@rockshin/tao-ui 0.0.56 → 0.0.58
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/component-manifest.json +1 -1
- package/dist/components/app/app-notices.js +10 -3
- package/dist/components/avatar/avatar.js +1 -1
- package/dist/components/badge/badge.js +2 -2
- package/dist/components/breadcrumb/breadcrumb.js +5 -1
- package/dist/components/calendar/calendar.js +4 -1
- package/dist/components/carousel/carousel.js +8 -2
- package/dist/components/collapse/collapse-panels.js +68 -67
- package/dist/components/date-picker/date-localization.js +12 -14
- package/dist/components/divider/divider.js +1 -1
- package/dist/components/float-button/float-button.js +7 -5
- package/dist/components/form/use-form.d.ts +1 -1
- package/dist/components/form/use-form.js +20 -0
- package/dist/components/image/image.js +135 -143
- package/dist/components/input/otp.js +6 -0
- package/dist/components/input/search.js +7 -5
- package/dist/components/list/list.js +106 -105
- package/dist/components/masonry/masonry.js +1 -1
- package/dist/components/modal/modal.js +112 -35
- package/dist/components/pagination/pagination.d.ts +2 -0
- package/dist/components/pagination/pagination.js +4 -0
- package/dist/components/rate/rate.js +83 -72
- package/dist/components/scroll-area/scroll-area.css +1 -1
- package/dist/components/scroll-area/scroll-area.js +294 -222
- package/dist/components/select/select-tags.js +2 -1
- package/dist/components/select/use-select-selection.d.ts +1 -1
- package/dist/components/select/use-select-selection.js +60 -53
- package/dist/components/statistic/statistic.js +84 -78
- package/dist/components/steps/steps.css +8 -0
- package/dist/components/steps/steps.d.ts +5 -1
- package/dist/components/steps/steps.js +126 -116
- package/dist/components/table/table.js +4 -1
- package/dist/components/upload/upload.js +2 -2
- package/dist/number-input/cursor.js +20 -8
- package/dist/number-input/format.js +12 -4
- package/dist/number-input/use-number-input.js +4 -1
- package/package.json +1 -1
|
@@ -117,8 +117,8 @@ function resolveStatuses(displaySteps, displayCurrent, currentStatus) {
|
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
function Steps(t0) {
|
|
120
|
-
const $ = c(
|
|
121
|
-
const { items, current: t1, initial: t2, status: t3, orientation, titlePlacement, responsive: t4, size, variant: t5, type, percent, maxCount, offset: t6, ellipsis: t7, iconRender, onChange, className, style, classNames, styles } = t0;
|
|
120
|
+
const $ = c(100);
|
|
121
|
+
const { items, current: t1, initial: t2, status: t3, orientation, titlePlacement, responsive: t4, size, variant: t5, type, percent, maxCount, offset: t6, ellipsis: t7, iconRender, finishIconBackground, finishIconColor, onChange, className, style, classNames, styles } = t0;
|
|
122
122
|
const current = void 0 === t1 ? 0 : t1;
|
|
123
123
|
const initial = void 0 === t2 ? 0 : t2;
|
|
124
124
|
const status = void 0 === t3 ? "process" : t3;
|
|
@@ -148,7 +148,7 @@ function Steps(t0) {
|
|
|
148
148
|
const isPanel = "panel" === mergedType;
|
|
149
149
|
const mergedOrientation = isPanel ? "horizontal" : "vertical" === orientation || responsive && true === screens.xs ? "vertical" : "horizontal";
|
|
150
150
|
const mergedTitlePlacement = isDot || "vertical" === mergedOrientation ? "vertical" === mergedOrientation ? "horizontal" : "vertical" : "navigation" === mergedType ? "horizontal" : titlePlacement ?? "horizontal";
|
|
151
|
-
const mergedPercent = isInline ? void 0 : percent;
|
|
151
|
+
const mergedPercent = isInline || void 0 === percent ? void 0 : Math.min(100, Math.max(0, percent || 0));
|
|
152
152
|
const { canApplyMaxCount, displaySteps, displayCurrent } = useDisplaySteps(mergedItems, current, initial, maxCount);
|
|
153
153
|
let t10;
|
|
154
154
|
if ($[4] !== displayCurrent || $[5] !== displaySteps || $[6] !== status) {
|
|
@@ -188,34 +188,40 @@ function Steps(t0) {
|
|
|
188
188
|
const t13 = String(isInline ? offset : 0);
|
|
189
189
|
const t14 = styles?.root;
|
|
190
190
|
let t15;
|
|
191
|
-
if ($[16] !==
|
|
191
|
+
if ($[16] !== finishIconBackground || $[17] !== finishIconColor || $[18] !== style || $[19] !== t13 || $[20] !== t14) {
|
|
192
192
|
t15 = {
|
|
193
193
|
"--tao-steps-items-offset": t13,
|
|
194
|
+
"--tao-steps-finish-icon-background": finishIconBackground,
|
|
195
|
+
"--tao-steps-finish-icon-color": finishIconColor,
|
|
194
196
|
...t14,
|
|
195
197
|
...style
|
|
196
198
|
};
|
|
197
|
-
$[16] =
|
|
198
|
-
$[17] =
|
|
199
|
-
$[18] =
|
|
200
|
-
$[19] =
|
|
201
|
-
|
|
199
|
+
$[16] = finishIconBackground;
|
|
200
|
+
$[17] = finishIconColor;
|
|
201
|
+
$[18] = style;
|
|
202
|
+
$[19] = t13;
|
|
203
|
+
$[20] = t14;
|
|
204
|
+
$[21] = t15;
|
|
205
|
+
} else t15 = $[21];
|
|
202
206
|
const rootStyle = t15;
|
|
203
|
-
const t16 =
|
|
204
|
-
const t17 =
|
|
205
|
-
const t18 =
|
|
206
|
-
const t19 =
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
$[22] =
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
207
|
+
const t16 = void 0 !== finishIconBackground || void 0;
|
|
208
|
+
const t17 = void 0 !== finishIconColor || void 0;
|
|
209
|
+
const t18 = ellipsis || void 0;
|
|
210
|
+
const t19 = canApplyMaxCount || void 0;
|
|
211
|
+
const t20 = void 0 !== mergedPercent || void 0;
|
|
212
|
+
const t21 = classNames?.root;
|
|
213
|
+
let t22;
|
|
214
|
+
if ($[22] !== className || $[23] !== t21) {
|
|
215
|
+
t22 = cx(t21, className);
|
|
216
|
+
$[22] = className;
|
|
217
|
+
$[23] = t21;
|
|
218
|
+
$[24] = t22;
|
|
219
|
+
} else t22 = $[24];
|
|
220
|
+
let t23;
|
|
221
|
+
if ($[25] !== classNames?.item || $[26] !== classNames?.itemContent || $[27] !== classNames?.itemHeader || $[28] !== classNames?.itemRail || $[29] !== classNames?.itemSection || $[30] !== classNames?.itemSubtitle || $[31] !== classNames?.itemTitle || $[32] !== classNames?.itemWrapper || $[33] !== contextDisabled || $[34] !== displayCurrent || $[35] !== displaySteps || $[36] !== handleStepClick || $[37] !== iconRender || $[38] !== initial || $[39] !== isDot || $[40] !== isInline || $[41] !== isPanel || $[42] !== mergedPercent || $[43] !== onChange || $[44] !== statuses || $[45] !== styles?.item || $[46] !== styles?.itemContent || $[47] !== styles?.itemHeader || $[48] !== styles?.itemRail || $[49] !== styles?.itemSection || $[50] !== styles?.itemSubtitle || $[51] !== styles?.itemTitle || $[52] !== styles?.itemWrapper) {
|
|
222
|
+
let t24;
|
|
223
|
+
if ($[54] !== classNames?.item || $[55] !== classNames?.itemContent || $[56] !== classNames?.itemHeader || $[57] !== classNames?.itemRail || $[58] !== classNames?.itemSection || $[59] !== classNames?.itemSubtitle || $[60] !== classNames?.itemTitle || $[61] !== classNames?.itemWrapper || $[62] !== contextDisabled || $[63] !== displayCurrent || $[64] !== displaySteps.length || $[65] !== handleStepClick || $[66] !== iconRender || $[67] !== initial || $[68] !== isDot || $[69] !== isInline || $[70] !== isPanel || $[71] !== mergedPercent || $[72] !== onChange || $[73] !== statuses || $[74] !== styles?.item || $[75] !== styles?.itemContent || $[76] !== styles?.itemHeader || $[77] !== styles?.itemRail || $[78] !== styles?.itemSection || $[79] !== styles?.itemSubtitle || $[80] !== styles?.itemTitle || $[81] !== styles?.itemWrapper) {
|
|
224
|
+
t24 = (displayStep, displayIndex_0)=>{
|
|
219
225
|
const { item, originIndex, ellipsis: isEllipsisStep } = displayStep;
|
|
220
226
|
const stepStatus = statuses[displayIndex_0];
|
|
221
227
|
const nextStatus = statuses[displayIndex_0 + 1];
|
|
@@ -369,107 +375,111 @@ function Steps(t0) {
|
|
|
369
375
|
}, itemKey);
|
|
370
376
|
return stepNode;
|
|
371
377
|
};
|
|
372
|
-
$[
|
|
373
|
-
$[
|
|
374
|
-
$[
|
|
375
|
-
$[
|
|
376
|
-
$[
|
|
377
|
-
$[
|
|
378
|
-
$[
|
|
379
|
-
$[
|
|
380
|
-
$[
|
|
381
|
-
$[
|
|
382
|
-
$[
|
|
383
|
-
$[
|
|
384
|
-
$[
|
|
385
|
-
$[
|
|
386
|
-
$[
|
|
387
|
-
$[
|
|
388
|
-
$[
|
|
389
|
-
$[
|
|
390
|
-
$[
|
|
391
|
-
$[
|
|
392
|
-
$[
|
|
393
|
-
$[
|
|
394
|
-
$[
|
|
395
|
-
$[
|
|
396
|
-
$[
|
|
397
|
-
$[
|
|
398
|
-
$[
|
|
399
|
-
$[
|
|
400
|
-
$[
|
|
401
|
-
} else
|
|
402
|
-
|
|
403
|
-
$[
|
|
404
|
-
$[
|
|
405
|
-
$[
|
|
406
|
-
$[
|
|
407
|
-
$[
|
|
408
|
-
$[
|
|
409
|
-
$[
|
|
410
|
-
$[
|
|
411
|
-
$[
|
|
412
|
-
$[
|
|
413
|
-
$[
|
|
414
|
-
$[
|
|
415
|
-
$[
|
|
416
|
-
$[
|
|
417
|
-
$[
|
|
418
|
-
$[
|
|
419
|
-
$[
|
|
420
|
-
$[
|
|
421
|
-
$[
|
|
422
|
-
$[
|
|
423
|
-
$[
|
|
424
|
-
$[
|
|
425
|
-
$[
|
|
426
|
-
$[
|
|
427
|
-
$[
|
|
428
|
-
$[
|
|
429
|
-
$[
|
|
430
|
-
$[
|
|
431
|
-
$[
|
|
432
|
-
} else
|
|
433
|
-
let
|
|
434
|
-
if ($[
|
|
435
|
-
|
|
378
|
+
$[54] = classNames?.item;
|
|
379
|
+
$[55] = classNames?.itemContent;
|
|
380
|
+
$[56] = classNames?.itemHeader;
|
|
381
|
+
$[57] = classNames?.itemRail;
|
|
382
|
+
$[58] = classNames?.itemSection;
|
|
383
|
+
$[59] = classNames?.itemSubtitle;
|
|
384
|
+
$[60] = classNames?.itemTitle;
|
|
385
|
+
$[61] = classNames?.itemWrapper;
|
|
386
|
+
$[62] = contextDisabled;
|
|
387
|
+
$[63] = displayCurrent;
|
|
388
|
+
$[64] = displaySteps.length;
|
|
389
|
+
$[65] = handleStepClick;
|
|
390
|
+
$[66] = iconRender;
|
|
391
|
+
$[67] = initial;
|
|
392
|
+
$[68] = isDot;
|
|
393
|
+
$[69] = isInline;
|
|
394
|
+
$[70] = isPanel;
|
|
395
|
+
$[71] = mergedPercent;
|
|
396
|
+
$[72] = onChange;
|
|
397
|
+
$[73] = statuses;
|
|
398
|
+
$[74] = styles?.item;
|
|
399
|
+
$[75] = styles?.itemContent;
|
|
400
|
+
$[76] = styles?.itemHeader;
|
|
401
|
+
$[77] = styles?.itemRail;
|
|
402
|
+
$[78] = styles?.itemSection;
|
|
403
|
+
$[79] = styles?.itemSubtitle;
|
|
404
|
+
$[80] = styles?.itemTitle;
|
|
405
|
+
$[81] = styles?.itemWrapper;
|
|
406
|
+
$[82] = t24;
|
|
407
|
+
} else t24 = $[82];
|
|
408
|
+
t23 = displaySteps.map(t24);
|
|
409
|
+
$[25] = classNames?.item;
|
|
410
|
+
$[26] = classNames?.itemContent;
|
|
411
|
+
$[27] = classNames?.itemHeader;
|
|
412
|
+
$[28] = classNames?.itemRail;
|
|
413
|
+
$[29] = classNames?.itemSection;
|
|
414
|
+
$[30] = classNames?.itemSubtitle;
|
|
415
|
+
$[31] = classNames?.itemTitle;
|
|
416
|
+
$[32] = classNames?.itemWrapper;
|
|
417
|
+
$[33] = contextDisabled;
|
|
418
|
+
$[34] = displayCurrent;
|
|
419
|
+
$[35] = displaySteps;
|
|
420
|
+
$[36] = handleStepClick;
|
|
421
|
+
$[37] = iconRender;
|
|
422
|
+
$[38] = initial;
|
|
423
|
+
$[39] = isDot;
|
|
424
|
+
$[40] = isInline;
|
|
425
|
+
$[41] = isPanel;
|
|
426
|
+
$[42] = mergedPercent;
|
|
427
|
+
$[43] = onChange;
|
|
428
|
+
$[44] = statuses;
|
|
429
|
+
$[45] = styles?.item;
|
|
430
|
+
$[46] = styles?.itemContent;
|
|
431
|
+
$[47] = styles?.itemHeader;
|
|
432
|
+
$[48] = styles?.itemRail;
|
|
433
|
+
$[49] = styles?.itemSection;
|
|
434
|
+
$[50] = styles?.itemSubtitle;
|
|
435
|
+
$[51] = styles?.itemTitle;
|
|
436
|
+
$[52] = styles?.itemWrapper;
|
|
437
|
+
$[53] = t23;
|
|
438
|
+
} else t23 = $[53];
|
|
439
|
+
let t24;
|
|
440
|
+
if ($[83] !== semanticValue || $[84] !== t23) {
|
|
441
|
+
t24 = /*#__PURE__*/ jsx(StepsSemanticContext.Provider, {
|
|
436
442
|
value: semanticValue,
|
|
437
|
-
children:
|
|
443
|
+
children: t23
|
|
438
444
|
});
|
|
439
|
-
$[
|
|
440
|
-
$[
|
|
441
|
-
$[
|
|
442
|
-
} else
|
|
443
|
-
let
|
|
444
|
-
if ($[
|
|
445
|
-
|
|
445
|
+
$[83] = semanticValue;
|
|
446
|
+
$[84] = t23;
|
|
447
|
+
$[85] = t24;
|
|
448
|
+
} else t24 = $[85];
|
|
449
|
+
let t25;
|
|
450
|
+
if ($[86] !== mergedOrientation || $[87] !== mergedTitlePlacement || $[88] !== mergedType || $[89] !== resolvedSize || $[90] !== rootStyle || $[91] !== t16 || $[92] !== t17 || $[93] !== t18 || $[94] !== t19 || $[95] !== t20 || $[96] !== t22 || $[97] !== t24 || $[98] !== variant) {
|
|
451
|
+
t25 = /*#__PURE__*/ jsx("div", {
|
|
446
452
|
"data-tao-steps": "",
|
|
453
|
+
"data-tao-finish-icon-background": t16,
|
|
454
|
+
"data-tao-finish-icon-color": t17,
|
|
447
455
|
"data-tao-orientation": mergedOrientation,
|
|
448
456
|
"data-tao-title-placement": mergedTitlePlacement,
|
|
449
457
|
"data-tao-type": mergedType,
|
|
450
458
|
"data-tao-variant": variant,
|
|
451
459
|
"data-tao-size": resolvedSize,
|
|
452
|
-
"data-tao-ellipsis":
|
|
453
|
-
"data-tao-max-count":
|
|
454
|
-
"data-tao-with-progress":
|
|
455
|
-
className:
|
|
460
|
+
"data-tao-ellipsis": t18,
|
|
461
|
+
"data-tao-max-count": t19,
|
|
462
|
+
"data-tao-with-progress": t20,
|
|
463
|
+
className: t22,
|
|
456
464
|
style: rootStyle,
|
|
457
|
-
children:
|
|
465
|
+
children: t24
|
|
458
466
|
});
|
|
459
|
-
$[
|
|
460
|
-
$[
|
|
461
|
-
$[
|
|
462
|
-
$[
|
|
463
|
-
$[
|
|
464
|
-
$[
|
|
465
|
-
$[
|
|
466
|
-
$[
|
|
467
|
-
$[
|
|
468
|
-
$[
|
|
469
|
-
$[
|
|
470
|
-
$[
|
|
471
|
-
|
|
472
|
-
|
|
467
|
+
$[86] = mergedOrientation;
|
|
468
|
+
$[87] = mergedTitlePlacement;
|
|
469
|
+
$[88] = mergedType;
|
|
470
|
+
$[89] = resolvedSize;
|
|
471
|
+
$[90] = rootStyle;
|
|
472
|
+
$[91] = t16;
|
|
473
|
+
$[92] = t17;
|
|
474
|
+
$[93] = t18;
|
|
475
|
+
$[94] = t19;
|
|
476
|
+
$[95] = t20;
|
|
477
|
+
$[96] = t22;
|
|
478
|
+
$[97] = t24;
|
|
479
|
+
$[98] = variant;
|
|
480
|
+
$[99] = t25;
|
|
481
|
+
} else t25 = $[99];
|
|
482
|
+
return t25;
|
|
473
483
|
}
|
|
474
484
|
function _temp(event_0) {
|
|
475
485
|
if (!event_0.defaultPrevented && event_0.target === event_0.currentTarget && ("Enter" === event_0.key || " " === event_0.key)) {
|
|
@@ -143,7 +143,9 @@ function Table({ columns: columnsProp, dataSource, rowKey, loading = false, pagi
|
|
|
143
143
|
] : expandedKeys.filter((k_0)=>k_0 !== key_1);
|
|
144
144
|
if (!isExpansionControlled) setInternalExpandedKeys(nextKeys_1);
|
|
145
145
|
expandable?.onExpand?.(expanded, record_2);
|
|
146
|
-
expandable?.onExpandedRowsChange?.(
|
|
146
|
+
expandable?.onExpandedRowsChange?.([
|
|
147
|
+
...nextKeys_1
|
|
148
|
+
]);
|
|
147
149
|
};
|
|
148
150
|
const scrollRef = useRef(null);
|
|
149
151
|
const headerRowRef = useRef(null);
|
|
@@ -416,6 +418,7 @@ function Table({ columns: columnsProp, dataSource, rowKey, loading = false, pagi
|
|
|
416
418
|
"data-tao-table-row": "",
|
|
417
419
|
"data-tao-selected": isSelected || void 0,
|
|
418
420
|
onClick: (event)=>{
|
|
421
|
+
if (!event.currentTarget.contains(event.target)) return;
|
|
419
422
|
const selectionCell = event.target.closest('[data-tao-table-selection-cell]');
|
|
420
423
|
if (selectionCell && event.target !== selectionCell) return void event.stopPropagation();
|
|
421
424
|
rowProps.onClick?.(event);
|
|
@@ -572,8 +572,8 @@ const UploadRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
572
572
|
showInfo: false,
|
|
573
573
|
...props.progress,
|
|
574
574
|
percent: file_15.percent ?? 0,
|
|
575
|
-
"aria-label": file_15['aria-label'] ?? file_15.name,
|
|
576
|
-
"aria-labelledby": file_15['aria-labelledby']
|
|
575
|
+
"aria-label": file_15['aria-label'] ?? props.progress?.['aria-label'] ?? file_15.name,
|
|
576
|
+
"aria-labelledby": file_15['aria-labelledby'] ?? props.progress?.['aria-labelledby']
|
|
577
577
|
}),
|
|
578
578
|
null != listConfig.extra && /*#__PURE__*/ jsx("span", {
|
|
579
579
|
"data-tao-upload-extra": "",
|
|
@@ -2,16 +2,22 @@ function countAnchored(display, upTo, thousandsSeparator) {
|
|
|
2
2
|
const limit = Math.min(upTo, display.length);
|
|
3
3
|
if (!thousandsSeparator) return Math.max(0, limit);
|
|
4
4
|
let count = 0;
|
|
5
|
-
for(let i = 0; i < limit;
|
|
5
|
+
for(let i = 0; i < limit;)if (display.startsWith(thousandsSeparator, i)) i += thousandsSeparator.length;
|
|
6
|
+
else {
|
|
7
|
+
count++;
|
|
8
|
+
i++;
|
|
9
|
+
}
|
|
6
10
|
return count;
|
|
7
11
|
}
|
|
8
12
|
function findCursorAt(display, anchorCount, thousandsSeparator) {
|
|
9
13
|
if (anchorCount <= 0) return 0;
|
|
10
14
|
if (!thousandsSeparator) return Math.min(anchorCount, display.length);
|
|
11
15
|
let count = 0;
|
|
12
|
-
for(let i = 0; i < display.length; i
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
for(let i = 0; i < display.length;)if (display.startsWith(thousandsSeparator, i)) i += thousandsSeparator.length;
|
|
17
|
+
else {
|
|
18
|
+
count++;
|
|
19
|
+
i++;
|
|
20
|
+
if (count === anchorCount) return i;
|
|
15
21
|
}
|
|
16
22
|
return display.length;
|
|
17
23
|
}
|
|
@@ -19,15 +25,21 @@ function countAnchoredFromEnd(display, fromPos, thousandsSeparator) {
|
|
|
19
25
|
if (fromPos >= display.length) return 0;
|
|
20
26
|
if (!thousandsSeparator) return display.length - Math.max(0, fromPos);
|
|
21
27
|
let count = 0;
|
|
22
|
-
for(let i = Math.max(0, fromPos);
|
|
28
|
+
for(let i = display.length; i > Math.max(0, fromPos);)if (display.endsWith(thousandsSeparator, i)) i -= thousandsSeparator.length;
|
|
29
|
+
else {
|
|
30
|
+
count++;
|
|
31
|
+
i--;
|
|
32
|
+
}
|
|
23
33
|
return count;
|
|
24
34
|
}
|
|
25
35
|
function findCursorFromEnd(display, anchoredFromEnd, thousandsSeparator) {
|
|
26
36
|
if (anchoredFromEnd <= 0) return display.length;
|
|
27
37
|
if (!thousandsSeparator) return Math.max(0, display.length - anchoredFromEnd);
|
|
28
38
|
let count = 0;
|
|
29
|
-
for(let i = display.length
|
|
30
|
-
|
|
39
|
+
for(let i = display.length; i > 0;)if (display.endsWith(thousandsSeparator, i)) i -= thousandsSeparator.length;
|
|
40
|
+
else {
|
|
41
|
+
count++;
|
|
42
|
+
i--;
|
|
31
43
|
if (count === anchoredFromEnd) return i;
|
|
32
44
|
}
|
|
33
45
|
return 0;
|
|
@@ -39,6 +51,6 @@ function reposition(args) {
|
|
|
39
51
|
}
|
|
40
52
|
function isThousandSepBeforeCursor(display, cursor, thousandsSeparator) {
|
|
41
53
|
if (!thousandsSeparator || cursor <= 0) return false;
|
|
42
|
-
return display
|
|
54
|
+
return display.endsWith(thousandsSeparator, cursor);
|
|
43
55
|
}
|
|
44
56
|
export { countAnchored, findCursorAt, isThousandSepBeforeCursor, reposition };
|
|
@@ -19,10 +19,18 @@ function parse(display, opts) {
|
|
|
19
19
|
const body = negative ? text.slice(1) : text;
|
|
20
20
|
let cleaned = '';
|
|
21
21
|
let seenDecimal = false;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
const { decimalSeparator } = opts;
|
|
23
|
+
for(let index = 0; index < body.length; index++){
|
|
24
|
+
const ch = body[index];
|
|
25
|
+
if (decimalSeparator && body.startsWith(decimalSeparator, index)) {
|
|
26
|
+
if (!seenDecimal) cleaned += '.';
|
|
27
|
+
seenDecimal = true;
|
|
28
|
+
index += decimalSeparator.length - 1;
|
|
29
|
+
} else if (ch >= '0' && ch <= '9') cleaned += ch;
|
|
30
|
+
else if (!seenDecimal && opts.allowAsciiDecimal && '.' === ch && '.' !== opts.thousandsSeparator) {
|
|
31
|
+
cleaned += '.';
|
|
32
|
+
seenDecimal = true;
|
|
33
|
+
}
|
|
26
34
|
}
|
|
27
35
|
if (cleaned.startsWith('.')) cleaned = `0${cleaned}`;
|
|
28
36
|
return (negative ? '-' : '') + cleaned;
|
|
@@ -294,7 +294,10 @@ function useNumberInput(opts) {
|
|
|
294
294
|
const el = inputRef.current;
|
|
295
295
|
if (!el) return;
|
|
296
296
|
const cursor_0 = el.selectionStart ?? 0;
|
|
297
|
-
if (cursor_0 > 0 && el.selectionEnd === cursor_0 && isThousandSepBeforeCursor(displayBuffer, cursor_0, thousandsSeparator))
|
|
297
|
+
if (cursor_0 > 0 && el.selectionEnd === cursor_0 && isThousandSepBeforeCursor(displayBuffer, cursor_0, thousandsSeparator)) {
|
|
298
|
+
const beforeSeparator = cursor_0 - thousandsSeparator.length;
|
|
299
|
+
el.setSelectionRange(beforeSeparator, beforeSeparator);
|
|
300
|
+
}
|
|
298
301
|
};
|
|
299
302
|
$[74] = displayBuffer;
|
|
300
303
|
$[75] = thousandsSeparator;
|