bj-web-components 0.2.28 → 0.2.29
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/index.js +1 -51
- package/dist/index.mjs +49 -49
- package/dist/style.css +1 -3744
- package/dist/web/BasicInput/BInput.js +1 -208
- package/dist/web/BasicInput/BInput.mjs +132 -164
- package/dist/web/BasicInput/utils.js +1 -47
- package/dist/web/BasicInput/utils.mjs +28 -38
- package/dist/web/CategoryDropdown/CategoryDropdown.js +1 -307
- package/dist/web/CategoryDropdown/CategoryDropdown.mjs +170 -218
- package/dist/web/CheckBox/BCheckBox.js +1 -116
- package/dist/web/CheckBox/BCheckBox.mjs +70 -86
- package/dist/web/CheckBox/Group.js +1 -73
- package/dist/web/CheckBox/Group.mjs +56 -63
- package/dist/web/CheckBox/context.js +1 -5
- package/dist/web/CheckBox/context.mjs +3 -3
- package/dist/web/CheckBox/index.js +1 -8
- package/dist/web/CheckBox/index.mjs +6 -6
- package/dist/web/Dropdown/BDropdown.js +1 -186
- package/dist/web/Dropdown/BDropdown.mjs +106 -132
- package/dist/web/EmptyInputBox/EmptyInputBox.js +1 -77
- package/dist/web/EmptyInputBox/EmptyInputBox.mjs +48 -52
- package/dist/web/FileCard/FileCard.js +1 -157
- package/dist/web/FileCard/FileCard.mjs +82 -112
- package/dist/web/Icon/Icon.js +1 -9
- package/dist/web/Icon/Icon.mjs +6 -6
- package/dist/web/Input/Input.js +1 -181
- package/dist/web/Input/Input.mjs +113 -122
- package/dist/web/InputNumber/BInputNumber.js +1 -311
- package/dist/web/InputNumber/BInputNumber.mjs +167 -275
- package/dist/web/InputNumber/StepHandler.js +1 -69
- package/dist/web/InputNumber/StepHandler.mjs +32 -38
- package/dist/web/InputNumber/hooks/useCursor.js +1 -40
- package/dist/web/InputNumber/hooks/useCursor.mjs +33 -35
- package/dist/web/InputNumber/hooks/useFrame.js +1 -12
- package/dist/web/InputNumber/hooks/useFrame.mjs +6 -9
- package/dist/web/InputNumber/utils/decimal.js +1 -147
- package/dist/web/InputNumber/utils/decimal.mjs +81 -109
- package/dist/web/Modal/Modal.js +1 -84
- package/dist/web/Modal/Modal.mjs +49 -52
- package/dist/web/OverlayScrollbar/BOverlayScrollbar.js +1 -232
- package/dist/web/OverlayScrollbar/BOverlayScrollbar.mjs +125 -206
- package/dist/web/Pagination/Pagination.js +1 -328
- package/dist/web/Pagination/Pagination.mjs +178 -254
- package/dist/web/ProductField/ProductField.js +1 -272
- package/dist/web/ProductField/ProductField.mjs +143 -190
- package/dist/web/ProductField/arrow-up.svg.js +1 -3
- package/dist/web/ProductField/arrow-up.svg.mjs +2 -2
- package/dist/web/ProductField/checkbox-no.svg.js +1 -3
- package/dist/web/ProductField/checkbox-no.svg.mjs +2 -2
- package/dist/web/ProductField/checkbox-ok.svg.js +1 -3
- package/dist/web/ProductField/checkbox-ok.svg.mjs +2 -2
- package/dist/web/ProductField/no_data_light.svg.js +1 -3
- package/dist/web/ProductField/no_data_light.svg.mjs +2 -2
- package/dist/web/ProductField/search.svg.js +1 -3
- package/dist/web/ProductField/search.svg.mjs +2 -2
- package/dist/web/ProductField/sort.svg.js +1 -3
- package/dist/web/ProductField/sort.svg.mjs +2 -2
- package/dist/web/SkuInputCard/SkuInputCard.js +1 -276
- package/dist/web/SkuInputCard/SkuInputCard.mjs +149 -188
- package/dist/web/SkuInputCard/spin_loading_red.gif.js +1 -3
- package/dist/web/SkuInputCard/spin_loading_red.gif.mjs +2 -2
- package/dist/web/Switch/Switch.js +1 -70
- package/dist/web/Switch/Switch.mjs +37 -47
- package/dist/web/Table/BTable.js +1 -950
- package/dist/web/Table/BTable.mjs +521 -767
- package/dist/web/Table/Column.js +1 -5
- package/dist/web/Table/Column.mjs +2 -2
- package/dist/web/Table/ColumnGroup.js +1 -5
- package/dist/web/Table/ColumnGroup.mjs +2 -2
- package/dist/web/Table/utils/columns.js +1 -48
- package/dist/web/Table/utils/columns.mjs +30 -35
- package/dist/web/Table/utils/sortFilter.js +1 -84
- package/dist/web/Table/utils/sortFilter.mjs +52 -73
- package/dist/web/Tabs/BTabs.js +1 -150
- package/dist/web/Tabs/BTabs.mjs +98 -118
- package/dist/web/Tabs/TabPane.js +1 -8
- package/dist/web/Tabs/TabPane.mjs +4 -4
- package/dist/web/Tooltip/ConfirmTooltip.js +1 -26
- package/dist/web/Tooltip/ConfirmTooltip.mjs +19 -20
- package/dist/web/Tooltip/ContentTooltip.js +1 -94
- package/dist/web/Tooltip/ContentTooltip.mjs +62 -72
- package/dist/web/Tooltip/ProgressTooltip.js +1 -36
- package/dist/web/Tooltip/ProgressTooltip.mjs +20 -22
- package/dist/web/Tooltip/TooltipWrapper.js +1 -12
- package/dist/web/Tooltip/TooltipWrapper.mjs +8 -8
- package/dist/web/Tooltip/useAutoPlacement.js +1 -41
- package/dist/web/Tooltip/useAutoPlacement.mjs +25 -34
- package/dist/web.js +1 -51
- package/dist/web.mjs +49 -49
- package/package.json +1 -1
|
@@ -1,312 +1,204 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useRef, useState, useCallback, useMemo } from "react";
|
|
1
|
+
import { jsxs as pe, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as Se, useRef as g, useState as z, useCallback as B, useMemo as U } from "react";
|
|
3
3
|
/* empty css */
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { getDecimal, getNumberPrecision, validateNumber, toFixed, getDecupleSteps } from "./utils/decimal.mjs";
|
|
8
|
-
function
|
|
9
|
-
if (
|
|
10
|
-
const
|
|
11
|
-
return
|
|
4
|
+
import We from "./hooks/useCursor.mjs";
|
|
5
|
+
import Ye from "./hooks/useFrame.mjs";
|
|
6
|
+
import Ge from "./StepHandler.mjs";
|
|
7
|
+
import { getDecimal as i, getNumberPrecision as de, validateNumber as Je, toFixed as O, getDecupleSteps as ge } from "./utils/decimal.mjs";
|
|
8
|
+
function je(I) {
|
|
9
|
+
if (I == null) return null;
|
|
10
|
+
const u = i(I);
|
|
11
|
+
return u.isInvalidate() ? null : u;
|
|
12
12
|
}
|
|
13
|
-
const
|
|
14
|
-
value,
|
|
15
|
-
defaultValue,
|
|
16
|
-
onChange,
|
|
17
|
-
min,
|
|
18
|
-
max,
|
|
19
|
-
step = 1,
|
|
20
|
-
precision,
|
|
21
|
-
disabled =
|
|
22
|
-
readOnly =
|
|
23
|
-
placeholder,
|
|
24
|
-
autoFocus,
|
|
25
|
-
size = "middle",
|
|
26
|
-
status,
|
|
27
|
-
bordered =
|
|
28
|
-
controls =
|
|
29
|
-
keyboard =
|
|
30
|
-
changeOnWheel =
|
|
31
|
-
changeOnBlur =
|
|
32
|
-
addonBefore,
|
|
33
|
-
addonAfter,
|
|
34
|
-
prefix,
|
|
35
|
-
suffix,
|
|
36
|
-
formatter,
|
|
37
|
-
parser,
|
|
38
|
-
decimalSeparator,
|
|
39
|
-
onStep,
|
|
40
|
-
onPressEnter,
|
|
41
|
-
onFocus,
|
|
42
|
-
onBlur,
|
|
43
|
-
id,
|
|
44
|
-
name,
|
|
45
|
-
className,
|
|
46
|
-
style
|
|
47
|
-
},
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const [decimalValue, setDecimalValue] = useState(() => getDecimal(value ?? defaultValue));
|
|
55
|
-
const setUncontrolledDecimalValue = (next) => {
|
|
56
|
-
if (value === void 0) setDecimalValue(next);
|
|
57
|
-
};
|
|
58
|
-
const getPrecision = useCallback(
|
|
59
|
-
(numStr, userTyping) => {
|
|
60
|
-
if (userTyping) return void 0;
|
|
61
|
-
if (precision !== void 0 && precision >= 0) return precision;
|
|
62
|
-
return Math.max(getNumberPrecision(numStr), getNumberPrecision(step));
|
|
13
|
+
const Ae = Se(function({
|
|
14
|
+
value: u,
|
|
15
|
+
defaultValue: A,
|
|
16
|
+
onChange: x,
|
|
17
|
+
min: C,
|
|
18
|
+
max: K,
|
|
19
|
+
step: c = 1,
|
|
20
|
+
precision: N,
|
|
21
|
+
disabled: F = !1,
|
|
22
|
+
readOnly: $ = !1,
|
|
23
|
+
placeholder: Ie,
|
|
24
|
+
autoFocus: Ne,
|
|
25
|
+
size: T = "middle",
|
|
26
|
+
status: ee,
|
|
27
|
+
bordered: ve = !0,
|
|
28
|
+
controls: k = !0,
|
|
29
|
+
keyboard: Ve = !0,
|
|
30
|
+
changeOnWheel: De = !1,
|
|
31
|
+
changeOnBlur: Re = !0,
|
|
32
|
+
addonBefore: a,
|
|
33
|
+
addonAfter: f,
|
|
34
|
+
prefix: v,
|
|
35
|
+
suffix: V,
|
|
36
|
+
formatter: D,
|
|
37
|
+
parser: R,
|
|
38
|
+
decimalSeparator: m,
|
|
39
|
+
onStep: M,
|
|
40
|
+
onPressEnter: P,
|
|
41
|
+
onFocus: H,
|
|
42
|
+
onBlur: S,
|
|
43
|
+
id: _e,
|
|
44
|
+
name: he,
|
|
45
|
+
className: te,
|
|
46
|
+
style: ne
|
|
47
|
+
}, _) {
|
|
48
|
+
const W = g(null), [Y, re] = z(!1), s = g(!1), j = g(!1), h = g(!1), G = g(""), [r, ue] = z(() => i(u ?? A)), we = (e) => {
|
|
49
|
+
u === void 0 && ue(e);
|
|
50
|
+
}, J = B(
|
|
51
|
+
(e, t) => {
|
|
52
|
+
if (!t)
|
|
53
|
+
return N !== void 0 && N >= 0 ? N : Math.max(de(e), de(c));
|
|
63
54
|
},
|
|
64
|
-
[
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (decimalSeparator) parsedStr = parsedStr.replace(decimalSeparator, ".");
|
|
71
|
-
return parsedStr.replace(/[^\w.-]+/g, "");
|
|
55
|
+
[N, c]
|
|
56
|
+
), L = B(
|
|
57
|
+
(e) => {
|
|
58
|
+
if (R) return R(e);
|
|
59
|
+
let t = e;
|
|
60
|
+
return m && (t = t.replace(m, ".")), t.replace(/[^\w.-]+/g, "");
|
|
72
61
|
},
|
|
73
|
-
[
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (validateNumber(str) && (decimalSeparator || (mergedPrecision ?? -1) >= 0)) {
|
|
82
|
-
str = toFixed(str, decimalSeparator || ".", mergedPrecision);
|
|
83
|
-
}
|
|
62
|
+
[R, m]
|
|
63
|
+
), ie = B(
|
|
64
|
+
(e, t) => {
|
|
65
|
+
if (D) return D(e, { userTyping: !!t, input: G.current });
|
|
66
|
+
let n = e;
|
|
67
|
+
if (!t) {
|
|
68
|
+
const l = J(n, t);
|
|
69
|
+
Je(n) && (m || (l ?? -1) >= 0) && (n = O(n, m || ".", l));
|
|
84
70
|
}
|
|
85
|
-
return
|
|
71
|
+
return n;
|
|
86
72
|
},
|
|
87
|
-
[
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (decimalValue.isInvalidate() && ["string", "number"].includes(typeof initValue)) {
|
|
92
|
-
return initValue === void 0 || initValue === null || Number.isNaN(initValue) ? "" : String(initValue);
|
|
93
|
-
}
|
|
94
|
-
return mergedFormatter(decimalValue.toString(), false);
|
|
73
|
+
[D, J, m]
|
|
74
|
+
), [w, se] = z(() => {
|
|
75
|
+
const e = A ?? u;
|
|
76
|
+
return r.isInvalidate() && ["string", "number"].includes(typeof e) ? e == null || Number.isNaN(e) ? "" : String(e) : ie(r.toString(), !1);
|
|
95
77
|
});
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
78
|
+
G.current = w;
|
|
79
|
+
const q = (e, t) => {
|
|
80
|
+
se(
|
|
81
|
+
ie(e.isInvalidate() ? e.toString(!1) : e.toString(!t), t)
|
|
100
82
|
);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return maxDecimal.lessEquals(decimalValue);
|
|
107
|
-
}, [maxDecimal, decimalValue]);
|
|
108
|
-
const downDisabled = useMemo(() => {
|
|
109
|
-
if (!minDecimal || decimalValue.isInvalidate()) return false;
|
|
110
|
-
return decimalValue.lessEquals(minDecimal);
|
|
111
|
-
}, [minDecimal, decimalValue]);
|
|
112
|
-
const [recordCursor] = useCursor(inputRef.current, focused);
|
|
113
|
-
const getRangeValue = (target) => {
|
|
114
|
-
if (maxDecimal && !target.lessEquals(maxDecimal)) return maxDecimal;
|
|
115
|
-
if (minDecimal && !minDecimal.lessEquals(target)) return minDecimal;
|
|
116
|
-
return null;
|
|
117
|
-
};
|
|
118
|
-
const isInRange = (target) => !getRangeValue(target);
|
|
119
|
-
const triggerValueUpdate = (newValue, userTyping) => {
|
|
120
|
-
let updateValue = newValue;
|
|
121
|
-
let isRangeValidate = isInRange(updateValue) || updateValue.isEmpty();
|
|
122
|
-
if (!updateValue.isEmpty() && !userTyping) {
|
|
123
|
-
updateValue = getRangeValue(updateValue) || updateValue;
|
|
124
|
-
isRangeValidate = true;
|
|
125
|
-
}
|
|
126
|
-
if (!readOnly && !disabled && isRangeValidate) {
|
|
127
|
-
const numStr = updateValue.toString();
|
|
128
|
-
const mergedPrecision = getPrecision(numStr, userTyping);
|
|
129
|
-
if (mergedPrecision !== void 0 && mergedPrecision >= 0) {
|
|
130
|
-
updateValue = getDecimal(toFixed(numStr, ".", mergedPrecision));
|
|
131
|
-
if (!isInRange(updateValue)) {
|
|
132
|
-
updateValue = getDecimal(toFixed(numStr, ".", mergedPrecision, true));
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
if (!updateValue.equals(decimalValue)) {
|
|
136
|
-
setUncontrolledDecimalValue(updateValue);
|
|
137
|
-
onChange == null ? void 0 : onChange(updateValue.isEmpty() ? null : updateValue.toNumber());
|
|
138
|
-
if (value === void 0) setInputValue(updateValue, userTyping);
|
|
139
|
-
}
|
|
140
|
-
return updateValue;
|
|
83
|
+
}, b = U(() => je(K), [K]), p = U(() => je(C), [C]), le = U(() => !b || r.isInvalidate() ? !1 : b.lessEquals(r), [b, r]), oe = U(() => !p || r.isInvalidate() ? !1 : r.lessEquals(p), [p, r]), [qe] = We(W.current, Y), ce = (e) => b && !e.lessEquals(b) ? b : p && !p.lessEquals(e) ? p : null, Q = (e) => !ce(e), y = (e, t) => {
|
|
84
|
+
let n = e, l = Q(n) || n.isEmpty();
|
|
85
|
+
if (!n.isEmpty() && !t && (n = ce(n) || n, l = !0), !$ && !F && l) {
|
|
86
|
+
const d = n.toString(), E = J(d, t);
|
|
87
|
+
return E !== void 0 && E >= 0 && (n = i(O(d, ".", E)), Q(n) || (n = i(O(d, ".", E, !0)))), n.equals(r) || (we(n), x == null || x(n.isEmpty() ? null : n.toNumber()), u === void 0 && q(n, t)), n;
|
|
141
88
|
}
|
|
142
|
-
return
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
inputValueRef.current = inputStr;
|
|
148
|
-
setInternalInputValue(inputStr);
|
|
149
|
-
if (!compositionRef.current) {
|
|
150
|
-
const finalValue = mergedParser(inputStr);
|
|
151
|
-
const finalDecimal = getDecimal(finalValue);
|
|
152
|
-
if (!finalDecimal.isNaN()) triggerValueUpdate(finalDecimal, true);
|
|
89
|
+
return r;
|
|
90
|
+
}, ye = Ye(), X = (e) => {
|
|
91
|
+
if (qe(), G.current = e, se(e), !j.current) {
|
|
92
|
+
const t = L(e), n = i(t);
|
|
93
|
+
n.isNaN() || y(n, !0);
|
|
153
94
|
}
|
|
154
|
-
|
|
155
|
-
const
|
|
156
|
-
|
|
95
|
+
ye(() => {
|
|
96
|
+
const t = R ? e : e.replace(/。/g, ".");
|
|
97
|
+
t !== e && X(t);
|
|
157
98
|
});
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
};
|
|
192
|
-
const onKeyDown = (event) => {
|
|
193
|
-
const { key, shiftKey } = event;
|
|
194
|
-
userTypingRef.current = true;
|
|
195
|
-
shiftKeyRef.current = shiftKey;
|
|
196
|
-
if (key === "Enter") {
|
|
197
|
-
if (!compositionRef.current) userTypingRef.current = false;
|
|
198
|
-
flushInputValue(false);
|
|
199
|
-
onPressEnter == null ? void 0 : onPressEnter(event);
|
|
200
|
-
}
|
|
201
|
-
if (!keyboard) return;
|
|
202
|
-
if (!compositionRef.current && (key === "ArrowUp" || key === "ArrowDown")) {
|
|
203
|
-
onInternalStep(key === "ArrowUp");
|
|
204
|
-
event.preventDefault();
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
const onKeyUp = () => {
|
|
208
|
-
userTypingRef.current = false;
|
|
209
|
-
shiftKeyRef.current = false;
|
|
210
|
-
};
|
|
211
|
-
const onInternalFocus = (e) => {
|
|
212
|
-
setFocused(true);
|
|
213
|
-
onFocus == null ? void 0 : onFocus(e);
|
|
214
|
-
};
|
|
215
|
-
const onInternalBlur = (e) => {
|
|
216
|
-
if (changeOnBlur) flushInputValue(false);
|
|
217
|
-
setFocused(false);
|
|
218
|
-
userTypingRef.current = false;
|
|
219
|
-
onBlur == null ? void 0 : onBlur(e);
|
|
220
|
-
};
|
|
221
|
-
const prevValueRef = useRef(value);
|
|
222
|
-
if (prevValueRef.current !== value) {
|
|
223
|
-
prevValueRef.current = value;
|
|
224
|
-
const newValue = getDecimal(value);
|
|
225
|
-
if (!newValue.equals(decimalValue)) {
|
|
226
|
-
setDecimalValue(newValue);
|
|
227
|
-
const currentParsedValue = getDecimal(mergedParser(inputValue));
|
|
228
|
-
if (!newValue.equals(currentParsedValue) || !userTypingRef.current || formatter) {
|
|
229
|
-
setInputValue(newValue, userTypingRef.current);
|
|
230
|
-
}
|
|
99
|
+
}, Ee = () => {
|
|
100
|
+
j.current = !0;
|
|
101
|
+
}, Ue = (e) => {
|
|
102
|
+
j.current = !1, X(e.target.value);
|
|
103
|
+
}, xe = (e) => X(e.target.value), Z = (e) => {
|
|
104
|
+
var d;
|
|
105
|
+
if (e && le || !e && oe) return;
|
|
106
|
+
s.current = !1;
|
|
107
|
+
let t = i(h.current ? ge(c) : c);
|
|
108
|
+
e || (t = t.negate());
|
|
109
|
+
const n = (r.isInvalidate() ? i(0) : r).add(t.toString()), l = y(n, !1);
|
|
110
|
+
M == null || M(l.toNumber(), { offset: h.current ? ge(c) : c, type: e ? "up" : "down" }), (d = W.current) == null || d.focus();
|
|
111
|
+
}, ae = (e) => {
|
|
112
|
+
const t = i(L(w));
|
|
113
|
+
let n;
|
|
114
|
+
t.isNaN() ? n = y(r, e) : n = y(t, e), u !== void 0 ? q(r, !1) : n.isNaN() || q(n, !1);
|
|
115
|
+
}, Ce = (e) => {
|
|
116
|
+
const { key: t, shiftKey: n } = e;
|
|
117
|
+
s.current = !0, h.current = n, t === "Enter" && (j.current || (s.current = !1), ae(!1), P == null || P(e)), Ve && !j.current && (t === "ArrowUp" || t === "ArrowDown") && (Z(t === "ArrowUp"), e.preventDefault());
|
|
118
|
+
}, Ke = () => {
|
|
119
|
+
s.current = !1, h.current = !1;
|
|
120
|
+
}, Fe = (e) => {
|
|
121
|
+
re(!0), H == null || H(e);
|
|
122
|
+
}, $e = (e) => {
|
|
123
|
+
Re && ae(!1), re(!1), s.current = !1, S == null || S(e);
|
|
124
|
+
}, fe = g(u);
|
|
125
|
+
if (fe.current !== u) {
|
|
126
|
+
fe.current = u;
|
|
127
|
+
const e = i(u);
|
|
128
|
+
if (!e.equals(r)) {
|
|
129
|
+
ue(e);
|
|
130
|
+
const t = i(L(w));
|
|
131
|
+
(!e.equals(t) || !s.current || D) && q(e, s.current);
|
|
231
132
|
}
|
|
232
133
|
}
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
else if (ref) ref.current = node;
|
|
237
|
-
};
|
|
238
|
-
const controlsEnabled = !!controls;
|
|
239
|
-
const controlsIcon = typeof controls === "object" ? controls.icon : void 0;
|
|
240
|
-
const outOfRange = !decimalValue.isInvalidate() && !isInRange(decimalValue);
|
|
241
|
-
const rootCls = [
|
|
134
|
+
const ke = (e) => {
|
|
135
|
+
W.current = e, typeof _ == "function" ? _(e) : _ && (_.current = e);
|
|
136
|
+
}, me = !!k, Me = typeof k == "object" ? k.icon : void 0, Pe = !r.isInvalidate() && !Q(r), He = [
|
|
242
137
|
"bj-input-number",
|
|
243
|
-
`bj-input-number--${
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
!
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
].filter(Boolean).join(" ")
|
|
254
|
-
const numberBox = /* @__PURE__ */ jsxs(
|
|
138
|
+
`bj-input-number--${T}`,
|
|
139
|
+
Y && "bj-input-number--focused",
|
|
140
|
+
F && "bj-input-number--disabled",
|
|
141
|
+
$ && "bj-input-number--readonly",
|
|
142
|
+
!ve && "bj-input-number--borderless",
|
|
143
|
+
ee && `bj-input-number--${ee}`,
|
|
144
|
+
Pe && "bj-input-number--out-of-range",
|
|
145
|
+
me && "bj-input-number--with-controls",
|
|
146
|
+
a && "bj-input-number--group-left",
|
|
147
|
+
f && "bj-input-number--group-right"
|
|
148
|
+
].filter(Boolean).join(" "), be = /* @__PURE__ */ pe(
|
|
255
149
|
"div",
|
|
256
150
|
{
|
|
257
|
-
className: [
|
|
258
|
-
style:
|
|
259
|
-
onKeyDown,
|
|
260
|
-
onKeyUp,
|
|
151
|
+
className: [He, !(a || f || v || V) && te].filter(Boolean).join(" "),
|
|
152
|
+
style: a || f || v || V ? void 0 : ne,
|
|
153
|
+
onKeyDown: Ce,
|
|
154
|
+
onKeyUp: Ke,
|
|
261
155
|
children: [
|
|
262
|
-
|
|
263
|
-
/* @__PURE__ */
|
|
156
|
+
v && /* @__PURE__ */ o("span", { className: "bj-input-number__prefix", children: v }),
|
|
157
|
+
/* @__PURE__ */ o("div", { className: "bj-input-number__input-wrap", children: /* @__PURE__ */ o(
|
|
264
158
|
"input",
|
|
265
159
|
{
|
|
266
|
-
ref:
|
|
267
|
-
id,
|
|
268
|
-
name,
|
|
160
|
+
ref: ke,
|
|
161
|
+
id: _e,
|
|
162
|
+
name: he,
|
|
269
163
|
className: "bj-input-number__input",
|
|
270
164
|
autoComplete: "off",
|
|
271
165
|
role: "spinbutton",
|
|
272
|
-
"aria-valuemin":
|
|
273
|
-
"aria-valuemax":
|
|
274
|
-
"aria-valuenow":
|
|
275
|
-
value:
|
|
276
|
-
placeholder,
|
|
277
|
-
disabled,
|
|
278
|
-
readOnly
|
|
279
|
-
autoFocus,
|
|
280
|
-
onChange:
|
|
281
|
-
onFocus:
|
|
282
|
-
onBlur:
|
|
283
|
-
onCompositionStart,
|
|
284
|
-
onCompositionEnd,
|
|
285
|
-
onWheel:
|
|
286
|
-
|
|
287
|
-
onInternalStep(e.deltaY < 0);
|
|
166
|
+
"aria-valuemin": C,
|
|
167
|
+
"aria-valuemax": K,
|
|
168
|
+
"aria-valuenow": r.isInvalidate() ? void 0 : r.toNumber(),
|
|
169
|
+
value: w,
|
|
170
|
+
placeholder: Ie,
|
|
171
|
+
disabled: F,
|
|
172
|
+
readOnly: $,
|
|
173
|
+
autoFocus: Ne,
|
|
174
|
+
onChange: xe,
|
|
175
|
+
onFocus: Fe,
|
|
176
|
+
onBlur: $e,
|
|
177
|
+
onCompositionStart: Ee,
|
|
178
|
+
onCompositionEnd: Ue,
|
|
179
|
+
onWheel: De ? (e) => {
|
|
180
|
+
Y && Z(e.deltaY < 0);
|
|
288
181
|
} : void 0
|
|
289
182
|
}
|
|
290
183
|
) }),
|
|
291
|
-
|
|
292
|
-
|
|
184
|
+
V && /* @__PURE__ */ o("span", { className: "bj-input-number__suffix", children: V }),
|
|
185
|
+
me && /* @__PURE__ */ o(Ge, { icon: Me, upDisabled: le, downDisabled: oe, onStep: Z })
|
|
293
186
|
]
|
|
294
187
|
}
|
|
295
188
|
);
|
|
296
|
-
|
|
297
|
-
return /* @__PURE__ */ jsxs(
|
|
189
|
+
return !a && !f ? be : /* @__PURE__ */ pe(
|
|
298
190
|
"div",
|
|
299
191
|
{
|
|
300
|
-
className: ["bj-input-number-group", `bj-input-number-group--${
|
|
301
|
-
style,
|
|
192
|
+
className: ["bj-input-number-group", `bj-input-number-group--${T}`, te].filter(Boolean).join(" "),
|
|
193
|
+
style: ne,
|
|
302
194
|
children: [
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
195
|
+
a && /* @__PURE__ */ o("div", { className: "bj-input-number-group__addon", children: a }),
|
|
196
|
+
be,
|
|
197
|
+
f && /* @__PURE__ */ o("div", { className: "bj-input-number-group__addon", children: f })
|
|
306
198
|
]
|
|
307
199
|
}
|
|
308
200
|
);
|
|
309
201
|
});
|
|
310
202
|
export {
|
|
311
|
-
|
|
203
|
+
Ae as default
|
|
312
204
|
};
|
|
@@ -1,69 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
-
const react = require("react");
|
|
4
|
-
const STEP_DELAY = 600;
|
|
5
|
-
const STEP_INTERVAL = 200;
|
|
6
|
-
function SpinnerIcon({ className }) {
|
|
7
|
-
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", className, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8
|
-
"path",
|
|
9
|
-
{
|
|
10
|
-
d: "M15.4573 13.6501C15.9047 13.6504 16.129 14.192 15.8128 14.5085L12.3352 17.9851C12.139 18.1811 11.8214 18.1811 11.6253 17.9851L8.14772 14.5085C7.83144 14.192 8.0558 13.6504 8.50319 13.6501H15.4573ZM11.6643 5.98311C11.8606 5.78688 12.179 5.78688 12.3753 5.98311L15.8518 9.45967C16.1683 9.77623 15.944 10.3171 15.4964 10.3171H8.54323C8.09567 10.3171 7.87154 9.77625 8.18776 9.45967L11.6643 5.98311Z",
|
|
11
|
-
fill: "currentColor"
|
|
12
|
-
}
|
|
13
|
-
) });
|
|
14
|
-
}
|
|
15
|
-
function StepHandler({ icon, upDisabled, downDisabled, onStep }) {
|
|
16
|
-
const stepTimeoutRef = react.useRef(void 0);
|
|
17
|
-
const onStepRef = react.useRef(onStep);
|
|
18
|
-
onStepRef.current = onStep;
|
|
19
|
-
const onStopStep = () => clearTimeout(stepTimeoutRef.current);
|
|
20
|
-
const onStepMouseDown = (e, up) => {
|
|
21
|
-
e.preventDefault();
|
|
22
|
-
onStopStep();
|
|
23
|
-
onStepRef.current(up);
|
|
24
|
-
function loopStep() {
|
|
25
|
-
onStepRef.current(up);
|
|
26
|
-
stepTimeoutRef.current = setTimeout(loopStep, STEP_INTERVAL);
|
|
27
|
-
}
|
|
28
|
-
stepTimeoutRef.current = setTimeout(loopStep, STEP_DELAY);
|
|
29
|
-
};
|
|
30
|
-
react.useEffect(() => onStopStep, []);
|
|
31
|
-
const sharedProps = {
|
|
32
|
-
unselectable: "on",
|
|
33
|
-
role: "button",
|
|
34
|
-
onMouseUp: onStopStep,
|
|
35
|
-
onMouseLeave: onStopStep
|
|
36
|
-
};
|
|
37
|
-
return (
|
|
38
|
-
// Click zones come before the icon(s) in DOM order so the icon halves
|
|
39
|
-
// can be dimmed via a `:hover ~`/`:active ~` sibling selector in CSS —
|
|
40
|
-
// the icon itself stays `pointer-events: none` and purely visual.
|
|
41
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bj-input-number__handler-wrap", children: [
|
|
42
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
43
|
-
"span",
|
|
44
|
-
{
|
|
45
|
-
...sharedProps,
|
|
46
|
-
"aria-label": "Increase Value",
|
|
47
|
-
"aria-disabled": upDisabled,
|
|
48
|
-
className: upDisabled ? "bj-input-number__handler bj-input-number__handler--up bj-input-number__handler--disabled" : "bj-input-number__handler bj-input-number__handler--up",
|
|
49
|
-
onMouseDown: (e) => onStepMouseDown(e, true)
|
|
50
|
-
}
|
|
51
|
-
),
|
|
52
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
53
|
-
"span",
|
|
54
|
-
{
|
|
55
|
-
...sharedProps,
|
|
56
|
-
"aria-label": "Decrease Value",
|
|
57
|
-
"aria-disabled": downDisabled,
|
|
58
|
-
className: downDisabled ? "bj-input-number__handler bj-input-number__handler--down bj-input-number__handler--disabled" : "bj-input-number__handler bj-input-number__handler--down",
|
|
59
|
-
onMouseDown: (e) => onStepMouseDown(e, false)
|
|
60
|
-
}
|
|
61
|
-
),
|
|
62
|
-
icon || /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
63
|
-
/* @__PURE__ */ jsxRuntime.jsx(SpinnerIcon, { className: "bj-input-number__handler-icon bj-input-number__handler-icon--up" }),
|
|
64
|
-
/* @__PURE__ */ jsxRuntime.jsx(SpinnerIcon, { className: "bj-input-number__handler-icon bj-input-number__handler-icon--down" })
|
|
65
|
-
] })
|
|
66
|
-
] })
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
module.exports = StepHandler;
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),a=require("react"),m=600,h=200;function _({className:t}){return e.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:e.jsx("path",{d:"M15.4573 13.6501C15.9047 13.6504 16.129 14.192 15.8128 14.5085L12.3352 17.9851C12.139 18.1811 11.8214 18.1811 11.6253 17.9851L8.14772 14.5085C7.83144 14.192 8.0558 13.6504 8.50319 13.6501H15.4573ZM11.6643 5.98311C11.8606 5.78688 12.179 5.78688 12.3753 5.98311L15.8518 9.45967C16.1683 9.77623 15.944 10.3171 15.4964 10.3171H8.54323C8.09567 10.3171 7.87154 9.77625 8.18776 9.45967L11.6643 5.98311Z",fill:"currentColor"})})}function j({icon:t,upDisabled:o,downDisabled:i,onStep:l}){const u=a.useRef(void 0),s=a.useRef(l);s.current=l;const r=()=>clearTimeout(u.current),c=(n,p)=>{n.preventDefault(),r(),s.current(p);function d(){s.current(p),u.current=setTimeout(d,h)}u.current=setTimeout(d,m)};a.useEffect(()=>r,[]);const b={unselectable:"on",role:"button",onMouseUp:r,onMouseLeave:r};return e.jsxs("div",{className:"bj-input-number__handler-wrap",children:[e.jsx("span",{...b,"aria-label":"Increase Value","aria-disabled":o,className:o?"bj-input-number__handler bj-input-number__handler--up bj-input-number__handler--disabled":"bj-input-number__handler bj-input-number__handler--up",onMouseDown:n=>c(n,!0)}),e.jsx("span",{...b,"aria-label":"Decrease Value","aria-disabled":i,className:i?"bj-input-number__handler bj-input-number__handler--down bj-input-number__handler--disabled":"bj-input-number__handler bj-input-number__handler--down",onMouseDown:n=>c(n,!1)}),t||e.jsxs(e.Fragment,{children:[e.jsx(_,{className:"bj-input-number__handler-icon bj-input-number__handler-icon--up"}),e.jsx(_,{className:"bj-input-number__handler-icon bj-input-number__handler-icon--down"})]})]})}module.exports=j;
|