@tu-design/vue 0.5.9 → 0.5.10
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/index.d.mts +41 -41
- package/dist/index.mjs +18 -18
- package/dist/registry/vue/alert-dialog.json +2 -2
- package/dist/registry/vue/alert.json +1 -1
- package/dist/registry/vue/avatar-group.json +1 -1
- package/dist/registry/vue/avatar.json +1 -1
- package/dist/registry/vue/badge.json +1 -1
- package/dist/registry/vue/button.json +1 -1
- package/dist/registry/vue/calendar.json +1 -1
- package/dist/registry/vue/card.json +1 -1
- package/dist/registry/vue/cascader.json +2 -2
- package/dist/registry/vue/checkbox.json +1 -1
- package/dist/registry/vue/context-menu.json +1 -1
- package/dist/registry/vue/currency-input.json +1 -1
- package/dist/registry/vue/date-picker.json +1 -1
- package/dist/registry/vue/date-range-picker.json +2 -2
- package/dist/registry/vue/date-shared.json +2 -2
- package/dist/registry/vue/dialog.json +2 -2
- package/dist/registry/vue/drawer.json +2 -2
- package/dist/registry/vue/dropdown-menu.json +1 -1
- package/dist/registry/vue/empty.json +1 -1
- package/dist/registry/vue/form-render.json +1 -1
- package/dist/registry/vue/form.json +1 -1
- package/dist/registry/vue/icon-shared.json +1 -1
- package/dist/registry/vue/input.json +1 -1
- package/dist/registry/vue/label.json +1 -1
- package/dist/registry/vue/month-picker.json +1 -1
- package/dist/registry/vue/number-input.json +1 -1
- package/dist/registry/vue/overlay-shared.json +1 -1
- package/dist/registry/vue/password-input.json +1 -1
- package/dist/registry/vue/pin-input.json +1 -1
- package/dist/registry/vue/popconfirm.json +1 -1
- package/dist/registry/vue/popover.json +2 -2
- package/dist/registry/vue/progress.json +1 -1
- package/dist/registry/vue/radio-group.json +1 -1
- package/dist/registry/vue/registry.json +52 -52
- package/dist/registry/vue/select.json +1 -1
- package/dist/registry/vue/separator.json +1 -1
- package/dist/registry/vue/skeleton.json +1 -1
- package/dist/registry/vue/slider.json +1 -1
- package/dist/registry/vue/slot.json +1 -1
- package/dist/registry/vue/spin.json +1 -1
- package/dist/registry/vue/switch.json +1 -1
- package/dist/registry/vue/table-render.json +1 -1
- package/dist/registry/vue/tabs.json +1 -1
- package/dist/registry/vue/textarea.json +1 -1
- package/dist/registry/vue/timeline.json +1 -1
- package/dist/registry/vue/toast.json +1 -1
- package/dist/registry/vue/tokens.json +2 -2
- package/dist/registry/vue/tooltip.json +1 -1
- package/dist/registry/vue/tree-select.json +2 -2
- package/dist/registry/vue/tree-shared.json +1 -1
- package/dist/registry/vue/utils.json +1 -1
- package/dist/registry/vue/week-picker.json +1 -1
- package/dist/registry/vue/year-picker.json +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -109,10 +109,10 @@ declare const __VLS_base$34: import("vue").DefineComponent<import("vue").Extract
|
|
|
109
109
|
}>, {
|
|
110
110
|
class: string;
|
|
111
111
|
name: string;
|
|
112
|
-
checked: boolean | "indeterminate";
|
|
113
|
-
defaultChecked: boolean;
|
|
114
112
|
disabled: boolean;
|
|
115
113
|
form: string;
|
|
114
|
+
checked: boolean | "indeterminate";
|
|
115
|
+
defaultChecked: boolean;
|
|
116
116
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
117
117
|
declare const __VLS_export$52: __VLS_WithSlots$34<typeof __VLS_base$34, __VLS_Slots$34>;
|
|
118
118
|
declare const _default$9: typeof __VLS_export$52;
|
|
@@ -216,10 +216,10 @@ declare const __VLS_export$51: import("vue").DefineComponent<import("vue").Extra
|
|
|
216
216
|
"onUpdate:modelValue"?: (value: number) => any;
|
|
217
217
|
}>, {
|
|
218
218
|
class: string;
|
|
219
|
-
modelValue: number;
|
|
220
219
|
disabled: boolean;
|
|
221
|
-
placeholder: string;
|
|
222
220
|
invalid: boolean;
|
|
221
|
+
modelValue: number;
|
|
222
|
+
placeholder: string;
|
|
223
223
|
labelUnit: CurrencyUnit;
|
|
224
224
|
valueUnit: CurrencyUnit;
|
|
225
225
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -390,17 +390,17 @@ declare const __VLS_export$50: import("vue").DefineComponent<import("vue").Extra
|
|
|
390
390
|
}>, {
|
|
391
391
|
class: string;
|
|
392
392
|
max: string;
|
|
393
|
-
modelValue: string;
|
|
394
393
|
defaultValue: string;
|
|
394
|
+
disabled: boolean;
|
|
395
|
+
readOnly: boolean;
|
|
396
|
+
invalid: boolean;
|
|
397
|
+
modelValue: string;
|
|
395
398
|
min: string;
|
|
396
399
|
isDateUnavailable: (date: DateValue) => boolean;
|
|
397
400
|
locale: string;
|
|
398
|
-
disabled: boolean;
|
|
399
401
|
open: boolean;
|
|
400
402
|
defaultOpen: boolean;
|
|
401
403
|
placeholder: string;
|
|
402
|
-
invalid: boolean;
|
|
403
|
-
readOnly: boolean;
|
|
404
404
|
closeOnSelect: boolean;
|
|
405
405
|
positioning: import("@zag-js/popper").PositioningOptions;
|
|
406
406
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -566,18 +566,18 @@ declare const __VLS_export$49: import("vue").DefineComponent<import("vue").Extra
|
|
|
566
566
|
}>, {
|
|
567
567
|
class: string;
|
|
568
568
|
max: string;
|
|
569
|
-
numOfMonths: number;
|
|
570
|
-
modelValue: [string, string];
|
|
571
569
|
defaultValue: [string, string];
|
|
570
|
+
disabled: boolean;
|
|
571
|
+
readOnly: boolean;
|
|
572
|
+
invalid: boolean;
|
|
573
|
+
modelValue: [string, string];
|
|
574
|
+
numOfMonths: number;
|
|
572
575
|
min: string;
|
|
573
576
|
isDateUnavailable: (date: DateValue) => boolean;
|
|
574
577
|
locale: string;
|
|
575
|
-
disabled: boolean;
|
|
576
578
|
open: boolean;
|
|
577
579
|
defaultOpen: boolean;
|
|
578
580
|
placeholder: string;
|
|
579
|
-
invalid: boolean;
|
|
580
|
-
readOnly: boolean;
|
|
581
581
|
closeOnSelect: boolean;
|
|
582
582
|
positioning: import("@zag-js/popper").PositioningOptions;
|
|
583
583
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -743,16 +743,16 @@ declare const __VLS_export$47: import("vue").DefineComponent<import("vue").Extra
|
|
|
743
743
|
}>, {
|
|
744
744
|
class: string;
|
|
745
745
|
max: string;
|
|
746
|
-
modelValue: string;
|
|
747
746
|
defaultValue: string;
|
|
747
|
+
disabled: boolean;
|
|
748
|
+
readOnly: boolean;
|
|
749
|
+
invalid: boolean;
|
|
750
|
+
modelValue: string;
|
|
748
751
|
min: string;
|
|
749
752
|
locale: string;
|
|
750
|
-
disabled: boolean;
|
|
751
753
|
open: boolean;
|
|
752
754
|
defaultOpen: boolean;
|
|
753
755
|
placeholder: string;
|
|
754
|
-
invalid: boolean;
|
|
755
|
-
readOnly: boolean;
|
|
756
756
|
closeOnSelect: boolean;
|
|
757
757
|
positioning: import("@zag-js/popper").PositioningOptions;
|
|
758
758
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -912,17 +912,17 @@ declare const __VLS_export$46: import("vue").DefineComponent<import("vue").Extra
|
|
|
912
912
|
}>, {
|
|
913
913
|
class: string;
|
|
914
914
|
max: string;
|
|
915
|
-
modelValue: string;
|
|
916
915
|
defaultValue: string;
|
|
916
|
+
disabled: boolean;
|
|
917
|
+
readOnly: boolean;
|
|
918
|
+
invalid: boolean;
|
|
919
|
+
modelValue: string;
|
|
917
920
|
min: string;
|
|
918
921
|
isDateUnavailable: (date: DateValue) => boolean;
|
|
919
922
|
locale: string;
|
|
920
|
-
disabled: boolean;
|
|
921
923
|
open: boolean;
|
|
922
924
|
defaultOpen: boolean;
|
|
923
925
|
placeholder: string;
|
|
924
|
-
invalid: boolean;
|
|
925
|
-
readOnly: boolean;
|
|
926
926
|
closeOnSelect: boolean;
|
|
927
927
|
positioning: import("@zag-js/popper").PositioningOptions;
|
|
928
928
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -1010,10 +1010,10 @@ declare const __VLS_base$33: import("vue").DefineComponent<import("vue").Extract
|
|
|
1010
1010
|
}>, {
|
|
1011
1011
|
class: string;
|
|
1012
1012
|
max: number;
|
|
1013
|
-
modelValue: number;
|
|
1014
|
-
min: number;
|
|
1015
1013
|
disabled: boolean;
|
|
1016
1014
|
invalid: boolean;
|
|
1015
|
+
modelValue: number;
|
|
1016
|
+
min: number;
|
|
1017
1017
|
step: number;
|
|
1018
1018
|
formatOptions: Intl.NumberFormatOptions;
|
|
1019
1019
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -1113,10 +1113,10 @@ declare const __VLS_base$32: import("vue").DefineComponent<import("vue").Extract
|
|
|
1113
1113
|
"onUpdate:visible"?: (visible: boolean) => any;
|
|
1114
1114
|
}>, {
|
|
1115
1115
|
class: string;
|
|
1116
|
-
modelValue: string;
|
|
1117
1116
|
disabled: boolean;
|
|
1118
|
-
placeholder: string;
|
|
1119
1117
|
invalid: boolean;
|
|
1118
|
+
modelValue: string;
|
|
1119
|
+
placeholder: string;
|
|
1120
1120
|
visible: boolean;
|
|
1121
1121
|
autoComplete: "current-password" | "new-password";
|
|
1122
1122
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -1384,9 +1384,9 @@ declare const __VLS_export$42: import("vue").DefineComponent<import("vue").Extra
|
|
|
1384
1384
|
"onUpdate:show"?: (open: boolean) => any;
|
|
1385
1385
|
}>, {
|
|
1386
1386
|
class: string;
|
|
1387
|
-
modelValue: Key | Key[];
|
|
1388
1387
|
defaultValue: Key | Key[];
|
|
1389
1388
|
disabled: boolean;
|
|
1389
|
+
modelValue: Key | Key[];
|
|
1390
1390
|
open: boolean;
|
|
1391
1391
|
defaultOpen: boolean;
|
|
1392
1392
|
placeholder: string;
|
|
@@ -1598,9 +1598,9 @@ declare const __VLS_export$41: import("vue").DefineComponent<import("vue").Extra
|
|
|
1598
1598
|
"onUpdate:expandedKeys"?: (keys: Key[]) => any;
|
|
1599
1599
|
}>, {
|
|
1600
1600
|
class: string;
|
|
1601
|
-
modelValue: Key | Key[];
|
|
1602
1601
|
defaultValue: Key | Key[];
|
|
1603
1602
|
disabled: boolean;
|
|
1603
|
+
modelValue: Key | Key[];
|
|
1604
1604
|
open: boolean;
|
|
1605
1605
|
defaultOpen: boolean;
|
|
1606
1606
|
placeholder: string;
|
|
@@ -1735,8 +1735,8 @@ declare const __VLS_base$30: import("vue").DefineComponent<import("vue").Extract
|
|
|
1735
1735
|
"onUpdate:modelValue"?: (value: string) => any;
|
|
1736
1736
|
"onUpdate:open"?: (open: boolean) => any;
|
|
1737
1737
|
}>, {
|
|
1738
|
-
modelValue: string;
|
|
1739
1738
|
defaultValue: string;
|
|
1739
|
+
modelValue: string;
|
|
1740
1740
|
open: boolean;
|
|
1741
1741
|
defaultOpen: boolean;
|
|
1742
1742
|
placeholder: string;
|
|
@@ -1821,9 +1821,9 @@ declare const __VLS_base$29: import("vue").DefineComponent<import("vue").Extract
|
|
|
1821
1821
|
"onUpdate:checked"?: (checked: boolean) => any;
|
|
1822
1822
|
}>, {
|
|
1823
1823
|
class: string;
|
|
1824
|
+
disabled: boolean;
|
|
1824
1825
|
checked: boolean;
|
|
1825
1826
|
defaultChecked: boolean;
|
|
1826
|
-
disabled: boolean;
|
|
1827
1827
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
1828
1828
|
declare const __VLS_export$38: __VLS_WithSlots$29<typeof __VLS_base$29, __VLS_Slots$29>;
|
|
1829
1829
|
declare const _default$42: typeof __VLS_export$38;
|
|
@@ -1993,16 +1993,16 @@ declare const __VLS_export$36: import("vue").DefineComponent<import("vue").Extra
|
|
|
1993
1993
|
}>, {
|
|
1994
1994
|
class: string;
|
|
1995
1995
|
max: string;
|
|
1996
|
-
modelValue: string;
|
|
1997
1996
|
defaultValue: string;
|
|
1997
|
+
disabled: boolean;
|
|
1998
|
+
readOnly: boolean;
|
|
1999
|
+
invalid: boolean;
|
|
2000
|
+
modelValue: string;
|
|
1998
2001
|
min: string;
|
|
1999
2002
|
locale: string;
|
|
2000
|
-
disabled: boolean;
|
|
2001
2003
|
open: boolean;
|
|
2002
2004
|
defaultOpen: boolean;
|
|
2003
2005
|
placeholder: string;
|
|
2004
|
-
invalid: boolean;
|
|
2005
|
-
readOnly: boolean;
|
|
2006
2006
|
closeOnSelect: boolean;
|
|
2007
2007
|
positioning: import("@zag-js/popper").PositioningOptions;
|
|
2008
2008
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -2626,9 +2626,9 @@ declare const __VLS_base$23: import("vue").DefineComponent<import("vue").Extract
|
|
|
2626
2626
|
}>, {
|
|
2627
2627
|
mode: "day" | "month" | "year";
|
|
2628
2628
|
max: string;
|
|
2629
|
-
numOfMonths: number;
|
|
2630
|
-
modelValue: string;
|
|
2631
2629
|
defaultValue: string;
|
|
2630
|
+
modelValue: string;
|
|
2631
|
+
numOfMonths: number;
|
|
2632
2632
|
min: string;
|
|
2633
2633
|
isDateUnavailable: (date: DateValue) => boolean;
|
|
2634
2634
|
locale: string;
|
|
@@ -2819,10 +2819,10 @@ declare const __VLS_base$21: import("vue").DefineComponent<import("vue").Extract
|
|
|
2819
2819
|
defaultOpen: boolean;
|
|
2820
2820
|
lazyMount: boolean;
|
|
2821
2821
|
unmountOnExit: boolean;
|
|
2822
|
+
contentClass: string;
|
|
2822
2823
|
title: string;
|
|
2823
2824
|
description: string;
|
|
2824
2825
|
showCloseButton: boolean;
|
|
2825
|
-
contentClass: string;
|
|
2826
2826
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2827
2827
|
declare const __VLS_export$28: __VLS_WithSlots$21<typeof __VLS_base$21, __VLS_Slots$21>;
|
|
2828
2828
|
declare const _default$14: typeof __VLS_export$28;
|
|
@@ -3235,10 +3235,10 @@ declare const __VLS_base$13: import("vue").DefineComponent<import("vue").Extract
|
|
|
3235
3235
|
class: string;
|
|
3236
3236
|
length: number;
|
|
3237
3237
|
type: "numeric" | "alphanumeric";
|
|
3238
|
-
modelValue: string[];
|
|
3239
3238
|
disabled: boolean;
|
|
3240
|
-
placeholder: string;
|
|
3241
3239
|
invalid: boolean;
|
|
3240
|
+
modelValue: string[];
|
|
3241
|
+
placeholder: string;
|
|
3242
3242
|
otp: boolean;
|
|
3243
3243
|
mask: boolean;
|
|
3244
3244
|
autoSubmit: boolean;
|
|
@@ -3475,7 +3475,6 @@ declare const __VLS_base$12: import("vue").DefineComponent<import("vue").Extract
|
|
|
3475
3475
|
defaultOpen: boolean;
|
|
3476
3476
|
lazyMount: boolean;
|
|
3477
3477
|
unmountOnExit: boolean;
|
|
3478
|
-
contentClass: string;
|
|
3479
3478
|
trigger: TriggerMode;
|
|
3480
3479
|
openDelay: number;
|
|
3481
3480
|
closeDelay: number;
|
|
@@ -3488,6 +3487,7 @@ declare const __VLS_base$12: import("vue").DefineComponent<import("vue").Extract
|
|
|
3488
3487
|
to: string | HTMLElement;
|
|
3489
3488
|
matchTriggerWidth: boolean;
|
|
3490
3489
|
zIndex: number;
|
|
3490
|
+
contentClass: string;
|
|
3491
3491
|
contentProps: Record<string, unknown>;
|
|
3492
3492
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
3493
3493
|
declare const __VLS_export$16: __VLS_WithSlots$12<typeof __VLS_base$12, __VLS_Slots$12>;
|
|
@@ -4380,11 +4380,11 @@ type __VLS_Slots$10 = {} & {
|
|
|
4380
4380
|
panel?: (props: typeof __VLS_39) => any;
|
|
4381
4381
|
};
|
|
4382
4382
|
declare const __VLS_base$10: import("vue").DefineComponent<Props$2, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
4383
|
-
close: (value: string) => any;
|
|
4384
4383
|
"update:value": (value: string) => any;
|
|
4384
|
+
close: (value: string) => any;
|
|
4385
4385
|
}, string, import("vue").PublicProps, Readonly<Props$2> & Readonly<{
|
|
4386
|
-
onClose?: (value: string) => any;
|
|
4387
4386
|
"onUpdate:value"?: (value: string) => any;
|
|
4387
|
+
onClose?: (value: string) => any;
|
|
4388
4388
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
4389
4389
|
declare const __VLS_export$11: __VLS_WithSlots$10<typeof __VLS_base$10, __VLS_Slots$10>;
|
|
4390
4390
|
declare const _default$45: typeof __VLS_export$11;
|
package/dist/index.mjs
CHANGED
|
@@ -1839,8 +1839,8 @@ const _sfc_main$59 = /*@__PURE__*/ defineComponent({
|
|
|
1839
1839
|
_: 1
|
|
1840
1840
|
}, 8, ["class", "data-invalid"]),
|
|
1841
1841
|
createCommentVNode(" 弹层 Teleport:脱离表单 DOM——隔离外层 FormControl 的 group class\n (group-hover 会污染面板内全部格子),并消除 overflow 容器裁剪弹层的隐患;\n 目标经沙箱适配降级(shadow DOM / wujie graft → 应用挂载容器) "),
|
|
1842
|
-
(openBlock(), createBlock(Teleport, { to: unref(teleportTarget) }, [createVNode(unref(DatePicker).Positioner, { class: "z-[var(--z-
|
|
1843
|
-
default: withCtx(() => [createVNode(unref(DatePicker).Content, { class: normalizeClass(unref(cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 relative z-[var(--z-
|
|
1842
|
+
(openBlock(), createBlock(Teleport, { to: unref(teleportTarget) }, [createVNode(unref(DatePicker).Positioner, { class: "z-[var(--z-modal,60)]" }, {
|
|
1843
|
+
default: withCtx(() => [createVNode(unref(DatePicker).Content, { class: normalizeClass(unref(cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 relative z-[var(--z-modal,60)] rounded-md border shadow-md")) }, {
|
|
1844
1844
|
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
1845
1845
|
_: 3
|
|
1846
1846
|
}, 8, ["class"])]),
|
|
@@ -2254,8 +2254,8 @@ const _sfc_main$13 = /*@__PURE__*/ defineComponent({
|
|
|
2254
2254
|
_: 1
|
|
2255
2255
|
}, 8, ["class", "data-invalid"]),
|
|
2256
2256
|
createCommentVNode(" 弹层 Teleport:脱离表单 DOM——隔离外层 FormControl 的 group class\n (group-hover 会污染面板内全部格子),并消除 overflow 容器裁剪弹层的隐患;\n 目标经沙箱适配降级(shadow DOM / wujie graft → 应用挂载容器) "),
|
|
2257
|
-
(openBlock(), createBlock(Teleport, { to: unref(teleportTarget) }, [createVNode(unref(DatePicker).Positioner, { class: "z-[var(--z-
|
|
2258
|
-
default: withCtx(() => [createVNode(unref(DatePicker).Content, { class: normalizeClass(unref(cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 relative z-[var(--z-
|
|
2257
|
+
(openBlock(), createBlock(Teleport, { to: unref(teleportTarget) }, [createVNode(unref(DatePicker).Positioner, { class: "z-[var(--z-modal,60)]" }, {
|
|
2258
|
+
default: withCtx(() => [createVNode(unref(DatePicker).Content, { class: normalizeClass(unref(cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 relative z-[var(--z-modal,60)] rounded-md border shadow-md")) }, {
|
|
2259
2259
|
default: withCtx(() => [createVNode(unref(_sfc_main$6), { "num-of-months": props.numOfMonths }, null, 8, ["num-of-months"])]),
|
|
2260
2260
|
_: 1
|
|
2261
2261
|
}, 8, ["class"])]),
|
|
@@ -4986,9 +4986,9 @@ const _sfc_main$8 = /*@__PURE__*/ defineComponent({
|
|
|
4986
4986
|
onClick: withModifiers(handleClear, ["stop"])
|
|
4987
4987
|
}, [createVNode(CloseIcon_default, { class: "size-4 shrink-0" })])) : createCommentVNode("v-if", true), createVNode(ChevronIcon_default, { class: normalizeClass(unref(cn)("size-4 shrink-0 text-muted-foreground transition-transform", unref(isOpen) ? "-rotate-90" : "rotate-90")) }, null, 8, ["class"])])], 16, _hoisted_1$17)]),
|
|
4988
4988
|
_: 1
|
|
4989
|
-
}), (openBlock(), createBlock(Teleport, { to: unref(teleportTarget) }, [createVNode(unref(Popover).Positioner, { class: "z-[var(--z-
|
|
4989
|
+
}), (openBlock(), createBlock(Teleport, { to: unref(teleportTarget) }, [createVNode(unref(Popover).Positioner, { class: "z-[var(--z-modal,60)]" }, {
|
|
4990
4990
|
default: withCtx(() => [createVNode(unref(Popover).Content, {
|
|
4991
|
-
class: normalizeClass(unref(cn)("bg-popover text-popover-foreground z-[var(--z-
|
|
4991
|
+
class: normalizeClass(unref(cn)("bg-popover text-popover-foreground z-[var(--z-modal,60)] rounded-md border p-0 shadow-md outline-none data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95")),
|
|
4992
4992
|
style: normalizeStyle({ minWidth: panelMinWidth.value }),
|
|
4993
4993
|
onKeydown: handleKeydown
|
|
4994
4994
|
}, {
|
|
@@ -5586,9 +5586,9 @@ const _sfc_main$50 = /*@__PURE__*/ defineComponent({
|
|
|
5586
5586
|
_: 1
|
|
5587
5587
|
}),
|
|
5588
5588
|
createCommentVNode(" 弹层 Teleport:脱离表单 DOM,消除 overflow 容器裁剪隐患(DatePicker 同款);\n 目标经沙箱适配降级(shadow DOM / wujie graft → 应用挂载容器) "),
|
|
5589
|
-
(openBlock(), createBlock(Teleport, { to: unref(teleportTarget) }, [createVNode(unref(Popover).Positioner, { class: "z-[var(--z-
|
|
5589
|
+
(openBlock(), createBlock(Teleport, { to: unref(teleportTarget) }, [createVNode(unref(Popover).Positioner, { class: "z-[var(--z-modal,60)]" }, {
|
|
5590
5590
|
default: withCtx(() => [createVNode(unref(Popover).Content, {
|
|
5591
|
-
class: normalizeClass(unref(cn)("bg-popover text-popover-foreground z-[var(--z-
|
|
5591
|
+
class: normalizeClass(unref(cn)("bg-popover text-popover-foreground z-[var(--z-modal,60)] rounded-md border p-0 shadow-md outline-none data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95")),
|
|
5592
5592
|
style: normalizeStyle({ minWidth: panelMinWidth.value }),
|
|
5593
5593
|
onKeydown: handleKeydown
|
|
5594
5594
|
}, {
|
|
@@ -6281,7 +6281,7 @@ const _sfc_main$14 = /*@__PURE__*/ defineComponent({
|
|
|
6281
6281
|
setOpen(false);
|
|
6282
6282
|
}
|
|
6283
6283
|
const hasHeader = computed(() => Boolean(props.title || props.description));
|
|
6284
|
-
const contentClass = computed(() => cn("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed left-1/2 top-1/2 z-[var(--z-
|
|
6284
|
+
const contentClass = computed(() => cn("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed left-1/2 top-1/2 z-[var(--z-modal,60)] grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-lg border p-6 shadow-lg duration-200 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:max-w-lg", props.contentClass));
|
|
6285
6285
|
return (_ctx, _cache) => {
|
|
6286
6286
|
return openBlock(), createBlock(unref(Dialog).Root, {
|
|
6287
6287
|
ids: unref(rootIds),
|
|
@@ -6299,8 +6299,8 @@ const _sfc_main$14 = /*@__PURE__*/ defineComponent({
|
|
|
6299
6299
|
default: withCtx(() => [renderSlot(_ctx.$slots, "trigger")]),
|
|
6300
6300
|
_: 3
|
|
6301
6301
|
})) : createCommentVNode("v-if", true),
|
|
6302
|
-
createVNode(unref(Dialog).Backdrop, { class: "fixed inset-0 z-[var(--z-
|
|
6303
|
-
createVNode(unref(Dialog).Positioner, { class: "fixed inset-0 z-[var(--z-
|
|
6302
|
+
createVNode(unref(Dialog).Backdrop, { class: "fixed inset-0 z-[var(--z-modal,60)] bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0" }),
|
|
6303
|
+
createVNode(unref(Dialog).Positioner, { class: "fixed inset-0 z-[var(--z-modal,60)] flex items-center justify-center p-4" }, {
|
|
6304
6304
|
default: withCtx(() => [createVNode(unref(Dialog).Content, { class: normalizeClass(contentClass.value) }, {
|
|
6305
6305
|
default: withCtx(() => [
|
|
6306
6306
|
createCommentVNode(" 标题/描述:#title / #description 插槽优先,回退 title/description props;皆无则不渲染对应 DOM "),
|
|
@@ -6792,9 +6792,9 @@ const _sfc_main$34 = /*@__PURE__*/ defineComponent({
|
|
|
6792
6792
|
sameWidth: props.matchTriggerWidth || user.sameWidth
|
|
6793
6793
|
});
|
|
6794
6794
|
});
|
|
6795
|
-
const contentClass = computed(() => cn("bg-popover text-popover-foreground z-[var(--z-
|
|
6795
|
+
const contentClass = computed(() => cn("bg-popover text-popover-foreground z-[var(--z-modal,60)] w-72 rounded-md border p-4 shadow-md outline-none data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95", props.contentClass, props.contentProps?.["class"]));
|
|
6796
6796
|
const arrowClass = computed(() => cn("[--arrow-size:10px] [--arrow-background:var(--popover)]", props.arrowClass));
|
|
6797
|
-
const positionerClass = computed(() => props.zIndex != null ? "" : "z-[var(--z-
|
|
6797
|
+
const positionerClass = computed(() => props.zIndex != null ? "" : "z-[var(--z-modal,60)]");
|
|
6798
6798
|
const positionerStyle = computed(() => props.zIndex != null ? { zIndex: props.zIndex } : void 0);
|
|
6799
6799
|
return (_ctx, _cache) => {
|
|
6800
6800
|
return openBlock(), createBlock(unref(Popover).Root, mergeProps(unref(attrs), {
|
|
@@ -10477,7 +10477,7 @@ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
|
10477
10477
|
emitCancel: () => emit("cancel"),
|
|
10478
10478
|
close
|
|
10479
10479
|
});
|
|
10480
|
-
const contentClass = computed(() => cn("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed left-1/2 top-1/2 z-[var(--z-
|
|
10480
|
+
const contentClass = computed(() => cn("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed left-1/2 top-1/2 z-[var(--z-modal,60)] grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-lg border p-6 shadow-lg duration-200 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:max-w-md"));
|
|
10481
10481
|
return (_ctx, _cache) => {
|
|
10482
10482
|
return openBlock(), createBlock(unref(Dialog).Root, {
|
|
10483
10483
|
ids: unref(rootIds),
|
|
@@ -10486,7 +10486,7 @@ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
|
10486
10486
|
"close-on-interact-outside": !unref(loading),
|
|
10487
10487
|
"onUpdate:open": handleUpdate
|
|
10488
10488
|
}, {
|
|
10489
|
-
default: withCtx(() => [createVNode(unref(Dialog).Backdrop, { class: "fixed inset-0 z-[var(--z-
|
|
10489
|
+
default: withCtx(() => [createVNode(unref(Dialog).Backdrop, { class: "fixed inset-0 z-[var(--z-modal,60)] bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0" }), createVNode(unref(Dialog).Positioner, { class: "fixed inset-0 z-[var(--z-modal,60)] flex items-center justify-center p-4" }, {
|
|
10490
10490
|
default: withCtx(() => [createCommentVNode(" role=\"alertdialog\":覆盖 Ark Content 默认 role=\"dialog\",补偿无上游 AlertDialog 原语的角色语义 "), createVNode(unref(Dialog).Content, {
|
|
10491
10491
|
class: normalizeClass(contentClass.value),
|
|
10492
10492
|
role: "alertdialog",
|
|
@@ -10729,7 +10729,7 @@ const _sfc_main$15 = /*@__PURE__*/ defineComponent({
|
|
|
10729
10729
|
};
|
|
10730
10730
|
const config = computed(() => placementConfig[props.placement]);
|
|
10731
10731
|
const isLateral = computed(() => props.placement === "left" || props.placement === "right");
|
|
10732
|
-
const contentClass = computed(() => cn("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-[var(--z-
|
|
10732
|
+
const contentClass = computed(() => cn("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-[var(--z-modal,60)] flex flex-col gap-4 overflow-y-auto p-6 shadow-lg duration-200", config.value.content, isLateral.value ? cn("w-full", config.value.sizes[props.size]) : cn("h-full", config.value.sizes[props.size]), placementAnimations[props.placement]));
|
|
10733
10733
|
return (_ctx, _cache) => {
|
|
10734
10734
|
return openBlock(), createBlock(unref(Drawer).Root, {
|
|
10735
10735
|
ids: unref(rootIds),
|
|
@@ -10746,8 +10746,8 @@ const _sfc_main$15 = /*@__PURE__*/ defineComponent({
|
|
|
10746
10746
|
default: withCtx(() => [renderSlot(_ctx.$slots, "trigger")]),
|
|
10747
10747
|
_: 3
|
|
10748
10748
|
})) : createCommentVNode("v-if", true),
|
|
10749
|
-
createVNode(unref(Drawer).Backdrop, { class: "fixed inset-0 z-[var(--z-
|
|
10750
|
-
createVNode(unref(Drawer).Positioner, { class: normalizeClass(unref(cn)("fixed inset-0 z-[var(--z-
|
|
10749
|
+
createVNode(unref(Drawer).Backdrop, { class: "fixed inset-0 z-[var(--z-modal,60)] bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0" }),
|
|
10750
|
+
createVNode(unref(Drawer).Positioner, { class: normalizeClass(unref(cn)("fixed inset-0 z-[var(--z-modal,60)] flex", config.value.positioner)) }, {
|
|
10751
10751
|
default: withCtx(() => [createVNode(unref(Drawer).Content, { class: normalizeClass(contentClass.value) }, {
|
|
10752
10752
|
default: withCtx(() => [
|
|
10753
10753
|
hasHeader.value || _ctx.$slots.title || _ctx.$slots.description ? (openBlock(), createElementBlock("div", _hoisted_1, [_ctx.$slots.title || props.title ? (openBlock(), createBlock(unref(Drawer).Title, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
3
|
"name": "alert-dialog",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.10",
|
|
5
5
|
"type": "registry:ui",
|
|
6
6
|
"description": "确认弹窗单组件:v-model:open 控制显隐,title/description 传文案,@confirm/@cancel 处理确认与取消;确认处理器返回 Promise 时按钮进入 loading 并锁定 ESC/遮罩关闭,resolve 自动关闭、reject 保持打开;内容节点为 role=alertdialog。",
|
|
7
7
|
"registryDependencies": ["button", "utils", "overlay-shared"],
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"path": "alert-dialog/AlertDialog.vue",
|
|
12
12
|
"type": "registry:component",
|
|
13
13
|
"target": "components/ui/alert-dialog/AlertDialog.vue",
|
|
14
|
-
"content": "<script setup lang=\"ts\">\nimport type { PropType } from \"vue\";\nimport { computed, getCurrentInstance, useAttrs } from \"vue\";\nimport { Dialog as ArkDialog } from \"@ark-ui/vue/dialog\";\nimport { cn } from \"@/lib/utils\";\nimport { Button } from \"@/components/ui/button\";\nimport { useConfirmPending } from \"../overlay-shared/useConfirmPending\";\nimport { useControlledBoolean } from \"../overlay-shared/useControlledBoolean\";\nimport { useOverlayIds } from \"../overlay-shared/useOverlayIds\";\n\n// ids 全量覆盖(无冒号):规避 wujie patch getElementById 对 zag 缺省冒号 id 的\n// SyntaxError 刷屏(详注见 useOverlayIds);复用 dialog machine,parts 同 Dialog\nconst { ids: rootIds } = useOverlayIds(useAttrs(), {\n primary: \"content\",\n parts: [\"content\", \"title\", \"description\", \"trigger\", \"closeTrigger\", \"positioner\", \"backdrop\"],\n});\n\n// 用运行时 props 显式 default: undefined:Boolean prop 缺省时 Vue 会 cast 成 false,\n// 导致无法区分「未传(非受控)」与「传了 false(受控关闭)」。与 Dialog.vue 同款约定。\nconst props = defineProps({\n /** 受控开关(配合 v-model:open);不传时为非受控,由内部状态管理 */\n open: { type: Boolean as PropType<boolean | undefined>, default: undefined },\n /** 标题文案(#title 插槽优先) */\n title: { type: String, required: true },\n /** 描述文案(#description 插槽优先,可不传) */\n description: { type: String, default: undefined },\n /** 确认按钮文案 */\n confirmText: { type: String, default: \"确定\" },\n /** 取消按钮文案 */\n cancelText: { type: String, default: \"取消\" },\n /** 确认按钮使用 destructive 语义色(危险操作场景) */\n destructive: { type: Boolean, default: false },\n});\n\nconst emit = defineEmits<{\n \"update:open\": [open: boolean];\n confirm: [];\n cancel: [];\n}>();\n\n// 对 Root 恒走受控模式(open 恒为布尔):非受控语义由内部 ref 实现,与 Dialog.vue 一致。\n// setup 期间捕获实例:getCurrentInstance 仅在 setup/生命周期内有效,事件回调里返回 null。\nconst instance = getCurrentInstance();\nconst { isOpen, setOpen } = useControlledBoolean({\n controlled: () => props.open,\n onChange: (open) => emit(\"update:open\", open),\n});\n\nfunction handleUpdate(open: boolean) {\n // pending 期间忽略一切关闭请求(走受控桥拒绝同步,弹窗保持打开)——\n // 与 Popconfirm 同款锁定方案;Root 仍保留 :close-on-escape/:close-on-interact-outside 双保险\n if (!open && loading.value) return;\n setOpen(open);\n}\n\n/** 关闭弹窗:走受控桥把 open 置 false,退出动画/焦点还原由 zag 处理 */\nfunction close() {\n handleUpdate(false);\n}\n\n// 确认 Promise pending 时锁定关闭通道(ESC/遮罩/取消按钮全部锁死),只能等 Promise 落定\nconst { loading, handleConfirm, handleCancel } = useConfirmPending({\n instance,\n emitConfirm: () => emit(\"confirm\"),\n emitCancel: () => emit(\"cancel\"),\n close,\n});\n\n// 面板样式:复用 Dialog 的内容面板类,宽度收窄为 sm:max-w-md 的确认弹窗尺度\nconst contentClass = computed(() =>\n cn(\n \"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed left-1/2 top-1/2 z-[var(--z-
|
|
14
|
+
"content": "<script setup lang=\"ts\">\nimport type { PropType } from \"vue\";\nimport { computed, getCurrentInstance, useAttrs } from \"vue\";\nimport { Dialog as ArkDialog } from \"@ark-ui/vue/dialog\";\nimport { cn } from \"@/lib/utils\";\nimport { Button } from \"@/components/ui/button\";\nimport { useConfirmPending } from \"../overlay-shared/useConfirmPending\";\nimport { useControlledBoolean } from \"../overlay-shared/useControlledBoolean\";\nimport { useOverlayIds } from \"../overlay-shared/useOverlayIds\";\n\n// ids 全量覆盖(无冒号):规避 wujie patch getElementById 对 zag 缺省冒号 id 的\n// SyntaxError 刷屏(详注见 useOverlayIds);复用 dialog machine,parts 同 Dialog\nconst { ids: rootIds } = useOverlayIds(useAttrs(), {\n primary: \"content\",\n parts: [\"content\", \"title\", \"description\", \"trigger\", \"closeTrigger\", \"positioner\", \"backdrop\"],\n});\n\n// 用运行时 props 显式 default: undefined:Boolean prop 缺省时 Vue 会 cast 成 false,\n// 导致无法区分「未传(非受控)」与「传了 false(受控关闭)」。与 Dialog.vue 同款约定。\nconst props = defineProps({\n /** 受控开关(配合 v-model:open);不传时为非受控,由内部状态管理 */\n open: { type: Boolean as PropType<boolean | undefined>, default: undefined },\n /** 标题文案(#title 插槽优先) */\n title: { type: String, required: true },\n /** 描述文案(#description 插槽优先,可不传) */\n description: { type: String, default: undefined },\n /** 确认按钮文案 */\n confirmText: { type: String, default: \"确定\" },\n /** 取消按钮文案 */\n cancelText: { type: String, default: \"取消\" },\n /** 确认按钮使用 destructive 语义色(危险操作场景) */\n destructive: { type: Boolean, default: false },\n});\n\nconst emit = defineEmits<{\n \"update:open\": [open: boolean];\n confirm: [];\n cancel: [];\n}>();\n\n// 对 Root 恒走受控模式(open 恒为布尔):非受控语义由内部 ref 实现,与 Dialog.vue 一致。\n// setup 期间捕获实例:getCurrentInstance 仅在 setup/生命周期内有效,事件回调里返回 null。\nconst instance = getCurrentInstance();\nconst { isOpen, setOpen } = useControlledBoolean({\n controlled: () => props.open,\n onChange: (open) => emit(\"update:open\", open),\n});\n\nfunction handleUpdate(open: boolean) {\n // pending 期间忽略一切关闭请求(走受控桥拒绝同步,弹窗保持打开)——\n // 与 Popconfirm 同款锁定方案;Root 仍保留 :close-on-escape/:close-on-interact-outside 双保险\n if (!open && loading.value) return;\n setOpen(open);\n}\n\n/** 关闭弹窗:走受控桥把 open 置 false,退出动画/焦点还原由 zag 处理 */\nfunction close() {\n handleUpdate(false);\n}\n\n// 确认 Promise pending 时锁定关闭通道(ESC/遮罩/取消按钮全部锁死),只能等 Promise 落定\nconst { loading, handleConfirm, handleCancel } = useConfirmPending({\n instance,\n emitConfirm: () => emit(\"confirm\"),\n emitCancel: () => emit(\"cancel\"),\n close,\n});\n\n// 面板样式:复用 Dialog 的内容面板类,宽度收窄为 sm:max-w-md 的确认弹窗尺度\nconst contentClass = computed(() =>\n cn(\n \"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed left-1/2 top-1/2 z-[var(--z-modal,60)] grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-lg border p-6 shadow-lg duration-200 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:max-w-md\",\n ),\n);\n</script>\n\n<template>\n <ArkDialog.Root\n :ids=\"rootIds\"\n :open=\"isOpen\"\n :close-on-escape=\"!loading\"\n :close-on-interact-outside=\"!loading\"\n @update:open=\"handleUpdate\"\n >\n <ArkDialog.Backdrop\n class=\"fixed inset-0 z-[var(--z-modal,60)] bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\"\n />\n <ArkDialog.Positioner\n class=\"fixed inset-0 z-[var(--z-modal,60)] flex items-center justify-center p-4\"\n >\n <!-- role=\"alertdialog\":覆盖 Ark Content 默认 role=\"dialog\",补偿无上游 AlertDialog 原语的角色语义 -->\n <ArkDialog.Content :class=\"contentClass\" role=\"alertdialog\" aria-modal=\"true\">\n <div class=\"flex flex-col gap-2 text-center sm:text-left\">\n <ArkDialog.Title class=\"text-lg font-semibold leading-none tracking-tight\">\n <slot name=\"title\">{{ props.title }}</slot>\n </ArkDialog.Title>\n <ArkDialog.Description\n v-if=\"$slots.description || props.description\"\n class=\"text-sm text-muted-foreground\"\n >\n <slot name=\"description\">{{ props.description }}</slot>\n </ArkDialog.Description>\n </div>\n\n <!-- 默认插槽:补充正文(可选) -->\n <slot />\n\n <!-- 底部操作区:取消 outline,确认按 destructive 切换语义色;pending 时确认钮转 loading -->\n <div class=\"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end\">\n <Button variant=\"outline\" :disabled=\"loading\" @click=\"handleCancel\">\n {{ props.cancelText }}\n </Button>\n <Button\n :variant=\"props.destructive ? 'destructive' : 'default'\"\n :disabled=\"loading\"\n @click=\"handleConfirm\"\n >\n <svg\n v-if=\"loading\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n class=\"size-4 animate-spin\"\n aria-hidden=\"true\"\n >\n <path d=\"M21 12a9 9 0 1 1-6.219-8.56\" />\n </svg>\n {{ props.confirmText }}\n </Button>\n </div>\n </ArkDialog.Content>\n </ArkDialog.Positioner>\n </ArkDialog.Root>\n</template>\n"
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
17
|
"path": "alert-dialog/index.ts",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
3
|
"name": "calendar",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.10",
|
|
5
5
|
"type": "registry:ui",
|
|
6
6
|
"description": "日历(TCalendar):紧凑日历卡。Picker 弹层内为 embedded 内嵌形态(TDatePicker/TDateRangePicker 自动挂靠,纯卡片内核);独立使用即 standalone 独立形态(自带日历状态与 v-model,恒开展示)。",
|
|
7
7
|
"registryDependencies": ["icon-shared", "utils", "date-shared"],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
3
|
"name": "card",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.10",
|
|
5
5
|
"type": "registry:ui",
|
|
6
6
|
"description": "卡片容器:单组件 API,title/description 头部 + 命名插槽(cover/action/footer/header),支持尺寸、视觉变体、分段分隔与可关闭。",
|
|
7
7
|
"registryDependencies": ["utils"],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
3
|
"name": "cascader",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.10",
|
|
5
5
|
"type": "registry:ui",
|
|
6
6
|
"description": "级联选择:一站式 props 驱动,多列联动、勾选级联、路径回显与多标签。",
|
|
7
7
|
"registryDependencies": ["icon-shared", "tree-shared", "utils", "date-shared", "overlay-shared"],
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"path": "cascader/Cascader.vue",
|
|
12
12
|
"type": "registry:component",
|
|
13
13
|
"target": "components/ui/cascader/Cascader.vue",
|
|
14
|
-
"content": "<script setup lang=\"ts\">\nimport { Popover as ArkPopover } from \"@ark-ui/vue/popover\";\nimport type { PopoverRootProps } from \"@ark-ui/vue/popover\";\nimport type { PropType } from \"vue\";\nimport { computed, getCurrentInstance, nextTick, ref, useAttrs, watch } from \"vue\";\nimport { cn } from \"@/lib/utils\";\nimport { controlCls } from \"../date-shared/shared\";\nimport { useControlledBoolean } from \"../overlay-shared/useControlledBoolean\";\nimport { useOverlayIds } from \"../overlay-shared/useOverlayIds\";\nimport { useSandboxTeleportTarget, withSandboxStrategy } from \"../overlay-shared/useSandboxOverlay\";\nimport ChevronIcon from \"../icon-shared/ChevronIcon.vue\";\nimport CloseIcon from \"../icon-shared/CloseIcon.vue\";\nimport ValueTags from \"../tree-shared/ValueTags.vue\";\n\n// ids 全量覆盖(无冒号):ArkPopover 浮层载体,规避 wujie patch getElementById\n// 对 zag 缺省冒号 id 的 SyntaxError 刷屏(详注见 useOverlayIds)\nconst { ids: rootIds } = useOverlayIds(useAttrs(), {\n primary: \"content\",\n parts: [\n \"content\",\n \"title\",\n \"description\",\n \"anchor\",\n \"trigger\",\n \"closeTrigger\",\n \"positioner\",\n \"arrow\",\n ],\n});\nimport {\n createTreeMate,\n type CheckStrategy,\n type Key,\n type TreeNode,\n type TreeOption,\n} from \"../tree-shared\";\nimport { nextActiveKey, type MoveKey } from \"../tree-shared/keyboard\";\nimport CascaderPanel from \"./CascaderPanel.vue\";\n\nconst props = defineProps({\n /** 树形选项(key 必填,label 展示名,children 子级) */\n options: { type: Array as PropType<TreeOption[]>, required: true },\n /** 受控值:单选为叶子 key,multiple/checkable 为 key 数组;undefined 走内部非受控 */\n modelValue: {\n type: [String, Number, Array] as PropType<Key | Key[] | undefined>,\n default: undefined,\n },\n defaultValue: {\n type: [String, Number, Array] as PropType<Key | Key[] | undefined>,\n default: undefined,\n },\n /** 多选(值恒为数组) */\n multiple: { type: Boolean, default: false },\n /** 勾选模式(隐含 multiple,值恒为数组) */\n checkable: { type: Boolean, default: false },\n /** 级联勾选:父子联动(默认 false,对齐 naive-ui) */\n cascade: { type: Boolean, default: false },\n /** 勾选策略:all=全选节点 child=仅叶子 parent=仅父级 */\n checkStrategy: { type: String as PropType<CheckStrategy>, default: \"all\" },\n /** 下级展开触发方式 */\n expandTrigger: { type: String as PropType<\"click\" | \"hover\">, default: \"click\" },\n /** 回显是否拼接完整路径 */\n showPath: { type: Boolean, default: true },\n /** 路径拼接分隔符 */\n separator: { type: String, default: \" / \" },\n /** 展示清空按钮 */\n clearable: { type: Boolean, default: false },\n disabled: { type: Boolean as PropType<boolean | undefined>, default: undefined },\n placeholder: { type: String, default: \"请选择\" },\n /** 多选时最多展示的标签数,超出折叠为 +N */\n maxTagCount: { type: Number, default: undefined },\n /** 弹层开合受控;undefined 走内部非受控(default: undefined 禁用 Boolean casting) */\n open: { type: Boolean as PropType<boolean | undefined>, default: undefined },\n defaultOpen: { type: Boolean, default: false },\n /** Ark Popover Root 的 positioning 配置(placement/gutter 等);\n iframe realm(wujie graft / iframe 嵌入)下 strategy 未显式指定时默认 fixed */\n positioning: {\n type: Object as PropType<PopoverRootProps[\"positioning\"]>,\n default: undefined,\n },\n class: { type: String, default: undefined },\n});\n\nconst emit = defineEmits<{\n \"update:modelValue\": [value: Key | Key[] | undefined];\n /** @deprecated 请改用 update:open(v-model:open);下一个 minor 移除 */\n \"update:show\": [open: boolean];\n \"update:open\": [open: boolean];\n}>();\n\nif (import.meta.env.DEV && getCurrentInstance()?.vnode.props?.[\"onUpdate:show\"]) {\n console.warn(\"[tu-design] <Cascader> update:show 已弃用,请改用 update:open(v-model:open)。\");\n}\n\n// attrs(id/aria-*)转发给触发器,保证 TLabel/TFormControl 关联\ndefineOptions({ inheritAttrs: false });\n\nconst toArrayValue = (v: Key | Key[] | undefined): Key[] =>\n Array.isArray(v) ? v : v === undefined || v === null ? [] : [v];\n\nconst treeMate = computed(() => createTreeMate(props.options, { ignoreEmptyChildren: true }));\nconst isMulti = computed(() => props.multiple || props.checkable);\n\n// —— 受控桥接(Select 同款):Root 恒走受控,非受控语义由内部 ref 实现 ——\nconst internalValue = ref<Key | Key[] | undefined>(props.defaultValue);\nconst value = computed(() =>\n props.modelValue !== undefined ? props.modelValue : internalValue.value,\n);\nconst selectedKeys = computed<Key[]>(() => toArrayValue(value.value));\n\nconst checkedState = computed<{ checked: Key[]; indeterminate: Key[] }>(() => {\n if (!props.checkable) return { checked: [], indeterminate: [] };\n const merged = treeMate.value.getCheckedKeys(toArrayValue(value.value), {\n cascade: props.cascade,\n checkStrategy: props.checkStrategy,\n });\n return { checked: merged.checkedKeys, indeterminate: merged.indeterminateKeys };\n});\n\n// 勾选选项运行时变化:值集合按新选项归一\nwatch(\n () => [props.cascade, props.checkStrategy] as const,\n () => {\n if (!props.checkable) return;\n const merged = treeMate.value.getCheckedKeys(toArrayValue(value.value), {\n cascade: props.cascade,\n checkStrategy: props.checkStrategy,\n });\n internalValue.value = merged.checkedKeys;\n emit(\"update:modelValue\", merged.checkedKeys);\n },\n);\n\n// —— 弹层开合(点击/键盘 ↓ 显式驱动,保证各环境一致)——\nconst { isOpen, setOpen } = useControlledBoolean({\n controlled: () => props.open,\n defaultValue: () => props.defaultOpen,\n onChange: (open) => {\n emit(\"update:open\", open);\n emit(\"update:show\", open);\n },\n});\n\n// —— 沙箱适配(机制详注见 useSandboxOverlay / sandbox.ts):Teleport 目标降级\n// (shadow DOM / wujie graft → 应用挂载容器,避免面板落入 iframe body)+\n// iframe realm 下 strategy 默认 fixed(absolute 包含块错位,fixed 唯一正确解);\n// 无 to prop,面板恒传送 ——\nconst teleportTarget = useSandboxTeleportTarget(() => undefined);\nconst rootPositioning = computed(() =>\n withSandboxStrategy(props.positioning, { ...props.positioning }),\n);\n\nfunction openFromInput() {\n if (props.disabled || isOpen.value) return;\n syncPanelWidth();\n setOpen(true);\n}\n\n// —— 面板宽度对齐触发器 ——\nconst triggerEl = ref<HTMLElement | null>(null);\nconst panelMinWidth = ref(\"0px\");\nfunction syncPanelWidth() {\n panelMinWidth.value = `${triggerEl.value?.offsetWidth ?? 0}px`;\n}\n\nfunction commitValue(next: Key | Key[] | undefined) {\n internalValue.value = next;\n emit(\"update:modelValue\", next);\n}\n\nfunction handleClear() {\n commitValue(isMulti.value ? [] : undefined);\n}\n\nfunction removeTag(key: Key) {\n if (props.checkable) {\n const merged = treeMate.value.uncheck(key, toArrayValue(value.value), {\n cascade: props.cascade,\n checkStrategy: props.checkStrategy,\n });\n commitValue(merged.checkedKeys);\n return;\n }\n commitValue(selectedKeys.value.filter((k) => k !== key));\n}\n\n// —— 展开路径(单路径:展开新列即收敛到该节点路径)——\nconst expandedPath = ref<Key[]>([]);\nconst columns = computed<TreeNode[][]>(() => {\n const result: TreeNode[][] = [treeMate.value.treeNodes];\n let current = treeMate.value.treeNodes;\n for (const key of expandedPath.value) {\n const node = current.find((n) => n.key === key);\n if (!node?.children?.length) break;\n current = node.children;\n result.push(current);\n }\n return result;\n});\n\nconst expandedPathSet = computed(() => new Set(expandedPath.value));\n\nfunction isExpanded(node: TreeNode): boolean {\n return expandedPathSet.value.has(node.key);\n}\n\nfunction handleExpand(node: TreeNode) {\n expandedPath.value = treeMate.value.getPath(node.key).keyPath;\n}\n\nfunction toggleCheck(node: TreeNode) {\n const current = toArrayValue(value.value);\n const op = current.includes(node.key) ? \"uncheck\" : \"check\";\n const merged = treeMate.value[op](node.key, current, {\n cascade: props.cascade,\n checkStrategy: props.checkStrategy,\n });\n commitValue(merged.checkedKeys);\n}\n\nfunction handleSelect(node: TreeNode) {\n // 级联语义:非叶子仅展开,叶子才选中/勾选\n if (node.children?.length) {\n handleExpand(node);\n return;\n }\n if (props.checkable) {\n toggleCheck(node);\n return;\n }\n if (props.multiple) {\n const current = selectedKeys.value;\n commitValue(\n current.includes(node.key) ? current.filter((k) => k !== node.key) : [...current, node.key],\n );\n return;\n }\n commitValue(node.key);\n setOpen(false);\n}\n\n// —— 回显:showPath 拼 keyPath 标签 ——\nfunction labelOf(node: TreeNode): string {\n return (node.rawNode as TreeOption).label ?? String(node.key);\n}\n\nfunction pathLabel(key: Key): string {\n const path = treeMate.value.getPath(key).keyPath;\n return path\n .map((k) => {\n const node = treeMate.value.getNode(k);\n return node ? labelOf(node as unknown as TreeNode) : String(k);\n })\n .join(props.separator);\n}\n\nfunction displayLabel(key: Key): string {\n const node = treeMate.value.getNode(key);\n if (!node) return \"\";\n return props.showPath ? pathLabel(key) : labelOf(node as unknown as TreeNode);\n}\n\nconst singleLabel = computed(() =>\n isMulti.value ? \"\" : displayLabel(selectedKeys.value[0]!) || \"\",\n);\n\nconst tags = computed(() =>\n selectedKeys.value\n .map((key) => ({ key, label: displayLabel(key) }))\n .filter((t) => t.label !== \"\"),\n);\n\nconst hasValue = computed(() => tags.value.length > 0);\n\n// —— 键盘导航(↑↓ 在 activeKey 所在列内移动,不跨列;←→/Enter 由下方分支处理)——\nconst activeKey = ref<Key | null>(null);\nconst MOVE_KEYS: MoveKey[] = [\"ArrowDown\", \"ArrowUp\", \"Home\", \"End\"];\n\n// activeKey 落在哪一列(无 active 或找不到时视为第 0 列)\nfunction activeColumn(): TreeNode[] {\n for (const col of columns.value) {\n if (col.some((n) => n.key === activeKey.value)) return col;\n }\n return columns.value[0] ?? [];\n}\n\nfunction scrollActiveIntoView() {\n nextTick(() => {\n document\n .querySelector('[data-part=\"cascader-panel\"] [data-part=\"tree-node\"][data-active]')\n ?.scrollIntoView?.({ block: \"nearest\" });\n });\n}\n\nfunction handleKeydown(e: KeyboardEvent) {\n if (props.disabled) return;\n if (!isOpen.value) {\n if (e.key === \"ArrowDown\" || e.key === \"Enter\") {\n e.preventDefault();\n openFromInput();\n }\n return;\n }\n if ((MOVE_KEYS as string[]).includes(e.key)) {\n e.preventDefault();\n activeKey.value = nextActiveKey(activeColumn(), activeKey.value, e.key as MoveKey);\n scrollActiveIntoView();\n return;\n }\n if (e.key === \"ArrowRight\") {\n e.preventDefault();\n const node = activeColumn().find((n) => n.key === activeKey.value);\n if (node?.children?.length) {\n handleExpand(node);\n const firstChild = node.children.find((c) => !c.disabled);\n if (firstChild) activeKey.value = firstChild.key;\n }\n return;\n }\n if (e.key === \"ArrowLeft\") {\n e.preventDefault();\n const node = activeColumn().find((n) => n.key === activeKey.value);\n const parent = node?.parent;\n if (parent && !parent.ignored) {\n expandedPath.value = treeMate.value.getPath(parent.key).keyPath.slice(0, -1);\n activeKey.value = parent.key;\n }\n return;\n }\n if (e.key === \"Enter\") {\n e.preventDefault();\n const node = activeColumn().find((n) => n.key === activeKey.value);\n if (node && !node.disabled) handleSelect(node);\n }\n}\n\n// 弹层开合时重置键盘游标与展开路径\nwatch(isOpen, (open) => {\n activeKey.value = null;\n if (open) syncPanelWidth();\n else expandedPath.value = [];\n});\n</script>\n\n<template>\n <ArkPopover.Root\n :ids=\"rootIds\"\n :open=\"isOpen\"\n :positioning=\"rootPositioning\"\n @update:open=\"setOpen\"\n >\n <ArkPopover.Anchor as-child>\n <div\n ref=\"triggerEl\"\n v-bind=\"$attrs\"\n data-part=\"trigger\"\n role=\"button\"\n tabindex=\"0\"\n :aria-expanded=\"isOpen\"\n aria-haspopup=\"true\"\n :aria-disabled=\"props.disabled || undefined\"\n :class=\"\n cn(\n controlCls,\n 'min-h-9 cursor-pointer gap-2 px-3 py-1.5 text-sm',\n props.disabled && 'cursor-not-allowed opacity-50',\n props.class,\n )\n \"\n @click=\"openFromInput\"\n @keydown=\"handleKeydown\"\n >\n <template v-if=\"isMulti\">\n <ValueTags\n v-if=\"tags.length\"\n :values=\"tags\"\n :max-tag-count=\"props.maxTagCount\"\n :disabled=\"!!props.disabled\"\n @remove=\"removeTag\"\n />\n <span v-if=\"!tags.length\" class=\"truncate text-muted-foreground\">{{\n props.placeholder\n }}</span>\n </template>\n <template v-else>\n <span v-if=\"singleLabel\" class=\"truncate\">{{ singleLabel }}</span>\n <span v-else class=\"truncate text-muted-foreground\">{{ props.placeholder }}</span>\n </template>\n <span class=\"ml-auto flex shrink-0 items-center gap-1\">\n <span\n v-if=\"props.clearable && hasValue && !props.disabled\"\n role=\"button\"\n data-part=\"clear\"\n class=\"text-muted-foreground hover:text-foreground\"\n aria-label=\"清空\"\n @click.stop=\"handleClear\"\n >\n <CloseIcon class=\"size-4 shrink-0\" />\n </span>\n <ChevronIcon\n :class=\"\n cn(\n 'size-4 shrink-0 text-muted-foreground transition-transform',\n isOpen ? '-rotate-90' : 'rotate-90',\n )\n \"\n />\n </span>\n </div>\n </ArkPopover.Anchor>\n <Teleport :to=\"teleportTarget\">\n <ArkPopover.Positioner class=\"z-[var(--z-overlay)]\">\n <ArkPopover.Content\n :class=\"\n cn(\n 'bg-popover text-popover-foreground z-[var(--z-overlay)] rounded-md border p-0 shadow-md outline-none data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95',\n )\n \"\n :style=\"{ minWidth: panelMinWidth }\"\n @keydown=\"handleKeydown\"\n >\n <CascaderPanel\n :columns=\"columns\"\n :expand-trigger=\"props.expandTrigger\"\n :selected-keys=\"isMulti ? selectedKeys : []\"\n :checkable=\"props.checkable\"\n :checked-keys=\"checkedState.checked\"\n :indeterminate-keys=\"checkedState.indeterminate\"\n :active-key=\"activeKey\"\n :is-expanded=\"isExpanded\"\n @expand=\"handleExpand\"\n @select=\"handleSelect\"\n @check=\"toggleCheck\"\n />\n </ArkPopover.Content>\n </ArkPopover.Positioner>\n </Teleport>\n </ArkPopover.Root>\n</template>\n"
|
|
14
|
+
"content": "<script setup lang=\"ts\">\nimport { Popover as ArkPopover } from \"@ark-ui/vue/popover\";\nimport type { PopoverRootProps } from \"@ark-ui/vue/popover\";\nimport type { PropType } from \"vue\";\nimport { computed, getCurrentInstance, nextTick, ref, useAttrs, watch } from \"vue\";\nimport { cn } from \"@/lib/utils\";\nimport { controlCls } from \"../date-shared/shared\";\nimport { useControlledBoolean } from \"../overlay-shared/useControlledBoolean\";\nimport { useOverlayIds } from \"../overlay-shared/useOverlayIds\";\nimport { useSandboxTeleportTarget, withSandboxStrategy } from \"../overlay-shared/useSandboxOverlay\";\nimport ChevronIcon from \"../icon-shared/ChevronIcon.vue\";\nimport CloseIcon from \"../icon-shared/CloseIcon.vue\";\nimport ValueTags from \"../tree-shared/ValueTags.vue\";\n\n// ids 全量覆盖(无冒号):ArkPopover 浮层载体,规避 wujie patch getElementById\n// 对 zag 缺省冒号 id 的 SyntaxError 刷屏(详注见 useOverlayIds)\nconst { ids: rootIds } = useOverlayIds(useAttrs(), {\n primary: \"content\",\n parts: [\n \"content\",\n \"title\",\n \"description\",\n \"anchor\",\n \"trigger\",\n \"closeTrigger\",\n \"positioner\",\n \"arrow\",\n ],\n});\nimport {\n createTreeMate,\n type CheckStrategy,\n type Key,\n type TreeNode,\n type TreeOption,\n} from \"../tree-shared\";\nimport { nextActiveKey, type MoveKey } from \"../tree-shared/keyboard\";\nimport CascaderPanel from \"./CascaderPanel.vue\";\n\nconst props = defineProps({\n /** 树形选项(key 必填,label 展示名,children 子级) */\n options: { type: Array as PropType<TreeOption[]>, required: true },\n /** 受控值:单选为叶子 key,multiple/checkable 为 key 数组;undefined 走内部非受控 */\n modelValue: {\n type: [String, Number, Array] as PropType<Key | Key[] | undefined>,\n default: undefined,\n },\n defaultValue: {\n type: [String, Number, Array] as PropType<Key | Key[] | undefined>,\n default: undefined,\n },\n /** 多选(值恒为数组) */\n multiple: { type: Boolean, default: false },\n /** 勾选模式(隐含 multiple,值恒为数组) */\n checkable: { type: Boolean, default: false },\n /** 级联勾选:父子联动(默认 false,对齐 naive-ui) */\n cascade: { type: Boolean, default: false },\n /** 勾选策略:all=全选节点 child=仅叶子 parent=仅父级 */\n checkStrategy: { type: String as PropType<CheckStrategy>, default: \"all\" },\n /** 下级展开触发方式 */\n expandTrigger: { type: String as PropType<\"click\" | \"hover\">, default: \"click\" },\n /** 回显是否拼接完整路径 */\n showPath: { type: Boolean, default: true },\n /** 路径拼接分隔符 */\n separator: { type: String, default: \" / \" },\n /** 展示清空按钮 */\n clearable: { type: Boolean, default: false },\n disabled: { type: Boolean as PropType<boolean | undefined>, default: undefined },\n placeholder: { type: String, default: \"请选择\" },\n /** 多选时最多展示的标签数,超出折叠为 +N */\n maxTagCount: { type: Number, default: undefined },\n /** 弹层开合受控;undefined 走内部非受控(default: undefined 禁用 Boolean casting) */\n open: { type: Boolean as PropType<boolean | undefined>, default: undefined },\n defaultOpen: { type: Boolean, default: false },\n /** Ark Popover Root 的 positioning 配置(placement/gutter 等);\n iframe realm(wujie graft / iframe 嵌入)下 strategy 未显式指定时默认 fixed */\n positioning: {\n type: Object as PropType<PopoverRootProps[\"positioning\"]>,\n default: undefined,\n },\n class: { type: String, default: undefined },\n});\n\nconst emit = defineEmits<{\n \"update:modelValue\": [value: Key | Key[] | undefined];\n /** @deprecated 请改用 update:open(v-model:open);下一个 minor 移除 */\n \"update:show\": [open: boolean];\n \"update:open\": [open: boolean];\n}>();\n\nif (import.meta.env.DEV && getCurrentInstance()?.vnode.props?.[\"onUpdate:show\"]) {\n console.warn(\"[tu-design] <Cascader> update:show 已弃用,请改用 update:open(v-model:open)。\");\n}\n\n// attrs(id/aria-*)转发给触发器,保证 TLabel/TFormControl 关联\ndefineOptions({ inheritAttrs: false });\n\nconst toArrayValue = (v: Key | Key[] | undefined): Key[] =>\n Array.isArray(v) ? v : v === undefined || v === null ? [] : [v];\n\nconst treeMate = computed(() => createTreeMate(props.options, { ignoreEmptyChildren: true }));\nconst isMulti = computed(() => props.multiple || props.checkable);\n\n// —— 受控桥接(Select 同款):Root 恒走受控,非受控语义由内部 ref 实现 ——\nconst internalValue = ref<Key | Key[] | undefined>(props.defaultValue);\nconst value = computed(() =>\n props.modelValue !== undefined ? props.modelValue : internalValue.value,\n);\nconst selectedKeys = computed<Key[]>(() => toArrayValue(value.value));\n\nconst checkedState = computed<{ checked: Key[]; indeterminate: Key[] }>(() => {\n if (!props.checkable) return { checked: [], indeterminate: [] };\n const merged = treeMate.value.getCheckedKeys(toArrayValue(value.value), {\n cascade: props.cascade,\n checkStrategy: props.checkStrategy,\n });\n return { checked: merged.checkedKeys, indeterminate: merged.indeterminateKeys };\n});\n\n// 勾选选项运行时变化:值集合按新选项归一\nwatch(\n () => [props.cascade, props.checkStrategy] as const,\n () => {\n if (!props.checkable) return;\n const merged = treeMate.value.getCheckedKeys(toArrayValue(value.value), {\n cascade: props.cascade,\n checkStrategy: props.checkStrategy,\n });\n internalValue.value = merged.checkedKeys;\n emit(\"update:modelValue\", merged.checkedKeys);\n },\n);\n\n// —— 弹层开合(点击/键盘 ↓ 显式驱动,保证各环境一致)——\nconst { isOpen, setOpen } = useControlledBoolean({\n controlled: () => props.open,\n defaultValue: () => props.defaultOpen,\n onChange: (open) => {\n emit(\"update:open\", open);\n emit(\"update:show\", open);\n },\n});\n\n// —— 沙箱适配(机制详注见 useSandboxOverlay / sandbox.ts):Teleport 目标降级\n// (shadow DOM / wujie graft → 应用挂载容器,避免面板落入 iframe body)+\n// iframe realm 下 strategy 默认 fixed(absolute 包含块错位,fixed 唯一正确解);\n// 无 to prop,面板恒传送 ——\nconst teleportTarget = useSandboxTeleportTarget(() => undefined);\nconst rootPositioning = computed(() =>\n withSandboxStrategy(props.positioning, { ...props.positioning }),\n);\n\nfunction openFromInput() {\n if (props.disabled || isOpen.value) return;\n syncPanelWidth();\n setOpen(true);\n}\n\n// —— 面板宽度对齐触发器 ——\nconst triggerEl = ref<HTMLElement | null>(null);\nconst panelMinWidth = ref(\"0px\");\nfunction syncPanelWidth() {\n panelMinWidth.value = `${triggerEl.value?.offsetWidth ?? 0}px`;\n}\n\nfunction commitValue(next: Key | Key[] | undefined) {\n internalValue.value = next;\n emit(\"update:modelValue\", next);\n}\n\nfunction handleClear() {\n commitValue(isMulti.value ? [] : undefined);\n}\n\nfunction removeTag(key: Key) {\n if (props.checkable) {\n const merged = treeMate.value.uncheck(key, toArrayValue(value.value), {\n cascade: props.cascade,\n checkStrategy: props.checkStrategy,\n });\n commitValue(merged.checkedKeys);\n return;\n }\n commitValue(selectedKeys.value.filter((k) => k !== key));\n}\n\n// —— 展开路径(单路径:展开新列即收敛到该节点路径)——\nconst expandedPath = ref<Key[]>([]);\nconst columns = computed<TreeNode[][]>(() => {\n const result: TreeNode[][] = [treeMate.value.treeNodes];\n let current = treeMate.value.treeNodes;\n for (const key of expandedPath.value) {\n const node = current.find((n) => n.key === key);\n if (!node?.children?.length) break;\n current = node.children;\n result.push(current);\n }\n return result;\n});\n\nconst expandedPathSet = computed(() => new Set(expandedPath.value));\n\nfunction isExpanded(node: TreeNode): boolean {\n return expandedPathSet.value.has(node.key);\n}\n\nfunction handleExpand(node: TreeNode) {\n expandedPath.value = treeMate.value.getPath(node.key).keyPath;\n}\n\nfunction toggleCheck(node: TreeNode) {\n const current = toArrayValue(value.value);\n const op = current.includes(node.key) ? \"uncheck\" : \"check\";\n const merged = treeMate.value[op](node.key, current, {\n cascade: props.cascade,\n checkStrategy: props.checkStrategy,\n });\n commitValue(merged.checkedKeys);\n}\n\nfunction handleSelect(node: TreeNode) {\n // 级联语义:非叶子仅展开,叶子才选中/勾选\n if (node.children?.length) {\n handleExpand(node);\n return;\n }\n if (props.checkable) {\n toggleCheck(node);\n return;\n }\n if (props.multiple) {\n const current = selectedKeys.value;\n commitValue(\n current.includes(node.key) ? current.filter((k) => k !== node.key) : [...current, node.key],\n );\n return;\n }\n commitValue(node.key);\n setOpen(false);\n}\n\n// —— 回显:showPath 拼 keyPath 标签 ——\nfunction labelOf(node: TreeNode): string {\n return (node.rawNode as TreeOption).label ?? String(node.key);\n}\n\nfunction pathLabel(key: Key): string {\n const path = treeMate.value.getPath(key).keyPath;\n return path\n .map((k) => {\n const node = treeMate.value.getNode(k);\n return node ? labelOf(node as unknown as TreeNode) : String(k);\n })\n .join(props.separator);\n}\n\nfunction displayLabel(key: Key): string {\n const node = treeMate.value.getNode(key);\n if (!node) return \"\";\n return props.showPath ? pathLabel(key) : labelOf(node as unknown as TreeNode);\n}\n\nconst singleLabel = computed(() =>\n isMulti.value ? \"\" : displayLabel(selectedKeys.value[0]!) || \"\",\n);\n\nconst tags = computed(() =>\n selectedKeys.value\n .map((key) => ({ key, label: displayLabel(key) }))\n .filter((t) => t.label !== \"\"),\n);\n\nconst hasValue = computed(() => tags.value.length > 0);\n\n// —— 键盘导航(↑↓ 在 activeKey 所在列内移动,不跨列;←→/Enter 由下方分支处理)——\nconst activeKey = ref<Key | null>(null);\nconst MOVE_KEYS: MoveKey[] = [\"ArrowDown\", \"ArrowUp\", \"Home\", \"End\"];\n\n// activeKey 落在哪一列(无 active 或找不到时视为第 0 列)\nfunction activeColumn(): TreeNode[] {\n for (const col of columns.value) {\n if (col.some((n) => n.key === activeKey.value)) return col;\n }\n return columns.value[0] ?? [];\n}\n\nfunction scrollActiveIntoView() {\n nextTick(() => {\n document\n .querySelector('[data-part=\"cascader-panel\"] [data-part=\"tree-node\"][data-active]')\n ?.scrollIntoView?.({ block: \"nearest\" });\n });\n}\n\nfunction handleKeydown(e: KeyboardEvent) {\n if (props.disabled) return;\n if (!isOpen.value) {\n if (e.key === \"ArrowDown\" || e.key === \"Enter\") {\n e.preventDefault();\n openFromInput();\n }\n return;\n }\n if ((MOVE_KEYS as string[]).includes(e.key)) {\n e.preventDefault();\n activeKey.value = nextActiveKey(activeColumn(), activeKey.value, e.key as MoveKey);\n scrollActiveIntoView();\n return;\n }\n if (e.key === \"ArrowRight\") {\n e.preventDefault();\n const node = activeColumn().find((n) => n.key === activeKey.value);\n if (node?.children?.length) {\n handleExpand(node);\n const firstChild = node.children.find((c) => !c.disabled);\n if (firstChild) activeKey.value = firstChild.key;\n }\n return;\n }\n if (e.key === \"ArrowLeft\") {\n e.preventDefault();\n const node = activeColumn().find((n) => n.key === activeKey.value);\n const parent = node?.parent;\n if (parent && !parent.ignored) {\n expandedPath.value = treeMate.value.getPath(parent.key).keyPath.slice(0, -1);\n activeKey.value = parent.key;\n }\n return;\n }\n if (e.key === \"Enter\") {\n e.preventDefault();\n const node = activeColumn().find((n) => n.key === activeKey.value);\n if (node && !node.disabled) handleSelect(node);\n }\n}\n\n// 弹层开合时重置键盘游标与展开路径\nwatch(isOpen, (open) => {\n activeKey.value = null;\n if (open) syncPanelWidth();\n else expandedPath.value = [];\n});\n</script>\n\n<template>\n <ArkPopover.Root\n :ids=\"rootIds\"\n :open=\"isOpen\"\n :positioning=\"rootPositioning\"\n @update:open=\"setOpen\"\n >\n <ArkPopover.Anchor as-child>\n <div\n ref=\"triggerEl\"\n v-bind=\"$attrs\"\n data-part=\"trigger\"\n role=\"button\"\n tabindex=\"0\"\n :aria-expanded=\"isOpen\"\n aria-haspopup=\"true\"\n :aria-disabled=\"props.disabled || undefined\"\n :class=\"\n cn(\n controlCls,\n 'min-h-9 cursor-pointer gap-2 px-3 py-1.5 text-sm',\n props.disabled && 'cursor-not-allowed opacity-50',\n props.class,\n )\n \"\n @click=\"openFromInput\"\n @keydown=\"handleKeydown\"\n >\n <template v-if=\"isMulti\">\n <ValueTags\n v-if=\"tags.length\"\n :values=\"tags\"\n :max-tag-count=\"props.maxTagCount\"\n :disabled=\"!!props.disabled\"\n @remove=\"removeTag\"\n />\n <span v-if=\"!tags.length\" class=\"truncate text-muted-foreground\">{{\n props.placeholder\n }}</span>\n </template>\n <template v-else>\n <span v-if=\"singleLabel\" class=\"truncate\">{{ singleLabel }}</span>\n <span v-else class=\"truncate text-muted-foreground\">{{ props.placeholder }}</span>\n </template>\n <span class=\"ml-auto flex shrink-0 items-center gap-1\">\n <span\n v-if=\"props.clearable && hasValue && !props.disabled\"\n role=\"button\"\n data-part=\"clear\"\n class=\"text-muted-foreground hover:text-foreground\"\n aria-label=\"清空\"\n @click.stop=\"handleClear\"\n >\n <CloseIcon class=\"size-4 shrink-0\" />\n </span>\n <ChevronIcon\n :class=\"\n cn(\n 'size-4 shrink-0 text-muted-foreground transition-transform',\n isOpen ? '-rotate-90' : 'rotate-90',\n )\n \"\n />\n </span>\n </div>\n </ArkPopover.Anchor>\n <Teleport :to=\"teleportTarget\">\n <ArkPopover.Positioner class=\"z-[var(--z-modal,60)]\">\n <ArkPopover.Content\n :class=\"\n cn(\n 'bg-popover text-popover-foreground z-[var(--z-modal,60)] rounded-md border p-0 shadow-md outline-none data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95',\n )\n \"\n :style=\"{ minWidth: panelMinWidth }\"\n @keydown=\"handleKeydown\"\n >\n <CascaderPanel\n :columns=\"columns\"\n :expand-trigger=\"props.expandTrigger\"\n :selected-keys=\"isMulti ? selectedKeys : []\"\n :checkable=\"props.checkable\"\n :checked-keys=\"checkedState.checked\"\n :indeterminate-keys=\"checkedState.indeterminate\"\n :active-key=\"activeKey\"\n :is-expanded=\"isExpanded\"\n @expand=\"handleExpand\"\n @select=\"handleSelect\"\n @check=\"toggleCheck\"\n />\n </ArkPopover.Content>\n </ArkPopover.Positioner>\n </Teleport>\n </ArkPopover.Root>\n</template>\n"
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
17
|
"path": "cascader/CascaderPanel.vue",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
3
|
"name": "context-menu",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.10",
|
|
5
5
|
"type": "registry:ui",
|
|
6
6
|
"description": "右键菜单:单组件模式,items 描述菜单项(与 dropdown-menu 同构,含分组/标题/分隔线,支持嵌套),默认插槽为触发元素(ContextTrigger as-child,右键唤出并定位到指针处),内置键盘导航与选中回调。",
|
|
7
7
|
"registryDependencies": ["overlay-shared", "utils", "dropdown-menu"],
|