@vlrc-fe/components 1.0.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/README.md +193 -0
- package/dist/index.cjs +1 -0
- package/dist/index.js +42 -0
- package/dist/index10.cjs +1 -0
- package/dist/index10.js +85 -0
- package/dist/index100.cjs +1 -0
- package/dist/index100.js +65 -0
- package/dist/index101.cjs +1 -0
- package/dist/index101.js +48 -0
- package/dist/index102.cjs +1 -0
- package/dist/index102.js +67 -0
- package/dist/index103.cjs +1 -0
- package/dist/index103.js +151 -0
- package/dist/index104.cjs +1 -0
- package/dist/index104.js +23 -0
- package/dist/index105.cjs +1 -0
- package/dist/index105.js +27 -0
- package/dist/index106.cjs +1 -0
- package/dist/index106.js +53 -0
- package/dist/index107.cjs +1 -0
- package/dist/index107.js +161 -0
- package/dist/index108.cjs +1 -0
- package/dist/index108.js +16 -0
- package/dist/index109.cjs +1 -0
- package/dist/index11.cjs +1 -0
- package/dist/index11.js +86 -0
- package/dist/index12.cjs +1 -0
- package/dist/index12.js +122 -0
- package/dist/index13.cjs +1 -0
- package/dist/index13.js +14 -0
- package/dist/index14.cjs +1 -0
- package/dist/index14.js +16 -0
- package/dist/index15.cjs +1 -0
- package/dist/index15.js +115 -0
- package/dist/index16.cjs +1 -0
- package/dist/index16.js +727 -0
- package/dist/index17.cjs +1 -0
- package/dist/index17.js +348 -0
- package/dist/index18.cjs +1 -0
- package/dist/index18.js +76 -0
- package/dist/index19.cjs +1 -0
- package/dist/index19.js +14 -0
- package/dist/index2.cjs +1 -0
- package/dist/index2.js +122 -0
- package/dist/index20.cjs +1 -0
- package/dist/index20.js +116 -0
- package/dist/index21.cjs +1 -0
- package/dist/index21.js +35 -0
- package/dist/index22.cjs +1 -0
- package/dist/index22.js +18 -0
- package/dist/index23.cjs +1 -0
- package/dist/index23.js +27 -0
- package/dist/index24.cjs +1 -0
- package/dist/index24.js +35 -0
- package/dist/index25.cjs +1 -0
- package/dist/index25.js +97 -0
- package/dist/index26.cjs +1 -0
- package/dist/index26.js +28 -0
- package/dist/index27.cjs +1 -0
- package/dist/index27.js +14 -0
- package/dist/index28.cjs +1 -0
- package/dist/index28.js +67 -0
- package/dist/index29.cjs +1 -0
- package/dist/index29.js +13 -0
- package/dist/index3.cjs +1 -0
- package/dist/index3.js +8 -0
- package/dist/index30.cjs +1 -0
- package/dist/index30.js +35 -0
- package/dist/index31.cjs +1 -0
- package/dist/index31.js +43 -0
- package/dist/index32.cjs +1 -0
- package/dist/index32.js +14 -0
- package/dist/index33.cjs +1 -0
- package/dist/index33.js +64 -0
- package/dist/index34.cjs +1 -0
- package/dist/index34.js +23 -0
- package/dist/index35.cjs +1 -0
- package/dist/index35.js +34 -0
- package/dist/index36.cjs +1 -0
- package/dist/index36.js +27 -0
- package/dist/index37.cjs +1 -0
- package/dist/index37.js +26 -0
- package/dist/index38.cjs +1 -0
- package/dist/index38.js +157 -0
- package/dist/index39.cjs +1 -0
- package/dist/index39.js +34 -0
- package/dist/index4.cjs +1 -0
- package/dist/index4.js +43 -0
- package/dist/index40.cjs +1 -0
- package/dist/index40.js +46 -0
- package/dist/index41.cjs +1 -0
- package/dist/index41.js +118 -0
- package/dist/index42.cjs +1 -0
- package/dist/index42.js +125 -0
- package/dist/index43.cjs +1 -0
- package/dist/index43.js +26 -0
- package/dist/index44.cjs +1 -0
- package/dist/index44.js +88 -0
- package/dist/index45.cjs +1 -0
- package/dist/index45.js +221 -0
- package/dist/index46.cjs +1 -0
- package/dist/index46.js +166 -0
- package/dist/index47.cjs +1 -0
- package/dist/index47.js +126 -0
- package/dist/index48.cjs +1 -0
- package/dist/index48.js +15 -0
- package/dist/index49.cjs +1 -0
- package/dist/index49.js +9 -0
- package/dist/index5.cjs +1 -0
- package/dist/index5.js +24 -0
- package/dist/index50.cjs +1 -0
- package/dist/index50.js +17 -0
- package/dist/index51.cjs +1 -0
- package/dist/index51.js +22 -0
- package/dist/index52.cjs +1 -0
- package/dist/index52.js +18 -0
- package/dist/index53.cjs +1 -0
- package/dist/index53.js +6 -0
- package/dist/index54.cjs +1 -0
- package/dist/index54.js +7 -0
- package/dist/index55.cjs +1 -0
- package/dist/index55.js +8 -0
- package/dist/index56.cjs +1 -0
- package/dist/index56.js +7 -0
- package/dist/index57.cjs +1 -0
- package/dist/index57.js +7 -0
- package/dist/index58.cjs +1 -0
- package/dist/index58.js +9 -0
- package/dist/index59.cjs +1 -0
- package/dist/index59.js +69 -0
- package/dist/index6.cjs +1 -0
- package/dist/index6.js +51 -0
- package/dist/index60.cjs +1 -0
- package/dist/index60.js +11 -0
- package/dist/index61.cjs +1 -0
- package/dist/index61.js +202 -0
- package/dist/index62.cjs +1 -0
- package/dist/index62.js +124 -0
- package/dist/index63.cjs +1 -0
- package/dist/index63.js +32 -0
- package/dist/index64.cjs +1 -0
- package/dist/index64.js +20 -0
- package/dist/index65.cjs +1 -0
- package/dist/index65.js +69 -0
- package/dist/index66.cjs +1 -0
- package/dist/index66.js +32 -0
- package/dist/index67.cjs +1 -0
- package/dist/index67.js +11 -0
- package/dist/index68.cjs +1 -0
- package/dist/index68.js +280 -0
- package/dist/index69.cjs +1 -0
- package/dist/index69.js +157 -0
- package/dist/index7.cjs +1 -0
- package/dist/index7.js +88 -0
- package/dist/index70.cjs +1 -0
- package/dist/index70.js +20 -0
- package/dist/index71.cjs +1 -0
- package/dist/index71.js +10 -0
- package/dist/index72.cjs +1 -0
- package/dist/index72.js +14 -0
- package/dist/index73.cjs +1 -0
- package/dist/index73.js +8 -0
- package/dist/index74.cjs +1 -0
- package/dist/index74.js +8 -0
- package/dist/index75.cjs +1 -0
- package/dist/index75.js +11 -0
- package/dist/index76.cjs +1 -0
- package/dist/index76.js +10 -0
- package/dist/index77.cjs +1 -0
- package/dist/index77.js +6 -0
- package/dist/index78.cjs +1 -0
- package/dist/index78.js +8 -0
- package/dist/index79.cjs +1 -0
- package/dist/index79.js +8 -0
- package/dist/index8.cjs +1 -0
- package/dist/index8.js +68 -0
- package/dist/index80.cjs +1 -0
- package/dist/index80.js +10 -0
- package/dist/index81.cjs +1 -0
- package/dist/index81.js +11 -0
- package/dist/index82.cjs +1 -0
- package/dist/index82.js +15 -0
- package/dist/index83.cjs +1 -0
- package/dist/index83.js +11 -0
- package/dist/index84.cjs +1 -0
- package/dist/index84.js +11 -0
- package/dist/index85.cjs +1 -0
- package/dist/index85.js +6 -0
- package/dist/index86.cjs +1 -0
- package/dist/index86.js +43 -0
- package/dist/index87.cjs +1 -0
- package/dist/index87.js +382 -0
- package/dist/index88.cjs +1 -0
- package/dist/index88.js +40 -0
- package/dist/index89.cjs +1 -0
- package/dist/index89.js +23 -0
- package/dist/index9.cjs +1 -0
- package/dist/index9.js +20 -0
- package/dist/index90.cjs +1 -0
- package/dist/index90.js +59 -0
- package/dist/index91.cjs +1 -0
- package/dist/index91.js +55 -0
- package/dist/index92.cjs +1 -0
- package/dist/index92.js +54 -0
- package/dist/index93.cjs +1 -0
- package/dist/index93.js +57 -0
- package/dist/index94.cjs +1 -0
- package/dist/index94.js +57 -0
- package/dist/index95.cjs +1 -0
- package/dist/index95.js +88 -0
- package/dist/index96.cjs +1 -0
- package/dist/index96.js +66 -0
- package/dist/index97.cjs +1 -0
- package/dist/index97.js +594 -0
- package/dist/index98.cjs +9 -0
- package/dist/index98.js +30 -0
- package/dist/index99.cjs +1 -0
- package/dist/index99.js +50 -0
- package/package.json +82 -0
package/dist/index97.js
ADDED
|
@@ -0,0 +1,594 @@
|
|
|
1
|
+
import e, { useEffect as t, useLayoutEffect as n, useMemo as r, useRef as i, useState as a } from "react";
|
|
2
|
+
//#region ../../node_modules/.pnpm/react-number-format@5.4.5_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/react-number-format/dist/react-number-format.es.js
|
|
3
|
+
function o(e, t) {
|
|
4
|
+
var n = {};
|
|
5
|
+
for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]);
|
|
6
|
+
if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var i = 0, r = Object.getOwnPropertySymbols(e); i < r.length; i++) t.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[i]) && (n[r[i]] = e[r[i]]);
|
|
7
|
+
return n;
|
|
8
|
+
}
|
|
9
|
+
var s;
|
|
10
|
+
(function(e) {
|
|
11
|
+
e.event = "event", e.props = "prop";
|
|
12
|
+
})(s ||= {});
|
|
13
|
+
function c() {}
|
|
14
|
+
function l(e) {
|
|
15
|
+
var t, n = void 0;
|
|
16
|
+
return function() {
|
|
17
|
+
for (var r = [], i = arguments.length; i--;) r[i] = arguments[i];
|
|
18
|
+
return t && r.length === t.length && r.every(function(e, n) {
|
|
19
|
+
return e === t[n];
|
|
20
|
+
}) ? n : (t = r, n = e.apply(void 0, r), n);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function u(e) {
|
|
24
|
+
return !!(e || "").match(/\d/);
|
|
25
|
+
}
|
|
26
|
+
function d(e) {
|
|
27
|
+
return e == null;
|
|
28
|
+
}
|
|
29
|
+
function f(e) {
|
|
30
|
+
return typeof e == "number" && isNaN(e);
|
|
31
|
+
}
|
|
32
|
+
function p(e) {
|
|
33
|
+
return d(e) || f(e) || typeof e == "number" && !isFinite(e);
|
|
34
|
+
}
|
|
35
|
+
function m(e) {
|
|
36
|
+
return e.replace(/[-[\]/{}()*+?.\\^$|]/g, "\\$&");
|
|
37
|
+
}
|
|
38
|
+
function h(e) {
|
|
39
|
+
switch (e) {
|
|
40
|
+
case "lakh": return /(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/g;
|
|
41
|
+
case "wan": return /(\d)(?=(\d{4})+(?!\d))/g;
|
|
42
|
+
default: return /(\d)(?=(\d{3})+(?!\d))/g;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function g(e, t, n) {
|
|
46
|
+
var r = h(n), i = e.search(/[1-9]/);
|
|
47
|
+
return i = i === -1 ? e.length : i, e.substring(0, i) + e.substring(i, e.length).replace(r, "$1" + t);
|
|
48
|
+
}
|
|
49
|
+
function _(e) {
|
|
50
|
+
var t = i(e);
|
|
51
|
+
return t.current = e, i(function() {
|
|
52
|
+
for (var e = [], n = arguments.length; n--;) e[n] = arguments[n];
|
|
53
|
+
return t.current.apply(t, e);
|
|
54
|
+
}).current;
|
|
55
|
+
}
|
|
56
|
+
function v(e, t) {
|
|
57
|
+
t === void 0 && (t = !0);
|
|
58
|
+
var n = e[0] === "-", r = n && t;
|
|
59
|
+
e = e.replace("-", "");
|
|
60
|
+
var i = e.split(".");
|
|
61
|
+
return {
|
|
62
|
+
beforeDecimal: i[0],
|
|
63
|
+
afterDecimal: i[1] || "",
|
|
64
|
+
hasNegation: n,
|
|
65
|
+
addNegation: r
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function y(e) {
|
|
69
|
+
if (!e) return e;
|
|
70
|
+
var t = e[0] === "-";
|
|
71
|
+
t && (e = e.substring(1, e.length));
|
|
72
|
+
var n = e.split("."), r = n[0].replace(/^0+/, "") || "0", i = n[1] || "";
|
|
73
|
+
return (t ? "-" : "") + r + (i ? "." + i : "");
|
|
74
|
+
}
|
|
75
|
+
function b(e, t, n) {
|
|
76
|
+
for (var r = "", i = n ? "0" : "", a = 0; a <= t - 1; a++) r += e[a] || i;
|
|
77
|
+
return r;
|
|
78
|
+
}
|
|
79
|
+
function x(e, t) {
|
|
80
|
+
return Array(t + 1).join(e);
|
|
81
|
+
}
|
|
82
|
+
function S(e) {
|
|
83
|
+
var t = e + "", n = t[0] === "-" ? "-" : "";
|
|
84
|
+
n && (t = t.substring(1));
|
|
85
|
+
var r = t.split(/[eE]/g), i = r[0], a = r[1];
|
|
86
|
+
if (a = Number(a), !a) return n + i;
|
|
87
|
+
i = i.replace(".", "");
|
|
88
|
+
var o = 1 + a, s = i.length;
|
|
89
|
+
return o < 0 ? i = "0." + x("0", Math.abs(o)) + i : o >= s ? i += x("0", o - s) : i = (i.substring(0, o) || "0") + "." + i.substring(o), n + i;
|
|
90
|
+
}
|
|
91
|
+
function C(e, t, n) {
|
|
92
|
+
if (["", "-"].indexOf(e) !== -1) return e;
|
|
93
|
+
var r = (e.indexOf(".") !== -1 || n) && t, i = v(e), a = i.beforeDecimal, o = i.afterDecimal, s = i.hasNegation, c = parseFloat("0." + (o || "0")), l = (o.length <= t ? "0." + o : c.toFixed(t)).split("."), u = a;
|
|
94
|
+
a && Number(l[0]) && (u = a.split("").reverse().reduce(function(e, t, n) {
|
|
95
|
+
return e.length > n ? (Number(e[0]) + Number(t)).toString() + e.substring(1, e.length) : t + e;
|
|
96
|
+
}, l[0]));
|
|
97
|
+
var d = b(l[1] || "", t, n), f = s ? "-" : "", p = r ? "." : "";
|
|
98
|
+
return "" + f + u + p + d;
|
|
99
|
+
}
|
|
100
|
+
function w(e, t) {
|
|
101
|
+
if (e.value = e.value, e !== null) {
|
|
102
|
+
if (e.createTextRange) {
|
|
103
|
+
var n = e.createTextRange();
|
|
104
|
+
return n.move("character", t), n.select(), !0;
|
|
105
|
+
}
|
|
106
|
+
return e.selectionStart || e.selectionStart === 0 ? (e.focus(), e.setSelectionRange(t, t), !0) : (e.focus(), !1);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
var T = l(function(e, t) {
|
|
110
|
+
for (var n = 0, r = 0, i = e.length, a = t.length; e[n] === t[n] && n < i;) n++;
|
|
111
|
+
for (; e[i - 1 - r] === t[a - 1 - r] && a - r > n && i - r > n;) r++;
|
|
112
|
+
return {
|
|
113
|
+
from: {
|
|
114
|
+
start: n,
|
|
115
|
+
end: i - r
|
|
116
|
+
},
|
|
117
|
+
to: {
|
|
118
|
+
start: n,
|
|
119
|
+
end: a - r
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}), E = function(e, t) {
|
|
123
|
+
var n = Math.min(e.selectionStart, t);
|
|
124
|
+
return {
|
|
125
|
+
from: {
|
|
126
|
+
start: n,
|
|
127
|
+
end: e.selectionEnd
|
|
128
|
+
},
|
|
129
|
+
to: {
|
|
130
|
+
start: n,
|
|
131
|
+
end: t
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
function D(e, t, n) {
|
|
136
|
+
return Math.min(Math.max(e, t), n);
|
|
137
|
+
}
|
|
138
|
+
function O(e) {
|
|
139
|
+
return Math.max(e.selectionStart, e.selectionEnd);
|
|
140
|
+
}
|
|
141
|
+
function k() {
|
|
142
|
+
return typeof navigator < "u" && !(navigator.platform && /iPhone|iPod/.test(navigator.platform));
|
|
143
|
+
}
|
|
144
|
+
function A(e) {
|
|
145
|
+
return {
|
|
146
|
+
from: {
|
|
147
|
+
start: 0,
|
|
148
|
+
end: 0
|
|
149
|
+
},
|
|
150
|
+
to: {
|
|
151
|
+
start: 0,
|
|
152
|
+
end: e.length
|
|
153
|
+
},
|
|
154
|
+
lastValue: ""
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function j(e) {
|
|
158
|
+
var t = e.currentValue, n = e.formattedValue, r = e.currentValueIndex, i = e.formattedValueIndex;
|
|
159
|
+
return t[r] === n[i];
|
|
160
|
+
}
|
|
161
|
+
function M(e, t, n, r, i, a, o) {
|
|
162
|
+
o === void 0 && (o = j);
|
|
163
|
+
var s = i.findIndex(function(e) {
|
|
164
|
+
return e;
|
|
165
|
+
}), c = e.slice(0, s);
|
|
166
|
+
!t && !n.startsWith(c) && (t = c, n = c + n, r += c.length);
|
|
167
|
+
for (var l = n.length, u = e.length, d = {}, f = Array(l), p = 0; p < l; p++) {
|
|
168
|
+
f[p] = -1;
|
|
169
|
+
for (var m = 0, h = u; m < h; m++) if (o({
|
|
170
|
+
currentValue: n,
|
|
171
|
+
lastValue: t,
|
|
172
|
+
formattedValue: e,
|
|
173
|
+
currentValueIndex: p,
|
|
174
|
+
formattedValueIndex: m
|
|
175
|
+
}) && d[m] !== !0) {
|
|
176
|
+
f[p] = m, d[m] = !0;
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
for (var g = r; g < l && (f[g] === -1 || !a(n[g]));) g++;
|
|
181
|
+
var _ = g === l || f[g] === -1 ? u : f[g];
|
|
182
|
+
for (g = r - 1; g > 0 && f[g] === -1;) g--;
|
|
183
|
+
var v = g === -1 || f[g] === -1 ? 0 : f[g] + 1;
|
|
184
|
+
return v > _ ? _ : r - v < _ - r ? v : _;
|
|
185
|
+
}
|
|
186
|
+
function N(e, t, n, r) {
|
|
187
|
+
var i = e.length;
|
|
188
|
+
if (t = D(t, 0, i), r === "left") {
|
|
189
|
+
for (; t >= 0 && !n[t];) t--;
|
|
190
|
+
t === -1 && (t = n.indexOf(!0));
|
|
191
|
+
} else {
|
|
192
|
+
for (; t <= i && !n[t];) t++;
|
|
193
|
+
t > i && (t = n.lastIndexOf(!0));
|
|
194
|
+
}
|
|
195
|
+
return t === -1 && (t = i), t;
|
|
196
|
+
}
|
|
197
|
+
function P(e) {
|
|
198
|
+
for (var t = Array.from({ length: e.length + 1 }).map(function() {
|
|
199
|
+
return !0;
|
|
200
|
+
}), n = 0, r = t.length; n < r; n++) t[n] = !!(u(e[n]) || u(e[n - 1]));
|
|
201
|
+
return t;
|
|
202
|
+
}
|
|
203
|
+
function F(e, n, i, o, l, u) {
|
|
204
|
+
u === void 0 && (u = c);
|
|
205
|
+
var f = _(function(e, t) {
|
|
206
|
+
var n, r;
|
|
207
|
+
return p(e) ? (r = "", n = "") : typeof e == "number" || t ? (r = typeof e == "number" ? S(e) : e, n = o(r)) : (r = l(e, void 0), n = o(r)), {
|
|
208
|
+
formattedValue: n,
|
|
209
|
+
numAsString: r
|
|
210
|
+
};
|
|
211
|
+
}), m = a(function() {
|
|
212
|
+
return f(d(e) ? n : e, i);
|
|
213
|
+
}), h = m[0], g = m[1], v = _(function(e, t) {
|
|
214
|
+
e.formattedValue !== h.formattedValue && g({
|
|
215
|
+
formattedValue: e.formattedValue,
|
|
216
|
+
numAsString: e.value
|
|
217
|
+
}), u(e, t);
|
|
218
|
+
}), y = e, b = i;
|
|
219
|
+
d(e) && (y = h.numAsString, b = !0);
|
|
220
|
+
var x = f(y, b);
|
|
221
|
+
return r(function() {
|
|
222
|
+
g(x);
|
|
223
|
+
}, [x.formattedValue]), t(function() {
|
|
224
|
+
if (!d(n) && d(e) && h.formattedValue !== "") {
|
|
225
|
+
var t = parseFloat(h.numAsString);
|
|
226
|
+
v({
|
|
227
|
+
formattedValue: h.formattedValue,
|
|
228
|
+
value: h.numAsString,
|
|
229
|
+
floatValue: isNaN(t) ? void 0 : t
|
|
230
|
+
}, {
|
|
231
|
+
event: void 0,
|
|
232
|
+
source: s.props
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
}, []), [h, v];
|
|
236
|
+
}
|
|
237
|
+
function I(e) {
|
|
238
|
+
return e.replace(/[^0-9]/g, "");
|
|
239
|
+
}
|
|
240
|
+
function L(e) {
|
|
241
|
+
return e;
|
|
242
|
+
}
|
|
243
|
+
function R(r) {
|
|
244
|
+
var l = r.type;
|
|
245
|
+
l === void 0 && (l = "text");
|
|
246
|
+
var d = r.displayType;
|
|
247
|
+
d === void 0 && (d = "input");
|
|
248
|
+
var f = r.customInput, p = r.renderText, m = r.getInputRef, h = r.format;
|
|
249
|
+
h === void 0 && (h = L);
|
|
250
|
+
var g = r.removeFormatting;
|
|
251
|
+
g === void 0 && (g = I);
|
|
252
|
+
var _ = r.defaultValue, v = r.valueIsNumericString, y = r.onValueChange, b = r.isAllowed, x = r.onChange;
|
|
253
|
+
x === void 0 && (x = c);
|
|
254
|
+
var S = r.onKeyDown;
|
|
255
|
+
S === void 0 && (S = c);
|
|
256
|
+
var C = r.onMouseUp;
|
|
257
|
+
C === void 0 && (C = c);
|
|
258
|
+
var D = r.onFocus;
|
|
259
|
+
D === void 0 && (D = c);
|
|
260
|
+
var A = r.onBlur;
|
|
261
|
+
A === void 0 && (A = c);
|
|
262
|
+
var j = r.value, R = r.getCaretBoundary;
|
|
263
|
+
R === void 0 && (R = P);
|
|
264
|
+
var z = r.isValidInputCharacter;
|
|
265
|
+
z === void 0 && (z = u);
|
|
266
|
+
var B = r.isCharacterSame, V = o(r, [
|
|
267
|
+
"type",
|
|
268
|
+
"displayType",
|
|
269
|
+
"customInput",
|
|
270
|
+
"renderText",
|
|
271
|
+
"getInputRef",
|
|
272
|
+
"format",
|
|
273
|
+
"removeFormatting",
|
|
274
|
+
"defaultValue",
|
|
275
|
+
"valueIsNumericString",
|
|
276
|
+
"onValueChange",
|
|
277
|
+
"isAllowed",
|
|
278
|
+
"onChange",
|
|
279
|
+
"onKeyDown",
|
|
280
|
+
"onMouseUp",
|
|
281
|
+
"onFocus",
|
|
282
|
+
"onBlur",
|
|
283
|
+
"value",
|
|
284
|
+
"getCaretBoundary",
|
|
285
|
+
"isValidInputCharacter",
|
|
286
|
+
"isCharacterSame"
|
|
287
|
+
]), H = F(j, _, !!v, h, g, y), U = H[0], W = U.formattedValue, G = U.numAsString, ee = H[1], K = i(), q = i({
|
|
288
|
+
formattedValue: W,
|
|
289
|
+
numAsString: G
|
|
290
|
+
}), te = function(e, t) {
|
|
291
|
+
q.current = {
|
|
292
|
+
formattedValue: e.formattedValue,
|
|
293
|
+
numAsString: e.value
|
|
294
|
+
}, ee(e, t);
|
|
295
|
+
}, ne = a(!1), re = ne[0], ie = ne[1], J = i(null), Y = i({
|
|
296
|
+
setCaretTimeout: null,
|
|
297
|
+
focusTimeout: null
|
|
298
|
+
});
|
|
299
|
+
t(function() {
|
|
300
|
+
return ie(!0), function() {
|
|
301
|
+
clearTimeout(Y.current.setCaretTimeout), clearTimeout(Y.current.focusTimeout);
|
|
302
|
+
};
|
|
303
|
+
}, []);
|
|
304
|
+
var ae = h, X = function(e, t) {
|
|
305
|
+
var n = parseFloat(t);
|
|
306
|
+
return {
|
|
307
|
+
formattedValue: e,
|
|
308
|
+
value: t,
|
|
309
|
+
floatValue: isNaN(n) ? void 0 : n
|
|
310
|
+
};
|
|
311
|
+
}, Z = function(e, t, n) {
|
|
312
|
+
e.selectionStart === 0 && e.selectionEnd === e.value.length || (w(e, t), Y.current.setCaretTimeout = setTimeout(function() {
|
|
313
|
+
e.value === n && e.selectionStart !== t && w(e, t);
|
|
314
|
+
}, 0));
|
|
315
|
+
}, Q = function(e, t, n) {
|
|
316
|
+
return N(e, t, R(e), n);
|
|
317
|
+
}, $ = function(e, t, n) {
|
|
318
|
+
var r = R(t), i = M(t, W, e, n, r, z, B);
|
|
319
|
+
return i = N(t, i, r), i;
|
|
320
|
+
}, oe = function(e) {
|
|
321
|
+
var t = e.formattedValue;
|
|
322
|
+
t === void 0 && (t = "");
|
|
323
|
+
var n = e.input, r = e.source, i = e.event, a = e.numAsString, o;
|
|
324
|
+
if (n) {
|
|
325
|
+
var s = e.inputValue || n.value, c = O(n);
|
|
326
|
+
n.value = t, o = $(s, t, c), o !== void 0 && Z(n, o, t);
|
|
327
|
+
}
|
|
328
|
+
t !== W && te(X(t, a), {
|
|
329
|
+
event: i,
|
|
330
|
+
source: r
|
|
331
|
+
});
|
|
332
|
+
};
|
|
333
|
+
t(function() {
|
|
334
|
+
var e = q.current, t = e.formattedValue, n = e.numAsString;
|
|
335
|
+
(W !== t || G !== n) && te(X(W, G), {
|
|
336
|
+
event: void 0,
|
|
337
|
+
source: s.props
|
|
338
|
+
});
|
|
339
|
+
}, [W, G]);
|
|
340
|
+
var se = J.current ? O(J.current) : void 0;
|
|
341
|
+
(typeof window < "u" ? n : t)(function() {
|
|
342
|
+
var e = J.current;
|
|
343
|
+
if (W !== q.current.formattedValue && e) {
|
|
344
|
+
var t = $(q.current.formattedValue, W, se);
|
|
345
|
+
e.value = W, Z(e, t, W);
|
|
346
|
+
}
|
|
347
|
+
}, [W]);
|
|
348
|
+
var ce = function(e, t, n) {
|
|
349
|
+
var r = t.target, i = K.current ? E(K.current, r.selectionEnd) : T(W, e), a = Object.assign(Object.assign({}, i), { lastValue: W }), o = g(e, a), s = ae(o);
|
|
350
|
+
if (o = g(s, void 0), b && !b(X(s, o))) {
|
|
351
|
+
var c = t.target, l = $(e, W, O(c));
|
|
352
|
+
return c.value = W, Z(c, l, W), !1;
|
|
353
|
+
}
|
|
354
|
+
return oe({
|
|
355
|
+
formattedValue: s,
|
|
356
|
+
numAsString: o,
|
|
357
|
+
inputValue: e,
|
|
358
|
+
event: t,
|
|
359
|
+
source: n,
|
|
360
|
+
input: t.target
|
|
361
|
+
}), !0;
|
|
362
|
+
}, le = function(e, t) {
|
|
363
|
+
t === void 0 && (t = 0), K.current = {
|
|
364
|
+
selectionStart: e.selectionStart,
|
|
365
|
+
selectionEnd: e.selectionEnd + t
|
|
366
|
+
};
|
|
367
|
+
}, ue = function(e) {
|
|
368
|
+
var t = e.target.value;
|
|
369
|
+
ce(t, e, s.event) && x(e), K.current = void 0;
|
|
370
|
+
}, de = function(e) {
|
|
371
|
+
var t = e.target, n = e.key, r = t.selectionStart, i = t.selectionEnd, a = t.value;
|
|
372
|
+
a === void 0 && (a = "");
|
|
373
|
+
var o;
|
|
374
|
+
n === "ArrowLeft" || n === "Backspace" ? o = Math.max(r - 1, 0) : n === "ArrowRight" ? o = Math.min(r + 1, a.length) : n === "Delete" && (o = r);
|
|
375
|
+
var s = 0;
|
|
376
|
+
n === "Delete" && r === i && (s = 1);
|
|
377
|
+
var c = n === "ArrowLeft" || n === "ArrowRight";
|
|
378
|
+
if (o === void 0 || r !== i && !c) {
|
|
379
|
+
S(e), le(t, s);
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
var l = o;
|
|
383
|
+
c ? (l = Q(a, o, n === "ArrowLeft" ? "left" : "right"), l !== o && e.preventDefault()) : n === "Delete" && !z(a[o]) ? l = Q(a, o, "right") : n === "Backspace" && !z(a[o]) && (l = Q(a, o, "left")), l !== o && Z(t, l, a), S(e), le(t, s);
|
|
384
|
+
}, fe = function(e) {
|
|
385
|
+
var t = e.target, n = function() {
|
|
386
|
+
var e = t.selectionStart, n = t.selectionEnd, r = t.value;
|
|
387
|
+
if (r === void 0 && (r = ""), e === n) {
|
|
388
|
+
var i = Q(r, e);
|
|
389
|
+
i !== e && Z(t, i, r);
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
n(), requestAnimationFrame(function() {
|
|
393
|
+
n();
|
|
394
|
+
}), C(e), le(t);
|
|
395
|
+
}, pe = function(e) {
|
|
396
|
+
e.persist && e.persist();
|
|
397
|
+
var t = e.target, n = e.currentTarget;
|
|
398
|
+
J.current = t, Y.current.focusTimeout = setTimeout(function() {
|
|
399
|
+
var r = t.selectionStart, i = t.selectionEnd, a = t.value;
|
|
400
|
+
a === void 0 && (a = "");
|
|
401
|
+
var o = Q(a, r);
|
|
402
|
+
o !== r && !(r === 0 && i === a.length) && Z(t, o, a), D(Object.assign(Object.assign({}, e), { currentTarget: n }));
|
|
403
|
+
}, 0);
|
|
404
|
+
}, me = function(e) {
|
|
405
|
+
J.current = null, clearTimeout(Y.current.focusTimeout), clearTimeout(Y.current.setCaretTimeout), A(e);
|
|
406
|
+
}, he = re && k() ? "numeric" : void 0, ge = Object.assign({ inputMode: he }, V, {
|
|
407
|
+
type: l,
|
|
408
|
+
value: W,
|
|
409
|
+
onChange: ue,
|
|
410
|
+
onKeyDown: de,
|
|
411
|
+
onMouseUp: fe,
|
|
412
|
+
onFocus: pe,
|
|
413
|
+
onBlur: me
|
|
414
|
+
});
|
|
415
|
+
if (d === "text") return p ? e.createElement(e.Fragment, null, p(W, V) || null) : e.createElement("span", Object.assign({}, V, { ref: m }), W);
|
|
416
|
+
if (f) {
|
|
417
|
+
var _e = f;
|
|
418
|
+
return e.createElement(_e, Object.assign({}, ge, { ref: m }));
|
|
419
|
+
}
|
|
420
|
+
return e.createElement("input", Object.assign({}, ge, { ref: m }));
|
|
421
|
+
}
|
|
422
|
+
function z(e, t) {
|
|
423
|
+
var n = t.decimalScale, r = t.fixedDecimalScale, i = t.prefix;
|
|
424
|
+
i === void 0 && (i = "");
|
|
425
|
+
var a = t.suffix;
|
|
426
|
+
a === void 0 && (a = "");
|
|
427
|
+
var o = t.allowNegative, s = t.thousandsGroupStyle;
|
|
428
|
+
if (s === void 0 && (s = "thousand"), e === "" || e === "-") return e;
|
|
429
|
+
var c = B(t), l = c.thousandSeparator, u = c.decimalSeparator, d = n !== 0 && e.indexOf(".") !== -1 || n && r, f = v(e, o), p = f.beforeDecimal, m = f.afterDecimal, h = f.addNegation;
|
|
430
|
+
return n !== void 0 && (m = b(m, n, !!r)), l && (p = g(p, l, s)), i && (p = i + p), a && (m += a), h && (p = "-" + p), e = p + (d && u || "") + m, e;
|
|
431
|
+
}
|
|
432
|
+
function B(e) {
|
|
433
|
+
var t = e.decimalSeparator;
|
|
434
|
+
t === void 0 && (t = ".");
|
|
435
|
+
var n = e.thousandSeparator, r = e.allowedDecimalSeparators;
|
|
436
|
+
return n === !0 && (n = ","), r ||= [t, "."], {
|
|
437
|
+
decimalSeparator: t,
|
|
438
|
+
thousandSeparator: n,
|
|
439
|
+
allowedDecimalSeparators: r
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
function V(e, t) {
|
|
443
|
+
e === void 0 && (e = "");
|
|
444
|
+
var n = /* @__PURE__ */ RegExp("(-)"), r = /* @__PURE__ */ RegExp("(-)(.)*(-)"), i = n.test(e), a = r.test(e);
|
|
445
|
+
return e = e.replace(/-/g, ""), i && !a && t && (e = "-" + e), e;
|
|
446
|
+
}
|
|
447
|
+
function H(e, t) {
|
|
448
|
+
return RegExp("(^-)|[0-9]|" + m(e), t ? "g" : void 0);
|
|
449
|
+
}
|
|
450
|
+
function U(e, t, n) {
|
|
451
|
+
return e === "" ? !0 : !t?.match(/\d/) && !n?.match(/\d/) && typeof e == "string" && !isNaN(Number(e));
|
|
452
|
+
}
|
|
453
|
+
function W(e, t, n) {
|
|
454
|
+
var r;
|
|
455
|
+
t === void 0 && (t = A(e));
|
|
456
|
+
var i = n.allowNegative, a = n.prefix;
|
|
457
|
+
a === void 0 && (a = "");
|
|
458
|
+
var o = n.suffix;
|
|
459
|
+
o === void 0 && (o = "");
|
|
460
|
+
var s = n.decimalScale, c = t.from, l = t.to, d = l.start, f = l.end, p = B(n), h = p.allowedDecimalSeparators, g = p.decimalSeparator, _ = e[f] === g;
|
|
461
|
+
if (u(e) && (e === a || e === o) && t.lastValue === "") return e;
|
|
462
|
+
if (f - d === 1 && h.indexOf(e[d]) !== -1) {
|
|
463
|
+
var y = s === 0 ? "" : g;
|
|
464
|
+
e = e.substring(0, d) + y + e.substring(d + 1, e.length);
|
|
465
|
+
}
|
|
466
|
+
var b = function(e, t, n) {
|
|
467
|
+
var r = !1, i = !1;
|
|
468
|
+
a.startsWith("-") ? r = !1 : e.startsWith("--") ? (r = !1, i = !0) : o.startsWith("-") && e.length === o.length ? r = !1 : e[0] === "-" && (r = !0);
|
|
469
|
+
var s = +!!r;
|
|
470
|
+
return i && (s = 2), s && (e = e.substring(s), t -= s, n -= s), {
|
|
471
|
+
value: e,
|
|
472
|
+
start: t,
|
|
473
|
+
end: n,
|
|
474
|
+
hasNegation: r
|
|
475
|
+
};
|
|
476
|
+
}, x = b(e, d, f), S = x.hasNegation;
|
|
477
|
+
r = x, e = r.value, d = r.start, f = r.end;
|
|
478
|
+
var C = b(t.lastValue, c.start, c.end), w = C.start, T = C.end, E = C.value, D = e.substring(d, f);
|
|
479
|
+
e.length && E.length && (w > E.length - o.length || T < a.length) && !(D && o.startsWith(D)) && (e = E);
|
|
480
|
+
var O = 0;
|
|
481
|
+
e.startsWith(a) ? O += a.length : d < a.length && (O = d), e = e.substring(O), f -= O;
|
|
482
|
+
var k = e.length, j = e.length - o.length;
|
|
483
|
+
e.endsWith(o) ? k = j : (f > j || f > e.length - o.length) && (k = f), e = e.substring(0, k), e = V(S ? "-" + e : e, i), e = (e.match(H(g, !0)) || []).join("");
|
|
484
|
+
var M = e.indexOf(g);
|
|
485
|
+
e = e.replace(new RegExp(m(g), "g"), function(e, t) {
|
|
486
|
+
return t === M ? "." : "";
|
|
487
|
+
});
|
|
488
|
+
var N = v(e, i), P = N.beforeDecimal, F = N.afterDecimal, I = N.addNegation;
|
|
489
|
+
return l.end - l.start < c.end - c.start && P === "" && _ && !parseFloat(F) && (e = I ? "-" : ""), e;
|
|
490
|
+
}
|
|
491
|
+
function G(e, t) {
|
|
492
|
+
var n = t.prefix;
|
|
493
|
+
n === void 0 && (n = "");
|
|
494
|
+
var r = t.suffix;
|
|
495
|
+
r === void 0 && (r = "");
|
|
496
|
+
var i = Array.from({ length: e.length + 1 }).map(function() {
|
|
497
|
+
return !0;
|
|
498
|
+
}), a = e[0] === "-";
|
|
499
|
+
i.fill(!1, 0, Math.min(n.length + +!!a, e.length));
|
|
500
|
+
var o = e.length;
|
|
501
|
+
return i.fill(!1, o - r.length + 1, o + 1), i;
|
|
502
|
+
}
|
|
503
|
+
function ee(e) {
|
|
504
|
+
var t = B(e), n = t.thousandSeparator, r = t.decimalSeparator, i = e.prefix;
|
|
505
|
+
i === void 0 && (i = "");
|
|
506
|
+
var a = e.allowNegative;
|
|
507
|
+
if (a === void 0 && (a = !0), n === r) throw Error("\n Decimal separator can't be same as thousand separator.\n thousandSeparator: " + n + " (thousandSeparator = {true} is same as thousandSeparator = \",\")\n decimalSeparator: " + r + " (default value for decimalSeparator is .)\n ");
|
|
508
|
+
return i.startsWith("-") && a && (console.error("\n Prefix can't start with '-' when allowNegative is true.\n prefix: " + i + "\n allowNegative: " + a + "\n "), a = !1), Object.assign(Object.assign({}, e), { allowNegative: a });
|
|
509
|
+
}
|
|
510
|
+
function K(e) {
|
|
511
|
+
e = ee(e), e.decimalSeparator, e.allowedDecimalSeparators, e.thousandsGroupStyle;
|
|
512
|
+
var t = e.suffix, n = e.allowNegative, r = e.allowLeadingZeros, i = e.onKeyDown;
|
|
513
|
+
i === void 0 && (i = c);
|
|
514
|
+
var a = e.onBlur;
|
|
515
|
+
a === void 0 && (a = c);
|
|
516
|
+
var l = e.thousandSeparator, f = e.decimalScale, m = e.fixedDecimalScale, h = e.prefix;
|
|
517
|
+
h === void 0 && (h = "");
|
|
518
|
+
var g = e.defaultValue, _ = e.value, v = e.valueIsNumericString, b = e.onValueChange, x = o(e, [
|
|
519
|
+
"decimalSeparator",
|
|
520
|
+
"allowedDecimalSeparators",
|
|
521
|
+
"thousandsGroupStyle",
|
|
522
|
+
"suffix",
|
|
523
|
+
"allowNegative",
|
|
524
|
+
"allowLeadingZeros",
|
|
525
|
+
"onKeyDown",
|
|
526
|
+
"onBlur",
|
|
527
|
+
"thousandSeparator",
|
|
528
|
+
"decimalScale",
|
|
529
|
+
"fixedDecimalScale",
|
|
530
|
+
"prefix",
|
|
531
|
+
"defaultValue",
|
|
532
|
+
"value",
|
|
533
|
+
"valueIsNumericString",
|
|
534
|
+
"onValueChange"
|
|
535
|
+
]), E = B(e), D = E.decimalSeparator, O = E.allowedDecimalSeparators, k = function(t) {
|
|
536
|
+
return z(t, e);
|
|
537
|
+
}, A = function(t, n) {
|
|
538
|
+
return W(t, n, e);
|
|
539
|
+
}, j = d(_) ? g : _, M = v ?? U(j, h, t);
|
|
540
|
+
d(_) ? d(g) || (M ||= typeof g == "number") : M ||= typeof _ == "number";
|
|
541
|
+
var N = function(e) {
|
|
542
|
+
return p(e) ? e : (typeof e == "number" && (e = S(e)), M && typeof f == "number" ? C(e, f, !!m) : e);
|
|
543
|
+
}, P = F(N(_), N(g), !!M, k, A, b), I = P[0], L = I.numAsString, R = I.formattedValue, V = P[1];
|
|
544
|
+
return Object.assign(Object.assign({}, x), {
|
|
545
|
+
value: R,
|
|
546
|
+
valueIsNumericString: !1,
|
|
547
|
+
isValidInputCharacter: function(e) {
|
|
548
|
+
return e === D ? !0 : u(e);
|
|
549
|
+
},
|
|
550
|
+
isCharacterSame: function(e) {
|
|
551
|
+
var t = e.currentValue, n = e.lastValue, r = e.formattedValue, i = e.currentValueIndex, a = e.formattedValueIndex, o = t[i], s = r[a], c = T(n, t).to, l = function(e) {
|
|
552
|
+
return A(e).indexOf(".") + h.length;
|
|
553
|
+
};
|
|
554
|
+
return _ === 0 && m && f && t[c.start] === D && l(t) < i && l(r) > a ? !1 : i >= c.start && i < c.end && O && O.includes(o) && s === D ? !0 : o === s;
|
|
555
|
+
},
|
|
556
|
+
onValueChange: V,
|
|
557
|
+
format: k,
|
|
558
|
+
removeFormatting: A,
|
|
559
|
+
getCaretBoundary: function(t) {
|
|
560
|
+
return G(t, e);
|
|
561
|
+
},
|
|
562
|
+
onKeyDown: function(e) {
|
|
563
|
+
var t = e.target, r = e.key, a = t.selectionStart, o = t.selectionEnd, s = t.value;
|
|
564
|
+
if (s === void 0 && (s = ""), (r === "Backspace" || r === "Delete") && o < h.length && s !== "-") {
|
|
565
|
+
e.preventDefault();
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
if (a !== o) {
|
|
569
|
+
i(e);
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
r === "Backspace" && s[0] === "-" && a === h.length + 1 && n && w(t, 1), f && m && (r === "Backspace" && s[a - 1] === D ? (w(t, a - 1), e.preventDefault()) : r === "Delete" && s[a] === D && e.preventDefault()), O?.includes(r) && s[a] === D && w(t, a + 1);
|
|
573
|
+
var c = l === !0 ? "," : l;
|
|
574
|
+
r === "Backspace" && s[a - 1] === c && w(t, a - 1), r === "Delete" && s[a] === c && w(t, a + 1), i(e);
|
|
575
|
+
},
|
|
576
|
+
onBlur: function(t) {
|
|
577
|
+
var n = L;
|
|
578
|
+
n.match(/\d/g) || (n = ""), r || (n = y(n)), m && f && (n = C(n, f, m)), n !== L && V({
|
|
579
|
+
formattedValue: z(n, e),
|
|
580
|
+
value: n,
|
|
581
|
+
floatValue: parseFloat(n)
|
|
582
|
+
}, {
|
|
583
|
+
event: t,
|
|
584
|
+
source: s.event
|
|
585
|
+
}), a(t);
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
function q(t) {
|
|
590
|
+
var n = K(t);
|
|
591
|
+
return e.createElement(R, Object.assign({}, n));
|
|
592
|
+
}
|
|
593
|
+
//#endregion
|
|
594
|
+
export { q as NumericFormat };
|
package/dist/index98.cjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const e=require("./index2.cjs");let t=require("react");t=e.__toESM(t);function n(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}var r;(function(e){e.event=`event`,e.props=`prop`})(r||={});function i(){}function a(e){var t,n=void 0;return function(){for(var r=[],i=arguments.length;i--;)r[i]=arguments[i];return t&&r.length===t.length&&r.every(function(e,n){return e===t[n]})?n:(t=r,n=e.apply(void 0,r),n)}}function o(e){return!!(e||``).match(/\d/)}function s(e){return e==null}function c(e){return typeof e==`number`&&isNaN(e)}function l(e){return s(e)||c(e)||typeof e==`number`&&!isFinite(e)}function u(e){return e.replace(/[-[\]/{}()*+?.\\^$|]/g,`\\$&`)}function d(e){switch(e){case`lakh`:return/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/g;case`wan`:return/(\d)(?=(\d{4})+(?!\d))/g;default:return/(\d)(?=(\d{3})+(?!\d))/g}}function f(e,t,n){var r=d(n),i=e.search(/[1-9]/);return i=i===-1?e.length:i,e.substring(0,i)+e.substring(i,e.length).replace(r,`$1`+t)}function p(e){var n=(0,t.useRef)(e);return n.current=e,(0,t.useRef)(function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return n.current.apply(n,e)}).current}function m(e,t){t===void 0&&(t=!0);var n=e[0]===`-`,r=n&&t;e=e.replace(`-`,``);var i=e.split(`.`);return{beforeDecimal:i[0],afterDecimal:i[1]||``,hasNegation:n,addNegation:r}}function h(e){if(!e)return e;var t=e[0]===`-`;t&&(e=e.substring(1,e.length));var n=e.split(`.`),r=n[0].replace(/^0+/,``)||`0`,i=n[1]||``;return(t?`-`:``)+r+(i?`.`+i:``)}function g(e,t,n){for(var r=``,i=n?`0`:``,a=0;a<=t-1;a++)r+=e[a]||i;return r}function _(e,t){return Array(t+1).join(e)}function v(e){var t=e+``,n=t[0]===`-`?`-`:``;n&&(t=t.substring(1));var r=t.split(/[eE]/g),i=r[0],a=r[1];if(a=Number(a),!a)return n+i;i=i.replace(`.`,``);var o=1+a,s=i.length;return o<0?i=`0.`+_(`0`,Math.abs(o))+i:o>=s?i+=_(`0`,o-s):i=(i.substring(0,o)||`0`)+`.`+i.substring(o),n+i}function y(e,t,n){if([``,`-`].indexOf(e)!==-1)return e;var r=(e.indexOf(`.`)!==-1||n)&&t,i=m(e),a=i.beforeDecimal,o=i.afterDecimal,s=i.hasNegation,c=parseFloat(`0.`+(o||`0`)),l=(o.length<=t?`0.`+o:c.toFixed(t)).split(`.`),u=a;a&&Number(l[0])&&(u=a.split(``).reverse().reduce(function(e,t,n){return e.length>n?(Number(e[0])+Number(t)).toString()+e.substring(1,e.length):t+e},l[0]));var d=g(l[1]||``,t,n),f=s?`-`:``,p=r?`.`:``;return``+f+u+p+d}function b(e,t){if(e.value=e.value,e!==null){if(e.createTextRange){var n=e.createTextRange();return n.move(`character`,t),n.select(),!0}return e.selectionStart||e.selectionStart===0?(e.focus(),e.setSelectionRange(t,t),!0):(e.focus(),!1)}}var x=a(function(e,t){for(var n=0,r=0,i=e.length,a=t.length;e[n]===t[n]&&n<i;)n++;for(;e[i-1-r]===t[a-1-r]&&a-r>n&&i-r>n;)r++;return{from:{start:n,end:i-r},to:{start:n,end:a-r}}}),S=function(e,t){var n=Math.min(e.selectionStart,t);return{from:{start:n,end:e.selectionEnd},to:{start:n,end:t}}};function C(e,t,n){return Math.min(Math.max(e,t),n)}function w(e){return Math.max(e.selectionStart,e.selectionEnd)}function T(){return typeof navigator<`u`&&!(navigator.platform&&/iPhone|iPod/.test(navigator.platform))}function E(e){return{from:{start:0,end:0},to:{start:0,end:e.length},lastValue:``}}function D(e){var t=e.currentValue,n=e.formattedValue,r=e.currentValueIndex,i=e.formattedValueIndex;return t[r]===n[i]}function O(e,t,n,r,i,a,o){o===void 0&&(o=D);var s=i.findIndex(function(e){return e}),c=e.slice(0,s);!t&&!n.startsWith(c)&&(t=c,n=c+n,r+=c.length);for(var l=n.length,u=e.length,d={},f=Array(l),p=0;p<l;p++){f[p]=-1;for(var m=0,h=u;m<h;m++)if(o({currentValue:n,lastValue:t,formattedValue:e,currentValueIndex:p,formattedValueIndex:m})&&d[m]!==!0){f[p]=m,d[m]=!0;break}}for(var g=r;g<l&&(f[g]===-1||!a(n[g]));)g++;var _=g===l||f[g]===-1?u:f[g];for(g=r-1;g>0&&f[g]===-1;)g--;var v=g===-1||f[g]===-1?0:f[g]+1;return v>_?_:r-v<_-r?v:_}function k(e,t,n,r){var i=e.length;if(t=C(t,0,i),r===`left`){for(;t>=0&&!n[t];)t--;t===-1&&(t=n.indexOf(!0))}else{for(;t<=i&&!n[t];)t++;t>i&&(t=n.lastIndexOf(!0))}return t===-1&&(t=i),t}function A(e){for(var t=Array.from({length:e.length+1}).map(function(){return!0}),n=0,r=t.length;n<r;n++)t[n]=!!(o(e[n])||o(e[n-1]));return t}function j(e,n,a,o,c,u){u===void 0&&(u=i);var d=p(function(e,t){var n,r;return l(e)?(r=``,n=``):typeof e==`number`||t?(r=typeof e==`number`?v(e):e,n=o(r)):(r=c(e,void 0),n=o(r)),{formattedValue:n,numAsString:r}}),f=(0,t.useState)(function(){return d(s(e)?n:e,a)}),m=f[0],h=f[1],g=p(function(e,t){e.formattedValue!==m.formattedValue&&h({formattedValue:e.formattedValue,numAsString:e.value}),u(e,t)}),_=e,y=a;s(e)&&(_=m.numAsString,y=!0);var b=d(_,y);return(0,t.useMemo)(function(){h(b)},[b.formattedValue]),(0,t.useEffect)(function(){if(!s(n)&&s(e)&&m.formattedValue!==``){var t=parseFloat(m.numAsString);g({formattedValue:m.formattedValue,value:m.numAsString,floatValue:isNaN(t)?void 0:t},{event:void 0,source:r.props})}},[]),[m,g]}function M(e){return e.replace(/[^0-9]/g,``)}function N(e){return e}function P(e){var a=e.type;a===void 0&&(a=`text`);var s=e.displayType;s===void 0&&(s=`input`);var c=e.customInput,l=e.renderText,u=e.getInputRef,d=e.format;d===void 0&&(d=N);var f=e.removeFormatting;f===void 0&&(f=M);var p=e.defaultValue,m=e.valueIsNumericString,h=e.onValueChange,g=e.isAllowed,_=e.onChange;_===void 0&&(_=i);var v=e.onKeyDown;v===void 0&&(v=i);var y=e.onMouseUp;y===void 0&&(y=i);var C=e.onFocus;C===void 0&&(C=i);var E=e.onBlur;E===void 0&&(E=i);var D=e.value,P=e.getCaretBoundary;P===void 0&&(P=A);var F=e.isValidInputCharacter;F===void 0&&(F=o);var I=e.isCharacterSame,L=n(e,[`type`,`displayType`,`customInput`,`renderText`,`getInputRef`,`format`,`removeFormatting`,`defaultValue`,`valueIsNumericString`,`onValueChange`,`isAllowed`,`onChange`,`onKeyDown`,`onMouseUp`,`onFocus`,`onBlur`,`value`,`getCaretBoundary`,`isValidInputCharacter`,`isCharacterSame`]),R=j(D,p,!!m,d,f,h),z=R[0],B=z.formattedValue,V=z.numAsString,H=R[1],U=(0,t.useRef)(),W=(0,t.useRef)({formattedValue:B,numAsString:V}),G=function(e,t){W.current={formattedValue:e.formattedValue,numAsString:e.value},H(e,t)},K=(0,t.useState)(!1),ee=K[0],te=K[1],q=(0,t.useRef)(null),J=(0,t.useRef)({setCaretTimeout:null,focusTimeout:null});(0,t.useEffect)(function(){return te(!0),function(){clearTimeout(J.current.setCaretTimeout),clearTimeout(J.current.focusTimeout)}},[]);var ne=d,Y=function(e,t){var n=parseFloat(t);return{formattedValue:e,value:t,floatValue:isNaN(n)?void 0:n}},X=function(e,t,n){e.selectionStart===0&&e.selectionEnd===e.value.length||(b(e,t),J.current.setCaretTimeout=setTimeout(function(){e.value===n&&e.selectionStart!==t&&b(e,t)},0))},Z=function(e,t,n){return k(e,t,P(e),n)},Q=function(e,t,n){var r=P(t),i=O(t,B,e,n,r,F,I);return i=k(t,i,r),i},re=function(e){var t=e.formattedValue;t===void 0&&(t=``);var n=e.input,r=e.source,i=e.event,a=e.numAsString,o;if(n){var s=e.inputValue||n.value,c=w(n);n.value=t,o=Q(s,t,c),o!==void 0&&X(n,o,t)}t!==B&&G(Y(t,a),{event:i,source:r})};(0,t.useEffect)(function(){var e=W.current,t=e.formattedValue,n=e.numAsString;(B!==t||V!==n)&&G(Y(B,V),{event:void 0,source:r.props})},[B,V]);var ie=q.current?w(q.current):void 0;(typeof window<`u`?t.useLayoutEffect:t.useEffect)(function(){var e=q.current;if(B!==W.current.formattedValue&&e){var t=Q(W.current.formattedValue,B,ie);e.value=B,X(e,t,B)}},[B]);var ae=function(e,t,n){var r=t.target,i=U.current?S(U.current,r.selectionEnd):x(B,e),a=Object.assign(Object.assign({},i),{lastValue:B}),o=f(e,a),s=ne(o);if(o=f(s,void 0),g&&!g(Y(s,o))){var c=t.target,l=Q(e,B,w(c));return c.value=B,X(c,l,B),!1}return re({formattedValue:s,numAsString:o,inputValue:e,event:t,source:n,input:t.target}),!0},$=function(e,t){t===void 0&&(t=0),U.current={selectionStart:e.selectionStart,selectionEnd:e.selectionEnd+t}},oe=function(e){var t=e.target.value;ae(t,e,r.event)&&_(e),U.current=void 0},se=function(e){var t=e.target,n=e.key,r=t.selectionStart,i=t.selectionEnd,a=t.value;a===void 0&&(a=``);var o;n===`ArrowLeft`||n===`Backspace`?o=Math.max(r-1,0):n===`ArrowRight`?o=Math.min(r+1,a.length):n===`Delete`&&(o=r);var s=0;n===`Delete`&&r===i&&(s=1);var c=n===`ArrowLeft`||n===`ArrowRight`;if(o===void 0||r!==i&&!c){v(e),$(t,s);return}var l=o;c?(l=Z(a,o,n===`ArrowLeft`?`left`:`right`),l!==o&&e.preventDefault()):n===`Delete`&&!F(a[o])?l=Z(a,o,`right`):n===`Backspace`&&!F(a[o])&&(l=Z(a,o,`left`)),l!==o&&X(t,l,a),v(e),$(t,s)},ce=function(e){var t=e.target,n=function(){var e=t.selectionStart,n=t.selectionEnd,r=t.value;if(r===void 0&&(r=``),e===n){var i=Z(r,e);i!==e&&X(t,i,r)}};n(),requestAnimationFrame(function(){n()}),y(e),$(t)},le=function(e){e.persist&&e.persist();var t=e.target,n=e.currentTarget;q.current=t,J.current.focusTimeout=setTimeout(function(){var r=t.selectionStart,i=t.selectionEnd,a=t.value;a===void 0&&(a=``);var o=Z(a,r);o!==r&&!(r===0&&i===a.length)&&X(t,o,a),C(Object.assign(Object.assign({},e),{currentTarget:n}))},0)},ue=function(e){q.current=null,clearTimeout(J.current.focusTimeout),clearTimeout(J.current.setCaretTimeout),E(e)},de=ee&&T()?`numeric`:void 0,fe=Object.assign({inputMode:de},L,{type:a,value:B,onChange:oe,onKeyDown:se,onMouseUp:ce,onFocus:le,onBlur:ue});if(s===`text`)return l?t.default.createElement(t.default.Fragment,null,l(B,L)||null):t.default.createElement(`span`,Object.assign({},L,{ref:u}),B);if(c){var pe=c;return t.default.createElement(pe,Object.assign({},fe,{ref:u}))}return t.default.createElement(`input`,Object.assign({},fe,{ref:u}))}function F(e,t){var n=t.decimalScale,r=t.fixedDecimalScale,i=t.prefix;i===void 0&&(i=``);var a=t.suffix;a===void 0&&(a=``);var o=t.allowNegative,s=t.thousandsGroupStyle;if(s===void 0&&(s=`thousand`),e===``||e===`-`)return e;var c=I(t),l=c.thousandSeparator,u=c.decimalSeparator,d=n!==0&&e.indexOf(`.`)!==-1||n&&r,p=m(e,o),h=p.beforeDecimal,_=p.afterDecimal,v=p.addNegation;return n!==void 0&&(_=g(_,n,!!r)),l&&(h=f(h,l,s)),i&&(h=i+h),a&&(_+=a),v&&(h=`-`+h),e=h+(d&&u||``)+_,e}function I(e){var t=e.decimalSeparator;t===void 0&&(t=`.`);var n=e.thousandSeparator,r=e.allowedDecimalSeparators;return n===!0&&(n=`,`),r||=[t,`.`],{decimalSeparator:t,thousandSeparator:n,allowedDecimalSeparators:r}}function L(e,t){e===void 0&&(e=``);var n=RegExp(`(-)`),r=RegExp(`(-)(.)*(-)`),i=n.test(e),a=r.test(e);return e=e.replace(/-/g,``),i&&!a&&t&&(e=`-`+e),e}function R(e,t){return RegExp(`(^-)|[0-9]|`+u(e),t?`g`:void 0)}function z(e,t,n){return e===``?!0:!t?.match(/\d/)&&!n?.match(/\d/)&&typeof e==`string`&&!isNaN(Number(e))}function B(e,t,n){var r;t===void 0&&(t=E(e));var i=n.allowNegative,a=n.prefix;a===void 0&&(a=``);var s=n.suffix;s===void 0&&(s=``);var c=n.decimalScale,l=t.from,d=t.to,f=d.start,p=d.end,h=I(n),g=h.allowedDecimalSeparators,_=h.decimalSeparator,v=e[p]===_;if(o(e)&&(e===a||e===s)&&t.lastValue===``)return e;if(p-f===1&&g.indexOf(e[f])!==-1){var y=c===0?``:_;e=e.substring(0,f)+y+e.substring(f+1,e.length)}var b=function(e,t,n){var r=!1,i=!1;a.startsWith(`-`)?r=!1:e.startsWith(`--`)?(r=!1,i=!0):s.startsWith(`-`)&&e.length===s.length?r=!1:e[0]===`-`&&(r=!0);var o=+!!r;return i&&(o=2),o&&(e=e.substring(o),t-=o,n-=o),{value:e,start:t,end:n,hasNegation:r}},x=b(e,f,p),S=x.hasNegation;r=x,e=r.value,f=r.start,p=r.end;var C=b(t.lastValue,l.start,l.end),w=C.start,T=C.end,D=C.value,O=e.substring(f,p);e.length&&D.length&&(w>D.length-s.length||T<a.length)&&!(O&&s.startsWith(O))&&(e=D);var k=0;e.startsWith(a)?k+=a.length:f<a.length&&(k=f),e=e.substring(k),p-=k;var A=e.length,j=e.length-s.length;e.endsWith(s)?A=j:(p>j||p>e.length-s.length)&&(A=p),e=e.substring(0,A),e=L(S?`-`+e:e,i),e=(e.match(R(_,!0))||[]).join(``);var M=e.indexOf(_);e=e.replace(new RegExp(u(_),`g`),function(e,t){return t===M?`.`:``});var N=m(e,i),P=N.beforeDecimal,F=N.afterDecimal,z=N.addNegation;return d.end-d.start<l.end-l.start&&P===``&&v&&!parseFloat(F)&&(e=z?`-`:``),e}function V(e,t){var n=t.prefix;n===void 0&&(n=``);var r=t.suffix;r===void 0&&(r=``);var i=Array.from({length:e.length+1}).map(function(){return!0}),a=e[0]===`-`;i.fill(!1,0,Math.min(n.length+ +!!a,e.length));var o=e.length;return i.fill(!1,o-r.length+1,o+1),i}function H(e){var t=I(e),n=t.thousandSeparator,r=t.decimalSeparator,i=e.prefix;i===void 0&&(i=``);var a=e.allowNegative;if(a===void 0&&(a=!0),n===r)throw Error(`
|
|
2
|
+
Decimal separator can't be same as thousand separator.
|
|
3
|
+
thousandSeparator: `+n+` (thousandSeparator = {true} is same as thousandSeparator = ",")
|
|
4
|
+
decimalSeparator: `+r+` (default value for decimalSeparator is .)
|
|
5
|
+
`);return i.startsWith(`-`)&&a&&(console.error(`
|
|
6
|
+
Prefix can't start with '-' when allowNegative is true.
|
|
7
|
+
prefix: `+i+`
|
|
8
|
+
allowNegative: `+a+`
|
|
9
|
+
`),a=!1),Object.assign(Object.assign({},e),{allowNegative:a})}function U(e){e=H(e),e.decimalSeparator,e.allowedDecimalSeparators,e.thousandsGroupStyle;var t=e.suffix,a=e.allowNegative,c=e.allowLeadingZeros,u=e.onKeyDown;u===void 0&&(u=i);var d=e.onBlur;d===void 0&&(d=i);var f=e.thousandSeparator,p=e.decimalScale,m=e.fixedDecimalScale,g=e.prefix;g===void 0&&(g=``);var _=e.defaultValue,S=e.value,C=e.valueIsNumericString,w=e.onValueChange,T=n(e,[`decimalSeparator`,`allowedDecimalSeparators`,`thousandsGroupStyle`,`suffix`,`allowNegative`,`allowLeadingZeros`,`onKeyDown`,`onBlur`,`thousandSeparator`,`decimalScale`,`fixedDecimalScale`,`prefix`,`defaultValue`,`value`,`valueIsNumericString`,`onValueChange`]),E=I(e),D=E.decimalSeparator,O=E.allowedDecimalSeparators,k=function(t){return F(t,e)},A=function(t,n){return B(t,n,e)},M=s(S)?_:S,N=C??z(M,g,t);s(S)?s(_)||(N||=typeof _==`number`):N||=typeof S==`number`;var P=function(e){return l(e)?e:(typeof e==`number`&&(e=v(e)),N&&typeof p==`number`?y(e,p,!!m):e)},L=j(P(S),P(_),!!N,k,A,w),R=L[0],U=R.numAsString,W=R.formattedValue,G=L[1];return Object.assign(Object.assign({},T),{value:W,valueIsNumericString:!1,isValidInputCharacter:function(e){return e===D?!0:o(e)},isCharacterSame:function(e){var t=e.currentValue,n=e.lastValue,r=e.formattedValue,i=e.currentValueIndex,a=e.formattedValueIndex,o=t[i],s=r[a],c=x(n,t).to,l=function(e){return A(e).indexOf(`.`)+g.length};return S===0&&m&&p&&t[c.start]===D&&l(t)<i&&l(r)>a?!1:i>=c.start&&i<c.end&&O&&O.includes(o)&&s===D?!0:o===s},onValueChange:G,format:k,removeFormatting:A,getCaretBoundary:function(t){return V(t,e)},onKeyDown:function(e){var t=e.target,n=e.key,r=t.selectionStart,i=t.selectionEnd,o=t.value;if(o===void 0&&(o=``),(n===`Backspace`||n===`Delete`)&&i<g.length&&o!==`-`){e.preventDefault();return}if(r!==i){u(e);return}n===`Backspace`&&o[0]===`-`&&r===g.length+1&&a&&b(t,1),p&&m&&(n===`Backspace`&&o[r-1]===D?(b(t,r-1),e.preventDefault()):n===`Delete`&&o[r]===D&&e.preventDefault()),O?.includes(n)&&o[r]===D&&b(t,r+1);var s=f===!0?`,`:f;n===`Backspace`&&o[r-1]===s&&b(t,r-1),n===`Delete`&&o[r]===s&&b(t,r+1),u(e)},onBlur:function(t){var n=U;n.match(/\d/g)||(n=``),c||(n=h(n)),m&&p&&(n=y(n,p,m)),n!==U&&G({formattedValue:F(n,e),value:n,floatValue:parseFloat(n)},{event:t,source:r.event}),d(t)}})}function W(e){var n=U(e);return t.default.createElement(P,Object.assign({},n))}exports.NumericFormat=W;
|
package/dist/index98.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Button as e } from "./index6.js";
|
|
2
|
+
import { ChevronDown as t, ChevronUp as n } from "lucide-react";
|
|
3
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
4
|
+
import { useTranslation as a } from "react-i18next";
|
|
5
|
+
//#region src/Form/FormNumberInput/StepperControls.tsx
|
|
6
|
+
function o({ onIncrement: o, onDecrement: s, disableIncrement: c, disableDecrement: l }) {
|
|
7
|
+
let { t: u } = a();
|
|
8
|
+
return /* @__PURE__ */ i("div", {
|
|
9
|
+
className: "flex flex-col ml-1",
|
|
10
|
+
children: [/* @__PURE__ */ r(e, {
|
|
11
|
+
"aria-label": u("form_increase_value"),
|
|
12
|
+
className: "px-2 h-5 rounded-l-none rounded-br-none border-input border-l-0 border-b-[0.5px] focus-visible:relative",
|
|
13
|
+
variant: "outline",
|
|
14
|
+
onClick: o,
|
|
15
|
+
disabled: c,
|
|
16
|
+
type: "button",
|
|
17
|
+
children: /* @__PURE__ */ r(n, { size: 15 })
|
|
18
|
+
}), /* @__PURE__ */ r(e, {
|
|
19
|
+
"aria-label": u("form_decrease_value"),
|
|
20
|
+
className: "px-2 h-5 rounded-l-none rounded-tr-none border-input border-l-0 border-t-[0.5px] focus-visible:relative",
|
|
21
|
+
variant: "outline",
|
|
22
|
+
onClick: s,
|
|
23
|
+
disabled: l,
|
|
24
|
+
type: "button",
|
|
25
|
+
children: /* @__PURE__ */ r(t, { size: 15 })
|
|
26
|
+
})]
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { o as StepperControls };
|
package/dist/index99.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./index7.cjs");let t=require("lucide-react"),n=require("react/jsx-runtime"),r=require("react-i18next");function i({onIncrement:i,onDecrement:a,disableIncrement:o,disableDecrement:s}){let{t:c}=(0,r.useTranslation)();return(0,n.jsxs)(`div`,{className:`flex flex-col ml-1`,children:[(0,n.jsx)(e.Button,{"aria-label":c(`form_increase_value`),className:`px-2 h-5 rounded-l-none rounded-br-none border-input border-l-0 border-b-[0.5px] focus-visible:relative`,variant:`outline`,onClick:i,disabled:o,type:`button`,children:(0,n.jsx)(t.ChevronUp,{size:15})}),(0,n.jsx)(e.Button,{"aria-label":c(`form_decrease_value`),className:`px-2 h-5 rounded-l-none rounded-tr-none border-input border-l-0 border-t-[0.5px] focus-visible:relative`,variant:`outline`,onClick:a,disabled:s,type:`button`,children:(0,n.jsx)(t.ChevronDown,{size:15})})]})}exports.StepperControls=i;
|