diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index 7435821a5..6c3e06714 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -74,6 +74,7 @@ module.exports = { ['/api/style_manager', 'Style Manager'], ['/api/sector', `${subDivider}Sector`], ['/api/property', `${subDivider}Property`], + ['/api/property_number', `${subDivider}PropertyNumber`], ['/api/storage_manager', 'Storage Manager'], ['/api/device_manager', 'Device Manager'], ['/api/device', `${subDivider}Device`], diff --git a/docs/api.js b/docs/api.js index 797bdabe6..cf00bbf06 100644 --- a/docs/api.js +++ b/docs/api.js @@ -23,6 +23,7 @@ async function generateDocs () { ['style_manager/index.js', 'style_manager.md'], ['style_manager/model/Sector.js', 'sector.md'], ['style_manager/model/Property.js', 'property.md'], + ['style_manager/model/PropertyNumber.js', 'property_number.md'], ['storage_manager/index.js', 'storage_manager.md'], ['device_manager/index.js', 'device_manager.md'], ['device_manager/model/Device.js', 'device.md'], diff --git a/docs/api/property_number.md b/docs/api/property_number.md new file mode 100644 index 000000000..a966f9aaf --- /dev/null +++ b/docs/api/property_number.md @@ -0,0 +1,48 @@ + + +## PropertyNumber + +**Extends Property** + +### Properties + +* `units` **[Array][1]<[String][2]>** Array of units, eg. `['px', '%']` +* `min` **[Number][3]** Minimum value. +* `max` **[Number][3]** Maximum value. +* `step` **[Number][3]** Step value. + +### getUnits + +Get property units. + +Returns **[Array][1]<[String][2]>** + +### getUnit + +Get property unit value. + +Returns **[String][2]** + +### upUnit + +Update property unit value. +The change is also propagated to the selected targets. + +#### Parameters + +* `unit` **[String][2]** New unit value +* `opts` **[Object][4]** Options (optional, default `{}`) + + * `opts.noTarget` **[Boolean][5]** If `true` the change won't be propagated to selected targets. (optional, default `false`) + +Returns **[String][2]** + +[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array + +[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String + +[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number + +[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object + +[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean diff --git a/src/style_manager/model/Property.js b/src/style_manager/model/Property.js index 6ce06e0b2..367a1840b 100644 --- a/src/style_manager/model/Property.js +++ b/src/style_manager/model/Property.js @@ -56,6 +56,7 @@ export default class Property extends Model { } _up(props, opts = {}) { + if (opts.noTarget) opts.__up = true; const { partial, ...rest } = opts; props.__p = !!(rest.avoidStore || partial); return this.set(props, { ...rest, avoidStore: props.__p }); @@ -157,7 +158,6 @@ export default class Property extends Model { * @param {Boolean} [opts.noTarget=false] If `true` the change won't be propagated to selected targets. */ upValue(value, opts = {}) { - if (opts.noTarget) opts.__up = true; const parsed = value === null || value === '' ? this.__getClearProps() : this.__parseValue(value, opts); return this._up(parsed, opts); } @@ -169,7 +169,6 @@ export default class Property extends Model { * @param {Boolean} [opts.noTarget=false] If `true` the change won't be propagated to selected targets. */ clear(opts = {}) { - if (opts.noTarget) opts.__up = true; this._up(this.__getClearProps(), { ...opts, __clear: true }); } @@ -311,7 +310,7 @@ export default class Property extends Model { * Get a complete value of the property. * This probably will replace the getValue when all * properties models will be splitted - * @param {string} val Custom value to replace the one on the model + * @param {String} val Custom value to replace the one on the model * @return {string} * @private */ diff --git a/src/style_manager/model/PropertyNumber.js b/src/style_manager/model/PropertyNumber.js index 4ba4e0896..76bbaa755 100644 --- a/src/style_manager/model/PropertyNumber.js +++ b/src/style_manager/model/PropertyNumber.js @@ -5,7 +5,7 @@ import { hasWin } from 'utils/mixins'; /** * @typedef PropertyNumber - * @property {Array} units Array of units, eg. ['px', '%'] + * @property {Array} units Array of units, eg. `['px', '%']` * @property {Number} min Minimum value. * @property {Number} max Maximum value. * @property {Number} step Step value. @@ -39,8 +39,36 @@ export default class PropertyNumber extends Property { return this.get('unit'); } + /** + * Get min value. + * @returns {Number} + */ + getMin() { + return this.get('min'); + } + + /** + * Get max value. + * @returns {Number} + */ + getMax() { + return this.get('max'); + } + + /** + * Get step value. + * @returns {Number} + */ + getStep() { + return this.get('step'); + } + /** * Update property unit value. + * The change is also propagated to the selected targets. + * @param {String} unit New unit value + * @param {Object} [opts={}] Options + * @param {Boolean} [opts.noTarget=false] If `true` the change won't be propagated to selected targets. * @returns {String} */ upUnit(unit, opts) {