@rockshin/tao-ui 0.0.47 → 0.0.49
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/dist/components/affix/affix.js +20 -16
- package/dist/components/alert/alert.js +114 -99
- package/dist/components/app/app-modals.js +134 -96
- package/dist/components/app/app-notices.js +39 -23
- package/dist/components/auto-complete/auto-complete.js +21 -7
- package/dist/components/avatar/avatar.js +31 -11
- package/dist/components/badge/badge.css +1 -1
- package/dist/components/badge/badge.js +72 -257
- package/dist/components/border-beam/border-beam.js +21 -17
- package/dist/components/breadcrumb/breadcrumb.js +178 -159
- package/dist/components/button/button.js +61 -53
- package/dist/components/calendar/calendar.js +6 -4
- package/dist/components/card/card.js +24 -8
- package/dist/components/carousel/carousel.d.ts +1 -1
- package/dist/components/carousel/carousel.js +105 -68
- package/dist/components/cascader/cascader.js +54 -19
- package/dist/components/checkbox/checkbox.css +13 -2
- package/dist/components/checkbox/checkbox.d.ts +2 -0
- package/dist/components/checkbox/checkbox.js +320 -229
- package/dist/components/collapse/collapse-panels.d.ts +1 -1
- package/dist/components/collapse/collapse-panels.js +122 -113
- package/dist/components/collapse/collapse.js +98 -63
- package/dist/components/color-picker/color-picker.js +539 -441
- package/dist/components/color-picker/color.js +1 -1
- package/dist/components/context-menu/context-menu.d.ts +1 -1
- package/dist/components/context-menu/context-menu.js +108 -68
- package/dist/components/date-picker/calendar/calendar-grid.js +42 -39
- package/dist/components/date-picker/calendar/month-grid.d.ts +8 -1
- package/dist/components/date-picker/calendar/month-grid.js +79 -37
- package/dist/components/date-picker/calendar/time-panel.d.ts +2 -1
- package/dist/components/date-picker/calendar/time-panel.js +94 -89
- package/dist/components/date-picker/calendar/year-grid.d.ts +8 -1
- package/dist/components/date-picker/calendar/year-grid.js +66 -35
- package/dist/components/date-picker/date-picker.css +24 -1
- package/dist/components/date-picker/date-picker.js +99 -53
- package/dist/components/date-picker/presets.d.ts +2 -1
- package/dist/components/date-picker/presets.js +27 -24
- package/dist/components/date-picker/range-picker.js +308 -153
- package/dist/components/descriptions/descriptions.js +7 -3
- package/dist/components/divider/divider.css +1 -1
- package/dist/components/divider/divider.js +1 -1
- package/dist/components/drawer/drawer.js +201 -369
- package/dist/components/dropdown/dropdown.d.ts +1 -1
- package/dist/components/dropdown/dropdown.js +183 -279
- package/dist/components/empty/empty.js +57 -78
- package/dist/components/float-button/float-button.d.ts +1 -0
- package/dist/components/float-button/float-button.js +47 -30
- package/dist/components/form/field-control.d.ts +4 -2
- package/dist/components/form/field-control.js +17 -9
- package/dist/components/form/form-context.d.ts +8 -2
- package/dist/components/form/form-context.js +2 -1
- package/dist/components/form/form-item.js +85 -63
- package/dist/components/form/form.css +3 -2
- package/dist/components/form/use-form.d.ts +2 -1
- package/dist/components/form/use-form.js +2 -1
- package/dist/components/form-field/form-field-view.d.ts +3 -1
- package/dist/components/form-field/form-field-view.js +194 -141
- package/dist/components/form-section/form-section.d.ts +1 -1
- package/dist/components/form-section/form-section.js +52 -45
- package/dist/components/image/image.js +585 -477
- package/dist/components/input/base-input.js +8 -9
- package/dist/components/input/input-shared.d.ts +5 -2
- package/dist/components/input/input-shared.js +42 -18
- package/dist/components/input/otp.js +236 -217
- package/dist/components/input/password.js +2 -1
- package/dist/components/input/search.js +8 -7
- package/dist/components/list/list-pagination.js +41 -36
- package/dist/components/list/list.js +141 -125
- package/dist/components/listy/listy.js +175 -106
- package/dist/components/masonry/masonry.js +108 -85
- package/dist/components/mentions/mentions.js +12 -3
- package/dist/components/menu/menu-render.d.ts +9 -3
- package/dist/components/menu/menu-render.js +99 -36
- package/dist/components/modal/confirm-dialog.js +10 -4
- package/dist/components/modal/confirm.js +3 -7
- package/dist/components/modal/index.js +9 -3
- package/dist/components/modal/modal.js +390 -365
- package/dist/components/pagination/pagination.js +105 -96
- package/dist/components/popconfirm/popconfirm.d.ts +1 -1
- package/dist/components/popconfirm/popconfirm.js +219 -168
- package/dist/components/popover/popover.js +330 -243
- package/dist/components/progress/progress.css +2 -2
- package/dist/components/progress/progress.js +232 -458
- package/dist/components/qr-code/qr-code.js +72 -66
- package/dist/components/radio/radio.css +15 -4
- package/dist/components/radio/radio.d.ts +2 -1
- package/dist/components/radio/radio.js +260 -198
- package/dist/components/rate/rate.js +173 -113
- package/dist/components/scroll-area/scroll-area.js +241 -211
- package/dist/components/segmented/segmented.js +73 -41
- package/dist/components/select/mobile-select.d.ts +2 -1
- package/dist/components/select/mobile-select.js +24 -13
- package/dist/components/select/select-searchable-list.d.ts +2 -1
- package/dist/components/select/select-searchable-list.js +2 -3
- package/dist/components/select/select.js +49 -25
- package/dist/components/select/use-select-selection.d.ts +1 -1
- package/dist/components/select/use-select-selection.js +7 -4
- package/dist/components/skeleton/skeleton.js +56 -48
- package/dist/components/slider/slider.js +87 -212
- package/dist/components/sonner/sonner.js +109 -93
- package/dist/components/spinner/spinner.js +147 -138
- package/dist/components/splitter/splitter.js +222 -159
- package/dist/components/statistic/statistic.js +7 -6
- package/dist/components/steps/steps.js +88 -81
- package/dist/components/steps/use-display-steps.js +1 -1
- package/dist/components/switch/switch.js +89 -89
- package/dist/components/table/table-filter.js +66 -56
- package/dist/components/table/table-icons.d.ts +2 -1
- package/dist/components/table/table-icons.js +11 -9
- package/dist/components/table/table-model.js +1 -1
- package/dist/components/table/table.js +107 -83
- package/dist/components/table/use-table-data.d.ts +6 -3
- package/dist/components/table/use-table-data.js +166 -130
- package/dist/components/tabs/tabs.css +1 -1
- package/dist/components/tabs/tabs.js +236 -179
- package/dist/components/tag/tag.d.ts +2 -2
- package/dist/components/tag/tag.js +111 -108
- package/dist/components/textarea/textarea.js +22 -17
- package/dist/components/time-picker/time-picker.js +5 -3
- package/dist/components/timeline/timeline.css +6 -1
- package/dist/components/timeline/timeline.js +21 -11
- package/dist/components/tooltip/tooltip.d.ts +2 -2
- package/dist/components/tooltip/tooltip.js +123 -233
- package/dist/components/tour/tour.css +4 -0
- package/dist/components/tour/tour.js +400 -331
- package/dist/components/transfer/transfer-list.js +29 -11
- package/dist/components/transfer/transfer-parts.js +1 -1
- package/dist/components/transfer/transfer-types.d.ts +1 -0
- package/dist/components/transfer/transfer.js +29 -14
- package/dist/components/tree/tree-keyboard.d.ts +1 -1
- package/dist/components/tree/tree-keyboard.js +5 -3
- package/dist/components/tree/tree.js +74 -59
- package/dist/components/tree-select/select-engine.d.ts +3 -2
- package/dist/components/tree-select/select-engine.js +18 -16
- package/dist/components/tree-select/tree-select.js +21 -5
- package/dist/components/upload/upload.css +8 -0
- package/dist/components/upload/upload.js +160 -72
- package/dist/components/watermark/watermark.js +36 -29
- package/dist/number-input/use-number-input.js +129 -90
- package/dist/number-input/validate.js +32 -5
- package/dist/provider/merge-locale.js +12 -9
- package/dist/provider/tao-provider.d.ts +3 -1
- package/dist/provider/tao-provider.js +123 -86
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
3
3
|
import { TaoPortalScope, useTaoConfig } from "../../provider/tao-provider.js";
|
|
4
4
|
import { cx } from "../../utils/semantic.js";
|
|
@@ -32,7 +32,7 @@ function clearRuntimeTimers(runtime) {
|
|
|
32
32
|
}
|
|
33
33
|
function beginExit(id) {
|
|
34
34
|
const runtime = runtimes.get(id);
|
|
35
|
-
if (!runtime || !state.toasts.some((toast)=>toast.id === id)) return;
|
|
35
|
+
if (!runtime || !state.toasts.some((toast)=>toast.id === id && 'active' === toast.phase)) return;
|
|
36
36
|
clearRuntimeTimers(runtime);
|
|
37
37
|
state = {
|
|
38
38
|
toasts: state.toasts.map((toast)=>toast.id === id ? {
|
|
@@ -53,21 +53,21 @@ function beginExit(id) {
|
|
|
53
53
|
}, REMOVE_DELAY);
|
|
54
54
|
}
|
|
55
55
|
function dismiss(id) {
|
|
56
|
-
if (id) return void beginExit(id);
|
|
56
|
+
if (void 0 !== id) return void beginExit(id);
|
|
57
57
|
for (const toast of state.toasts)beginExit(toast.id);
|
|
58
58
|
}
|
|
59
59
|
function scheduleDismiss(id, duration) {
|
|
60
60
|
const runtime = runtimes.get(id);
|
|
61
61
|
if (!runtime) return;
|
|
62
62
|
if (runtime.dismissTimer) clearTimeout(runtime.dismissTimer);
|
|
63
|
-
if (null == duration || duration <= 0) return;
|
|
63
|
+
if (null == duration || !Number.isFinite(duration) || duration <= 0) return;
|
|
64
64
|
const generation = runtime.generation;
|
|
65
65
|
runtime.dismissTimer = setTimeout(()=>{
|
|
66
66
|
if (runtimes.get(id)?.generation === generation) beginExit(id);
|
|
67
67
|
}, duration);
|
|
68
68
|
}
|
|
69
69
|
function isToastOptions(value) {
|
|
70
|
-
return null != value && 'object' == typeof value && !
|
|
70
|
+
return null != value && 'object' == typeof value && !(Symbol.iterator in value) && !('$$typeof' in value);
|
|
71
71
|
}
|
|
72
72
|
function normalizeOptions(options) {
|
|
73
73
|
return isToastOptions(options) ? options : {
|
|
@@ -101,9 +101,18 @@ function create(type, options, custom) {
|
|
|
101
101
|
scheduleDismiss(id, normalized.duration);
|
|
102
102
|
return id;
|
|
103
103
|
}
|
|
104
|
-
function settlePromiseToast(id, generation, type,
|
|
105
|
-
|
|
106
|
-
if (!
|
|
104
|
+
function settlePromiseToast(id, generation, type, renderOptions) {
|
|
105
|
+
const isActive = ()=>runtimes.get(id)?.generation === generation && state.toasts.some((toast)=>toast.id === id && 'active' === toast.phase);
|
|
106
|
+
if (!isActive()) return;
|
|
107
|
+
let options;
|
|
108
|
+
try {
|
|
109
|
+
options = renderOptions();
|
|
110
|
+
} catch (error) {
|
|
111
|
+
if (isActive()) dismiss(id);
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
if (!isActive()) return;
|
|
115
|
+
if (!options && 0 !== options) return void dismiss(id);
|
|
107
116
|
const normalized = normalizeOptions(options);
|
|
108
117
|
create(type, {
|
|
109
118
|
...normalized,
|
|
@@ -133,7 +142,7 @@ function getAriaLabel(type, messages) {
|
|
|
133
142
|
}
|
|
134
143
|
}
|
|
135
144
|
function renderPromiseState(stateValue, payload) {
|
|
136
|
-
if (!stateValue) return;
|
|
145
|
+
if (!stateValue && 0 !== stateValue) return;
|
|
137
146
|
if ('function' == typeof stateValue) return stateValue(payload);
|
|
138
147
|
return stateValue;
|
|
139
148
|
}
|
|
@@ -150,11 +159,9 @@ function Sonner({ position = 'bottom-right', visibleToasts = 3, offset = 24, gap
|
|
|
150
159
|
snapshot.toasts
|
|
151
160
|
]);
|
|
152
161
|
const visible = useMemo(()=>{
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
return sliced.slice(-visibleToasts).reverse();
|
|
162
|
+
const count = Math.floor(visibleToasts);
|
|
163
|
+
return count > 0 ? snapshot.toasts.slice(-count).reverse() : [];
|
|
156
164
|
}, [
|
|
157
|
-
expand,
|
|
158
165
|
snapshot.toasts,
|
|
159
166
|
visibleToasts
|
|
160
167
|
]);
|
|
@@ -198,14 +205,14 @@ function Sonner({ position = 'bottom-right', visibleToasts = 3, offset = 24, gap
|
|
|
198
205
|
function ToastView({ toast, richColors, showClose, yPosition, index, visibleToasts, expanded, offset, frontToastHeight, setHeights, classNames, styles }) {
|
|
199
206
|
const { locale: { messages } } = useTaoConfig();
|
|
200
207
|
const [mounted, setMounted] = useState(false);
|
|
201
|
-
const
|
|
208
|
+
const offsetBeforeRemove = useRef(offset);
|
|
202
209
|
const ref = useRef(null);
|
|
203
210
|
useEffect(()=>{
|
|
204
211
|
const frame = requestAnimationFrame(()=>setMounted(true));
|
|
205
212
|
return ()=>cancelAnimationFrame(frame);
|
|
206
213
|
}, []);
|
|
207
|
-
|
|
208
|
-
if ('
|
|
214
|
+
useLayoutEffect(()=>{
|
|
215
|
+
if ('active' === toast.phase) offsetBeforeRemove.current = offset;
|
|
209
216
|
}, [
|
|
210
217
|
offset,
|
|
211
218
|
toast.phase
|
|
@@ -213,14 +220,23 @@ function ToastView({ toast, richColors, showClose, yPosition, index, visibleToas
|
|
|
213
220
|
useLayoutEffect(()=>{
|
|
214
221
|
const node = ref.current;
|
|
215
222
|
if (!node) return;
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
223
|
+
const updateHeight = (nextHeight)=>{
|
|
224
|
+
setHeights((current)=>{
|
|
225
|
+
if (current.get(toast.id) === nextHeight) return current;
|
|
226
|
+
const next = new Map(current);
|
|
227
|
+
next.set(toast.id, nextHeight);
|
|
228
|
+
return next;
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
updateHeight(node.getBoundingClientRect().height);
|
|
232
|
+
const observer = "u" < typeof ResizeObserver ? void 0 : new ResizeObserver(([entry])=>{
|
|
233
|
+
updateHeight(entry.borderBoxSize?.[0]?.blockSize ?? node.getBoundingClientRect().height);
|
|
234
|
+
});
|
|
235
|
+
observer?.observe(node, {
|
|
236
|
+
box: 'border-box'
|
|
222
237
|
});
|
|
223
238
|
return ()=>{
|
|
239
|
+
observer?.disconnect();
|
|
224
240
|
setHeights((current_0)=>{
|
|
225
241
|
if (!current_0.has(toast.id)) return current_0;
|
|
226
242
|
const next_0 = new Map(current_0);
|
|
@@ -239,8 +255,14 @@ function ToastView({ toast, richColors, showClose, yPosition, index, visibleToas
|
|
|
239
255
|
]);
|
|
240
256
|
const isFront = 0 === index;
|
|
241
257
|
const isVisible = index < visibleToasts;
|
|
242
|
-
const
|
|
243
|
-
|
|
258
|
+
const exiting = 'exiting' === toast.phase;
|
|
259
|
+
const activeOffset = exiting ? offsetBeforeRemove.current : offset;
|
|
260
|
+
function dismissAfterAction(action) {
|
|
261
|
+
if (exiting || !state.toasts.includes(toast)) return;
|
|
262
|
+
action?.onClick?.();
|
|
263
|
+
if (state.toasts.includes(toast)) dismiss(toast.id);
|
|
264
|
+
}
|
|
265
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
244
266
|
ref: ref,
|
|
245
267
|
className: cx(classNames?.toast),
|
|
246
268
|
role: "status",
|
|
@@ -250,7 +272,7 @@ function ToastView({ toast, richColors, showClose, yPosition, index, visibleToas
|
|
|
250
272
|
"data-tao-type": resolveDataType(toast.type, richColors),
|
|
251
273
|
"data-tao-mounted": mounted,
|
|
252
274
|
"data-tao-y-position": yPosition,
|
|
253
|
-
"data-tao-removing":
|
|
275
|
+
"data-tao-removing": exiting ? 'true' : 'false',
|
|
254
276
|
"data-tao-front": isFront ? 'true' : 'false',
|
|
255
277
|
"data-tao-expanded": expanded ? 'true' : 'false',
|
|
256
278
|
"data-tao-visible": isVisible ? 'true' : 'false',
|
|
@@ -261,68 +283,63 @@ function ToastView({ toast, richColors, showClose, yPosition, index, visibleToas
|
|
|
261
283
|
['--tao-sonner-front-height']: `${frontToastHeight}px`,
|
|
262
284
|
['--tao-sonner-z-index']: String(visibleToasts - index)
|
|
263
285
|
},
|
|
264
|
-
children:
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
(
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}) : null
|
|
322
|
-
]
|
|
323
|
-
})
|
|
324
|
-
]
|
|
325
|
-
})
|
|
286
|
+
children: [
|
|
287
|
+
toast.custom || 0 === toast.custom ? toast.custom : /*#__PURE__*/ jsxs("div", {
|
|
288
|
+
className: cx(classNames?.content),
|
|
289
|
+
style: styles?.content,
|
|
290
|
+
"data-tao-sonner-content": "",
|
|
291
|
+
children: [
|
|
292
|
+
toast.title || 0 === toast.title ? /*#__PURE__*/ jsx("div", {
|
|
293
|
+
className: cx(classNames?.title),
|
|
294
|
+
style: styles?.title,
|
|
295
|
+
"data-tao-sonner-title": "",
|
|
296
|
+
children: toast.title
|
|
297
|
+
}) : null,
|
|
298
|
+
toast.description || 0 === toast.description ? /*#__PURE__*/ jsx("div", {
|
|
299
|
+
className: cx(classNames?.description),
|
|
300
|
+
style: styles?.description,
|
|
301
|
+
"data-tao-sonner-description": "",
|
|
302
|
+
children: toast.description
|
|
303
|
+
}) : null
|
|
304
|
+
]
|
|
305
|
+
}),
|
|
306
|
+
(toast.action || toast.cancel || showClose) && /*#__PURE__*/ jsxs("div", {
|
|
307
|
+
className: cx(classNames?.actions),
|
|
308
|
+
style: styles?.actions,
|
|
309
|
+
"data-tao-sonner-actions": "",
|
|
310
|
+
"data-tao-close-only": toast.action || toast.cancel || !showClose ? void 0 : '',
|
|
311
|
+
children: [
|
|
312
|
+
toast.cancel ? /*#__PURE__*/ jsx(Button, {
|
|
313
|
+
variant: "ghost",
|
|
314
|
+
size: "small",
|
|
315
|
+
className: cx(classNames?.cancel),
|
|
316
|
+
style: styles?.cancel,
|
|
317
|
+
disabled: exiting,
|
|
318
|
+
onClick: ()=>dismissAfterAction(toast.cancel),
|
|
319
|
+
children: toast.cancel.label
|
|
320
|
+
}) : null,
|
|
321
|
+
toast.action ? /*#__PURE__*/ jsx(Button, {
|
|
322
|
+
variant: "secondary",
|
|
323
|
+
size: "small",
|
|
324
|
+
className: cx(classNames?.action),
|
|
325
|
+
style: styles?.action,
|
|
326
|
+
disabled: exiting,
|
|
327
|
+
onClick: ()=>dismissAfterAction(toast.action),
|
|
328
|
+
children: toast.action.label
|
|
329
|
+
}) : null,
|
|
330
|
+
showClose ? /*#__PURE__*/ jsx("button", {
|
|
331
|
+
type: "button",
|
|
332
|
+
"aria-label": messages.closeNotification,
|
|
333
|
+
className: cx(classNames?.close),
|
|
334
|
+
style: styles?.close,
|
|
335
|
+
disabled: exiting,
|
|
336
|
+
"data-tao-sonner-close": "",
|
|
337
|
+
onClick: ()=>dismissAfterAction(),
|
|
338
|
+
children: "\xd7"
|
|
339
|
+
}) : null
|
|
340
|
+
]
|
|
341
|
+
})
|
|
342
|
+
]
|
|
326
343
|
});
|
|
327
344
|
}
|
|
328
345
|
const baseToast = (options)=>create('default', options);
|
|
@@ -348,16 +365,15 @@ const sonner_toast = Object.assign(baseToast, {
|
|
|
348
365
|
duration: 0
|
|
349
366
|
});
|
|
350
367
|
const generation = runtimes.get(id)?.generation;
|
|
368
|
+
let value;
|
|
351
369
|
try {
|
|
352
|
-
|
|
353
|
-
const success = renderPromiseState(messages.success, value);
|
|
354
|
-
settlePromiseToast(id, generation, 'success', success);
|
|
355
|
-
return value;
|
|
370
|
+
value = await promise;
|
|
356
371
|
} catch (error) {
|
|
357
|
-
|
|
358
|
-
settlePromiseToast(id, generation, 'error', failure);
|
|
372
|
+
settlePromiseToast(id, generation, 'error', ()=>renderPromiseState(messages.error, error));
|
|
359
373
|
throw error;
|
|
360
374
|
}
|
|
375
|
+
settlePromiseToast(id, generation, 'success', ()=>renderPromiseState(messages.success, value));
|
|
376
|
+
return value;
|
|
361
377
|
},
|
|
362
378
|
dismiss: dismiss
|
|
363
379
|
});
|