@wisdomgarden/torque 0.1.0 → 0.1.1
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/LICENSE +101 -0
- package/README.md +10 -1
- package/dist/components/number-input/number-input.js +1 -1
- package/package.json +7 -7
- package/dist/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 +0 -572
package/LICENSE
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
WisdomGarden License
|
|
2
|
+
Version 1.0, September 2026
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2026 WisdomGarden. All rights reserved.
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean WisdomGarden, the copyright owner of the Work.
|
|
14
|
+
|
|
15
|
+
"Work" shall mean the software made available under this License,
|
|
16
|
+
including its source code, object code, documentation, design assets,
|
|
17
|
+
and any accompanying files.
|
|
18
|
+
|
|
19
|
+
"You" shall mean an individual or Legal Entity exercising permissions
|
|
20
|
+
granted by this License.
|
|
21
|
+
|
|
22
|
+
"Authorized User" shall mean (a) WisdomGarden and its affiliates, and
|
|
23
|
+
(b) any Legal Entity that has entered into a valid commercial agreement
|
|
24
|
+
with WisdomGarden covering a WisdomGarden product, for the duration of
|
|
25
|
+
that agreement and solely in connection with that product.
|
|
26
|
+
|
|
27
|
+
2. Grant of Copyright License.
|
|
28
|
+
|
|
29
|
+
Subject to the terms of this License, Licensor grants to each Authorized
|
|
30
|
+
User a non-exclusive, non-transferable, non-sublicensable, revocable,
|
|
31
|
+
royalty-free license to use, reproduce, and modify the Work, and to
|
|
32
|
+
incorporate the Work into products operated by or on behalf of that
|
|
33
|
+
Authorized User, solely for that purpose.
|
|
34
|
+
|
|
35
|
+
3. Grant of Patent License.
|
|
36
|
+
|
|
37
|
+
Subject to the terms of this License, Licensor grants to each Authorized
|
|
38
|
+
User a non-exclusive, non-transferable, revocable, royalty-free patent
|
|
39
|
+
license to make and use the Work, limited to those patent claims
|
|
40
|
+
licensable by Licensor that are necessarily infringed by the Work alone.
|
|
41
|
+
If You institute patent litigation against any entity alleging that the
|
|
42
|
+
Work constitutes patent infringement, any license granted to You under
|
|
43
|
+
this License terminates as of the date such litigation is filed.
|
|
44
|
+
|
|
45
|
+
4. Restrictions.
|
|
46
|
+
|
|
47
|
+
Except as expressly permitted by Section 2, You may not:
|
|
48
|
+
|
|
49
|
+
(a) use the Work if You are not an Authorized User;
|
|
50
|
+
|
|
51
|
+
(b) distribute, sublicense, sell, rent, or lease the Work, or any
|
|
52
|
+
derivative of it, to any third party;
|
|
53
|
+
|
|
54
|
+
(c) use the Work to build, operate, or offer a product that competes
|
|
55
|
+
with any WisdomGarden product; or
|
|
56
|
+
|
|
57
|
+
(d) remove or obscure any copyright, trademark, or other proprietary
|
|
58
|
+
notice contained in the Work.
|
|
59
|
+
|
|
60
|
+
The Work may be publicly downloadable from a package registry. Public
|
|
61
|
+
availability does not grant any license beyond what this document
|
|
62
|
+
states.
|
|
63
|
+
|
|
64
|
+
5. Redistribution.
|
|
65
|
+
|
|
66
|
+
Redistribution of the Work as a standalone library is not permitted. An
|
|
67
|
+
Authorized User may deploy the Work as part of a product it operates,
|
|
68
|
+
provided the Work is not offered to third parties on its own.
|
|
69
|
+
|
|
70
|
+
6. Trademarks.
|
|
71
|
+
|
|
72
|
+
This License does not grant permission to use the trade names,
|
|
73
|
+
trademarks, service marks, or product names of Licensor, including
|
|
74
|
+
"WisdomGarden" and "Torque Design", except as required for reasonable
|
|
75
|
+
and customary use in describing the origin of the Work.
|
|
76
|
+
|
|
77
|
+
7. Disclaimer of Warranty.
|
|
78
|
+
|
|
79
|
+
THE WORK IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
80
|
+
CONDITIONS OF ANY KIND, either express or implied, including, without
|
|
81
|
+
limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT,
|
|
82
|
+
MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely
|
|
83
|
+
responsible for determining the appropriateness of using the Work and
|
|
84
|
+
assume any risks associated with Your exercise of permissions under
|
|
85
|
+
this License.
|
|
86
|
+
|
|
87
|
+
8. Limitation of Liability.
|
|
88
|
+
|
|
89
|
+
IN NO EVENT AND UNDER NO LEGAL THEORY SHALL LICENSOR BE LIABLE TO YOU
|
|
90
|
+
FOR DAMAGES, INCLUDING ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR
|
|
91
|
+
CONSEQUENTIAL DAMAGES OF ANY CHARACTER ARISING AS A RESULT OF THIS
|
|
92
|
+
LICENSE OR OUT OF THE USE OR INABILITY TO USE THE WORK, even if
|
|
93
|
+
Licensor has been advised of the possibility of such damages.
|
|
94
|
+
|
|
95
|
+
9. Termination.
|
|
96
|
+
|
|
97
|
+
This License terminates automatically if You breach any of its terms,
|
|
98
|
+
or when You cease to be an Authorized User. Upon termination You must
|
|
99
|
+
cease all use of the Work and destroy all copies in Your possession.
|
|
100
|
+
|
|
101
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
# @wisdomgarden/torque
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Torque Design** 的 React 组件库 —— Wisdom Garden 的设计系统。基于 Web 2.0 设计规范,
|
|
4
|
+
提供统一的组件 API 与 `--t-*` 设计 token。
|
|
5
|
+
|
|
6
|
+
整套设计系统由三个包组成:
|
|
7
|
+
|
|
8
|
+
| 包 | 是什么 |
|
|
9
|
+
| --- | --- |
|
|
10
|
+
| `@wisdomgarden/torque` | 组件库(本包) |
|
|
11
|
+
| `@wisdomgarden/torque-icons` | 图标集 |
|
|
12
|
+
| `@wisdomgarden/torque-styles` | 设计 token(纯 CSS 变量) |
|
|
4
13
|
|
|
5
14
|
## 安装
|
|
6
15
|
|
|
@@ -4,7 +4,7 @@ import { Space as A } from "@mantine/core";
|
|
|
4
4
|
import { useId as O, useMergedRef as J, useUncontrolled as K } from "@mantine/hooks";
|
|
5
5
|
import { clsx as Q } from "clsx";
|
|
6
6
|
import { useRef as X, useState as W } from "react";
|
|
7
|
-
import { NumericFormat as Y } from "
|
|
7
|
+
import { NumericFormat as Y } from "react-number-format";
|
|
8
8
|
import { useFormWrapperProps as Z } from "../../common/use-form-wrapper-props.js";
|
|
9
9
|
import { NumberInputLeft as $ } from "../_inner/number/number-input-left.js";
|
|
10
10
|
import { NumberInputRight as ee } from "../_inner/number/number-input-right.js";
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wisdomgarden/torque",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Torque Design — Wisdom Garden's base UI component library for React, built on Mantine.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"license": "
|
|
6
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
@@ -153,8 +153,8 @@
|
|
|
153
153
|
"@mantine/hooks": "^8.3.6",
|
|
154
154
|
"@mantine/notifications": "^8.3.6",
|
|
155
155
|
"@tanstack/react-virtual": "^3.13.18",
|
|
156
|
-
"@wisdomgarden/torque-icons": "0.1.
|
|
157
|
-
"@wisdomgarden/torque-styles": "0.1.
|
|
156
|
+
"@wisdomgarden/torque-icons": "0.1.1",
|
|
157
|
+
"@wisdomgarden/torque-styles": "0.1.1",
|
|
158
158
|
"ahooks": "^3.9.0",
|
|
159
159
|
"dayjs": "^1.11.13",
|
|
160
160
|
"mantine-datatable": "^8.3.13",
|
|
@@ -176,8 +176,8 @@
|
|
|
176
176
|
"@tanstack/react-virtual": "^3.13.18",
|
|
177
177
|
"@types/react": "^19.2.18",
|
|
178
178
|
"@types/react-dom": "^19.2.4",
|
|
179
|
-
"@wisdomgarden/torque-icons": "0.1.
|
|
180
|
-
"@wisdomgarden/torque-styles": "0.1.
|
|
179
|
+
"@wisdomgarden/torque-icons": "0.1.1",
|
|
180
|
+
"@wisdomgarden/torque-styles": "0.1.1",
|
|
181
181
|
"ahooks": "^3.9.0",
|
|
182
182
|
"dayjs": "^1.11.13",
|
|
183
183
|
"mantine-datatable": "^8.3.13",
|
|
@@ -191,7 +191,7 @@
|
|
|
191
191
|
"registry": "https://registry.npmjs.org/"
|
|
192
192
|
},
|
|
193
193
|
"scripts": {
|
|
194
|
-
"build": "vite build && tsc -p tsconfig.build.json && node scripts/verify-exports.mjs",
|
|
194
|
+
"build": "vite build && tsc -p tsconfig.build.json && node ../../scripts/verify-no-bundled-deps.mjs && node scripts/verify-exports.mjs",
|
|
195
195
|
"type:check": "tsc -p tsconfig.json",
|
|
196
196
|
"verify:exports": "node scripts/verify-exports.mjs"
|
|
197
197
|
}
|
|
@@ -1,572 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import X, { useRef as Y, useState as pe, useEffect as ie, useMemo as Fe, useLayoutEffect as _e } from "react";
|
|
3
|
-
function Ve(e, r) {
|
|
4
|
-
var a = {};
|
|
5
|
-
for (var n in e)
|
|
6
|
-
Object.prototype.hasOwnProperty.call(e, n) && r.indexOf(n) < 0 && (a[n] = e[n]);
|
|
7
|
-
if (e != null && typeof Object.getOwnPropertySymbols == "function")
|
|
8
|
-
for (var t = 0, n = Object.getOwnPropertySymbols(e); t < n.length; t++)
|
|
9
|
-
r.indexOf(n[t]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[t]) && (a[n[t]] = e[n[t]]);
|
|
10
|
-
return a;
|
|
11
|
-
}
|
|
12
|
-
var ee;
|
|
13
|
-
(function(e) {
|
|
14
|
-
e.event = "event", e.props = "prop";
|
|
15
|
-
})(ee || (ee = {}));
|
|
16
|
-
function Z() {
|
|
17
|
-
}
|
|
18
|
-
function Me(e) {
|
|
19
|
-
var r, a = void 0;
|
|
20
|
-
return function() {
|
|
21
|
-
for (var n = [], t = arguments.length; t--; ) n[t] = arguments[t];
|
|
22
|
-
return r && n.length === r.length && n.every(function(o, f) {
|
|
23
|
-
return o === r[f];
|
|
24
|
-
}) || (r = n, a = e.apply(void 0, n)), a;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
function te(e) {
|
|
28
|
-
return !!(e || "").match(/\d/);
|
|
29
|
-
}
|
|
30
|
-
function q(e) {
|
|
31
|
-
return e == null;
|
|
32
|
-
}
|
|
33
|
-
function je(e) {
|
|
34
|
-
return typeof e == "number" && isNaN(e);
|
|
35
|
-
}
|
|
36
|
-
function ye(e) {
|
|
37
|
-
return q(e) || je(e) || typeof e == "number" && !isFinite(e);
|
|
38
|
-
}
|
|
39
|
-
function Ne(e) {
|
|
40
|
-
return e.replace(/[-[\]/{}()*+?.\\^$|]/g, "\\$&");
|
|
41
|
-
}
|
|
42
|
-
function Le(e) {
|
|
43
|
-
switch (e) {
|
|
44
|
-
case "lakh":
|
|
45
|
-
return /(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/g;
|
|
46
|
-
case "wan":
|
|
47
|
-
return /(\d)(?=(\d{4})+(?!\d))/g;
|
|
48
|
-
default:
|
|
49
|
-
return /(\d)(?=(\d{3})+(?!\d))/g;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function ke(e, r, a) {
|
|
53
|
-
var n = Le(a), t = e.search(/[1-9]/);
|
|
54
|
-
return t = t === -1 ? e.length : t, e.substring(0, t) + e.substring(t, e.length).replace(n, "$1" + r);
|
|
55
|
-
}
|
|
56
|
-
function ge(e) {
|
|
57
|
-
var r = Y(e);
|
|
58
|
-
r.current = e;
|
|
59
|
-
var a = Y(function() {
|
|
60
|
-
for (var n = [], t = arguments.length; t--; ) n[t] = arguments[t];
|
|
61
|
-
return r.current.apply(r, n);
|
|
62
|
-
});
|
|
63
|
-
return a.current;
|
|
64
|
-
}
|
|
65
|
-
function se(e, r) {
|
|
66
|
-
r === void 0 && (r = !0);
|
|
67
|
-
var a = e[0] === "-", n = a && r;
|
|
68
|
-
e = e.replace("-", "");
|
|
69
|
-
var t = e.split("."), o = t[0], f = t[1] || "";
|
|
70
|
-
return {
|
|
71
|
-
beforeDecimal: o,
|
|
72
|
-
afterDecimal: f,
|
|
73
|
-
hasNegation: a,
|
|
74
|
-
addNegation: n
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
function Pe(e) {
|
|
78
|
-
if (!e)
|
|
79
|
-
return e;
|
|
80
|
-
var r = e[0] === "-";
|
|
81
|
-
r && (e = e.substring(1, e.length));
|
|
82
|
-
var a = e.split("."), n = a[0].replace(/^0+/, "") || "0", t = a[1] || "";
|
|
83
|
-
return (r ? "-" : "") + n + (t ? "." + t : "");
|
|
84
|
-
}
|
|
85
|
-
function be(e, r, a) {
|
|
86
|
-
for (var n = "", t = a ? "0" : "", o = 0; o <= r - 1; o++)
|
|
87
|
-
n += e[o] || t;
|
|
88
|
-
return n;
|
|
89
|
-
}
|
|
90
|
-
function me(e, r) {
|
|
91
|
-
return Array(r + 1).join(e);
|
|
92
|
-
}
|
|
93
|
-
function we(e) {
|
|
94
|
-
var r = e + "", a = r[0] === "-" ? "-" : "";
|
|
95
|
-
a && (r = r.substring(1));
|
|
96
|
-
var n = r.split(/[eE]/g), t = n[0], o = n[1];
|
|
97
|
-
if (o = Number(o), !o)
|
|
98
|
-
return a + t;
|
|
99
|
-
t = t.replace(".", "");
|
|
100
|
-
var f = 1 + o, h = t.length;
|
|
101
|
-
return f < 0 ? t = "0." + me("0", Math.abs(f)) + t : f >= h ? t = t + me("0", f - h) : t = (t.substring(0, f) || "0") + "." + t.substring(f), a + t;
|
|
102
|
-
}
|
|
103
|
-
function he(e, r, a) {
|
|
104
|
-
if (["", "-"].indexOf(e) !== -1)
|
|
105
|
-
return e;
|
|
106
|
-
var n = (e.indexOf(".") !== -1 || a) && r, t = se(e), o = t.beforeDecimal, f = t.afterDecimal, h = t.hasNegation, m = parseFloat("0." + (f || "0")), y = f.length <= r ? "0." + f : m.toFixed(r), S = y.split("."), g = o;
|
|
107
|
-
o && Number(S[0]) && (g = o.split("").reverse().reduce(function(I, C, d) {
|
|
108
|
-
return I.length > d ? (Number(I[0]) + Number(C)).toString() + I.substring(1, I.length) : C + I;
|
|
109
|
-
}, S[0]));
|
|
110
|
-
var x = be(S[1] || "", r, a), p = h ? "-" : "", l = n ? "." : "";
|
|
111
|
-
return "" + p + g + l + x;
|
|
112
|
-
}
|
|
113
|
-
function H(e, r) {
|
|
114
|
-
if (e.value = e.value, e !== null) {
|
|
115
|
-
if (e.createTextRange) {
|
|
116
|
-
var a = e.createTextRange();
|
|
117
|
-
return a.move("character", r), a.select(), !0;
|
|
118
|
-
}
|
|
119
|
-
return e.selectionStart || e.selectionStart === 0 ? (e.focus(), e.setSelectionRange(r, r), !0) : (e.focus(), !1);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
var De = Me(function(e, r) {
|
|
123
|
-
for (var a = 0, n = 0, t = e.length, o = r.length; e[a] === r[a] && a < t; )
|
|
124
|
-
a++;
|
|
125
|
-
for (; e[t - 1 - n] === r[o - 1 - n] && o - n > a && t - n > a; )
|
|
126
|
-
n++;
|
|
127
|
-
return {
|
|
128
|
-
from: { start: a, end: t - n },
|
|
129
|
-
to: { start: a, end: o - n }
|
|
130
|
-
};
|
|
131
|
-
}), Ke = function(e, r) {
|
|
132
|
-
var a = Math.min(e.selectionStart, r);
|
|
133
|
-
return {
|
|
134
|
-
from: { start: a, end: e.selectionEnd },
|
|
135
|
-
to: { start: a, end: r }
|
|
136
|
-
};
|
|
137
|
-
};
|
|
138
|
-
function Ue(e, r, a) {
|
|
139
|
-
return Math.min(Math.max(e, r), a);
|
|
140
|
-
}
|
|
141
|
-
function ce(e) {
|
|
142
|
-
return Math.max(e.selectionStart, e.selectionEnd);
|
|
143
|
-
}
|
|
144
|
-
function We() {
|
|
145
|
-
return typeof navigator < "u" && !(navigator.platform && /iPhone|iPod/.test(navigator.platform));
|
|
146
|
-
}
|
|
147
|
-
function $e(e) {
|
|
148
|
-
return {
|
|
149
|
-
from: {
|
|
150
|
-
start: 0,
|
|
151
|
-
end: 0
|
|
152
|
-
},
|
|
153
|
-
to: {
|
|
154
|
-
start: 0,
|
|
155
|
-
end: e.length
|
|
156
|
-
},
|
|
157
|
-
lastValue: ""
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
function Ge(e) {
|
|
161
|
-
var r = e.currentValue, a = e.formattedValue, n = e.currentValueIndex, t = e.formattedValueIndex;
|
|
162
|
-
return r[n] === a[t];
|
|
163
|
-
}
|
|
164
|
-
function Ze(e, r, a, n, t, o, f) {
|
|
165
|
-
f === void 0 && (f = Ge);
|
|
166
|
-
var h = t.findIndex(function(L) {
|
|
167
|
-
return L;
|
|
168
|
-
}), m = e.slice(0, h);
|
|
169
|
-
!r && !a.startsWith(m) && (r = m, a = m + a, n = n + m.length);
|
|
170
|
-
for (var y = a.length, S = e.length, g = {}, x = new Array(y), p = 0; p < y; p++) {
|
|
171
|
-
x[p] = -1;
|
|
172
|
-
for (var l = 0, I = S; l < I; l++) {
|
|
173
|
-
var C = f({
|
|
174
|
-
currentValue: a,
|
|
175
|
-
lastValue: r,
|
|
176
|
-
formattedValue: e,
|
|
177
|
-
currentValueIndex: p,
|
|
178
|
-
formattedValueIndex: l
|
|
179
|
-
});
|
|
180
|
-
if (C && g[l] !== !0) {
|
|
181
|
-
x[p] = l, g[l] = !0;
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
for (var d = n; d < y && (x[d] === -1 || !o(a[d])); )
|
|
187
|
-
d++;
|
|
188
|
-
var T = d === y || x[d] === -1 ? S : x[d];
|
|
189
|
-
for (d = n - 1; d > 0 && x[d] === -1; )
|
|
190
|
-
d--;
|
|
191
|
-
var R = d === -1 || x[d] === -1 ? 0 : x[d] + 1;
|
|
192
|
-
return R > T ? T : n - R < T - n ? R : T;
|
|
193
|
-
}
|
|
194
|
-
function Se(e, r, a, n) {
|
|
195
|
-
var t = e.length;
|
|
196
|
-
if (r = Ue(r, 0, t), n === "left") {
|
|
197
|
-
for (; r >= 0 && !a[r]; )
|
|
198
|
-
r--;
|
|
199
|
-
r === -1 && (r = a.indexOf(!0));
|
|
200
|
-
} else {
|
|
201
|
-
for (; r <= t && !a[r]; )
|
|
202
|
-
r++;
|
|
203
|
-
r > t && (r = a.lastIndexOf(!0));
|
|
204
|
-
}
|
|
205
|
-
return r === -1 && (r = t), r;
|
|
206
|
-
}
|
|
207
|
-
function qe(e) {
|
|
208
|
-
for (var r = Array.from({ length: e.length + 1 }).map(function() {
|
|
209
|
-
return !0;
|
|
210
|
-
}), a = 0, n = r.length; a < n; a++)
|
|
211
|
-
r[a] = !!(te(e[a]) || te(e[a - 1]));
|
|
212
|
-
return r;
|
|
213
|
-
}
|
|
214
|
-
function Ie(e, r, a, n, t, o) {
|
|
215
|
-
o === void 0 && (o = Z);
|
|
216
|
-
var f = ge(function(l, I) {
|
|
217
|
-
var C, d;
|
|
218
|
-
return ye(l) ? (d = "", C = "") : typeof l == "number" || I ? (d = typeof l == "number" ? we(l) : l, C = n(d)) : (d = t(l, void 0), C = n(d)), { formattedValue: C, numAsString: d };
|
|
219
|
-
}), h = pe(function() {
|
|
220
|
-
return f(q(e) ? r : e, a);
|
|
221
|
-
}), m = h[0], y = h[1], S = ge(function(l, I) {
|
|
222
|
-
l.formattedValue !== m.formattedValue && y({
|
|
223
|
-
formattedValue: l.formattedValue,
|
|
224
|
-
numAsString: l.value
|
|
225
|
-
}), o(l, I);
|
|
226
|
-
}), g = e, x = a;
|
|
227
|
-
q(e) && (g = m.numAsString, x = !0);
|
|
228
|
-
var p = f(g, x);
|
|
229
|
-
return Fe(function() {
|
|
230
|
-
y(p);
|
|
231
|
-
}, [p.formattedValue]), ie(function() {
|
|
232
|
-
if (!q(r) && q(e) && m.formattedValue !== "") {
|
|
233
|
-
var l = parseFloat(m.numAsString);
|
|
234
|
-
S({
|
|
235
|
-
formattedValue: m.formattedValue,
|
|
236
|
-
value: m.numAsString,
|
|
237
|
-
floatValue: isNaN(l) ? void 0 : l
|
|
238
|
-
}, { event: void 0, source: ee.props });
|
|
239
|
-
}
|
|
240
|
-
}, []), [m, S];
|
|
241
|
-
}
|
|
242
|
-
function ze(e) {
|
|
243
|
-
return e.replace(/[^0-9]/g, "");
|
|
244
|
-
}
|
|
245
|
-
function He(e) {
|
|
246
|
-
return e;
|
|
247
|
-
}
|
|
248
|
-
function Je(e) {
|
|
249
|
-
var r = e.type;
|
|
250
|
-
r === void 0 && (r = "text");
|
|
251
|
-
var a = e.displayType;
|
|
252
|
-
a === void 0 && (a = "input");
|
|
253
|
-
var n = e.customInput, t = e.renderText, o = e.getInputRef, f = e.format;
|
|
254
|
-
f === void 0 && (f = He);
|
|
255
|
-
var h = e.removeFormatting;
|
|
256
|
-
h === void 0 && (h = ze);
|
|
257
|
-
var m = e.defaultValue, y = e.valueIsNumericString, S = e.onValueChange, g = e.isAllowed, x = e.onChange;
|
|
258
|
-
x === void 0 && (x = Z);
|
|
259
|
-
var p = e.onKeyDown;
|
|
260
|
-
p === void 0 && (p = Z);
|
|
261
|
-
var l = e.onMouseUp;
|
|
262
|
-
l === void 0 && (l = Z);
|
|
263
|
-
var I = e.onFocus;
|
|
264
|
-
I === void 0 && (I = Z);
|
|
265
|
-
var C = e.onBlur;
|
|
266
|
-
C === void 0 && (C = Z);
|
|
267
|
-
var d = e.value, T = e.getCaretBoundary;
|
|
268
|
-
T === void 0 && (T = qe);
|
|
269
|
-
var R = e.isValidInputCharacter;
|
|
270
|
-
R === void 0 && (R = te);
|
|
271
|
-
var L = e.isCharacterSame, _ = Ve(e, ["type", "displayType", "customInput", "renderText", "getInputRef", "format", "removeFormatting", "defaultValue", "valueIsNumericString", "onValueChange", "isAllowed", "onChange", "onKeyDown", "onMouseUp", "onFocus", "onBlur", "value", "getCaretBoundary", "isValidInputCharacter", "isCharacterSame"]), z = Ie(d, m, !!y, f, h, S), k = z[0], N = k.formattedValue, M = k.numAsString, K = z[1], j = Y(), U = Y({ formattedValue: N, numAsString: M }), W = function(i, u) {
|
|
272
|
-
U.current = { formattedValue: i.formattedValue, numAsString: i.value }, K(i, u);
|
|
273
|
-
}, J = pe(!1), re = J[0], s = J[1], v = Y(null), b = Y({
|
|
274
|
-
setCaretTimeout: null,
|
|
275
|
-
focusTimeout: null
|
|
276
|
-
});
|
|
277
|
-
ie(function() {
|
|
278
|
-
return s(!0), function() {
|
|
279
|
-
clearTimeout(b.current.setCaretTimeout), clearTimeout(b.current.focusTimeout);
|
|
280
|
-
};
|
|
281
|
-
}, []);
|
|
282
|
-
var B = f, E = function(i, u) {
|
|
283
|
-
var c = parseFloat(u);
|
|
284
|
-
return {
|
|
285
|
-
formattedValue: i,
|
|
286
|
-
value: u,
|
|
287
|
-
floatValue: isNaN(c) ? void 0 : c
|
|
288
|
-
};
|
|
289
|
-
}, A = function(i, u, c) {
|
|
290
|
-
i.selectionStart === 0 && i.selectionEnd === i.value.length || (H(i, u), b.current.setCaretTimeout = setTimeout(function() {
|
|
291
|
-
i.value === c && i.selectionStart !== u && H(i, u);
|
|
292
|
-
}, 0));
|
|
293
|
-
}, O = function(i, u, c) {
|
|
294
|
-
return Se(i, u, T(i), c);
|
|
295
|
-
}, Q = function(i, u, c) {
|
|
296
|
-
var w = T(u), F = Ze(u, N, i, c, w, R, L);
|
|
297
|
-
return F = Se(u, F, w), F;
|
|
298
|
-
}, ue = function(i) {
|
|
299
|
-
var u = i.formattedValue;
|
|
300
|
-
u === void 0 && (u = "");
|
|
301
|
-
var c = i.input, w = i.source, F = i.event, D = i.numAsString, V;
|
|
302
|
-
if (c) {
|
|
303
|
-
var P = i.inputValue || c.value, $ = ce(c);
|
|
304
|
-
c.value = u, V = Q(P, u, $), V !== void 0 && A(c, V, u);
|
|
305
|
-
}
|
|
306
|
-
u !== N && W(E(u, D), { event: F, source: w });
|
|
307
|
-
};
|
|
308
|
-
ie(function() {
|
|
309
|
-
var i = U.current, u = i.formattedValue, c = i.numAsString;
|
|
310
|
-
(N !== u || M !== c) && W(E(N, M), {
|
|
311
|
-
event: void 0,
|
|
312
|
-
source: ee.props
|
|
313
|
-
});
|
|
314
|
-
}, [N, M]);
|
|
315
|
-
var ae = v.current ? ce(v.current) : void 0, ne = typeof window < "u" ? _e : ie;
|
|
316
|
-
ne(function() {
|
|
317
|
-
var i = v.current;
|
|
318
|
-
if (N !== U.current.formattedValue && i) {
|
|
319
|
-
var u = Q(U.current.formattedValue, N, ae);
|
|
320
|
-
i.value = N, A(i, u, N);
|
|
321
|
-
}
|
|
322
|
-
}, [N]);
|
|
323
|
-
var fe = function(i, u, c) {
|
|
324
|
-
var w = u.target, F = j.current ? Ke(j.current, w.selectionEnd) : De(N, i), D = Object.assign(Object.assign({}, F), { lastValue: N }), V = h(i, D), P = B(V);
|
|
325
|
-
if (V = h(P, void 0), g && !g(E(P, V))) {
|
|
326
|
-
var $ = u.target, G = ce($), ve = Q(i, N, G);
|
|
327
|
-
return $.value = N, A($, ve, N), !1;
|
|
328
|
-
}
|
|
329
|
-
return ue({
|
|
330
|
-
formattedValue: P,
|
|
331
|
-
numAsString: V,
|
|
332
|
-
inputValue: i,
|
|
333
|
-
event: u,
|
|
334
|
-
source: c,
|
|
335
|
-
input: u.target
|
|
336
|
-
}), !0;
|
|
337
|
-
}, le = function(i, u) {
|
|
338
|
-
u === void 0 && (u = 0);
|
|
339
|
-
var c = i.selectionStart, w = i.selectionEnd;
|
|
340
|
-
j.current = { selectionStart: c, selectionEnd: w + u };
|
|
341
|
-
}, Ce = function(i) {
|
|
342
|
-
var u = i.target, c = u.value, w = fe(c, i, ee.event);
|
|
343
|
-
w && x(i), j.current = void 0;
|
|
344
|
-
}, Ae = function(i) {
|
|
345
|
-
var u = i.target, c = i.key, w = u.selectionStart, F = u.selectionEnd, D = u.value;
|
|
346
|
-
D === void 0 && (D = "");
|
|
347
|
-
var V;
|
|
348
|
-
c === "ArrowLeft" || c === "Backspace" ? V = Math.max(w - 1, 0) : c === "ArrowRight" ? V = Math.min(w + 1, D.length) : c === "Delete" && (V = w);
|
|
349
|
-
var P = 0;
|
|
350
|
-
c === "Delete" && w === F && (P = 1);
|
|
351
|
-
var $ = c === "ArrowLeft" || c === "ArrowRight";
|
|
352
|
-
if (V === void 0 || w !== F && !$) {
|
|
353
|
-
p(i), le(u, P);
|
|
354
|
-
return;
|
|
355
|
-
}
|
|
356
|
-
var G = V;
|
|
357
|
-
if ($) {
|
|
358
|
-
var ve = c === "ArrowLeft" ? "left" : "right";
|
|
359
|
-
G = O(D, V, ve), G !== V && i.preventDefault();
|
|
360
|
-
} else c === "Delete" && !R(D[V]) ? G = O(D, V, "right") : c === "Backspace" && !R(D[V]) && (G = O(D, V, "left"));
|
|
361
|
-
G !== V && A(u, G, D), p(i), le(u, P);
|
|
362
|
-
}, Be = function(i) {
|
|
363
|
-
var u = i.target, c = function() {
|
|
364
|
-
var w = u.selectionStart, F = u.selectionEnd, D = u.value;
|
|
365
|
-
if (D === void 0 && (D = ""), w === F) {
|
|
366
|
-
var V = O(D, w);
|
|
367
|
-
V !== w && A(u, V, D);
|
|
368
|
-
}
|
|
369
|
-
};
|
|
370
|
-
c(), requestAnimationFrame(function() {
|
|
371
|
-
c();
|
|
372
|
-
}), l(i), le(u);
|
|
373
|
-
}, Ee = function(i) {
|
|
374
|
-
i.persist && i.persist();
|
|
375
|
-
var u = i.target, c = i.currentTarget;
|
|
376
|
-
v.current = u, b.current.focusTimeout = setTimeout(function() {
|
|
377
|
-
var w = u.selectionStart, F = u.selectionEnd, D = u.value;
|
|
378
|
-
D === void 0 && (D = "");
|
|
379
|
-
var V = O(D, w);
|
|
380
|
-
V !== w && !(w === 0 && F === D.length) && A(u, V, D), I(Object.assign(Object.assign({}, i), { currentTarget: c }));
|
|
381
|
-
}, 0);
|
|
382
|
-
}, Oe = function(i) {
|
|
383
|
-
v.current = null, clearTimeout(b.current.focusTimeout), clearTimeout(b.current.setCaretTimeout), C(i);
|
|
384
|
-
}, Te = re && We() ? "numeric" : void 0, de = Object.assign({ inputMode: Te }, _, {
|
|
385
|
-
type: r,
|
|
386
|
-
value: N,
|
|
387
|
-
onChange: Ce,
|
|
388
|
-
onKeyDown: Ae,
|
|
389
|
-
onMouseUp: Be,
|
|
390
|
-
onFocus: Ee,
|
|
391
|
-
onBlur: Oe
|
|
392
|
-
});
|
|
393
|
-
if (a === "text")
|
|
394
|
-
return t ? X.createElement(X.Fragment, null, t(N, _) || null) : X.createElement("span", Object.assign({}, _, { ref: o }), N);
|
|
395
|
-
if (n) {
|
|
396
|
-
var Re = n;
|
|
397
|
-
return X.createElement(Re, Object.assign({}, de, { ref: o }));
|
|
398
|
-
}
|
|
399
|
-
return X.createElement("input", Object.assign({}, de, { ref: o }));
|
|
400
|
-
}
|
|
401
|
-
function xe(e, r) {
|
|
402
|
-
var a = r.decimalScale, n = r.fixedDecimalScale, t = r.prefix;
|
|
403
|
-
t === void 0 && (t = "");
|
|
404
|
-
var o = r.suffix;
|
|
405
|
-
o === void 0 && (o = "");
|
|
406
|
-
var f = r.allowNegative, h = r.thousandsGroupStyle;
|
|
407
|
-
if (h === void 0 && (h = "thousand"), e === "" || e === "-")
|
|
408
|
-
return e;
|
|
409
|
-
var m = oe(r), y = m.thousandSeparator, S = m.decimalSeparator, g = a !== 0 && e.indexOf(".") !== -1 || a && n, x = se(e, f), p = x.beforeDecimal, l = x.afterDecimal, I = x.addNegation;
|
|
410
|
-
return a !== void 0 && (l = be(l, a, !!n)), y && (p = ke(p, y, h)), t && (p = t + p), o && (l = l + o), I && (p = "-" + p), e = p + (g && S || "") + l, e;
|
|
411
|
-
}
|
|
412
|
-
function oe(e) {
|
|
413
|
-
var r = e.decimalSeparator;
|
|
414
|
-
r === void 0 && (r = ".");
|
|
415
|
-
var a = e.thousandSeparator, n = e.allowedDecimalSeparators;
|
|
416
|
-
return a === !0 && (a = ","), n || (n = [r, "."]), {
|
|
417
|
-
decimalSeparator: r,
|
|
418
|
-
thousandSeparator: a,
|
|
419
|
-
allowedDecimalSeparators: n
|
|
420
|
-
};
|
|
421
|
-
}
|
|
422
|
-
function Qe(e, r) {
|
|
423
|
-
e === void 0 && (e = "");
|
|
424
|
-
var a = new RegExp("(-)"), n = new RegExp("(-)(.)*(-)"), t = a.test(e), o = n.test(e);
|
|
425
|
-
return e = e.replace(/-/g, ""), t && !o && r && (e = "-" + e), e;
|
|
426
|
-
}
|
|
427
|
-
function Xe(e, r) {
|
|
428
|
-
return new RegExp("(^-)|[0-9]|" + Ne(e), "g");
|
|
429
|
-
}
|
|
430
|
-
function Ye(e, r, a) {
|
|
431
|
-
return e === "" ? !0 : !r?.match(/\d/) && !a?.match(/\d/) && typeof e == "string" && !isNaN(Number(e));
|
|
432
|
-
}
|
|
433
|
-
function er(e, r, a) {
|
|
434
|
-
var n;
|
|
435
|
-
r === void 0 && (r = $e(e));
|
|
436
|
-
var t = a.allowNegative, o = a.prefix;
|
|
437
|
-
o === void 0 && (o = "");
|
|
438
|
-
var f = a.suffix;
|
|
439
|
-
f === void 0 && (f = "");
|
|
440
|
-
var h = a.decimalScale, m = r.from, y = r.to, S = y.start, g = y.end, x = oe(a), p = x.allowedDecimalSeparators, l = x.decimalSeparator, I = e[g] === l;
|
|
441
|
-
if (te(e) && (e === o || e === f) && r.lastValue === "")
|
|
442
|
-
return e;
|
|
443
|
-
if (g - S === 1 && p.indexOf(e[S]) !== -1) {
|
|
444
|
-
var C = h === 0 ? "" : l;
|
|
445
|
-
e = e.substring(0, S) + C + e.substring(S + 1, e.length);
|
|
446
|
-
}
|
|
447
|
-
var d = function(v, b, B) {
|
|
448
|
-
var E = !1, A = !1;
|
|
449
|
-
o.startsWith("-") ? E = !1 : v.startsWith("--") ? (E = !1, A = !0) : f.startsWith("-") && v.length === f.length ? E = !1 : v[0] === "-" && (E = !0);
|
|
450
|
-
var O = E ? 1 : 0;
|
|
451
|
-
return A && (O = 2), O && (v = v.substring(O), b -= O, B -= O), { value: v, start: b, end: B, hasNegation: E };
|
|
452
|
-
}, T = d(e, S, g), R = T.hasNegation;
|
|
453
|
-
n = T, e = n.value, S = n.start, g = n.end;
|
|
454
|
-
var L = d(r.lastValue, m.start, m.end), _ = L.start, z = L.end, k = L.value, N = e.substring(S, g);
|
|
455
|
-
e.length && k.length && (_ > k.length - f.length || z < o.length) && !(N && f.startsWith(N)) && (e = k);
|
|
456
|
-
var M = 0;
|
|
457
|
-
e.startsWith(o) ? M += o.length : S < o.length && (M = S), e = e.substring(M), g -= M;
|
|
458
|
-
var K = e.length, j = e.length - f.length;
|
|
459
|
-
e.endsWith(f) ? K = j : (g > j || g > e.length - f.length) && (K = g), e = e.substring(0, K), e = Qe(R ? "-" + e : e, t), e = (e.match(Xe(l)) || []).join("");
|
|
460
|
-
var U = e.indexOf(l);
|
|
461
|
-
e = e.replace(new RegExp(Ne(l), "g"), function(v, b) {
|
|
462
|
-
return b === U ? "." : "";
|
|
463
|
-
});
|
|
464
|
-
var W = se(e, t), J = W.beforeDecimal, re = W.afterDecimal, s = W.addNegation;
|
|
465
|
-
return y.end - y.start < m.end - m.start && J === "" && I && !parseFloat(re) && (e = s ? "-" : ""), e;
|
|
466
|
-
}
|
|
467
|
-
function rr(e, r) {
|
|
468
|
-
var a = r.prefix;
|
|
469
|
-
a === void 0 && (a = "");
|
|
470
|
-
var n = r.suffix;
|
|
471
|
-
n === void 0 && (n = "");
|
|
472
|
-
var t = Array.from({ length: e.length + 1 }).map(function() {
|
|
473
|
-
return !0;
|
|
474
|
-
}), o = e[0] === "-";
|
|
475
|
-
t.fill(!1, 0, Math.min(a.length + (o ? 1 : 0), e.length));
|
|
476
|
-
var f = e.length;
|
|
477
|
-
return t.fill(!1, f - n.length + 1, f + 1), t;
|
|
478
|
-
}
|
|
479
|
-
function ar(e) {
|
|
480
|
-
var r = oe(e), a = r.thousandSeparator, n = r.decimalSeparator, t = e.prefix;
|
|
481
|
-
t === void 0 && (t = "");
|
|
482
|
-
var o = e.allowNegative;
|
|
483
|
-
if (o === void 0 && (o = !0), a === n)
|
|
484
|
-
throw new Error(`
|
|
485
|
-
Decimal separator can't be same as thousand separator.
|
|
486
|
-
thousandSeparator: ` + a + ` (thousandSeparator = {true} is same as thousandSeparator = ",")
|
|
487
|
-
decimalSeparator: ` + n + ` (default value for decimalSeparator is .)
|
|
488
|
-
`);
|
|
489
|
-
return t.startsWith("-") && o && (console.error(`
|
|
490
|
-
Prefix can't start with '-' when allowNegative is true.
|
|
491
|
-
prefix: ` + t + `
|
|
492
|
-
allowNegative: ` + o + `
|
|
493
|
-
`), o = !1), Object.assign(Object.assign({}, e), { allowNegative: o });
|
|
494
|
-
}
|
|
495
|
-
function tr(e) {
|
|
496
|
-
e = ar(e), e.decimalSeparator, e.allowedDecimalSeparators, e.thousandsGroupStyle;
|
|
497
|
-
var r = e.suffix, a = e.allowNegative, n = e.allowLeadingZeros, t = e.onKeyDown;
|
|
498
|
-
t === void 0 && (t = Z);
|
|
499
|
-
var o = e.onBlur;
|
|
500
|
-
o === void 0 && (o = Z);
|
|
501
|
-
var f = e.thousandSeparator, h = e.decimalScale, m = e.fixedDecimalScale, y = e.prefix;
|
|
502
|
-
y === void 0 && (y = "");
|
|
503
|
-
var S = e.defaultValue, g = e.value, x = e.valueIsNumericString, p = e.onValueChange, l = Ve(e, ["decimalSeparator", "allowedDecimalSeparators", "thousandsGroupStyle", "suffix", "allowNegative", "allowLeadingZeros", "onKeyDown", "onBlur", "thousandSeparator", "decimalScale", "fixedDecimalScale", "prefix", "defaultValue", "value", "valueIsNumericString", "onValueChange"]), I = oe(e), C = I.decimalSeparator, d = I.allowedDecimalSeparators, T = function(s) {
|
|
504
|
-
return xe(s, e);
|
|
505
|
-
}, R = function(s, v) {
|
|
506
|
-
return er(s, v, e);
|
|
507
|
-
}, L = q(g) ? S : g, _ = x ?? Ye(L, y, r);
|
|
508
|
-
q(g) ? q(S) || (_ = _ || typeof S == "number") : _ = _ || typeof g == "number";
|
|
509
|
-
var z = function(s) {
|
|
510
|
-
return ye(s) ? s : (typeof s == "number" && (s = we(s)), _ && typeof h == "number" ? he(s, h, !!m) : s);
|
|
511
|
-
}, k = Ie(z(g), z(S), !!_, T, R, p), N = k[0], M = N.numAsString, K = N.formattedValue, j = k[1], U = function(s) {
|
|
512
|
-
var v = s.target, b = s.key, B = v.selectionStart, E = v.selectionEnd, A = v.value;
|
|
513
|
-
if (A === void 0 && (A = ""), (b === "Backspace" || b === "Delete") && E < y.length && A !== "-") {
|
|
514
|
-
s.preventDefault();
|
|
515
|
-
return;
|
|
516
|
-
}
|
|
517
|
-
if (B !== E) {
|
|
518
|
-
t(s);
|
|
519
|
-
return;
|
|
520
|
-
}
|
|
521
|
-
b === "Backspace" && A[0] === "-" && B === y.length + 1 && a && H(v, 1), h && m && (b === "Backspace" && A[B - 1] === C ? (H(v, B - 1), s.preventDefault()) : b === "Delete" && A[B] === C && s.preventDefault()), d?.includes(b) && A[B] === C && H(v, B + 1);
|
|
522
|
-
var O = f === !0 ? "," : f;
|
|
523
|
-
b === "Backspace" && A[B - 1] === O && H(v, B - 1), b === "Delete" && A[B] === O && H(v, B + 1), t(s);
|
|
524
|
-
}, W = function(s) {
|
|
525
|
-
var v = M;
|
|
526
|
-
if (v.match(/\d/g) || (v = ""), n || (v = Pe(v)), m && h && (v = he(v, h, m)), v !== M) {
|
|
527
|
-
var b = xe(v, e);
|
|
528
|
-
j({
|
|
529
|
-
formattedValue: b,
|
|
530
|
-
value: v,
|
|
531
|
-
floatValue: parseFloat(v)
|
|
532
|
-
}, {
|
|
533
|
-
event: s,
|
|
534
|
-
source: ee.event
|
|
535
|
-
});
|
|
536
|
-
}
|
|
537
|
-
o(s);
|
|
538
|
-
}, J = function(s) {
|
|
539
|
-
return s === C ? !0 : te(s);
|
|
540
|
-
}, re = function(s) {
|
|
541
|
-
var v = s.currentValue, b = s.lastValue, B = s.formattedValue, E = s.currentValueIndex, A = s.formattedValueIndex, O = v[E], Q = B[A], ue = De(b, v), ae = ue.to, ne = function(fe) {
|
|
542
|
-
return R(fe).indexOf(".") + y.length;
|
|
543
|
-
};
|
|
544
|
-
return g === 0 && m && h && v[ae.start] === C && ne(v) < E && ne(B) > A ? !1 : E >= ae.start && E < ae.end && d && d.includes(O) && Q === C ? !0 : O === Q;
|
|
545
|
-
};
|
|
546
|
-
return Object.assign(Object.assign({}, l), {
|
|
547
|
-
value: K,
|
|
548
|
-
valueIsNumericString: !1,
|
|
549
|
-
isValidInputCharacter: J,
|
|
550
|
-
isCharacterSame: re,
|
|
551
|
-
onValueChange: j,
|
|
552
|
-
format: T,
|
|
553
|
-
removeFormatting: R,
|
|
554
|
-
getCaretBoundary: function(s) {
|
|
555
|
-
return rr(s, e);
|
|
556
|
-
},
|
|
557
|
-
onKeyDown: U,
|
|
558
|
-
onBlur: W
|
|
559
|
-
});
|
|
560
|
-
}
|
|
561
|
-
function ir(e) {
|
|
562
|
-
var r = tr(e);
|
|
563
|
-
return X.createElement(Je, Object.assign({}, r));
|
|
564
|
-
}
|
|
565
|
-
export {
|
|
566
|
-
Je as NumberFormatBase,
|
|
567
|
-
ir as NumericFormat,
|
|
568
|
-
rr as getNumericCaretBoundary,
|
|
569
|
-
xe as numericFormatter,
|
|
570
|
-
er as removeNumericFormat,
|
|
571
|
-
tr as useNumericFormat
|
|
572
|
-
};
|