@rockshin/tao-ui 0.0.47 → 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/form.css +3 -2
- 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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { forwardRef, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { useTaoConfig, useTaoDirection } from "../../provider/tao-provider.js";
|
|
4
4
|
import { cx } from "../../utils/semantic.js";
|
|
5
5
|
import { Tooltip } from "../tooltip/tooltip.js";
|
|
@@ -15,8 +15,13 @@ function SegmentedInner(props, ref) {
|
|
|
15
15
|
}), [
|
|
16
16
|
options
|
|
17
17
|
]);
|
|
18
|
-
const
|
|
19
|
-
const
|
|
18
|
+
const firstEnabledValue = resolved.find((option_0)=>!option_0.disabled)?.value;
|
|
19
|
+
const initialValue = resolved.some((option_1)=>option_1.value === defaultValue && !option_1.disabled) ? defaultValue : firstEnabledValue;
|
|
20
|
+
const [internal, setInternal] = useState(initialValue);
|
|
21
|
+
const controlled = 'value' in props;
|
|
22
|
+
const internalAvailable = resolved.some((option_2)=>option_2.value === internal && !option_2.disabled);
|
|
23
|
+
if (!controlled && !internalAvailable && internal !== initialValue) setInternal(initialValue);
|
|
24
|
+
const selected = controlled ? value : internalAvailable ? internal : initialValue;
|
|
20
25
|
const axis = orientation ?? (vertical ? 'vertical' : 'horizontal');
|
|
21
26
|
const merged = {
|
|
22
27
|
...props,
|
|
@@ -38,14 +43,40 @@ function SegmentedInner(props, ref) {
|
|
|
38
43
|
directionRef
|
|
39
44
|
]);
|
|
40
45
|
useImperativeHandle(ref, ()=>root.current);
|
|
41
|
-
const
|
|
46
|
+
const resetValue = controlled ? selected : initialValue;
|
|
42
47
|
useLayoutEffect(()=>{
|
|
43
48
|
const container = root.current;
|
|
44
|
-
|
|
45
|
-
const
|
|
49
|
+
if (!container?.closest('form')) return;
|
|
50
|
+
const radios = container.querySelectorAll(':scope > [data-tao-segmented-item] > input');
|
|
51
|
+
resolved.forEach((option_3, index)=>{
|
|
52
|
+
radios[index].defaultChecked = option_3.value === resetValue;
|
|
53
|
+
});
|
|
54
|
+
}, [
|
|
55
|
+
resetValue,
|
|
56
|
+
resolved
|
|
57
|
+
]);
|
|
58
|
+
useEffect(()=>{
|
|
59
|
+
if (controlled) return;
|
|
60
|
+
const form = root.current?.closest('form');
|
|
61
|
+
const reset = (event)=>{
|
|
62
|
+
queueMicrotask(()=>{
|
|
63
|
+
if (!event.defaultPrevented) setInternal(initialValue);
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
form?.addEventListener('reset', reset);
|
|
67
|
+
return ()=>form?.removeEventListener('reset', reset);
|
|
68
|
+
}, [
|
|
69
|
+
controlled,
|
|
70
|
+
initialValue
|
|
71
|
+
]);
|
|
72
|
+
const [thumb, setThumb] = useState(null);
|
|
73
|
+
useLayoutEffect(()=>{
|
|
74
|
+
const container_0 = root.current;
|
|
75
|
+
const items = container_0.querySelectorAll('[data-tao-segmented-item]');
|
|
76
|
+
const item = items[resolved.findIndex((option_4)=>option_4.value === selected)];
|
|
46
77
|
if (!item) return void setThumb(null);
|
|
47
78
|
const measure = ()=>{
|
|
48
|
-
const bounds =
|
|
79
|
+
const bounds = container_0.getBoundingClientRect();
|
|
49
80
|
const target = item.getBoundingClientRect();
|
|
50
81
|
const next = {
|
|
51
82
|
x: target.left - bounds.left,
|
|
@@ -60,10 +91,10 @@ function SegmentedInner(props, ref) {
|
|
|
60
91
|
};
|
|
61
92
|
measure();
|
|
62
93
|
const observer = new ResizeObserver(measure);
|
|
63
|
-
observer.observe(
|
|
94
|
+
observer.observe(container_0);
|
|
64
95
|
for (const element of items)observer.observe(element);
|
|
65
96
|
const attributes = new MutationObserver(measure);
|
|
66
|
-
attributes.observe(
|
|
97
|
+
attributes.observe(container_0, {
|
|
67
98
|
attributes: true,
|
|
68
99
|
attributeFilter: [
|
|
69
100
|
'dir',
|
|
@@ -81,7 +112,7 @@ function SegmentedInner(props, ref) {
|
|
|
81
112
|
]);
|
|
82
113
|
function select(next_0) {
|
|
83
114
|
if (next_0 === selected) return;
|
|
84
|
-
if (
|
|
115
|
+
if (!controlled) setInternal(next_0);
|
|
85
116
|
onChange?.(next_0);
|
|
86
117
|
}
|
|
87
118
|
return /*#__PURE__*/ jsxs("div", {
|
|
@@ -102,26 +133,27 @@ function SegmentedInner(props, ref) {
|
|
|
102
133
|
...slots?.root,
|
|
103
134
|
...style
|
|
104
135
|
},
|
|
105
|
-
onKeyDown: (
|
|
106
|
-
onKeyDown?.(
|
|
107
|
-
if (
|
|
108
|
-
const target_0 =
|
|
136
|
+
onKeyDown: (event_0)=>{
|
|
137
|
+
onKeyDown?.(event_0);
|
|
138
|
+
if (event_0.defaultPrevented || disabled) return;
|
|
139
|
+
const target_0 = event_0.target;
|
|
109
140
|
if ('radio' !== target_0.type) return;
|
|
110
|
-
const
|
|
111
|
-
const
|
|
112
|
-
|
|
141
|
+
const radios_0 = Array.from(event_0.currentTarget.querySelectorAll('input[type="radio"]:not(:disabled)'));
|
|
142
|
+
const index_0 = radios_0.indexOf(target_0);
|
|
143
|
+
if (index_0 < 0) return;
|
|
144
|
+
const rtl = 'rtl' === getComputedStyle(event_0.currentTarget).direction;
|
|
113
145
|
const previous_0 = 'vertical' === axis ? 'ArrowUp' : rtl ? 'ArrowRight' : 'ArrowLeft';
|
|
114
146
|
const next_1 = 'vertical' === axis ? 'ArrowDown' : rtl ? 'ArrowLeft' : 'ArrowRight';
|
|
115
147
|
let nextIndex;
|
|
116
|
-
if (
|
|
117
|
-
else if (
|
|
118
|
-
else if ('Home' ===
|
|
148
|
+
if (event_0.key === previous_0) nextIndex = (index_0 - 1 + radios_0.length) % radios_0.length;
|
|
149
|
+
else if (event_0.key === next_1) nextIndex = (index_0 + 1) % radios_0.length;
|
|
150
|
+
else if ('Home' === event_0.key) nextIndex = 0;
|
|
119
151
|
else {
|
|
120
|
-
if ('End' !==
|
|
121
|
-
nextIndex =
|
|
152
|
+
if ('End' !== event_0.key) return;
|
|
153
|
+
nextIndex = radios_0.length - 1;
|
|
122
154
|
}
|
|
123
|
-
|
|
124
|
-
const radio =
|
|
155
|
+
event_0.preventDefault();
|
|
156
|
+
const radio = radios_0[nextIndex];
|
|
125
157
|
if (radio) {
|
|
126
158
|
radio.focus();
|
|
127
159
|
radio.click();
|
|
@@ -142,46 +174,46 @@ function SegmentedInner(props, ref) {
|
|
|
142
174
|
moving: false
|
|
143
175
|
} : previous_1)
|
|
144
176
|
}),
|
|
145
|
-
resolved.map((
|
|
146
|
-
const isDisabled = disabled ||
|
|
147
|
-
const key = `${typeof
|
|
177
|
+
resolved.map((option_5)=>{
|
|
178
|
+
const isDisabled = disabled || option_5.disabled;
|
|
179
|
+
const key = `${typeof option_5.value}:${String(option_5.value)}`;
|
|
148
180
|
const item_0 = /*#__PURE__*/ jsxs("label", {
|
|
149
181
|
"data-tao-segmented-item": "",
|
|
150
|
-
"data-tao-checked":
|
|
182
|
+
"data-tao-checked": option_5.value === selected || void 0,
|
|
151
183
|
"data-tao-disabled": isDisabled || void 0,
|
|
152
|
-
className: cx(classes?.item,
|
|
184
|
+
className: cx(classes?.item, option_5.className),
|
|
153
185
|
style: slots?.item,
|
|
154
|
-
title:
|
|
186
|
+
title: option_5.title ?? ('string' == typeof option_5.label || 'number' == typeof option_5.label ? String(option_5.label) : void 0),
|
|
155
187
|
children: [
|
|
156
188
|
/*#__PURE__*/ jsx("input", {
|
|
157
189
|
type: "radio",
|
|
158
190
|
name: name,
|
|
159
|
-
value: String(
|
|
160
|
-
checked:
|
|
191
|
+
value: String(option_5.value),
|
|
192
|
+
checked: option_5.value === selected,
|
|
161
193
|
disabled: isDisabled,
|
|
162
|
-
onChange: ()=>select(
|
|
163
|
-
"aria-label":
|
|
194
|
+
onChange: ()=>select(option_5.value),
|
|
195
|
+
"aria-label": null == option_5.label || '' === option_5.label || 'boolean' == typeof option_5.label ? String(option_5.value) : void 0
|
|
164
196
|
}),
|
|
165
197
|
/*#__PURE__*/ jsxs("span", {
|
|
166
198
|
"data-tao-segmented-label": "",
|
|
167
199
|
className: classes?.label,
|
|
168
200
|
style: slots?.label,
|
|
169
201
|
children: [
|
|
170
|
-
void 0 !==
|
|
202
|
+
void 0 !== option_5.icon && /*#__PURE__*/ jsx("span", {
|
|
171
203
|
"data-tao-segmented-icon": "",
|
|
172
204
|
className: classes?.icon,
|
|
173
205
|
style: slots?.icon,
|
|
174
|
-
children:
|
|
206
|
+
children: option_5.icon
|
|
175
207
|
}),
|
|
176
|
-
|
|
208
|
+
option_5.label
|
|
177
209
|
]
|
|
178
210
|
})
|
|
179
211
|
]
|
|
180
212
|
}, key);
|
|
181
|
-
return
|
|
182
|
-
...'string' == typeof
|
|
183
|
-
title:
|
|
184
|
-
} :
|
|
213
|
+
return option_5.tooltip ? /*#__PURE__*/ jsx(Tooltip, {
|
|
214
|
+
...'string' == typeof option_5.tooltip ? {
|
|
215
|
+
title: option_5.tooltip
|
|
216
|
+
} : option_5.tooltip,
|
|
185
217
|
children: item_0
|
|
186
218
|
}, key) : item_0;
|
|
187
219
|
})
|
|
@@ -20,12 +20,13 @@ interface MobileSelectContentProps extends Pick<SelectProps, 'classNames' | 'sty
|
|
|
20
20
|
onClose: () => void;
|
|
21
21
|
/** Enable multi-select checkboxes + Done button flow. */
|
|
22
22
|
multiple?: boolean;
|
|
23
|
+
hideSelected?: boolean;
|
|
23
24
|
maxCount?: number;
|
|
24
25
|
mode?: 'multiple' | 'tags';
|
|
25
26
|
tokenSeparators?: string[];
|
|
26
27
|
onSearchClear: () => void;
|
|
27
28
|
}
|
|
28
|
-
declare function MobileSelectContentInner({ options, value, onChange, onMultiChange, showSearch, searchValue: search, onSearch, filterOption, notFoundContent: notFoundContentProp, optionRender, onClose, multiple, maxCount, mode, tokenSeparators, onSearchClear, disabled, classNames, styles, }: MobileSelectContentProps): import("react").JSX.Element;
|
|
29
|
+
declare function MobileSelectContentInner({ options, value, onChange, onMultiChange, showSearch, searchValue: search, onSearch, filterOption, notFoundContent: notFoundContentProp, optionRender, onClose, multiple, hideSelected, maxCount, mode, tokenSeparators, onSearchClear, disabled, classNames, styles, }: MobileSelectContentProps): import("react").JSX.Element;
|
|
29
30
|
export { MobileSelectContentInner as MobileSelectContent };
|
|
30
31
|
export interface MobileSelectDrawerProps extends MobileSelectContentProps {
|
|
31
32
|
direction?: 'ltr' | 'rtl';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
|
-
import { useCallback, useMemo, useRef } from "react";
|
|
3
|
+
import { useCallback, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { useTaoConfig } from "../../provider/tao-provider.js";
|
|
5
5
|
import { useMobileTitle } from "../../utils/field-label.js";
|
|
6
6
|
import { Button } from "../button/button.js";
|
|
@@ -9,7 +9,7 @@ import { SearchIcon } from "./select-icons.js";
|
|
|
9
9
|
import { countLeafOptions, defaultFilter, filterTree, flattenLeafOptions } from "./select-model.js";
|
|
10
10
|
import { useSelectSelection } from "./use-select-selection.js";
|
|
11
11
|
import "./mobile-select.css";
|
|
12
|
-
function MobileSelectContentInner({ options, value, onChange, onMultiChange, showSearch, searchValue: search, onSearch, filterOption, notFoundContent: notFoundContentProp, optionRender, onClose, multiple, maxCount, mode, tokenSeparators, onSearchClear, disabled, classNames, styles }) {
|
|
12
|
+
function MobileSelectContentInner({ options, value, onChange, onMultiChange, showSearch, searchValue: search, onSearch, filterOption, notFoundContent: notFoundContentProp, optionRender, onClose, multiple, hideSelected, maxCount, mode, tokenSeparators, onSearchClear, disabled, classNames, styles }) {
|
|
13
13
|
const { locale } = useTaoConfig();
|
|
14
14
|
const notFoundContent = void 0 === notFoundContentProp ? locale.noResults : notFoundContentProp;
|
|
15
15
|
const valueArray = useMemo(()=>{
|
|
@@ -21,17 +21,23 @@ function MobileSelectContentInner({ options, value, onChange, onMultiChange, sho
|
|
|
21
21
|
multiple,
|
|
22
22
|
value
|
|
23
23
|
]);
|
|
24
|
-
const
|
|
24
|
+
const [draft, setDraft] = useState(valueArray);
|
|
25
|
+
const [previousValue, setPreviousValue] = useState(valueArray);
|
|
26
|
+
if (previousValue.length !== valueArray.length || previousValue.some((item, index)=>item !== valueArray[index])) {
|
|
27
|
+
setPreviousValue(valueArray);
|
|
28
|
+
setDraft(valueArray);
|
|
29
|
+
}
|
|
30
|
+
const { selectedValueSet: draftSet, selectedOptions, select, addTokens } = useSelectSelection({
|
|
25
31
|
options,
|
|
26
|
-
|
|
32
|
+
value: draft,
|
|
33
|
+
onChange: (next)=>setDraft(next),
|
|
27
34
|
mode,
|
|
28
35
|
maxCount,
|
|
29
36
|
tokenSeparators
|
|
30
37
|
}, !!disabled);
|
|
31
38
|
const composingRef = useRef(false);
|
|
32
39
|
const createTag = ()=>{
|
|
33
|
-
addTokens(search);
|
|
34
|
-
onSearchClear();
|
|
40
|
+
if (addTokens(search)) onSearchClear();
|
|
35
41
|
};
|
|
36
42
|
const knownOptions = useMemo(()=>flattenLeafOptions(options), [
|
|
37
43
|
options
|
|
@@ -42,14 +48,19 @@ function MobileSelectContentInner({ options, value, onChange, onMultiChange, sho
|
|
|
42
48
|
...options,
|
|
43
49
|
...selectedOptions.filter((option_0)=>!knownValues.has(option_0.value))
|
|
44
50
|
] : options;
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
51
|
+
const committed = hideSelected && multiple && valueArray.length ? new Set(valueArray) : void 0;
|
|
52
|
+
const searching = showSearch && !!search;
|
|
53
|
+
if (!committed && !searching) return available;
|
|
54
|
+
const filter = filterOption ?? defaultFilter;
|
|
55
|
+
return filterTree(available, (query, option_1)=>!committed?.has(option_1.value) && (!searching || filter(query, option_1)), search);
|
|
48
56
|
}, [
|
|
49
57
|
options,
|
|
50
58
|
knownOptions,
|
|
51
59
|
selectedOptions,
|
|
52
60
|
mode,
|
|
61
|
+
multiple,
|
|
62
|
+
hideSelected,
|
|
63
|
+
valueArray,
|
|
53
64
|
search,
|
|
54
65
|
showSearch,
|
|
55
66
|
filterOption
|
|
@@ -85,7 +96,7 @@ function MobileSelectContentInner({ options, value, onChange, onMultiChange, sho
|
|
|
85
96
|
]);
|
|
86
97
|
let optIndex = 0;
|
|
87
98
|
const renderItem = (opt)=>{
|
|
88
|
-
const
|
|
99
|
+
const index_0 = optIndex++;
|
|
89
100
|
const isSelected = multiple ? draftSet.has(opt.value) : opt.value === value;
|
|
90
101
|
const itemDisabled = disabled || opt.disabled || multiple && null != maxCount && draft.length >= maxCount && !isSelected;
|
|
91
102
|
return /*#__PURE__*/ jsxs("button", {
|
|
@@ -103,7 +114,7 @@ function MobileSelectContentInner({ options, value, onChange, onMultiChange, sho
|
|
|
103
114
|
"data-tao-has-desc": null != opt.description || void 0,
|
|
104
115
|
children: [
|
|
105
116
|
optionRender ? optionRender(opt, {
|
|
106
|
-
index
|
|
117
|
+
index: index_0
|
|
107
118
|
}) : /*#__PURE__*/ jsxs(Fragment, {
|
|
108
119
|
children: [
|
|
109
120
|
null != opt.icon && /*#__PURE__*/ jsx("span", {
|
|
@@ -149,7 +160,7 @@ function MobileSelectContentInner({ options, value, onChange, onMultiChange, sho
|
|
|
149
160
|
style: styles?.groupLabel,
|
|
150
161
|
children: o.label
|
|
151
162
|
}),
|
|
152
|
-
o.options
|
|
163
|
+
renderTree(o.options)
|
|
153
164
|
]
|
|
154
165
|
}, o.value) : renderItem(o));
|
|
155
166
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
@@ -188,7 +199,7 @@ function MobileSelectContentInner({ options, value, onChange, onMultiChange, sho
|
|
|
188
199
|
/*#__PURE__*/ jsxs("div", {
|
|
189
200
|
"data-tao-sheet-list": "",
|
|
190
201
|
children: [
|
|
191
|
-
'tags' === mode && search.trim() && !draftSet.has(search.trim()) && !knownOptions.some((
|
|
202
|
+
'tags' === mode && search.trim() && !draftSet.has(search.trim()) && !knownOptions.some((option_2)=>option_2.value === search.trim() || option_2.label === search.trim()) && /*#__PURE__*/ jsx("button", {
|
|
192
203
|
type: "button",
|
|
193
204
|
"data-tao-sheet-item": "",
|
|
194
205
|
className: classNames?.item,
|
|
@@ -8,6 +8,7 @@ interface SearchableSelectListProps {
|
|
|
8
8
|
activeValue?: string;
|
|
9
9
|
selectedValues: string[];
|
|
10
10
|
multiple: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
11
12
|
maxCountReached: boolean;
|
|
12
13
|
listHeight: number;
|
|
13
14
|
notFoundContent: ReactNode;
|
|
@@ -18,5 +19,5 @@ interface SearchableSelectListProps {
|
|
|
18
19
|
onValueChange: (value: string) => void;
|
|
19
20
|
onClose: () => void;
|
|
20
21
|
}
|
|
21
|
-
export declare function SearchableSelectList({ id, options, resultCount, searchableOptions, activeValue, selectedValues, multiple, maxCountReached, listHeight, notFoundContent, optionRender, classNames, styles, onActiveIndexChange, onValueChange, onClose, }: SearchableSelectListProps): import("react").JSX.Element;
|
|
22
|
+
export declare function SearchableSelectList({ id, options, resultCount, searchableOptions, activeValue, selectedValues, multiple, disabled, maxCountReached, listHeight, notFoundContent, optionRender, classNames, styles, onActiveIndexChange, onValueChange, onClose, }: SearchableSelectListProps): import("react").JSX.Element;
|
|
22
23
|
export {};
|
|
@@ -2,7 +2,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useMemo } from "react";
|
|
3
3
|
import { cx } from "../../utils/semantic.js";
|
|
4
4
|
import { CheckIcon } from "./select-icons.js";
|
|
5
|
-
function SearchableSelectList({ id, options, resultCount, searchableOptions, activeValue, selectedValues, multiple, maxCountReached, listHeight, notFoundContent, optionRender, classNames, styles, onActiveIndexChange, onValueChange, onClose }) {
|
|
5
|
+
function SearchableSelectList({ id, options, resultCount, searchableOptions, activeValue, selectedValues, multiple, disabled, maxCountReached, listHeight, notFoundContent, optionRender, classNames, styles, onActiveIndexChange, onValueChange, onClose }) {
|
|
6
6
|
const indexByValue = useMemo(()=>{
|
|
7
7
|
const index = new Map();
|
|
8
8
|
searchableOptions.forEach((option, position)=>{
|
|
@@ -21,7 +21,7 @@ function SearchableSelectList({ id, options, resultCount, searchableOptions, act
|
|
|
21
21
|
const renderIndex = itemIndex++;
|
|
22
22
|
const optionIndex = indexByValue.get(option_0.value);
|
|
23
23
|
const isSelected = selectedValueSet.has(option_0.value);
|
|
24
|
-
const isDisabled =
|
|
24
|
+
const isDisabled = disabled || option_0.disabled || maxCountReached && !isSelected;
|
|
25
25
|
return /*#__PURE__*/ jsxs("button", {
|
|
26
26
|
id: `${id}-option-${encodeURIComponent(option_0.value)}`,
|
|
27
27
|
type: "button",
|
|
@@ -82,7 +82,6 @@ function SearchableSelectList({ id, options, resultCount, searchableOptions, act
|
|
|
82
82
|
}, option_0.value);
|
|
83
83
|
};
|
|
84
84
|
const renderTree = (items)=>items.map((option_1)=>option_1.options ? /*#__PURE__*/ jsxs("fieldset", {
|
|
85
|
-
"aria-label": String(option_1.label),
|
|
86
85
|
"data-tao-select-group": "",
|
|
87
86
|
className: cx(classNames?.group),
|
|
88
87
|
style: styles?.group,
|
|
@@ -43,6 +43,8 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
43
43
|
const isOpenControlled = void 0 !== openProp;
|
|
44
44
|
const [openInternal, setOpenInternal] = useState(defaultOpen ?? false);
|
|
45
45
|
const requestedOpen = isOpenControlled ? openProp : openInternal;
|
|
46
|
+
const latestRequestedOpen = useRef(requestedOpen);
|
|
47
|
+
latestRequestedOpen.current = requestedOpen;
|
|
46
48
|
const [mobilePresentation, setMobilePresentation] = useState(requestedMobile);
|
|
47
49
|
if ((!requestedOpen || void 0 === mobilePresentation) && mobilePresentation !== requestedMobile) setMobilePresentation(requestedMobile);
|
|
48
50
|
const isMobile = (requestedOpen ? mobilePresentation : requestedMobile) ?? false;
|
|
@@ -68,7 +70,14 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
68
70
|
const isSearchControlled = void 0 !== searchValueProp;
|
|
69
71
|
const [searchInternal, setSearchInternal] = useState('');
|
|
70
72
|
const search = isSearchControlled ? searchValueProp : searchInternal;
|
|
71
|
-
const [
|
|
73
|
+
const [previousOpen, setPreviousOpen] = useState(requestedOpen);
|
|
74
|
+
if (previousOpen !== requestedOpen) {
|
|
75
|
+
setPreviousOpen(requestedOpen);
|
|
76
|
+
if (!requestedOpen && !isSearchControlled) setSearchInternal('');
|
|
77
|
+
}
|
|
78
|
+
const [activeSearch, setActiveSearch] = useState({
|
|
79
|
+
index: 0
|
|
80
|
+
});
|
|
72
81
|
const composingRef = useRef(false);
|
|
73
82
|
const isComposingKey = useCallback((event)=>composingRef.current || event.isComposing || 229 === event.keyCode, []);
|
|
74
83
|
const handleEscapeKeyDown = useCallback((event_0)=>{
|
|
@@ -79,19 +88,14 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
79
88
|
const suppressCloseRef = useRef(false);
|
|
80
89
|
const handleValueChange = useCallback((next)=>{
|
|
81
90
|
if (resolvedDisabled) return;
|
|
82
|
-
if (isMultiple)
|
|
83
|
-
if (tokenSeparators?.some((separator)=>separator && next.includes(separator))) return void addTokens(next);
|
|
84
|
-
if (!hasInlineSearch) suppressCloseRef.current = true;
|
|
85
|
-
}
|
|
91
|
+
if (isMultiple && !hasInlineSearch) suppressCloseRef.current = true;
|
|
86
92
|
if (!selectValue(next)) return;
|
|
87
93
|
if (isMultiple && autoClearSearchValue && !isSearchControlled) setSearchInternal('');
|
|
88
94
|
}, [
|
|
89
95
|
isMultiple,
|
|
90
96
|
hasInlineSearch,
|
|
91
|
-
tokenSeparators,
|
|
92
97
|
resolvedDisabled,
|
|
93
98
|
selectValue,
|
|
94
|
-
addTokens,
|
|
95
99
|
autoClearSearchValue,
|
|
96
100
|
isSearchControlled
|
|
97
101
|
]);
|
|
@@ -103,15 +107,15 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
103
107
|
}
|
|
104
108
|
suppressCloseRef.current = false;
|
|
105
109
|
if (!isOpenControlled) setOpenInternal(next_0);
|
|
106
|
-
if (!next_0 &&
|
|
107
|
-
|
|
110
|
+
if (!next_0 && isMobile) setTimeout(()=>{
|
|
111
|
+
if (!latestRequestedOpen.current) (inputRef.current ?? triggerRef.current)?.focus();
|
|
112
|
+
}, 0);
|
|
108
113
|
if (next_0 && showSearch && !isMobile) setTimeout(()=>inputRef.current?.focus(), 0);
|
|
109
114
|
onOpenChange?.(next_0);
|
|
110
115
|
}, [
|
|
111
116
|
isMultiple,
|
|
112
117
|
hasInlineSearch,
|
|
113
118
|
isOpenControlled,
|
|
114
|
-
isSearchControlled,
|
|
115
119
|
onOpenChange,
|
|
116
120
|
resolvedDisabled,
|
|
117
121
|
showSearch,
|
|
@@ -131,12 +135,11 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
131
135
|
const sep = tokenSeparators.find((s)=>s && value_0.includes(s));
|
|
132
136
|
if (!sep) return;
|
|
133
137
|
e.preventDefault();
|
|
134
|
-
|
|
135
|
-
if (!isSearchControlled) setSearchInternal('');
|
|
138
|
+
if (addTokens(value_0) && !isSearchControlled) setSearchInternal('');
|
|
136
139
|
}, [
|
|
137
140
|
isMultiple,
|
|
138
141
|
tokenSeparators,
|
|
139
|
-
|
|
142
|
+
addTokens,
|
|
140
143
|
isSearchControlled,
|
|
141
144
|
isComposingKey
|
|
142
145
|
]);
|
|
@@ -303,6 +306,8 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
303
306
|
role: "button",
|
|
304
307
|
tabIndex: resolvedDisabled ? void 0 : 0,
|
|
305
308
|
...ariaProps,
|
|
309
|
+
"aria-haspopup": "dialog",
|
|
310
|
+
"aria-expanded": open,
|
|
306
311
|
"aria-disabled": resolvedDisabled || void 0,
|
|
307
312
|
"data-disabled": resolvedDisabled || void 0,
|
|
308
313
|
className: cx(classNames?.root, className),
|
|
@@ -345,7 +350,7 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
345
350
|
children: labelRender(selectedOption)
|
|
346
351
|
}) : selectedOption ? /*#__PURE__*/ jsx("span", {
|
|
347
352
|
"data-tao-select-value": "",
|
|
348
|
-
children:
|
|
353
|
+
children: selectedOption.label
|
|
349
354
|
}) : /*#__PURE__*/ jsx("span", {
|
|
350
355
|
"data-tao-select-placeholder": "",
|
|
351
356
|
className: cx(classNames?.placeholder),
|
|
@@ -377,6 +382,7 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
377
382
|
notFoundContent: notFoundContent,
|
|
378
383
|
optionRender: optionRender,
|
|
379
384
|
multiple: isMultiple,
|
|
385
|
+
hideSelected: hideSelected,
|
|
380
386
|
maxCount: maxCount,
|
|
381
387
|
mode: mode,
|
|
382
388
|
tokenSeparators: tokenSeparators,
|
|
@@ -393,7 +399,7 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
393
399
|
...styles?.popup
|
|
394
400
|
};
|
|
395
401
|
if ('number' == typeof popupMatchSelectWidth) contentStyle.width = popupMatchSelectWidth;
|
|
396
|
-
const radixValue = isMultiple ? '' : value
|
|
402
|
+
const radixValue = isMultiple ? '' : value ?? '';
|
|
397
403
|
const resultCount = filteredFlatOptions.length;
|
|
398
404
|
const overMaxCount = isMultiple && null != maxCount && valueArray.length >= maxCount;
|
|
399
405
|
let optIndex = 0;
|
|
@@ -401,7 +407,7 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
401
407
|
const index = optIndex++;
|
|
402
408
|
const textLabel = 'string' == typeof opt.label ? opt.label : String(opt.label);
|
|
403
409
|
const isSelected = selectedValueSet.has(opt.value);
|
|
404
|
-
const itemDisabled = opt.disabled || !isSelected && overMaxCount;
|
|
410
|
+
const itemDisabled = resolvedDisabled || opt.disabled || !isSelected && overMaxCount;
|
|
405
411
|
return /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_select_4606f4d3.Item, {
|
|
406
412
|
value: opt.value,
|
|
407
413
|
disabled: itemDisabled,
|
|
@@ -470,7 +476,7 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
470
476
|
style: styles?.groupLabel,
|
|
471
477
|
children: o_0.label
|
|
472
478
|
}),
|
|
473
|
-
o_0.options
|
|
479
|
+
renderTree(o_0.options)
|
|
474
480
|
]
|
|
475
481
|
}, o_0.value) : renderItem(o_0));
|
|
476
482
|
const menuNode = /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_4606f4d3.Viewport, {
|
|
@@ -485,12 +491,17 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
485
491
|
children: notFoundContent
|
|
486
492
|
})
|
|
487
493
|
});
|
|
488
|
-
const isSearchableOptionDisabled = (option)
|
|
494
|
+
const isSearchableOptionDisabled = (option)=>resolvedDisabled || option.disabled || overMaxCount && !selectedValueSet.has(option.value);
|
|
489
495
|
const searchableOptions = filteredFlatOptions.filter((option_0)=>!isSearchableOptionDisabled(option_0));
|
|
490
496
|
const lastSearchIndex = Math.max(searchableOptions.length - 1, 0);
|
|
491
|
-
const
|
|
492
|
-
|
|
497
|
+
const previousSearchIndex = searchableOptions[activeSearch.index]?.value === activeSearch.value ? activeSearch.index : searchableOptions.findIndex((option_1)=>option_1.value === activeSearch.value);
|
|
498
|
+
const boundedSearchIndex = previousSearchIndex < 0 ? Math.min(activeSearch.index, lastSearchIndex) : previousSearchIndex;
|
|
493
499
|
const activeSearchOption = searchableOptions[boundedSearchIndex];
|
|
500
|
+
const setActiveSearchIndex = (index_0)=>setActiveSearch({
|
|
501
|
+
index: index_0,
|
|
502
|
+
value: searchableOptions[index_0]?.value
|
|
503
|
+
});
|
|
504
|
+
if (activeSearch.index !== boundedSearchIndex || activeSearch.value !== activeSearchOption?.value) setActiveSearchIndex(boundedSearchIndex);
|
|
494
505
|
const searchableMenuNode = /*#__PURE__*/ jsx(SearchableSelectList, {
|
|
495
506
|
id: searchListboxId,
|
|
496
507
|
options: filteredOptions,
|
|
@@ -499,6 +510,7 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
499
510
|
activeValue: activeSearchOption?.value,
|
|
500
511
|
selectedValues: valueArray,
|
|
501
512
|
multiple: isMultiple,
|
|
513
|
+
disabled: resolvedDisabled,
|
|
502
514
|
maxCountReached: overMaxCount,
|
|
503
515
|
listHeight: listHeight,
|
|
504
516
|
notFoundContent: notFoundContent,
|
|
@@ -510,6 +522,8 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
510
522
|
onClose: ()=>handleOpenChange(false)
|
|
511
523
|
});
|
|
512
524
|
const container = getPopupContainer && triggerRef.current ? getPopupContainer(triggerRef.current) : void 0;
|
|
525
|
+
const selectedLabel = selectedOption?.label;
|
|
526
|
+
const selectedLabelId = null != selectedLabel && 'object' == typeof selectedLabel ? `${searchListboxId}-selected-label` : void 0;
|
|
513
527
|
const inlineSearchInput = /*#__PURE__*/ jsx("input", {
|
|
514
528
|
ref: inputRef,
|
|
515
529
|
id: id,
|
|
@@ -525,7 +539,8 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
525
539
|
"aria-autocomplete": "list",
|
|
526
540
|
"aria-controls": open ? searchListboxId : void 0,
|
|
527
541
|
"aria-activedescendant": open && activeSearchOption ? `${searchListboxId}-option-${encodeURIComponent(activeSearchOption.value)}` : void 0,
|
|
528
|
-
"aria-label": props['aria-label'] ?? (
|
|
542
|
+
"aria-label": props['aria-label'] ?? ('string' == typeof selectedLabel || 'number' == typeof selectedLabel ? String(selectedLabel) : selectedLabelId ? void 0 : placeholder),
|
|
543
|
+
"aria-labelledby": props['aria-labelledby'] ?? (null == props['aria-label'] ? selectedLabelId : void 0),
|
|
529
544
|
autoFocus: autoFocus,
|
|
530
545
|
autoComplete: "off",
|
|
531
546
|
onCompositionStart: ()=>{
|
|
@@ -542,7 +557,9 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
542
557
|
},
|
|
543
558
|
onChange: (event_3)=>{
|
|
544
559
|
handleSearchChange(event_3.target.value);
|
|
545
|
-
|
|
560
|
+
setActiveSearch({
|
|
561
|
+
index: 0
|
|
562
|
+
});
|
|
546
563
|
if (!open) handleOpenChange(true);
|
|
547
564
|
},
|
|
548
565
|
onKeyDown: (event_4)=>{
|
|
@@ -566,6 +583,11 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
566
583
|
setActiveSearchIndex(Math.max(boundedSearchIndex - 1, 0));
|
|
567
584
|
return;
|
|
568
585
|
}
|
|
586
|
+
if ('Enter' === event_4.key && !requestedOpen) {
|
|
587
|
+
event_4.preventDefault();
|
|
588
|
+
handleOpenChange(true);
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
569
591
|
const nextValue = activeSearchOption?.value ?? ('tags' === mode ? search.trim() : void 0);
|
|
570
592
|
if ('Enter' === event_4.key && nextValue) {
|
|
571
593
|
event_4.preventDefault();
|
|
@@ -631,12 +653,14 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
631
653
|
style: styles?.search,
|
|
632
654
|
children: [
|
|
633
655
|
inlineSearchInput,
|
|
634
|
-
!search && /*#__PURE__*/ jsx("span", {
|
|
656
|
+
(!search || selectedLabelId) && /*#__PURE__*/ jsx("span", {
|
|
657
|
+
id: selectedLabelId,
|
|
658
|
+
hidden: !!search,
|
|
635
659
|
"data-tao-select-trigger-value": "",
|
|
636
660
|
"data-tao-select-placeholder": selectedOption ? void 0 : '',
|
|
637
661
|
className: cx(selectedOption ? void 0 : classNames?.placeholder),
|
|
638
662
|
style: selectedOption ? void 0 : styles?.placeholder,
|
|
639
|
-
children: selectedOption && labelRender ? labelRender(selectedOption) : selectedOption ?
|
|
663
|
+
children: selectedOption && labelRender ? labelRender(selectedOption) : selectedOption ? selectedOption.label : placeholder
|
|
640
664
|
})
|
|
641
665
|
]
|
|
642
666
|
})
|
|
@@ -736,7 +760,7 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
736
760
|
children: labelRender(selectedOption)
|
|
737
761
|
}) : selectedOption ? /*#__PURE__*/ jsx("span", {
|
|
738
762
|
"data-tao-select-value": "",
|
|
739
|
-
children:
|
|
763
|
+
children: selectedOption.label
|
|
740
764
|
}) : /*#__PURE__*/ jsx("span", {
|
|
741
765
|
"data-tao-select-placeholder": "",
|
|
742
766
|
className: cx(classNames?.placeholder),
|
|
@@ -8,7 +8,7 @@ export declare function useSelectSelection(props: SelectionProps, disabled: bool
|
|
|
8
8
|
selectedOption: import("./select-types.js").SelectOption | undefined;
|
|
9
9
|
selectedOptions: import("./select-types.js").SelectOption[];
|
|
10
10
|
select: (next: string) => boolean;
|
|
11
|
-
addTokens: (input: string) =>
|
|
11
|
+
addTokens: (input: string) => boolean;
|
|
12
12
|
remove: (removed: string) => void;
|
|
13
13
|
commit: (nextArray: string[]) => void;
|
|
14
14
|
clear: () => void;
|
|
@@ -58,7 +58,9 @@ function useSelectSelection(props, disabled) {
|
|
|
58
58
|
const clear = void 0 === t5 ? false : t5;
|
|
59
59
|
if (!controlled) setInternalValue(next);
|
|
60
60
|
const nextOptions = clear ? void 0 : Array.isArray(next) ? next.map((item)=>optionByValue.get(item)).filter(_temp) : optionByValue.get(next ?? "");
|
|
61
|
-
onChange?.(next
|
|
61
|
+
onChange?.(Array.isArray(next) ? [
|
|
62
|
+
...next
|
|
63
|
+
] : next ?? "", nextOptions);
|
|
62
64
|
};
|
|
63
65
|
$[11] = controlled;
|
|
64
66
|
$[12] = onChange;
|
|
@@ -102,7 +104,7 @@ function useSelectSelection(props, disabled) {
|
|
|
102
104
|
let t6;
|
|
103
105
|
if ($[25] !== disabled || $[26] !== maxCount || $[27] !== mode || $[28] !== onSelect || $[29] !== optionByToken || $[30] !== optionByValue || $[31] !== publish || $[32] !== selectedValueSet || $[33] !== tokenSeparators || $[34] !== valueArray) {
|
|
104
106
|
t6 = (input)=>{
|
|
105
|
-
if (disabled) return;
|
|
107
|
+
if (disabled) return false;
|
|
106
108
|
const tokens = (tokenSeparators ?? []).reduce(_temp2, [
|
|
107
109
|
input
|
|
108
110
|
]).map(_temp3).filter(Boolean);
|
|
@@ -117,17 +119,18 @@ function useSelectSelection(props, disabled) {
|
|
|
117
119
|
added.push(next_1);
|
|
118
120
|
}
|
|
119
121
|
}
|
|
120
|
-
if (0 === added.length) return;
|
|
122
|
+
if (0 === added.length) return false;
|
|
121
123
|
const nextArray_0 = [
|
|
122
124
|
...valueArray,
|
|
123
125
|
...added
|
|
124
126
|
];
|
|
125
|
-
if (null != maxCount && nextArray_0.length > maxCount) return;
|
|
127
|
+
if (null != maxCount && nextArray_0.length > maxCount) return false;
|
|
126
128
|
publish(nextArray_0);
|
|
127
129
|
for (const next_2 of added){
|
|
128
130
|
const option_2 = optionByValue.get(next_2);
|
|
129
131
|
if (option_2) onSelect?.(next_2, option_2);
|
|
130
132
|
}
|
|
133
|
+
return true;
|
|
131
134
|
};
|
|
132
135
|
$[25] = disabled;
|
|
133
136
|
$[26] = maxCount;
|