@rockshin/tao-ui 0.0.25 → 0.0.27
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 +17 -6
- package/component-manifest.json +534 -6
- package/dist/components/alert/alert.css +120 -0
- package/dist/components/alert/alert.d.ts +20 -0
- package/dist/components/alert/alert.js +185 -0
- package/dist/components/button/button.css +19 -18
- package/dist/components/button/button.d.ts +8 -0
- package/dist/components/date-picker/date-picker.d.ts +1 -1
- package/dist/components/date-picker/date-picker.js +57 -43
- package/dist/components/date-picker/range-picker.js +68 -23
- package/dist/components/dropdown/dropdown.css +22 -1
- package/dist/components/dropdown/dropdown.js +4 -3
- package/dist/components/form/form-context.d.ts +7 -0
- package/dist/components/form/form-context.js +8 -0
- package/dist/components/form/form-item.d.ts +55 -0
- package/dist/components/form/form-item.js +131 -0
- package/dist/components/form/form.css +22 -0
- package/dist/components/form/form.d.ts +35 -0
- package/dist/components/form/form.js +125 -0
- package/dist/components/form/index.d.ts +2 -0
- package/dist/components/form/index.js +1 -0
- package/dist/components/form-field/form-field-view.d.ts +30 -0
- package/dist/components/form-field/form-field-view.js +154 -0
- package/dist/components/form-field/form-field.d.ts +2 -2
- package/dist/components/form-field/form-field.js +29 -137
- package/dist/components/form-field/form.css +17 -7
- package/dist/components/input/input.css +6 -6
- package/dist/components/modal/confirm-dialog.js +14 -111
- package/dist/components/modal/modal.d.ts +7 -1
- package/dist/components/modal/modal.js +205 -195
- package/dist/components/popconfirm/popconfirm.css +44 -0
- package/dist/components/popconfirm/popconfirm.d.ts +41 -0
- package/dist/components/popconfirm/popconfirm.js +238 -0
- package/dist/components/popover/popover.css +105 -0
- package/dist/components/popover/popover.d.ts +41 -0
- package/dist/components/popover/popover.js +412 -0
- package/dist/components/select/mobile-select.js +9 -20
- package/dist/components/select/select-model.d.ts +7 -1
- package/dist/components/select/select-model.js +30 -7
- package/dist/components/select/select.js +49 -38
- package/dist/components/sonner/sonner.d.ts +2 -1
- package/dist/components/sonner/sonner.js +74 -81
- package/dist/components/status-icon/status-icon.d.ts +5 -0
- package/dist/components/status-icon/status-icon.js +77 -0
- package/dist/components/table/table-types.d.ts +7 -0
- package/dist/components/table/table.d.ts +1 -1
- package/dist/components/table/table.js +296 -283
- package/dist/components/tooltip/tooltip.css +93 -0
- package/dist/components/tooltip/tooltip.d.ts +33 -0
- package/dist/components/tooltip/tooltip.js +226 -0
- package/dist/docs/component-docs.js +11 -1
- package/dist/docs/components/alert.doc.d.ts +29 -0
- package/dist/docs/components/alert.doc.js +93 -0
- package/dist/docs/components/form.doc.d.ts +29 -0
- package/dist/docs/components/form.doc.js +71 -0
- package/dist/docs/components/modal.doc.d.ts +6 -0
- package/dist/docs/components/modal.doc.js +9 -1
- package/dist/docs/components/popconfirm.doc.d.ts +29 -0
- package/dist/docs/components/popconfirm.doc.js +132 -0
- package/dist/docs/components/popover.doc.d.ts +29 -0
- package/dist/docs/components/popover.doc.js +121 -0
- package/dist/docs/components/stack.doc.d.ts +6 -0
- package/dist/docs/components/stack.doc.js +23 -2
- package/dist/docs/components/table.doc.js +2 -1
- package/dist/docs/components/tao-provider.doc.js +11 -1
- package/dist/docs/components/tooltip.doc.d.ts +37 -0
- package/dist/docs/components/tooltip.doc.js +76 -0
- package/dist/index.d.ts +9 -1
- package/dist/index.js +8 -1
- package/dist/layouts/stack/stack.d.ts +12 -3
- package/dist/layouts/stack/stack.js +60 -34
- package/dist/provider/tao-provider.d.ts +71 -0
- package/dist/provider/tao-provider.js +166 -120
- package/dist/theme/control.css +12 -12
- package/dist/theme/theme.css +23 -0
- package/dist/utils/breakpoint.d.ts +31 -0
- package/dist/utils/breakpoint.js +80 -0
- package/dist/utils/overlay.d.ts +19 -0
- package/dist/utils/overlay.js +41 -0
- package/llms.txt +68 -3
- package/package.json +6 -4
- package/dist/components/select/use-is-mobile.d.ts +0 -1
- package/dist/components/select/use-is-mobile.js +0 -27
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import * as __rspack_external__radix_ui_react_popover_c8444160 from "@radix-ui/react-popover";
|
|
4
|
+
import { useEffect, useRef } from "react";
|
|
5
|
+
import { TaoPortalScope } from "../../provider/tao-provider.js";
|
|
6
|
+
import { asTriggerChild, useControlledOpen } from "../../utils/overlay.js";
|
|
7
|
+
import { cx } from "../../utils/semantic.js";
|
|
8
|
+
import "./popover.css";
|
|
9
|
+
const placements = {
|
|
10
|
+
top: {
|
|
11
|
+
side: 'top',
|
|
12
|
+
align: 'center'
|
|
13
|
+
},
|
|
14
|
+
topLeft: {
|
|
15
|
+
side: 'top',
|
|
16
|
+
align: 'start'
|
|
17
|
+
},
|
|
18
|
+
topRight: {
|
|
19
|
+
side: 'top',
|
|
20
|
+
align: 'end'
|
|
21
|
+
},
|
|
22
|
+
bottom: {
|
|
23
|
+
side: 'bottom',
|
|
24
|
+
align: 'center'
|
|
25
|
+
},
|
|
26
|
+
bottomLeft: {
|
|
27
|
+
side: 'bottom',
|
|
28
|
+
align: 'start'
|
|
29
|
+
},
|
|
30
|
+
bottomRight: {
|
|
31
|
+
side: 'bottom',
|
|
32
|
+
align: 'end'
|
|
33
|
+
},
|
|
34
|
+
left: {
|
|
35
|
+
side: 'left',
|
|
36
|
+
align: 'center'
|
|
37
|
+
},
|
|
38
|
+
leftTop: {
|
|
39
|
+
side: 'left',
|
|
40
|
+
align: 'start'
|
|
41
|
+
},
|
|
42
|
+
leftBottom: {
|
|
43
|
+
side: 'left',
|
|
44
|
+
align: 'end'
|
|
45
|
+
},
|
|
46
|
+
right: {
|
|
47
|
+
side: 'right',
|
|
48
|
+
align: 'center'
|
|
49
|
+
},
|
|
50
|
+
rightTop: {
|
|
51
|
+
side: 'right',
|
|
52
|
+
align: 'start'
|
|
53
|
+
},
|
|
54
|
+
rightBottom: {
|
|
55
|
+
side: 'right',
|
|
56
|
+
align: 'end'
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
function getRenderNode(node) {
|
|
60
|
+
return 'function' == typeof node ? node() : node;
|
|
61
|
+
}
|
|
62
|
+
function isRenderable(node) {
|
|
63
|
+
return null != node && false !== node && '' !== node;
|
|
64
|
+
}
|
|
65
|
+
function Popover(t0) {
|
|
66
|
+
const $ = c(86);
|
|
67
|
+
const { title, content, trigger: t1, placement: t2, open, defaultOpen, onOpenChange, mouseEnterDelay: t3, mouseLeaveDelay: t4, arrow: t5, destroyOnHidden, destroyTooltipOnHide, className, style, classNames, styles, children } = t0;
|
|
68
|
+
const trigger = void 0 === t1 ? "hover" : t1;
|
|
69
|
+
const placement = void 0 === t2 ? "top" : t2;
|
|
70
|
+
const mouseEnterDelay = void 0 === t3 ? 0.1 : t3;
|
|
71
|
+
const mouseLeaveDelay = void 0 === t4 ? 0.1 : t4;
|
|
72
|
+
const arrow = void 0 === t5 ? true : t5;
|
|
73
|
+
let t6;
|
|
74
|
+
if ($[0] !== trigger) {
|
|
75
|
+
t6 = Array.isArray(trigger) ? trigger : [
|
|
76
|
+
trigger
|
|
77
|
+
];
|
|
78
|
+
$[0] = trigger;
|
|
79
|
+
$[1] = t6;
|
|
80
|
+
} else t6 = $[1];
|
|
81
|
+
let t7;
|
|
82
|
+
if ($[2] !== t6) {
|
|
83
|
+
t7 = new Set(t6);
|
|
84
|
+
$[2] = t6;
|
|
85
|
+
$[3] = t7;
|
|
86
|
+
} else t7 = $[3];
|
|
87
|
+
const triggers = t7;
|
|
88
|
+
const hoverMode = triggers.has("hover");
|
|
89
|
+
const focusMode = triggers.has("focus");
|
|
90
|
+
const clickMode = triggers.has("click");
|
|
91
|
+
const contextMenuMode = triggers.has("contextMenu");
|
|
92
|
+
const shouldDestroy = destroyOnHidden ?? destroyTooltipOnHide ?? false;
|
|
93
|
+
const placementProps = placements[placement];
|
|
94
|
+
const TriggerPrimitive = clickMode ? __rspack_external__radix_ui_react_popover_c8444160.Trigger : __rspack_external__radix_ui_react_popover_c8444160.Anchor;
|
|
95
|
+
const titleNode = getRenderNode(title);
|
|
96
|
+
const contentNode = getRenderNode(content);
|
|
97
|
+
const hasPopup = isRenderable(titleNode) || isRenderable(contentNode);
|
|
98
|
+
const [realOpen, setOpen] = useControlledOpen({
|
|
99
|
+
open,
|
|
100
|
+
defaultOpen,
|
|
101
|
+
onOpenChange,
|
|
102
|
+
canOpen: hasPopup
|
|
103
|
+
});
|
|
104
|
+
const openTimer = useRef(void 0);
|
|
105
|
+
const closeTimer = useRef(void 0);
|
|
106
|
+
const popupRef = useRef(null);
|
|
107
|
+
let t8;
|
|
108
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
109
|
+
t8 = ()=>{
|
|
110
|
+
clearTimeout(openTimer.current);
|
|
111
|
+
clearTimeout(closeTimer.current);
|
|
112
|
+
};
|
|
113
|
+
$[4] = t8;
|
|
114
|
+
} else t8 = $[4];
|
|
115
|
+
const cancelTimers = t8;
|
|
116
|
+
let t10;
|
|
117
|
+
let t9;
|
|
118
|
+
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
119
|
+
t9 = ()=>cancelTimers;
|
|
120
|
+
t10 = [
|
|
121
|
+
cancelTimers
|
|
122
|
+
];
|
|
123
|
+
$[5] = t10;
|
|
124
|
+
$[6] = t9;
|
|
125
|
+
} else {
|
|
126
|
+
t10 = $[5];
|
|
127
|
+
t9 = $[6];
|
|
128
|
+
}
|
|
129
|
+
useEffect(t9, t10);
|
|
130
|
+
let t11;
|
|
131
|
+
if ($[7] !== mouseEnterDelay || $[8] !== setOpen) {
|
|
132
|
+
t11 = ()=>{
|
|
133
|
+
cancelTimers();
|
|
134
|
+
if (mouseEnterDelay <= 0) return void setOpen(true);
|
|
135
|
+
openTimer.current = setTimeout(()=>setOpen(true), 1000 * mouseEnterDelay);
|
|
136
|
+
};
|
|
137
|
+
$[7] = mouseEnterDelay;
|
|
138
|
+
$[8] = setOpen;
|
|
139
|
+
$[9] = t11;
|
|
140
|
+
} else t11 = $[9];
|
|
141
|
+
const scheduleOpen = t11;
|
|
142
|
+
let t12;
|
|
143
|
+
if ($[10] !== mouseLeaveDelay || $[11] !== setOpen) {
|
|
144
|
+
t12 = ()=>{
|
|
145
|
+
cancelTimers();
|
|
146
|
+
if (mouseLeaveDelay <= 0) return void setOpen(false);
|
|
147
|
+
closeTimer.current = setTimeout(()=>setOpen(false), 1000 * mouseLeaveDelay);
|
|
148
|
+
};
|
|
149
|
+
$[10] = mouseLeaveDelay;
|
|
150
|
+
$[11] = setOpen;
|
|
151
|
+
$[12] = t12;
|
|
152
|
+
} else t12 = $[12];
|
|
153
|
+
const scheduleClose = t12;
|
|
154
|
+
let t13;
|
|
155
|
+
if ($[13] !== focusMode || $[14] !== setOpen) {
|
|
156
|
+
t13 = (event)=>{
|
|
157
|
+
if (focusMode && !popupRef.current?.contains(event.relatedTarget)) setOpen(false);
|
|
158
|
+
};
|
|
159
|
+
$[13] = focusMode;
|
|
160
|
+
$[14] = setOpen;
|
|
161
|
+
$[15] = t13;
|
|
162
|
+
} else t13 = $[15];
|
|
163
|
+
const handleTriggerBlur = t13;
|
|
164
|
+
let t14;
|
|
165
|
+
if ($[16] !== focusMode || $[17] !== setOpen) {
|
|
166
|
+
t14 = (event_0)=>{
|
|
167
|
+
if (focusMode && !event_0.currentTarget.contains(event_0.relatedTarget)) setOpen(false);
|
|
168
|
+
};
|
|
169
|
+
$[16] = focusMode;
|
|
170
|
+
$[17] = setOpen;
|
|
171
|
+
$[18] = t14;
|
|
172
|
+
} else t14 = $[18];
|
|
173
|
+
const handleContentBlur = t14;
|
|
174
|
+
if (!hasPopup) {
|
|
175
|
+
let t15;
|
|
176
|
+
if ($[19] !== children) {
|
|
177
|
+
t15 = /*#__PURE__*/ jsx(Fragment, {
|
|
178
|
+
children: children
|
|
179
|
+
});
|
|
180
|
+
$[19] = children;
|
|
181
|
+
$[20] = t15;
|
|
182
|
+
} else t15 = $[20];
|
|
183
|
+
return t15;
|
|
184
|
+
}
|
|
185
|
+
let t15;
|
|
186
|
+
if ($[21] !== hoverMode || $[22] !== scheduleClose || $[23] !== scheduleOpen) {
|
|
187
|
+
t15 = hoverMode ? {
|
|
188
|
+
onPointerEnter: scheduleOpen,
|
|
189
|
+
onPointerLeave: scheduleClose
|
|
190
|
+
} : void 0;
|
|
191
|
+
$[21] = hoverMode;
|
|
192
|
+
$[22] = scheduleClose;
|
|
193
|
+
$[23] = scheduleOpen;
|
|
194
|
+
$[24] = t15;
|
|
195
|
+
} else t15 = $[24];
|
|
196
|
+
const hoverProps = t15;
|
|
197
|
+
let t16;
|
|
198
|
+
if ($[25] !== focusMode || $[26] !== setOpen) {
|
|
199
|
+
t16 = focusMode ? ()=>setOpen(true) : void 0;
|
|
200
|
+
$[25] = focusMode;
|
|
201
|
+
$[26] = setOpen;
|
|
202
|
+
$[27] = t16;
|
|
203
|
+
} else t16 = $[27];
|
|
204
|
+
const t17 = focusMode ? handleTriggerBlur : void 0;
|
|
205
|
+
let t18;
|
|
206
|
+
if ($[28] !== contextMenuMode || $[29] !== setOpen) {
|
|
207
|
+
t18 = contextMenuMode ? (event_1)=>{
|
|
208
|
+
event_1.preventDefault();
|
|
209
|
+
setOpen(true);
|
|
210
|
+
} : void 0;
|
|
211
|
+
$[28] = contextMenuMode;
|
|
212
|
+
$[29] = setOpen;
|
|
213
|
+
$[30] = t18;
|
|
214
|
+
} else t18 = $[30];
|
|
215
|
+
let t19;
|
|
216
|
+
if ($[31] !== hoverProps || $[32] !== t16 || $[33] !== t17 || $[34] !== t18) {
|
|
217
|
+
t19 = {
|
|
218
|
+
...hoverProps,
|
|
219
|
+
onFocus: t16,
|
|
220
|
+
onBlur: t17,
|
|
221
|
+
onContextMenu: t18
|
|
222
|
+
};
|
|
223
|
+
$[31] = hoverProps;
|
|
224
|
+
$[32] = t16;
|
|
225
|
+
$[33] = t17;
|
|
226
|
+
$[34] = t18;
|
|
227
|
+
$[35] = t19;
|
|
228
|
+
} else t19 = $[35];
|
|
229
|
+
const triggerProps = t19;
|
|
230
|
+
const t20 = __rspack_external__radix_ui_react_popover_c8444160;
|
|
231
|
+
let t21;
|
|
232
|
+
if ($[36] !== children) {
|
|
233
|
+
t21 = asTriggerChild(children);
|
|
234
|
+
$[36] = children;
|
|
235
|
+
$[37] = t21;
|
|
236
|
+
} else t21 = $[37];
|
|
237
|
+
let t22;
|
|
238
|
+
if ($[38] !== TriggerPrimitive || $[39] !== t21 || $[40] !== triggerProps) {
|
|
239
|
+
t22 = /*#__PURE__*/ jsx(TriggerPrimitive, {
|
|
240
|
+
asChild: true,
|
|
241
|
+
...triggerProps,
|
|
242
|
+
children: t21
|
|
243
|
+
});
|
|
244
|
+
$[38] = TriggerPrimitive;
|
|
245
|
+
$[39] = t21;
|
|
246
|
+
$[40] = triggerProps;
|
|
247
|
+
$[41] = t22;
|
|
248
|
+
} else t22 = $[41];
|
|
249
|
+
const t23 = __rspack_external__radix_ui_react_popover_c8444160;
|
|
250
|
+
const t24 = shouldDestroy ? void 0 : true;
|
|
251
|
+
const T0 = TaoPortalScope;
|
|
252
|
+
const t25 = true;
|
|
253
|
+
const t26 = __rspack_external__radix_ui_react_popover_c8444160;
|
|
254
|
+
const t27 = "";
|
|
255
|
+
const t28 = !shouldDestroy || void 0;
|
|
256
|
+
const t29 = classNames?.root;
|
|
257
|
+
let t30;
|
|
258
|
+
if ($[42] !== className || $[43] !== t29) {
|
|
259
|
+
t30 = cx(t29, className);
|
|
260
|
+
$[42] = className;
|
|
261
|
+
$[43] = t29;
|
|
262
|
+
$[44] = t30;
|
|
263
|
+
} else t30 = $[44];
|
|
264
|
+
const t31 = styles?.root;
|
|
265
|
+
let t32;
|
|
266
|
+
if ($[45] !== style || $[46] !== t31) {
|
|
267
|
+
t32 = {
|
|
268
|
+
...t31,
|
|
269
|
+
...style
|
|
270
|
+
};
|
|
271
|
+
$[45] = style;
|
|
272
|
+
$[46] = t31;
|
|
273
|
+
$[47] = t32;
|
|
274
|
+
} else t32 = $[47];
|
|
275
|
+
const t33 = 4;
|
|
276
|
+
const t34 = shouldDestroy ? void 0 : true;
|
|
277
|
+
const t35 = _temp;
|
|
278
|
+
const t36 = focusMode ? cancelTimers : void 0;
|
|
279
|
+
const t37 = focusMode ? handleContentBlur : void 0;
|
|
280
|
+
const t38 = "";
|
|
281
|
+
const t39 = classNames?.container;
|
|
282
|
+
let t40;
|
|
283
|
+
if ($[48] !== t39) {
|
|
284
|
+
t40 = cx(t39);
|
|
285
|
+
$[48] = t39;
|
|
286
|
+
$[49] = t40;
|
|
287
|
+
} else t40 = $[49];
|
|
288
|
+
const t41 = styles?.container;
|
|
289
|
+
const t42 = isRenderable(titleNode) && /*#__PURE__*/ jsx("div", {
|
|
290
|
+
"data-tao-popover-title": "",
|
|
291
|
+
className: cx(classNames?.title),
|
|
292
|
+
style: styles?.title,
|
|
293
|
+
children: titleNode
|
|
294
|
+
});
|
|
295
|
+
const t43 = isRenderable(contentNode) && /*#__PURE__*/ jsx("div", {
|
|
296
|
+
"data-tao-popover-content": "",
|
|
297
|
+
className: cx(classNames?.content),
|
|
298
|
+
style: styles?.content,
|
|
299
|
+
children: contentNode
|
|
300
|
+
});
|
|
301
|
+
let t44;
|
|
302
|
+
if ($[50] !== t40 || $[51] !== t41 || $[52] !== t42 || $[53] !== t43) {
|
|
303
|
+
t44 = /*#__PURE__*/ jsxs("div", {
|
|
304
|
+
"data-tao-popover-container": t38,
|
|
305
|
+
className: t40,
|
|
306
|
+
style: t41,
|
|
307
|
+
children: [
|
|
308
|
+
t42,
|
|
309
|
+
t43
|
|
310
|
+
]
|
|
311
|
+
});
|
|
312
|
+
$[50] = t40;
|
|
313
|
+
$[51] = t41;
|
|
314
|
+
$[52] = t42;
|
|
315
|
+
$[53] = t43;
|
|
316
|
+
$[54] = t44;
|
|
317
|
+
} else t44 = $[54];
|
|
318
|
+
let t45;
|
|
319
|
+
if ($[55] !== arrow || $[56] !== classNames?.arrow || $[57] !== styles?.arrow) {
|
|
320
|
+
t45 = false !== arrow && /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_popover_c8444160.Arrow, {
|
|
321
|
+
asChild: true,
|
|
322
|
+
children: /*#__PURE__*/ jsx("span", {
|
|
323
|
+
"data-tao-popover-arrow": "",
|
|
324
|
+
className: cx(classNames?.arrow),
|
|
325
|
+
style: styles?.arrow
|
|
326
|
+
})
|
|
327
|
+
});
|
|
328
|
+
$[55] = arrow;
|
|
329
|
+
$[56] = classNames?.arrow;
|
|
330
|
+
$[57] = styles?.arrow;
|
|
331
|
+
$[58] = t45;
|
|
332
|
+
} else t45 = $[58];
|
|
333
|
+
let t46;
|
|
334
|
+
if ($[59] !== hoverProps || $[60] !== placement || $[61] !== placementProps || $[62] !== t26.Content || $[63] !== t28 || $[64] !== t30 || $[65] !== t32 || $[66] !== t34 || $[67] !== t35 || $[68] !== t36 || $[69] !== t37 || $[70] !== t44 || $[71] !== t45) {
|
|
335
|
+
t46 = /*#__PURE__*/ jsxs(t26.Content, {
|
|
336
|
+
ref: popupRef,
|
|
337
|
+
"data-tao-popover": t27,
|
|
338
|
+
"data-tao-placement": placement,
|
|
339
|
+
"data-tao-keep-alive": t28,
|
|
340
|
+
className: t30,
|
|
341
|
+
style: t32,
|
|
342
|
+
...placementProps,
|
|
343
|
+
sideOffset: t33,
|
|
344
|
+
forceMount: t34,
|
|
345
|
+
onOpenAutoFocus: t35,
|
|
346
|
+
onFocusCapture: t36,
|
|
347
|
+
onBlurCapture: t37,
|
|
348
|
+
...hoverProps,
|
|
349
|
+
children: [
|
|
350
|
+
t44,
|
|
351
|
+
t45
|
|
352
|
+
]
|
|
353
|
+
});
|
|
354
|
+
$[59] = hoverProps;
|
|
355
|
+
$[60] = placement;
|
|
356
|
+
$[61] = placementProps;
|
|
357
|
+
$[62] = t26.Content;
|
|
358
|
+
$[63] = t28;
|
|
359
|
+
$[64] = t30;
|
|
360
|
+
$[65] = t32;
|
|
361
|
+
$[66] = t34;
|
|
362
|
+
$[67] = t35;
|
|
363
|
+
$[68] = t36;
|
|
364
|
+
$[69] = t37;
|
|
365
|
+
$[70] = t44;
|
|
366
|
+
$[71] = t45;
|
|
367
|
+
$[72] = t46;
|
|
368
|
+
} else t46 = $[72];
|
|
369
|
+
let t47;
|
|
370
|
+
if ($[73] !== T0 || $[74] !== t46) {
|
|
371
|
+
t47 = /*#__PURE__*/ jsx(T0, {
|
|
372
|
+
asChild: t25,
|
|
373
|
+
children: t46
|
|
374
|
+
});
|
|
375
|
+
$[73] = T0;
|
|
376
|
+
$[74] = t46;
|
|
377
|
+
$[75] = t47;
|
|
378
|
+
} else t47 = $[75];
|
|
379
|
+
let t48;
|
|
380
|
+
if ($[76] !== t23.Portal || $[77] !== t24 || $[78] !== t47) {
|
|
381
|
+
t48 = /*#__PURE__*/ jsx(t23.Portal, {
|
|
382
|
+
forceMount: t24,
|
|
383
|
+
children: t47
|
|
384
|
+
});
|
|
385
|
+
$[76] = t23.Portal;
|
|
386
|
+
$[77] = t24;
|
|
387
|
+
$[78] = t47;
|
|
388
|
+
$[79] = t48;
|
|
389
|
+
} else t48 = $[79];
|
|
390
|
+
let t49;
|
|
391
|
+
if ($[80] !== realOpen || $[81] !== setOpen || $[82] !== t20.Root || $[83] !== t22 || $[84] !== t48) {
|
|
392
|
+
t49 = /*#__PURE__*/ jsxs(t20.Root, {
|
|
393
|
+
open: realOpen,
|
|
394
|
+
onOpenChange: setOpen,
|
|
395
|
+
children: [
|
|
396
|
+
t22,
|
|
397
|
+
t48
|
|
398
|
+
]
|
|
399
|
+
});
|
|
400
|
+
$[80] = realOpen;
|
|
401
|
+
$[81] = setOpen;
|
|
402
|
+
$[82] = t20.Root;
|
|
403
|
+
$[83] = t22;
|
|
404
|
+
$[84] = t48;
|
|
405
|
+
$[85] = t49;
|
|
406
|
+
} else t49 = $[85];
|
|
407
|
+
return t49;
|
|
408
|
+
}
|
|
409
|
+
function _temp(event_2) {
|
|
410
|
+
return event_2.preventDefault();
|
|
411
|
+
}
|
|
412
|
+
export { Popover };
|
|
@@ -3,25 +3,8 @@ import { c } from "react/compiler-runtime";
|
|
|
3
3
|
import { useCallback, useMemo, useState } from "react";
|
|
4
4
|
import { Drawer } from "../drawer/drawer.js";
|
|
5
5
|
import { SearchIcon } from "./select-icons.js";
|
|
6
|
+
import { countLeafOptions, defaultFilter, filterTree } from "./select-model.js";
|
|
6
7
|
import "./mobile-select.css";
|
|
7
|
-
const defaultFilter = (input, option)=>{
|
|
8
|
-
const label = 'string' == typeof option.label ? option.label : String(option.label);
|
|
9
|
-
return label.toLowerCase().includes(input.toLowerCase());
|
|
10
|
-
};
|
|
11
|
-
function filterTree(options, fn, input) {
|
|
12
|
-
const result = [];
|
|
13
|
-
for (const o of options)if (o.options) {
|
|
14
|
-
const kids = filterTree(o.options, fn, input);
|
|
15
|
-
if (kids.length) result.push({
|
|
16
|
-
...o,
|
|
17
|
-
options: kids
|
|
18
|
-
});
|
|
19
|
-
} else if (fn(input, o)) result.push(o);
|
|
20
|
-
return result;
|
|
21
|
-
}
|
|
22
|
-
function countLeaves(options) {
|
|
23
|
-
return options.reduce((n, o)=>n + (o.options ? countLeaves(o.options) : 1), 0);
|
|
24
|
-
}
|
|
25
8
|
function MobileSelectContentInner({ options, value, onChange, onMultiChange, showSearch, filterOption, notFoundContent = 'No results', optionRender, onClose, multiple }) {
|
|
26
9
|
const [search, setSearch] = useState('');
|
|
27
10
|
const valueArray = useMemo(()=>{
|
|
@@ -34,6 +17,9 @@ function MobileSelectContentInner({ options, value, onChange, onMultiChange, sho
|
|
|
34
17
|
value
|
|
35
18
|
]);
|
|
36
19
|
const [draft, setDraft] = useState(valueArray);
|
|
20
|
+
const draftSet = useMemo(()=>new Set(draft), [
|
|
21
|
+
draft
|
|
22
|
+
]);
|
|
37
23
|
const filteredOptions = useMemo(()=>{
|
|
38
24
|
if (!showSearch || !search) return options;
|
|
39
25
|
const fn = filterOption ?? defaultFilter;
|
|
@@ -44,6 +30,9 @@ function MobileSelectContentInner({ options, value, onChange, onMultiChange, sho
|
|
|
44
30
|
showSearch,
|
|
45
31
|
filterOption
|
|
46
32
|
]);
|
|
33
|
+
const resultCount = useMemo(()=>countLeafOptions(filteredOptions), [
|
|
34
|
+
filteredOptions
|
|
35
|
+
]);
|
|
47
36
|
const handleSelect = useCallback((optValue)=>{
|
|
48
37
|
if (multiple) setDraft((prev)=>prev.includes(optValue) ? prev.filter((v)=>v !== optValue) : [
|
|
49
38
|
...prev,
|
|
@@ -69,7 +58,7 @@ function MobileSelectContentInner({ options, value, onChange, onMultiChange, sho
|
|
|
69
58
|
let optIndex = 0;
|
|
70
59
|
const renderItem = (opt)=>{
|
|
71
60
|
const index = optIndex++;
|
|
72
|
-
const isSelected = multiple ?
|
|
61
|
+
const isSelected = multiple ? draftSet.has(opt.value) : opt.value === value;
|
|
73
62
|
return /*#__PURE__*/ jsxs("button", {
|
|
74
63
|
type: "button",
|
|
75
64
|
"data-tao-sheet-item": "",
|
|
@@ -137,7 +126,7 @@ function MobileSelectContentInner({ options, value, onChange, onMultiChange, sho
|
|
|
137
126
|
}),
|
|
138
127
|
/*#__PURE__*/ jsx("div", {
|
|
139
128
|
"data-tao-sheet-list": "",
|
|
140
|
-
children:
|
|
129
|
+
children: resultCount > 0 ? renderTree(filteredOptions) : /*#__PURE__*/ jsx("div", {
|
|
141
130
|
"data-tao-sheet-empty": "",
|
|
142
131
|
children: notFoundContent
|
|
143
132
|
})
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { SelectOption } from './select-types';
|
|
2
|
+
export interface SelectIndex {
|
|
3
|
+
optionByValue: Map<string, SelectOption>;
|
|
4
|
+
optionByToken: Map<string, SelectOption>;
|
|
5
|
+
}
|
|
6
|
+
export declare function buildSelectIndex(options: SelectOption[]): SelectIndex;
|
|
7
|
+
export declare function flattenLeafOptions(options: SelectOption[]): SelectOption[];
|
|
8
|
+
export declare function countLeafOptions(options: SelectOption[]): number;
|
|
2
9
|
export declare function defaultFilter(input: string, option: SelectOption): boolean;
|
|
3
|
-
export declare function flattenOptions(options: SelectOption[]): SelectOption[];
|
|
4
10
|
export declare function filterTree(options: SelectOption[], filter: (input: string, option: SelectOption) => boolean, input: string): SelectOption[];
|
|
@@ -1,13 +1,36 @@
|
|
|
1
|
-
function
|
|
2
|
-
const
|
|
3
|
-
|
|
1
|
+
function forEachLeafOption(options, visit) {
|
|
2
|
+
for (const option of options)if (option.options) forEachLeafOption(option.options, visit);
|
|
3
|
+
else visit(option);
|
|
4
4
|
}
|
|
5
|
-
function
|
|
5
|
+
function buildSelectIndex(options) {
|
|
6
|
+
const optionByValue = new Map();
|
|
7
|
+
const optionByToken = new Map();
|
|
8
|
+
forEachLeafOption(options, (option)=>{
|
|
9
|
+
if (!optionByValue.has(option.value)) optionByValue.set(option.value, option);
|
|
10
|
+
if (!optionByToken.has(option.value)) optionByToken.set(option.value, option);
|
|
11
|
+
if ('string' == typeof option.label && !optionByToken.has(option.label)) optionByToken.set(option.label, option);
|
|
12
|
+
});
|
|
13
|
+
return {
|
|
14
|
+
optionByValue,
|
|
15
|
+
optionByToken
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function flattenLeafOptions(options) {
|
|
6
19
|
const result = [];
|
|
7
|
-
|
|
8
|
-
else result.push(option);
|
|
20
|
+
forEachLeafOption(options, (option)=>result.push(option));
|
|
9
21
|
return result;
|
|
10
22
|
}
|
|
23
|
+
function countLeafOptions(options) {
|
|
24
|
+
let count = 0;
|
|
25
|
+
forEachLeafOption(options, ()=>{
|
|
26
|
+
count += 1;
|
|
27
|
+
});
|
|
28
|
+
return count;
|
|
29
|
+
}
|
|
30
|
+
function defaultFilter(input, option) {
|
|
31
|
+
const label = 'string' == typeof option.label ? option.label : String(option.label);
|
|
32
|
+
return label.toLowerCase().includes(input.toLowerCase());
|
|
33
|
+
}
|
|
11
34
|
function filterTree(options, filter, input) {
|
|
12
35
|
const result = [];
|
|
13
36
|
for (const option of options)if (option.options) {
|
|
@@ -19,4 +42,4 @@ function filterTree(options, filter, input) {
|
|
|
19
42
|
} else if (filter(input, option)) result.push(option);
|
|
20
43
|
return result;
|
|
21
44
|
}
|
|
22
|
-
export { defaultFilter, filterTree,
|
|
45
|
+
export { buildSelectIndex, countLeafOptions, defaultFilter, filterTree, flattenLeafOptions };
|