@rockshin/tao-ui 0.0.58 → 0.0.60

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 (111) hide show
  1. package/dist/components/affix/affix.js +38 -4
  2. package/dist/components/app/app-modals.js +11 -6
  3. package/dist/components/app/app-notices.js +105 -47
  4. package/dist/components/auto-complete/auto-complete.js +9 -2
  5. package/dist/components/calendar/calendar.js +22 -18
  6. package/dist/components/carousel/carousel.js +27 -14
  7. package/dist/components/cascader/cascader.js +18 -12
  8. package/dist/components/checkbox/checkbox.d.ts +3 -1
  9. package/dist/components/checkbox/checkbox.js +65 -58
  10. package/dist/components/color-picker/color-picker.css +1 -1
  11. package/dist/components/color-picker/color-picker.js +386 -362
  12. package/dist/components/context-menu/context-menu.d.ts +3 -1
  13. package/dist/components/context-menu/context-menu.js +48 -43
  14. package/dist/components/date-picker/calendar/calendar-grid.d.ts +5 -3
  15. package/dist/components/date-picker/calendar/calendar-grid.js +9 -4
  16. package/dist/components/date-picker/calendar/month-grid.d.ts +2 -1
  17. package/dist/components/date-picker/calendar/month-grid.js +61 -45
  18. package/dist/components/date-picker/calendar/time-panel.d.ts +8 -1
  19. package/dist/components/date-picker/calendar/time-panel.js +93 -88
  20. package/dist/components/date-picker/calendar/year-grid.d.ts +2 -1
  21. package/dist/components/date-picker/calendar/year-grid.js +60 -44
  22. package/dist/components/date-picker/date-picker.css +9 -0
  23. package/dist/components/date-picker/date-picker.js +25 -14
  24. package/dist/components/date-picker/range-picker.d.ts +2 -0
  25. package/dist/components/date-picker/range-picker.js +132 -73
  26. package/dist/components/date-picker/types.js +1 -1
  27. package/dist/components/drawer/drawer.d.ts +1 -1
  28. package/dist/components/drawer/drawer.js +4 -3
  29. package/dist/components/dropdown/dropdown.d.ts +1 -0
  30. package/dist/components/dropdown/dropdown.js +29 -21
  31. package/dist/components/float-button/float-button.js +6 -5
  32. package/dist/components/form/form-item.d.ts +1 -1
  33. package/dist/components/form/form-item.js +160 -120
  34. package/dist/components/form/use-form.js +2 -1
  35. package/dist/components/form-field/form-field-view.d.ts +2 -1
  36. package/dist/components/form-field/form-field-view.js +173 -108
  37. package/dist/components/input/input-shared.js +3 -2
  38. package/dist/components/input/otp.js +114 -110
  39. package/dist/components/input/password.js +55 -61
  40. package/dist/components/input/search.js +8 -4
  41. package/dist/components/input-number/input-number.d.ts +2 -1
  42. package/dist/components/input-number/input-number.js +67 -52
  43. package/dist/components/mentions/mentions.js +4 -2
  44. package/dist/components/menu/menu-render.d.ts +6 -0
  45. package/dist/components/menu/menu-render.js +39 -26
  46. package/dist/components/modal/confirm-dialog.js +22 -10
  47. package/dist/components/modal/modal.js +320 -315
  48. package/dist/components/modal/use-modal.js +1 -1
  49. package/dist/components/pagination/pagination.d.ts +4 -2
  50. package/dist/components/pagination/pagination.js +128 -117
  51. package/dist/components/popover/popover.js +214 -351
  52. package/dist/components/qr-code/qr-code.js +157 -150
  53. package/dist/components/radio/radio.d.ts +3 -1
  54. package/dist/components/radio/radio.js +73 -64
  55. package/dist/components/select/mobile-select.js +7 -4
  56. package/dist/components/select/select-model.js +3 -3
  57. package/dist/components/select/select.js +78 -39
  58. package/dist/components/select/use-select-selection.js +100 -92
  59. package/dist/components/slider/slider.d.ts +2 -2
  60. package/dist/components/slider/slider.js +13 -2
  61. package/dist/components/sonner/sonner.js +2 -2
  62. package/dist/components/splitter/splitter.css +1 -0
  63. package/dist/components/splitter/splitter.js +152 -126
  64. package/dist/components/statistic/statistic.js +38 -31
  65. package/dist/components/switch/switch.js +45 -39
  66. package/dist/components/table/table-filter.d.ts +3 -1
  67. package/dist/components/table/table-filter.js +100 -74
  68. package/dist/components/table/table.js +2 -0
  69. package/dist/components/table/use-table-data.js +2 -2
  70. package/dist/components/tabs/tabs.d.ts +3 -2
  71. package/dist/components/tabs/tabs.js +122 -112
  72. package/dist/components/time-picker/time-picker.js +35 -3
  73. package/dist/components/tooltip/tooltip.d.ts +1 -1
  74. package/dist/components/tooltip/tooltip.js +220 -124
  75. package/dist/components/tree/tree.js +31 -3
  76. package/dist/components/tree-select/tree-select.js +2 -1
  77. package/dist/components/upload/upload.js +67 -40
  78. package/dist/locales/ar-EG.js +2 -0
  79. package/dist/locales/de-DE.js +2 -0
  80. package/dist/locales/en-US.js +2 -0
  81. package/dist/locales/es-ES.js +2 -0
  82. package/dist/locales/fr-FR.js +2 -0
  83. package/dist/locales/hi-IN.js +2 -0
  84. package/dist/locales/id-ID.js +2 -0
  85. package/dist/locales/it-IT.js +2 -0
  86. package/dist/locales/ja-JP.js +2 -0
  87. package/dist/locales/ko-KR.js +2 -0
  88. package/dist/locales/pt-BR.js +2 -0
  89. package/dist/locales/ru-RU.js +2 -0
  90. package/dist/locales/th-TH.js +2 -0
  91. package/dist/locales/tr-TR.js +2 -0
  92. package/dist/locales/types.d.ts +2 -0
  93. package/dist/locales/vi-VN.js +2 -0
  94. package/dist/locales/zh-CN.js +2 -0
  95. package/dist/locales/zh-TW.js +2 -0
  96. package/dist/number-input/format.js +1 -1
  97. package/dist/number-input/use-number-input.d.ts +1 -0
  98. package/dist/number-input/use-number-input.js +170 -321
  99. package/dist/number-input/validate.d.ts +1 -0
  100. package/dist/number-input/validate.js +1 -1
  101. package/dist/provider/tao-provider.d.ts +2 -2
  102. package/dist/provider/tao-provider.js +66 -52
  103. package/dist/theme/control.css +5 -1
  104. package/dist/theme/theme.css +2 -2
  105. package/dist/utils/composed-parent.d.ts +1 -0
  106. package/dist/utils/composed-parent.js +7 -0
  107. package/dist/utils/portal.d.ts +5 -0
  108. package/dist/utils/portal.js +7 -1
  109. package/dist/utils/refs.d.ts +3 -1
  110. package/dist/utils/refs.js +25 -1
  111. package/package.json +1 -1
@@ -1,8 +1,9 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { c } from "react-compiler-runtime";
3
3
  import { Slot } from "@radix-ui/react-slot";
4
- import { createContext, useContext, useLayoutEffect, useRef, useState } from "react";
4
+ import { createContext, forwardRef, useContext, useLayoutEffect, useRef, useState } from "react";
5
5
  import { taoTokenVars } from "../theme/tokens.js";
6
+ import { getComposedParent } from "../utils/composed-parent.js";
6
7
  import { enUS, zhCN } from "./locale.js";
7
8
  import { mergeLocale } from "./merge-locale.js";
8
9
  const TaoConfigContext = /*#__PURE__*/ createContext({
@@ -43,12 +44,6 @@ function useTaoConfig() {
43
44
  function useTaoInternalConfig() {
44
45
  return useContext(TaoConfigContext);
45
46
  }
46
- function directionParent(element) {
47
- if (element.assignedSlot) return element.assignedSlot;
48
- if (element.parentElement) return element.parentElement;
49
- const root = element.getRootNode();
50
- return 'host' in root ? root.host : null;
51
- }
52
47
  function useTaoDirection(explicit, t0) {
53
48
  const $ = c(8);
54
49
  const source = void 0 === t0 ? "parent" : t0;
@@ -60,14 +55,28 @@ function useTaoDirection(explicit, t0) {
60
55
  if ($[0] !== contextDirection || $[1] !== element || $[2] !== explicit || $[3] !== source) {
61
56
  t1 = ()=>{
62
57
  if (explicit && "auto" !== explicit || !element) return;
63
- const target = "self" === source || "auto" === explicit ? element : directionParent(element);
58
+ const target = "self" === source || "auto" === explicit ? element : getComposedParent(element);
64
59
  if (!target) return;
65
60
  const update = ()=>{
66
- const value = getComputedStyle(target).direction || target.closest("[dir]")?.getAttribute("dir") || contextDirection;
61
+ let resolved;
62
+ for(let ancestor = target; ancestor; ancestor = getComposedParent(ancestor)){
63
+ const inlineDir = ancestor.style?.direction;
64
+ if ("rtl" === inlineDir || "ltr" === inlineDir) {
65
+ resolved = inlineDir;
66
+ break;
67
+ }
68
+ const attrDir = ancestor.getAttribute("dir");
69
+ if ("rtl" === attrDir || "ltr" === attrDir) {
70
+ resolved = attrDir;
71
+ break;
72
+ }
73
+ }
74
+ const computed = getComputedStyle(target).direction;
75
+ const value = resolved ?? ("rtl" === computed ? "rtl" : contextDirection ?? "ltr");
67
76
  setInherited("rtl" === value ? "rtl" : "ltr");
68
- for(let ancestor = target; ancestor; ancestor = directionParent(ancestor)){
69
- const auto = "auto" === ancestor.getAttribute("dir");
70
- observer.observe(ancestor, {
77
+ for(let ancestor_0 = target; ancestor_0; ancestor_0 = getComposedParent(ancestor_0)){
78
+ const auto = "auto" === ancestor_0.getAttribute("dir");
79
+ observer.observe(ancestor_0, {
71
80
  attributes: true,
72
81
  attributeFilter: [
73
82
  "dir",
@@ -124,8 +133,8 @@ function useTaoToken() {
124
133
  } else t0 = $[0];
125
134
  return t0;
126
135
  }
127
- function TaoPortalScope(t0) {
128
- const $ = c(31);
136
+ const tao_provider_TaoPortalScope = /*#__PURE__*/ forwardRef(function(t0, ref) {
137
+ const $ = c(33);
129
138
  const { children, style, asChild, direction: directionProp } = t0;
130
139
  const config = useTaoInternalConfig();
131
140
  const { tokenStyle, mode, compact } = config;
@@ -171,8 +180,9 @@ function TaoPortalScope(t0) {
171
180
  $[9] = t4;
172
181
  } else t4 = $[9];
173
182
  let t5;
174
- if ($[10] !== children || $[11] !== densityAttr || $[12] !== direction || $[13] !== t4 || $[14] !== themeAttr) {
183
+ if ($[10] !== children || $[11] !== densityAttr || $[12] !== direction || $[13] !== ref || $[14] !== t4 || $[15] !== themeAttr) {
175
184
  t5 = /*#__PURE__*/ jsx(Slot, {
185
+ ref: ref,
176
186
  dir: direction,
177
187
  "data-tao-provider": "",
178
188
  ...themeAttr,
@@ -183,62 +193,66 @@ function TaoPortalScope(t0) {
183
193
  $[10] = children;
184
194
  $[11] = densityAttr;
185
195
  $[12] = direction;
186
- $[13] = t4;
187
- $[14] = themeAttr;
188
- $[15] = t5;
189
- } else t5 = $[15];
196
+ $[13] = ref;
197
+ $[14] = t4;
198
+ $[15] = themeAttr;
199
+ $[16] = t5;
200
+ } else t5 = $[16];
190
201
  let t6;
191
- if ($[16] !== portalConfig || $[17] !== t5) {
202
+ if ($[17] !== portalConfig || $[18] !== t5) {
192
203
  t6 = /*#__PURE__*/ jsx(TaoConfigContext.Provider, {
193
204
  value: portalConfig,
194
205
  children: t5
195
206
  });
196
- $[16] = portalConfig;
197
- $[17] = t5;
198
- $[18] = t6;
199
- } else t6 = $[18];
207
+ $[17] = portalConfig;
208
+ $[18] = t5;
209
+ $[19] = t6;
210
+ } else t6 = $[19];
200
211
  return t6;
201
212
  }
202
- let t4;
203
- if ($[19] !== style || $[20] !== tokenStyle) {
204
- t4 = {
213
+ const t4 = ref;
214
+ let t5;
215
+ if ($[20] !== style || $[21] !== tokenStyle) {
216
+ t5 = {
205
217
  display: "contents",
206
218
  ...tokenStyle,
207
219
  ...style
208
220
  };
209
- $[19] = style;
210
- $[20] = tokenStyle;
211
- $[21] = t4;
212
- } else t4 = $[21];
213
- let t5;
214
- if ($[22] !== children || $[23] !== densityAttr || $[24] !== direction || $[25] !== t4 || $[26] !== themeAttr) {
215
- t5 = /*#__PURE__*/ jsx("div", {
221
+ $[20] = style;
222
+ $[21] = tokenStyle;
223
+ $[22] = t5;
224
+ } else t5 = $[22];
225
+ let t6;
226
+ if ($[23] !== children || $[24] !== densityAttr || $[25] !== direction || $[26] !== t4 || $[27] !== t5 || $[28] !== themeAttr) {
227
+ t6 = /*#__PURE__*/ jsx("div", {
228
+ ref: t4,
216
229
  dir: direction,
217
230
  "data-tao-provider": "",
218
231
  ...themeAttr,
219
232
  ...densityAttr,
220
- style: t4,
233
+ style: t5,
221
234
  children: children
222
235
  });
223
- $[22] = children;
224
- $[23] = densityAttr;
225
- $[24] = direction;
226
- $[25] = t4;
227
- $[26] = themeAttr;
236
+ $[23] = children;
237
+ $[24] = densityAttr;
238
+ $[25] = direction;
239
+ $[26] = t4;
228
240
  $[27] = t5;
229
- } else t5 = $[27];
230
- let t6;
231
- if ($[28] !== portalConfig || $[29] !== t5) {
232
- t6 = /*#__PURE__*/ jsx(TaoConfigContext.Provider, {
241
+ $[28] = themeAttr;
242
+ $[29] = t6;
243
+ } else t6 = $[29];
244
+ let t7;
245
+ if ($[30] !== portalConfig || $[31] !== t6) {
246
+ t7 = /*#__PURE__*/ jsx(TaoConfigContext.Provider, {
233
247
  value: portalConfig,
234
- children: t5
248
+ children: t6
235
249
  });
236
- $[28] = portalConfig;
237
- $[29] = t5;
238
- $[30] = t6;
239
- } else t6 = $[30];
240
- return t6;
241
- }
250
+ $[30] = portalConfig;
251
+ $[31] = t6;
252
+ $[32] = t7;
253
+ } else t7 = $[32];
254
+ return t7;
255
+ });
242
256
  const TOKEN_TO_VAR = {
243
257
  colorPrimary: '--tao-color-primary',
244
258
  colorSuccess: '--tao-color-success',
@@ -485,4 +499,4 @@ function TaoProvider(t0) {
485
499
  } else t12 = $[36];
486
500
  return t12;
487
501
  }
488
- export { TaoPortalScope, TaoProvider, enUS, useTaoConfig, useTaoDirection, useTaoInternalConfig, useTaoToken, zhCN };
502
+ export { TaoProvider, enUS, tao_provider_TaoPortalScope as TaoPortalScope, useTaoConfig, useTaoDirection, useTaoInternalConfig, useTaoToken, zhCN };
@@ -47,7 +47,7 @@
47
47
  }
48
48
 
49
49
  [data-tao-control][data-tao-variant="outlined"][data-tao-warning]:hover:not([data-disabled]):not(:focus-within) {
50
- border-color: color-mix(in oklch, var(--tao-color-warning) 80%, white);
50
+ border-color: color-mix(in oklab, var(--tao-color-warning) 80%, white);
51
51
  }
52
52
 
53
53
  [data-tao-control][data-tao-variant="outlined"][data-tao-warning]:focus-within, [data-tao-control][data-tao-variant="outlined"][data-tao-warning][data-state="open"] {
@@ -134,6 +134,10 @@
134
134
  border-block-end-color: var(--tao-error);
135
135
  }
136
136
 
137
+ [data-tao-control][data-tao-variant="borderless"][data-tao-warning] {
138
+ border-block-end-color: var(--tao-warning);
139
+ }
140
+
137
141
  [data-tao-control][data-tao-variant="borderless"][data-disabled], [data-tao-control][data-tao-variant="borderless"]:has(input:disabled) {
138
142
  color: var(--tao-color-text-disabled);
139
143
  cursor: not-allowed;
@@ -47,8 +47,8 @@
47
47
  var(--tao-color-bg-base));
48
48
  --tao-primary-fg: var(--tao-color-bg-base);
49
49
  --tao-error: var(--tao-color-error);
50
- --tao-error-hover: color-mix(in oklch, var(--tao-color-error) 80%, white);
51
- --tao-error-active: color-mix(in oklch, var(--tao-color-error) 90%, black);
50
+ --tao-error-hover: color-mix(in oklab, var(--tao-color-error) 80%, white);
51
+ --tao-error-active: color-mix(in oklab, var(--tao-color-error) 90%, black);
52
52
  --tao-error-bg: color-mix(in oklab,
53
53
  var(--tao-color-error) 6%,
54
54
  var(--tao-color-bg-base));
@@ -0,0 +1 @@
1
+ export declare function getComposedParent(element: Element): Element | null;
@@ -0,0 +1,7 @@
1
+ function getComposedParent(element) {
2
+ if (element.assignedSlot) return element.assignedSlot;
3
+ if (element.parentElement) return element.parentElement;
4
+ const root = element.getRootNode();
5
+ return 'host' in root ? root.host : null;
6
+ }
7
+ export { getComposedParent };
@@ -2,3 +2,8 @@
2
2
  export declare function preventParentOutsideDismiss(event: {
3
3
  preventDefault: () => void;
4
4
  }): void;
5
+ /**
6
+ * Dialogs see Escape first (document capture). An expanded combobox inside
7
+ * them owns that key: it closes its popup and leaves the dialog open.
8
+ */
9
+ export declare function isEscapeForOpenCombobox(event: KeyboardEvent): boolean;
@@ -1,4 +1,10 @@
1
1
  function preventParentOutsideDismiss(event) {
2
2
  event.preventDefault();
3
3
  }
4
- export { preventParentOutsideDismiss };
4
+ function isEscapeForOpenCombobox(event) {
5
+ const target = event.target;
6
+ if (!(target instanceof Element) || 'true' !== target.getAttribute('aria-expanded')) return false;
7
+ const popup = target.getAttribute('aria-haspopup');
8
+ return 'combobox' === target.getAttribute('role') || null != popup && 'false' !== popup;
9
+ }
10
+ export { isEscapeForOpenCombobox, preventParentOutsideDismiss };
@@ -1,2 +1,4 @@
1
- import type { Ref } from 'react';
1
+ import { type Ref } from 'react';
2
+ /** Timers and document listeners only see values from committed renders. */
3
+ export declare function useCommittedRef<T>(value: T): import("react").RefObject<T>;
2
4
  export declare function mergeRefs<T>(...refs: Array<Ref<T> | undefined>): (value: T | null) => void;
@@ -1,3 +1,27 @@
1
+ import { c } from "react-compiler-runtime";
2
+ import { useLayoutEffect, useRef } from "react";
3
+ function useCommittedRef(value) {
4
+ const $ = c(3);
5
+ const ref = useRef(value);
6
+ let t0;
7
+ let t1;
8
+ if ($[0] !== value) {
9
+ t0 = ()=>{
10
+ ref.current = value;
11
+ };
12
+ t1 = [
13
+ value
14
+ ];
15
+ $[0] = value;
16
+ $[1] = t0;
17
+ $[2] = t1;
18
+ } else {
19
+ t0 = $[1];
20
+ t1 = $[2];
21
+ }
22
+ useLayoutEffect(t0, t1);
23
+ return ref;
24
+ }
1
25
  function mergeRefs(...refs) {
2
26
  let cleanups = [];
3
27
  return (value)=>{
@@ -19,4 +43,4 @@ function mergeRefs(...refs) {
19
43
  }
20
44
  };
21
45
  }
22
- export { mergeRefs };
46
+ export { mergeRefs, useCommittedRef };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rockshin/tao-ui",
3
- "version": "0.0.58",
3
+ "version": "0.0.60",
4
4
  "type": "module",
5
5
  "description": "A modern React component library with semantic DOM customization and OKLCH-based theming.",
6
6
  "keywords": [