@rockshin/tao-ui 0.0.30 → 0.0.32
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 +124 -72
- 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.css +11 -10
- 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(()=>{
|
|
@@ -70,6 +70,13 @@ function Select(props) {
|
|
|
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,
|
|
@@ -297,6 +322,14 @@ function Select(props) {
|
|
|
297
322
|
'data-tao-error': 'error' === status || void 0,
|
|
298
323
|
'data-tao-warning': 'warning' === status || void 0
|
|
299
324
|
};
|
|
325
|
+
const ariaProps = {
|
|
326
|
+
'aria-label': props['aria-label'],
|
|
327
|
+
'aria-labelledby': props['aria-labelledby'],
|
|
328
|
+
'aria-describedby': props['aria-describedby'],
|
|
329
|
+
'aria-errormessage': props['aria-errormessage'],
|
|
330
|
+
'aria-invalid': 'error' === status ? true : props['aria-invalid'],
|
|
331
|
+
'aria-required': props['aria-required']
|
|
332
|
+
};
|
|
300
333
|
const tags = isMultiple ? /*#__PURE__*/ jsx(SelectTags, {
|
|
301
334
|
options: selectedOptions,
|
|
302
335
|
disabled: !!resolvedDisabled,
|
|
@@ -354,7 +387,7 @@ function Select(props) {
|
|
|
354
387
|
"data-tao-select-clear": "",
|
|
355
388
|
className: cx(classNames?.clear),
|
|
356
389
|
style: styles?.clear,
|
|
357
|
-
onPointerDown: (
|
|
390
|
+
onPointerDown: (event_1)=>event_1.stopPropagation(),
|
|
358
391
|
onClick: handleClear,
|
|
359
392
|
"aria-label": "Clear",
|
|
360
393
|
children: clearIcon
|
|
@@ -383,7 +416,9 @@ function Select(props) {
|
|
|
383
416
|
autoFocus: autoFocus,
|
|
384
417
|
role: "button",
|
|
385
418
|
tabIndex: resolvedDisabled ? void 0 : 0,
|
|
419
|
+
...ariaProps,
|
|
386
420
|
"aria-disabled": resolvedDisabled || void 0,
|
|
421
|
+
"data-disabled": resolvedDisabled || void 0,
|
|
387
422
|
className: cx(classNames?.root, className),
|
|
388
423
|
style: {
|
|
389
424
|
...styles?.root,
|
|
@@ -450,7 +485,8 @@ function Select(props) {
|
|
|
450
485
|
filterOption: filterOption,
|
|
451
486
|
notFoundContent: notFoundContent,
|
|
452
487
|
optionRender: optionRender,
|
|
453
|
-
multiple: isMultiple
|
|
488
|
+
multiple: isMultiple,
|
|
489
|
+
disabled: resolvedDisabled
|
|
454
490
|
})
|
|
455
491
|
]
|
|
456
492
|
});
|
|
@@ -463,23 +499,23 @@ function Select(props) {
|
|
|
463
499
|
const resultCount = filteredFlatOptions.length;
|
|
464
500
|
const overMaxCount = isMultiple && null != maxCount && valueArray.length >= maxCount;
|
|
465
501
|
let optIndex = 0;
|
|
466
|
-
const renderItem = (
|
|
502
|
+
const renderItem = (opt_5)=>{
|
|
467
503
|
const index = optIndex++;
|
|
468
|
-
const textLabel = 'string' == typeof
|
|
469
|
-
const isSelected = selectedValueSet.has(
|
|
470
|
-
const itemDisabled =
|
|
504
|
+
const textLabel = 'string' == typeof opt_5.label ? opt_5.label : String(opt_5.label);
|
|
505
|
+
const isSelected = selectedValueSet.has(opt_5.value);
|
|
506
|
+
const itemDisabled = opt_5.disabled || !isSelected && overMaxCount;
|
|
471
507
|
return /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_select_4606f4d3.Item, {
|
|
472
|
-
value:
|
|
508
|
+
value: opt_5.value,
|
|
473
509
|
disabled: itemDisabled,
|
|
474
510
|
"data-tao-select-item": "",
|
|
475
|
-
"data-tao-has-desc": null !=
|
|
511
|
+
"data-tao-has-desc": null != opt_5.description || void 0,
|
|
476
512
|
"data-tao-selected": isMultiple && isSelected ? '' : void 0,
|
|
477
513
|
className: cx(classNames?.item),
|
|
478
514
|
style: styles?.item,
|
|
479
515
|
children: [
|
|
480
516
|
optionRender ? /*#__PURE__*/ jsxs(Fragment, {
|
|
481
517
|
children: [
|
|
482
|
-
optionRender(
|
|
518
|
+
optionRender(opt_5, {
|
|
483
519
|
index
|
|
484
520
|
}),
|
|
485
521
|
/*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_4606f4d3.ItemText, {
|
|
@@ -491,11 +527,11 @@ function Select(props) {
|
|
|
491
527
|
]
|
|
492
528
|
}) : /*#__PURE__*/ jsxs(Fragment, {
|
|
493
529
|
children: [
|
|
494
|
-
null !=
|
|
530
|
+
null != opt_5.icon && /*#__PURE__*/ jsx("span", {
|
|
495
531
|
"data-tao-select-item-icon": "",
|
|
496
532
|
className: cx(classNames?.itemIcon),
|
|
497
533
|
style: styles?.itemIcon,
|
|
498
|
-
children:
|
|
534
|
+
children: opt_5.icon
|
|
499
535
|
}),
|
|
500
536
|
/*#__PURE__*/ jsxs("span", {
|
|
501
537
|
"data-tao-select-item-main": "",
|
|
@@ -503,13 +539,13 @@ function Select(props) {
|
|
|
503
539
|
style: styles?.itemLabel,
|
|
504
540
|
children: [
|
|
505
541
|
/*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_4606f4d3.ItemText, {
|
|
506
|
-
children:
|
|
542
|
+
children: opt_5.label
|
|
507
543
|
}),
|
|
508
|
-
null !=
|
|
544
|
+
null != opt_5.description && /*#__PURE__*/ jsx("span", {
|
|
509
545
|
"data-tao-select-item-desc": "",
|
|
510
546
|
className: cx(classNames?.itemDesc),
|
|
511
547
|
style: styles?.itemDesc,
|
|
512
|
-
children:
|
|
548
|
+
children: opt_5.description
|
|
513
549
|
})
|
|
514
550
|
]
|
|
515
551
|
})
|
|
@@ -523,7 +559,7 @@ function Select(props) {
|
|
|
523
559
|
children: /*#__PURE__*/ jsx(CheckIcon, {})
|
|
524
560
|
})
|
|
525
561
|
]
|
|
526
|
-
},
|
|
562
|
+
}, opt_5.value);
|
|
527
563
|
};
|
|
528
564
|
const renderTree = (opts_0)=>opts_0.map((o_0)=>o_0.options ? /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_select_4606f4d3.Group, {
|
|
529
565
|
"data-tao-select-group": "",
|
|
@@ -551,9 +587,12 @@ function Select(props) {
|
|
|
551
587
|
children: notFoundContent
|
|
552
588
|
})
|
|
553
589
|
});
|
|
554
|
-
const isSearchableOptionDisabled = (
|
|
555
|
-
const searchableOptions = filteredFlatOptions.filter((
|
|
556
|
-
const
|
|
590
|
+
const isSearchableOptionDisabled = (option_0)=>!!option_0.disabled || overMaxCount && !selectedValueSet.has(option_0.value);
|
|
591
|
+
const searchableOptions = filteredFlatOptions.filter((option_1)=>!isSearchableOptionDisabled(option_1));
|
|
592
|
+
const lastSearchIndex = Math.max(searchableOptions.length - 1, 0);
|
|
593
|
+
const boundedSearchIndex = Math.min(Math.max(activeSearchIndex, 0), lastSearchIndex);
|
|
594
|
+
if (activeSearchIndex !== boundedSearchIndex) setActiveSearchIndex(boundedSearchIndex);
|
|
595
|
+
const activeSearchOption = searchableOptions[boundedSearchIndex];
|
|
557
596
|
const searchableMenuNode = /*#__PURE__*/ jsx(SearchableSelectList, {
|
|
558
597
|
id: searchListboxId,
|
|
559
598
|
options: filteredOptions,
|
|
@@ -577,6 +616,7 @@ function Select(props) {
|
|
|
577
616
|
ref: inputRef,
|
|
578
617
|
id: id,
|
|
579
618
|
role: "combobox",
|
|
619
|
+
...ariaProps,
|
|
580
620
|
"data-tao-select-trigger-input": "",
|
|
581
621
|
className: cx(classNames?.searchInput),
|
|
582
622
|
style: styles?.searchInput,
|
|
@@ -586,42 +626,51 @@ function Select(props) {
|
|
|
586
626
|
"aria-expanded": open,
|
|
587
627
|
"aria-autocomplete": "list",
|
|
588
628
|
"aria-controls": open ? searchListboxId : void 0,
|
|
589
|
-
"aria-invalid": 'error' === status || void 0,
|
|
590
629
|
"aria-activedescendant": open && activeSearchOption ? `${searchListboxId}-option-${encodeURIComponent(activeSearchOption.value)}` : void 0,
|
|
591
|
-
"aria-label": selectedOption ? String(selectedOption.label) : placeholder,
|
|
630
|
+
"aria-label": props['aria-label'] ?? (selectedOption ? String(selectedOption.label) : placeholder),
|
|
592
631
|
autoFocus: autoFocus,
|
|
593
632
|
autoComplete: "off",
|
|
594
|
-
|
|
595
|
-
|
|
633
|
+
onCompositionStart: ()=>{
|
|
634
|
+
composingRef.current = true;
|
|
635
|
+
},
|
|
636
|
+
onCompositionEnd: ()=>{
|
|
637
|
+
composingRef.current = false;
|
|
638
|
+
},
|
|
639
|
+
onBlur: ()=>{
|
|
640
|
+
composingRef.current = false;
|
|
641
|
+
},
|
|
642
|
+
onClick: (event_2)=>{
|
|
643
|
+
if (open) event_2.stopPropagation();
|
|
596
644
|
},
|
|
597
|
-
onChange: (
|
|
598
|
-
handleSearchChange(
|
|
645
|
+
onChange: (event_3)=>{
|
|
646
|
+
handleSearchChange(event_3.target.value);
|
|
599
647
|
setActiveSearchIndex(0);
|
|
600
648
|
if (!open) handleOpenChange(true);
|
|
601
649
|
},
|
|
602
|
-
onKeyDown: (
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
if (
|
|
650
|
+
onKeyDown: (event_4)=>{
|
|
651
|
+
event_4.stopPropagation();
|
|
652
|
+
if (isComposingKey(event_4.nativeEvent)) return;
|
|
653
|
+
handleSearchKeyDown(event_4);
|
|
654
|
+
if (event_4.defaultPrevented) return;
|
|
655
|
+
if ('Escape' === event_4.key) {
|
|
607
656
|
handleSearchChange('');
|
|
608
657
|
handleOpenChange(false);
|
|
609
658
|
return;
|
|
610
659
|
}
|
|
611
|
-
if ('ArrowDown' ===
|
|
612
|
-
|
|
613
|
-
setActiveSearchIndex(
|
|
660
|
+
if ('ArrowDown' === event_4.key) {
|
|
661
|
+
event_4.preventDefault();
|
|
662
|
+
setActiveSearchIndex(Math.min(boundedSearchIndex + 1, lastSearchIndex));
|
|
614
663
|
if (!open) handleOpenChange(true);
|
|
615
664
|
return;
|
|
616
665
|
}
|
|
617
|
-
if ('ArrowUp' ===
|
|
618
|
-
|
|
619
|
-
setActiveSearchIndex(
|
|
666
|
+
if ('ArrowUp' === event_4.key) {
|
|
667
|
+
event_4.preventDefault();
|
|
668
|
+
setActiveSearchIndex(Math.max(boundedSearchIndex - 1, 0));
|
|
620
669
|
return;
|
|
621
670
|
}
|
|
622
671
|
const nextValue = activeSearchOption?.value ?? ('tags' === mode ? search.trim() : void 0);
|
|
623
|
-
if ('Enter' ===
|
|
624
|
-
|
|
672
|
+
if ('Enter' === event_4.key && nextValue) {
|
|
673
|
+
event_4.preventDefault();
|
|
625
674
|
handleValueChange(nextValue);
|
|
626
675
|
if (!isMultiple) handleOpenChange(false);
|
|
627
676
|
}
|
|
@@ -716,9 +765,10 @@ function Select(props) {
|
|
|
716
765
|
side: side,
|
|
717
766
|
align: align,
|
|
718
767
|
sideOffset: 4,
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
768
|
+
onEscapeKeyDown: handleEscapeKeyDown,
|
|
769
|
+
onOpenAutoFocus: (event_5)=>event_5.preventDefault(),
|
|
770
|
+
onCloseAutoFocus: (event_6)=>{
|
|
771
|
+
event_6.preventDefault();
|
|
722
772
|
inputRef.current?.focus();
|
|
723
773
|
},
|
|
724
774
|
children: popupRender ? popupRender(searchableMenuNode) : searchableMenuNode
|
|
@@ -741,6 +791,7 @@ function Select(props) {
|
|
|
741
791
|
children: /*#__PURE__*/ jsxs("div", {
|
|
742
792
|
ref: triggerRef,
|
|
743
793
|
id: id,
|
|
794
|
+
...ariaProps,
|
|
744
795
|
"data-tao-control": "",
|
|
745
796
|
"data-tao-select": "",
|
|
746
797
|
"data-tao-size": resolvedSize,
|
|
@@ -806,6 +857,7 @@ function Select(props) {
|
|
|
806
857
|
className: cx(classNames?.popup),
|
|
807
858
|
style: contentStyle,
|
|
808
859
|
position: "popper",
|
|
860
|
+
onEscapeKeyDown: handleEscapeKeyDown,
|
|
809
861
|
side: side,
|
|
810
862
|
align: align,
|
|
811
863
|
sideOffset: 4,
|
|
@@ -842,5 +894,5 @@ function Select(props) {
|
|
|
842
894
|
})
|
|
843
895
|
]
|
|
844
896
|
});
|
|
845
|
-
}
|
|
846
|
-
export { Select };
|
|
897
|
+
});
|
|
898
|
+
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";
|