@rockshin/tao-ui 0.0.48 → 0.0.49
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/components/affix/affix.js +20 -16
- package/dist/components/alert/alert.js +114 -99
- package/dist/components/app/app-modals.js +134 -96
- package/dist/components/app/app-notices.js +39 -23
- package/dist/components/auto-complete/auto-complete.js +21 -7
- package/dist/components/avatar/avatar.js +31 -11
- package/dist/components/badge/badge.css +1 -1
- package/dist/components/badge/badge.js +72 -257
- package/dist/components/border-beam/border-beam.js +21 -17
- package/dist/components/breadcrumb/breadcrumb.js +178 -159
- package/dist/components/button/button.js +61 -53
- package/dist/components/calendar/calendar.js +6 -4
- package/dist/components/card/card.js +24 -8
- package/dist/components/carousel/carousel.d.ts +1 -1
- package/dist/components/carousel/carousel.js +105 -68
- package/dist/components/cascader/cascader.js +54 -19
- package/dist/components/checkbox/checkbox.css +13 -2
- package/dist/components/checkbox/checkbox.d.ts +2 -0
- package/dist/components/checkbox/checkbox.js +320 -229
- package/dist/components/collapse/collapse-panels.d.ts +1 -1
- package/dist/components/collapse/collapse-panels.js +122 -113
- package/dist/components/collapse/collapse.js +98 -63
- package/dist/components/color-picker/color-picker.js +539 -441
- package/dist/components/color-picker/color.js +1 -1
- package/dist/components/context-menu/context-menu.d.ts +1 -1
- package/dist/components/context-menu/context-menu.js +108 -68
- package/dist/components/date-picker/calendar/calendar-grid.js +42 -39
- package/dist/components/date-picker/calendar/month-grid.d.ts +8 -1
- package/dist/components/date-picker/calendar/month-grid.js +79 -37
- package/dist/components/date-picker/calendar/time-panel.d.ts +2 -1
- package/dist/components/date-picker/calendar/time-panel.js +94 -89
- package/dist/components/date-picker/calendar/year-grid.d.ts +8 -1
- package/dist/components/date-picker/calendar/year-grid.js +66 -35
- package/dist/components/date-picker/date-picker.css +24 -1
- package/dist/components/date-picker/date-picker.js +99 -53
- package/dist/components/date-picker/presets.d.ts +2 -1
- package/dist/components/date-picker/presets.js +27 -24
- package/dist/components/date-picker/range-picker.js +308 -153
- package/dist/components/descriptions/descriptions.js +7 -3
- package/dist/components/divider/divider.css +1 -1
- package/dist/components/divider/divider.js +1 -1
- package/dist/components/drawer/drawer.js +201 -369
- package/dist/components/dropdown/dropdown.d.ts +1 -1
- package/dist/components/dropdown/dropdown.js +183 -279
- package/dist/components/empty/empty.js +57 -78
- package/dist/components/float-button/float-button.d.ts +1 -0
- package/dist/components/float-button/float-button.js +47 -30
- package/dist/components/form/field-control.d.ts +4 -2
- package/dist/components/form/field-control.js +17 -9
- package/dist/components/form/form-context.d.ts +8 -2
- package/dist/components/form/form-context.js +2 -1
- package/dist/components/form/form-item.js +85 -63
- package/dist/components/form/use-form.d.ts +2 -1
- package/dist/components/form/use-form.js +2 -1
- package/dist/components/form-field/form-field-view.d.ts +3 -1
- package/dist/components/form-field/form-field-view.js +194 -141
- package/dist/components/form-section/form-section.d.ts +1 -1
- package/dist/components/form-section/form-section.js +52 -45
- package/dist/components/image/image.js +585 -477
- package/dist/components/input/base-input.js +8 -9
- package/dist/components/input/input-shared.d.ts +5 -2
- package/dist/components/input/input-shared.js +42 -18
- package/dist/components/input/otp.js +236 -217
- package/dist/components/input/password.js +2 -1
- package/dist/components/input/search.js +8 -7
- package/dist/components/list/list-pagination.js +41 -36
- package/dist/components/list/list.js +141 -125
- package/dist/components/listy/listy.js +175 -106
- package/dist/components/masonry/masonry.js +108 -85
- package/dist/components/mentions/mentions.js +12 -3
- package/dist/components/menu/menu-render.d.ts +9 -3
- package/dist/components/menu/menu-render.js +99 -36
- package/dist/components/modal/confirm-dialog.js +10 -4
- package/dist/components/modal/confirm.js +3 -7
- package/dist/components/modal/index.js +9 -3
- package/dist/components/modal/modal.js +390 -365
- package/dist/components/pagination/pagination.js +105 -96
- package/dist/components/popconfirm/popconfirm.d.ts +1 -1
- package/dist/components/popconfirm/popconfirm.js +219 -168
- package/dist/components/popover/popover.js +330 -243
- package/dist/components/progress/progress.css +2 -2
- package/dist/components/progress/progress.js +232 -458
- package/dist/components/qr-code/qr-code.js +72 -66
- package/dist/components/radio/radio.css +15 -4
- package/dist/components/radio/radio.d.ts +2 -1
- package/dist/components/radio/radio.js +260 -198
- package/dist/components/rate/rate.js +173 -113
- package/dist/components/scroll-area/scroll-area.js +241 -211
- package/dist/components/segmented/segmented.js +73 -41
- package/dist/components/select/mobile-select.d.ts +2 -1
- package/dist/components/select/mobile-select.js +24 -13
- package/dist/components/select/select-searchable-list.d.ts +2 -1
- package/dist/components/select/select-searchable-list.js +2 -3
- package/dist/components/select/select.js +49 -25
- package/dist/components/select/use-select-selection.d.ts +1 -1
- package/dist/components/select/use-select-selection.js +7 -4
- package/dist/components/skeleton/skeleton.js +56 -48
- package/dist/components/slider/slider.js +87 -212
- package/dist/components/sonner/sonner.js +109 -93
- package/dist/components/spinner/spinner.js +147 -138
- package/dist/components/splitter/splitter.js +222 -159
- package/dist/components/statistic/statistic.js +7 -6
- package/dist/components/steps/steps.js +88 -81
- package/dist/components/steps/use-display-steps.js +1 -1
- package/dist/components/switch/switch.js +89 -89
- package/dist/components/table/table-filter.js +66 -56
- package/dist/components/table/table-icons.d.ts +2 -1
- package/dist/components/table/table-icons.js +11 -9
- package/dist/components/table/table-model.js +1 -1
- package/dist/components/table/table.js +107 -83
- package/dist/components/table/use-table-data.d.ts +6 -3
- package/dist/components/table/use-table-data.js +166 -130
- package/dist/components/tabs/tabs.css +1 -1
- package/dist/components/tabs/tabs.js +236 -179
- package/dist/components/tag/tag.d.ts +2 -2
- package/dist/components/tag/tag.js +111 -108
- package/dist/components/textarea/textarea.js +22 -17
- package/dist/components/time-picker/time-picker.js +5 -3
- package/dist/components/timeline/timeline.css +6 -1
- package/dist/components/timeline/timeline.js +21 -11
- package/dist/components/tooltip/tooltip.d.ts +2 -2
- package/dist/components/tooltip/tooltip.js +123 -233
- package/dist/components/tour/tour.css +4 -0
- package/dist/components/tour/tour.js +400 -331
- package/dist/components/transfer/transfer-list.js +29 -11
- package/dist/components/transfer/transfer-parts.js +1 -1
- package/dist/components/transfer/transfer-types.d.ts +1 -0
- package/dist/components/transfer/transfer.js +29 -14
- package/dist/components/tree/tree-keyboard.d.ts +1 -1
- package/dist/components/tree/tree-keyboard.js +5 -3
- package/dist/components/tree/tree.js +74 -59
- package/dist/components/tree-select/select-engine.d.ts +3 -2
- package/dist/components/tree-select/select-engine.js +18 -16
- package/dist/components/tree-select/tree-select.js +21 -5
- package/dist/components/upload/upload.css +8 -0
- package/dist/components/upload/upload.js +160 -72
- package/dist/components/watermark/watermark.js +36 -29
- package/dist/number-input/use-number-input.js +129 -90
- package/dist/number-input/validate.js +32 -5
- package/dist/provider/merge-locale.js +12 -9
- package/dist/provider/tao-provider.d.ts +3 -1
- package/dist/provider/tao-provider.js +123 -86
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ import { resolveNumberFormat } from "./locale.js";
|
|
|
7
7
|
import { fromPercent, toPercent } from "./percentage.js";
|
|
8
8
|
import { clampToRange, isValidCanonical, stripDisallowedSign } from "./validate.js";
|
|
9
9
|
function useNumberInput(opts) {
|
|
10
|
-
const $ = c(
|
|
10
|
+
const $ = c(91);
|
|
11
11
|
const { value, defaultValue, onChange, onBlur, locale: localeProp, decimalSeparator, thousandsSeparator: thousandsSeparatorProp, decimalPlaces: t0, padDecimalsOnBlur: t1, isPercentage: t2, allowNegative: t3, min, max } = opts;
|
|
12
12
|
const decimalPlaces = void 0 === t0 ? 2 : t0;
|
|
13
13
|
const padMode = void 0 === t1 ? "never" : t1;
|
|
@@ -156,27 +156,65 @@ function useNumberInput(opts) {
|
|
|
156
156
|
useEffect(t10, t11);
|
|
157
157
|
let t12;
|
|
158
158
|
let t13;
|
|
159
|
-
if ($[42] !==
|
|
159
|
+
if ($[42] !== defaultValue || $[43] !== fmtOpts || $[44] !== isPercentage || $[45] !== isValueControlled) {
|
|
160
160
|
t12 = ()=>{
|
|
161
|
+
if (isValueControlled) return;
|
|
162
|
+
const form = inputRef.current?.form;
|
|
163
|
+
const reset = (event)=>{
|
|
164
|
+
queueMicrotask(()=>{
|
|
165
|
+
if (event.defaultPrevented) return;
|
|
166
|
+
pendingCursorRef.current = null;
|
|
167
|
+
const initial = defaultValue ?? "";
|
|
168
|
+
setBuffer({
|
|
169
|
+
display: format(isPercentage ? toPercent(initial) : initial, fmtOpts),
|
|
170
|
+
format: fmtOpts,
|
|
171
|
+
isPercentage
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
form?.addEventListener("reset", reset);
|
|
176
|
+
return ()=>form?.removeEventListener("reset", reset);
|
|
177
|
+
};
|
|
178
|
+
t13 = [
|
|
179
|
+
defaultValue,
|
|
180
|
+
fmtOpts,
|
|
181
|
+
isPercentage,
|
|
182
|
+
isValueControlled
|
|
183
|
+
];
|
|
184
|
+
$[42] = defaultValue;
|
|
185
|
+
$[43] = fmtOpts;
|
|
186
|
+
$[44] = isPercentage;
|
|
187
|
+
$[45] = isValueControlled;
|
|
188
|
+
$[46] = t12;
|
|
189
|
+
$[47] = t13;
|
|
190
|
+
} else {
|
|
191
|
+
t12 = $[46];
|
|
192
|
+
t13 = $[47];
|
|
193
|
+
}
|
|
194
|
+
useEffect(t12, t13);
|
|
195
|
+
let t14;
|
|
196
|
+
let t15;
|
|
197
|
+
if ($[48] !== displayBuffer) {
|
|
198
|
+
t14 = ()=>{
|
|
161
199
|
const pending = pendingCursorRef.current;
|
|
162
200
|
if (pending?.display !== displayBuffer) return;
|
|
163
201
|
inputRef.current?.setSelectionRange(pending.start, pending.end);
|
|
164
202
|
pendingCursorRef.current = null;
|
|
165
203
|
};
|
|
166
|
-
|
|
204
|
+
t15 = [
|
|
167
205
|
displayBuffer
|
|
168
206
|
];
|
|
169
|
-
$[
|
|
170
|
-
$[
|
|
171
|
-
$[
|
|
207
|
+
$[48] = displayBuffer;
|
|
208
|
+
$[49] = t14;
|
|
209
|
+
$[50] = t15;
|
|
172
210
|
} else {
|
|
173
|
-
|
|
174
|
-
|
|
211
|
+
t14 = $[49];
|
|
212
|
+
t15 = $[50];
|
|
175
213
|
}
|
|
176
|
-
useLayoutEffect(
|
|
177
|
-
let
|
|
178
|
-
if ($[
|
|
179
|
-
|
|
214
|
+
useLayoutEffect(t14, t15);
|
|
215
|
+
let t16;
|
|
216
|
+
if ($[51] !== allowNegative || $[52] !== decimalPlaces || $[53] !== fmtOpts || $[54] !== isPercentage || $[55] !== onChange || $[56] !== setDisplayBuffer || $[57] !== thousandsSeparator) {
|
|
217
|
+
t16 = (e)=>{
|
|
180
218
|
const raw = e.target.value;
|
|
181
219
|
const cursor = e.target.selectionStart ?? raw.length;
|
|
182
220
|
let canonical_1 = parse(raw, fmtOpts);
|
|
@@ -199,110 +237,111 @@ function useNumberInput(opts) {
|
|
|
199
237
|
const actual_1 = isPercentage ? fromPercent(canonical_1) : canonical_1;
|
|
200
238
|
onChange?.(actual_1);
|
|
201
239
|
};
|
|
202
|
-
$[
|
|
203
|
-
$[
|
|
204
|
-
$[
|
|
205
|
-
$[
|
|
206
|
-
$[
|
|
207
|
-
$[
|
|
208
|
-
$[
|
|
209
|
-
$[
|
|
210
|
-
} else
|
|
211
|
-
const handleChange =
|
|
212
|
-
let
|
|
213
|
-
if ($[
|
|
214
|
-
|
|
240
|
+
$[51] = allowNegative;
|
|
241
|
+
$[52] = decimalPlaces;
|
|
242
|
+
$[53] = fmtOpts;
|
|
243
|
+
$[54] = isPercentage;
|
|
244
|
+
$[55] = onChange;
|
|
245
|
+
$[56] = setDisplayBuffer;
|
|
246
|
+
$[57] = thousandsSeparator;
|
|
247
|
+
$[58] = t16;
|
|
248
|
+
} else t16 = $[58];
|
|
249
|
+
const handleChange = t16;
|
|
250
|
+
let t17;
|
|
251
|
+
if ($[59] !== canonicalToDisplay || $[60] !== decimalPlaces || $[61] !== displayBuffer || $[62] !== fmtOpts || $[63] !== isPercentage || $[64] !== isValueControlled || $[65] !== max || $[66] !== min || $[67] !== onBlur || $[68] !== onChange || $[69] !== padMode || $[70] !== setDisplayBuffer || $[71] !== value) {
|
|
252
|
+
t17 = ()=>{
|
|
215
253
|
isFocusedRef.current = false;
|
|
216
254
|
const raw_0 = isValueControlled ? canonicalToDisplay(value ?? "") : inputRef.current?.value ?? displayBuffer;
|
|
217
255
|
let canonical_2 = parse(raw_0, fmtOpts);
|
|
218
256
|
canonical_2 = padOnBlur(canonical_2, decimalPlaces, padMode);
|
|
219
|
-
|
|
220
|
-
|
|
257
|
+
const beforeClamp = isPercentage ? fromPercent(canonical_2) : canonical_2;
|
|
258
|
+
const bounded = clampToRange(beforeClamp, min, max);
|
|
259
|
+
const actual_2 = !isPercentage && decimalPlaces > 0 && bounded !== beforeClamp ? padOnBlur(bounded, decimalPlaces, padMode) : bounded;
|
|
221
260
|
const canonicalAfter = isPercentage ? toPercent(actual_2) : actual_2;
|
|
222
261
|
const newDisplay_0 = format(canonicalAfter, fmtOpts);
|
|
223
262
|
setDisplayBuffer(newDisplay_0);
|
|
224
263
|
onChange?.(actual_2);
|
|
225
264
|
onBlur?.(actual_2);
|
|
226
265
|
};
|
|
227
|
-
$[
|
|
228
|
-
$[
|
|
229
|
-
$[
|
|
230
|
-
$[
|
|
231
|
-
$[
|
|
232
|
-
$[
|
|
233
|
-
$[
|
|
234
|
-
$[
|
|
235
|
-
$[
|
|
236
|
-
$[
|
|
237
|
-
$[
|
|
238
|
-
$[
|
|
239
|
-
$[
|
|
240
|
-
$[
|
|
241
|
-
} else
|
|
242
|
-
const handleBlur =
|
|
243
|
-
let
|
|
244
|
-
if ($[
|
|
245
|
-
|
|
266
|
+
$[59] = canonicalToDisplay;
|
|
267
|
+
$[60] = decimalPlaces;
|
|
268
|
+
$[61] = displayBuffer;
|
|
269
|
+
$[62] = fmtOpts;
|
|
270
|
+
$[63] = isPercentage;
|
|
271
|
+
$[64] = isValueControlled;
|
|
272
|
+
$[65] = max;
|
|
273
|
+
$[66] = min;
|
|
274
|
+
$[67] = onBlur;
|
|
275
|
+
$[68] = onChange;
|
|
276
|
+
$[69] = padMode;
|
|
277
|
+
$[70] = setDisplayBuffer;
|
|
278
|
+
$[71] = value;
|
|
279
|
+
$[72] = t17;
|
|
280
|
+
} else t17 = $[72];
|
|
281
|
+
const handleBlur = t17;
|
|
282
|
+
let t18;
|
|
283
|
+
if ($[73] === Symbol.for("react.memo_cache_sentinel")) {
|
|
284
|
+
t18 = ()=>{
|
|
246
285
|
isFocusedRef.current = true;
|
|
247
286
|
};
|
|
248
|
-
$[
|
|
249
|
-
} else
|
|
250
|
-
const handleFocus =
|
|
251
|
-
let
|
|
252
|
-
if ($[
|
|
253
|
-
|
|
254
|
-
if ("Backspace" !== e_0.key) return;
|
|
287
|
+
$[73] = t18;
|
|
288
|
+
} else t18 = $[73];
|
|
289
|
+
const handleFocus = t18;
|
|
290
|
+
let t19;
|
|
291
|
+
if ($[74] !== displayBuffer || $[75] !== thousandsSeparator) {
|
|
292
|
+
t19 = (e_0)=>{
|
|
293
|
+
if ("Backspace" !== e_0.key || e_0.nativeEvent.isComposing || 229 === e_0.keyCode) return;
|
|
255
294
|
const el = inputRef.current;
|
|
256
295
|
if (!el) return;
|
|
257
296
|
const cursor_0 = el.selectionStart ?? 0;
|
|
258
|
-
if (cursor_0 > 0 && isThousandSepBeforeCursor(displayBuffer, cursor_0, thousandsSeparator)) el.setSelectionRange(cursor_0 - 1, cursor_0 - 1);
|
|
297
|
+
if (cursor_0 > 0 && el.selectionEnd === cursor_0 && isThousandSepBeforeCursor(displayBuffer, cursor_0, thousandsSeparator)) el.setSelectionRange(cursor_0 - 1, cursor_0 - 1);
|
|
259
298
|
};
|
|
260
|
-
$[
|
|
261
|
-
$[
|
|
262
|
-
$[
|
|
263
|
-
} else
|
|
264
|
-
const handleKeyDown =
|
|
265
|
-
let t18;
|
|
266
|
-
if ($[71] !== buffer.display || $[72] !== buffer.format || $[73] !== buffer.isPercentage) {
|
|
267
|
-
const canonical_3 = parse(buffer.display, buffer.format);
|
|
268
|
-
t18 = buffer.isPercentage ? fromPercent(canonical_3) : canonical_3;
|
|
269
|
-
$[71] = buffer.display;
|
|
270
|
-
$[72] = buffer.format;
|
|
271
|
-
$[73] = buffer.isPercentage;
|
|
272
|
-
$[74] = t18;
|
|
273
|
-
} else t18 = $[74];
|
|
274
|
-
const derivedActual = t18;
|
|
275
|
-
const t19 = decimalPlaces > 0 ? "decimal" : "numeric";
|
|
299
|
+
$[74] = displayBuffer;
|
|
300
|
+
$[75] = thousandsSeparator;
|
|
301
|
+
$[76] = t19;
|
|
302
|
+
} else t19 = $[76];
|
|
303
|
+
const handleKeyDown = t19;
|
|
276
304
|
let t20;
|
|
277
|
-
if ($[
|
|
278
|
-
|
|
305
|
+
if ($[77] !== buffer.display || $[78] !== buffer.format || $[79] !== buffer.isPercentage) {
|
|
306
|
+
const canonical_3 = parse(buffer.display, buffer.format);
|
|
307
|
+
t20 = buffer.isPercentage ? fromPercent(canonical_3) : canonical_3;
|
|
308
|
+
$[77] = buffer.display;
|
|
309
|
+
$[78] = buffer.format;
|
|
310
|
+
$[79] = buffer.isPercentage;
|
|
311
|
+
$[80] = t20;
|
|
312
|
+
} else t20 = $[80];
|
|
313
|
+
const derivedActual = t20;
|
|
314
|
+
const t21 = decimalPlaces > 0 ? "decimal" : "numeric";
|
|
315
|
+
let t22;
|
|
316
|
+
if ($[81] !== displayBuffer || $[82] !== handleBlur || $[83] !== handleChange || $[84] !== handleKeyDown || $[85] !== t21) {
|
|
317
|
+
t22 = {
|
|
279
318
|
value: displayBuffer,
|
|
280
319
|
onChange: handleChange,
|
|
281
320
|
onBlur: handleBlur,
|
|
282
321
|
onFocus: handleFocus,
|
|
283
322
|
onKeyDown: handleKeyDown,
|
|
284
323
|
ref: inputRef,
|
|
285
|
-
inputMode:
|
|
324
|
+
inputMode: t21
|
|
286
325
|
};
|
|
287
|
-
$[
|
|
288
|
-
$[
|
|
289
|
-
$[
|
|
290
|
-
$[
|
|
291
|
-
$[
|
|
292
|
-
$[
|
|
293
|
-
} else
|
|
294
|
-
let
|
|
295
|
-
if ($[
|
|
296
|
-
|
|
297
|
-
inputProps:
|
|
326
|
+
$[81] = displayBuffer;
|
|
327
|
+
$[82] = handleBlur;
|
|
328
|
+
$[83] = handleChange;
|
|
329
|
+
$[84] = handleKeyDown;
|
|
330
|
+
$[85] = t21;
|
|
331
|
+
$[86] = t22;
|
|
332
|
+
} else t22 = $[86];
|
|
333
|
+
let t23;
|
|
334
|
+
if ($[87] !== derivedActual || $[88] !== displayBuffer || $[89] !== t22) {
|
|
335
|
+
t23 = {
|
|
336
|
+
inputProps: t22,
|
|
298
337
|
value: derivedActual,
|
|
299
338
|
displayValue: displayBuffer
|
|
300
339
|
};
|
|
301
|
-
$[
|
|
302
|
-
$[
|
|
303
|
-
$[
|
|
304
|
-
$[
|
|
305
|
-
} else
|
|
306
|
-
return
|
|
340
|
+
$[87] = derivedActual;
|
|
341
|
+
$[88] = displayBuffer;
|
|
342
|
+
$[89] = t22;
|
|
343
|
+
$[90] = t23;
|
|
344
|
+
} else t23 = $[90];
|
|
345
|
+
return t23;
|
|
307
346
|
}
|
|
308
347
|
export { useNumberInput };
|
|
@@ -11,12 +11,39 @@ function stripDisallowedSign(canonical, allowNegative) {
|
|
|
11
11
|
if (allowNegative) return canonical;
|
|
12
12
|
return canonical.startsWith('-') ? canonical.slice(1) : canonical;
|
|
13
13
|
}
|
|
14
|
+
function decimalParts(value) {
|
|
15
|
+
const [integer, fraction = ''] = value.replace(/^-/, '').split('.');
|
|
16
|
+
const whole = integer.replace(/^0+/, '') || '0';
|
|
17
|
+
const decimals = fraction.replace(/0+$/, '');
|
|
18
|
+
const sign = value.startsWith('-') && ('0' !== whole || decimals) ? -1 : 1;
|
|
19
|
+
return {
|
|
20
|
+
whole,
|
|
21
|
+
decimals,
|
|
22
|
+
sign
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function compareDecimals(left, right) {
|
|
26
|
+
const a = decimalParts(left);
|
|
27
|
+
const b = decimalParts(right);
|
|
28
|
+
if (a.sign !== b.sign) return a.sign - b.sign;
|
|
29
|
+
if (a.whole.length !== b.whole.length) return (a.whole.length - b.whole.length) * a.sign;
|
|
30
|
+
if (a.whole !== b.whole) return (a.whole > b.whole ? 1 : -1) * a.sign;
|
|
31
|
+
const length = Math.max(a.decimals.length, b.decimals.length);
|
|
32
|
+
const aFraction = a.decimals.padEnd(length, '0');
|
|
33
|
+
const bFraction = b.decimals.padEnd(length, '0');
|
|
34
|
+
if (aFraction === bFraction) return 0;
|
|
35
|
+
return (aFraction > bFraction ? 1 : -1) * a.sign;
|
|
36
|
+
}
|
|
14
37
|
function clampToRange(canonical, min, max) {
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
38
|
+
if (!/\d/.test(canonical)) return canonical;
|
|
39
|
+
if (void 0 !== min && Number.isFinite(min)) {
|
|
40
|
+
const lower = toCanonical(min);
|
|
41
|
+
if (compareDecimals(canonical, lower) < 0) return lower;
|
|
42
|
+
}
|
|
43
|
+
if (void 0 !== max && Number.isFinite(max)) {
|
|
44
|
+
const upper = toCanonical(max);
|
|
45
|
+
if (compareDecimals(canonical, upper) > 0) return upper;
|
|
46
|
+
}
|
|
20
47
|
return canonical;
|
|
21
48
|
}
|
|
22
49
|
export { clampToRange, isValidCanonical, stripDisallowedSign };
|
|
@@ -1,32 +1,35 @@
|
|
|
1
1
|
import { enUS, zhCN } from "./locale.js";
|
|
2
|
+
function defined(value) {
|
|
3
|
+
return Object.fromEntries(Object.entries(value ?? {}).filter(([, entry])=>void 0 !== entry));
|
|
4
|
+
}
|
|
2
5
|
function mergeValidateMessages(parent, override) {
|
|
3
6
|
if (!override) return parent;
|
|
4
7
|
return {
|
|
5
8
|
...parent,
|
|
6
|
-
...override,
|
|
9
|
+
...defined(override),
|
|
7
10
|
date: {
|
|
8
11
|
...parent?.date,
|
|
9
|
-
...override.date
|
|
12
|
+
...defined(override.date)
|
|
10
13
|
},
|
|
11
14
|
types: {
|
|
12
15
|
...parent?.types,
|
|
13
|
-
...override.types
|
|
16
|
+
...defined(override.types)
|
|
14
17
|
},
|
|
15
18
|
string: {
|
|
16
19
|
...parent?.string,
|
|
17
|
-
...override.string
|
|
20
|
+
...defined(override.string)
|
|
18
21
|
},
|
|
19
22
|
number: {
|
|
20
23
|
...parent?.number,
|
|
21
|
-
...override.number
|
|
24
|
+
...defined(override.number)
|
|
22
25
|
},
|
|
23
26
|
array: {
|
|
24
27
|
...parent?.array,
|
|
25
|
-
...override.array
|
|
28
|
+
...defined(override.array)
|
|
26
29
|
},
|
|
27
30
|
pattern: {
|
|
28
31
|
...parent?.pattern,
|
|
29
|
-
...override.pattern
|
|
32
|
+
...defined(override.pattern)
|
|
30
33
|
}
|
|
31
34
|
};
|
|
32
35
|
}
|
|
@@ -41,11 +44,11 @@ function mergeLocale(parent, override) {
|
|
|
41
44
|
weekStartsOn: legacy.weekStartsOn,
|
|
42
45
|
pickerLocale: legacy.pickerLocale
|
|
43
46
|
} : {},
|
|
44
|
-
...override,
|
|
47
|
+
...defined(override),
|
|
45
48
|
messages: {
|
|
46
49
|
...parent.messages,
|
|
47
50
|
...legacy?.messages,
|
|
48
|
-
...override.messages
|
|
51
|
+
...defined(override.messages)
|
|
49
52
|
},
|
|
50
53
|
form: mergeValidateMessages(legacy?.form ?? parent.form, override.form)
|
|
51
54
|
};
|
|
@@ -114,7 +114,9 @@ interface TaoConfigContextValue extends TaoConfig {
|
|
|
114
114
|
* Carried through context so portaled layers (Modal/Drawer/Select dropdown…)
|
|
115
115
|
* — which render outside the provider's DOM subtree — can re-apply the theme.
|
|
116
116
|
*/
|
|
117
|
-
tokenStyle:
|
|
117
|
+
tokenStyle: Record<string, string>;
|
|
118
|
+
/** Caller-provided tokens, excluding generated defaults used to isolate a scope. */
|
|
119
|
+
tokenOverrides: Record<string, string>;
|
|
118
120
|
}
|
|
119
121
|
export declare function useTaoConfig(): TaoConfig & {
|
|
120
122
|
locale: ResolvedTaoLocale;
|