numora 0.0.2 → 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.
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # numora
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/numora.svg)](https://www.npmjs.com/package/numora)
4
+
3
5
  A lightweight, framework-agnostic numeric input library for handling currency and decimal inputs in **financial/DeFi** applications. Built with TypeScript with **zero-dependencies**.
4
6
 
5
7
  ## Features
@@ -56,7 +58,7 @@ Numora is also available for popular frameworks:
56
58
 
57
59
  - React: `numora-react`
58
60
  - Vue: `numora-vue`
59
- - Svelte: `numora-svelte`
61
+ - Svelte: `numora`
60
62
 
61
63
  ## License
62
64
 
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": "0.0.2",
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,13 +9,14 @@
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
  },
16
17
  "repository": {
17
18
  "type": "git",
18
- "url": "https://github.com/Sharqiewicz/numora/tree/main/packages/core"
19
+ "url": "https://github.com/Sharqiewicz/numora"
19
20
  },
20
21
  "scripts": {
21
22
  "build": "vite build && tsc --emitDeclarationOnly",