numora 1.0.3 → 1.0.4
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.
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +8 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var N=Object.defineProperty;var f=(t,e,n)=>e in t?N(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var r=(t,e,n)=>f(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=t=>t.replace(/[^0-9.]/g,""),L=t=>t.replace(/(\..*?)\./g,"$1"),o=t=>L(y(t)),g=t=>t.replace(/,/g,"."),v=t=>[".",","].some(n=>t.key===n&&t.target&&t.target.value.includes(".")),a=(t,e)=>{const[n,i]=t.split(".");return i?`${n}.${i.slice(0,e)}`:t};function D(t,e){const n=t.target;n.value=g(n.value),n.value=o(n.value),n.value=a(n.value,e)}function b(t){v(t)&&t.preventDefault()}function C(t,e){var d;const n=t.target,{value:i,selectionStart:s,selectionEnd:E}=n,c=o(((d=t.clipboardData)==null?void 0:d.getData("text/plain"))||""),u=i.slice(0,s||0)+c+i.slice(E||0),[I,...h]=u.split("."),l=I+(h.length>0?"."+h.join(""):"");t.preventDefault(),n.value=a(l,e);const m=(s||0)+c.length-(u.length-l.length);return n.setSelectionRange(m,m),a(l,e)}const p=2;class A{constructor(e,{maxDecimals:n=p,onChange:i,...s}){r(this,"element");r(this,"options");this.options={maxDecimals:n,onChange:i,...s},this.createInputElement(e),this.setupEventListeners()}createInputElement(e){this.element=document.createElement("input"),this.element.setAttribute("minlength","1"),this.element.setAttribute("pattern","^[0-9]*[.,]?[0-9]*$"),this.element.setAttribute("spellcheck","false"),this.element.setAttribute("type","text"),this.element.setAttribute("inputmode","decimal");const{maxDecimals:n,onChange:i,...s}=this.options;Object.assign(this.element,s),e.appendChild(this.element)}setupEventListeners(){this.element.addEventListener("input",this.handleChange.bind(this)),this.element.addEventListener("keydown",this.handleKeyDown.bind(this)),this.element.addEventListener("paste",this.handlePaste.bind(this))}handleChange(e){D(e,this.options.maxDecimals||p),this.options.onChange&&this.options.onChange(e.target.value)}handleKeyDown(e){b(e)}handlePaste(e){C(e,this.options.maxDecimals),this.options.onChange&&this.options.onChange(e.target.value)}getValue(){return this.element.value}setValue(e){this.element.value=e}disable(){this.element.disabled=!0}enable(){this.element.disabled=!1}addEventListener(e,n){this.element.addEventListener(e,n)}removeEventListener(e,n){this.element.removeEventListener(e,n)}}exports.NumericInput=A;exports.alreadyHasDecimal=v;exports.handleOnChangeNumericInput=D;exports.handleOnKeyDownNumericInput=b;exports.handleOnPasteNumericInput=C;exports.replaceCommasWithDots=g;exports.sanitizeNumericInput=o;exports.trimToMaxDecimals=a;
|
package/dist/index.mjs
CHANGED
|
@@ -69,5 +69,12 @@ class N {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
export {
|
|
72
|
-
N as NumericInput
|
|
72
|
+
N as NumericInput,
|
|
73
|
+
f as alreadyHasDecimal,
|
|
74
|
+
A as handleOnChangeNumericInput,
|
|
75
|
+
I as handleOnKeyDownNumericInput,
|
|
76
|
+
x as handleOnPasteNumericInput,
|
|
77
|
+
L as replaceCommasWithDots,
|
|
78
|
+
p as sanitizeNumericInput,
|
|
79
|
+
o as trimToMaxDecimals
|
|
73
80
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "numora",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Framework-agnostic headless finance input library",
|
|
5
5
|
"homepage": "https://numora.netlify.app/",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
],
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
13
14
|
"import": "./dist/index.mjs",
|
|
14
|
-
"require": "./dist/index.js"
|
|
15
|
-
"types": "./dist/index.d.ts"
|
|
15
|
+
"require": "./dist/index.js"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|