@rockshin/tao-ui 0.0.31 → 0.0.33
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/README.md +14 -3
- package/dist/components/alert/alert.js +1 -1
- package/dist/components/breadcrumb/breadcrumb.js +1 -1
- package/dist/components/button/button.d.ts +2 -2
- package/dist/components/button/button.js +48 -50
- package/dist/components/checkbox/checkbox.css +5 -1
- package/dist/components/checkbox/checkbox.d.ts +2 -2
- package/dist/components/checkbox/checkbox.js +135 -120
- package/dist/components/collapsible/collapsible.js +1 -1
- package/dist/components/context-menu/context-menu.js +1 -1
- package/dist/components/date-picker/calendar/calendar-header.js +1 -1
- package/dist/components/date-picker/calendar/month-grid.d.ts +3 -1
- package/dist/components/date-picker/calendar/month-grid.js +19 -17
- package/dist/components/date-picker/calendar/time-panel.js +1 -1
- package/dist/components/date-picker/calendar/year-grid.d.ts +3 -1
- package/dist/components/date-picker/calendar/year-grid.js +28 -24
- package/dist/components/date-picker/date-picker.d.ts +1 -1
- package/dist/components/date-picker/date-picker.js +37 -24
- package/dist/components/date-picker/presets.js +1 -1
- package/dist/components/date-picker/range-picker.d.ts +1 -1
- package/dist/components/date-picker/range-picker.js +104 -56
- package/dist/components/drawer/drawer.d.ts +1 -1
- package/dist/components/drawer/drawer.js +98 -91
- package/dist/components/dropdown/dropdown.js +84 -84
- package/dist/components/form/form-item.js +8 -4
- package/dist/components/form/form.js +1 -1
- package/dist/components/form-actions/form-actions.js +1 -1
- package/dist/components/form-field/form-field-view.js +58 -51
- package/dist/components/form-field/form-field.js +1 -1
- package/dist/components/form-section/form-section.js +1 -1
- package/dist/components/input/input.js +42 -39
- package/dist/components/input-number/input-number.d.ts +2 -2
- package/dist/components/input-number/input-number.js +57 -59
- package/dist/components/menu/menu-render.js +1 -1
- package/dist/components/modal/confirm-dialog.d.ts +2 -1
- package/dist/components/modal/confirm-dialog.js +25 -5
- package/dist/components/modal/confirm.js +15 -3
- package/dist/components/modal/modal.d.ts +1 -1
- package/dist/components/modal/modal.js +131 -132
- package/dist/components/modal/use-modal.js +48 -35
- package/dist/components/pagination/pagination.js +3 -1
- package/dist/components/popconfirm/popconfirm.js +1 -1
- package/dist/components/popover/popover.js +253 -228
- package/dist/components/radio/radio.css +2 -2
- package/dist/components/radio/radio.d.ts +1 -1
- package/dist/components/radio/radio.js +7 -7
- package/dist/components/scroll-area/scroll-area.css +2 -2
- package/dist/components/scroll-area/scroll-area.js +187 -165
- package/dist/components/select/mobile-select.d.ts +2 -1
- package/dist/components/select/mobile-select.js +12 -6
- package/dist/components/select/select-icons.js +1 -1
- package/dist/components/select/select-searchable-list.d.ts +1 -1
- package/dist/components/select/select-searchable-list.js +35 -21
- package/dist/components/select/select-tags.js +1 -1
- package/dist/components/select/select-types.d.ts +2 -2
- package/dist/components/select/select.css +4 -0
- package/dist/components/select/select.d.ts +2 -2
- package/dist/components/select/select.js +127 -73
- package/dist/components/sonner/sonner.js +6 -5
- package/dist/components/spinner/spinner.js +1 -1
- package/dist/components/splitter/splitter.js +187 -194
- package/dist/components/status-icon/status-icon.js +1 -1
- package/dist/components/switch/switch.d.ts +1 -1
- package/dist/components/switch/switch.js +6 -6
- package/dist/components/table/table-filter.js +1 -1
- package/dist/components/table/table-icons.js +1 -1
- package/dist/components/table/table.js +483 -599
- package/dist/components/tabs/tabs.js +179 -161
- package/dist/components/tag/tag.js +1 -1
- package/dist/components/textarea/textarea.d.ts +1 -1
- package/dist/components/textarea/textarea.js +142 -108
- package/dist/components/tooltip/tooltip.js +88 -72
- package/dist/entries/alert.d.ts +3 -0
- package/dist/entries/alert.js +4 -0
- package/dist/entries/breadcrumb.d.ts +3 -0
- package/dist/entries/breadcrumb.js +4 -0
- package/dist/entries/button.d.ts +3 -0
- package/dist/entries/button.js +4 -0
- package/dist/entries/checkbox.d.ts +3 -0
- package/dist/entries/checkbox.js +4 -0
- package/dist/entries/collapsible.d.ts +3 -0
- package/dist/entries/collapsible.js +4 -0
- package/dist/entries/context-menu.d.ts +3 -0
- package/dist/entries/context-menu.js +4 -0
- package/dist/entries/date-picker.d.ts +3 -0
- package/dist/entries/date-picker.js +4 -0
- package/dist/entries/drawer.d.ts +3 -0
- package/dist/entries/drawer.js +4 -0
- package/dist/entries/dropdown.d.ts +3 -0
- package/dist/entries/dropdown.js +4 -0
- package/dist/entries/form-actions.d.ts +3 -0
- package/dist/entries/form-actions.js +4 -0
- package/dist/entries/form-field.d.ts +3 -0
- package/dist/entries/form-field.js +4 -0
- package/dist/entries/form-layout.d.ts +3 -0
- package/dist/entries/form-layout.js +4 -0
- package/dist/entries/form-section.d.ts +3 -0
- package/dist/entries/form-section.js +4 -0
- package/dist/entries/form.d.ts +4 -0
- package/dist/entries/form.js +4 -0
- package/dist/entries/input-number.d.ts +3 -0
- package/dist/entries/input-number.js +4 -0
- package/dist/entries/input.d.ts +3 -0
- package/dist/entries/input.js +4 -0
- package/dist/entries/modal.d.ts +3 -0
- package/dist/entries/modal.js +4 -0
- package/dist/entries/number-input.d.ts +3 -0
- package/dist/entries/number-input.js +4 -0
- package/dist/entries/pagination.d.ts +3 -0
- package/dist/entries/pagination.js +4 -0
- package/dist/entries/popconfirm.d.ts +3 -0
- package/dist/entries/popconfirm.js +4 -0
- package/dist/entries/popover.d.ts +3 -0
- package/dist/entries/popover.js +4 -0
- package/dist/entries/provider.d.ts +3 -0
- package/dist/entries/provider.js +4 -0
- package/dist/entries/radio.d.ts +3 -0
- package/dist/entries/radio.js +4 -0
- package/dist/entries/range-picker.d.ts +3 -0
- package/dist/entries/range-picker.js +4 -0
- package/dist/entries/scroll-area.d.ts +3 -0
- package/dist/entries/scroll-area.js +4 -0
- package/dist/entries/select.d.ts +3 -0
- package/dist/entries/select.js +4 -0
- package/dist/entries/sonner.d.ts +3 -0
- package/dist/entries/sonner.js +4 -0
- package/dist/entries/spinner.d.ts +3 -0
- package/dist/entries/spinner.js +4 -0
- package/dist/entries/splitter.d.ts +3 -0
- package/dist/entries/splitter.js +4 -0
- package/dist/entries/stack.d.ts +3 -0
- package/dist/entries/stack.js +4 -0
- package/dist/entries/switch.d.ts +3 -0
- package/dist/entries/switch.js +4 -0
- package/dist/entries/table.d.ts +3 -0
- package/dist/entries/table.js +4 -0
- package/dist/entries/tabs.d.ts +3 -0
- package/dist/entries/tabs.js +4 -0
- package/dist/entries/tag.d.ts +3 -0
- package/dist/entries/tag.js +4 -0
- package/dist/entries/textarea.d.ts +3 -0
- package/dist/entries/textarea.js +4 -0
- package/dist/entries/tooltip.d.ts +3 -0
- package/dist/entries/tooltip.js +4 -0
- package/dist/layouts/form-layout/form-layout.js +1 -1
- package/dist/layouts/stack/stack.js +1 -1
- package/dist/number-input/number-input.js +1 -1
- package/dist/number-input/use-number-input.d.ts +2 -2
- package/dist/number-input/use-number-input.js +224 -131
- package/dist/number-input/validate.js +7 -2
- package/dist/provider/tao-provider.js +1 -1
- package/dist/utils/dialog-content.d.ts +10 -0
- package/dist/utils/dialog-content.js +222 -0
- package/dist/utils/overlay.d.ts +2 -2
- package/dist/utils/overlay.js +8 -3
- package/dist/utils/refs.js +17 -2
- package/llms.txt +5 -3
- package/package.json +21 -8
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
2
3
|
import { cx } from "../../utils/semantic.js";
|
|
3
4
|
import { CheckIcon } from "./select-icons.js";
|
|
4
5
|
function SearchableSelectList({ id, options, resultCount, searchableOptions, activeValue, selectedValues, multiple, maxCountReached, listHeight, notFoundContent, optionRender, classNames, styles, onActiveIndexChange, onValueChange, onClose }) {
|
|
6
|
+
const indexByValue = useMemo(()=>{
|
|
7
|
+
const index = new Map();
|
|
8
|
+
searchableOptions.forEach((option, position)=>{
|
|
9
|
+
const value = option.value;
|
|
10
|
+
if (!index.has(value)) index.set(value, position);
|
|
11
|
+
});
|
|
12
|
+
return index;
|
|
13
|
+
}, [
|
|
14
|
+
searchableOptions
|
|
15
|
+
]);
|
|
16
|
+
const selectedValueSet = useMemo(()=>new Set(selectedValues), [
|
|
17
|
+
selectedValues
|
|
18
|
+
]);
|
|
5
19
|
let itemIndex = 0;
|
|
6
|
-
const renderItem = (
|
|
20
|
+
const renderItem = (option_0)=>{
|
|
7
21
|
const renderIndex = itemIndex++;
|
|
8
|
-
const optionIndex =
|
|
9
|
-
const isSelected =
|
|
10
|
-
const isDisabled = !!
|
|
22
|
+
const optionIndex = indexByValue.get(option_0.value);
|
|
23
|
+
const isSelected = selectedValueSet.has(option_0.value);
|
|
24
|
+
const isDisabled = !!option_0.disabled || maxCountReached && !isSelected;
|
|
11
25
|
return /*#__PURE__*/ jsxs("button", {
|
|
12
|
-
id: `${id}-option-${encodeURIComponent(
|
|
26
|
+
id: `${id}-option-${encodeURIComponent(option_0.value)}`,
|
|
13
27
|
type: "button",
|
|
14
28
|
role: "option",
|
|
15
29
|
"aria-selected": isSelected,
|
|
@@ -17,30 +31,30 @@ function SearchableSelectList({ id, options, resultCount, searchableOptions, act
|
|
|
17
31
|
"data-disabled": isDisabled || void 0,
|
|
18
32
|
"data-tao-select-item": "",
|
|
19
33
|
"data-tao-selected": multiple && isSelected ? '' : void 0,
|
|
20
|
-
"data-tao-has-desc": null !=
|
|
34
|
+
"data-tao-has-desc": null != option_0.description || void 0,
|
|
21
35
|
"data-state": isSelected ? 'checked' : 'unchecked',
|
|
22
|
-
"data-highlighted": activeValue ===
|
|
36
|
+
"data-highlighted": activeValue === option_0.value ? '' : void 0,
|
|
23
37
|
className: cx(classNames?.item),
|
|
24
38
|
style: styles?.item,
|
|
25
39
|
onPointerDown: (event)=>event.preventDefault(),
|
|
26
40
|
onMouseMove: ()=>{
|
|
27
|
-
if (
|
|
41
|
+
if (void 0 !== optionIndex) onActiveIndexChange(optionIndex);
|
|
28
42
|
},
|
|
29
43
|
onClick: ()=>{
|
|
30
44
|
if (isDisabled) return;
|
|
31
|
-
onValueChange(
|
|
45
|
+
onValueChange(option_0.value);
|
|
32
46
|
if (!multiple) onClose();
|
|
33
47
|
},
|
|
34
48
|
children: [
|
|
35
|
-
optionRender ? optionRender(
|
|
49
|
+
optionRender ? optionRender(option_0, {
|
|
36
50
|
index: renderIndex
|
|
37
51
|
}) : /*#__PURE__*/ jsxs(Fragment, {
|
|
38
52
|
children: [
|
|
39
|
-
null !=
|
|
53
|
+
null != option_0.icon && /*#__PURE__*/ jsx("span", {
|
|
40
54
|
"data-tao-select-item-icon": "",
|
|
41
55
|
className: cx(classNames?.itemIcon),
|
|
42
56
|
style: styles?.itemIcon,
|
|
43
|
-
children:
|
|
57
|
+
children: option_0.icon
|
|
44
58
|
}),
|
|
45
59
|
/*#__PURE__*/ jsxs("span", {
|
|
46
60
|
"data-tao-select-item-main": "",
|
|
@@ -48,13 +62,13 @@ function SearchableSelectList({ id, options, resultCount, searchableOptions, act
|
|
|
48
62
|
style: styles?.itemLabel,
|
|
49
63
|
children: [
|
|
50
64
|
/*#__PURE__*/ jsx("span", {
|
|
51
|
-
children:
|
|
65
|
+
children: option_0.label
|
|
52
66
|
}),
|
|
53
|
-
null !=
|
|
67
|
+
null != option_0.description && /*#__PURE__*/ jsx("span", {
|
|
54
68
|
"data-tao-select-item-desc": "",
|
|
55
69
|
className: cx(classNames?.itemDesc),
|
|
56
70
|
style: styles?.itemDesc,
|
|
57
|
-
children:
|
|
71
|
+
children: option_0.description
|
|
58
72
|
})
|
|
59
73
|
]
|
|
60
74
|
})
|
|
@@ -65,10 +79,10 @@ function SearchableSelectList({ id, options, resultCount, searchableOptions, act
|
|
|
65
79
|
children: /*#__PURE__*/ jsx(CheckIcon, {})
|
|
66
80
|
})
|
|
67
81
|
]
|
|
68
|
-
},
|
|
82
|
+
}, option_0.value);
|
|
69
83
|
};
|
|
70
|
-
const renderTree = (items)=>items.map((
|
|
71
|
-
"aria-label": String(
|
|
84
|
+
const renderTree = (items)=>items.map((option_1)=>option_1.options ? /*#__PURE__*/ jsxs("fieldset", {
|
|
85
|
+
"aria-label": String(option_1.label),
|
|
72
86
|
"data-tao-select-group": "",
|
|
73
87
|
className: cx(classNames?.group),
|
|
74
88
|
style: styles?.group,
|
|
@@ -77,11 +91,11 @@ function SearchableSelectList({ id, options, resultCount, searchableOptions, act
|
|
|
77
91
|
"data-tao-select-group-label": "",
|
|
78
92
|
className: cx(classNames?.groupLabel),
|
|
79
93
|
style: styles?.groupLabel,
|
|
80
|
-
children:
|
|
94
|
+
children: option_1.label
|
|
81
95
|
}),
|
|
82
|
-
renderTree(
|
|
96
|
+
renderTree(option_1.options)
|
|
83
97
|
]
|
|
84
|
-
},
|
|
98
|
+
}, option_1.value) : renderItem(option_1));
|
|
85
99
|
return /*#__PURE__*/ jsx("div", {
|
|
86
100
|
id: id,
|
|
87
101
|
role: "listbox",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { c } from "react
|
|
2
|
+
import { c } from "react-compiler-runtime";
|
|
3
3
|
import { Fragment as external_react_Fragment } from "react";
|
|
4
4
|
import { cx } from "../../utils/semantic.js";
|
|
5
5
|
import { CloseIcon } from "./select-icons.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CSSProperties, ReactNode, Ref } from 'react';
|
|
1
|
+
import type { AriaAttributes, CSSProperties, ReactNode, Ref } from 'react';
|
|
2
2
|
import type { TaoSize, TaoStatus, TaoVariant } from '../../provider/tao-provider';
|
|
3
3
|
import type { SemanticClassNames, SemanticStyles } from '../../utils/semantic';
|
|
4
4
|
export interface SelectOption {
|
|
@@ -23,7 +23,7 @@ export interface SelectRef {
|
|
|
23
23
|
blur: () => void;
|
|
24
24
|
nativeElement: HTMLElement | null;
|
|
25
25
|
}
|
|
26
|
-
export interface SelectProps {
|
|
26
|
+
export interface SelectProps extends Pick<AriaAttributes, 'aria-label' | 'aria-labelledby' | 'aria-describedby' | 'aria-errormessage' | 'aria-invalid' | 'aria-required'> {
|
|
27
27
|
options: SelectOption[];
|
|
28
28
|
value?: string | string[];
|
|
29
29
|
defaultValue?: string | string[];
|
|
@@ -417,6 +417,10 @@ legend[data-tao-select-group-label] {
|
|
|
417
417
|
width: 4ch;
|
|
418
418
|
}
|
|
419
419
|
|
|
420
|
+
[data-tao-select][data-tao-inline-search][data-tao-multiple] [data-tao-select-values] > [data-tao-select-trigger-input]:only-child {
|
|
421
|
+
padding-inline-start: calc(var(--tao-select-padding-inline) - 4px);
|
|
422
|
+
}
|
|
423
|
+
|
|
420
424
|
[data-tao-select-tag] {
|
|
421
425
|
max-width: 160px;
|
|
422
426
|
font-size: var(--tao-font-size-sm);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import './select.css';
|
|
2
|
-
import type { SelectProps } from './select-types';
|
|
2
|
+
import type { SelectProps, SelectRef } from './select-types';
|
|
3
3
|
export type { SelectOption, SelectPlacement, SelectProps, SelectRef, SelectSemanticPart, TagRenderProps, } from './select-types';
|
|
4
|
-
export declare
|
|
4
|
+
export declare const Select: import("react").ForwardRefExoticComponent<Omit<SelectProps, "ref"> & import("react").RefAttributes<SelectRef>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useId, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { forwardRef, useCallback, useId, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { TaoPortalScope, useTaoConfig } from "../../provider/tao-provider.js";
|
|
4
4
|
import { cx } from "../../utils/semantic.js";
|
|
5
5
|
import { MobileSelectDrawer } from "./mobile-select.js";
|
|
@@ -29,8 +29,8 @@ const PLACEMENT_MAP = {
|
|
|
29
29
|
align: 'end'
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
|
-
|
|
33
|
-
const { options, value: valueProp, defaultValue, onChange, onSelect, onDeselect, onClear, mode, placeholder, size, variant, disabled, status, showSearch, filterOption, searchValue: searchValueProp, onSearch, allowClear, loading, loadingIcon, notFoundContent = 'No results', prefix, suffixIcon, removeIcon, autoFocus, id, name, open: openProp, defaultOpen, onOpenChange, placement = 'bottomLeft', popupMatchSelectWidth = true, listHeight = 256, getPopupContainer, optionRender, labelRender, popupRender, tagRender, maxTagCount, maxTagPlaceholder, maxTagTextLength, maxCount, autoClearSearchValue = true, tokenSeparators, hideSelected, mobile, className, style, classNames, styles
|
|
32
|
+
const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
33
|
+
const { options, value: valueProp, defaultValue, onChange, onSelect, onDeselect, onClear, mode, placeholder, size, variant, disabled, status, showSearch, filterOption, searchValue: searchValueProp, onSearch, allowClear, loading, loadingIcon, notFoundContent = 'No results', prefix, suffixIcon, removeIcon, autoFocus, id, name, open: openProp, defaultOpen, onOpenChange, placement = 'bottomLeft', popupMatchSelectWidth = true, listHeight = 256, getPopupContainer, optionRender, labelRender, popupRender, tagRender, maxTagCount, maxTagPlaceholder, maxTagTextLength, maxCount, autoClearSearchValue = true, tokenSeparators, hideSelected, mobile, className, style, classNames, styles } = props;
|
|
34
34
|
const ctx = useTaoConfig();
|
|
35
35
|
const resolvedSize = size ?? ctx.size;
|
|
36
36
|
const resolvedVariant = variant ?? ctx.variant;
|
|
@@ -51,7 +51,7 @@ function Select(props) {
|
|
|
51
51
|
}), [
|
|
52
52
|
hasInlineSearch
|
|
53
53
|
]);
|
|
54
|
-
const isValueControlled =
|
|
54
|
+
const isValueControlled = 'value' in props;
|
|
55
55
|
const [valueInternal, setValueInternal] = useState(isMultiple ? defaultValue ?? [] : defaultValue);
|
|
56
56
|
const value = isValueControlled ? valueProp : valueInternal;
|
|
57
57
|
const valueArray = useMemo(()=>{
|
|
@@ -65,11 +65,18 @@ function Select(props) {
|
|
|
65
65
|
]);
|
|
66
66
|
const isOpenControlled = void 0 !== openProp;
|
|
67
67
|
const [openInternal, setOpenInternal] = useState(defaultOpen ?? false);
|
|
68
|
-
const
|
|
68
|
+
const requestedOpen = isOpenControlled ? openProp : openInternal;
|
|
69
69
|
const isSearchControlled = void 0 !== searchValueProp;
|
|
70
70
|
const [searchInternal, setSearchInternal] = useState('');
|
|
71
71
|
const search = isSearchControlled ? searchValueProp : searchInternal;
|
|
72
72
|
const [activeSearchIndex, setActiveSearchIndex] = useState(0);
|
|
73
|
+
const composingRef = useRef(false);
|
|
74
|
+
const isComposingKey = useCallback((event)=>composingRef.current || event.isComposing || 229 === event.keyCode, []);
|
|
75
|
+
const handleEscapeKeyDown = useCallback((event_0)=>{
|
|
76
|
+
if (isComposingKey(event_0)) event_0.preventDefault();
|
|
77
|
+
}, [
|
|
78
|
+
isComposingKey
|
|
79
|
+
]);
|
|
73
80
|
const [hovering, setHovering] = useState(false);
|
|
74
81
|
const suppressCloseRef = useRef(false);
|
|
75
82
|
const { optionByToken, optionByValue } = useMemo(()=>buildSelectIndex(options), [
|
|
@@ -79,15 +86,25 @@ function Select(props) {
|
|
|
79
86
|
valueArray
|
|
80
87
|
]);
|
|
81
88
|
const handleValueChange = useCallback((next)=>{
|
|
89
|
+
if (resolvedDisabled) return;
|
|
82
90
|
if (isMultiple) {
|
|
83
91
|
if (tokenSeparators && tokenSeparators.length > 0) {
|
|
84
|
-
const
|
|
85
|
-
if (
|
|
86
|
-
const tokens =
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
const hasSeparator = tokenSeparators.some((separator)=>separator && next.includes(separator));
|
|
93
|
+
if (hasSeparator) {
|
|
94
|
+
const tokens = tokenSeparators.reduce((parts, separator_0)=>separator_0 ? parts.flatMap((part)=>part.split(separator_0)) : parts, [
|
|
95
|
+
next
|
|
96
|
+
]).map((token)=>token.trim()).filter(Boolean);
|
|
97
|
+
const seen = new Set(selectedValueSet);
|
|
98
|
+
const toAdd = [];
|
|
99
|
+
for (const token_0 of tokens){
|
|
100
|
+
const option = optionByToken.get(token_0);
|
|
101
|
+
if (option?.disabled || !option && 'tags' !== mode) continue;
|
|
102
|
+
const value_0 = option?.value ?? token_0;
|
|
103
|
+
if (!seen.has(value_0)) {
|
|
104
|
+
seen.add(value_0);
|
|
105
|
+
toAdd.push(value_0);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
91
108
|
if (toAdd.length > 0) {
|
|
92
109
|
const nextArray = [
|
|
93
110
|
...valueArray,
|
|
@@ -98,8 +115,8 @@ function Select(props) {
|
|
|
98
115
|
const selectedOpts = nextArray.map((v)=>optionByValue.get(v)).filter(Boolean);
|
|
99
116
|
onChange?.(nextArray, selectedOpts);
|
|
100
117
|
for (const v_0 of toAdd){
|
|
101
|
-
const
|
|
102
|
-
if (
|
|
118
|
+
const opt = optionByValue.get(v_0);
|
|
119
|
+
if (opt) onSelect?.(v_0, opt);
|
|
103
120
|
}
|
|
104
121
|
}
|
|
105
122
|
return;
|
|
@@ -116,22 +133,24 @@ function Select(props) {
|
|
|
116
133
|
if (!isValueControlled) setValueInternal(nextArray_0);
|
|
117
134
|
const selectedOpts_0 = nextArray_0.map((v_2)=>optionByValue.get(v_2)).filter(Boolean);
|
|
118
135
|
onChange?.(nextArray_0, selectedOpts_0);
|
|
119
|
-
const
|
|
120
|
-
if (
|
|
121
|
-
else onSelect?.(next,
|
|
136
|
+
const opt_0 = optionByValue.get(next);
|
|
137
|
+
if (opt_0) if (existed) onDeselect?.(next, opt_0);
|
|
138
|
+
else onSelect?.(next, opt_0);
|
|
122
139
|
if (autoClearSearchValue && !isSearchControlled) setSearchInternal('');
|
|
123
140
|
return;
|
|
124
141
|
}
|
|
125
|
-
const
|
|
142
|
+
const opt_1 = optionByValue.get(next);
|
|
126
143
|
if (!isValueControlled) setValueInternal(next);
|
|
127
|
-
onChange?.(next,
|
|
128
|
-
if (
|
|
144
|
+
onChange?.(next, opt_1);
|
|
145
|
+
if (opt_1) onSelect?.(next, opt_1);
|
|
129
146
|
}, [
|
|
130
147
|
isMultiple,
|
|
131
148
|
hasInlineSearch,
|
|
132
149
|
valueArray,
|
|
133
150
|
maxCount,
|
|
134
151
|
tokenSeparators,
|
|
152
|
+
resolvedDisabled,
|
|
153
|
+
mode,
|
|
135
154
|
isValueControlled,
|
|
136
155
|
optionByToken,
|
|
137
156
|
optionByValue,
|
|
@@ -143,6 +162,7 @@ function Select(props) {
|
|
|
143
162
|
isSearchControlled
|
|
144
163
|
]);
|
|
145
164
|
const handleOpenChange = useCallback((next_0)=>{
|
|
165
|
+
if (next_0 && resolvedDisabled) return;
|
|
146
166
|
if (isMultiple && !hasInlineSearch && !next_0 && suppressCloseRef.current) {
|
|
147
167
|
suppressCloseRef.current = false;
|
|
148
168
|
return;
|
|
@@ -158,6 +178,7 @@ function Select(props) {
|
|
|
158
178
|
isOpenControlled,
|
|
159
179
|
isSearchControlled,
|
|
160
180
|
onOpenChange,
|
|
181
|
+
resolvedDisabled,
|
|
161
182
|
showSearch,
|
|
162
183
|
isMobile
|
|
163
184
|
]);
|
|
@@ -169,18 +190,20 @@ function Select(props) {
|
|
|
169
190
|
onSearch
|
|
170
191
|
]);
|
|
171
192
|
const handleSearchKeyDown = useCallback((e)=>{
|
|
193
|
+
if (isComposingKey(e.nativeEvent)) return;
|
|
172
194
|
if (!isMultiple || !tokenSeparators || 0 === tokenSeparators.length) return;
|
|
173
|
-
const
|
|
174
|
-
const
|
|
175
|
-
if (!
|
|
195
|
+
const value_1 = e.target.value;
|
|
196
|
+
const sep = tokenSeparators.find((s)=>s && value_1.includes(s));
|
|
197
|
+
if (!sep) return;
|
|
176
198
|
e.preventDefault();
|
|
177
|
-
handleValueChange(
|
|
199
|
+
handleValueChange(value_1);
|
|
178
200
|
if (!isSearchControlled) setSearchInternal('');
|
|
179
201
|
}, [
|
|
180
202
|
isMultiple,
|
|
181
203
|
tokenSeparators,
|
|
182
204
|
handleValueChange,
|
|
183
|
-
isSearchControlled
|
|
205
|
+
isSearchControlled,
|
|
206
|
+
isComposingKey
|
|
184
207
|
]);
|
|
185
208
|
const clearValue = useCallback(()=>{
|
|
186
209
|
if (isMultiple) {
|
|
@@ -211,8 +234,8 @@ function Select(props) {
|
|
|
211
234
|
if (!isValueControlled) setValueInternal(nextArray_1);
|
|
212
235
|
const selectedOpts_1 = nextArray_1.map((v_5)=>optionByValue.get(v_5)).filter(Boolean);
|
|
213
236
|
onChange?.(nextArray_1, selectedOpts_1);
|
|
214
|
-
const
|
|
215
|
-
if (
|
|
237
|
+
const opt_2 = optionByValue.get(removedValue);
|
|
238
|
+
if (opt_2) onDeselect?.(removedValue, opt_2);
|
|
216
239
|
}, [
|
|
217
240
|
isMultiple,
|
|
218
241
|
valueArray,
|
|
@@ -222,22 +245,24 @@ function Select(props) {
|
|
|
222
245
|
onDeselect
|
|
223
246
|
]);
|
|
224
247
|
const handleMultiChange = useCallback((nextArray_2)=>{
|
|
248
|
+
if (resolvedDisabled) return;
|
|
225
249
|
if (!isValueControlled) setValueInternal(nextArray_2);
|
|
226
250
|
const selectedOpts_2 = nextArray_2.map((v_6)=>optionByValue.get(v_6)).filter(Boolean);
|
|
227
251
|
onChange?.(nextArray_2, selectedOpts_2);
|
|
228
252
|
const prev = valueArray;
|
|
229
253
|
const nextSet = new Set(nextArray_2);
|
|
230
254
|
for (const v_7 of nextArray_2)if (!selectedValueSet.has(v_7)) {
|
|
231
|
-
const
|
|
232
|
-
if (
|
|
255
|
+
const opt_3 = optionByValue.get(v_7);
|
|
256
|
+
if (opt_3) onSelect?.(v_7, opt_3);
|
|
233
257
|
}
|
|
234
258
|
for (const v_8 of prev)if (!nextSet.has(v_8)) {
|
|
235
|
-
const
|
|
236
|
-
if (
|
|
259
|
+
const opt_4 = optionByValue.get(v_8);
|
|
260
|
+
if (opt_4) onDeselect?.(v_8, opt_4);
|
|
237
261
|
}
|
|
238
262
|
}, [
|
|
239
263
|
valueArray,
|
|
240
264
|
selectedValueSet,
|
|
265
|
+
resolvedDisabled,
|
|
241
266
|
isValueControlled,
|
|
242
267
|
optionByValue,
|
|
243
268
|
onChange,
|
|
@@ -276,6 +301,8 @@ function Select(props) {
|
|
|
276
301
|
const filteredFlatOptions = useMemo(()=>flattenLeafOptions(filteredOptions), [
|
|
277
302
|
filteredOptions
|
|
278
303
|
]);
|
|
304
|
+
const suppressEmptyTagsPopup = hasInlineSearch && 'tags' === mode && 0 === filteredFlatOptions.length && !notFoundContent && !loading && !popupRender;
|
|
305
|
+
const open = requestedOpen && !suppressEmptyTagsPopup;
|
|
279
306
|
const allowClearEnabled = !!allowClear;
|
|
280
307
|
const clearIcon = 'object' == typeof allowClear && allowClear.clearIcon || /*#__PURE__*/ jsx(CloseIcon, {});
|
|
281
308
|
const showClearBtn = allowClearEnabled && (isMultiple ? valueArray.length > 0 : !!value) && !resolvedDisabled;
|
|
@@ -297,6 +324,14 @@ function Select(props) {
|
|
|
297
324
|
'data-tao-error': 'error' === status || void 0,
|
|
298
325
|
'data-tao-warning': 'warning' === status || void 0
|
|
299
326
|
};
|
|
327
|
+
const ariaProps = {
|
|
328
|
+
'aria-label': props['aria-label'],
|
|
329
|
+
'aria-labelledby': props['aria-labelledby'],
|
|
330
|
+
'aria-describedby': props['aria-describedby'],
|
|
331
|
+
'aria-errormessage': props['aria-errormessage'],
|
|
332
|
+
'aria-invalid': 'error' === status ? true : props['aria-invalid'],
|
|
333
|
+
'aria-required': props['aria-required']
|
|
334
|
+
};
|
|
300
335
|
const tags = isMultiple ? /*#__PURE__*/ jsx(SelectTags, {
|
|
301
336
|
options: selectedOptions,
|
|
302
337
|
disabled: !!resolvedDisabled,
|
|
@@ -354,7 +389,7 @@ function Select(props) {
|
|
|
354
389
|
"data-tao-select-clear": "",
|
|
355
390
|
className: cx(classNames?.clear),
|
|
356
391
|
style: styles?.clear,
|
|
357
|
-
onPointerDown: (
|
|
392
|
+
onPointerDown: (event_1)=>event_1.stopPropagation(),
|
|
358
393
|
onClick: handleClear,
|
|
359
394
|
"aria-label": "Clear",
|
|
360
395
|
children: clearIcon
|
|
@@ -383,7 +418,9 @@ function Select(props) {
|
|
|
383
418
|
autoFocus: autoFocus,
|
|
384
419
|
role: "button",
|
|
385
420
|
tabIndex: resolvedDisabled ? void 0 : 0,
|
|
421
|
+
...ariaProps,
|
|
386
422
|
"aria-disabled": resolvedDisabled || void 0,
|
|
423
|
+
"data-disabled": resolvedDisabled || void 0,
|
|
387
424
|
className: cx(classNames?.root, className),
|
|
388
425
|
style: {
|
|
389
426
|
...styles?.root,
|
|
@@ -450,7 +487,8 @@ function Select(props) {
|
|
|
450
487
|
filterOption: filterOption,
|
|
451
488
|
notFoundContent: notFoundContent,
|
|
452
489
|
optionRender: optionRender,
|
|
453
|
-
multiple: isMultiple
|
|
490
|
+
multiple: isMultiple,
|
|
491
|
+
disabled: resolvedDisabled
|
|
454
492
|
})
|
|
455
493
|
]
|
|
456
494
|
});
|
|
@@ -463,23 +501,23 @@ function Select(props) {
|
|
|
463
501
|
const resultCount = filteredFlatOptions.length;
|
|
464
502
|
const overMaxCount = isMultiple && null != maxCount && valueArray.length >= maxCount;
|
|
465
503
|
let optIndex = 0;
|
|
466
|
-
const renderItem = (
|
|
504
|
+
const renderItem = (opt_5)=>{
|
|
467
505
|
const index = optIndex++;
|
|
468
|
-
const textLabel = 'string' == typeof
|
|
469
|
-
const isSelected = selectedValueSet.has(
|
|
470
|
-
const itemDisabled =
|
|
506
|
+
const textLabel = 'string' == typeof opt_5.label ? opt_5.label : String(opt_5.label);
|
|
507
|
+
const isSelected = selectedValueSet.has(opt_5.value);
|
|
508
|
+
const itemDisabled = opt_5.disabled || !isSelected && overMaxCount;
|
|
471
509
|
return /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_select_4606f4d3.Item, {
|
|
472
|
-
value:
|
|
510
|
+
value: opt_5.value,
|
|
473
511
|
disabled: itemDisabled,
|
|
474
512
|
"data-tao-select-item": "",
|
|
475
|
-
"data-tao-has-desc": null !=
|
|
513
|
+
"data-tao-has-desc": null != opt_5.description || void 0,
|
|
476
514
|
"data-tao-selected": isMultiple && isSelected ? '' : void 0,
|
|
477
515
|
className: cx(classNames?.item),
|
|
478
516
|
style: styles?.item,
|
|
479
517
|
children: [
|
|
480
518
|
optionRender ? /*#__PURE__*/ jsxs(Fragment, {
|
|
481
519
|
children: [
|
|
482
|
-
optionRender(
|
|
520
|
+
optionRender(opt_5, {
|
|
483
521
|
index
|
|
484
522
|
}),
|
|
485
523
|
/*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_4606f4d3.ItemText, {
|
|
@@ -491,11 +529,11 @@ function Select(props) {
|
|
|
491
529
|
]
|
|
492
530
|
}) : /*#__PURE__*/ jsxs(Fragment, {
|
|
493
531
|
children: [
|
|
494
|
-
null !=
|
|
532
|
+
null != opt_5.icon && /*#__PURE__*/ jsx("span", {
|
|
495
533
|
"data-tao-select-item-icon": "",
|
|
496
534
|
className: cx(classNames?.itemIcon),
|
|
497
535
|
style: styles?.itemIcon,
|
|
498
|
-
children:
|
|
536
|
+
children: opt_5.icon
|
|
499
537
|
}),
|
|
500
538
|
/*#__PURE__*/ jsxs("span", {
|
|
501
539
|
"data-tao-select-item-main": "",
|
|
@@ -503,13 +541,13 @@ function Select(props) {
|
|
|
503
541
|
style: styles?.itemLabel,
|
|
504
542
|
children: [
|
|
505
543
|
/*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_4606f4d3.ItemText, {
|
|
506
|
-
children:
|
|
544
|
+
children: opt_5.label
|
|
507
545
|
}),
|
|
508
|
-
null !=
|
|
546
|
+
null != opt_5.description && /*#__PURE__*/ jsx("span", {
|
|
509
547
|
"data-tao-select-item-desc": "",
|
|
510
548
|
className: cx(classNames?.itemDesc),
|
|
511
549
|
style: styles?.itemDesc,
|
|
512
|
-
children:
|
|
550
|
+
children: opt_5.description
|
|
513
551
|
})
|
|
514
552
|
]
|
|
515
553
|
})
|
|
@@ -523,7 +561,7 @@ function Select(props) {
|
|
|
523
561
|
children: /*#__PURE__*/ jsx(CheckIcon, {})
|
|
524
562
|
})
|
|
525
563
|
]
|
|
526
|
-
},
|
|
564
|
+
}, opt_5.value);
|
|
527
565
|
};
|
|
528
566
|
const renderTree = (opts_0)=>opts_0.map((o_0)=>o_0.options ? /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_select_4606f4d3.Group, {
|
|
529
567
|
"data-tao-select-group": "",
|
|
@@ -551,9 +589,12 @@ function Select(props) {
|
|
|
551
589
|
children: notFoundContent
|
|
552
590
|
})
|
|
553
591
|
});
|
|
554
|
-
const isSearchableOptionDisabled = (
|
|
555
|
-
const searchableOptions = filteredFlatOptions.filter((
|
|
556
|
-
const
|
|
592
|
+
const isSearchableOptionDisabled = (option_0)=>!!option_0.disabled || overMaxCount && !selectedValueSet.has(option_0.value);
|
|
593
|
+
const searchableOptions = filteredFlatOptions.filter((option_1)=>!isSearchableOptionDisabled(option_1));
|
|
594
|
+
const lastSearchIndex = Math.max(searchableOptions.length - 1, 0);
|
|
595
|
+
const boundedSearchIndex = Math.min(Math.max(activeSearchIndex, 0), lastSearchIndex);
|
|
596
|
+
if (activeSearchIndex !== boundedSearchIndex) setActiveSearchIndex(boundedSearchIndex);
|
|
597
|
+
const activeSearchOption = searchableOptions[boundedSearchIndex];
|
|
557
598
|
const searchableMenuNode = /*#__PURE__*/ jsx(SearchableSelectList, {
|
|
558
599
|
id: searchListboxId,
|
|
559
600
|
options: filteredOptions,
|
|
@@ -577,6 +618,7 @@ function Select(props) {
|
|
|
577
618
|
ref: inputRef,
|
|
578
619
|
id: id,
|
|
579
620
|
role: "combobox",
|
|
621
|
+
...ariaProps,
|
|
580
622
|
"data-tao-select-trigger-input": "",
|
|
581
623
|
className: cx(classNames?.searchInput),
|
|
582
624
|
style: styles?.searchInput,
|
|
@@ -586,42 +628,51 @@ function Select(props) {
|
|
|
586
628
|
"aria-expanded": open,
|
|
587
629
|
"aria-autocomplete": "list",
|
|
588
630
|
"aria-controls": open ? searchListboxId : void 0,
|
|
589
|
-
"aria-invalid": 'error' === status || void 0,
|
|
590
631
|
"aria-activedescendant": open && activeSearchOption ? `${searchListboxId}-option-${encodeURIComponent(activeSearchOption.value)}` : void 0,
|
|
591
|
-
"aria-label": selectedOption ? String(selectedOption.label) : placeholder,
|
|
632
|
+
"aria-label": props['aria-label'] ?? (selectedOption ? String(selectedOption.label) : placeholder),
|
|
592
633
|
autoFocus: autoFocus,
|
|
593
634
|
autoComplete: "off",
|
|
594
|
-
|
|
595
|
-
|
|
635
|
+
onCompositionStart: ()=>{
|
|
636
|
+
composingRef.current = true;
|
|
637
|
+
},
|
|
638
|
+
onCompositionEnd: ()=>{
|
|
639
|
+
composingRef.current = false;
|
|
640
|
+
},
|
|
641
|
+
onBlur: ()=>{
|
|
642
|
+
composingRef.current = false;
|
|
643
|
+
},
|
|
644
|
+
onClick: (event_2)=>{
|
|
645
|
+
if (open) event_2.stopPropagation();
|
|
596
646
|
},
|
|
597
|
-
onChange: (
|
|
598
|
-
handleSearchChange(
|
|
647
|
+
onChange: (event_3)=>{
|
|
648
|
+
handleSearchChange(event_3.target.value);
|
|
599
649
|
setActiveSearchIndex(0);
|
|
600
650
|
if (!open) handleOpenChange(true);
|
|
601
651
|
},
|
|
602
|
-
onKeyDown: (
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
if (
|
|
652
|
+
onKeyDown: (event_4)=>{
|
|
653
|
+
event_4.stopPropagation();
|
|
654
|
+
if (isComposingKey(event_4.nativeEvent)) return;
|
|
655
|
+
handleSearchKeyDown(event_4);
|
|
656
|
+
if (event_4.defaultPrevented) return;
|
|
657
|
+
if ('Escape' === event_4.key) {
|
|
607
658
|
handleSearchChange('');
|
|
608
659
|
handleOpenChange(false);
|
|
609
660
|
return;
|
|
610
661
|
}
|
|
611
|
-
if ('ArrowDown' ===
|
|
612
|
-
|
|
613
|
-
setActiveSearchIndex(
|
|
662
|
+
if ('ArrowDown' === event_4.key) {
|
|
663
|
+
event_4.preventDefault();
|
|
664
|
+
setActiveSearchIndex(Math.min(boundedSearchIndex + 1, lastSearchIndex));
|
|
614
665
|
if (!open) handleOpenChange(true);
|
|
615
666
|
return;
|
|
616
667
|
}
|
|
617
|
-
if ('ArrowUp' ===
|
|
618
|
-
|
|
619
|
-
setActiveSearchIndex(
|
|
668
|
+
if ('ArrowUp' === event_4.key) {
|
|
669
|
+
event_4.preventDefault();
|
|
670
|
+
setActiveSearchIndex(Math.max(boundedSearchIndex - 1, 0));
|
|
620
671
|
return;
|
|
621
672
|
}
|
|
622
673
|
const nextValue = activeSearchOption?.value ?? ('tags' === mode ? search.trim() : void 0);
|
|
623
|
-
if ('Enter' ===
|
|
624
|
-
|
|
674
|
+
if ('Enter' === event_4.key && nextValue) {
|
|
675
|
+
event_4.preventDefault();
|
|
625
676
|
handleValueChange(nextValue);
|
|
626
677
|
if (!isMultiple) handleOpenChange(false);
|
|
627
678
|
}
|
|
@@ -716,9 +767,10 @@ function Select(props) {
|
|
|
716
767
|
side: side,
|
|
717
768
|
align: align,
|
|
718
769
|
sideOffset: 4,
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
770
|
+
onEscapeKeyDown: handleEscapeKeyDown,
|
|
771
|
+
onOpenAutoFocus: (event_5)=>event_5.preventDefault(),
|
|
772
|
+
onCloseAutoFocus: (event_6)=>{
|
|
773
|
+
event_6.preventDefault();
|
|
722
774
|
inputRef.current?.focus();
|
|
723
775
|
},
|
|
724
776
|
children: popupRender ? popupRender(searchableMenuNode) : searchableMenuNode
|
|
@@ -741,6 +793,7 @@ function Select(props) {
|
|
|
741
793
|
children: /*#__PURE__*/ jsxs("div", {
|
|
742
794
|
ref: triggerRef,
|
|
743
795
|
id: id,
|
|
796
|
+
...ariaProps,
|
|
744
797
|
"data-tao-control": "",
|
|
745
798
|
"data-tao-select": "",
|
|
746
799
|
"data-tao-size": resolvedSize,
|
|
@@ -806,6 +859,7 @@ function Select(props) {
|
|
|
806
859
|
className: cx(classNames?.popup),
|
|
807
860
|
style: contentStyle,
|
|
808
861
|
position: "popper",
|
|
862
|
+
onEscapeKeyDown: handleEscapeKeyDown,
|
|
809
863
|
side: side,
|
|
810
864
|
align: align,
|
|
811
865
|
sideOffset: 4,
|
|
@@ -842,5 +896,5 @@ function Select(props) {
|
|
|
842
896
|
})
|
|
843
897
|
]
|
|
844
898
|
});
|
|
845
|
-
}
|
|
846
|
-
export { Select };
|
|
899
|
+
});
|
|
900
|
+
export { select_Select as Select };
|
|
@@ -101,7 +101,9 @@ function create(type, options, custom) {
|
|
|
101
101
|
scheduleDismiss(id, normalized.duration);
|
|
102
102
|
return id;
|
|
103
103
|
}
|
|
104
|
-
function
|
|
104
|
+
function settlePromiseToast(id, generation, type, options) {
|
|
105
|
+
if (runtimes.get(id)?.generation !== generation || !state.toasts.some((toast)=>toast.id === id && 'active' === toast.phase)) return;
|
|
106
|
+
if (!options) return void dismiss(id);
|
|
105
107
|
const normalized = normalizeOptions(options);
|
|
106
108
|
create(type, {
|
|
107
109
|
...normalized,
|
|
@@ -345,16 +347,15 @@ const sonner_toast = Object.assign(baseToast, {
|
|
|
345
347
|
title: messages.loading,
|
|
346
348
|
duration: 0
|
|
347
349
|
});
|
|
350
|
+
const generation = runtimes.get(id)?.generation;
|
|
348
351
|
try {
|
|
349
352
|
const value = await promise;
|
|
350
353
|
const success = renderPromiseState(messages.success, value);
|
|
351
|
-
|
|
352
|
-
else dismiss(id);
|
|
354
|
+
settlePromiseToast(id, generation, 'success', success);
|
|
353
355
|
return value;
|
|
354
356
|
} catch (error) {
|
|
355
357
|
const failure = renderPromiseState(messages.error, error);
|
|
356
|
-
|
|
357
|
-
else dismiss(id);
|
|
358
|
+
settlePromiseToast(id, generation, 'error', failure);
|
|
358
359
|
throw error;
|
|
359
360
|
}
|
|
360
361
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { c } from "react
|
|
2
|
+
import { c } from "react-compiler-runtime";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
4
|
import { useTaoConfig } from "../../provider/tao-provider.js";
|
|
5
5
|
import { cx } from "../../utils/semantic.js";
|