@rockshin/tao-ui 0.0.58 → 0.0.59

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 (93) 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 +17 -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.js +383 -360
  11. package/dist/components/date-picker/calendar/calendar-grid.d.ts +5 -3
  12. package/dist/components/date-picker/calendar/calendar-grid.js +9 -4
  13. package/dist/components/date-picker/calendar/month-grid.d.ts +2 -1
  14. package/dist/components/date-picker/calendar/month-grid.js +61 -45
  15. package/dist/components/date-picker/calendar/time-panel.d.ts +8 -1
  16. package/dist/components/date-picker/calendar/time-panel.js +89 -88
  17. package/dist/components/date-picker/calendar/year-grid.d.ts +2 -1
  18. package/dist/components/date-picker/calendar/year-grid.js +60 -44
  19. package/dist/components/date-picker/date-picker.css +9 -0
  20. package/dist/components/date-picker/date-picker.js +22 -13
  21. package/dist/components/date-picker/range-picker.d.ts +2 -0
  22. package/dist/components/date-picker/range-picker.js +127 -70
  23. package/dist/components/date-picker/types.js +1 -1
  24. package/dist/components/drawer/drawer.d.ts +1 -1
  25. package/dist/components/drawer/drawer.js +4 -3
  26. package/dist/components/dropdown/dropdown.js +11 -9
  27. package/dist/components/float-button/float-button.js +4 -4
  28. package/dist/components/form/form-item.d.ts +1 -1
  29. package/dist/components/form/form-item.js +160 -120
  30. package/dist/components/form-field/form-field-view.d.ts +2 -1
  31. package/dist/components/form-field/form-field-view.js +173 -108
  32. package/dist/components/input/input-shared.js +3 -2
  33. package/dist/components/input/otp.js +114 -110
  34. package/dist/components/input/password.js +55 -61
  35. package/dist/components/input/search.js +8 -4
  36. package/dist/components/mentions/mentions.js +1 -0
  37. package/dist/components/menu/menu-render.js +1 -0
  38. package/dist/components/modal/confirm-dialog.js +11 -4
  39. package/dist/components/modal/modal.js +320 -315
  40. package/dist/components/pagination/pagination.d.ts +1 -0
  41. package/dist/components/pagination/pagination.js +1 -0
  42. package/dist/components/popover/popover.js +325 -289
  43. package/dist/components/qr-code/qr-code.js +157 -150
  44. package/dist/components/radio/radio.d.ts +3 -1
  45. package/dist/components/radio/radio.js +73 -64
  46. package/dist/components/select/mobile-select.js +6 -3
  47. package/dist/components/select/select-model.js +2 -2
  48. package/dist/components/select/select.js +78 -39
  49. package/dist/components/select/use-select-selection.js +58 -58
  50. package/dist/components/slider/slider.d.ts +2 -2
  51. package/dist/components/slider/slider.js +13 -2
  52. package/dist/components/sonner/sonner.js +2 -2
  53. package/dist/components/splitter/splitter.css +1 -0
  54. package/dist/components/splitter/splitter.js +152 -126
  55. package/dist/components/switch/switch.js +45 -39
  56. package/dist/components/table/table.js +1 -0
  57. package/dist/components/table/use-table-data.js +2 -2
  58. package/dist/components/time-picker/time-picker.js +31 -1
  59. package/dist/components/tooltip/tooltip.js +237 -99
  60. package/dist/components/tree/tree.js +31 -3
  61. package/dist/components/tree-select/tree-select.js +1 -1
  62. package/dist/components/upload/upload.js +67 -40
  63. package/dist/locales/ar-EG.js +2 -0
  64. package/dist/locales/de-DE.js +2 -0
  65. package/dist/locales/en-US.js +2 -0
  66. package/dist/locales/es-ES.js +2 -0
  67. package/dist/locales/fr-FR.js +2 -0
  68. package/dist/locales/hi-IN.js +2 -0
  69. package/dist/locales/id-ID.js +2 -0
  70. package/dist/locales/it-IT.js +2 -0
  71. package/dist/locales/ja-JP.js +2 -0
  72. package/dist/locales/ko-KR.js +2 -0
  73. package/dist/locales/pt-BR.js +2 -0
  74. package/dist/locales/ru-RU.js +2 -0
  75. package/dist/locales/th-TH.js +2 -0
  76. package/dist/locales/tr-TR.js +2 -0
  77. package/dist/locales/types.d.ts +2 -0
  78. package/dist/locales/vi-VN.js +2 -0
  79. package/dist/locales/zh-CN.js +2 -0
  80. package/dist/locales/zh-TW.js +2 -0
  81. package/dist/number-input/format.js +1 -1
  82. package/dist/number-input/use-number-input.js +166 -321
  83. package/dist/number-input/validate.d.ts +1 -0
  84. package/dist/number-input/validate.js +1 -1
  85. package/dist/provider/tao-provider.d.ts +2 -2
  86. package/dist/provider/tao-provider.js +49 -49
  87. package/dist/utils/composed-parent.d.ts +1 -0
  88. package/dist/utils/composed-parent.js +7 -0
  89. package/dist/utils/portal.d.ts +5 -0
  90. package/dist/utils/portal.js +7 -1
  91. package/dist/utils/refs.d.ts +3 -1
  92. package/dist/utils/refs.js +25 -1
  93. 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,12 +55,12 @@ 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
61
  const value = getComputedStyle(target).direction || target.closest("[dir]")?.getAttribute("dir") || contextDirection;
67
62
  setInherited("rtl" === value ? "rtl" : "ltr");
68
- for(let ancestor = target; ancestor; ancestor = directionParent(ancestor)){
63
+ for(let ancestor = target; ancestor; ancestor = getComposedParent(ancestor)){
69
64
  const auto = "auto" === ancestor.getAttribute("dir");
70
65
  observer.observe(ancestor, {
71
66
  attributes: true,
@@ -124,8 +119,8 @@ function useTaoToken() {
124
119
  } else t0 = $[0];
125
120
  return t0;
126
121
  }
127
- function TaoPortalScope(t0) {
128
- const $ = c(31);
122
+ const tao_provider_TaoPortalScope = /*#__PURE__*/ forwardRef(function(t0, ref) {
123
+ const $ = c(33);
129
124
  const { children, style, asChild, direction: directionProp } = t0;
130
125
  const config = useTaoInternalConfig();
131
126
  const { tokenStyle, mode, compact } = config;
@@ -171,8 +166,9 @@ function TaoPortalScope(t0) {
171
166
  $[9] = t4;
172
167
  } else t4 = $[9];
173
168
  let t5;
174
- if ($[10] !== children || $[11] !== densityAttr || $[12] !== direction || $[13] !== t4 || $[14] !== themeAttr) {
169
+ if ($[10] !== children || $[11] !== densityAttr || $[12] !== direction || $[13] !== ref || $[14] !== t4 || $[15] !== themeAttr) {
175
170
  t5 = /*#__PURE__*/ jsx(Slot, {
171
+ ref: ref,
176
172
  dir: direction,
177
173
  "data-tao-provider": "",
178
174
  ...themeAttr,
@@ -183,62 +179,66 @@ function TaoPortalScope(t0) {
183
179
  $[10] = children;
184
180
  $[11] = densityAttr;
185
181
  $[12] = direction;
186
- $[13] = t4;
187
- $[14] = themeAttr;
188
- $[15] = t5;
189
- } else t5 = $[15];
182
+ $[13] = ref;
183
+ $[14] = t4;
184
+ $[15] = themeAttr;
185
+ $[16] = t5;
186
+ } else t5 = $[16];
190
187
  let t6;
191
- if ($[16] !== portalConfig || $[17] !== t5) {
188
+ if ($[17] !== portalConfig || $[18] !== t5) {
192
189
  t6 = /*#__PURE__*/ jsx(TaoConfigContext.Provider, {
193
190
  value: portalConfig,
194
191
  children: t5
195
192
  });
196
- $[16] = portalConfig;
197
- $[17] = t5;
198
- $[18] = t6;
199
- } else t6 = $[18];
193
+ $[17] = portalConfig;
194
+ $[18] = t5;
195
+ $[19] = t6;
196
+ } else t6 = $[19];
200
197
  return t6;
201
198
  }
202
- let t4;
203
- if ($[19] !== style || $[20] !== tokenStyle) {
204
- t4 = {
199
+ const t4 = ref;
200
+ let t5;
201
+ if ($[20] !== style || $[21] !== tokenStyle) {
202
+ t5 = {
205
203
  display: "contents",
206
204
  ...tokenStyle,
207
205
  ...style
208
206
  };
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", {
207
+ $[20] = style;
208
+ $[21] = tokenStyle;
209
+ $[22] = t5;
210
+ } else t5 = $[22];
211
+ let t6;
212
+ if ($[23] !== children || $[24] !== densityAttr || $[25] !== direction || $[26] !== t4 || $[27] !== t5 || $[28] !== themeAttr) {
213
+ t6 = /*#__PURE__*/ jsx("div", {
214
+ ref: t4,
216
215
  dir: direction,
217
216
  "data-tao-provider": "",
218
217
  ...themeAttr,
219
218
  ...densityAttr,
220
- style: t4,
219
+ style: t5,
221
220
  children: children
222
221
  });
223
- $[22] = children;
224
- $[23] = densityAttr;
225
- $[24] = direction;
226
- $[25] = t4;
227
- $[26] = themeAttr;
222
+ $[23] = children;
223
+ $[24] = densityAttr;
224
+ $[25] = direction;
225
+ $[26] = t4;
228
226
  $[27] = t5;
229
- } else t5 = $[27];
230
- let t6;
231
- if ($[28] !== portalConfig || $[29] !== t5) {
232
- t6 = /*#__PURE__*/ jsx(TaoConfigContext.Provider, {
227
+ $[28] = themeAttr;
228
+ $[29] = t6;
229
+ } else t6 = $[29];
230
+ let t7;
231
+ if ($[30] !== portalConfig || $[31] !== t6) {
232
+ t7 = /*#__PURE__*/ jsx(TaoConfigContext.Provider, {
233
233
  value: portalConfig,
234
- children: t5
234
+ children: t6
235
235
  });
236
- $[28] = portalConfig;
237
- $[29] = t5;
238
- $[30] = t6;
239
- } else t6 = $[30];
240
- return t6;
241
- }
236
+ $[30] = portalConfig;
237
+ $[31] = t6;
238
+ $[32] = t7;
239
+ } else t7 = $[32];
240
+ return t7;
241
+ });
242
242
  const TOKEN_TO_VAR = {
243
243
  colorPrimary: '--tao-color-primary',
244
244
  colorSuccess: '--tao-color-success',
@@ -485,4 +485,4 @@ function TaoProvider(t0) {
485
485
  } else t12 = $[36];
486
486
  return t12;
487
487
  }
488
- export { TaoPortalScope, TaoProvider, enUS, useTaoConfig, useTaoDirection, useTaoInternalConfig, useTaoToken, zhCN };
488
+ export { TaoProvider, enUS, tao_provider_TaoPortalScope as TaoPortalScope, useTaoConfig, useTaoDirection, useTaoInternalConfig, useTaoToken, zhCN };
@@ -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.59",
4
4
  "type": "module",
5
5
  "description": "A modern React component library with semantic DOM customization and OKLCH-based theming.",
6
6
  "keywords": [