numora 3.2.0 → 3.4.0
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/NumoraInput.d.ts +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +297 -267
- package/dist/types.d.ts +1 -2
- package/dist/utils/locale.d.ts +3 -6
- package/package.json +1 -1
package/dist/NumoraInput.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export interface NumoraInputOptions extends Partial<Omit<HTMLInputElement, 'valu
|
|
|
6
6
|
decimalSeparator?: string;
|
|
7
7
|
decimalMaxLength?: number;
|
|
8
8
|
decimalMinLength?: number;
|
|
9
|
+
locale?: string | true;
|
|
9
10
|
enableCompactNotation?: boolean;
|
|
10
11
|
enableNegative?: boolean;
|
|
11
12
|
enableLeadingZeros?: boolean;
|
|
@@ -19,7 +20,7 @@ export declare class NumoraInput {
|
|
|
19
20
|
private resolvedOptions;
|
|
20
21
|
private rawValue;
|
|
21
22
|
private caretPositionBeforeChange?;
|
|
22
|
-
constructor(container: HTMLElement, { decimalMaxLength, decimalMinLength, formatOn, thousandSeparator, thousandStyle, decimalSeparator, enableCompactNotation, enableNegative, enableLeadingZeros, rawValueMode, onChange, ...rest }: NumoraInputOptions);
|
|
23
|
+
constructor(container: HTMLElement, { decimalMaxLength, decimalMinLength, formatOn, thousandSeparator, thousandStyle, decimalSeparator, locale, enableCompactNotation, enableNegative, enableLeadingZeros, rawValueMode, onChange, ...rest }: NumoraInputOptions);
|
|
23
24
|
private createInputElement;
|
|
24
25
|
private setupEventListeners;
|
|
25
26
|
private getResolvedOptions;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from './NumoraInput';
|
|
2
2
|
export { ThousandStyle, FormatOn } from './types';
|
|
3
|
-
export { getSeparatorsFromLocale,
|
|
3
|
+
export { getSeparatorsFromLocale, applyLocale } from './utils/locale';
|
|
4
4
|
export { handleOnChangeNumoraInput, handleOnPasteNumoraInput, handleOnKeyDownNumoraInput, } from './utils/event-handlers';
|
|
5
5
|
export { formatValueForDisplay, formatInputValue, } from './utils/format-utils';
|
|
6
6
|
export type { FormattingOptions, CaretPositionInfo } from './types';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var oe=Object.defineProperty;var le=(e,t,n)=>t in e?oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var D=(e,t,n)=>le(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var p=(e=>(e.Blur="blur",e.Change="change",e))(p||{}),E=(e=>(e.None="none",e.Thousand="thousand",e.Lakh="lakh",e.Wan="wan",e.Locale="locale",e))(E||{});const G=2,Z=0,P=p.Blur,he=",",H=E.None,$=".",k=!1,B=!1,W=!1,U=!1;function y(e){return e.replace(/[-[\]/{}()*+?.\\^$|]/g,"\\$&")}const z=new Map;function O(e,t="g"){const n=`${e}:${t}`;let r=z.get(n);return r||(r=new RegExp(e,t),z.set(n,r)),r}function ue(e,t="g"){const n=y(e);return O(n,t)}const de=/[.,]/g;function _(e){return{decimalSeparator:(e==null?void 0:e.decimalSeparator)??$,thousandSeparator:e==null?void 0:e.thousandSeparator}}function Y(e,t){const n=e.startsWith("-"),r=n?e.slice(1):e,[a="",i=""]=r.split(t);return{sign:n?"-":"",integer:a,decimal:i}}function fe(e,t){if(!e.value.includes(t))return!1;const{selectionStart:n,selectionEnd:r,value:a}=e;return!a.slice(n??0,r??0).includes(t)}function ge(e,t,n){const{key:r}=e;if(r!==","&&r!==".")return!1;if(fe(t,n))return!0;if(r!==n){const{selectionStart:a,selectionEnd:i,value:s}=t,c=a??0,l=i??c;t.value=s.slice(0,c)+n+s.slice(l);const o=c+1;return t.setSelectionRange(o,o),!0}return!1}const Se=(e,t,n=$)=>{const{sign:r,integer:a,decimal:i}=Y(e,n);if(!i)return e;const s=i.slice(0,t);return`${r}${a}${n}${s}`},Ee=(e,t=$)=>{const n=e.indexOf(t);if(n===-1||n===e.length-1)return e;const r=e.slice(0,n+1),a=e.slice(n+1),s=t==="."||t===","?de:O("[,\\."+y(t)+"]","g");return r+a.replace(s,"")},me=(e,t=0,n=$)=>{if(t<=0)return e;const{sign:r,integer:a,decimal:i}=Y(e,n);if(i.length>=t)return e;const s=i.padEnd(t,"0");return`${r}${a}${n}${s}`},v={thousand:{size:3},lakh:{firstGroup:3,restGroup:2},wan:{size:4}},pe=/^(0+)/;function Q(e,t,n=E.Thousand,r=!1,a="."){if(!e||e==="0"||e===a||e==="-"||e===`-${a}`)return e;const i=e.includes(a),s=e.startsWith("-"),c=s?e.slice(1):e,[l,o]=c.split(a);if(!l){const u=o?`${a}${o}`:c;return s?`-${u}`:u}if(r&&l.startsWith("0")&&l.length>1){const u=l.match(pe);if(u){const g=u[1],S=l.slice(g.length);if(S){const m=J(S,t,n),f=g+m,b=s?"-":"";return i?o?`${b}${f}${a}${o}`:`${b}${f}${a}`:`${b}${f}`}}}const h=J(l,t,n),d=s?"-":"";return i?o?`${d}${h}${a}${o}`:`${d}${h}${a}`:`${d}${h}`}function J(e,t,n){if(e==="0"||e==="")return e;switch(n){case E.None:return e;case E.Thousand:return X(e,t,v.thousand.size);case E.Lakh:return be(e,t);case E.Wan:return X(e,t,v.wan.size);default:return e}}function be(e,t){if(e.length<=v.lakh.firstGroup)return e;const n=[],r=e.length-v.lakh.firstGroup;n.unshift(e.slice(r));for(let a=r;a>0;a-=v.lakh.restGroup)n.unshift(e.slice(Math.max(0,a-v.lakh.restGroup),a));return n.join(t)}function X(e,t,n){const r=[];for(let a=e.length;a>0;a-=n)r.unshift(e.slice(Math.max(0,a-n),a));return r.join(t)}function Le(e,t,n){return(t==null?void 0:t.formatOn)===p.Change&&t.thousandSeparator?Q(e,t.thousandSeparator,t.ThousandStyle??E.None,t.enableLeadingZeros,(n==null?void 0:n.decimalSeparator)??$):e}function N(e,t,n){let r=0;for(let a=0;a<t&&a<e.length;a++)e[a]!==n&&r++;return r}function Ne(e,t,n){if(t===0)return 0;let r=0;for(let a=0;a<e.length;a++)if(e[a]!==n){if(r===t-1)return a+1;r++}return e.length}function T(e,t,n){if(t===0)return 0;let r=0;for(let a=0;a<e.length;a++)if(e[a]!==n){if(r++,r===t)return a+1;if(r>t)return a}return e.length}function V(e,t,n){return t<0||t>=e.length?!1:e[t]===n}const ve=/\d/;function $e(e,t={}){const{thousandSeparator:n,decimalSeparator:r=".",prefix:a="",suffix:i=""}=t,s=new Array(e.length+1).fill(!0);if(a&&s.fill(!1,0,a.length),i){const c=e.length-i.length;s.fill(!1,c+1,e.length+1)}for(let c=0;c<e.length;c++){const l=e[c];(n&&l===n||l===r)&&(s[c]=!1,c+1<e.length&&!ve.test(e[c+1])&&(s[c+1]=!1))}return s.some(c=>c)||s.fill(!0),s}function x(e,t,n,r){const a=e.length;if(t=Math.max(0,Math.min(t,a)),!n[t]){let i=t;for(;i<=a&&!n[i];)i++;let s=t;for(;s>=0&&!n[s];)s--;i<=a&&s>=0?t=t-s<i-t?s:i:i<=a?t=i:s>=0&&(t=s)}return(t===-1||t>a)&&(t=a),t}const j=/(\d+\.?\d*)\s*[kmbt]$/i,De=(e,t)=>e===t;function ye(e,t,n,r,a,i,s=".",c={}){if(n<0)return 0;if(n>e.length||e===""||t===""||j.test(e)&&!j.test(t)&&t.length>e.length&&n>=e.length-1)return t.length;const l=t.length<e.length,o=V(e,n,r),h=e.indexOf(s),d=t.indexOf(s);if(c.isCharacterEquivalent&&e!==t){const f=we(e,t,n,c.isCharacterEquivalent||De,i,c);if(f!==void 0)return f}const g=new Map,S=(f,b,w)=>{const C=`${f===e?"o":"n"}:${b}`;return g.has(C)||g.set(C,N(f,b,r)),g.get(C)};if(l)return Ce(e,t,n,r,o,h,d,i,c,S);const m=Re(e,t,n,r,o,S);return c.boundary?x(t,m,c.boundary):m}function we(e,t,n,r,a,i){const s=e.length,c=t.length;let l=0,o=0,h=c;for(let u=0;u<s;u++){let g=-1;for(let S=l;S<c;S++)if(r(e[u],t[S],{oldValue:e,newValue:t,typedRange:a,oldIndex:u,newIndex:S})){g=S;break}g!==-1&&(l=g+1,u<n?o=g+1:h===c&&/\d/.test(e[u])&&(h=g))}if(o>h)return h;const d=n-o<h-n?o:h;return i.boundary?x(t,d,i.boundary):d}function Ce(e,t,n,r,a,i,s,c,l={},o=N){if(a)return Ie(e,t,n,r,s,o);const h=o(e,n,r),d=o(e,e.length,r),u=o(t,t.length,r),g=d-u,S=Me(e,n,r,h,g,i,c,o),m=i===-1||n<=i,f=Ae(t,S,r,g,c,m,s,o);return l.boundary?x(t,f,l.boundary):f}function Ie(e,t,n,r,a,i=N){const s=n+1;if(s<e.length){const c=i(e,s,r),l=Ne(t,c,r);return l<t.length&&t[l]!==r?l+1:l}return n}function Me(e,t,n,r,a,i,s,c=N){if(s){const{start:o,isDelete:h}=s;return h?c(e,o,n):Math.max(0,c(e,o,n))}return t>0&&e[t-1]===n&&a>0?r+1:r}function K(e,t,n,r,a,i,s=N){if(t>0&&t<e.length&&s(e,t,r)===n){if(e[t]===r&&i&&a>0&&t<e.length-1)return t+1;if(!i&&a>0&&t<e.length-1)return Math.min(t+1,e.length)}return t}function Ae(e,t,n,r,a,i,s,c=N){if(i&&s!==-1){const o=e.substring(0,s),h=c(o,o.length,n);if(t<=h){const d=T(o,t,n);return K(o,d,t,n,r,a,c)}}const l=T(e,t,n);return K(e,l,t,n,r,a,c)}function Re(e,t,n,r,a,i=N){const s=n>=e.length,c=i(e,n,r),l=i(e,e.length,r),o=i(t,t.length,r);if(s||c===l)return t.length;const h=o-l;let d=c;h>0&&!s&&c<l&&(d=c+1);const u=T(t,d,r);return a&&!V(t,u,r)?Math.max(0,u-1):u}function Te(e,t,n){const{selectionStart:r,selectionEnd:a,endOffset:i=0}=e;if(r!==a){const h=a-r;return{start:r,end:a,deletedLength:h,isDelete:!1}}if(i>0){const h=i;return{start:r,end:r+h,deletedLength:h,isDelete:!0}}const c=t.length,l=n.length,o=c-l;if(!(o<=0))return{start:r,end:r+o,deletedLength:o,isDelete:!1}}function Oe(e,t){if(e===t)return;let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;let r=e.length-1,a=t.length-1;for(;r>=n&&a>=n&&e[r]===t[a];)r--,a--;const i=r-n+1,s=a-n+1;if(!(i===0&&s===0))return{start:n,end:r+1,deletedLength:i,isDelete:i>s}}function q(e,t){if(e.value=e.value,e===null)return!1;if(e.createTextRange){const n=e.createTextRange();return n.move("character",t),n.select(),!0}return e.selectionStart!==null||e.selectionStart===0?(e.focus(),e.setSelectionRange(t,t),!0):(e.focus(),!1)}function _e(e,t,n){return e.selectionStart===0&&e.selectionEnd===e.value.length?null:(q(e,t),setTimeout(()=>{e.value===n&&e.selectionStart!==t&&q(e,t)},0))}function xe(e){return Math.max(e.selectionStart,e.selectionEnd)}function Ge(e,t,n){if((n==null?void 0:n.formatOn)!==p.Change||!n.thousandSeparator)return;const{selectionStart:r,selectionEnd:a,value:i}=t;if(r===null||a===null||r!==a)return;const{key:s}=e,c=n.thousandSeparator;s==="Backspace"&&r>0&&i[r-1]===c&&t.setSelectionRange(r-1,r-1),s==="Delete"&&i[r]===c&&t.setSelectionRange(r+1,r+1)}function Ze(e,t,n,r,a,i,s){if(!a)return;const{selectionStart:c=0,selectionEnd:l=0,endOffset:o=0}=a;let h=Te({selectionStart:c,selectionEnd:l,endOffset:o},t,n);if(h||(h=Oe(t,n)),!h)return;const d=$e(n,{thousandSeparator:(s==null?void 0:s.thousandSeparator)??i.thousandSeparator,decimalSeparator:i.decimalSeparator}),u={thousandSeparator:(s==null?void 0:s.thousandSeparator)??i.thousandSeparator,isCharacterEquivalent:(f,b)=>{const w=(s==null?void 0:s.thousandSeparator)??i.thousandSeparator;return w&&f===w?!1:f===b},boundary:d},g=(s==null?void 0:s.thousandSeparator)??i.thousandSeparator??",",S=(s==null?void 0:s.ThousandStyle)??E.None,m=ye(t,n,r,g,S,h,i.decimalSeparator,u);_e(e,m,n)}const Pe=(e,t=!1,n=".")=>{const r=y(n),a=O(`[^0-9${r}]`,"g");if(!t)return e.replace(a,"");const i=e.startsWith("-"),s=e.replace(a,"");return i&&(s.length>0||e==="-")?"-"+s:s},ke=/([+-]?\d+\.?\d*)[eE]([+-]?\d+)/g,F=/^0+$/,A=/\.?0+$/;function Be(e){return!e.includes("e")&&!e.includes("E")?e:e.replace(ke,(t,n,r)=>{const a=parseInt(r,10);if(a===0)return n;const i=n.startsWith("-"),s=i?n.slice(1):n,[c,l=""]=s.split("."),o=a>0?We(c,l,a):Ue(c,l,Math.abs(a));return i?"-"+o:o})}function We(e,t,n){const r=e+t;if(r==="0"||F.test(r))return"0";const a=t.length;if(n<=a){const s=r.slice(0,e.length+n),c=r.slice(e.length+n);return c?`${s}.${c}`:s}const i=n-a;return r+"0".repeat(i)}function Ue(e,t,n){const r=e+t;if(r==="0"||F.test(r))return"0";const i=e.length-n;if(i<=0){const s=Math.abs(i),c=`0.${"0".repeat(s)}${r}`;return R(c)}if(i<e.length){const s=r.slice(0,i),c=r.slice(i),l=`${s}.${c}`;return R(l)}return R(r)}function R(e){if(!e.includes("."))return e;if(e==="0.")return"0";if(e.startsWith("0.")){const t=e.replace(A,"");return t==="0"?"0":t||"0"}if(e.startsWith("-0.")){const t=e.replace(A,"");return t==="-0"||t==="0"?"0":t||"0"}return e.replace(A,"")||e}const ze=/(\d+\.?\d*)\s*([kmbt])/gi,Je=/^0+/,Xe=/^(-?)0+([1-9])/,je=/^-?0+$/,Ke=/\.?0+$/,qe={k:3,m:6,b:9,t:12};function He(e){return e.replace(ze,(t,n,r)=>{const a=r.toLowerCase(),i=qe[a];if(!i)return t;const[s,c=""]=n.split("."),l=s.replace(Je,"")||"0";let o;if(c.length===0)o=l+"0".repeat(i);else if(c.length<=i){const h=i-c.length;o=l+c+"0".repeat(h)}else{const h=c.slice(0,i),d=c.slice(i);o=l+h+"."+d}return o=o.replace(Xe,"$1$2"),je.test(o)&&(o="0"),o.includes(".")&&(o=o.replace(Ke,"")),o})}function Ye(e){if(!e||e==="0"||e==="-0"||e==="-"||e===".")return e;const t=e.startsWith("-"),n=t?e.slice(1):e;if(n===".")return e;if(n.includes(".")){const[a,i]=n.split(".");if(a){const c=(a.replace(/^0+/,"")||"0")+"."+i;return t?"-"+c:c}return e}if(n.startsWith("0")){const a=n.replace(/^0+/,"")||"0";return t?"-"+a:a}return e}function Qe(e){return e.replace(/[\s\u200B]/g,"")}function L(e,t){const n=ue(t);return e.replace(n,"")}const Ve=(e,t)=>{let n=Qe(e);return t!=null&&t.thousandSeparator&&(n=L(n,t.thousandSeparator)),t!=null&&t.enableCompactNotation&&(n=He(n)),n=Be(n),n=Pe(n,t==null?void 0:t.enableNegative,t==null?void 0:t.decimalSeparator),n=Ee(n,t==null?void 0:t.decimalSeparator),t!=null&&t.enableLeadingZeros||(n=Ye(n)),n};function Fe(e,t,n){return{enableCompactNotation:e==null?void 0:e.enableCompactNotation,enableNegative:e==null?void 0:e.enableNegative,enableLeadingZeros:e==null?void 0:e.enableLeadingZeros,decimalSeparator:t.decimalSeparator,thousandSeparator:n?t.thousandSeparator:void 0}}function M(e,t,n,r){const a=_(n),i=r??(n==null?void 0:n.formatOn)===p.Change,s=Ve(e,Fe(n,a,i)),c=Se(s,t,a.decimalSeparator),l=(n==null?void 0:n.decimalMinLength)??0,o=me(c,l,a.decimalSeparator);return{formatted:Le(o,n,a),raw:o}}function et(e,t,n){const r=!!(n!=null&&n.thousandSeparator);return M(e,t,n,r)}function tt(e,t,n){if(e==="Backspace"||e==="Delete")return e==="Delete"&&t===n?{endOffset:1}:{endOffset:0}}function ee(e,t){const{decimalSeparator:n}=_(t),r=e.target;if(ge(e,r,n)){e.preventDefault();return}return Ge(e,r,t),tt(e.key,r.selectionStart,r.selectionEnd)}function te(e,t,n,r){const a=e.target,i=a.value,s=xe(a),c=_(r),l=(r==null?void 0:r.formatOn)===p.Change,{formatted:o,raw:h}=M(i,t,r,l);return a.value=o,i!==o&&Ze(a,i,o,s,n,c,r),{formatted:o,raw:h}}function nt(e,t,n,r){const a=r-n;return e+t+a}function ne(e,t,n){var u;e.preventDefault();const r=e.target,{value:a,selectionStart:i,selectionEnd:s}=r,c=((u=e.clipboardData)==null?void 0:u.getData("text/plain"))||"",l=a.slice(0,i||0)+c+a.slice(s||0),{formatted:o,raw:h}=M(l,t,n,!0);r.value=o;const d=nt(i||0,c.length,l.length,o.length);return r.setSelectionRange(d,d),{formatted:o,raw:h}}function re(e,t){const n=y(e);return t?`^-?[0-9]*[${n}]?[0-9]*$`:`^[0-9]*[${n}]?[0-9]*$`}function ae(e){var t,n;try{const a=new Intl.NumberFormat(e).formatToParts(123456789e-2);return{decimalSeparator:((t=a.find(i=>i.type==="decimal"))==null?void 0:t.value)??".",thousandSeparator:((n=a.find(i=>i.type==="group"))==null?void 0:n.value)??","}}catch{return{thousandSeparator:",",decimalSeparator:"."}}}function ie(e){let t=e.thousandSeparator??he,n=e.decimalSeparator??$,r=e.thousandStyle??H;if(e.thousandStyle===E.Locale||e.decimalSeparator==="auto"){const i=ae();e.thousandStyle===E.Locale&&(t=e.thousandSeparator??i.thousandSeparator,n=e.decimalSeparator==="auto"||e.decimalSeparator===void 0?i.decimalSeparator:e.decimalSeparator,r=E.Thousand),e.decimalSeparator==="auto"&&(n=i.decimalSeparator)}return{thousandSeparator:t,thousandStyle:r,decimalSeparator:n}}function se(e){rt(e.decimalMaxLength),at(e.decimalMinLength),it(e.decimalMinLength,e.decimalMaxLength),st(e.formatOn),ct(e.thousandSeparator),ot(e.thousandStyle),lt(e.decimalSeparator),ht(e.thousandSeparator,e.decimalSeparator),I("enableCompactNotation",e.enableCompactNotation),I("enableNegative",e.enableNegative),I("enableLeadingZeros",e.enableLeadingZeros),I("rawValueMode",e.rawValueMode),ut(e.onChange)}function rt(e){if(e!==void 0){if(typeof e!="number")throw new Error(`decimalMaxLength must be a number. Received: ${typeof e} (${JSON.stringify(e)})`);if(!Number.isInteger(e))throw new Error(`decimalMaxLength must be an integer. Received: ${e}`);if(e<0)throw new Error(`decimalMaxLength must be non-negative. Received: ${e}`)}}function at(e){if(e!==void 0){if(typeof e!="number")throw new Error(`decimalMinLength must be a number. Received: ${typeof e} (${JSON.stringify(e)})`);if(!Number.isInteger(e))throw new Error(`decimalMinLength must be an integer. Received: ${e}`);if(e<0)throw new Error(`decimalMinLength must be non-negative. Received: ${e}`)}}function it(e,t){if(!(e===void 0||t===void 0)&&e>t)throw new Error(`decimalMinLength (${e}) cannot be greater than decimalMaxLength (${t}).`)}function st(e){if(e!==void 0&&e!==p.Blur&&e!==p.Change)throw new Error(`formatOn must be either ${p.Blur} or ${p.Change}. Received: ${JSON.stringify(e)}`)}function ct(e){if(e!==void 0){if(typeof e!="string")throw new Error(`thousandSeparator must be a string. Received: ${typeof e} (${JSON.stringify(e)})`);if(e.length===0)throw new Error(`thousandSeparator cannot be empty. Received: ${JSON.stringify(e)}`);if(e.length>1)throw new Error(`thousandSeparator must be a single character. Received: "${e}" (length: ${e.length})`)}}function ot(e){if(e!==void 0&&!Object.values(E).includes(e))throw new Error(`ThousandStyle must be one of: ${Object.values(E).map(t=>`'${t}'`).join(", ")}. Received: ${JSON.stringify(e)}`)}function lt(e){if(!(e===void 0||e==="auto")){if(typeof e!="string")throw new Error(`decimalSeparator must be a string. Received: ${typeof e} (${JSON.stringify(e)})`);if(e.length===0)throw new Error(`decimalSeparator cannot be empty. Received: ${JSON.stringify(e)}`);if(e.length>1)throw new Error(`decimalSeparator must be a single character. Received: "${e}" (length: ${e.length})`)}}function ht(e,t){if(!(e===void 0||t===void 0)&&t!=="auto"&&e===t)throw new Error(`Decimal separator can't be same as thousand separator. thousandSeparator: ${e}, decimalSeparator: ${t}`)}function I(e,t){if(t!==void 0&&typeof t!="boolean")throw new Error(`${e} must be a boolean. Received: ${typeof t} (${JSON.stringify(t)})`)}function ut(e){if(e!==void 0&&typeof e!="function")throw new Error(`onChange must be a function or undefined. Received: ${typeof e} (${JSON.stringify(e)})`)}class dt{constructor(t,{decimalMaxLength:n=G,decimalMinLength:r=Z,formatOn:a=P,thousandSeparator:i,thousandStyle:s=H,decimalSeparator:c,enableCompactNotation:l=k,enableNegative:o=B,enableLeadingZeros:h=W,rawValueMode:d=U,onChange:u,...g}){D(this,"element");D(this,"resolvedOptions");D(this,"rawValue","");D(this,"caretPositionBeforeChange");se({decimalMaxLength:n,decimalMinLength:r,formatOn:a,thousandSeparator:i,thousandStyle:s,decimalSeparator:c,enableCompactNotation:l,enableNegative:o,enableLeadingZeros:h,rawValueMode:d,onChange:u});const S={decimalMaxLength:n,decimalMinLength:r,onChange:u,formatOn:a,thousandSeparator:i,thousandStyle:s,decimalSeparator:c,enableCompactNotation:l,enableNegative:o,enableLeadingZeros:h,rawValueMode:d,...g};if(this.resolvedOptions=this.getResolvedOptions(S),this.createInputElement(t,S),this.setupEventListeners(),this.resolvedOptions.rawValueMode&&this.element.value){const m=this.element.value,f=this.resolvedOptions.thousandSeparator?L(m,this.resolvedOptions.thousandSeparator):m;this.rawValue=f,this.element.value=this.formatValueForDisplay(f)}else if(this.element.value){const m=this.element.value;this.element.value=this.formatValueForDisplay(m)}}createInputElement(t,n){this.element=document.createElement("input"),this.element.setAttribute("type","text"),this.element.setAttribute("inputmode","decimal"),this.element.setAttribute("spellcheck","false"),this.element.setAttribute("autocomplete","off");const r=re(this.resolvedOptions.decimalSeparator,this.resolvedOptions.enableNegative);this.element.setAttribute("pattern",r);const{decimalMaxLength:a,decimalMinLength:i,formatOn:s,thousandSeparator:c,thousandStyle:l,decimalSeparator:o,enableCompactNotation:h,enableNegative:d,enableLeadingZeros:u,rawValueMode:g,onChange:S,value:m,defaultValue:f,type:b,inputMode:w,spellcheck:C,autocomplete:ft,...ce}=n;Object.assign(this.element,ce),m!==void 0?this.element.value=m:f!==void 0&&(this.element.defaultValue=f,this.element.value=f),t.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)),this.resolvedOptions.formatOn===p.Blur&&this.resolvedOptions.thousandSeparator&&(this.element.addEventListener("focus",this.handleFocus.bind(this)),this.element.addEventListener("blur",this.handleBlur.bind(this)))}getResolvedOptions(t){const n=ie({thousandSeparator:t.thousandSeparator,thousandStyle:t.thousandStyle,decimalSeparator:t.decimalSeparator});return{decimalMaxLength:t.decimalMaxLength??G,decimalMinLength:t.decimalMinLength??Z,formatOn:t.formatOn??P,thousandSeparator:n.thousandSeparator,thousandStyle:n.thousandStyle,decimalSeparator:n.decimalSeparator,enableCompactNotation:t.enableCompactNotation??k,enableNegative:t.enableNegative??B,enableLeadingZeros:t.enableLeadingZeros??W,rawValueMode:t.rawValueMode??U,onChange:t.onChange}}buildFormattingOptions(){return{formatOn:this.resolvedOptions.formatOn,thousandSeparator:this.resolvedOptions.thousandSeparator,ThousandStyle:this.resolvedOptions.thousandStyle,enableCompactNotation:this.resolvedOptions.enableCompactNotation,enableNegative:this.resolvedOptions.enableNegative,enableLeadingZeros:this.resolvedOptions.enableLeadingZeros,decimalSeparator:this.resolvedOptions.decimalSeparator,decimalMinLength:this.resolvedOptions.decimalMinLength,rawValueMode:this.resolvedOptions.rawValueMode}}handleValueChange(t,n){if(this.resolvedOptions.rawValueMode&&n!==void 0&&(this.rawValue=n),this.resolvedOptions.onChange){const r=this.resolvedOptions.rawValueMode?this.rawValue:t;this.resolvedOptions.onChange(r)}}formatValueForDisplay(t){if(!t)return t;const{thousandSeparator:n,thousandStyle:r,enableLeadingZeros:a,decimalSeparator:i}=this.resolvedOptions;return n&&r!==E.None?Q(t,n,r,a,i):t}handleChange(t){const{formatted:n,raw:r}=te(t,this.resolvedOptions.decimalMaxLength,this.caretPositionBeforeChange,this.buildFormattingOptions());this.caretPositionBeforeChange=void 0,this.handleValueChange(n,r)}handleKeyDown(t){const n=t.target,{selectionStart:r,selectionEnd:a}=n,i=this.buildFormattingOptions(),s=ee(t,{formatOn:i.formatOn,thousandSeparator:i.thousandSeparator,ThousandStyle:i.ThousandStyle,decimalSeparator:i.decimalSeparator});s?this.caretPositionBeforeChange={selectionStart:r??0,selectionEnd:a??0,endOffset:s.endOffset}:this.caretPositionBeforeChange={selectionStart:r??0,selectionEnd:a??0}}handlePaste(t){const{formatted:n,raw:r}=ne(t,this.resolvedOptions.decimalMaxLength,this.buildFormattingOptions());this.handleValueChange(n,r);const a=new Event("input",{bubbles:!0,cancelable:!0});this.element.dispatchEvent(a)}handleFocus(t){if(this.resolvedOptions.formatOn===p.Blur&&this.resolvedOptions.thousandSeparator){const n=t.target;n.value=L(n.value,this.resolvedOptions.thousandSeparator)}}handleBlur(t){const n=t.target,{thousandSeparator:r,thousandStyle:a}=this.resolvedOptions;if(r&&a!==E.None&&n.value){const i=this.formatValueForDisplay(n.value);n.value=i;const s=this.resolvedOptions.rawValueMode?L(i,r):void 0;this.handleValueChange(i,s)}}getValue(){return this.resolvedOptions.rawValueMode?this.rawValue:this.element.value}setValue(t){if(this.resolvedOptions.rawValueMode){const n=this.resolvedOptions.thousandSeparator?L(t,this.resolvedOptions.thousandSeparator):t;this.rawValue=n,this.element.value=this.formatValueForDisplay(n)}else this.element.value=t}disable(){this.element.disabled=!0}enable(){this.element.disabled=!1}addEventListener(t,n){this.element.addEventListener(t,n)}removeEventListener(t,n){this.element.removeEventListener(t,n)}getElement(){return this.element}get value(){return this.getValue()}set value(t){this.setValue(t)}get valueAsNumber(){const t=this.getValue();if(!t)return NaN;const n=this.resolvedOptions.thousandSeparator?L(t,this.resolvedOptions.thousandSeparator):t,r=this.resolvedOptions.decimalSeparator&&this.resolvedOptions.decimalSeparator!=="."?n.replace(new RegExp(y(this.resolvedOptions.decimalSeparator),"g"),"."):n;return parseFloat(r)}set valueAsNumber(t){if(isNaN(t)){this.setValue("");return}const n=t.toString();this.setValue(n)}}exports.FormatOn=p;exports.NumoraInput=dt;exports.ThousandStyle=E;exports.formatInputValue=M;exports.formatValueForDisplay=et;exports.getNumoraPattern=re;exports.getSeparatorsFromLocale=ae;exports.handleOnChangeNumoraInput=te;exports.handleOnKeyDownNumoraInput=ee;exports.handleOnPasteNumoraInput=ne;exports.removeThousandSeparators=L;exports.resolveLocaleOptions=ie;exports.validateNumoraInputOptions=se;
|
|
1
|
+
"use strict";var le=Object.defineProperty;var he=(e,t,n)=>t in e?le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var w=(e,t,n)=>he(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var N=(e=>(e.Blur="blur",e.Change="change",e))(N||{}),m=(e=>(e.None="none",e.Thousand="thousand",e.Lakh="lakh",e.Wan="wan",e))(m||{});const G=2,B=0,Z=N.Blur,ue=",",k=m.None,C=".",W=!1,U=!1,P=!1,z=!1;function y(e){return e.replace(/[-[\]/{}()*+?.\\^$|]/g,"\\$&")}const J=new Map;function O(e,t="g"){const n=`${e}:${t}`;let r=J.get(n);return r||(r=new RegExp(e,t),J.set(n,r)),r}function de(e,t="g"){const n=y(e);return O(n,t)}const fe=/[.,]/g;function _(e){return{decimalSeparator:(e==null?void 0:e.decimalSeparator)??C,thousandSeparator:e==null?void 0:e.thousandSeparator}}function Y(e,t){const n=e.startsWith("-"),r=n?e.slice(1):e,[i="",s=""]=r.split(t);return{sign:n?"-":"",integer:i,decimal:s}}function ge(e,t){if(!e.value.includes(t))return!1;const{selectionStart:n,selectionEnd:r,value:i}=e;return!i.slice(n??0,r??0).includes(t)}function Se(e,t,n){const{key:r}=e;if(r!==","&&r!==".")return!1;if(ge(t,n))return!0;if(r!==n){const{selectionStart:i,selectionEnd:s,value:a}=t,c=i??0,l=s??c;t.value=a.slice(0,c)+n+a.slice(l);const o=c+1;return t.setSelectionRange(o,o),!0}return!1}const Ee=(e,t,n=C)=>{const{sign:r,integer:i,decimal:s}=Y(e,n);if(!s)return e;const a=s.slice(0,t);return`${r}${i}${n}${a}`},pe=(e,t=C)=>{const n=e.indexOf(t);if(n===-1||n===e.length-1)return e;const r=e.slice(0,n+1),i=e.slice(n+1),a=t==="."||t===","?fe:O("[,\\."+y(t)+"]","g");return r+i.replace(a,"")},me=(e,t=0,n=C)=>{if(t<=0)return e;const{sign:r,integer:i,decimal:s}=Y(e,n);if(s.length>=t)return e;const a=s.padEnd(t,"0");return`${r}${i}${n}${a}`},D={thousand:{size:3},lakh:{firstGroup:3,restGroup:2},wan:{size:4}},be=/^(0+)/;function Q(e,t,n=m.Thousand,r=!1,i="."){if(!e||e==="0"||e===i||e==="-"||e===`-${i}`)return e;const s=e.includes(i),a=e.startsWith("-"),c=a?e.slice(1):e,[l,o]=c.split(i);if(!l){const u=o?`${i}${o}`:c;return a?`-${u}`:u}if(r&&l.startsWith("0")&&l.length>1){const u=l.match(be);if(u){const S=u[1],E=l.slice(S.length);if(E){const p=X(E,t,n),g=S+p,d=a?"-":"";return s?o?`${d}${g}${i}${o}`:`${d}${g}${i}`:`${d}${g}`}}}const h=X(l,t,n),f=a?"-":"";return s?o?`${f}${h}${i}${o}`:`${f}${h}${i}`:`${f}${h}`}function X(e,t,n){if(e==="0"||e==="")return e;switch(n){case m.None:return e;case m.Thousand:return j(e,t,D.thousand.size);case m.Lakh:return Ne(e,t);case m.Wan:return j(e,t,D.wan.size);default:return e}}function Ne(e,t){if(e.length<=D.lakh.firstGroup)return e;const n=[],r=e.length-D.lakh.firstGroup;n.unshift(e.slice(r));for(let i=r;i>0;i-=D.lakh.restGroup)n.unshift(e.slice(Math.max(0,i-D.lakh.restGroup),i));return n.join(t)}function j(e,t,n){const r=[];for(let i=e.length;i>0;i-=n)r.unshift(e.slice(Math.max(0,i-n),i));return r.join(t)}function Le(e,t,n){return(t==null?void 0:t.formatOn)===N.Change&&t.thousandSeparator?Q(e,t.thousandSeparator,t.ThousandStyle??m.None,t.enableLeadingZeros,(n==null?void 0:n.decimalSeparator)??C):e}function $(e,t,n){let r=0;for(let i=0;i<t&&i<e.length;i++)e[i]!==n&&r++;return r}function ve(e,t,n){if(t===0)return 0;let r=0;for(let i=0;i<e.length;i++)if(e[i]!==n){if(r===t-1)return i+1;r++}return e.length}function T(e,t,n){if(t===0)return 0;let r=0;for(let i=0;i<e.length;i++)if(e[i]!==n){if(r++,r===t)return i+1;if(r>t)return i}return e.length}function V(e,t,n){return t<0||t>=e.length?!1:e[t]===n}const $e=/\d/;function De(e,t={}){const{thousandSeparator:n,decimalSeparator:r=".",prefix:i="",suffix:s=""}=t,a=new Array(e.length+1).fill(!0);if(i&&a.fill(!1,0,i.length),s){const c=e.length-s.length;a.fill(!1,c+1,e.length+1)}for(let c=0;c<e.length;c++){const l=e[c];(n&&l===n||l===r)&&(a[c]=!1,c+1<e.length&&!$e.test(e[c+1])&&(a[c+1]=!1))}return a.some(c=>c)||a.fill(!0),a}function x(e,t,n,r){const i=e.length;if(t=Math.max(0,Math.min(t,i)),r==="left"){for(;t>=0&&!n[t];)t--;t===-1&&(t=n.indexOf(!0))}else if(r==="right"){for(;t<=i&&!n[t];)t++;t>i&&(t=n.lastIndexOf(!0))}else if(!n[t]){let s=t;for(;s<=i&&!n[s];)s++;let a=t;for(;a>=0&&!n[a];)a--;s<=i&&a>=0?t=t-a<s-t?a:s:s<=i?t=s:a>=0&&(t=a)}return(t===-1||t>i)&&(t=i),t}const K=/(\d+\.?\d*)\s*[kmbt]$/i,Ce=(e,t)=>e===t;function we(e,t,n,r,i,s,a=".",c={}){if(n<0)return 0;if(n>e.length||e===""||t===""||K.test(e)&&!K.test(t)&&t.length>e.length&&n>=e.length-1)return t.length;const l=t.length<e.length,o=V(e,n,r),h=e.indexOf(a),f=t.indexOf(a);if(c.isCharacterEquivalent&&e!==t){const g={thousandSeparator:r||void 0,...c},d=ye(e,t,n,c.isCharacterEquivalent||Ce,s,g);if(d!==void 0)return d}const S=new Map,E=(g,d,L)=>{const b=`${g===e?"o":"n"}:${d}`;return S.has(b)||S.set(b,$(g,d,r)),S.get(b)};if(l)return Ie(e,t,n,r,o,h,f,s,c,E);const p=Te(e,t,n,r,o,E);return c.boundary?x(t,p,c.boundary):p}function ye(e,t,n,r,i,s){const a=e.length,c=t.length;let l=0,o=0,h=c;for(let d=0;d<a;d++){let L=-1;for(let b=l;b<c;b++)if(r(e[d],t[b],{oldValue:e,newValue:t,typedRange:i,oldIndex:d,newIndex:b})){L=b;break}L!==-1&&(l=L+1,d<n?o=L+1:h===c&&/\d/.test(e[d])&&(h=L))}if(o>h)return h;const f=t.length<e.length||i!==void 0&&i.isDelete===!1;let u,S=!1,E=!1;if(f){u=o;const d=s.thousandSeparator,L=s.decimalSeparator??".",b=u<t.length?t[u]:"";d&&b===d?(n>0?e[n-1]:"")===d?(u=h,S=!0):E=!0:b===L&&(E=!0)}else u=n-o<h-n?o:h;const p=f&&!S?"left":"right";if(s.boundary)return E?u:x(t,u,s.boundary,p);const g=s.thousandSeparator;if(!E&&g&&u>=0&&u<t.length&&t[u]===g)if(f&&!S)for(;u>0&&t[u]===g;)u--;else for(;u<t.length&&t[u]===g;)u++;return u}function Ie(e,t,n,r,i,s,a,c,l={},o=$){if(i)return Me(e,t,n,r,a,o);const h=o(e,n,r),f=o(e,e.length,r),u=o(t,t.length,r),S=f-u,E=Ae(e,n,r,h,S,s,c,o),p=s===-1||n<=s,g=Re(t,E,r,S,c,p,a,o);return l.boundary?x(t,g,l.boundary):g}function Me(e,t,n,r,i,s=$){const a=n+1;if(a<e.length){const c=s(e,a,r),l=ve(t,c,r);return l<t.length&&t[l]!==r?l+1:l}return n}function Ae(e,t,n,r,i,s,a,c=$){if(a){const{start:o,isDelete:h}=a;return h?c(e,o,n):Math.max(0,c(e,o,n))}return t>0&&e[t-1]===n&&i>0?r+1:r}function q(e,t,n,r,i,s,a=$){if(t>0&&t<e.length&&a(e,t,r)===n){if(e[t]===r&&s&&i>0&&t<e.length-1)return t+1;if(!s&&i>0&&t<e.length-1)return Math.min(t+1,e.length)}return t}function Re(e,t,n,r,i,s,a,c=$){if(s&&a!==-1){const o=e.substring(0,a),h=c(o,o.length,n);if(t<=h){const f=T(o,t,n);return q(o,f,t,n,r,i,c)}}const l=T(e,t,n);return q(e,l,t,n,r,i,c)}function Te(e,t,n,r,i,s=$){const a=n>=e.length,c=s(e,n,r),l=s(e,e.length,r),o=s(t,t.length,r);if(a||c===l)return t.length;const h=o-l;let f=c;h>0&&!a&&c<l&&(f=c+1);const u=T(t,f,r);return i&&!V(t,u,r)?Math.max(0,u-1):u}function Oe(e,t,n){const{selectionStart:r,selectionEnd:i,endOffset:s=0}=e;if(r!==i){const h=i-r;return{start:r,end:i,deletedLength:h,isDelete:!1}}if(s>0){const h=s;return{start:r,end:r+h,deletedLength:h,isDelete:!0}}const c=t.length,l=n.length,o=c-l;if(!(o<=0))return{start:r,end:r+o,deletedLength:o,isDelete:!1}}function _e(e,t){if(e===t)return;let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;let r=e.length-1,i=t.length-1;for(;r>=n&&i>=n&&e[r]===t[i];)r--,i--;const s=r-n+1,a=i-n+1;if(!(s===0&&a===0))return{start:n,end:r+1,deletedLength:s,isDelete:s>a}}function H(e,t){if(e.value=e.value,e===null)return!1;if(e.createTextRange){const n=e.createTextRange();return n.move("character",t),n.select(),!0}return e.selectionStart!==null||e.selectionStart===0?(e.focus(),e.setSelectionRange(t,t),!0):(e.focus(),!1)}function xe(e,t,n){return e.selectionStart===0&&e.selectionEnd===e.value.length?null:(H(e,t),setTimeout(()=>{e.value===n&&e.selectionStart!==t&&H(e,t)},0))}function Ge(e){return Math.max(e.selectionStart,e.selectionEnd)}function Be(e,t,n){if((n==null?void 0:n.formatOn)!==N.Change||!n.thousandSeparator)return;const{selectionStart:r,selectionEnd:i,value:s}=t;if(r===null||i===null||r!==i)return;const{key:a}=e,c=n.thousandSeparator;a==="Backspace"&&r>0&&s[r-1]===c&&t.setSelectionRange(r-1,r-1),a==="Delete"&&s[r]===c&&t.setSelectionRange(r+1,r+1)}function Ze(e,t,n,r,i,s,a){if(!i)return;const{selectionStart:c=0,selectionEnd:l=0,endOffset:o=0}=i;let h=Oe({selectionStart:c,selectionEnd:l,endOffset:o},t,n);if(h||(h=_e(t,n)),!h)return;const f=De(n,{thousandSeparator:(a==null?void 0:a.thousandSeparator)??s.thousandSeparator,decimalSeparator:s.decimalSeparator}),u={thousandSeparator:(a==null?void 0:a.thousandSeparator)??s.thousandSeparator,decimalSeparator:s.decimalSeparator,isCharacterEquivalent:(g,d)=>{const L=(a==null?void 0:a.thousandSeparator)??s.thousandSeparator;return L&&g===L?!1:g===d},boundary:f},S=(a==null?void 0:a.thousandSeparator)??s.thousandSeparator??",",E=(a==null?void 0:a.ThousandStyle)??m.None,p=we(t,n,r,S,E,h,s.decimalSeparator,u);xe(e,p,n)}const ke=(e,t=!1,n=".")=>{const r=y(n),i=O(`[^0-9${r}]`,"g");if(!t)return e.replace(i,"");const s=e.startsWith("-"),a=e.replace(i,"");return s&&(a.length>0||e==="-")?"-"+a:a},We=/([+-]?\d+\.?\d*)[eE]([+-]?\d+)/g,F=/^0+$/,A=/\.?0+$/;function Ue(e){return!e.includes("e")&&!e.includes("E")?e:e.replace(We,(t,n,r)=>{const i=parseInt(r,10);if(i===0)return n;const s=n.startsWith("-"),a=s?n.slice(1):n,[c,l=""]=a.split("."),o=i>0?Pe(c,l,i):ze(c,l,Math.abs(i));return s?"-"+o:o})}function Pe(e,t,n){const r=e+t;if(r==="0"||F.test(r))return"0";const i=t.length;if(n<=i){const a=r.slice(0,e.length+n),c=r.slice(e.length+n);return c?`${a}.${c}`:a}const s=n-i;return r+"0".repeat(s)}function ze(e,t,n){const r=e+t;if(r==="0"||F.test(r))return"0";const s=e.length-n;if(s<=0){const a=Math.abs(s),c=`0.${"0".repeat(a)}${r}`;return R(c)}if(s<e.length){const a=r.slice(0,s),c=r.slice(s),l=`${a}.${c}`;return R(l)}return R(r)}function R(e){if(!e.includes("."))return e;if(e==="0.")return"0";if(e.startsWith("0.")){const t=e.replace(A,"");return t==="0"?"0":t||"0"}if(e.startsWith("-0.")){const t=e.replace(A,"");return t==="-0"||t==="0"?"0":t||"0"}return e.replace(A,"")||e}const Je=/(\d+\.?\d*)\s*([kmbt])/gi,Xe=/^0+/,je=/^(-?)0+([1-9])/,Ke=/^-?0+$/,qe=/\.?0+$/,He={k:3,m:6,b:9,t:12};function Ye(e){return e.replace(Je,(t,n,r)=>{const i=r.toLowerCase(),s=He[i];if(!s)return t;const[a,c=""]=n.split("."),l=a.replace(Xe,"")||"0";let o;if(c.length===0)o=l+"0".repeat(s);else if(c.length<=s){const h=s-c.length;o=l+c+"0".repeat(h)}else{const h=c.slice(0,s),f=c.slice(s);o=l+h+"."+f}return o=o.replace(je,"$1$2"),Ke.test(o)&&(o="0"),o.includes(".")&&(o=o.replace(qe,"")),o})}function Qe(e){if(!e||e==="0"||e==="-0"||e==="-"||e===".")return e;const t=e.startsWith("-"),n=t?e.slice(1):e;if(n===".")return e;if(n.includes(".")){const[i,s]=n.split(".");if(i){const c=(i.replace(/^0+/,"")||"0")+"."+s;return t?"-"+c:c}return e}if(n.startsWith("0")){const i=n.replace(/^0+/,"")||"0";return t?"-"+i:i}return e}function Ve(e){return e.replace(/[\s\u200B]/g,"")}function v(e,t){const n=de(t);return e.replace(n,"")}const Fe=(e,t)=>{let n=Ve(e);return t!=null&&t.thousandSeparator&&(n=v(n,t.thousandSeparator)),t!=null&&t.enableCompactNotation&&(n=Ye(n)),n=Ue(n),n=ke(n,t==null?void 0:t.enableNegative,t==null?void 0:t.decimalSeparator),n=pe(n,t==null?void 0:t.decimalSeparator),t!=null&&t.enableLeadingZeros||(n=Qe(n)),n};function et(e,t,n){return{enableCompactNotation:e==null?void 0:e.enableCompactNotation,enableNegative:e==null?void 0:e.enableNegative,enableLeadingZeros:e==null?void 0:e.enableLeadingZeros,decimalSeparator:t.decimalSeparator,thousandSeparator:n?t.thousandSeparator:void 0}}function M(e,t,n,r){const i=_(n),s=r??(n==null?void 0:n.formatOn)===N.Change,a=Fe(e,et(n,i,s)),c=Ee(a,t,i.decimalSeparator),l=(n==null?void 0:n.decimalMinLength)??0,o=me(c,l,i.decimalSeparator);return{formatted:Le(o,n,i),raw:o}}function tt(e,t,n){const r=!!(n!=null&&n.thousandSeparator);return M(e,t,n,r)}function nt(e,t,n){if(e==="Backspace"||e==="Delete")return e==="Delete"&&t===n?{endOffset:1}:{endOffset:0}}function ee(e,t){const{decimalSeparator:n}=_(t),r=e.target;if(Se(e,r,n)){e.preventDefault();return}return Be(e,r,t),nt(e.key,r.selectionStart,r.selectionEnd)}function te(e,t,n,r){const i=e.target,s=i.value,a=Ge(i),c=_(r),l=(r==null?void 0:r.formatOn)===N.Change,{formatted:o,raw:h}=M(s,t,r,l);return i.value=o,s!==o&&Ze(i,s,o,a,n,c,r),{formatted:o,raw:h}}function rt(e,t,n,r){const i=r-n;return e+t+i}function ne(e,t,n){var u;e.preventDefault();const r=e.target,{value:i,selectionStart:s,selectionEnd:a}=r,c=((u=e.clipboardData)==null?void 0:u.getData("text/plain"))||"",l=i.slice(0,s||0)+c+i.slice(a||0),{formatted:o,raw:h}=M(l,t,n,!0);r.value=o;const f=rt(s||0,c.length,l.length,o.length);return r.setSelectionRange(f,f),{formatted:o,raw:h}}function re(e,t){const n=y(e);return t?`^-?[0-9]*[${n}]?[0-9]*$`:`^[0-9]*[${n}]?[0-9]*$`}function ie(e){var t,n;try{const i=new Intl.NumberFormat(e).formatToParts(123456789e-2);return{decimalSeparator:((t=i.find(s=>s.type==="decimal"))==null?void 0:t.value)??".",thousandSeparator:((n=i.find(s=>s.type==="group"))==null?void 0:n.value)??","}}catch{return{thousandSeparator:",",decimalSeparator:"."}}}function se(e,t){if(!e)return t;const r=ie(e===!0?void 0:e);return{thousandSeparator:t.thousandSeparator??r.thousandSeparator,decimalSeparator:t.decimalSeparator??r.decimalSeparator}}function ae(e){it(e.decimalMaxLength),st(e.decimalMinLength),at(e.decimalMinLength,e.decimalMaxLength),ct(e.formatOn),ot(e.thousandSeparator),lt(e.thousandStyle),ht(e.decimalSeparator),ut(e.thousandSeparator,e.decimalSeparator),I("enableCompactNotation",e.enableCompactNotation),I("enableNegative",e.enableNegative),I("enableLeadingZeros",e.enableLeadingZeros),I("rawValueMode",e.rawValueMode),dt(e.onChange)}function it(e){if(e!==void 0){if(typeof e!="number")throw new Error(`decimalMaxLength must be a number. Received: ${typeof e} (${JSON.stringify(e)})`);if(!Number.isInteger(e))throw new Error(`decimalMaxLength must be an integer. Received: ${e}`);if(e<0)throw new Error(`decimalMaxLength must be non-negative. Received: ${e}`)}}function st(e){if(e!==void 0){if(typeof e!="number")throw new Error(`decimalMinLength must be a number. Received: ${typeof e} (${JSON.stringify(e)})`);if(!Number.isInteger(e))throw new Error(`decimalMinLength must be an integer. Received: ${e}`);if(e<0)throw new Error(`decimalMinLength must be non-negative. Received: ${e}`)}}function at(e,t){if(!(e===void 0||t===void 0)&&e>t)throw new Error(`decimalMinLength (${e}) cannot be greater than decimalMaxLength (${t}).`)}function ct(e){if(e!==void 0&&e!==N.Blur&&e!==N.Change)throw new Error(`formatOn must be either ${N.Blur} or ${N.Change}. Received: ${JSON.stringify(e)}`)}function ot(e){if(e!==void 0){if(typeof e!="string")throw new Error(`thousandSeparator must be a string. Received: ${typeof e} (${JSON.stringify(e)})`);if(e.length===0)throw new Error(`thousandSeparator cannot be empty. Received: ${JSON.stringify(e)}`);if(e.length>1)throw new Error(`thousandSeparator must be a single character. Received: "${e}" (length: ${e.length})`)}}function lt(e){if(e!==void 0&&!Object.values(m).includes(e))throw new Error(`ThousandStyle must be one of: ${Object.values(m).map(t=>`'${t}'`).join(", ")}. Received: ${JSON.stringify(e)}`)}function ht(e){if(e!==void 0){if(typeof e!="string")throw new Error(`decimalSeparator must be a string. Received: ${typeof e} (${JSON.stringify(e)})`);if(e.length===0)throw new Error(`decimalSeparator cannot be empty. Received: ${JSON.stringify(e)}`);if(e.length>1)throw new Error(`decimalSeparator must be a single character. Received: "${e}" (length: ${e.length})`)}}function ut(e,t){if(!(e===void 0||t===void 0)&&e===t)throw new Error(`Decimal separator can't be same as thousand separator. thousandSeparator: ${e}, decimalSeparator: ${t}`)}function I(e,t){if(t!==void 0&&typeof t!="boolean")throw new Error(`${e} must be a boolean. Received: ${typeof t} (${JSON.stringify(t)})`)}function dt(e){if(e!==void 0&&typeof e!="function")throw new Error(`onChange must be a function or undefined. Received: ${typeof e} (${JSON.stringify(e)})`)}class ft{constructor(t,{decimalMaxLength:n=G,decimalMinLength:r=B,formatOn:i=Z,thousandSeparator:s,thousandStyle:a=k,decimalSeparator:c,locale:l,enableCompactNotation:o=W,enableNegative:h=U,enableLeadingZeros:f=P,rawValueMode:u=z,onChange:S,...E}){w(this,"element");w(this,"resolvedOptions");w(this,"rawValue","");w(this,"caretPositionBeforeChange");ae({decimalMaxLength:n,decimalMinLength:r,formatOn:i,thousandSeparator:s,thousandStyle:a,decimalSeparator:c,enableCompactNotation:o,enableNegative:h,enableLeadingZeros:f,rawValueMode:u,onChange:S});const p={decimalMaxLength:n,decimalMinLength:r,onChange:S,formatOn:i,thousandSeparator:s,thousandStyle:a,decimalSeparator:c,locale:l,enableCompactNotation:o,enableNegative:h,enableLeadingZeros:f,rawValueMode:u,...E};if(this.resolvedOptions=this.getResolvedOptions(p),this.createInputElement(t,p),this.setupEventListeners(),this.resolvedOptions.rawValueMode&&this.element.value){const g=this.element.value,d=this.resolvedOptions.thousandSeparator?v(g,this.resolvedOptions.thousandSeparator):g;this.rawValue=d,this.element.value=this.formatValueForDisplay(d)}else if(this.element.value){const g=this.element.value;this.element.value=this.formatValueForDisplay(g)}}createInputElement(t,n){this.element=document.createElement("input"),this.element.setAttribute("type","text"),this.element.setAttribute("inputmode","decimal"),this.element.setAttribute("spellcheck","false"),this.element.setAttribute("autocomplete","off");const r=re(this.resolvedOptions.decimalSeparator,this.resolvedOptions.enableNegative);this.element.setAttribute("pattern",r);const{decimalMaxLength:i,decimalMinLength:s,formatOn:a,thousandSeparator:c,thousandStyle:l,decimalSeparator:o,locale:h,enableCompactNotation:f,enableNegative:u,enableLeadingZeros:S,rawValueMode:E,onChange:p,value:g,defaultValue:d,type:L,inputMode:b,spellcheck:ce,autocomplete:gt,...oe}=n;Object.assign(this.element,oe),g!==void 0?this.element.value=g:d!==void 0&&(this.element.defaultValue=d,this.element.value=d),t.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)),this.resolvedOptions.formatOn===N.Blur&&this.resolvedOptions.thousandSeparator&&(this.element.addEventListener("focus",this.handleFocus.bind(this)),this.element.addEventListener("blur",this.handleBlur.bind(this)))}getResolvedOptions(t){const n=se(t.locale,{thousandSeparator:t.thousandSeparator,decimalSeparator:t.decimalSeparator});return{decimalMaxLength:t.decimalMaxLength??G,decimalMinLength:t.decimalMinLength??B,formatOn:t.formatOn??Z,thousandSeparator:n.thousandSeparator??ue,thousandStyle:t.thousandStyle??k,decimalSeparator:n.decimalSeparator??C,enableCompactNotation:t.enableCompactNotation??W,enableNegative:t.enableNegative??U,enableLeadingZeros:t.enableLeadingZeros??P,rawValueMode:t.rawValueMode??z,onChange:t.onChange}}buildFormattingOptions(){return{formatOn:this.resolvedOptions.formatOn,thousandSeparator:this.resolvedOptions.thousandSeparator,ThousandStyle:this.resolvedOptions.thousandStyle,enableCompactNotation:this.resolvedOptions.enableCompactNotation,enableNegative:this.resolvedOptions.enableNegative,enableLeadingZeros:this.resolvedOptions.enableLeadingZeros,decimalSeparator:this.resolvedOptions.decimalSeparator,decimalMinLength:this.resolvedOptions.decimalMinLength,rawValueMode:this.resolvedOptions.rawValueMode}}handleValueChange(t,n){if(this.resolvedOptions.rawValueMode&&n!==void 0&&(this.rawValue=n),this.resolvedOptions.onChange){const r=this.resolvedOptions.rawValueMode?this.rawValue:t;this.resolvedOptions.onChange(r)}}formatValueForDisplay(t){if(!t)return t;const{thousandSeparator:n,thousandStyle:r,enableLeadingZeros:i,decimalSeparator:s}=this.resolvedOptions;return n&&r!==m.None?Q(t,n,r,i,s):t}handleChange(t){const{formatted:n,raw:r}=te(t,this.resolvedOptions.decimalMaxLength,this.caretPositionBeforeChange,this.buildFormattingOptions());this.caretPositionBeforeChange=void 0,this.handleValueChange(n,r)}handleKeyDown(t){const n=t.target,{selectionStart:r,selectionEnd:i}=n,s=this.buildFormattingOptions(),a=ee(t,{formatOn:s.formatOn,thousandSeparator:s.thousandSeparator,ThousandStyle:s.ThousandStyle,decimalSeparator:s.decimalSeparator});a?this.caretPositionBeforeChange={selectionStart:r??0,selectionEnd:i??0,endOffset:a.endOffset}:this.caretPositionBeforeChange={selectionStart:r??0,selectionEnd:i??0}}handlePaste(t){const{formatted:n,raw:r}=ne(t,this.resolvedOptions.decimalMaxLength,this.buildFormattingOptions());this.handleValueChange(n,r);const i=new Event("input",{bubbles:!0,cancelable:!0});this.element.dispatchEvent(i)}handleFocus(t){if(this.resolvedOptions.formatOn===N.Blur&&this.resolvedOptions.thousandSeparator){const n=t.target;n.value=v(n.value,this.resolvedOptions.thousandSeparator)}}handleBlur(t){const n=t.target,{thousandSeparator:r,thousandStyle:i}=this.resolvedOptions;if(r&&i!==m.None&&n.value){const s=this.formatValueForDisplay(n.value);n.value=s;const a=this.resolvedOptions.rawValueMode?v(s,r):void 0;this.handleValueChange(s,a)}}getValue(){return this.resolvedOptions.rawValueMode?this.rawValue:this.element.value}setValue(t){if(this.resolvedOptions.rawValueMode){const n=this.resolvedOptions.thousandSeparator?v(t,this.resolvedOptions.thousandSeparator):t;this.rawValue=n,this.element.value=this.formatValueForDisplay(n)}else this.element.value=t}disable(){this.element.disabled=!0}enable(){this.element.disabled=!1}addEventListener(t,n){this.element.addEventListener(t,n)}removeEventListener(t,n){this.element.removeEventListener(t,n)}getElement(){return this.element}get value(){return this.getValue()}set value(t){this.setValue(t)}get valueAsNumber(){const t=this.getValue();if(!t)return NaN;const n=this.resolvedOptions.thousandSeparator?v(t,this.resolvedOptions.thousandSeparator):t,r=this.resolvedOptions.decimalSeparator&&this.resolvedOptions.decimalSeparator!=="."?n.replace(new RegExp(y(this.resolvedOptions.decimalSeparator),"g"),"."):n;return parseFloat(r)}set valueAsNumber(t){if(isNaN(t)){this.setValue("");return}const n=t.toString();this.setValue(n)}}exports.FormatOn=N;exports.NumoraInput=ft;exports.ThousandStyle=m;exports.applyLocale=se;exports.formatInputValue=M;exports.formatValueForDisplay=tt;exports.getNumoraPattern=re;exports.getSeparatorsFromLocale=ie;exports.handleOnChangeNumoraInput=te;exports.handleOnKeyDownNumoraInput=ee;exports.handleOnPasteNumoraInput=ne;exports.removeThousandSeparators=v;exports.validateNumoraInputOptions=ae;
|
package/dist/index.mjs
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
const G = 2,
|
|
6
|
-
function
|
|
1
|
+
var ne = Object.defineProperty;
|
|
2
|
+
var re = (e, t, n) => t in e ? ne(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var w = (e, t, n) => re(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
var N = /* @__PURE__ */ ((e) => (e.Blur = "blur", e.Change = "change", e))(N || {}), m = /* @__PURE__ */ ((e) => (e.None = "none", e.Thousand = "thousand", e.Lakh = "lakh", e.Wan = "wan", e))(m || {});
|
|
5
|
+
const G = 2, B = 0, Z = N.Blur, ie = ",", k = m.None, C = ".", W = !1, U = !1, z = !1, J = !1;
|
|
6
|
+
function M(e) {
|
|
7
7
|
return e.replace(/[-[\]/{}()*+?.\\^$|]/g, "\\$&");
|
|
8
8
|
}
|
|
9
|
-
const
|
|
9
|
+
const P = /* @__PURE__ */ new Map();
|
|
10
10
|
function T(e, t = "g") {
|
|
11
11
|
const n = `${e}:${t}`;
|
|
12
|
-
let r =
|
|
13
|
-
return r || (r = new RegExp(e, t),
|
|
12
|
+
let r = P.get(n);
|
|
13
|
+
return r || (r = new RegExp(e, t), P.set(n, r)), r;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
const n =
|
|
15
|
+
function se(e, t = "g") {
|
|
16
|
+
const n = M(e);
|
|
17
17
|
return T(n, t);
|
|
18
18
|
}
|
|
19
|
-
const
|
|
19
|
+
const ae = /[.,]/g;
|
|
20
20
|
function _(e) {
|
|
21
21
|
return {
|
|
22
|
-
decimalSeparator: (e == null ? void 0 : e.decimalSeparator) ??
|
|
22
|
+
decimalSeparator: (e == null ? void 0 : e.decimalSeparator) ?? C,
|
|
23
23
|
thousandSeparator: e == null ? void 0 : e.thousandSeparator
|
|
24
24
|
};
|
|
25
25
|
}
|
|
@@ -31,15 +31,15 @@ function Y(e, t) {
|
|
|
31
31
|
decimal: s
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function ce(e, t) {
|
|
35
35
|
if (!e.value.includes(t)) return !1;
|
|
36
36
|
const { selectionStart: n, selectionEnd: r, value: i } = e;
|
|
37
37
|
return !i.slice(n ?? 0, r ?? 0).includes(t);
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function oe(e, t, n) {
|
|
40
40
|
const { key: r } = e;
|
|
41
41
|
if (r !== "," && r !== ".") return !1;
|
|
42
|
-
if (
|
|
42
|
+
if (ce(t, n))
|
|
43
43
|
return !0;
|
|
44
44
|
if (r !== n) {
|
|
45
45
|
const { selectionStart: i, selectionEnd: s, value: a } = t, c = i ?? 0, l = s ?? c;
|
|
@@ -49,28 +49,28 @@ function ce(e, t, n) {
|
|
|
49
49
|
}
|
|
50
50
|
return !1;
|
|
51
51
|
}
|
|
52
|
-
const
|
|
52
|
+
const le = (e, t, n = C) => {
|
|
53
53
|
const { sign: r, integer: i, decimal: s } = Y(e, n);
|
|
54
54
|
if (!s) return e;
|
|
55
55
|
const a = s.slice(0, t);
|
|
56
56
|
return `${r}${i}${n}${a}`;
|
|
57
|
-
},
|
|
57
|
+
}, he = (e, t = C) => {
|
|
58
58
|
const n = e.indexOf(t);
|
|
59
59
|
if (n === -1 || n === e.length - 1) return e;
|
|
60
|
-
const r = e.slice(0, n + 1), i = e.slice(n + 1), a = t === "." || t === "," ?
|
|
60
|
+
const r = e.slice(0, n + 1), i = e.slice(n + 1), a = t === "." || t === "," ? ae : T("[,\\." + M(t) + "]", "g");
|
|
61
61
|
return r + i.replace(a, "");
|
|
62
|
-
},
|
|
62
|
+
}, ue = (e, t = 0, n = C) => {
|
|
63
63
|
if (t <= 0) return e;
|
|
64
64
|
const { sign: r, integer: i, decimal: s } = Y(e, n);
|
|
65
65
|
if (s.length >= t)
|
|
66
66
|
return e;
|
|
67
67
|
const a = s.padEnd(t, "0");
|
|
68
68
|
return `${r}${i}${n}${a}`;
|
|
69
|
-
},
|
|
69
|
+
}, D = {
|
|
70
70
|
thousand: { size: 3 },
|
|
71
71
|
lakh: { firstGroup: 3, restGroup: 2 },
|
|
72
72
|
wan: { size: 4 }
|
|
73
|
-
},
|
|
73
|
+
}, de = /^(0+)/;
|
|
74
74
|
function Q(e, t, n = m.Thousand, r = !1, i = ".") {
|
|
75
75
|
if (!e || e === "0" || e === i || e === "-" || e === `-${i}`)
|
|
76
76
|
return e;
|
|
@@ -80,65 +80,65 @@ function Q(e, t, n = m.Thousand, r = !1, i = ".") {
|
|
|
80
80
|
return a ? `-${u}` : u;
|
|
81
81
|
}
|
|
82
82
|
if (r && l.startsWith("0") && l.length > 1) {
|
|
83
|
-
const u = l.match(
|
|
83
|
+
const u = l.match(de);
|
|
84
84
|
if (u) {
|
|
85
|
-
const
|
|
86
|
-
if (
|
|
87
|
-
const
|
|
88
|
-
return s ? o ? `${
|
|
85
|
+
const S = u[1], E = l.slice(S.length);
|
|
86
|
+
if (E) {
|
|
87
|
+
const p = X(E, t, n), g = S + p, d = a ? "-" : "";
|
|
88
|
+
return s ? o ? `${d}${g}${i}${o}` : `${d}${g}${i}` : `${d}${g}`;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
const h =
|
|
93
|
-
return s ? o ? `${
|
|
92
|
+
const h = X(l, t, n), f = a ? "-" : "";
|
|
93
|
+
return s ? o ? `${f}${h}${i}${o}` : `${f}${h}${i}` : `${f}${h}`;
|
|
94
94
|
}
|
|
95
|
-
function
|
|
95
|
+
function X(e, t, n) {
|
|
96
96
|
if (e === "0" || e === "")
|
|
97
97
|
return e;
|
|
98
98
|
switch (n) {
|
|
99
99
|
case m.None:
|
|
100
100
|
return e;
|
|
101
101
|
case m.Thousand:
|
|
102
|
-
return
|
|
102
|
+
return j(e, t, D.thousand.size);
|
|
103
103
|
case m.Lakh:
|
|
104
|
-
return
|
|
104
|
+
return fe(e, t);
|
|
105
105
|
case m.Wan:
|
|
106
|
-
return
|
|
106
|
+
return j(e, t, D.wan.size);
|
|
107
107
|
default:
|
|
108
108
|
return e;
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
function
|
|
112
|
-
if (e.length <=
|
|
111
|
+
function fe(e, t) {
|
|
112
|
+
if (e.length <= D.lakh.firstGroup)
|
|
113
113
|
return e;
|
|
114
|
-
const n = [], r = e.length -
|
|
114
|
+
const n = [], r = e.length - D.lakh.firstGroup;
|
|
115
115
|
n.unshift(e.slice(r));
|
|
116
|
-
for (let i = r; i > 0; i -=
|
|
117
|
-
n.unshift(e.slice(Math.max(0, i -
|
|
116
|
+
for (let i = r; i > 0; i -= D.lakh.restGroup)
|
|
117
|
+
n.unshift(e.slice(Math.max(0, i - D.lakh.restGroup), i));
|
|
118
118
|
return n.join(t);
|
|
119
119
|
}
|
|
120
|
-
function
|
|
120
|
+
function j(e, t, n) {
|
|
121
121
|
const r = [];
|
|
122
122
|
for (let i = e.length; i > 0; i -= n)
|
|
123
123
|
r.unshift(e.slice(Math.max(0, i - n), i));
|
|
124
124
|
return r.join(t);
|
|
125
125
|
}
|
|
126
|
-
function
|
|
127
|
-
return (t == null ? void 0 : t.formatOn) ===
|
|
126
|
+
function ge(e, t, n) {
|
|
127
|
+
return (t == null ? void 0 : t.formatOn) === N.Change && t.thousandSeparator ? Q(
|
|
128
128
|
e,
|
|
129
129
|
t.thousandSeparator,
|
|
130
130
|
t.ThousandStyle ?? m.None,
|
|
131
131
|
t.enableLeadingZeros,
|
|
132
|
-
(n == null ? void 0 : n.decimalSeparator) ??
|
|
132
|
+
(n == null ? void 0 : n.decimalSeparator) ?? C
|
|
133
133
|
) : e;
|
|
134
134
|
}
|
|
135
|
-
function
|
|
135
|
+
function $(e, t, n) {
|
|
136
136
|
let r = 0;
|
|
137
137
|
for (let i = 0; i < t && i < e.length; i++)
|
|
138
138
|
e[i] !== n && r++;
|
|
139
139
|
return r;
|
|
140
140
|
}
|
|
141
|
-
function
|
|
141
|
+
function Se(e, t, n) {
|
|
142
142
|
if (t === 0)
|
|
143
143
|
return 0;
|
|
144
144
|
let r = 0;
|
|
@@ -150,7 +150,7 @@ function ge(e, t, n) {
|
|
|
150
150
|
}
|
|
151
151
|
return e.length;
|
|
152
152
|
}
|
|
153
|
-
function
|
|
153
|
+
function R(e, t, n) {
|
|
154
154
|
if (t === 0)
|
|
155
155
|
return 0;
|
|
156
156
|
let r = 0;
|
|
@@ -166,8 +166,8 @@ function I(e, t, n) {
|
|
|
166
166
|
function V(e, t, n) {
|
|
167
167
|
return t < 0 || t >= e.length ? !1 : e[t] === n;
|
|
168
168
|
}
|
|
169
|
-
const
|
|
170
|
-
function
|
|
169
|
+
const Ee = /\d/;
|
|
170
|
+
function pe(e, t = {}) {
|
|
171
171
|
const {
|
|
172
172
|
thousandSeparator: n,
|
|
173
173
|
decimalSeparator: r = ".",
|
|
@@ -180,13 +180,21 @@ function Ee(e, t = {}) {
|
|
|
180
180
|
}
|
|
181
181
|
for (let c = 0; c < e.length; c++) {
|
|
182
182
|
const l = e[c];
|
|
183
|
-
(n && l === n || l === r) && (a[c] = !1, c + 1 < e.length && !
|
|
183
|
+
(n && l === n || l === r) && (a[c] = !1, c + 1 < e.length && !Ee.test(e[c + 1]) && (a[c + 1] = !1));
|
|
184
184
|
}
|
|
185
185
|
return a.some((c) => c) || a.fill(!0), a;
|
|
186
186
|
}
|
|
187
187
|
function x(e, t, n, r) {
|
|
188
188
|
const i = e.length;
|
|
189
|
-
if (t = Math.max(0, Math.min(t, i)),
|
|
189
|
+
if (t = Math.max(0, Math.min(t, i)), r === "left") {
|
|
190
|
+
for (; t >= 0 && !n[t]; )
|
|
191
|
+
t--;
|
|
192
|
+
t === -1 && (t = n.indexOf(!0));
|
|
193
|
+
} else if (r === "right") {
|
|
194
|
+
for (; t <= i && !n[t]; )
|
|
195
|
+
t++;
|
|
196
|
+
t > i && (t = n.lastIndexOf(!0));
|
|
197
|
+
} else if (!n[t]) {
|
|
190
198
|
let s = t;
|
|
191
199
|
for (; s <= i && !n[s]; )
|
|
192
200
|
s++;
|
|
@@ -197,85 +205,104 @@ function x(e, t, n, r) {
|
|
|
197
205
|
}
|
|
198
206
|
return (t === -1 || t > i) && (t = i), t;
|
|
199
207
|
}
|
|
200
|
-
const
|
|
201
|
-
function
|
|
208
|
+
const K = /(\d+\.?\d*)\s*[kmbt]$/i, be = (e, t) => e === t;
|
|
209
|
+
function me(e, t, n, r, i, s, a = ".", c = {}) {
|
|
202
210
|
if (n < 0)
|
|
203
211
|
return 0;
|
|
204
|
-
if (n > e.length || e === "" || t === "" ||
|
|
212
|
+
if (n > e.length || e === "" || t === "" || K.test(e) && !K.test(t) && t.length > e.length && n >= e.length - 1)
|
|
205
213
|
return t.length;
|
|
206
214
|
const l = t.length < e.length, o = V(
|
|
207
215
|
e,
|
|
208
216
|
n,
|
|
209
217
|
r
|
|
210
|
-
), h = e.indexOf(a),
|
|
218
|
+
), h = e.indexOf(a), f = t.indexOf(a);
|
|
211
219
|
if (c.isCharacterEquivalent && e !== t) {
|
|
212
|
-
const
|
|
220
|
+
const g = {
|
|
221
|
+
thousandSeparator: r || void 0,
|
|
222
|
+
...c
|
|
223
|
+
}, d = Le(
|
|
213
224
|
e,
|
|
214
225
|
t,
|
|
215
226
|
n,
|
|
216
|
-
c.isCharacterEquivalent ||
|
|
227
|
+
c.isCharacterEquivalent || be,
|
|
217
228
|
s,
|
|
218
|
-
|
|
229
|
+
g
|
|
219
230
|
);
|
|
220
|
-
if (
|
|
221
|
-
return
|
|
231
|
+
if (d !== void 0)
|
|
232
|
+
return d;
|
|
222
233
|
}
|
|
223
|
-
const
|
|
224
|
-
const
|
|
225
|
-
return
|
|
234
|
+
const S = /* @__PURE__ */ new Map(), E = (g, d, L) => {
|
|
235
|
+
const b = `${g === e ? "o" : "n"}:${d}`;
|
|
236
|
+
return S.has(b) || S.set(b, $(g, d, r)), S.get(b);
|
|
226
237
|
};
|
|
227
238
|
if (l)
|
|
228
|
-
return
|
|
239
|
+
return Ne(
|
|
229
240
|
e,
|
|
230
241
|
t,
|
|
231
242
|
n,
|
|
232
243
|
r,
|
|
233
244
|
o,
|
|
234
245
|
h,
|
|
235
|
-
|
|
246
|
+
f,
|
|
236
247
|
s,
|
|
237
248
|
c,
|
|
238
|
-
|
|
249
|
+
E
|
|
239
250
|
);
|
|
240
|
-
const
|
|
251
|
+
const p = Ce(
|
|
241
252
|
e,
|
|
242
253
|
t,
|
|
243
254
|
n,
|
|
244
255
|
r,
|
|
245
256
|
o,
|
|
246
|
-
|
|
257
|
+
E
|
|
247
258
|
);
|
|
248
|
-
return c.boundary ? x(t,
|
|
259
|
+
return c.boundary ? x(t, p, c.boundary) : p;
|
|
249
260
|
}
|
|
250
|
-
function
|
|
261
|
+
function Le(e, t, n, r, i, s) {
|
|
251
262
|
const a = e.length, c = t.length;
|
|
252
263
|
let l = 0, o = 0, h = c;
|
|
253
|
-
for (let
|
|
254
|
-
let
|
|
255
|
-
for (let
|
|
264
|
+
for (let d = 0; d < a; d++) {
|
|
265
|
+
let L = -1;
|
|
266
|
+
for (let b = l; b < c; b++)
|
|
256
267
|
if (r(
|
|
257
|
-
e[
|
|
258
|
-
t[
|
|
268
|
+
e[d],
|
|
269
|
+
t[b],
|
|
259
270
|
{
|
|
260
271
|
oldValue: e,
|
|
261
272
|
newValue: t,
|
|
262
273
|
typedRange: i,
|
|
263
|
-
oldIndex:
|
|
264
|
-
newIndex:
|
|
274
|
+
oldIndex: d,
|
|
275
|
+
newIndex: b
|
|
265
276
|
}
|
|
266
277
|
)) {
|
|
267
|
-
|
|
278
|
+
L = b;
|
|
268
279
|
break;
|
|
269
280
|
}
|
|
270
|
-
|
|
281
|
+
L !== -1 && (l = L + 1, d < n ? o = L + 1 : h === c && /\d/.test(e[d]) && (h = L));
|
|
271
282
|
}
|
|
272
283
|
if (o > h) return h;
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
284
|
+
const f = t.length < e.length || i !== void 0 && i.isDelete === !1;
|
|
285
|
+
let u, S = !1, E = !1;
|
|
286
|
+
if (f) {
|
|
287
|
+
u = o;
|
|
288
|
+
const d = s.thousandSeparator, L = s.decimalSeparator ?? ".", b = u < t.length ? t[u] : "";
|
|
289
|
+
d && b === d ? (n > 0 ? e[n - 1] : "") === d ? (u = h, S = !0) : E = !0 : b === L && (E = !0);
|
|
290
|
+
} else
|
|
291
|
+
u = n - o < h - n ? o : h;
|
|
292
|
+
const p = f && !S ? "left" : "right";
|
|
293
|
+
if (s.boundary)
|
|
294
|
+
return E ? u : x(t, u, s.boundary, p);
|
|
295
|
+
const g = s.thousandSeparator;
|
|
296
|
+
if (!E && g && u >= 0 && u < t.length && t[u] === g)
|
|
297
|
+
if (f && !S)
|
|
298
|
+
for (; u > 0 && t[u] === g; ) u--;
|
|
299
|
+
else
|
|
300
|
+
for (; u < t.length && t[u] === g; ) u++;
|
|
301
|
+
return u;
|
|
302
|
+
}
|
|
303
|
+
function Ne(e, t, n, r, i, s, a, c, l = {}, o = $) {
|
|
277
304
|
if (i)
|
|
278
|
-
return
|
|
305
|
+
return $e(
|
|
279
306
|
e,
|
|
280
307
|
t,
|
|
281
308
|
n,
|
|
@@ -283,31 +310,31 @@ function Le(e, t, n, r, i, s, a, c, l = {}, o = L) {
|
|
|
283
310
|
a,
|
|
284
311
|
o
|
|
285
312
|
);
|
|
286
|
-
const h = o(e, n, r),
|
|
313
|
+
const h = o(e, n, r), f = o(e, e.length, r), u = o(t, t.length, r), S = f - u, E = ve(
|
|
287
314
|
e,
|
|
288
315
|
n,
|
|
289
316
|
r,
|
|
290
317
|
h,
|
|
291
|
-
|
|
318
|
+
S,
|
|
292
319
|
s,
|
|
293
320
|
c,
|
|
294
321
|
o
|
|
295
|
-
),
|
|
322
|
+
), p = s === -1 || n <= s, g = De(
|
|
296
323
|
t,
|
|
297
|
-
|
|
324
|
+
E,
|
|
298
325
|
r,
|
|
299
|
-
|
|
326
|
+
S,
|
|
300
327
|
c,
|
|
301
|
-
|
|
328
|
+
p,
|
|
302
329
|
a,
|
|
303
330
|
o
|
|
304
331
|
);
|
|
305
|
-
return l.boundary ? x(t,
|
|
332
|
+
return l.boundary ? x(t, g, l.boundary) : g;
|
|
306
333
|
}
|
|
307
|
-
function
|
|
334
|
+
function $e(e, t, n, r, i, s = $) {
|
|
308
335
|
const a = n + 1;
|
|
309
336
|
if (a < e.length) {
|
|
310
|
-
const c = s(e, a, r), l =
|
|
337
|
+
const c = s(e, a, r), l = Se(
|
|
311
338
|
t,
|
|
312
339
|
c,
|
|
313
340
|
r
|
|
@@ -316,14 +343,14 @@ function Ne(e, t, n, r, i, s = L) {
|
|
|
316
343
|
}
|
|
317
344
|
return n;
|
|
318
345
|
}
|
|
319
|
-
function
|
|
346
|
+
function ve(e, t, n, r, i, s, a, c = $) {
|
|
320
347
|
if (a) {
|
|
321
348
|
const { start: o, isDelete: h } = a;
|
|
322
349
|
return h ? c(e, o, n) : Math.max(0, c(e, o, n));
|
|
323
350
|
}
|
|
324
351
|
return t > 0 && e[t - 1] === n && i > 0 ? r + 1 : r;
|
|
325
352
|
}
|
|
326
|
-
function
|
|
353
|
+
function q(e, t, n, r, i, s, a = $) {
|
|
327
354
|
if (t > 0 && t < e.length && a(e, t, r) === n) {
|
|
328
355
|
if (e[t] === r && s && i > 0 && t < e.length - 1)
|
|
329
356
|
return t + 1;
|
|
@@ -332,35 +359,35 @@ function K(e, t, n, r, i, s, a = L) {
|
|
|
332
359
|
}
|
|
333
360
|
return t;
|
|
334
361
|
}
|
|
335
|
-
function
|
|
362
|
+
function De(e, t, n, r, i, s, a, c = $) {
|
|
336
363
|
if (s && a !== -1) {
|
|
337
364
|
const o = e.substring(0, a), h = c(o, o.length, n);
|
|
338
365
|
if (t <= h) {
|
|
339
|
-
const
|
|
366
|
+
const f = R(
|
|
340
367
|
o,
|
|
341
368
|
t,
|
|
342
369
|
n
|
|
343
370
|
);
|
|
344
|
-
return
|
|
371
|
+
return q(o, f, t, n, r, i, c);
|
|
345
372
|
}
|
|
346
373
|
}
|
|
347
|
-
const l =
|
|
374
|
+
const l = R(
|
|
348
375
|
e,
|
|
349
376
|
t,
|
|
350
377
|
n
|
|
351
378
|
);
|
|
352
|
-
return
|
|
379
|
+
return q(e, l, t, n, r, i, c);
|
|
353
380
|
}
|
|
354
|
-
function
|
|
381
|
+
function Ce(e, t, n, r, i, s = $) {
|
|
355
382
|
const a = n >= e.length, c = s(e, n, r), l = s(e, e.length, r), o = s(t, t.length, r);
|
|
356
383
|
if (a || c === l)
|
|
357
384
|
return t.length;
|
|
358
385
|
const h = o - l;
|
|
359
|
-
let
|
|
360
|
-
h > 0 && !a && c < l && (
|
|
361
|
-
const u =
|
|
386
|
+
let f = c;
|
|
387
|
+
h > 0 && !a && c < l && (f = c + 1);
|
|
388
|
+
const u = R(
|
|
362
389
|
t,
|
|
363
|
-
|
|
390
|
+
f,
|
|
364
391
|
r
|
|
365
392
|
);
|
|
366
393
|
return i && !V(t, u, r) ? Math.max(0, u - 1) : u;
|
|
@@ -394,7 +421,7 @@ function we(e, t, n) {
|
|
|
394
421
|
isDelete: !1
|
|
395
422
|
};
|
|
396
423
|
}
|
|
397
|
-
function
|
|
424
|
+
function Me(e, t) {
|
|
398
425
|
if (e === t)
|
|
399
426
|
return;
|
|
400
427
|
let n = 0;
|
|
@@ -412,7 +439,7 @@ function ye(e, t) {
|
|
|
412
439
|
isDelete: s > a
|
|
413
440
|
};
|
|
414
441
|
}
|
|
415
|
-
function
|
|
442
|
+
function H(e, t) {
|
|
416
443
|
if (e.value = e.value, e === null)
|
|
417
444
|
return !1;
|
|
418
445
|
if (e.createTextRange) {
|
|
@@ -421,16 +448,16 @@ function q(e, t) {
|
|
|
421
448
|
}
|
|
422
449
|
return e.selectionStart !== null || e.selectionStart === 0 ? (e.focus(), e.setSelectionRange(t, t), !0) : (e.focus(), !1);
|
|
423
450
|
}
|
|
424
|
-
function
|
|
425
|
-
return e.selectionStart === 0 && e.selectionEnd === e.value.length ? null : (
|
|
426
|
-
e.value === n && e.selectionStart !== t &&
|
|
451
|
+
function ye(e, t, n) {
|
|
452
|
+
return e.selectionStart === 0 && e.selectionEnd === e.value.length ? null : (H(e, t), setTimeout(() => {
|
|
453
|
+
e.value === n && e.selectionStart !== t && H(e, t);
|
|
427
454
|
}, 0));
|
|
428
455
|
}
|
|
429
|
-
function
|
|
456
|
+
function Ae(e) {
|
|
430
457
|
return Math.max(e.selectionStart, e.selectionEnd);
|
|
431
458
|
}
|
|
432
|
-
function
|
|
433
|
-
if ((n == null ? void 0 : n.formatOn) !==
|
|
459
|
+
function Ie(e, t, n) {
|
|
460
|
+
if ((n == null ? void 0 : n.formatOn) !== N.Change || !n.thousandSeparator)
|
|
434
461
|
return;
|
|
435
462
|
const { selectionStart: r, selectionEnd: i, value: s } = t;
|
|
436
463
|
if (r === null || i === null || r !== i)
|
|
@@ -446,45 +473,46 @@ function Re(e, t, n, r, i, s, a) {
|
|
|
446
473
|
t,
|
|
447
474
|
n
|
|
448
475
|
);
|
|
449
|
-
if (h || (h =
|
|
450
|
-
const
|
|
476
|
+
if (h || (h = Me(t, n)), !h) return;
|
|
477
|
+
const f = pe(n, {
|
|
451
478
|
thousandSeparator: (a == null ? void 0 : a.thousandSeparator) ?? s.thousandSeparator,
|
|
452
479
|
decimalSeparator: s.decimalSeparator
|
|
453
480
|
}), u = {
|
|
454
481
|
thousandSeparator: (a == null ? void 0 : a.thousandSeparator) ?? s.thousandSeparator,
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
482
|
+
decimalSeparator: s.decimalSeparator,
|
|
483
|
+
isCharacterEquivalent: (g, d) => {
|
|
484
|
+
const L = (a == null ? void 0 : a.thousandSeparator) ?? s.thousandSeparator;
|
|
485
|
+
return L && g === L ? !1 : g === d;
|
|
458
486
|
},
|
|
459
|
-
boundary:
|
|
460
|
-
},
|
|
487
|
+
boundary: f
|
|
488
|
+
}, S = (a == null ? void 0 : a.thousandSeparator) ?? s.thousandSeparator ?? ",", E = (a == null ? void 0 : a.ThousandStyle) ?? m.None, p = me(
|
|
461
489
|
t,
|
|
462
490
|
n,
|
|
463
491
|
r,
|
|
464
|
-
g,
|
|
465
492
|
S,
|
|
493
|
+
E,
|
|
466
494
|
h,
|
|
467
495
|
s.decimalSeparator,
|
|
468
496
|
u
|
|
469
497
|
);
|
|
470
|
-
|
|
498
|
+
ye(e, p, n);
|
|
471
499
|
}
|
|
472
|
-
const
|
|
473
|
-
const r =
|
|
500
|
+
const Te = (e, t = !1, n = ".") => {
|
|
501
|
+
const r = M(n), i = T(`[^0-9${r}]`, "g");
|
|
474
502
|
if (!t)
|
|
475
503
|
return e.replace(i, "");
|
|
476
504
|
const s = e.startsWith("-"), a = e.replace(i, "");
|
|
477
505
|
return s && (a.length > 0 || e === "-") ? "-" + a : a;
|
|
478
|
-
},
|
|
479
|
-
function
|
|
480
|
-
return !e.includes("e") && !e.includes("E") ? e : e.replace(
|
|
506
|
+
}, _e = /([+-]?\d+\.?\d*)[eE]([+-]?\d+)/g, F = /^0+$/, A = /\.?0+$/;
|
|
507
|
+
function xe(e) {
|
|
508
|
+
return !e.includes("e") && !e.includes("E") ? e : e.replace(_e, (t, n, r) => {
|
|
481
509
|
const i = parseInt(r, 10);
|
|
482
510
|
if (i === 0) return n;
|
|
483
|
-
const s = n.startsWith("-"), a = s ? n.slice(1) : n, [c, l = ""] = a.split("."), o = i > 0 ?
|
|
511
|
+
const s = n.startsWith("-"), a = s ? n.slice(1) : n, [c, l = ""] = a.split("."), o = i > 0 ? Oe(c, l, i) : Ge(c, l, Math.abs(i));
|
|
484
512
|
return s ? "-" + o : o;
|
|
485
513
|
});
|
|
486
514
|
}
|
|
487
|
-
function
|
|
515
|
+
function Oe(e, t, n) {
|
|
488
516
|
const r = e + t;
|
|
489
517
|
if (r === "0" || F.test(r))
|
|
490
518
|
return "0";
|
|
@@ -496,22 +524,22 @@ function xe(e, t, n) {
|
|
|
496
524
|
const s = n - i;
|
|
497
525
|
return r + "0".repeat(s);
|
|
498
526
|
}
|
|
499
|
-
function
|
|
527
|
+
function Ge(e, t, n) {
|
|
500
528
|
const r = e + t;
|
|
501
529
|
if (r === "0" || F.test(r))
|
|
502
530
|
return "0";
|
|
503
531
|
const s = e.length - n;
|
|
504
532
|
if (s <= 0) {
|
|
505
533
|
const a = Math.abs(s), c = `0.${"0".repeat(a)}${r}`;
|
|
506
|
-
return
|
|
534
|
+
return I(c);
|
|
507
535
|
}
|
|
508
536
|
if (s < e.length) {
|
|
509
537
|
const a = r.slice(0, s), c = r.slice(s), l = `${a}.${c}`;
|
|
510
|
-
return
|
|
538
|
+
return I(l);
|
|
511
539
|
}
|
|
512
|
-
return
|
|
540
|
+
return I(r);
|
|
513
541
|
}
|
|
514
|
-
function
|
|
542
|
+
function I(e) {
|
|
515
543
|
if (!e.includes("."))
|
|
516
544
|
return e;
|
|
517
545
|
if (e === "0.")
|
|
@@ -526,7 +554,7 @@ function R(e) {
|
|
|
526
554
|
}
|
|
527
555
|
return e.replace(A, "") || e;
|
|
528
556
|
}
|
|
529
|
-
const
|
|
557
|
+
const Be = /(\d+\.?\d*)\s*([kmbt])/gi, Ze = /^0+/, ke = /^(-?)0+([1-9])/, We = /^-?0+$/, Ue = /\.?0+$/, ze = {
|
|
530
558
|
k: 3,
|
|
531
559
|
// Thousand
|
|
532
560
|
m: 6,
|
|
@@ -536,9 +564,9 @@ const Ge = /(\d+\.?\d*)\s*([kmbt])/gi, Ze = /^0+/, ke = /^(-?)0+([1-9])/, Be = /
|
|
|
536
564
|
t: 12
|
|
537
565
|
// Trillion
|
|
538
566
|
};
|
|
539
|
-
function
|
|
540
|
-
return e.replace(
|
|
541
|
-
const i = r.toLowerCase(), s =
|
|
567
|
+
function Je(e) {
|
|
568
|
+
return e.replace(Be, (t, n, r) => {
|
|
569
|
+
const i = r.toLowerCase(), s = ze[i];
|
|
542
570
|
if (!s)
|
|
543
571
|
return t;
|
|
544
572
|
const [a, c = ""] = n.split("."), l = a.replace(Ze, "") || "0";
|
|
@@ -549,13 +577,13 @@ function Ue(e) {
|
|
|
549
577
|
const h = s - c.length;
|
|
550
578
|
o = l + c + "0".repeat(h);
|
|
551
579
|
} else {
|
|
552
|
-
const h = c.slice(0, s),
|
|
553
|
-
o = l + h + "." +
|
|
580
|
+
const h = c.slice(0, s), f = c.slice(s);
|
|
581
|
+
o = l + h + "." + f;
|
|
554
582
|
}
|
|
555
|
-
return o = o.replace(ke, "$1$2"),
|
|
583
|
+
return o = o.replace(ke, "$1$2"), We.test(o) && (o = "0"), o.includes(".") && (o = o.replace(Ue, "")), o;
|
|
556
584
|
});
|
|
557
585
|
}
|
|
558
|
-
function
|
|
586
|
+
function Pe(e) {
|
|
559
587
|
if (!e || e === "0" || e === "-0" || e === "-" || e === ".")
|
|
560
588
|
return e;
|
|
561
589
|
const t = e.startsWith("-"), n = t ? e.slice(1) : e;
|
|
@@ -575,22 +603,22 @@ function ze(e) {
|
|
|
575
603
|
}
|
|
576
604
|
return e;
|
|
577
605
|
}
|
|
578
|
-
function
|
|
606
|
+
function Xe(e) {
|
|
579
607
|
return e.replace(/[\s\u200B]/g, "");
|
|
580
608
|
}
|
|
581
|
-
function
|
|
582
|
-
const n =
|
|
609
|
+
function v(e, t) {
|
|
610
|
+
const n = se(t);
|
|
583
611
|
return e.replace(n, "");
|
|
584
612
|
}
|
|
585
|
-
const
|
|
586
|
-
let n =
|
|
587
|
-
return t != null && t.thousandSeparator && (n =
|
|
613
|
+
const je = (e, t) => {
|
|
614
|
+
let n = Xe(e);
|
|
615
|
+
return t != null && t.thousandSeparator && (n = v(n, t.thousandSeparator)), t != null && t.enableCompactNotation && (n = Je(n)), n = xe(n), n = Te(
|
|
588
616
|
n,
|
|
589
617
|
t == null ? void 0 : t.enableNegative,
|
|
590
618
|
t == null ? void 0 : t.decimalSeparator
|
|
591
|
-
), n =
|
|
619
|
+
), n = he(n, t == null ? void 0 : t.decimalSeparator), t != null && t.enableLeadingZeros || (n = Pe(n)), n;
|
|
592
620
|
};
|
|
593
|
-
function
|
|
621
|
+
function Ke(e, t, n) {
|
|
594
622
|
return {
|
|
595
623
|
enableCompactNotation: e == null ? void 0 : e.enableCompactNotation,
|
|
596
624
|
enableNegative: e == null ? void 0 : e.enableNegative,
|
|
@@ -600,21 +628,21 @@ function je(e, t, n) {
|
|
|
600
628
|
};
|
|
601
629
|
}
|
|
602
630
|
function O(e, t, n, r) {
|
|
603
|
-
const i = _(n), s = r ?? (n == null ? void 0 : n.formatOn) ===
|
|
631
|
+
const i = _(n), s = r ?? (n == null ? void 0 : n.formatOn) === N.Change, a = je(
|
|
604
632
|
e,
|
|
605
|
-
|
|
606
|
-
), c =
|
|
633
|
+
Ke(n, i, s)
|
|
634
|
+
), c = le(
|
|
607
635
|
a,
|
|
608
636
|
t,
|
|
609
637
|
i.decimalSeparator
|
|
610
|
-
), l = (n == null ? void 0 : n.decimalMinLength) ?? 0, o =
|
|
638
|
+
), l = (n == null ? void 0 : n.decimalMinLength) ?? 0, o = ue(
|
|
611
639
|
c,
|
|
612
640
|
l,
|
|
613
641
|
i.decimalSeparator
|
|
614
642
|
);
|
|
615
|
-
return { formatted:
|
|
643
|
+
return { formatted: ge(o, n, i), raw: o };
|
|
616
644
|
}
|
|
617
|
-
function
|
|
645
|
+
function gt(e, t, n) {
|
|
618
646
|
const r = !!(n != null && n.thousandSeparator);
|
|
619
647
|
return O(
|
|
620
648
|
e,
|
|
@@ -623,7 +651,7 @@ function ft(e, t, n) {
|
|
|
623
651
|
r
|
|
624
652
|
);
|
|
625
653
|
}
|
|
626
|
-
function
|
|
654
|
+
function qe(e, t, n) {
|
|
627
655
|
if (e === "Backspace" || e === "Delete")
|
|
628
656
|
return e === "Delete" && t === n ? {
|
|
629
657
|
endOffset: 1
|
|
@@ -631,16 +659,16 @@ function Ke(e, t, n) {
|
|
|
631
659
|
endOffset: 0
|
|
632
660
|
};
|
|
633
661
|
}
|
|
634
|
-
function
|
|
662
|
+
function He(e, t) {
|
|
635
663
|
const { decimalSeparator: n } = _(t), r = e.target;
|
|
636
|
-
if (
|
|
664
|
+
if (oe(e, r, n)) {
|
|
637
665
|
e.preventDefault();
|
|
638
666
|
return;
|
|
639
667
|
}
|
|
640
|
-
return
|
|
668
|
+
return Ie(e, r, t), qe(e.key, r.selectionStart, r.selectionEnd);
|
|
641
669
|
}
|
|
642
|
-
function
|
|
643
|
-
const i = e.target, s = i.value, a =
|
|
670
|
+
function Ye(e, t, n, r) {
|
|
671
|
+
const i = e.target, s = i.value, a = Ae(i), c = _(r), l = (r == null ? void 0 : r.formatOn) === N.Change, { formatted: o, raw: h } = O(
|
|
644
672
|
s,
|
|
645
673
|
t,
|
|
646
674
|
r,
|
|
@@ -656,11 +684,11 @@ function He(e, t, n, r) {
|
|
|
656
684
|
r
|
|
657
685
|
), { formatted: o, raw: h };
|
|
658
686
|
}
|
|
659
|
-
function
|
|
687
|
+
function Qe(e, t, n, r) {
|
|
660
688
|
const i = r - n;
|
|
661
689
|
return e + t + i;
|
|
662
690
|
}
|
|
663
|
-
function
|
|
691
|
+
function Ve(e, t, n) {
|
|
664
692
|
var u;
|
|
665
693
|
e.preventDefault();
|
|
666
694
|
const r = e.target, { value: i, selectionStart: s, selectionEnd: a } = r, c = ((u = e.clipboardData) == null ? void 0 : u.getData("text/plain")) || "", l = i.slice(0, s || 0) + c + i.slice(a || 0), { formatted: o, raw: h } = O(
|
|
@@ -670,19 +698,19 @@ function Qe(e, t, n) {
|
|
|
670
698
|
!0
|
|
671
699
|
);
|
|
672
700
|
r.value = o;
|
|
673
|
-
const
|
|
701
|
+
const f = Qe(
|
|
674
702
|
s || 0,
|
|
675
703
|
c.length,
|
|
676
704
|
l.length,
|
|
677
705
|
o.length
|
|
678
706
|
);
|
|
679
|
-
return r.setSelectionRange(
|
|
707
|
+
return r.setSelectionRange(f, f), { formatted: o, raw: h };
|
|
680
708
|
}
|
|
681
|
-
function
|
|
682
|
-
const n =
|
|
709
|
+
function Fe(e, t) {
|
|
710
|
+
const n = M(e);
|
|
683
711
|
return t ? `^-?[0-9]*[${n}]?[0-9]*$` : `^[0-9]*[${n}]?[0-9]*$`;
|
|
684
712
|
}
|
|
685
|
-
function
|
|
713
|
+
function et(e) {
|
|
686
714
|
var t, n;
|
|
687
715
|
try {
|
|
688
716
|
const i = new Intl.NumberFormat(e).formatToParts(123456789e-2);
|
|
@@ -694,18 +722,18 @@ function Fe(e) {
|
|
|
694
722
|
return { thousandSeparator: ",", decimalSeparator: "." };
|
|
695
723
|
}
|
|
696
724
|
}
|
|
697
|
-
function
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
}
|
|
705
|
-
function tt(e) {
|
|
706
|
-
nt(e.decimalMaxLength), rt(e.decimalMinLength), it(e.decimalMinLength, e.decimalMaxLength), st(e.formatOn), at(e.thousandSeparator), ct(e.thousandStyle), ot(e.decimalSeparator), lt(e.thousandSeparator, e.decimalSeparator), M("enableCompactNotation", e.enableCompactNotation), M("enableNegative", e.enableNegative), M("enableLeadingZeros", e.enableLeadingZeros), M("rawValueMode", e.rawValueMode), ht(e.onChange);
|
|
725
|
+
function tt(e, t) {
|
|
726
|
+
if (!e) return t;
|
|
727
|
+
const r = et(e === !0 ? void 0 : e);
|
|
728
|
+
return {
|
|
729
|
+
thousandSeparator: t.thousandSeparator ?? r.thousandSeparator,
|
|
730
|
+
decimalSeparator: t.decimalSeparator ?? r.decimalSeparator
|
|
731
|
+
};
|
|
707
732
|
}
|
|
708
733
|
function nt(e) {
|
|
734
|
+
rt(e.decimalMaxLength), it(e.decimalMinLength), st(e.decimalMinLength, e.decimalMaxLength), at(e.formatOn), ct(e.thousandSeparator), ot(e.thousandStyle), lt(e.decimalSeparator), ht(e.thousandSeparator, e.decimalSeparator), y("enableCompactNotation", e.enableCompactNotation), y("enableNegative", e.enableNegative), y("enableLeadingZeros", e.enableLeadingZeros), y("rawValueMode", e.rawValueMode), ut(e.onChange);
|
|
735
|
+
}
|
|
736
|
+
function rt(e) {
|
|
709
737
|
if (e !== void 0) {
|
|
710
738
|
if (typeof e != "number")
|
|
711
739
|
throw new Error(
|
|
@@ -721,7 +749,7 @@ function nt(e) {
|
|
|
721
749
|
);
|
|
722
750
|
}
|
|
723
751
|
}
|
|
724
|
-
function
|
|
752
|
+
function it(e) {
|
|
725
753
|
if (e !== void 0) {
|
|
726
754
|
if (typeof e != "number")
|
|
727
755
|
throw new Error(
|
|
@@ -737,19 +765,19 @@ function rt(e) {
|
|
|
737
765
|
);
|
|
738
766
|
}
|
|
739
767
|
}
|
|
740
|
-
function
|
|
768
|
+
function st(e, t) {
|
|
741
769
|
if (!(e === void 0 || t === void 0) && e > t)
|
|
742
770
|
throw new Error(
|
|
743
771
|
`decimalMinLength (${e}) cannot be greater than decimalMaxLength (${t}).`
|
|
744
772
|
);
|
|
745
773
|
}
|
|
746
|
-
function
|
|
747
|
-
if (e !== void 0 && e !==
|
|
774
|
+
function at(e) {
|
|
775
|
+
if (e !== void 0 && e !== N.Blur && e !== N.Change)
|
|
748
776
|
throw new Error(
|
|
749
|
-
`formatOn must be either ${
|
|
777
|
+
`formatOn must be either ${N.Blur} or ${N.Change}. Received: ${JSON.stringify(e)}`
|
|
750
778
|
);
|
|
751
779
|
}
|
|
752
|
-
function
|
|
780
|
+
function ct(e) {
|
|
753
781
|
if (e !== void 0) {
|
|
754
782
|
if (typeof e != "string")
|
|
755
783
|
throw new Error(
|
|
@@ -765,14 +793,14 @@ function at(e) {
|
|
|
765
793
|
);
|
|
766
794
|
}
|
|
767
795
|
}
|
|
768
|
-
function
|
|
796
|
+
function ot(e) {
|
|
769
797
|
if (e !== void 0 && !Object.values(m).includes(e))
|
|
770
798
|
throw new Error(
|
|
771
799
|
`ThousandStyle must be one of: ${Object.values(m).map((t) => `'${t}'`).join(", ")}. Received: ${JSON.stringify(e)}`
|
|
772
800
|
);
|
|
773
801
|
}
|
|
774
|
-
function
|
|
775
|
-
if (
|
|
802
|
+
function lt(e) {
|
|
803
|
+
if (e !== void 0) {
|
|
776
804
|
if (typeof e != "string")
|
|
777
805
|
throw new Error(
|
|
778
806
|
`decimalSeparator must be a string. Received: ${typeof e} (${JSON.stringify(e)})`
|
|
@@ -787,81 +815,83 @@ function ot(e) {
|
|
|
787
815
|
);
|
|
788
816
|
}
|
|
789
817
|
}
|
|
790
|
-
function
|
|
791
|
-
if (!(e === void 0 || t === void 0) &&
|
|
818
|
+
function ht(e, t) {
|
|
819
|
+
if (!(e === void 0 || t === void 0) && e === t)
|
|
792
820
|
throw new Error(
|
|
793
821
|
`Decimal separator can't be same as thousand separator. thousandSeparator: ${e}, decimalSeparator: ${t}`
|
|
794
822
|
);
|
|
795
823
|
}
|
|
796
|
-
function
|
|
824
|
+
function y(e, t) {
|
|
797
825
|
if (t !== void 0 && typeof t != "boolean")
|
|
798
826
|
throw new Error(
|
|
799
827
|
`${e} must be a boolean. Received: ${typeof t} (${JSON.stringify(t)})`
|
|
800
828
|
);
|
|
801
829
|
}
|
|
802
|
-
function
|
|
830
|
+
function ut(e) {
|
|
803
831
|
if (e !== void 0 && typeof e != "function")
|
|
804
832
|
throw new Error(
|
|
805
833
|
`onChange must be a function or undefined. Received: ${typeof e} (${JSON.stringify(e)})`
|
|
806
834
|
);
|
|
807
835
|
}
|
|
808
|
-
class
|
|
836
|
+
class St {
|
|
809
837
|
constructor(t, {
|
|
810
838
|
decimalMaxLength: n = G,
|
|
811
|
-
decimalMinLength: r =
|
|
812
|
-
formatOn: i =
|
|
839
|
+
decimalMinLength: r = B,
|
|
840
|
+
formatOn: i = Z,
|
|
813
841
|
thousandSeparator: s,
|
|
814
|
-
thousandStyle: a =
|
|
842
|
+
thousandStyle: a = k,
|
|
815
843
|
decimalSeparator: c,
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
844
|
+
locale: l,
|
|
845
|
+
enableCompactNotation: o = W,
|
|
846
|
+
enableNegative: h = U,
|
|
847
|
+
enableLeadingZeros: f = z,
|
|
848
|
+
rawValueMode: u = J,
|
|
849
|
+
onChange: S,
|
|
850
|
+
...E
|
|
822
851
|
}) {
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
852
|
+
w(this, "element");
|
|
853
|
+
w(this, "resolvedOptions");
|
|
854
|
+
w(this, "rawValue", "");
|
|
855
|
+
w(this, "caretPositionBeforeChange");
|
|
856
|
+
nt({
|
|
828
857
|
decimalMaxLength: n,
|
|
829
858
|
decimalMinLength: r,
|
|
830
859
|
formatOn: i,
|
|
831
860
|
thousandSeparator: s,
|
|
832
861
|
thousandStyle: a,
|
|
833
862
|
decimalSeparator: c,
|
|
834
|
-
enableCompactNotation:
|
|
835
|
-
enableNegative:
|
|
836
|
-
enableLeadingZeros:
|
|
837
|
-
rawValueMode:
|
|
838
|
-
onChange:
|
|
863
|
+
enableCompactNotation: o,
|
|
864
|
+
enableNegative: h,
|
|
865
|
+
enableLeadingZeros: f,
|
|
866
|
+
rawValueMode: u,
|
|
867
|
+
onChange: S
|
|
839
868
|
});
|
|
840
|
-
const
|
|
869
|
+
const p = {
|
|
841
870
|
decimalMaxLength: n,
|
|
842
871
|
decimalMinLength: r,
|
|
843
|
-
onChange:
|
|
872
|
+
onChange: S,
|
|
844
873
|
formatOn: i,
|
|
845
874
|
thousandSeparator: s,
|
|
846
875
|
thousandStyle: a,
|
|
847
876
|
decimalSeparator: c,
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
877
|
+
locale: l,
|
|
878
|
+
enableCompactNotation: o,
|
|
879
|
+
enableNegative: h,
|
|
880
|
+
enableLeadingZeros: f,
|
|
881
|
+
rawValueMode: u,
|
|
882
|
+
...E
|
|
853
883
|
};
|
|
854
|
-
if (this.resolvedOptions = this.getResolvedOptions(
|
|
855
|
-
const
|
|
856
|
-
this.rawValue =
|
|
884
|
+
if (this.resolvedOptions = this.getResolvedOptions(p), this.createInputElement(t, p), this.setupEventListeners(), this.resolvedOptions.rawValueMode && this.element.value) {
|
|
885
|
+
const g = this.element.value, d = this.resolvedOptions.thousandSeparator ? v(g, this.resolvedOptions.thousandSeparator) : g;
|
|
886
|
+
this.rawValue = d, this.element.value = this.formatValueForDisplay(d);
|
|
857
887
|
} else if (this.element.value) {
|
|
858
|
-
const
|
|
859
|
-
this.element.value = this.formatValueForDisplay(
|
|
888
|
+
const g = this.element.value;
|
|
889
|
+
this.element.value = this.formatValueForDisplay(g);
|
|
860
890
|
}
|
|
861
891
|
}
|
|
862
892
|
createInputElement(t, n) {
|
|
863
893
|
this.element = document.createElement("input"), this.element.setAttribute("type", "text"), this.element.setAttribute("inputmode", "decimal"), this.element.setAttribute("spellcheck", "false"), this.element.setAttribute("autocomplete", "off");
|
|
864
|
-
const r =
|
|
894
|
+
const r = Fe(this.resolvedOptions.decimalSeparator, this.resolvedOptions.enableNegative);
|
|
865
895
|
this.element.setAttribute("pattern", r);
|
|
866
896
|
const {
|
|
867
897
|
decimalMaxLength: i,
|
|
@@ -870,41 +900,41 @@ class gt {
|
|
|
870
900
|
thousandSeparator: c,
|
|
871
901
|
thousandStyle: l,
|
|
872
902
|
decimalSeparator: o,
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
903
|
+
locale: h,
|
|
904
|
+
enableCompactNotation: f,
|
|
905
|
+
enableNegative: u,
|
|
906
|
+
enableLeadingZeros: S,
|
|
907
|
+
rawValueMode: E,
|
|
908
|
+
onChange: p,
|
|
909
|
+
value: g,
|
|
910
|
+
defaultValue: d,
|
|
911
|
+
type: L,
|
|
912
|
+
inputMode: b,
|
|
913
|
+
spellcheck: ee,
|
|
914
|
+
autocomplete: dt,
|
|
915
|
+
...te
|
|
885
916
|
} = n;
|
|
886
|
-
Object.assign(this.element,
|
|
917
|
+
Object.assign(this.element, te), g !== void 0 ? this.element.value = g : d !== void 0 && (this.element.defaultValue = d, this.element.value = d), t.appendChild(this.element);
|
|
887
918
|
}
|
|
888
919
|
setupEventListeners() {
|
|
889
|
-
this.element.addEventListener("input", this.handleChange.bind(this)), this.element.addEventListener("keydown", this.handleKeyDown.bind(this)), this.element.addEventListener("paste", this.handlePaste.bind(this)), this.resolvedOptions.formatOn ===
|
|
920
|
+
this.element.addEventListener("input", this.handleChange.bind(this)), this.element.addEventListener("keydown", this.handleKeyDown.bind(this)), this.element.addEventListener("paste", this.handlePaste.bind(this)), this.resolvedOptions.formatOn === N.Blur && this.resolvedOptions.thousandSeparator && (this.element.addEventListener("focus", this.handleFocus.bind(this)), this.element.addEventListener("blur", this.handleBlur.bind(this)));
|
|
890
921
|
}
|
|
891
922
|
getResolvedOptions(t) {
|
|
892
|
-
const n =
|
|
923
|
+
const n = tt(t.locale, {
|
|
893
924
|
thousandSeparator: t.thousandSeparator,
|
|
894
|
-
thousandStyle: t.thousandStyle,
|
|
895
925
|
decimalSeparator: t.decimalSeparator
|
|
896
926
|
});
|
|
897
927
|
return {
|
|
898
928
|
decimalMaxLength: t.decimalMaxLength ?? G,
|
|
899
|
-
decimalMinLength: t.decimalMinLength ??
|
|
900
|
-
formatOn: t.formatOn ??
|
|
901
|
-
thousandSeparator: n.thousandSeparator,
|
|
902
|
-
thousandStyle:
|
|
903
|
-
decimalSeparator: n.decimalSeparator,
|
|
904
|
-
enableCompactNotation: t.enableCompactNotation ??
|
|
905
|
-
enableNegative: t.enableNegative ??
|
|
906
|
-
enableLeadingZeros: t.enableLeadingZeros ??
|
|
907
|
-
rawValueMode: t.rawValueMode ??
|
|
929
|
+
decimalMinLength: t.decimalMinLength ?? B,
|
|
930
|
+
formatOn: t.formatOn ?? Z,
|
|
931
|
+
thousandSeparator: n.thousandSeparator ?? ie,
|
|
932
|
+
thousandStyle: t.thousandStyle ?? k,
|
|
933
|
+
decimalSeparator: n.decimalSeparator ?? C,
|
|
934
|
+
enableCompactNotation: t.enableCompactNotation ?? W,
|
|
935
|
+
enableNegative: t.enableNegative ?? U,
|
|
936
|
+
enableLeadingZeros: t.enableLeadingZeros ?? z,
|
|
937
|
+
rawValueMode: t.rawValueMode ?? J,
|
|
908
938
|
onChange: t.onChange
|
|
909
939
|
};
|
|
910
940
|
}
|
|
@@ -940,7 +970,7 @@ class gt {
|
|
|
940
970
|
) : t;
|
|
941
971
|
}
|
|
942
972
|
handleChange(t) {
|
|
943
|
-
const { formatted: n, raw: r } =
|
|
973
|
+
const { formatted: n, raw: r } = Ye(
|
|
944
974
|
t,
|
|
945
975
|
this.resolvedOptions.decimalMaxLength,
|
|
946
976
|
this.caretPositionBeforeChange,
|
|
@@ -949,7 +979,7 @@ class gt {
|
|
|
949
979
|
this.caretPositionBeforeChange = void 0, this.handleValueChange(n, r);
|
|
950
980
|
}
|
|
951
981
|
handleKeyDown(t) {
|
|
952
|
-
const n = t.target, { selectionStart: r, selectionEnd: i } = n, s = this.buildFormattingOptions(), a =
|
|
982
|
+
const n = t.target, { selectionStart: r, selectionEnd: i } = n, s = this.buildFormattingOptions(), a = He(t, {
|
|
953
983
|
formatOn: s.formatOn,
|
|
954
984
|
thousandSeparator: s.thousandSeparator,
|
|
955
985
|
ThousandStyle: s.ThousandStyle,
|
|
@@ -965,15 +995,15 @@ class gt {
|
|
|
965
995
|
};
|
|
966
996
|
}
|
|
967
997
|
handlePaste(t) {
|
|
968
|
-
const { formatted: n, raw: r } =
|
|
998
|
+
const { formatted: n, raw: r } = Ve(t, this.resolvedOptions.decimalMaxLength, this.buildFormattingOptions());
|
|
969
999
|
this.handleValueChange(n, r);
|
|
970
1000
|
const i = new Event("input", { bubbles: !0, cancelable: !0 });
|
|
971
1001
|
this.element.dispatchEvent(i);
|
|
972
1002
|
}
|
|
973
1003
|
handleFocus(t) {
|
|
974
|
-
if (this.resolvedOptions.formatOn ===
|
|
1004
|
+
if (this.resolvedOptions.formatOn === N.Blur && this.resolvedOptions.thousandSeparator) {
|
|
975
1005
|
const n = t.target;
|
|
976
|
-
n.value =
|
|
1006
|
+
n.value = v(n.value, this.resolvedOptions.thousandSeparator);
|
|
977
1007
|
}
|
|
978
1008
|
}
|
|
979
1009
|
handleBlur(t) {
|
|
@@ -981,7 +1011,7 @@ class gt {
|
|
|
981
1011
|
if (r && i !== m.None && n.value) {
|
|
982
1012
|
const s = this.formatValueForDisplay(n.value);
|
|
983
1013
|
n.value = s;
|
|
984
|
-
const a = this.resolvedOptions.rawValueMode ?
|
|
1014
|
+
const a = this.resolvedOptions.rawValueMode ? v(s, r) : void 0;
|
|
985
1015
|
this.handleValueChange(s, a);
|
|
986
1016
|
}
|
|
987
1017
|
}
|
|
@@ -990,7 +1020,7 @@ class gt {
|
|
|
990
1020
|
}
|
|
991
1021
|
setValue(t) {
|
|
992
1022
|
if (this.resolvedOptions.rawValueMode) {
|
|
993
|
-
const n = this.resolvedOptions.thousandSeparator ?
|
|
1023
|
+
const n = this.resolvedOptions.thousandSeparator ? v(t, this.resolvedOptions.thousandSeparator) : t;
|
|
994
1024
|
this.rawValue = n, this.element.value = this.formatValueForDisplay(n);
|
|
995
1025
|
} else
|
|
996
1026
|
this.element.value = t;
|
|
@@ -1038,7 +1068,7 @@ class gt {
|
|
|
1038
1068
|
const t = this.getValue();
|
|
1039
1069
|
if (!t)
|
|
1040
1070
|
return NaN;
|
|
1041
|
-
const n = this.resolvedOptions.thousandSeparator ?
|
|
1071
|
+
const n = this.resolvedOptions.thousandSeparator ? v(t, this.resolvedOptions.thousandSeparator) : t, r = this.resolvedOptions.decimalSeparator && this.resolvedOptions.decimalSeparator !== "." ? n.replace(new RegExp(M(this.resolvedOptions.decimalSeparator), "g"), ".") : n;
|
|
1042
1072
|
return parseFloat(r);
|
|
1043
1073
|
}
|
|
1044
1074
|
/**
|
|
@@ -1054,17 +1084,17 @@ class gt {
|
|
|
1054
1084
|
}
|
|
1055
1085
|
}
|
|
1056
1086
|
export {
|
|
1057
|
-
|
|
1058
|
-
|
|
1087
|
+
N as FormatOn,
|
|
1088
|
+
St as NumoraInput,
|
|
1059
1089
|
m as ThousandStyle,
|
|
1090
|
+
tt as applyLocale,
|
|
1060
1091
|
O as formatInputValue,
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
tt as validateNumoraInputOptions
|
|
1092
|
+
gt as formatValueForDisplay,
|
|
1093
|
+
Fe as getNumoraPattern,
|
|
1094
|
+
et as getSeparatorsFromLocale,
|
|
1095
|
+
Ye as handleOnChangeNumoraInput,
|
|
1096
|
+
He as handleOnKeyDownNumoraInput,
|
|
1097
|
+
Ve as handleOnPasteNumoraInput,
|
|
1098
|
+
v as removeThousandSeparators,
|
|
1099
|
+
nt as validateNumoraInputOptions
|
|
1070
1100
|
};
|
package/dist/types.d.ts
CHANGED
package/dist/utils/locale.d.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { ThousandStyle } from '../types';
|
|
2
1
|
export declare function getSeparatorsFromLocale(locale?: string): {
|
|
3
2
|
thousandSeparator: string;
|
|
4
3
|
decimalSeparator: string;
|
|
5
4
|
};
|
|
6
|
-
export declare function
|
|
5
|
+
export declare function applyLocale(locale: string | true | undefined, options: {
|
|
7
6
|
thousandSeparator?: string;
|
|
8
|
-
thousandStyle?: ThousandStyle;
|
|
9
7
|
decimalSeparator?: string;
|
|
10
8
|
}): {
|
|
11
|
-
thousandSeparator
|
|
12
|
-
|
|
13
|
-
decimalSeparator: string;
|
|
9
|
+
thousandSeparator?: string;
|
|
10
|
+
decimalSeparator?: string;
|
|
14
11
|
};
|