@ew-color-picker/input-number 2.0.4 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@
3
3
  * (c) 2024-2026 eveningwater(854806732@qq.com)
4
4
  * Released under the MIT License.
5
5
  */
6
- import { create, addClass, setAttr, upArrowIcon, downArrowIcon, insertNode, on, hasClass, removeClass, off, removeElement, isFunction, extend, DEFAULT_PREFIX, debounce, isUndefined, getPrefix } from '@ew-color-picker/utils';
6
+ import { create, addClass, setAttr, upArrowIcon, downArrowIcon, insertNode, on, hasClass, removeClass, off, removeElement, isFunction, extend, debounce, DEFAULT_PREFIX, ApplyOrder, isUndefined, getPrefix, $ } from '@ew-color-picker/utils';
7
7
 
8
8
  /******************************************************************************
9
9
  Copyright (c) Microsoft Corporation.
@@ -335,7 +335,7 @@ var ewColorPickerInputNumberPlugin = /** @class */ (function () {
335
335
  this.instances.set("default", inputNumber);
336
336
  var panelContainer = this.ewColorPicker.getMountPoint("panelContainer");
337
337
  if (panelContainer) {
338
- var bottomRow = panelContainer.querySelector(".".concat(prefix, "color-picker-bottom-row"));
338
+ var bottomRow = $(".".concat(prefix, "color-picker-bottom-row"), panelContainer);
339
339
  if (bottomRow) {
340
340
  bottomRow.appendChild(inputNumber.getElement());
341
341
  }
@@ -361,7 +361,7 @@ var ewColorPickerInputNumberPlugin = /** @class */ (function () {
361
361
  this.ewColorPicker = null;
362
362
  };
363
363
  ewColorPickerInputNumberPlugin.pluginName = "ewColorPickerInputNumber";
364
- ewColorPickerInputNumberPlugin.applyOrder = "post" /* ApplyOrder.Post */;
364
+ ewColorPickerInputNumberPlugin.applyOrder = ApplyOrder.Post;
365
365
  return ewColorPickerInputNumberPlugin;
366
366
  }());
367
367
 
@@ -1 +1 @@
1
- ((t,n)=>{"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@ew-color-picker/utils")):"function"==typeof define&&define.amd?define(["exports","@ew-color-picker/utils"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).InputNumber={},t.Utils)})(this,function(t,e){var n=function(){return(n=Object.assign||function(t){for(var n,i=1,e=arguments.length;i<e;i++)for(var o in n=arguments[i])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t}).apply(this,arguments)},i=(Object.defineProperty(o.prototype,"prefix",{get:function(){return this.options.prefix||e.DEFAULT_PREFIX},enumerable:!1,configurable:!0}),o.prototype.createElements=function(){var t=this.prefix,n=(this.container=e.create("div"),e.addClass(this.container,"".concat(t,"input-number")),e.addClass(this.container,"".concat(t,"input-number--").concat(this.options.size)),this.input=e.create("input"),e.addClass(this.input,"".concat(t,"input-number__input")),e.setAttr(this.input,{type:"text",inputmode:"decimal",placeholder:this.options.placeholder}),e.create("div"));e.addClass(n,"".concat(t,"input-number__buttons")),this.upButton=e.create("button"),e.addClass(this.upButton,"".concat(t,"input-number__button")),e.addClass(this.upButton,"".concat(t,"input-number__button--up")),e.setAttr(this.upButton,{type:"button"}),this.upButton.innerHTML=e.upArrowIcon("".concat(t,"input-number__icon"),void 0,t),this.downButton=e.create("button"),e.addClass(this.downButton,"".concat(t,"input-number__button")),e.addClass(this.downButton,"".concat(t,"input-number__button--down")),e.setAttr(this.downButton,{type:"button"}),this.downButton.innerHTML=e.downArrowIcon("".concat(t,"input-number__icon"),void 0,t),e.insertNode(n,this.upButton),e.insertNode(n,this.downButton),e.insertNode(this.container,this.input),e.insertNode(this.container,n),this.setStyles()},o.prototype.setStyles=function(){this.options.disabled&&this.setDisabled(!0)},o.prototype.bindEvents=function(){e.on(this.input,"input",this.handleInput.bind(this)),e.on(this.input,"blur",this.handleBlur.bind(this)),e.on(this.input,"focus",this.handleFocus.bind(this)),e.on(this.input,"keydown",this.handleKeydown.bind(this)),e.on(this.upButton,"click",this.handleUpClick.bind(this)),e.on(this.downButton,"click",this.handleDownClick.bind(this)),e.on(this.container,"wheel",this.handleWheel.bind(this))},o.prototype.handleInput=function(t){var t=t.target.value;""!==t&&"-"!==t&&"."!==t&&(t=parseFloat(t),isNaN(t)?this.input.value=this.currentValue.toString():this.currentValue=t)},o.prototype.handleBlur=function(t){this.isFocused=!1,this.removeClass(this.container,"".concat(this.prefix,"input-number--focused")),this.updateValue(this.currentValue,!1),this.options.onBlur(this.currentValue)},o.prototype.handleFocus=function(t){this.isFocused=!0,this.addClass(this.container,"".concat(this.prefix,"input-number--focused")),this.options.onFocus(t)},o.prototype.handleKeydown=function(t){switch(t.key){case"ArrowUp":t.preventDefault(),this.increment();break;case"ArrowDown":t.preventDefault(),this.decrement();break;case"Enter":t.preventDefault(),this.input.blur()}},o.prototype.handleUpClick=function(){this.options.disabled||this.increment()},o.prototype.handleDownClick=function(){this.options.disabled||this.decrement()},o.prototype.handleWheel=function(t){this.isFocused&&!this.options.disabled&&(t.preventDefault(),t.deltaY<0?this.increment():this.decrement())},o.prototype.increment=function(){var t=this.currentValue+this.options.step;this.updateValue(t)},o.prototype.decrement=function(){var t=this.currentValue-this.options.step;this.updateValue(t)},o.prototype.updateValue=function(t,n){void 0===n&&(n=!0);var i=this.options.min,e=this.options.max,i=(t<i?t=i:e<t&&(t=e),this.options.precision);t=Math.round(t*Math.pow(10,i))/Math.pow(10,i),this.currentValue=t,this.formatDisplayValue(),n&&this.debouncedOnChange(t)},o.prototype.formatDisplayValue=function(){var t=this.options.precision;this.input.value=this.currentValue.toFixed(t)},o.prototype.addClass=function(t,n){e.hasClass(t,n)||e.addClass(t,n)},o.prototype.removeClass=function(t,n){e.hasClass(t,n)&&e.removeClass(t,n)},o.prototype.getValue=function(){return this.currentValue},o.prototype.setValue=function(t,n){this.updateValue(t,n=void 0===n?!0:n)},o.prototype.setDisabled=function(t){(this.options.disabled=t)?(this.addClass(this.container,"".concat(this.prefix,"input-number--disabled")),e.setAttr(this.input,{disabled:"true"}),e.setAttr(this.upButton,{disabled:"true"}),e.setAttr(this.downButton,{disabled:"true"})):(this.removeClass(this.container,"".concat(this.prefix,"input-number--disabled")),e.setAttr(this.input,{disabled:"false"}),e.setAttr(this.upButton,{disabled:"false"}),e.setAttr(this.downButton,{disabled:"false"}))},o.prototype.getElement=function(){return this.container},o.prototype.destroy=function(){var t;e.off(this.input,"input",this.handleInput.bind(this)),e.off(this.input,"blur",this.handleBlur.bind(this)),e.off(this.input,"focus",this.handleFocus.bind(this)),e.off(this.input,"keydown",this.handleKeydown.bind(this)),e.off(this.upButton,"click",this.handleUpClick.bind(this)),e.off(this.downButton,"click",this.handleDownClick.bind(this)),e.off(this.container,"wheel",this.handleWheel.bind(this)),null!=(t=this.container)&&t.parentNode&&e.removeElement(this.container),this.container=null,this.input=null,this.upButton=null,this.downButton=null},o.prototype.install=function(t){var n;this.ewColorPicker=t,null!=(n=this.handleOptions)&&n.call(this),!1!==(null==(n=this.ewColorPicker.options)?void 0:n.showInputNumber)&&(e.isFunction(t.on)&&t.on("change",function(){}),null!=(n=this.run))&&n.call(this)},o);function o(t){void 0===t&&(t={});var n={value:0,min:-1/0,max:1/0,step:1,precision:0,disabled:this.isFocused=!1,placeholder:"",size:"default",prefix:e.DEFAULT_PREFIX,onChange:function(){},onBlur:function(){},onFocus:function(){}};this.options=e.extend(n,t),this.currentValue=null!=(n=this.options.value)?n:0,this.debouncedOnChange=e.debounce(this.options.onChange,300),this.createElements(),this.bindEvents(),this.updateValue(this.currentValue,!1)}u.prototype.install=function(t){this.ewColorPicker=t,this.handleOptions(),this.run()},u.prototype.updateOptions=function(){var n=this;this.handleOptions(),this.instances.forEach(function(t){e.isUndefined(n.options.disabled)||t.setDisabled(n.options.disabled)})},u.prototype.run=function(){var t,n,i;this.ewColorPicker&&(t=e.getPrefix(this.ewColorPicker),n=this.createInputNumber({value:0,disabled:this.options.disabled||!1,prefix:t}),this.instances.set("default",n),i=this.ewColorPicker.getMountPoint("panelContainer"))&&(i=i.querySelector(".".concat(t,"color-picker-bottom-row")))&&i.appendChild(n.getElement())},u.prototype.handleOptions=function(){var t=null==(t=this.ewColorPicker)?void 0:t.options;t&&(this.options=n(n(n({},this.options),t),{disabled:e.isUndefined(t.disabled)?this.options.disabled||!1:t.disabled}))},u.prototype.createInputNumber=function(t){return new i(t)},u.prototype.destroy=function(){this.instances.forEach(function(t){t.destroy()}),this.instances.clear(),this.ewColorPicker=null},u.pluginName="ewColorPickerInputNumber",u.applyOrder="post";var s=u;function u(t){this.options={},this.instances=new Map,this.ewColorPicker=t,this.handleOptions()}t.InputNumber=i,t.default=s,t.ewColorPickerInputNumberPlugin=s,Object.defineProperty(t,"__esModule",{value:!0})});
1
+ ((t,n)=>{"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@ew-color-picker/utils")):"function"==typeof define&&define.amd?define(["exports","@ew-color-picker/utils"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).InputNumber={},t.Utils)})(this,function(t,e){var n=function(){return(n=Object.assign||function(t){for(var n,i=1,e=arguments.length;i<e;i++)for(var o in n=arguments[i])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t}).apply(this,arguments)},i=(Object.defineProperty(o.prototype,"prefix",{get:function(){return this.options.prefix||e.DEFAULT_PREFIX},enumerable:!1,configurable:!0}),o.prototype.createElements=function(){var t=this.prefix,n=(this.container=e.create("div"),e.addClass(this.container,"".concat(t,"input-number")),e.addClass(this.container,"".concat(t,"input-number--").concat(this.options.size)),this.input=e.create("input"),e.addClass(this.input,"".concat(t,"input-number__input")),e.setAttr(this.input,{type:"text",inputmode:"decimal",placeholder:this.options.placeholder}),e.create("div"));e.addClass(n,"".concat(t,"input-number__buttons")),this.upButton=e.create("button"),e.addClass(this.upButton,"".concat(t,"input-number__button")),e.addClass(this.upButton,"".concat(t,"input-number__button--up")),e.setAttr(this.upButton,{type:"button"}),this.upButton.innerHTML=e.upArrowIcon("".concat(t,"input-number__icon"),void 0,t),this.downButton=e.create("button"),e.addClass(this.downButton,"".concat(t,"input-number__button")),e.addClass(this.downButton,"".concat(t,"input-number__button--down")),e.setAttr(this.downButton,{type:"button"}),this.downButton.innerHTML=e.downArrowIcon("".concat(t,"input-number__icon"),void 0,t),e.insertNode(n,this.upButton),e.insertNode(n,this.downButton),e.insertNode(this.container,this.input),e.insertNode(this.container,n),this.setStyles()},o.prototype.setStyles=function(){this.options.disabled&&this.setDisabled(!0)},o.prototype.bindEvents=function(){e.on(this.input,"input",this.handleInput.bind(this)),e.on(this.input,"blur",this.handleBlur.bind(this)),e.on(this.input,"focus",this.handleFocus.bind(this)),e.on(this.input,"keydown",this.handleKeydown.bind(this)),e.on(this.upButton,"click",this.handleUpClick.bind(this)),e.on(this.downButton,"click",this.handleDownClick.bind(this)),e.on(this.container,"wheel",this.handleWheel.bind(this))},o.prototype.handleInput=function(t){var t=t.target.value;""!==t&&"-"!==t&&"."!==t&&(t=parseFloat(t),isNaN(t)?this.input.value=this.currentValue.toString():this.currentValue=t)},o.prototype.handleBlur=function(t){this.isFocused=!1,this.removeClass(this.container,"".concat(this.prefix,"input-number--focused")),this.updateValue(this.currentValue,!1),this.options.onBlur(this.currentValue)},o.prototype.handleFocus=function(t){this.isFocused=!0,this.addClass(this.container,"".concat(this.prefix,"input-number--focused")),this.options.onFocus(t)},o.prototype.handleKeydown=function(t){switch(t.key){case"ArrowUp":t.preventDefault(),this.increment();break;case"ArrowDown":t.preventDefault(),this.decrement();break;case"Enter":t.preventDefault(),this.input.blur()}},o.prototype.handleUpClick=function(){this.options.disabled||this.increment()},o.prototype.handleDownClick=function(){this.options.disabled||this.decrement()},o.prototype.handleWheel=function(t){this.isFocused&&!this.options.disabled&&(t.preventDefault(),t.deltaY<0?this.increment():this.decrement())},o.prototype.increment=function(){var t=this.currentValue+this.options.step;this.updateValue(t)},o.prototype.decrement=function(){var t=this.currentValue-this.options.step;this.updateValue(t)},o.prototype.updateValue=function(t,n){void 0===n&&(n=!0);var i=this.options.min,e=this.options.max,i=(t<i?t=i:e<t&&(t=e),this.options.precision);t=Math.round(t*Math.pow(10,i))/Math.pow(10,i),this.currentValue=t,this.formatDisplayValue(),n&&this.debouncedOnChange(t)},o.prototype.formatDisplayValue=function(){var t=this.options.precision;this.input.value=this.currentValue.toFixed(t)},o.prototype.addClass=function(t,n){e.hasClass(t,n)||e.addClass(t,n)},o.prototype.removeClass=function(t,n){e.hasClass(t,n)&&e.removeClass(t,n)},o.prototype.getValue=function(){return this.currentValue},o.prototype.setValue=function(t,n){this.updateValue(t,n=void 0===n?!0:n)},o.prototype.setDisabled=function(t){(this.options.disabled=t)?(this.addClass(this.container,"".concat(this.prefix,"input-number--disabled")),e.setAttr(this.input,{disabled:"true"}),e.setAttr(this.upButton,{disabled:"true"}),e.setAttr(this.downButton,{disabled:"true"})):(this.removeClass(this.container,"".concat(this.prefix,"input-number--disabled")),e.setAttr(this.input,{disabled:"false"}),e.setAttr(this.upButton,{disabled:"false"}),e.setAttr(this.downButton,{disabled:"false"}))},o.prototype.getElement=function(){return this.container},o.prototype.destroy=function(){var t;e.off(this.input,"input",this.handleInput.bind(this)),e.off(this.input,"blur",this.handleBlur.bind(this)),e.off(this.input,"focus",this.handleFocus.bind(this)),e.off(this.input,"keydown",this.handleKeydown.bind(this)),e.off(this.upButton,"click",this.handleUpClick.bind(this)),e.off(this.downButton,"click",this.handleDownClick.bind(this)),e.off(this.container,"wheel",this.handleWheel.bind(this)),null!=(t=this.container)&&t.parentNode&&e.removeElement(this.container),this.container=null,this.input=null,this.upButton=null,this.downButton=null},o.prototype.install=function(t){var n;this.ewColorPicker=t,null!=(n=this.handleOptions)&&n.call(this),!1!==(null==(n=this.ewColorPicker.options)?void 0:n.showInputNumber)&&(e.isFunction(t.on)&&t.on("change",function(){}),null!=(n=this.run))&&n.call(this)},o);function o(t){void 0===t&&(t={});var n={value:0,min:-1/0,max:1/0,step:1,precision:0,disabled:this.isFocused=!1,placeholder:"",size:"default",prefix:e.DEFAULT_PREFIX,onChange:function(){},onBlur:function(){},onFocus:function(){}};this.options=e.extend(n,t),this.currentValue=null!=(n=this.options.value)?n:0,this.debouncedOnChange=e.debounce(this.options.onChange,300),this.createElements(),this.bindEvents(),this.updateValue(this.currentValue,!1)}u.prototype.install=function(t){this.ewColorPicker=t,this.handleOptions(),this.run()},u.prototype.updateOptions=function(){var n=this;this.handleOptions(),this.instances.forEach(function(t){e.isUndefined(n.options.disabled)||t.setDisabled(n.options.disabled)})},u.prototype.run=function(){var t,n,i;this.ewColorPicker&&(i=e.getPrefix(this.ewColorPicker),t=this.createInputNumber({value:0,disabled:this.options.disabled||!1,prefix:i}),this.instances.set("default",t),n=this.ewColorPicker.getMountPoint("panelContainer"))&&(i=e.$(".".concat(i,"color-picker-bottom-row"),n))&&i.appendChild(t.getElement())},u.prototype.handleOptions=function(){var t=null==(t=this.ewColorPicker)?void 0:t.options;t&&(this.options=n(n(n({},this.options),t),{disabled:e.isUndefined(t.disabled)?this.options.disabled||!1:t.disabled}))},u.prototype.createInputNumber=function(t){return new i(t)},u.prototype.destroy=function(){this.instances.forEach(function(t){t.destroy()}),this.instances.clear(),this.ewColorPicker=null},u.pluginName="ewColorPickerInputNumber",u.applyOrder=e.ApplyOrder.Post;var s=u;function u(t){this.options={},this.instances=new Map,this.ewColorPicker=t,this.handleOptions()}t.InputNumber=i,t.default=s,t.ewColorPickerInputNumberPlugin=s,Object.defineProperty(t,"__esModule",{value:!0})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ew-color-picker/input-number",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "EW Color Picker Input Number Plugin",
5
5
  "main": "dist/input-number.min.js",
6
6
  "module": "dist/input-number.esm.js",
@@ -19,16 +19,16 @@
19
19
  "author": "eveningwater(854806732@qq.com)",
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
- "@ew-color-picker/core": "^2.0.4",
23
- "@ew-color-picker/utils": "^2.0.4"
22
+ "@ew-color-picker/utils": "^2.0.5",
23
+ "@ew-color-picker/core": "^2.0.5"
24
24
  },
25
25
  "devDependencies": {
26
26
  "rollup": "^3.0.0",
27
27
  "rollup-plugin-typescript2": "^0.34.0",
28
28
  "typescript": "^4.9.0",
29
29
  "rimraf": "^3.0.2",
30
- "@ew-color-picker/core": "2.0.4",
31
- "@ew-color-picker/utils": "2.0.4"
30
+ "@ew-color-picker/core": "2.0.5",
31
+ "@ew-color-picker/utils": "2.0.5"
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public"