@rockshin/tao-ui 0.0.43 → 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.
- package/README.md +7 -1
- package/component-manifest.json +10 -3
- package/dist/components/auto-complete/auto-complete.js +12 -3
- package/dist/components/breadcrumb/breadcrumb.css +4 -0
- package/dist/components/breadcrumb/breadcrumb.js +1 -0
- package/dist/components/calendar/calendar.d.ts +1 -0
- package/dist/components/calendar/calendar.js +10 -3
- package/dist/components/card/card-tabs.js +204 -182
- package/dist/components/card/card.js +1 -1
- package/dist/components/carousel/carousel.js +11 -5
- package/dist/components/cascader/cascader.js +16 -4
- package/dist/components/collapse/collapse.css +8 -0
- package/dist/components/context-menu/context-menu.d.ts +2 -1
- package/dist/components/context-menu/context-menu.js +57 -44
- package/dist/components/date-picker/calendar/calendar-grid.js +3 -2
- package/dist/components/date-picker/date-picker.css +4 -0
- package/dist/components/date-picker/date-picker.d.ts +1 -0
- package/dist/components/date-picker/date-picker.js +13 -3
- package/dist/components/date-picker/range-picker.d.ts +1 -0
- package/dist/components/date-picker/range-picker.js +13 -3
- package/dist/components/drawer/drawer.d.ts +2 -1
- package/dist/components/drawer/drawer.js +32 -20
- package/dist/components/dropdown/dropdown.d.ts +1 -0
- package/dist/components/dropdown/dropdown.js +139 -123
- package/dist/components/form/field-control.d.ts +6 -0
- package/dist/components/form/field-control.js +42 -0
- package/dist/components/form/form-context.d.ts +3 -0
- package/dist/components/form/form-item.d.ts +2 -1
- package/dist/components/form/form-item.js +55 -42
- package/dist/components/form/form.d.ts +5 -5
- package/dist/components/form/form.js +86 -68
- package/dist/components/form/index.d.ts +1 -0
- package/dist/components/form/use-form.d.ts +16 -0
- package/dist/components/form/use-form.js +69 -0
- package/dist/components/form-field/form-field-view.d.ts +4 -2
- package/dist/components/form-field/form-field-view.js +42 -35
- package/dist/components/mentions/mentions.js +6 -2
- package/dist/components/modal/modal.d.ts +2 -1
- package/dist/components/modal/modal.js +14 -4
- package/dist/components/pagination/pagination.css +4 -0
- package/dist/components/popover/popover.d.ts +2 -1
- package/dist/components/popover/popover.js +185 -176
- package/dist/components/rate/rate.js +114 -88
- package/dist/components/scroll-area/scroll-area.js +127 -118
- package/dist/components/segmented/segmented.js +52 -29
- package/dist/components/select/mobile-select.d.ts +2 -1
- package/dist/components/select/mobile-select.js +52 -47
- package/dist/components/select/select-types.d.ts +1 -0
- package/dist/components/select/select.js +19 -6
- package/dist/components/slider/slider.js +136 -133
- package/dist/components/splitter/splitter.css +4 -0
- package/dist/components/splitter/splitter.js +5 -3
- package/dist/components/table/table.css +29 -11
- package/dist/components/table/table.js +383 -547
- package/dist/components/tabs/tabs.js +3 -2
- package/dist/components/time-picker/time-picker.js +21 -7
- package/dist/components/tooltip/tooltip.d.ts +2 -1
- package/dist/components/tooltip/tooltip.js +82 -71
- package/dist/components/transfer/transfer-parts.js +12 -2
- package/dist/components/transfer/transfer.js +10 -4
- package/dist/components/tree/tree-keyboard.d.ts +6 -0
- package/dist/components/tree/tree-keyboard.js +27 -0
- package/dist/components/tree/tree.js +14 -3
- package/dist/components/tree-select/select-engine.d.ts +2 -1
- package/dist/components/tree-select/select-engine.js +23 -15
- package/dist/components/tree-select/tree-select.js +20 -10
- package/dist/docs/components/form.doc.js +3 -1
- package/dist/docs/components/tao-provider.doc.js +6 -1
- package/dist/entries/form.d.ts +2 -2
- package/dist/entries/provider.d.ts +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/provider/tao-provider.d.ts +10 -3
- package/dist/provider/tao-provider.js +198 -88
- package/dist/utils/scroll-left.d.ts +3 -0
- package/dist/utils/scroll-left.js +7 -0
- package/llms.txt +3 -3
- package/package.json +4 -2
|
@@ -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(
|
|
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]
|
|
37
|
+
if ($[1] !== textDirection) {
|
|
35
38
|
t8 = ()=>{
|
|
36
39
|
const el = viewportRef.current;
|
|
37
40
|
if (!el) return;
|
|
38
|
-
const { scrollTop,
|
|
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] =
|
|
55
|
-
|
|
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 ($[
|
|
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
|
-
$[
|
|
73
|
-
$[
|
|
77
|
+
$[3] = updateScrollState;
|
|
78
|
+
$[4] = t10;
|
|
79
|
+
$[5] = t9;
|
|
74
80
|
} else {
|
|
75
|
-
t10 = $[
|
|
76
|
-
t9 = $[
|
|
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 ($[
|
|
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
|
-
$[
|
|
96
|
-
$[
|
|
97
|
-
$[
|
|
98
|
-
$[
|
|
99
|
-
|
|
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 ($[
|
|
111
|
+
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
|
105
112
|
t12 = ()=>()=>dragCleanup.current?.();
|
|
106
113
|
t13 = [];
|
|
107
|
-
$[
|
|
108
|
-
$[
|
|
114
|
+
$[11] = t12;
|
|
115
|
+
$[12] = t13;
|
|
109
116
|
} else {
|
|
110
|
-
t12 = $[
|
|
111
|
-
t13 = $[
|
|
117
|
+
t12 = $[11];
|
|
118
|
+
t13 = $[12];
|
|
112
119
|
}
|
|
113
120
|
useEffect(t12, t13);
|
|
114
121
|
let t14;
|
|
115
|
-
if ($[
|
|
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
|
|
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
|
|
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
|
-
$[
|
|
156
|
-
} else t14 = $[
|
|
162
|
+
$[13] = t14;
|
|
163
|
+
} else t14 = $[13];
|
|
157
164
|
const handleThumbPointerDown = t14;
|
|
158
165
|
let t15;
|
|
159
|
-
if ($[
|
|
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
|
|
174
|
+
else setScrollLeft(el_3, clickPos * (el_3.scrollWidth - el_3.clientWidth));
|
|
168
175
|
};
|
|
169
|
-
$[
|
|
170
|
-
} else t15 = $[
|
|
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 ($[
|
|
184
|
+
if ($[15] !== t16 || $[16] !== t17) {
|
|
178
185
|
t18 = {
|
|
179
186
|
maxHeight: t16,
|
|
180
187
|
maxWidth: t17
|
|
181
188
|
};
|
|
182
|
-
$[
|
|
183
|
-
$[
|
|
184
|
-
$[
|
|
185
|
-
} else t18 = $[
|
|
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 ($[
|
|
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
|
-
$[
|
|
198
|
-
$[
|
|
199
|
-
$[
|
|
200
|
-
$[
|
|
201
|
-
} else t22 = $[
|
|
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 ($[
|
|
213
|
+
if ($[22] !== t23 || $[23] !== t24) {
|
|
207
214
|
t25 = {
|
|
208
215
|
"--tao-scrollbar-size": t23,
|
|
209
216
|
"--tao-scrollbar-offset": t24
|
|
210
217
|
};
|
|
211
|
-
$[
|
|
212
|
-
$[
|
|
213
|
-
$[
|
|
214
|
-
} else t25 = $[
|
|
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 ($[
|
|
227
|
+
if ($[25] !== className || $[26] !== t28) {
|
|
221
228
|
t29 = cx(t28, className);
|
|
222
|
-
$[
|
|
223
|
-
$[
|
|
224
|
-
$[
|
|
225
|
-
} else t29 = $[
|
|
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 ($[
|
|
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
|
-
$[
|
|
236
|
-
$[
|
|
237
|
-
$[
|
|
238
|
-
$[
|
|
239
|
-
$[
|
|
240
|
-
} else t31 = $[
|
|
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 ($[
|
|
250
|
+
if ($[33] !== t32) {
|
|
244
251
|
t33 = cx(t32);
|
|
245
|
-
$[
|
|
246
|
-
$[
|
|
247
|
-
} else t33 = $[
|
|
252
|
+
$[33] = t32;
|
|
253
|
+
$[34] = t33;
|
|
254
|
+
} else t33 = $[34];
|
|
248
255
|
let t34;
|
|
249
|
-
if ($[
|
|
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
|
-
$[
|
|
259
|
-
$[
|
|
260
|
-
$[
|
|
261
|
-
$[
|
|
262
|
-
$[
|
|
263
|
-
} else t34 = $[
|
|
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 ($[
|
|
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
|
-
$[
|
|
279
|
-
$[
|
|
280
|
-
$[
|
|
281
|
-
$[
|
|
282
|
-
$[
|
|
283
|
-
} else t35 = $[
|
|
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 ($[
|
|
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
|
-
$[
|
|
299
|
-
$[
|
|
300
|
-
$[
|
|
301
|
-
$[
|
|
302
|
-
$[
|
|
303
|
-
} else t36 = $[
|
|
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 ($[
|
|
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
|
-
$[
|
|
328
|
-
$[
|
|
329
|
-
$[
|
|
330
|
-
$[
|
|
331
|
-
$[
|
|
332
|
-
$[
|
|
333
|
-
$[
|
|
334
|
-
$[
|
|
335
|
-
$[
|
|
336
|
-
} else t37 = $[
|
|
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 ($[
|
|
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
|
-
$[
|
|
361
|
-
$[
|
|
362
|
-
$[
|
|
363
|
-
$[
|
|
364
|
-
$[
|
|
365
|
-
$[
|
|
366
|
-
$[
|
|
367
|
-
$[
|
|
368
|
-
$[
|
|
369
|
-
} else t38 = $[
|
|
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 ($[
|
|
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
|
-
$[
|
|
388
|
-
$[
|
|
389
|
-
$[
|
|
390
|
-
$[
|
|
391
|
-
$[
|
|
392
|
-
$[
|
|
393
|
-
$[
|
|
394
|
-
$[
|
|
395
|
-
$[
|
|
396
|
-
$[
|
|
397
|
-
$[
|
|
398
|
-
|
|
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
|
-
|
|
13
|
-
|
|
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
|
|
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(
|
|
57
|
-
|
|
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:
|
|
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((
|
|
123
|
-
const isDisabled = disabled ||
|
|
124
|
-
const key = `${typeof
|
|
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":
|
|
150
|
+
"data-tao-checked": option_1.value === selected || void 0,
|
|
128
151
|
"data-tao-disabled": isDisabled || void 0,
|
|
129
|
-
className: cx(classes?.item,
|
|
152
|
+
className: cx(classes?.item, option_1.className),
|
|
130
153
|
style: slots?.item,
|
|
131
|
-
title:
|
|
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(
|
|
137
|
-
checked:
|
|
159
|
+
value: String(option_1.value),
|
|
160
|
+
checked: option_1.value === selected,
|
|
138
161
|
disabled: isDisabled,
|
|
139
|
-
onChange: ()=>select(
|
|
140
|
-
"aria-label": 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 !==
|
|
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:
|
|
174
|
+
children: option_1.icon
|
|
152
175
|
}),
|
|
153
|
-
|
|
176
|
+
option_1.label
|
|
154
177
|
]
|
|
155
178
|
})
|
|
156
179
|
]
|
|
157
180
|
}, key);
|
|
158
|
-
return
|
|
159
|
-
...'string' == typeof
|
|
160
|
-
title:
|
|
161
|
-
} :
|
|
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;
|