numora 1.0.1 → 1.0.2

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -0
  2. package/package.json +9 -8
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var b=Object.defineProperty;var E=(t,e,n)=>e in t?b(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var l=(t,e,n)=>E(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=t=>t.replace(/[^0-9.]/g,""),D=t=>t.replace(/(\..*?)\./g,"$1"),p=t=>D(C(t)),f=t=>t.replace(/,/g,"."),L=t=>[".",","].some(n=>t.key===n&&t.target&&t.target.value.includes(".")),o=(t,e)=>{const[n,s]=t.split(".");return s?`${n}.${s.slice(0,e)}`:t};function y(t,e){const n=t.target;n.value=f(n.value),n.value=p(n.value),n.value=o(n.value,e)}function I(t){L(t)&&t.preventDefault()}function A(t,e){var m;const n=t.target,{value:s,selectionStart:i,selectionEnd:g}=n,r=p(((m=t.clipboardData)==null?void 0:m.getData("text/plain"))||""),c=s.slice(0,i||0)+r+s.slice(g||0),[v,...h]=c.split("."),a=v+(h.length>0?"."+h.join(""):"");t.preventDefault(),n.value=o(a,e);const u=(i||0)+r.length-(c.length-a.length);return n.setSelectionRange(u,u),o(a,e)}const d=2;class N{constructor(e,{maxDecimals:n=d,onChange:s,...i}){l(this,"element");l(this,"options");this.options={maxDecimals:n,onChange:s,...i},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:s,...i}=this.options;Object.assign(this.element,i),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){y(e,this.options.maxDecimals||d),this.options.onChange&&this.options.onChange(e.target.value)}handleKeyDown(e){I(e)}handlePaste(e){A(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=N;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "numora",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Framework-agnostic headless finance input library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -9,7 +9,8 @@
9
9
  ],
10
10
  "exports": {
11
11
  ".": {
12
- "import": "./dist/index.js",
12
+ "import": "./dist/index.mjs",
13
+ "require": "./dist/index.js",
13
14
  "types": "./dist/index.d.ts"
14
15
  }
15
16
  },
@@ -17,6 +18,11 @@
17
18
  "type": "git",
18
19
  "url": "https://github.com/Sharqiewicz/numora"
19
20
  },
21
+ "scripts": {
22
+ "build": "vite build && tsc --emitDeclarationOnly",
23
+ "test": "vitest run",
24
+ "dev": "vite build --watch"
25
+ },
20
26
  "keywords": [
21
27
  "numeric input",
22
28
  "currency input",
@@ -54,10 +60,5 @@
54
60
  "typescript": "^5.8.2",
55
61
  "vite": "^6.2.2",
56
62
  "vitest": "^3.0.9"
57
- },
58
- "scripts": {
59
- "build": "vite build && tsc --emitDeclarationOnly",
60
- "test": "vitest run",
61
- "dev": "vite build --watch"
62
63
  }
63
- }
64
+ }