@rockshin/tao-ui 0.0.57 → 0.0.59
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 +38 -4
- package/dist/components/app/app-modals.js +11 -6
- package/dist/components/app/app-notices.js +112 -47
- package/dist/components/auto-complete/auto-complete.js +9 -2
- 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 +24 -17
- package/dist/components/carousel/carousel.js +35 -16
- package/dist/components/cascader/cascader.js +17 -12
- package/dist/components/checkbox/checkbox.d.ts +3 -1
- package/dist/components/checkbox/checkbox.js +65 -58
- package/dist/components/collapse/collapse-panels.js +68 -67
- package/dist/components/color-picker/color-picker.js +383 -360
- package/dist/components/date-picker/calendar/calendar-grid.d.ts +5 -3
- package/dist/components/date-picker/calendar/calendar-grid.js +9 -4
- package/dist/components/date-picker/calendar/month-grid.d.ts +2 -1
- package/dist/components/date-picker/calendar/month-grid.js +61 -45
- package/dist/components/date-picker/calendar/time-panel.d.ts +8 -1
- package/dist/components/date-picker/calendar/time-panel.js +89 -88
- package/dist/components/date-picker/calendar/year-grid.d.ts +2 -1
- package/dist/components/date-picker/calendar/year-grid.js +60 -44
- package/dist/components/date-picker/date-localization.js +12 -14
- package/dist/components/date-picker/date-picker.css +9 -0
- package/dist/components/date-picker/date-picker.js +22 -13
- package/dist/components/date-picker/range-picker.d.ts +2 -0
- package/dist/components/date-picker/range-picker.js +127 -70
- package/dist/components/date-picker/types.js +1 -1
- package/dist/components/divider/divider.js +1 -1
- package/dist/components/drawer/drawer.d.ts +1 -1
- package/dist/components/drawer/drawer.js +4 -3
- package/dist/components/dropdown/dropdown.js +11 -9
- package/dist/components/float-button/float-button.js +11 -9
- package/dist/components/form/form-item.d.ts +1 -1
- package/dist/components/form/form-item.js +160 -120
- package/dist/components/form-field/form-field-view.d.ts +2 -1
- package/dist/components/form-field/form-field-view.js +173 -108
- package/dist/components/image/image.js +135 -143
- package/dist/components/input/input-shared.js +3 -2
- package/dist/components/input/otp.js +120 -110
- package/dist/components/input/password.js +55 -61
- package/dist/components/input/search.js +13 -7
- package/dist/components/list/list.js +106 -105
- package/dist/components/masonry/masonry.js +1 -1
- package/dist/components/mentions/mentions.js +1 -0
- package/dist/components/menu/menu-render.js +1 -0
- package/dist/components/modal/confirm-dialog.js +11 -4
- package/dist/components/modal/modal.js +320 -315
- package/dist/components/pagination/pagination.d.ts +3 -0
- package/dist/components/pagination/pagination.js +5 -0
- package/dist/components/popover/popover.js +325 -289
- package/dist/components/qr-code/qr-code.js +157 -150
- package/dist/components/radio/radio.d.ts +3 -1
- package/dist/components/radio/radio.js +73 -64
- 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/mobile-select.js +6 -3
- package/dist/components/select/select-model.js +2 -2
- package/dist/components/select/select.js +78 -39
- package/dist/components/select/use-select-selection.d.ts +1 -1
- package/dist/components/select/use-select-selection.js +91 -84
- package/dist/components/slider/slider.d.ts +2 -2
- package/dist/components/slider/slider.js +13 -2
- package/dist/components/sonner/sonner.js +2 -2
- package/dist/components/splitter/splitter.css +1 -0
- package/dist/components/splitter/splitter.js +152 -126
- package/dist/components/statistic/statistic.js +84 -78
- package/dist/components/steps/steps.js +1 -1
- package/dist/components/switch/switch.js +45 -39
- package/dist/components/table/table.js +5 -1
- package/dist/components/table/use-table-data.js +2 -2
- package/dist/components/time-picker/time-picker.js +31 -1
- package/dist/components/tooltip/tooltip.js +237 -99
- package/dist/components/tree/tree.js +31 -3
- package/dist/components/tree-select/tree-select.js +1 -1
- package/dist/components/upload/upload.js +69 -42
- package/dist/locales/ar-EG.js +2 -0
- package/dist/locales/de-DE.js +2 -0
- package/dist/locales/en-US.js +2 -0
- package/dist/locales/es-ES.js +2 -0
- package/dist/locales/fr-FR.js +2 -0
- package/dist/locales/hi-IN.js +2 -0
- package/dist/locales/id-ID.js +2 -0
- package/dist/locales/it-IT.js +2 -0
- package/dist/locales/ja-JP.js +2 -0
- package/dist/locales/ko-KR.js +2 -0
- package/dist/locales/pt-BR.js +2 -0
- package/dist/locales/ru-RU.js +2 -0
- package/dist/locales/th-TH.js +2 -0
- package/dist/locales/tr-TR.js +2 -0
- package/dist/locales/types.d.ts +2 -0
- package/dist/locales/vi-VN.js +2 -0
- package/dist/locales/zh-CN.js +2 -0
- package/dist/locales/zh-TW.js +2 -0
- package/dist/number-input/cursor.js +20 -8
- package/dist/number-input/format.js +13 -5
- package/dist/number-input/use-number-input.js +166 -318
- package/dist/number-input/validate.d.ts +1 -0
- package/dist/number-input/validate.js +1 -1
- package/dist/provider/tao-provider.d.ts +2 -2
- package/dist/provider/tao-provider.js +49 -49
- package/dist/utils/composed-parent.d.ts +1 -0
- package/dist/utils/composed-parent.js +7 -0
- package/dist/utils/portal.d.ts +5 -0
- package/dist/utils/portal.js +7 -1
- package/dist/utils/refs.d.ts +3 -1
- package/dist/utils/refs.js +25 -1
- package/package.json +1 -1
|
@@ -37,7 +37,9 @@ function MobileSelectContentInner({ options, value, onChange, onMultiChange, sho
|
|
|
37
37
|
}, !!disabled);
|
|
38
38
|
const composingRef = useRef(false);
|
|
39
39
|
const createTag = ()=>{
|
|
40
|
-
|
|
40
|
+
const added = addTokens(search);
|
|
41
|
+
if (added) onSearchClear();
|
|
42
|
+
return added;
|
|
41
43
|
};
|
|
42
44
|
const knownOptions = useMemo(()=>flattenLeafOptions(options), [
|
|
43
45
|
options
|
|
@@ -187,10 +189,11 @@ function MobileSelectContentInner({ options, value, onChange, onMultiChange, sho
|
|
|
187
189
|
},
|
|
188
190
|
onKeyDown: (e_0)=>{
|
|
189
191
|
if (composingRef.current || e_0.nativeEvent.isComposing || 229 === e_0.keyCode) return;
|
|
190
|
-
if (multiple
|
|
192
|
+
if (!multiple) return;
|
|
193
|
+
if ('Enter' === e_0.key) {
|
|
191
194
|
e_0.preventDefault();
|
|
192
195
|
createTag();
|
|
193
|
-
}
|
|
196
|
+
} else if (tokenSeparators?.includes(e_0.key) && createTag()) e_0.preventDefault();
|
|
194
197
|
},
|
|
195
198
|
placeholder: locale.searchPlaceholder,
|
|
196
199
|
"aria-label": locale.searchOptions
|
|
@@ -28,8 +28,8 @@ function countLeafOptions(options) {
|
|
|
28
28
|
return count;
|
|
29
29
|
}
|
|
30
30
|
function defaultFilter(input, option) {
|
|
31
|
-
const
|
|
32
|
-
return
|
|
31
|
+
const text = 'string' == typeof option.label || 'number' == typeof option.label ? String(option.label) : option.value;
|
|
32
|
+
return text.toLowerCase().includes(input.toLowerCase());
|
|
33
33
|
}
|
|
34
34
|
function filterTree(options, filter, input) {
|
|
35
35
|
const result = [];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useCallback, useId, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { forwardRef, useCallback, useEffect, useId, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { TaoPortalScope, useTaoConfig, useTaoDirection } from "../../provider/tao-provider.js";
|
|
4
4
|
import { mergeRefs } from "../../utils/refs.js";
|
|
5
5
|
import { cx } from "../../utils/semantic.js";
|
|
@@ -57,6 +57,10 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
57
57
|
const searchListboxId = useId();
|
|
58
58
|
const isMultiple = 'multiple' === mode || 'tags' === mode;
|
|
59
59
|
const hasInlineSearch = !!showSearch && !isMobile;
|
|
60
|
+
const autoFocusTrigger = useRef(autoFocus && !hasInlineSearch && !resolvedDisabled);
|
|
61
|
+
useEffect(()=>{
|
|
62
|
+
if (autoFocusTrigger.current) triggerRef.current?.focus();
|
|
63
|
+
}, []);
|
|
60
64
|
useImperativeHandle(ref, ()=>({
|
|
61
65
|
focus: ()=>(hasInlineSearch ? inputRef.current : triggerRef.current)?.focus(),
|
|
62
66
|
blur: ()=>(hasInlineSearch ? inputRef.current : triggerRef.current)?.blur(),
|
|
@@ -70,14 +74,21 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
70
74
|
const isSearchControlled = void 0 !== searchValueProp;
|
|
71
75
|
const [searchInternal, setSearchInternal] = useState('');
|
|
72
76
|
const search = isSearchControlled ? searchValueProp : searchInternal;
|
|
77
|
+
const [activeSearch, setActiveSearch] = useState(()=>({
|
|
78
|
+
index: 0,
|
|
79
|
+
value: isMultiple ? void 0 : value
|
|
80
|
+
}));
|
|
73
81
|
const [previousOpen, setPreviousOpen] = useState(requestedOpen);
|
|
74
|
-
|
|
82
|
+
const [previousValue, setPreviousValue] = useState(value);
|
|
83
|
+
if (previousOpen !== requestedOpen || !isMultiple && previousValue !== value) {
|
|
84
|
+
if (previousOpen !== requestedOpen && !requestedOpen && !isSearchControlled) setSearchInternal('');
|
|
75
85
|
setPreviousOpen(requestedOpen);
|
|
76
|
-
|
|
86
|
+
setPreviousValue(value);
|
|
87
|
+
if (!requestedOpen && !isMultiple && value) setActiveSearch({
|
|
88
|
+
index: 0,
|
|
89
|
+
value: value
|
|
90
|
+
});
|
|
77
91
|
}
|
|
78
|
-
const [activeSearch, setActiveSearch] = useState({
|
|
79
|
-
index: 0
|
|
80
|
-
});
|
|
81
92
|
const composingRef = useRef(false);
|
|
82
93
|
const isComposingKey = useCallback((event)=>composingRef.current || event.isComposing || 229 === event.keyCode, []);
|
|
83
94
|
const handleEscapeKeyDown = useCallback((event_0)=>{
|
|
@@ -86,6 +97,7 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
86
97
|
isComposingKey
|
|
87
98
|
]);
|
|
88
99
|
const suppressCloseRef = useRef(false);
|
|
100
|
+
const repeatedOptionRef = useRef(void 0);
|
|
89
101
|
const handleValueChange = useCallback((next)=>{
|
|
90
102
|
if (resolvedDisabled) return;
|
|
91
103
|
if (isMultiple && !hasInlineSearch) suppressCloseRef.current = true;
|
|
@@ -101,6 +113,11 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
101
113
|
]);
|
|
102
114
|
const handleOpenChange = useCallback((next_0)=>{
|
|
103
115
|
if (next_0 && resolvedDisabled) return;
|
|
116
|
+
if (!next_0 && void 0 !== repeatedOptionRef.current) {
|
|
117
|
+
const selected = repeatedOptionRef.current;
|
|
118
|
+
repeatedOptionRef.current = void 0;
|
|
119
|
+
handleValueChange(selected);
|
|
120
|
+
}
|
|
104
121
|
if (isMultiple && !hasInlineSearch && !next_0 && suppressCloseRef.current) {
|
|
105
122
|
suppressCloseRef.current = false;
|
|
106
123
|
return;
|
|
@@ -113,6 +130,7 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
113
130
|
if (next_0 && showSearch && !isMobile) setTimeout(()=>inputRef.current?.focus(), 0);
|
|
114
131
|
onOpenChange?.(next_0);
|
|
115
132
|
}, [
|
|
133
|
+
handleValueChange,
|
|
116
134
|
isMultiple,
|
|
117
135
|
hasInlineSearch,
|
|
118
136
|
isOpenControlled,
|
|
@@ -132,10 +150,11 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
132
150
|
if (isComposingKey(e.nativeEvent)) return;
|
|
133
151
|
if (!isMultiple || !tokenSeparators || 0 === tokenSeparators.length) return;
|
|
134
152
|
const value_0 = e.target.value;
|
|
135
|
-
const
|
|
136
|
-
if (!
|
|
137
|
-
|
|
138
|
-
if (
|
|
153
|
+
const separatorKey = tokenSeparators.includes(e.key);
|
|
154
|
+
if (!separatorKey && ('Enter' !== e.key || !tokenSeparators.some((s)=>s && value_0.includes(s)))) return;
|
|
155
|
+
const added = addTokens(value_0);
|
|
156
|
+
if (added || !separatorKey) e.preventDefault();
|
|
157
|
+
if (added && !isSearchControlled) setSearchInternal('');
|
|
139
158
|
}, [
|
|
140
159
|
isMultiple,
|
|
141
160
|
tokenSeparators,
|
|
@@ -153,6 +172,7 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
153
172
|
e_1.stopPropagation();
|
|
154
173
|
e_1.preventDefault();
|
|
155
174
|
removeValue(removedValue);
|
|
175
|
+
if ('keydown' === e_1.type) (inputRef.current ?? triggerRef.current)?.focus();
|
|
156
176
|
}, [
|
|
157
177
|
removeValue
|
|
158
178
|
]);
|
|
@@ -289,6 +309,17 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
289
309
|
]
|
|
290
310
|
})
|
|
291
311
|
});
|
|
312
|
+
const hiddenInputs = name && (isMultiple ? valueArray.map((item)=>/*#__PURE__*/ jsx("input", {
|
|
313
|
+
type: "hidden",
|
|
314
|
+
name: name,
|
|
315
|
+
value: item,
|
|
316
|
+
disabled: resolvedDisabled
|
|
317
|
+
}, item)) : /*#__PURE__*/ jsx("input", {
|
|
318
|
+
type: "hidden",
|
|
319
|
+
name: name,
|
|
320
|
+
value: value ?? '',
|
|
321
|
+
disabled: resolvedDisabled
|
|
322
|
+
}));
|
|
292
323
|
if (isMobile) return /*#__PURE__*/ jsxs(Fragment, {
|
|
293
324
|
children: [
|
|
294
325
|
/*#__PURE__*/ jsxs("div", {
|
|
@@ -302,7 +333,6 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
302
333
|
"data-tao-variant": resolvedVariant,
|
|
303
334
|
"data-tao-disabled": resolvedDisabled || void 0,
|
|
304
335
|
...statusProps,
|
|
305
|
-
autoFocus: autoFocus,
|
|
306
336
|
role: "button",
|
|
307
337
|
tabIndex: resolvedDisabled ? void 0 : 0,
|
|
308
338
|
...ariaProps,
|
|
@@ -362,6 +392,7 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
362
392
|
trailingIcons
|
|
363
393
|
]
|
|
364
394
|
}),
|
|
395
|
+
hiddenInputs,
|
|
365
396
|
/*#__PURE__*/ jsx(MobileSelectDrawer, {
|
|
366
397
|
direction: direction,
|
|
367
398
|
mobileTitle: props.mobileTitle,
|
|
@@ -417,9 +448,21 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
417
448
|
const textLabel = 'string' == typeof opt.label ? opt.label : String(opt.label);
|
|
418
449
|
const isSelected = selectedValueSet.has(opt.value);
|
|
419
450
|
const itemDisabled = resolvedDisabled || opt.disabled || !isSelected && overMaxCount;
|
|
451
|
+
const markReselection = ()=>{
|
|
452
|
+
repeatedOptionRef.current = opt.value;
|
|
453
|
+
queueMicrotask(()=>{
|
|
454
|
+
repeatedOptionRef.current = void 0;
|
|
455
|
+
});
|
|
456
|
+
};
|
|
457
|
+
const reselectable = !isMultiple && isSelected && !itemDisabled;
|
|
420
458
|
return /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_select_4606f4d3.Item, {
|
|
421
459
|
value: opt.value,
|
|
422
460
|
disabled: itemDisabled,
|
|
461
|
+
onPointerUp: reselectable ? markReselection : void 0,
|
|
462
|
+
onClick: reselectable ? markReselection : void 0,
|
|
463
|
+
onKeyDown: reselectable ? (event_2)=>{
|
|
464
|
+
if ('Enter' === event_2.key || ' ' === event_2.key) markReselection();
|
|
465
|
+
} : void 0,
|
|
423
466
|
"data-tao-select-item": "",
|
|
424
467
|
"data-tao-label-wrap": optionLabelWrap || void 0,
|
|
425
468
|
"data-tao-has-desc": null != opt.description || void 0,
|
|
@@ -564,45 +607,45 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
564
607
|
onBlur: ()=>{
|
|
565
608
|
composingRef.current = false;
|
|
566
609
|
},
|
|
567
|
-
onClick: (
|
|
568
|
-
if (open)
|
|
610
|
+
onClick: (event_3)=>{
|
|
611
|
+
if (open) event_3.stopPropagation();
|
|
569
612
|
},
|
|
570
|
-
onChange: (
|
|
571
|
-
handleSearchChange(
|
|
613
|
+
onChange: (event_4)=>{
|
|
614
|
+
handleSearchChange(event_4.target.value);
|
|
572
615
|
setActiveSearch({
|
|
573
|
-
index: 0
|
|
616
|
+
index: 'tags' === mode ? -1 : 0
|
|
574
617
|
});
|
|
575
618
|
if (!open) handleOpenChange(true);
|
|
576
619
|
},
|
|
577
|
-
onKeyDown: (
|
|
578
|
-
|
|
579
|
-
if (isComposingKey(
|
|
580
|
-
handleSearchKeyDown(
|
|
581
|
-
if (
|
|
582
|
-
if ('Escape' ===
|
|
620
|
+
onKeyDown: (event_5)=>{
|
|
621
|
+
event_5.stopPropagation();
|
|
622
|
+
if (isComposingKey(event_5.nativeEvent)) return;
|
|
623
|
+
handleSearchKeyDown(event_5);
|
|
624
|
+
if (event_5.defaultPrevented) return;
|
|
625
|
+
if ('Escape' === event_5.key) {
|
|
583
626
|
handleSearchChange('');
|
|
584
627
|
handleOpenChange(false);
|
|
585
628
|
return;
|
|
586
629
|
}
|
|
587
|
-
if ('ArrowDown' ===
|
|
588
|
-
|
|
630
|
+
if ('ArrowDown' === event_5.key) {
|
|
631
|
+
event_5.preventDefault();
|
|
589
632
|
setActiveSearchIndex(Math.min(boundedSearchIndex + 1, lastSearchIndex));
|
|
590
633
|
if (!open) handleOpenChange(true);
|
|
591
634
|
return;
|
|
592
635
|
}
|
|
593
|
-
if ('ArrowUp' ===
|
|
594
|
-
|
|
636
|
+
if ('ArrowUp' === event_5.key) {
|
|
637
|
+
event_5.preventDefault();
|
|
595
638
|
setActiveSearchIndex(Math.max(boundedSearchIndex - 1, 0));
|
|
596
639
|
return;
|
|
597
640
|
}
|
|
598
|
-
if ('Enter' ===
|
|
599
|
-
|
|
641
|
+
if ('Enter' === event_5.key && !requestedOpen) {
|
|
642
|
+
event_5.preventDefault();
|
|
600
643
|
handleOpenChange(true);
|
|
601
644
|
return;
|
|
602
645
|
}
|
|
603
646
|
const nextValue = activeSearchOption?.value ?? ('tags' === mode ? search.trim() : void 0);
|
|
604
|
-
if ('Enter' ===
|
|
605
|
-
|
|
647
|
+
if ('Enter' === event_5.key && nextValue) {
|
|
648
|
+
event_5.preventDefault();
|
|
606
649
|
handleValueChange(nextValue);
|
|
607
650
|
if (!isMultiple) handleOpenChange(false);
|
|
608
651
|
}
|
|
@@ -682,12 +725,7 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
682
725
|
]
|
|
683
726
|
})
|
|
684
727
|
}),
|
|
685
|
-
|
|
686
|
-
type: "hidden",
|
|
687
|
-
name: name,
|
|
688
|
-
value: value ?? '',
|
|
689
|
-
disabled: resolvedDisabled
|
|
690
|
-
}),
|
|
728
|
+
hiddenInputs,
|
|
691
729
|
/*#__PURE__*/ jsx(__rspack_external__radix_ui_react_popover_c8444160.Portal, {
|
|
692
730
|
container: container,
|
|
693
731
|
children: /*#__PURE__*/ jsx(TaoPortalScope, {
|
|
@@ -703,9 +741,9 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
703
741
|
align: align,
|
|
704
742
|
sideOffset: 4,
|
|
705
743
|
onEscapeKeyDown: handleEscapeKeyDown,
|
|
706
|
-
onOpenAutoFocus: (
|
|
707
|
-
onCloseAutoFocus: (
|
|
708
|
-
|
|
744
|
+
onOpenAutoFocus: (event_6)=>event_6.preventDefault(),
|
|
745
|
+
onCloseAutoFocus: (event_7)=>{
|
|
746
|
+
event_7.preventDefault();
|
|
709
747
|
inputRef.current?.focus();
|
|
710
748
|
},
|
|
711
749
|
children: popupRender ? popupRender(searchableMenuNode) : searchableMenuNode
|
|
@@ -785,6 +823,7 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
785
823
|
]
|
|
786
824
|
})
|
|
787
825
|
}),
|
|
826
|
+
isMultiple && hiddenInputs,
|
|
788
827
|
/*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_4606f4d3.Portal, {
|
|
789
828
|
container: container,
|
|
790
829
|
children: /*#__PURE__*/ jsx(TaoPortalScope, {
|
|
@@ -10,7 +10,7 @@ export declare function useSelectSelection(props: SelectionProps, disabled: bool
|
|
|
10
10
|
select: (next: string) => boolean;
|
|
11
11
|
addTokens: (input: string) => boolean;
|
|
12
12
|
remove: (removed: string) => void;
|
|
13
|
-
commit: (
|
|
13
|
+
commit: (draft: string[]) => void;
|
|
14
14
|
clear: () => void;
|
|
15
15
|
};
|
|
16
16
|
export {};
|
|
@@ -2,7 +2,7 @@ import { c } from "react-compiler-runtime";
|
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { buildSelectIndex } from "./select-model.js";
|
|
4
4
|
function useSelectSelection(props, disabled) {
|
|
5
|
-
const $ = c(
|
|
5
|
+
const $ = c(76);
|
|
6
6
|
const { options, value: valueProp, defaultValue, mode, maxCount, tokenSeparators, onChange, onSelect, onDeselect, onClear } = props;
|
|
7
7
|
const multiple = "multiple" === mode || "tags" === mode;
|
|
8
8
|
const controlled = "value" in props;
|
|
@@ -69,12 +69,12 @@ function useSelectSelection(props, disabled) {
|
|
|
69
69
|
} else t4 = $[14];
|
|
70
70
|
const publish = t4;
|
|
71
71
|
let t5;
|
|
72
|
-
if ($[15] !== disabled || $[16] !== maxCount || $[17] !== multiple || $[18] !== onDeselect || $[19] !== onSelect || $[20] !== optionByValue || $[21] !== publish || $[22] !== selectedValueSet || $[23] !== valueArray) {
|
|
72
|
+
if ($[15] !== disabled || $[16] !== maxCount || $[17] !== multiple || $[18] !== onDeselect || $[19] !== onSelect || $[20] !== optionByValue || $[21] !== publish || $[22] !== selectedValueSet || $[23] !== value || $[24] !== valueArray) {
|
|
73
73
|
t5 = (next_0)=>{
|
|
74
74
|
if (disabled) return false;
|
|
75
75
|
const option_0 = optionByValue.get(next_0);
|
|
76
76
|
if (!multiple) {
|
|
77
|
-
publish(next_0);
|
|
77
|
+
if (next_0 !== value) publish(next_0);
|
|
78
78
|
if (option_0) onSelect?.(next_0, option_0);
|
|
79
79
|
return true;
|
|
80
80
|
}
|
|
@@ -97,12 +97,13 @@ function useSelectSelection(props, disabled) {
|
|
|
97
97
|
$[20] = optionByValue;
|
|
98
98
|
$[21] = publish;
|
|
99
99
|
$[22] = selectedValueSet;
|
|
100
|
-
$[23] =
|
|
101
|
-
$[24] =
|
|
102
|
-
|
|
100
|
+
$[23] = value;
|
|
101
|
+
$[24] = valueArray;
|
|
102
|
+
$[25] = t5;
|
|
103
|
+
} else t5 = $[25];
|
|
103
104
|
const select = t5;
|
|
104
105
|
let t6;
|
|
105
|
-
if ($[
|
|
106
|
+
if ($[26] !== disabled || $[27] !== maxCount || $[28] !== mode || $[29] !== onSelect || $[30] !== optionByToken || $[31] !== optionByValue || $[32] !== publish || $[33] !== selectedValueSet || $[34] !== tokenSeparators || $[35] !== valueArray) {
|
|
106
107
|
t6 = (input)=>{
|
|
107
108
|
if (disabled) return false;
|
|
108
109
|
const tokens = (tokenSeparators ?? []).reduce(_temp2, [
|
|
@@ -132,97 +133,106 @@ function useSelectSelection(props, disabled) {
|
|
|
132
133
|
}
|
|
133
134
|
return true;
|
|
134
135
|
};
|
|
135
|
-
$[
|
|
136
|
-
$[
|
|
137
|
-
$[
|
|
138
|
-
$[
|
|
139
|
-
$[
|
|
140
|
-
$[
|
|
141
|
-
$[
|
|
142
|
-
$[
|
|
143
|
-
$[
|
|
144
|
-
$[
|
|
145
|
-
$[
|
|
146
|
-
} else t6 = $[
|
|
136
|
+
$[26] = disabled;
|
|
137
|
+
$[27] = maxCount;
|
|
138
|
+
$[28] = mode;
|
|
139
|
+
$[29] = onSelect;
|
|
140
|
+
$[30] = optionByToken;
|
|
141
|
+
$[31] = optionByValue;
|
|
142
|
+
$[32] = publish;
|
|
143
|
+
$[33] = selectedValueSet;
|
|
144
|
+
$[34] = tokenSeparators;
|
|
145
|
+
$[35] = valueArray;
|
|
146
|
+
$[36] = t6;
|
|
147
|
+
} else t6 = $[36];
|
|
147
148
|
const addTokens = t6;
|
|
148
149
|
let t7;
|
|
149
|
-
if ($[
|
|
150
|
+
if ($[37] !== multiple || $[38] !== onDeselect || $[39] !== optionByValue || $[40] !== publish || $[41] !== valueArray) {
|
|
150
151
|
t7 = (removed)=>{
|
|
151
152
|
if (!multiple) return;
|
|
152
153
|
publish(valueArray.filter((item_1)=>item_1 !== removed));
|
|
153
154
|
const option_3 = optionByValue.get(removed);
|
|
154
155
|
if (option_3) onDeselect?.(removed, option_3);
|
|
155
156
|
};
|
|
156
|
-
$[
|
|
157
|
-
$[
|
|
158
|
-
$[
|
|
159
|
-
$[
|
|
160
|
-
$[
|
|
161
|
-
$[
|
|
162
|
-
} else t7 = $[
|
|
157
|
+
$[37] = multiple;
|
|
158
|
+
$[38] = onDeselect;
|
|
159
|
+
$[39] = optionByValue;
|
|
160
|
+
$[40] = publish;
|
|
161
|
+
$[41] = valueArray;
|
|
162
|
+
$[42] = t7;
|
|
163
|
+
} else t7 = $[42];
|
|
163
164
|
const remove = t7;
|
|
164
165
|
let t8;
|
|
165
|
-
if ($[
|
|
166
|
-
t8 = (
|
|
167
|
-
if (disabled
|
|
166
|
+
if ($[43] !== disabled || $[44] !== maxCount || $[45] !== mode || $[46] !== onDeselect || $[47] !== onSelect || $[48] !== optionByValue || $[49] !== publish || $[50] !== selectedValueSet || $[51] !== valueArray) {
|
|
167
|
+
t8 = (draft)=>{
|
|
168
|
+
if (disabled) return;
|
|
169
|
+
const nextArray_1 = draft.filter((item_2)=>{
|
|
170
|
+
if (selectedValueSet.has(item_2)) return true;
|
|
171
|
+
const option_4 = optionByValue.get(item_2);
|
|
172
|
+
return option_4 ? !option_4.disabled : "tags" === mode;
|
|
173
|
+
});
|
|
174
|
+
if (null != maxCount && nextArray_1.length > maxCount) return;
|
|
168
175
|
publish(nextArray_1);
|
|
169
176
|
const nextSet = new Set(nextArray_1);
|
|
170
177
|
for (const next_3 of nextArray_1)if (!selectedValueSet.has(next_3)) {
|
|
171
|
-
const
|
|
172
|
-
if (
|
|
178
|
+
const option_5 = optionByValue.get(next_3);
|
|
179
|
+
if (option_5) onSelect?.(next_3, option_5);
|
|
173
180
|
}
|
|
174
181
|
for (const previous of valueArray)if (!nextSet.has(previous)) {
|
|
175
|
-
const
|
|
176
|
-
if (
|
|
182
|
+
const option_6 = optionByValue.get(previous);
|
|
183
|
+
if (option_6) onDeselect?.(previous, option_6);
|
|
177
184
|
}
|
|
178
185
|
};
|
|
179
|
-
$[
|
|
180
|
-
$[
|
|
181
|
-
$[
|
|
182
|
-
$[
|
|
183
|
-
$[
|
|
184
|
-
$[
|
|
185
|
-
$[
|
|
186
|
-
$[
|
|
187
|
-
$[
|
|
188
|
-
|
|
186
|
+
$[43] = disabled;
|
|
187
|
+
$[44] = maxCount;
|
|
188
|
+
$[45] = mode;
|
|
189
|
+
$[46] = onDeselect;
|
|
190
|
+
$[47] = onSelect;
|
|
191
|
+
$[48] = optionByValue;
|
|
192
|
+
$[49] = publish;
|
|
193
|
+
$[50] = selectedValueSet;
|
|
194
|
+
$[51] = valueArray;
|
|
195
|
+
$[52] = t8;
|
|
196
|
+
} else t8 = $[52];
|
|
189
197
|
const commit = t8;
|
|
190
198
|
let t9;
|
|
191
|
-
if ($[
|
|
199
|
+
if ($[53] !== multiple || $[54] !== onClear || $[55] !== publish) {
|
|
192
200
|
t9 = ()=>{
|
|
193
201
|
publish(multiple ? [] : void 0, true);
|
|
194
202
|
onClear?.();
|
|
195
203
|
};
|
|
196
|
-
$[
|
|
197
|
-
$[
|
|
198
|
-
$[
|
|
199
|
-
$[
|
|
200
|
-
} else t9 = $[
|
|
204
|
+
$[53] = multiple;
|
|
205
|
+
$[54] = onClear;
|
|
206
|
+
$[55] = publish;
|
|
207
|
+
$[56] = t9;
|
|
208
|
+
} else t9 = $[56];
|
|
201
209
|
const clear_0 = t9;
|
|
202
210
|
let t10;
|
|
203
|
-
if ($[
|
|
204
|
-
t10 = !multiple && value ? optionByValue.get(value)
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
$[
|
|
209
|
-
|
|
211
|
+
if ($[57] !== multiple || $[58] !== optionByValue || $[59] !== value) {
|
|
212
|
+
t10 = !multiple && value ? optionByValue.get(value) ?? {
|
|
213
|
+
label: value,
|
|
214
|
+
value: value
|
|
215
|
+
} : void 0;
|
|
216
|
+
$[57] = multiple;
|
|
217
|
+
$[58] = optionByValue;
|
|
218
|
+
$[59] = value;
|
|
219
|
+
$[60] = t10;
|
|
220
|
+
} else t10 = $[60];
|
|
210
221
|
const selectedOption = t10;
|
|
211
222
|
let t11;
|
|
212
|
-
if ($[
|
|
213
|
-
t11 = multiple ? valueArray.map((
|
|
214
|
-
label:
|
|
215
|
-
value:
|
|
216
|
-
}
|
|
217
|
-
$[
|
|
218
|
-
$[
|
|
219
|
-
$[
|
|
220
|
-
$[
|
|
221
|
-
|
|
222
|
-
} else t11 = $[63];
|
|
223
|
+
if ($[61] !== multiple || $[62] !== optionByValue || $[63] !== valueArray) {
|
|
224
|
+
t11 = multiple ? valueArray.map((item_3)=>optionByValue.get(item_3) ?? {
|
|
225
|
+
label: item_3,
|
|
226
|
+
value: item_3
|
|
227
|
+
}) : [];
|
|
228
|
+
$[61] = multiple;
|
|
229
|
+
$[62] = optionByValue;
|
|
230
|
+
$[63] = valueArray;
|
|
231
|
+
$[64] = t11;
|
|
232
|
+
} else t11 = $[64];
|
|
223
233
|
const selectedOptions = t11;
|
|
224
234
|
let t12;
|
|
225
|
-
if ($[
|
|
235
|
+
if ($[65] !== addTokens || $[66] !== clear_0 || $[67] !== commit || $[68] !== remove || $[69] !== select || $[70] !== selectedOption || $[71] !== selectedOptions || $[72] !== selectedValueSet || $[73] !== value || $[74] !== valueArray) {
|
|
226
236
|
t12 = {
|
|
227
237
|
value,
|
|
228
238
|
valueArray,
|
|
@@ -235,23 +245,20 @@ function useSelectSelection(props, disabled) {
|
|
|
235
245
|
commit,
|
|
236
246
|
clear: clear_0
|
|
237
247
|
};
|
|
238
|
-
$[
|
|
239
|
-
$[
|
|
240
|
-
$[
|
|
241
|
-
$[
|
|
242
|
-
$[
|
|
243
|
-
$[
|
|
244
|
-
$[
|
|
245
|
-
$[
|
|
246
|
-
$[
|
|
247
|
-
$[
|
|
248
|
-
$[
|
|
249
|
-
} else t12 = $[
|
|
248
|
+
$[65] = addTokens;
|
|
249
|
+
$[66] = clear_0;
|
|
250
|
+
$[67] = commit;
|
|
251
|
+
$[68] = remove;
|
|
252
|
+
$[69] = select;
|
|
253
|
+
$[70] = selectedOption;
|
|
254
|
+
$[71] = selectedOptions;
|
|
255
|
+
$[72] = selectedValueSet;
|
|
256
|
+
$[73] = value;
|
|
257
|
+
$[74] = valueArray;
|
|
258
|
+
$[75] = t12;
|
|
259
|
+
} else t12 = $[75];
|
|
250
260
|
return t12;
|
|
251
261
|
}
|
|
252
|
-
function _temp4(option_6) {
|
|
253
|
-
return void 0 !== option_6;
|
|
254
|
-
}
|
|
255
262
|
function _temp3(token) {
|
|
256
263
|
return token.trim();
|
|
257
264
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type SliderProps as RcSliderProps, type SliderRef } from '@rc-component/slider';
|
|
2
|
-
import { type ReactNode } from 'react';
|
|
2
|
+
import { type AriaAttributes, type ReactNode } from 'react';
|
|
3
3
|
import { type SemanticClassNames, type SemanticStyles } from '../../utils/semantic.js';
|
|
4
4
|
import type { TooltipProps } from '../tooltip/tooltip.js';
|
|
5
5
|
import '../tooltip/tooltip.css';
|
|
@@ -15,7 +15,7 @@ export interface SliderTooltipProps extends Omit<TooltipProps, 'children' | 'tit
|
|
|
15
15
|
formatter?: Formatter;
|
|
16
16
|
autoAdjustOverflow?: boolean;
|
|
17
17
|
}
|
|
18
|
-
export interface SliderBaseProps extends Omit<RcSliderProps, 'value' | 'defaultValue' | 'onChange' | 'onAfterChange' | 'onChangeComplete' | 'range' | 'classNames' | 'styles'> {
|
|
18
|
+
export interface SliderBaseProps extends Omit<RcSliderProps, 'value' | 'defaultValue' | 'onChange' | 'onAfterChange' | 'onChangeComplete' | 'range' | 'classNames' | 'styles'>, Pick<AriaAttributes, 'aria-label' | 'aria-labelledby' | 'aria-describedby'> {
|
|
19
19
|
rootClassName?: string;
|
|
20
20
|
orientation?: 'horizontal' | 'vertical';
|
|
21
21
|
direction?: 'ltr' | 'rtl';
|
|
@@ -2,6 +2,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import slider from "@rc-component/slider";
|
|
3
3
|
import { cloneElement, forwardRef, useEffect, useRef, useState } from "react";
|
|
4
4
|
import { TaoPortalScope, useTaoConfig, useTaoDirection } from "../../provider/tao-provider.js";
|
|
5
|
+
import { useCommittedRef } from "../../utils/refs.js";
|
|
5
6
|
import { cx } from "../../utils/semantic.js";
|
|
6
7
|
import "../tooltip/tooltip.css";
|
|
7
8
|
import "./slider.css";
|
|
@@ -15,6 +16,7 @@ function SliderTip({ children, value, dragging, disabled, vertical, direction, o
|
|
|
15
16
|
const closeTimer = useRef(void 0);
|
|
16
17
|
useEffect(()=>()=>clearTimeout(closeTimer.current), []);
|
|
17
18
|
const { formatter, open, placement = vertical ? 'rtl' === direction ? 'left' : 'right' : 'top', getPopupContainer, autoAdjustOverflow = true, arrow = true, prefixCls, className, classNames, styles, style, color, mouseEnterDelay = 0.1, mouseLeaveDelay = 0.1, onOpenChange, defaultOpen } = options;
|
|
19
|
+
const latestOpenChange = useCommittedRef(onOpenChange);
|
|
18
20
|
const title = null === formatter ? null : formatter ? formatter(value) : String(value);
|
|
19
21
|
const side = placement.startsWith('top') ? 'top' : placement.startsWith('bottom') ? 'bottom' : placement.startsWith('left') ? 'left' : 'right';
|
|
20
22
|
const align = placement.endsWith('Left') || placement.endsWith('Top') ? 'start' : placement.endsWith('Right') || placement.endsWith('Bottom') ? 'end' : 'center';
|
|
@@ -28,7 +30,7 @@ function SliderTip({ children, value, dragging, disabled, vertical, direction, o
|
|
|
28
30
|
clearTimeout(closeTimer.current);
|
|
29
31
|
const update = ()=>{
|
|
30
32
|
setActive(next);
|
|
31
|
-
|
|
33
|
+
latestOpenChange.current?.(next);
|
|
32
34
|
};
|
|
33
35
|
if (!next && pointerDriven.current && mouseLeaveDelay > 0) closeTimer.current = setTimeout(update, 1000 * mouseLeaveDelay);
|
|
34
36
|
else update();
|
|
@@ -57,6 +59,12 @@ function SliderTip({ children, value, dragging, disabled, vertical, direction, o
|
|
|
57
59
|
sideOffset: 8,
|
|
58
60
|
avoidCollisions: autoAdjustOverflow,
|
|
59
61
|
updatePositionStrategy: "always",
|
|
62
|
+
onEscapeKeyDown: ()=>{
|
|
63
|
+
pointerDriven.current = false;
|
|
64
|
+
},
|
|
65
|
+
onPointerDownOutside: ()=>{
|
|
66
|
+
pointerDriven.current = false;
|
|
67
|
+
},
|
|
60
68
|
className: cx(prefixCls, classNames?.content, className),
|
|
61
69
|
style: {
|
|
62
70
|
...color ? {
|
|
@@ -92,7 +100,7 @@ const withValueSnapshot = (callback)=>callback ? (value)=>callback(Array.isArray
|
|
|
92
100
|
...value
|
|
93
101
|
] : value) : void 0;
|
|
94
102
|
const Slider = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
95
|
-
const { prefixCls = 'tao-slider', classNames, styles, rootClassName, className, style, orientation, vertical = false, direction: directionProp, disabled, keyboard, tooltip = {}, handleRender, reverse, ...rest } = props;
|
|
103
|
+
const { prefixCls = 'tao-slider', classNames, styles, rootClassName, className, style, orientation, vertical = false, direction: directionProp, disabled, keyboard, tooltip = {}, handleRender, reverse, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, 'aria-describedby': ariaDescribedBy, ...rest } = props;
|
|
96
104
|
const [direction, directionRef] = useTaoDirection(directionProp);
|
|
97
105
|
const config = useTaoConfig();
|
|
98
106
|
const resolvedDisabled = disabled ?? config.disabled;
|
|
@@ -125,6 +133,9 @@ const Slider = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
125
133
|
...engineProps,
|
|
126
134
|
ref: ref,
|
|
127
135
|
prefixCls: prefixCls,
|
|
136
|
+
ariaLabelForHandle: engineProps.ariaLabelForHandle ?? ariaLabel,
|
|
137
|
+
ariaLabelledByForHandle: engineProps.ariaLabelledByForHandle ?? ariaLabelledBy,
|
|
138
|
+
ariaDescribedByForHandle: engineProps.ariaDescribedByForHandle ?? ariaDescribedBy,
|
|
128
139
|
disabled: resolvedDisabled,
|
|
129
140
|
keyboard: keyboard,
|
|
130
141
|
onBeforeChange: withValueSnapshot(engineProps.onBeforeChange),
|
|
@@ -92,8 +92,8 @@ function create(type, options, custom) {
|
|
|
92
92
|
phase: 'active'
|
|
93
93
|
};
|
|
94
94
|
state = {
|
|
95
|
-
toasts: [
|
|
96
|
-
...state.toasts
|
|
95
|
+
toasts: state.toasts.some((toast)=>toast.id === id) ? state.toasts.map((toast)=>toast.id === id ? next : toast) : [
|
|
96
|
+
...state.toasts,
|
|
97
97
|
next
|
|
98
98
|
]
|
|
99
99
|
};
|