@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.
Files changed (159) hide show
  1. package/README.md +14 -3
  2. package/dist/components/alert/alert.js +1 -1
  3. package/dist/components/breadcrumb/breadcrumb.js +1 -1
  4. package/dist/components/button/button.d.ts +2 -2
  5. package/dist/components/button/button.js +48 -50
  6. package/dist/components/checkbox/checkbox.css +5 -1
  7. package/dist/components/checkbox/checkbox.d.ts +2 -2
  8. package/dist/components/checkbox/checkbox.js +135 -120
  9. package/dist/components/collapsible/collapsible.js +1 -1
  10. package/dist/components/context-menu/context-menu.js +1 -1
  11. package/dist/components/date-picker/calendar/calendar-header.js +1 -1
  12. package/dist/components/date-picker/calendar/month-grid.d.ts +3 -1
  13. package/dist/components/date-picker/calendar/month-grid.js +19 -17
  14. package/dist/components/date-picker/calendar/time-panel.js +1 -1
  15. package/dist/components/date-picker/calendar/year-grid.d.ts +3 -1
  16. package/dist/components/date-picker/calendar/year-grid.js +28 -24
  17. package/dist/components/date-picker/date-picker.d.ts +1 -1
  18. package/dist/components/date-picker/date-picker.js +37 -24
  19. package/dist/components/date-picker/presets.js +1 -1
  20. package/dist/components/date-picker/range-picker.d.ts +1 -1
  21. package/dist/components/date-picker/range-picker.js +104 -56
  22. package/dist/components/drawer/drawer.d.ts +1 -1
  23. package/dist/components/drawer/drawer.js +98 -91
  24. package/dist/components/dropdown/dropdown.js +84 -84
  25. package/dist/components/form/form-item.js +8 -4
  26. package/dist/components/form/form.js +1 -1
  27. package/dist/components/form-actions/form-actions.js +1 -1
  28. package/dist/components/form-field/form-field-view.js +58 -51
  29. package/dist/components/form-field/form-field.js +1 -1
  30. package/dist/components/form-section/form-section.js +1 -1
  31. package/dist/components/input/input.js +42 -39
  32. package/dist/components/input-number/input-number.d.ts +2 -2
  33. package/dist/components/input-number/input-number.js +57 -59
  34. package/dist/components/menu/menu-render.js +1 -1
  35. package/dist/components/modal/confirm-dialog.d.ts +2 -1
  36. package/dist/components/modal/confirm-dialog.js +25 -5
  37. package/dist/components/modal/confirm.js +15 -3
  38. package/dist/components/modal/modal.d.ts +1 -1
  39. package/dist/components/modal/modal.js +131 -132
  40. package/dist/components/modal/use-modal.js +48 -35
  41. package/dist/components/pagination/pagination.js +3 -1
  42. package/dist/components/popconfirm/popconfirm.js +1 -1
  43. package/dist/components/popover/popover.js +253 -228
  44. package/dist/components/radio/radio.css +2 -2
  45. package/dist/components/radio/radio.d.ts +1 -1
  46. package/dist/components/radio/radio.js +7 -7
  47. package/dist/components/scroll-area/scroll-area.css +2 -2
  48. package/dist/components/scroll-area/scroll-area.js +187 -165
  49. package/dist/components/select/mobile-select.d.ts +2 -1
  50. package/dist/components/select/mobile-select.js +12 -6
  51. package/dist/components/select/select-icons.js +1 -1
  52. package/dist/components/select/select-searchable-list.d.ts +1 -1
  53. package/dist/components/select/select-searchable-list.js +35 -21
  54. package/dist/components/select/select-tags.js +1 -1
  55. package/dist/components/select/select-types.d.ts +2 -2
  56. package/dist/components/select/select.css +4 -0
  57. package/dist/components/select/select.d.ts +2 -2
  58. package/dist/components/select/select.js +124 -72
  59. package/dist/components/sonner/sonner.js +6 -5
  60. package/dist/components/spinner/spinner.js +1 -1
  61. package/dist/components/splitter/splitter.js +187 -194
  62. package/dist/components/status-icon/status-icon.js +1 -1
  63. package/dist/components/switch/switch.d.ts +1 -1
  64. package/dist/components/switch/switch.js +6 -6
  65. package/dist/components/table/table-filter.js +1 -1
  66. package/dist/components/table/table-icons.js +1 -1
  67. package/dist/components/table/table.css +11 -10
  68. package/dist/components/table/table.js +483 -599
  69. package/dist/components/tabs/tabs.js +179 -161
  70. package/dist/components/tag/tag.js +1 -1
  71. package/dist/components/textarea/textarea.d.ts +1 -1
  72. package/dist/components/textarea/textarea.js +142 -108
  73. package/dist/components/tooltip/tooltip.js +88 -72
  74. package/dist/entries/alert.d.ts +3 -0
  75. package/dist/entries/alert.js +4 -0
  76. package/dist/entries/breadcrumb.d.ts +3 -0
  77. package/dist/entries/breadcrumb.js +4 -0
  78. package/dist/entries/button.d.ts +3 -0
  79. package/dist/entries/button.js +4 -0
  80. package/dist/entries/checkbox.d.ts +3 -0
  81. package/dist/entries/checkbox.js +4 -0
  82. package/dist/entries/collapsible.d.ts +3 -0
  83. package/dist/entries/collapsible.js +4 -0
  84. package/dist/entries/context-menu.d.ts +3 -0
  85. package/dist/entries/context-menu.js +4 -0
  86. package/dist/entries/date-picker.d.ts +3 -0
  87. package/dist/entries/date-picker.js +4 -0
  88. package/dist/entries/drawer.d.ts +3 -0
  89. package/dist/entries/drawer.js +4 -0
  90. package/dist/entries/dropdown.d.ts +3 -0
  91. package/dist/entries/dropdown.js +4 -0
  92. package/dist/entries/form-actions.d.ts +3 -0
  93. package/dist/entries/form-actions.js +4 -0
  94. package/dist/entries/form-field.d.ts +3 -0
  95. package/dist/entries/form-field.js +4 -0
  96. package/dist/entries/form-layout.d.ts +3 -0
  97. package/dist/entries/form-layout.js +4 -0
  98. package/dist/entries/form-section.d.ts +3 -0
  99. package/dist/entries/form-section.js +4 -0
  100. package/dist/entries/form.d.ts +4 -0
  101. package/dist/entries/form.js +4 -0
  102. package/dist/entries/input-number.d.ts +3 -0
  103. package/dist/entries/input-number.js +4 -0
  104. package/dist/entries/input.d.ts +3 -0
  105. package/dist/entries/input.js +4 -0
  106. package/dist/entries/modal.d.ts +3 -0
  107. package/dist/entries/modal.js +4 -0
  108. package/dist/entries/number-input.d.ts +3 -0
  109. package/dist/entries/number-input.js +4 -0
  110. package/dist/entries/pagination.d.ts +3 -0
  111. package/dist/entries/pagination.js +4 -0
  112. package/dist/entries/popconfirm.d.ts +3 -0
  113. package/dist/entries/popconfirm.js +4 -0
  114. package/dist/entries/popover.d.ts +3 -0
  115. package/dist/entries/popover.js +4 -0
  116. package/dist/entries/provider.d.ts +3 -0
  117. package/dist/entries/provider.js +4 -0
  118. package/dist/entries/radio.d.ts +3 -0
  119. package/dist/entries/radio.js +4 -0
  120. package/dist/entries/range-picker.d.ts +3 -0
  121. package/dist/entries/range-picker.js +4 -0
  122. package/dist/entries/scroll-area.d.ts +3 -0
  123. package/dist/entries/scroll-area.js +4 -0
  124. package/dist/entries/select.d.ts +3 -0
  125. package/dist/entries/select.js +4 -0
  126. package/dist/entries/sonner.d.ts +3 -0
  127. package/dist/entries/sonner.js +4 -0
  128. package/dist/entries/spinner.d.ts +3 -0
  129. package/dist/entries/spinner.js +4 -0
  130. package/dist/entries/splitter.d.ts +3 -0
  131. package/dist/entries/splitter.js +4 -0
  132. package/dist/entries/stack.d.ts +3 -0
  133. package/dist/entries/stack.js +4 -0
  134. package/dist/entries/switch.d.ts +3 -0
  135. package/dist/entries/switch.js +4 -0
  136. package/dist/entries/table.d.ts +3 -0
  137. package/dist/entries/table.js +4 -0
  138. package/dist/entries/tabs.d.ts +3 -0
  139. package/dist/entries/tabs.js +4 -0
  140. package/dist/entries/tag.d.ts +3 -0
  141. package/dist/entries/tag.js +4 -0
  142. package/dist/entries/textarea.d.ts +3 -0
  143. package/dist/entries/textarea.js +4 -0
  144. package/dist/entries/tooltip.d.ts +3 -0
  145. package/dist/entries/tooltip.js +4 -0
  146. package/dist/layouts/form-layout/form-layout.js +1 -1
  147. package/dist/layouts/stack/stack.js +1 -1
  148. package/dist/number-input/number-input.js +1 -1
  149. package/dist/number-input/use-number-input.d.ts +2 -2
  150. package/dist/number-input/use-number-input.js +224 -131
  151. package/dist/number-input/validate.js +7 -2
  152. package/dist/provider/tao-provider.js +1 -1
  153. package/dist/utils/dialog-content.d.ts +10 -0
  154. package/dist/utils/dialog-content.js +222 -0
  155. package/dist/utils/overlay.d.ts +2 -2
  156. package/dist/utils/overlay.js +8 -3
  157. package/dist/utils/refs.js +17 -2
  158. package/llms.txt +5 -3
  159. 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 = (option)=>{
20
+ const renderItem = (option_0)=>{
7
21
  const renderIndex = itemIndex++;
8
- const optionIndex = searchableOptions.findIndex((candidate)=>candidate.value === option.value);
9
- const isSelected = selectedValues.includes(option.value);
10
- const isDisabled = !!option.disabled || maxCountReached && !isSelected;
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(option.value)}`,
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 != option.description || void 0,
34
+ "data-tao-has-desc": null != option_0.description || void 0,
21
35
  "data-state": isSelected ? 'checked' : 'unchecked',
22
- "data-highlighted": activeValue === option.value ? '' : void 0,
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 (optionIndex >= 0) onActiveIndexChange(optionIndex);
41
+ if (void 0 !== optionIndex) onActiveIndexChange(optionIndex);
28
42
  },
29
43
  onClick: ()=>{
30
44
  if (isDisabled) return;
31
- onValueChange(option.value);
45
+ onValueChange(option_0.value);
32
46
  if (!multiple) onClose();
33
47
  },
34
48
  children: [
35
- optionRender ? optionRender(option, {
49
+ optionRender ? optionRender(option_0, {
36
50
  index: renderIndex
37
51
  }) : /*#__PURE__*/ jsxs(Fragment, {
38
52
  children: [
39
- null != option.icon && /*#__PURE__*/ jsx("span", {
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: option.icon
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: option.label
65
+ children: option_0.label
52
66
  }),
53
- null != option.description && /*#__PURE__*/ jsx("span", {
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: option.description
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
- }, option.value);
82
+ }, option_0.value);
69
83
  };
70
- const renderTree = (items)=>items.map((option_0)=>option_0.options ? /*#__PURE__*/ jsxs("fieldset", {
71
- "aria-label": String(option_0.label),
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: option_0.label
94
+ children: option_1.label
81
95
  }),
82
- renderTree(option_0.options)
96
+ renderTree(option_1.options)
83
97
  ]
84
- }, option_0.value) : renderItem(option_0));
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/compiler-runtime";
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 function Select(props: SelectProps): import("react/jsx-runtime").JSX.Element;
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
- function Select(props) {
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, ref } = props;
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 = void 0 !== valueProp;
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 sep = tokenSeparators.find((s)=>next.includes(s));
85
- if (sep) {
86
- const tokens = next.split(sep).map((t)=>t.trim()).filter(Boolean);
87
- const toAdd = tokens.filter((t_0)=>{
88
- const opt = optionByToken.get(t_0);
89
- return opt && !selectedValueSet.has(opt.value);
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 opt_0 = optionByValue.get(v_0);
102
- if (opt_0) onSelect?.(v_0, opt_0);
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 opt_1 = optionByValue.get(next);
120
- if (opt_1) if (existed) onDeselect?.(next, opt_1);
121
- else onSelect?.(next, opt_1);
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 opt_2 = optionByValue.get(next);
142
+ const opt_1 = optionByValue.get(next);
126
143
  if (!isValueControlled) setValueInternal(next);
127
- onChange?.(next, opt_2);
128
- if (opt_2) onSelect?.(next, opt_2);
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 value_0 = e.target.value;
174
- const sep_0 = tokenSeparators.find((s_0)=>value_0.includes(s_0));
175
- if (!sep_0) return;
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(value_0);
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 opt_3 = optionByValue.get(removedValue);
215
- if (opt_3) onDeselect?.(removedValue, opt_3);
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 opt_4 = optionByValue.get(v_7);
232
- if (opt_4) onSelect?.(v_7, opt_4);
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 opt_5 = optionByValue.get(v_8);
236
- if (opt_5) onDeselect?.(v_8, opt_5);
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: (event)=>event.stopPropagation(),
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 = (opt_6)=>{
502
+ const renderItem = (opt_5)=>{
467
503
  const index = optIndex++;
468
- const textLabel = 'string' == typeof opt_6.label ? opt_6.label : String(opt_6.label);
469
- const isSelected = selectedValueSet.has(opt_6.value);
470
- const itemDisabled = opt_6.disabled || !isSelected && overMaxCount;
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: opt_6.value,
508
+ value: opt_5.value,
473
509
  disabled: itemDisabled,
474
510
  "data-tao-select-item": "",
475
- "data-tao-has-desc": null != opt_6.description || void 0,
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(opt_6, {
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 != opt_6.icon && /*#__PURE__*/ jsx("span", {
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: opt_6.icon
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: opt_6.label
542
+ children: opt_5.label
507
543
  }),
508
- null != opt_6.description && /*#__PURE__*/ jsx("span", {
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: opt_6.description
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
- }, opt_6.value);
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 = (option)=>!!option.disabled || overMaxCount && !selectedValueSet.has(option.value);
555
- const searchableOptions = filteredFlatOptions.filter((option_0)=>!isSearchableOptionDisabled(option_0));
556
- const activeSearchOption = searchableOptions[Math.min(activeSearchIndex, Math.max(searchableOptions.length - 1, 0))];
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
- onClick: (event_0)=>{
595
- if (open) event_0.stopPropagation();
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: (event_1)=>{
598
- handleSearchChange(event_1.target.value);
645
+ onChange: (event_3)=>{
646
+ handleSearchChange(event_3.target.value);
599
647
  setActiveSearchIndex(0);
600
648
  if (!open) handleOpenChange(true);
601
649
  },
602
- onKeyDown: (event_2)=>{
603
- event_2.stopPropagation();
604
- handleSearchKeyDown(event_2);
605
- if (event_2.defaultPrevented) return;
606
- if ('Escape' === event_2.key) {
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' === event_2.key) {
612
- event_2.preventDefault();
613
- setActiveSearchIndex((index_0)=>Math.min(index_0 + 1, searchableOptions.length - 1));
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' === event_2.key) {
618
- event_2.preventDefault();
619
- setActiveSearchIndex((index_1)=>Math.max(index_1 - 1, 0));
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' === event_2.key && nextValue) {
624
- event_2.preventDefault();
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
- onOpenAutoFocus: (event_3)=>event_3.preventDefault(),
720
- onCloseAutoFocus: (event_4)=>{
721
- event_4.preventDefault();
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 replacePromiseToast(id, type, options) {
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
- if (success) replacePromiseToast(id, 'success', success);
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
- if (failure) replacePromiseToast(id, 'error', failure);
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/compiler-runtime";
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";