@rockshin/tao-ui 0.0.44 → 0.0.45

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 (63) hide show
  1. package/README.md +6 -0
  2. package/component-manifest.json +7 -2
  3. package/dist/components/auto-complete/auto-complete.js +12 -3
  4. package/dist/components/breadcrumb/breadcrumb.css +4 -0
  5. package/dist/components/breadcrumb/breadcrumb.js +1 -0
  6. package/dist/components/calendar/calendar.d.ts +1 -0
  7. package/dist/components/calendar/calendar.js +10 -3
  8. package/dist/components/card/card-tabs.js +204 -182
  9. package/dist/components/card/card.js +1 -1
  10. package/dist/components/carousel/carousel.js +11 -5
  11. package/dist/components/cascader/cascader.js +16 -4
  12. package/dist/components/collapse/collapse.css +8 -0
  13. package/dist/components/context-menu/context-menu.d.ts +2 -1
  14. package/dist/components/context-menu/context-menu.js +57 -44
  15. package/dist/components/date-picker/calendar/calendar-grid.js +3 -2
  16. package/dist/components/date-picker/date-picker.css +4 -0
  17. package/dist/components/date-picker/date-picker.d.ts +1 -0
  18. package/dist/components/date-picker/date-picker.js +13 -3
  19. package/dist/components/date-picker/range-picker.d.ts +1 -0
  20. package/dist/components/date-picker/range-picker.js +13 -3
  21. package/dist/components/drawer/drawer.d.ts +2 -1
  22. package/dist/components/drawer/drawer.js +32 -20
  23. package/dist/components/dropdown/dropdown.d.ts +1 -0
  24. package/dist/components/dropdown/dropdown.js +139 -123
  25. package/dist/components/mentions/mentions.js +6 -2
  26. package/dist/components/modal/modal.d.ts +2 -1
  27. package/dist/components/modal/modal.js +14 -4
  28. package/dist/components/pagination/pagination.css +4 -0
  29. package/dist/components/popover/popover.d.ts +2 -1
  30. package/dist/components/popover/popover.js +185 -176
  31. package/dist/components/rate/rate.js +114 -88
  32. package/dist/components/scroll-area/scroll-area.js +127 -118
  33. package/dist/components/segmented/segmented.js +52 -29
  34. package/dist/components/select/mobile-select.d.ts +2 -1
  35. package/dist/components/select/mobile-select.js +52 -47
  36. package/dist/components/select/select-types.d.ts +1 -0
  37. package/dist/components/select/select.js +19 -6
  38. package/dist/components/slider/slider.js +136 -133
  39. package/dist/components/splitter/splitter.css +4 -0
  40. package/dist/components/splitter/splitter.js +5 -3
  41. package/dist/components/table/table.css +29 -11
  42. package/dist/components/table/table.js +383 -547
  43. package/dist/components/tabs/tabs.js +3 -2
  44. package/dist/components/time-picker/time-picker.js +21 -7
  45. package/dist/components/tooltip/tooltip.d.ts +2 -1
  46. package/dist/components/tooltip/tooltip.js +82 -71
  47. package/dist/components/transfer/transfer-parts.js +12 -2
  48. package/dist/components/transfer/transfer.js +10 -4
  49. package/dist/components/tree/tree-keyboard.d.ts +6 -0
  50. package/dist/components/tree/tree-keyboard.js +27 -0
  51. package/dist/components/tree/tree.js +14 -3
  52. package/dist/components/tree-select/select-engine.d.ts +2 -1
  53. package/dist/components/tree-select/select-engine.js +23 -15
  54. package/dist/components/tree-select/tree-select.js +20 -10
  55. package/dist/docs/components/tao-provider.doc.js +6 -1
  56. package/dist/entries/provider.d.ts +1 -1
  57. package/dist/index.d.ts +1 -1
  58. package/dist/provider/tao-provider.d.ts +10 -3
  59. package/dist/provider/tao-provider.js +198 -88
  60. package/dist/utils/scroll-left.d.ts +3 -0
  61. package/dist/utils/scroll-left.js +7 -0
  62. package/llms.txt +2 -2
  63. package/package.json +1 -1
@@ -1,10 +1,12 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { c } from "react-compiler-runtime";
3
3
  import { useEffect, useRef, useState } from "react";
4
+ import { useTaoDirection } from "../../provider/tao-provider.js";
5
+ import { getScrollLeft, setScrollLeft } from "../../utils/scroll-left.js";
4
6
  import { cx } from "../../utils/semantic.js";
5
7
  import "./scroll-area.css";
6
8
  function ScrollArea(t0) {
7
- const $ = c(76);
9
+ const $ = c(80);
8
10
  const { children, type: t1, direction: t2, maxHeight, maxWidth, scrollbarSize: t3, scrollbarOffset: t4, scrollShadow: t5, onScroll: onScrollProp, onScrollEnd, scrollEndThreshold: t6, className, style, classNames, styles } = t0;
9
11
  const type = void 0 === t1 ? "hover" : t1;
10
12
  const direction = void 0 === t2 ? "vertical" : t2;
@@ -30,12 +32,14 @@ function ScrollArea(t0) {
30
32
  $[0] = t7;
31
33
  } else t7 = $[0];
32
34
  const [scrollState, setScrollState] = useState(t7);
35
+ const [textDirection, directionRef] = useTaoDirection(void 0, "self");
33
36
  let t8;
34
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
37
+ if ($[1] !== textDirection) {
35
38
  t8 = ()=>{
36
39
  const el = viewportRef.current;
37
40
  if (!el) return;
38
- const { scrollTop, scrollLeft, scrollHeight, scrollWidth, clientHeight, clientWidth } = el;
41
+ const { scrollTop, scrollHeight, scrollWidth, clientHeight, clientWidth } = el;
42
+ const scrollLeft = getScrollLeft(el, getComputedStyle(el).direction || textDirection);
39
43
  const hasV = scrollHeight > clientHeight + 1;
40
44
  const hasH = scrollWidth > clientWidth + 1;
41
45
  setScrollState({
@@ -51,12 +55,13 @@ function ScrollArea(t0) {
51
55
  atRight: scrollLeft + clientWidth >= scrollWidth - 1
52
56
  });
53
57
  };
54
- $[1] = t8;
55
- } else t8 = $[1];
58
+ $[1] = textDirection;
59
+ $[2] = t8;
60
+ } else t8 = $[2];
56
61
  const updateScrollState = t8;
57
62
  let t10;
58
63
  let t9;
59
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
64
+ if ($[3] !== updateScrollState) {
60
65
  t9 = ()=>{
61
66
  const el_0 = viewportRef.current;
62
67
  if (!el_0) return;
@@ -69,16 +74,17 @@ function ScrollArea(t0) {
69
74
  t10 = [
70
75
  updateScrollState
71
76
  ];
72
- $[2] = t10;
73
- $[3] = t9;
77
+ $[3] = updateScrollState;
78
+ $[4] = t10;
79
+ $[5] = t9;
74
80
  } else {
75
- t10 = $[2];
76
- t9 = $[3];
81
+ t10 = $[4];
82
+ t9 = $[5];
77
83
  }
78
84
  useEffect(t9, t10);
79
85
  const firedScrollEnd = useRef(false);
80
86
  let t11;
81
- if ($[4] !== onScrollEnd || $[5] !== onScrollProp || $[6] !== scrollEndThreshold) {
87
+ if ($[6] !== onScrollEnd || $[7] !== onScrollProp || $[8] !== scrollEndThreshold || $[9] !== updateScrollState) {
82
88
  t11 = (e)=>{
83
89
  updateScrollState();
84
90
  onScrollProp?.(e);
@@ -92,27 +98,28 @@ function ScrollArea(t0) {
92
98
  } else if (!nearBottom) firedScrollEnd.current = false;
93
99
  }
94
100
  };
95
- $[4] = onScrollEnd;
96
- $[5] = onScrollProp;
97
- $[6] = scrollEndThreshold;
98
- $[7] = t11;
99
- } else t11 = $[7];
101
+ $[6] = onScrollEnd;
102
+ $[7] = onScrollProp;
103
+ $[8] = scrollEndThreshold;
104
+ $[9] = updateScrollState;
105
+ $[10] = t11;
106
+ } else t11 = $[10];
100
107
  const handleScroll = t11;
101
108
  const dragCleanup = useRef(null);
102
109
  let t12;
103
110
  let t13;
104
- if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
111
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
105
112
  t12 = ()=>()=>dragCleanup.current?.();
106
113
  t13 = [];
107
- $[8] = t12;
108
- $[9] = t13;
114
+ $[11] = t12;
115
+ $[12] = t13;
109
116
  } else {
110
- t12 = $[8];
111
- t13 = $[9];
117
+ t12 = $[11];
118
+ t13 = $[12];
112
119
  }
113
120
  useEffect(t12, t13);
114
121
  let t14;
115
- if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
122
+ if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
116
123
  t14 = (axis, e_0)=>{
117
124
  e_0.preventDefault();
118
125
  e_0.stopPropagation();
@@ -123,7 +130,7 @@ function ScrollArea(t0) {
123
130
  const track = thumb.parentElement;
124
131
  if (!track) return;
125
132
  const pos = "y" === axis ? e_0.clientY : e_0.clientX;
126
- const scroll = "y" === axis ? el_2.scrollTop : el_2.scrollLeft;
133
+ const scroll = "y" === axis ? el_2.scrollTop : getScrollLeft(el_2);
127
134
  const pointerId = e_0.pointerId;
128
135
  const handleMove = (ev)=>{
129
136
  if (ev.pointerId !== pointerId || !viewportRef.current) return;
@@ -136,7 +143,7 @@ function ScrollArea(t0) {
136
143
  if (travel <= 0 || maxScroll <= 0) return;
137
144
  const nextScroll = Math.max(0, Math.min(maxScroll, scroll + delta / travel * maxScroll));
138
145
  if ("y" === axis) vp.scrollTop = nextScroll;
139
- else vp.scrollLeft = nextScroll;
146
+ else setScrollLeft(vp, nextScroll);
140
147
  };
141
148
  const cleanup = ()=>{
142
149
  document.removeEventListener("pointermove", handleMove);
@@ -152,11 +159,11 @@ function ScrollArea(t0) {
152
159
  document.addEventListener("pointerup", handleEnd);
153
160
  document.addEventListener("pointercancel", handleEnd);
154
161
  };
155
- $[10] = t14;
156
- } else t14 = $[10];
162
+ $[13] = t14;
163
+ } else t14 = $[13];
157
164
  const handleThumbPointerDown = t14;
158
165
  let t15;
159
- if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
166
+ if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
160
167
  t15 = (axis_0, e_1)=>{
161
168
  const el_3 = viewportRef.current;
162
169
  if (!el_3) return;
@@ -164,89 +171,89 @@ function ScrollArea(t0) {
164
171
  const rect = e_1.currentTarget.getBoundingClientRect();
165
172
  const clickPos = "y" === axis_0 ? (e_1.clientY - rect.top) / rect.height : (e_1.clientX - rect.left) / rect.width;
166
173
  if ("y" === axis_0) el_3.scrollTop = clickPos * (el_3.scrollHeight - el_3.clientHeight);
167
- else el_3.scrollLeft = clickPos * (el_3.scrollWidth - el_3.clientWidth);
174
+ else setScrollLeft(el_3, clickPos * (el_3.scrollWidth - el_3.clientWidth));
168
175
  };
169
- $[11] = t15;
170
- } else t15 = $[11];
176
+ $[14] = t15;
177
+ } else t15 = $[14];
171
178
  const handleTrackClick = t15;
172
179
  const showVertical = "vertical" === direction || "both" === direction;
173
180
  const showHorizontal = "horizontal" === direction || "both" === direction;
174
181
  const t16 = maxHeight ?? void 0;
175
182
  const t17 = maxWidth ?? void 0;
176
183
  let t18;
177
- if ($[12] !== t16 || $[13] !== t17) {
184
+ if ($[15] !== t16 || $[16] !== t17) {
178
185
  t18 = {
179
186
  maxHeight: t16,
180
187
  maxWidth: t17
181
188
  };
182
- $[12] = t16;
183
- $[13] = t17;
184
- $[14] = t18;
185
- } else t18 = $[14];
189
+ $[15] = t16;
190
+ $[16] = t17;
191
+ $[17] = t18;
192
+ } else t18 = $[17];
186
193
  const rootStyle = t18;
187
194
  const t19 = showVertical ? "scroll" : "hidden";
188
195
  const t20 = showHorizontal ? "scroll" : "hidden";
189
196
  const t21 = styles?.viewport;
190
197
  let t22;
191
- if ($[15] !== t19 || $[16] !== t20 || $[17] !== t21) {
198
+ if ($[18] !== t19 || $[19] !== t20 || $[20] !== t21) {
192
199
  t22 = {
193
200
  overflowY: t19,
194
201
  overflowX: t20,
195
202
  ...t21
196
203
  };
197
- $[15] = t19;
198
- $[16] = t20;
199
- $[17] = t21;
200
- $[18] = t22;
201
- } else t22 = $[18];
204
+ $[18] = t19;
205
+ $[19] = t20;
206
+ $[20] = t21;
207
+ $[21] = t22;
208
+ } else t22 = $[21];
202
209
  const viewportStyle = t22;
203
210
  const t23 = `${scrollbarSize}px`;
204
211
  const t24 = `${scrollbarOffset}px`;
205
212
  let t25;
206
- if ($[19] !== t23 || $[20] !== t24) {
213
+ if ($[22] !== t23 || $[23] !== t24) {
207
214
  t25 = {
208
215
  "--tao-scrollbar-size": t23,
209
216
  "--tao-scrollbar-offset": t24
210
217
  };
211
- $[19] = t23;
212
- $[20] = t24;
213
- $[21] = t25;
214
- } else t25 = $[21];
218
+ $[22] = t23;
219
+ $[23] = t24;
220
+ $[24] = t25;
221
+ } else t25 = $[24];
215
222
  const scrollbarVars = t25;
216
223
  const t26 = scrollState.hasVertical || void 0;
217
224
  const t27 = scrollState.hasHorizontal || void 0;
218
225
  const t28 = classNames?.root;
219
226
  let t29;
220
- if ($[22] !== className || $[23] !== t28) {
227
+ if ($[25] !== className || $[26] !== t28) {
221
228
  t29 = cx(t28, className);
222
- $[22] = className;
223
- $[23] = t28;
224
- $[24] = t29;
225
- } else t29 = $[24];
229
+ $[25] = className;
230
+ $[26] = t28;
231
+ $[27] = t29;
232
+ } else t29 = $[27];
226
233
  const t30 = styles?.root;
227
234
  let t31;
228
- if ($[25] !== rootStyle || $[26] !== scrollbarVars || $[27] !== style || $[28] !== t30) {
235
+ if ($[28] !== rootStyle || $[29] !== scrollbarVars || $[30] !== style || $[31] !== t30) {
229
236
  t31 = {
230
237
  ...rootStyle,
231
238
  ...scrollbarVars,
232
239
  ...t30,
233
240
  ...style
234
241
  };
235
- $[25] = rootStyle;
236
- $[26] = scrollbarVars;
237
- $[27] = style;
238
- $[28] = t30;
239
- $[29] = t31;
240
- } else t31 = $[29];
242
+ $[28] = rootStyle;
243
+ $[29] = scrollbarVars;
244
+ $[30] = style;
245
+ $[31] = t30;
246
+ $[32] = t31;
247
+ } else t31 = $[32];
241
248
  const t32 = classNames?.viewport;
242
249
  let t33;
243
- if ($[30] !== t32) {
250
+ if ($[33] !== t32) {
244
251
  t33 = cx(t32);
245
- $[30] = t32;
246
- $[31] = t33;
247
- } else t33 = $[31];
252
+ $[33] = t32;
253
+ $[34] = t33;
254
+ } else t33 = $[34];
248
255
  let t34;
249
- if ($[32] !== children || $[33] !== handleScroll || $[34] !== t33 || $[35] !== viewportStyle) {
256
+ if ($[35] !== children || $[36] !== handleScroll || $[37] !== t33 || $[38] !== viewportStyle) {
250
257
  t34 = /*#__PURE__*/ jsx("div", {
251
258
  ref: viewportRef,
252
259
  "data-tao-scroll-viewport": "",
@@ -255,14 +262,14 @@ function ScrollArea(t0) {
255
262
  onScroll: handleScroll,
256
263
  children: children
257
264
  });
258
- $[32] = children;
259
- $[33] = handleScroll;
260
- $[34] = t33;
261
- $[35] = viewportStyle;
262
- $[36] = t34;
263
- } else t34 = $[36];
265
+ $[35] = children;
266
+ $[36] = handleScroll;
267
+ $[37] = t33;
268
+ $[38] = viewportStyle;
269
+ $[39] = t34;
270
+ } else t34 = $[39];
264
271
  let t35;
265
- if ($[37] !== scrollShadow || $[38] !== scrollState.atBottom || $[39] !== scrollState.atTop || $[40] !== showVertical) {
272
+ if ($[40] !== scrollShadow || $[41] !== scrollState.atBottom || $[42] !== scrollState.atTop || $[43] !== showVertical) {
266
273
  t35 = scrollShadow && showVertical && /*#__PURE__*/ jsxs(Fragment, {
267
274
  children: [
268
275
  /*#__PURE__*/ jsx("div", {
@@ -275,14 +282,14 @@ function ScrollArea(t0) {
275
282
  })
276
283
  ]
277
284
  });
278
- $[37] = scrollShadow;
279
- $[38] = scrollState.atBottom;
280
- $[39] = scrollState.atTop;
281
- $[40] = showVertical;
282
- $[41] = t35;
283
- } else t35 = $[41];
285
+ $[40] = scrollShadow;
286
+ $[41] = scrollState.atBottom;
287
+ $[42] = scrollState.atTop;
288
+ $[43] = showVertical;
289
+ $[44] = t35;
290
+ } else t35 = $[44];
284
291
  let t36;
285
- if ($[42] !== scrollShadow || $[43] !== scrollState.atLeft || $[44] !== scrollState.atRight || $[45] !== showHorizontal) {
292
+ if ($[45] !== scrollShadow || $[46] !== scrollState.atLeft || $[47] !== scrollState.atRight || $[48] !== showHorizontal) {
286
293
  t36 = scrollShadow && showHorizontal && /*#__PURE__*/ jsxs(Fragment, {
287
294
  children: [
288
295
  /*#__PURE__*/ jsx("div", {
@@ -295,14 +302,14 @@ function ScrollArea(t0) {
295
302
  })
296
303
  ]
297
304
  });
298
- $[42] = scrollShadow;
299
- $[43] = scrollState.atLeft;
300
- $[44] = scrollState.atRight;
301
- $[45] = showHorizontal;
302
- $[46] = t36;
303
- } else t36 = $[46];
305
+ $[45] = scrollShadow;
306
+ $[46] = scrollState.atLeft;
307
+ $[47] = scrollState.atRight;
308
+ $[48] = showHorizontal;
309
+ $[49] = t36;
310
+ } else t36 = $[49];
304
311
  let t37;
305
- if ($[47] !== classNames?.scrollbar || $[48] !== classNames?.thumb || $[49] !== scrollState.hasVertical || $[50] !== scrollState.thumbYOffset || $[51] !== scrollState.thumbYRatio || $[52] !== showVertical || $[53] !== styles?.scrollbar || $[54] !== styles?.thumb) {
312
+ if ($[50] !== classNames?.scrollbar || $[51] !== classNames?.thumb || $[52] !== scrollState.hasVertical || $[53] !== scrollState.thumbYOffset || $[54] !== scrollState.thumbYRatio || $[55] !== showVertical || $[56] !== styles?.scrollbar || $[57] !== styles?.thumb) {
306
313
  t37 = showVertical && scrollState.hasVertical && /*#__PURE__*/ jsx("button", {
307
314
  type: "button",
308
315
  "data-tao-scrollbar": "",
@@ -324,18 +331,18 @@ function ScrollArea(t0) {
324
331
  onPointerDown: (e_3)=>handleThumbPointerDown("y", e_3)
325
332
  })
326
333
  });
327
- $[47] = classNames?.scrollbar;
328
- $[48] = classNames?.thumb;
329
- $[49] = scrollState.hasVertical;
330
- $[50] = scrollState.thumbYOffset;
331
- $[51] = scrollState.thumbYRatio;
332
- $[52] = showVertical;
333
- $[53] = styles?.scrollbar;
334
- $[54] = styles?.thumb;
335
- $[55] = t37;
336
- } else t37 = $[55];
334
+ $[50] = classNames?.scrollbar;
335
+ $[51] = classNames?.thumb;
336
+ $[52] = scrollState.hasVertical;
337
+ $[53] = scrollState.thumbYOffset;
338
+ $[54] = scrollState.thumbYRatio;
339
+ $[55] = showVertical;
340
+ $[56] = styles?.scrollbar;
341
+ $[57] = styles?.thumb;
342
+ $[58] = t37;
343
+ } else t37 = $[58];
337
344
  let t38;
338
- if ($[56] !== classNames?.scrollbar || $[57] !== classNames?.thumb || $[58] !== scrollState.hasHorizontal || $[59] !== scrollState.thumbXOffset || $[60] !== scrollState.thumbXRatio || $[61] !== showHorizontal || $[62] !== styles?.scrollbar || $[63] !== styles?.thumb) {
345
+ if ($[59] !== classNames?.scrollbar || $[60] !== classNames?.thumb || $[61] !== scrollState.hasHorizontal || $[62] !== scrollState.thumbXOffset || $[63] !== scrollState.thumbXRatio || $[64] !== showHorizontal || $[65] !== styles?.scrollbar || $[66] !== styles?.thumb) {
339
346
  t38 = showHorizontal && scrollState.hasHorizontal && /*#__PURE__*/ jsx("button", {
340
347
  type: "button",
341
348
  "data-tao-scrollbar": "",
@@ -357,19 +364,20 @@ function ScrollArea(t0) {
357
364
  onPointerDown: (e_5)=>handleThumbPointerDown("x", e_5)
358
365
  })
359
366
  });
360
- $[56] = classNames?.scrollbar;
361
- $[57] = classNames?.thumb;
362
- $[58] = scrollState.hasHorizontal;
363
- $[59] = scrollState.thumbXOffset;
364
- $[60] = scrollState.thumbXRatio;
365
- $[61] = showHorizontal;
366
- $[62] = styles?.scrollbar;
367
- $[63] = styles?.thumb;
368
- $[64] = t38;
369
- } else t38 = $[64];
367
+ $[59] = classNames?.scrollbar;
368
+ $[60] = classNames?.thumb;
369
+ $[61] = scrollState.hasHorizontal;
370
+ $[62] = scrollState.thumbXOffset;
371
+ $[63] = scrollState.thumbXRatio;
372
+ $[64] = showHorizontal;
373
+ $[65] = styles?.scrollbar;
374
+ $[66] = styles?.thumb;
375
+ $[67] = t38;
376
+ } else t38 = $[67];
370
377
  let t39;
371
- if ($[65] !== t26 || $[66] !== t27 || $[67] !== t29 || $[68] !== t31 || $[69] !== t34 || $[70] !== t35 || $[71] !== t36 || $[72] !== t37 || $[73] !== t38 || $[74] !== type) {
378
+ if ($[68] !== directionRef || $[69] !== t26 || $[70] !== t27 || $[71] !== t29 || $[72] !== t31 || $[73] !== t34 || $[74] !== t35 || $[75] !== t36 || $[76] !== t37 || $[77] !== t38 || $[78] !== type) {
372
379
  t39 = /*#__PURE__*/ jsxs("div", {
380
+ ref: directionRef,
373
381
  "data-tao-scroll-area": "",
374
382
  "data-tao-scroll-type": type,
375
383
  "data-tao-has-v": t26,
@@ -384,18 +392,19 @@ function ScrollArea(t0) {
384
392
  t38
385
393
  ]
386
394
  });
387
- $[65] = t26;
388
- $[66] = t27;
389
- $[67] = t29;
390
- $[68] = t31;
391
- $[69] = t34;
392
- $[70] = t35;
393
- $[71] = t36;
394
- $[72] = t37;
395
- $[73] = t38;
396
- $[74] = type;
397
- $[75] = t39;
398
- } else t39 = $[75];
395
+ $[68] = directionRef;
396
+ $[69] = t26;
397
+ $[70] = t27;
398
+ $[71] = t29;
399
+ $[72] = t31;
400
+ $[73] = t34;
401
+ $[74] = t35;
402
+ $[75] = t36;
403
+ $[76] = t37;
404
+ $[77] = t38;
405
+ $[78] = type;
406
+ $[79] = t39;
407
+ } else t39 = $[79];
399
408
  return t39;
400
409
  }
401
410
  export { ScrollArea };
@@ -1,17 +1,20 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { forwardRef, useId, useImperativeHandle, useLayoutEffect, useRef, useState } from "react";
3
- import { useTaoConfig } from "../../provider/tao-provider.js";
2
+ import { forwardRef, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
3
+ import { useTaoConfig, useTaoDirection } from "../../provider/tao-provider.js";
4
4
  import { cx } from "../../utils/semantic.js";
5
5
  import { Tooltip } from "../tooltip/tooltip.js";
6
+ import { mergeRefs } from "../../utils/refs.js";
6
7
  import "./segmented.css";
7
8
  function SegmentedInner(props, ref) {
8
9
  const config = useTaoConfig();
9
10
  const id = useId();
10
11
  const { prefixCls, rootClassName, options, value, defaultValue, onChange, disabled = config.disabled, name = id, block, size = config.size, vertical, orientation, direction, shape = 'default', motionName = 'tao-segmented-thumb-motion', classNames, styles, className, style, onKeyDown, ...rest } = props;
11
- const resolved = options.map((option)=>'object' == typeof option && null !== option ? option : {
12
- value: option,
13
- label: String(option)
14
- });
12
+ const resolved = useMemo(()=>options.map((option)=>'object' == typeof option && null !== option ? option : {
13
+ value: option,
14
+ label: String(option)
15
+ }), [
16
+ options
17
+ ]);
15
18
  const [internal, setInternal] = useState(defaultValue ?? resolved[0]?.value);
16
19
  const selected = void 0 !== value ? value : internal;
17
20
  const axis = orientation ?? (vertical ? 'vertical' : 'horizontal');
@@ -30,11 +33,16 @@ function SegmentedInner(props, ref) {
30
33
  props: merged
31
34
  }) : styles;
32
35
  const root = useRef(null);
36
+ const [resolvedDirection, directionRef] = useTaoDirection(direction ?? ('auto' === props.dir || 'ltr' === props.dir || 'rtl' === props.dir ? props.dir : void 0));
37
+ const mergedRootRef = useMemo(()=>mergeRefs(root, directionRef), [
38
+ directionRef
39
+ ]);
33
40
  useImperativeHandle(ref, ()=>root.current);
34
41
  const [thumb, setThumb] = useState(null);
35
42
  useLayoutEffect(()=>{
36
43
  const container = root.current;
37
- const item = container.querySelector('[data-tao-segmented-item][data-tao-checked]');
44
+ const items = container.querySelectorAll('[data-tao-segmented-item]');
45
+ const item = items[resolved.findIndex((option_0)=>option_0.value === selected)];
38
46
  if (!item) return void setThumb(null);
39
47
  const measure = ()=>{
40
48
  const bounds = container.getBoundingClientRect();
@@ -53,9 +61,24 @@ function SegmentedInner(props, ref) {
53
61
  measure();
54
62
  const observer = new ResizeObserver(measure);
55
63
  observer.observe(container);
56
- observer.observe(item);
57
- return ()=>observer.disconnect();
58
- });
64
+ for (const element of items)observer.observe(element);
65
+ const attributes = new MutationObserver(measure);
66
+ attributes.observe(container, {
67
+ attributes: true,
68
+ attributeFilter: [
69
+ 'dir',
70
+ 'style',
71
+ 'class'
72
+ ]
73
+ });
74
+ return ()=>{
75
+ observer.disconnect();
76
+ attributes.disconnect();
77
+ };
78
+ }, [
79
+ resolved,
80
+ selected
81
+ ]);
59
82
  function select(next_0) {
60
83
  if (next_0 === selected) return;
61
84
  if (void 0 === value) setInternal(next_0);
@@ -63,10 +86,10 @@ function SegmentedInner(props, ref) {
63
86
  }
64
87
  return /*#__PURE__*/ jsxs("div", {
65
88
  ...rest,
66
- ref: root,
89
+ ref: mergedRootRef,
67
90
  role: "radiogroup",
68
91
  "aria-orientation": axis,
69
- dir: direction ?? props.dir,
92
+ dir: direction ?? ('auto' === props.dir ? 'auto' : resolvedDirection),
70
93
  "data-tao-segmented": "",
71
94
  "data-tao-has-thumb": null !== thumb || void 0,
72
95
  "data-tao-disabled": disabled || void 0,
@@ -119,46 +142,46 @@ function SegmentedInner(props, ref) {
119
142
  moving: false
120
143
  } : previous_1)
121
144
  }),
122
- resolved.map((option_0)=>{
123
- const isDisabled = disabled || option_0.disabled;
124
- const key = `${typeof option_0.value}:${String(option_0.value)}`;
145
+ resolved.map((option_1)=>{
146
+ const isDisabled = disabled || option_1.disabled;
147
+ const key = `${typeof option_1.value}:${String(option_1.value)}`;
125
148
  const item_0 = /*#__PURE__*/ jsxs("label", {
126
149
  "data-tao-segmented-item": "",
127
- "data-tao-checked": option_0.value === selected || void 0,
150
+ "data-tao-checked": option_1.value === selected || void 0,
128
151
  "data-tao-disabled": isDisabled || void 0,
129
- className: cx(classes?.item, option_0.className),
152
+ className: cx(classes?.item, option_1.className),
130
153
  style: slots?.item,
131
- title: option_0.title ?? ('string' == typeof option_0.label || 'number' == typeof option_0.label ? String(option_0.label) : void 0),
154
+ title: option_1.title ?? ('string' == typeof option_1.label || 'number' == typeof option_1.label ? String(option_1.label) : void 0),
132
155
  children: [
133
156
  /*#__PURE__*/ jsx("input", {
134
157
  type: "radio",
135
158
  name: name,
136
- value: String(option_0.value),
137
- checked: option_0.value === selected,
159
+ value: String(option_1.value),
160
+ checked: option_1.value === selected,
138
161
  disabled: isDisabled,
139
- onChange: ()=>select(option_0.value),
140
- "aria-label": void 0 === option_0.label ? String(option_0.value) : void 0
162
+ onChange: ()=>select(option_1.value),
163
+ "aria-label": void 0 === option_1.label ? String(option_1.value) : void 0
141
164
  }),
142
165
  /*#__PURE__*/ jsxs("span", {
143
166
  "data-tao-segmented-label": "",
144
167
  className: classes?.label,
145
168
  style: slots?.label,
146
169
  children: [
147
- void 0 !== option_0.icon && /*#__PURE__*/ jsx("span", {
170
+ void 0 !== option_1.icon && /*#__PURE__*/ jsx("span", {
148
171
  "data-tao-segmented-icon": "",
149
172
  className: classes?.icon,
150
173
  style: slots?.icon,
151
- children: option_0.icon
174
+ children: option_1.icon
152
175
  }),
153
- option_0.label
176
+ option_1.label
154
177
  ]
155
178
  })
156
179
  ]
157
180
  }, key);
158
- return option_0.tooltip ? /*#__PURE__*/ jsx(Tooltip, {
159
- ...'string' == typeof option_0.tooltip ? {
160
- title: option_0.tooltip
161
- } : option_0.tooltip,
181
+ return option_1.tooltip ? /*#__PURE__*/ jsx(Tooltip, {
182
+ ...'string' == typeof option_1.tooltip ? {
183
+ title: option_1.tooltip
184
+ } : option_1.tooltip,
162
185
  children: item_0
163
186
  }, key) : item_0;
164
187
  })
@@ -28,7 +28,8 @@ interface MobileSelectContentProps extends Pick<SelectProps, 'classNames' | 'sty
28
28
  declare function MobileSelectContentInner({ options, value, onChange, onMultiChange, showSearch, searchValue: search, onSearch, filterOption, notFoundContent, optionRender, onClose, multiple, maxCount, mode, tokenSeparators, onSearchClear, disabled, classNames, styles, }: MobileSelectContentProps): import("react").JSX.Element;
29
29
  export { MobileSelectContentInner as MobileSelectContent };
30
30
  export interface MobileSelectDrawerProps extends MobileSelectContentProps {
31
+ direction?: 'ltr' | 'rtl';
31
32
  open: boolean;
32
33
  mobileTitle?: ReactNode;
33
34
  }
34
- export declare function MobileSelectDrawer({ open, mobileTitle, onClose, placeholder, classNames, styles, popupRender, ...rest }: MobileSelectDrawerProps): import("react").JSX.Element;
35
+ export declare function MobileSelectDrawer({ direction, open, mobileTitle, onClose, placeholder, classNames, styles, popupRender, ...rest }: MobileSelectDrawerProps): import("react").JSX.Element;