@brumaombra/ui-vintage 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +75 -78
  3. package/dist/{AlertDialogTitle.vue_vue_type_script_setup_true_lang-CWCr2erD.js → AlertDialogTitle.vue_vue_type_script_setup_true_lang-Ca0g2mVz.js} +8 -8
  4. package/dist/{Busy-B65Nd9ec.js → Busy-DSyPtpVD.js} +1 -1
  5. package/dist/BusyIndicator-D-4YHN2L.js +4 -0
  6. package/dist/{CalendarPrevButton.vue_vue_type_script_setup_true_lang-C-WnFnvj.js → CalendarPrevButton.vue_vue_type_script_setup_true_lang-Dqz6DIGp.js} +22 -22
  7. package/dist/{Collection-CmOoLBo7.js → Collection-Coi6nyvb.js} +1 -1
  8. package/dist/ConfirmDialog-Zu4m9TY-.js +4 -0
  9. package/dist/{DialogClose-BNlqG4G2.js → DialogClose-DDtZ0Em0.js} +2 -2
  10. package/dist/{x-2_VzbDS9.js → DialogPortal-BTVR2QvT.js} +12 -12
  11. package/dist/{DialogTitle-DXj0nkXn.js → DialogTitle-CLuntLBB.js} +5 -5
  12. package/dist/{DialogTitle.vue_vue_type_script_setup_true_lang-Bw40D4AK.js → DialogTitle.vue_vue_type_script_setup_true_lang-83YQbiAn.js} +4 -4
  13. package/dist/{DialogTrigger-CpyKnu11.js → DialogTrigger-CjJ8QNL_.js} +3 -3
  14. package/dist/{FocusScope-C3mcVwsf.js → FocusScope-DYbCtSNc.js} +4 -4
  15. package/dist/{Input.vue_vue_type_script_setup_true_lang-U778IWa0.js → Input.vue_vue_type_script_setup_true_lang-6SfPeT8d.js} +1 -1
  16. package/dist/{Label.vue_vue_type_script_setup_true_lang-B_fwvfJ-.js → Label.vue_vue_type_script_setup_true_lang-pMIzCHzV.js} +2 -2
  17. package/dist/MessageDialog-ChS4d2qN.js +4 -0
  18. package/dist/{NativeSelectOption.vue_vue_type_script_setup_true_lang-DS87OTLT.js → NativeSelectOption.vue_vue_type_script_setup_true_lang-CWhL2Lw8.js} +2 -2
  19. package/dist/{PopoverTrigger.vue_vue_type_script_setup_true_lang-KTcg6Jnl.js → PopoverTrigger.vue_vue_type_script_setup_true_lang-DFZJvU_P.js} +9 -9
  20. package/dist/{PopperContent-BiM0YLO3.js → PopperContent-h-thLTz8.js} +3 -3
  21. package/dist/{Separator.vue_vue_type_script_setup_true_lang-COrZ60NR.js → Separator.vue_vue_type_script_setup_true_lang-CMRkdntA.js} +1 -1
  22. package/dist/{SheetTitle.vue_vue_type_script_setup_true_lang-DLoXGMbx.js → SheetTitle.vue_vue_type_script_setup_true_lang-fx9jbBwT.js} +4 -4
  23. package/dist/{Slider.vue_vue_type_script_setup_true_lang-D-cAN-4Q.js → Slider.vue_vue_type_script_setup_true_lang-C_CsSGAt.js} +7 -7
  24. package/dist/{Switch.vue_vue_type_script_setup_true_lang-BWKCycMm.js → Switch.vue_vue_type_script_setup_true_lang-BG6nkPSO.js} +5 -5
  25. package/dist/{Teleport-CuUn4UkG.js → Teleport-CV0tKbq5.js} +3 -3
  26. package/dist/{TooltipTrigger.vue_vue_type_script_setup_true_lang-BRyHTWgw.js → TooltipTrigger.vue_vue_type_script_setup_true_lang-DEPKysA_.js} +5 -5
  27. package/dist/{VisuallyHiddenInput-DLAsRwUw.js → VisuallyHiddenInput-1G1IEkBL.js} +1 -1
  28. package/dist/alert-dialog.js +161 -9
  29. package/dist/busy-indicator.js +64 -4
  30. package/dist/busy.js +1 -1
  31. package/dist/calendar.js +1 -1
  32. package/dist/card.js +110 -7
  33. package/dist/command.js +20 -20
  34. package/dist/components/dashboard-shell/DashboardShell.vue.d.ts +1 -1
  35. package/dist/components/ui/button/index.d.ts +1 -1
  36. package/dist/components/ui/sidebar/SidebarMenuButton.vue.d.ts +1 -1
  37. package/dist/components/ui/sidebar/SidebarMenuButtonChild.vue.d.ts +1 -1
  38. package/dist/confirm-dialog.js +228 -7
  39. package/dist/dashboard-shell.js +170 -3
  40. package/dist/date-picker.js +91 -3
  41. package/dist/dialog.js +140 -6
  42. package/dist/field.js +2 -2
  43. package/dist/{index-C1_fxYhb.js → index-Cq9Ekgtb.js} +2 -2
  44. package/dist/{index-Dfi5ESP2.js → index-qGMU40e1.js} +1 -1
  45. package/dist/input.js +1 -1
  46. package/dist/label.js +1 -1
  47. package/dist/message-dialog.js +240 -6
  48. package/dist/native-select.js +1 -1
  49. package/dist/popover.js +62 -5
  50. package/dist/select.js +2122 -12
  51. package/dist/separator.js +1 -1
  52. package/dist/sheet.js +61 -5
  53. package/dist/sidebar.js +6 -6
  54. package/dist/slider-form-component.js +58 -3
  55. package/dist/slider.js +1 -1
  56. package/dist/style.css +4 -4016
  57. package/dist/switch-form-component.js +38 -3
  58. package/dist/switch.js +1 -1
  59. package/dist/tooltip.js +27 -3
  60. package/dist/{useFocusGuards-tgErlvMF.js → useFocusGuards-WYWvpJy2.js} +1 -1
  61. package/dist/{useFormControl-7ytzz-r7.js → useFormControl-CyoJwp9r.js} +1 -1
  62. package/dist/{useForwardExpose-CNVHwdF2.js → useForwardExpose-BiRQH8eO.js} +1 -1
  63. package/dist/{usePrimitiveElement-CijaRBgF.js → usePrimitiveElement-Bk3ZOslv.js} +1 -1
  64. package/dist/{useSize-DO9Z3wC4.js → useSize-BLYTFgnQ.js} +1 -1
  65. package/dist/{useTypeahead-Dqe1QXq1.js → useTypeahead-KTl4-oeq.js} +2 -2
  66. package/dist/{utils-RRmyeqLm.js → utils-BXBXPGDA.js} +1 -1
  67. package/package.json +188 -186
  68. package/dist/AlertDialogTrigger.vue_vue_type_script_setup_true_lang-vNwxOYhM.js +0 -158
  69. package/dist/BusyIndicator-CnWzSMDb.js +0 -4
  70. package/dist/BusyIndicator.vue_vue_type_script_setup_true_lang-CYeXMI_V.js +0 -66
  71. package/dist/CardTitle.vue_vue_type_script_setup_true_lang-DVAd7AWF.js +0 -112
  72. package/dist/ConfirmDialog-DEsvF0b_.js +0 -4
  73. package/dist/ConfirmDialog.vue_vue_type_script_setup_true_lang-BAd1l1zF.js +0 -230
  74. package/dist/DashboardShell.vue_vue_type_script_setup_true_lang-CT2SQBXv.js +0 -171
  75. package/dist/DatePicker.vue_vue_type_script_setup_true_lang-D8mev2ha.js +0 -92
  76. package/dist/DialogTrigger.vue_vue_type_script_setup_true_lang-DLrFiCsw.js +0 -141
  77. package/dist/MessageDialog-BrowppID.js +0 -4
  78. package/dist/MessageDialog.vue_vue_type_script_setup_true_lang-Ddih5Isd.js +0 -242
  79. package/dist/PopoverAnchor.vue_vue_type_script_setup_true_lang-CsfybvZp.js +0 -61
  80. package/dist/SelectValue.vue_vue_type_script_setup_true_lang-DGAI4hw5.js +0 -2124
  81. package/dist/SheetTrigger.vue_vue_type_script_setup_true_lang-CE2XJNHy.js +0 -62
  82. package/dist/SliderFormComponent.vue_vue_type_script_setup_true_lang-KPzC_Lmr.js +0 -59
  83. package/dist/SwitchFormComponent.vue_vue_type_script_setup_true_lang-XOBEs3pa.js +0 -39
  84. package/dist/TooltipProvider.vue_vue_type_script_setup_true_lang-DwIfCQjY.js +0 -28
  85. package/dist/alert-dialog.d.ts +0 -2
  86. package/dist/alert.d.ts +0 -2
  87. package/dist/background-grid.d.ts +0 -6
  88. package/dist/busy-indicator.d.ts +0 -2
  89. package/dist/busy.d.ts +0 -2
  90. package/dist/button.d.ts +0 -2
  91. package/dist/calendar.d.ts +0 -2
  92. package/dist/card.d.ts +0 -2
  93. package/dist/command.d.ts +0 -2
  94. package/dist/confirm-dialog.d.ts +0 -2
  95. package/dist/dashboard-shell.d.ts +0 -6
  96. package/dist/date-picker.d.ts +0 -6
  97. package/dist/dialog.d.ts +0 -2
  98. package/dist/field.d.ts +0 -2
  99. package/dist/index.d.ts +0 -28
  100. package/dist/index.js +0 -171
  101. package/dist/input.d.ts +0 -2
  102. package/dist/label.d.ts +0 -2
  103. package/dist/message-dialog.d.ts +0 -2
  104. package/dist/native-select.d.ts +0 -2
  105. package/dist/popover.d.ts +0 -2
  106. package/dist/select.d.ts +0 -2
  107. package/dist/separator.d.ts +0 -2
  108. package/dist/sheet.d.ts +0 -2
  109. package/dist/sidebar.d.ts +0 -2
  110. package/dist/skeleton.d.ts +0 -2
  111. package/dist/slider-form-component.d.ts +0 -6
  112. package/dist/slider.d.ts +0 -2
  113. package/dist/switch-form-component.d.ts +0 -6
  114. package/dist/switch.d.ts +0 -2
  115. package/dist/tooltip.d.ts +0 -2
  116. package/dist/utils.d.ts +0 -2
@@ -1,158 +0,0 @@
1
- import { defineComponent, openBlock, createBlock, unref, normalizeProps, guardReactiveProps, withCtx, renderSlot, onMounted, mergeProps } from "vue";
2
- import { u as useForwardExpose } from "./useForwardExpose-CNVHwdF2.js";
3
- import { D as DialogClose_default } from "./DialogClose-BNlqG4G2.js";
4
- import { c as cn } from "./utils-Bz4m9VPB.js";
5
- import { buttonVariants } from "./button.js";
6
- import { r as reactiveOmit } from "./index-Dfi5ESP2.js";
7
- import { i as injectAlertDialogContentContext } from "./AlertDialogTitle.vue_vue_type_script_setup_true_lang-CWCr2erD.js";
8
- import { D as DialogTrigger_default } from "./DialogTrigger-CpyKnu11.js";
9
- var AlertDialogAction_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
10
- __name: "AlertDialogAction",
11
- props: {
12
- asChild: {
13
- type: Boolean,
14
- required: false
15
- },
16
- as: {
17
- type: null,
18
- required: false,
19
- default: "button"
20
- }
21
- },
22
- setup(__props) {
23
- const props = __props;
24
- useForwardExpose();
25
- return (_ctx, _cache) => {
26
- return openBlock(), createBlock(unref(DialogClose_default), normalizeProps(guardReactiveProps(props)), {
27
- default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
28
- _: 3
29
- }, 16);
30
- };
31
- }
32
- });
33
- var AlertDialogAction_default = AlertDialogAction_vue_vue_type_script_setup_true_lang_default;
34
- var AlertDialogCancel_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
35
- __name: "AlertDialogCancel",
36
- props: {
37
- asChild: {
38
- type: Boolean,
39
- required: false
40
- },
41
- as: {
42
- type: null,
43
- required: false,
44
- default: "button"
45
- }
46
- },
47
- setup(__props) {
48
- const props = __props;
49
- const contentContext = injectAlertDialogContentContext();
50
- const { forwardRef, currentElement } = useForwardExpose();
51
- onMounted(() => {
52
- contentContext.onCancelElementChange(currentElement.value);
53
- });
54
- return (_ctx, _cache) => {
55
- return openBlock(), createBlock(unref(DialogClose_default), mergeProps(props, { ref: unref(forwardRef) }), {
56
- default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
57
- _: 3
58
- }, 16);
59
- };
60
- }
61
- });
62
- var AlertDialogCancel_default = AlertDialogCancel_vue_vue_type_script_setup_true_lang_default;
63
- var AlertDialogTrigger_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
64
- __name: "AlertDialogTrigger",
65
- props: {
66
- asChild: {
67
- type: Boolean,
68
- required: false
69
- },
70
- as: {
71
- type: null,
72
- required: false,
73
- default: "button"
74
- }
75
- },
76
- setup(__props) {
77
- const props = __props;
78
- useForwardExpose();
79
- return (_ctx, _cache) => {
80
- return openBlock(), createBlock(unref(DialogTrigger_default), normalizeProps(guardReactiveProps(props)), {
81
- default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
82
- _: 3
83
- }, 16);
84
- };
85
- }
86
- });
87
- var AlertDialogTrigger_default = AlertDialogTrigger_vue_vue_type_script_setup_true_lang_default;
88
- const _sfc_main$2 = /* @__PURE__ */ defineComponent({
89
- __name: "AlertDialogAction",
90
- props: {
91
- asChild: { type: Boolean },
92
- as: {},
93
- class: {}
94
- },
95
- setup(__props) {
96
- const props = __props;
97
- const delegatedProps = reactiveOmit(props, "class");
98
- return (_ctx, _cache) => {
99
- return openBlock(), createBlock(unref(AlertDialogAction_default), mergeProps(unref(delegatedProps), {
100
- class: unref(cn)(unref(buttonVariants)(), props.class)
101
- }), {
102
- default: withCtx(() => [
103
- renderSlot(_ctx.$slots, "default")
104
- ]),
105
- _: 3
106
- }, 16, ["class"]);
107
- };
108
- }
109
- });
110
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
111
- __name: "AlertDialogCancel",
112
- props: {
113
- asChild: { type: Boolean },
114
- as: {},
115
- class: {}
116
- },
117
- setup(__props) {
118
- const props = __props;
119
- const delegatedProps = reactiveOmit(props, "class");
120
- return (_ctx, _cache) => {
121
- return openBlock(), createBlock(unref(AlertDialogCancel_default), mergeProps(unref(delegatedProps), {
122
- class: unref(cn)(
123
- unref(buttonVariants)({ variant: "outline" }),
124
- "mt-2 sm:mt-0",
125
- props.class
126
- )
127
- }), {
128
- default: withCtx(() => [
129
- renderSlot(_ctx.$slots, "default")
130
- ]),
131
- _: 3
132
- }, 16, ["class"]);
133
- };
134
- }
135
- });
136
- const _sfc_main = /* @__PURE__ */ defineComponent({
137
- __name: "AlertDialogTrigger",
138
- props: {
139
- asChild: { type: Boolean },
140
- as: {}
141
- },
142
- setup(__props) {
143
- const props = __props;
144
- return (_ctx, _cache) => {
145
- return openBlock(), createBlock(unref(AlertDialogTrigger_default), mergeProps({ "data-slot": "alert-dialog-trigger" }, props), {
146
- default: withCtx(() => [
147
- renderSlot(_ctx.$slots, "default")
148
- ]),
149
- _: 3
150
- }, 16);
151
- };
152
- }
153
- });
154
- export {
155
- _sfc_main$2 as _,
156
- _sfc_main$1 as a,
157
- _sfc_main as b
158
- };
@@ -1,4 +0,0 @@
1
- import { _ as _sfc_main } from "./BusyIndicator.vue_vue_type_script_setup_true_lang-CYeXMI_V.js";
2
- export {
3
- _sfc_main as default
4
- };
@@ -1,66 +0,0 @@
1
- import { reactive, render, h, defineComponent, openBlock, createBlock, unref, normalizeClass } from "vue";
2
- import { B as Busy } from "./Busy-B65Nd9ec.js";
3
- const BUSY_INDICATOR_ROOT_ID = "ui-vintage-busy-indicator-root";
4
- let busyIndicatorMountPromise = null;
5
- const busyIndicatorState = reactive({
6
- show: false,
7
- label: "Loading...",
8
- class: void 0,
9
- overlayClass: void 0
10
- });
11
- const ensureBusyIndicatorMounted = () => {
12
- if (typeof document === "undefined") {
13
- return Promise.resolve();
14
- }
15
- const existingRoot = document.getElementById(BUSY_INDICATOR_ROOT_ID);
16
- if (existingRoot) {
17
- return Promise.resolve();
18
- }
19
- if (busyIndicatorMountPromise) {
20
- return busyIndicatorMountPromise;
21
- }
22
- busyIndicatorMountPromise = (async () => {
23
- const { default: BusyIndicator } = await import("./BusyIndicator-CnWzSMDb.js");
24
- if (document.getElementById(BUSY_INDICATOR_ROOT_ID)) {
25
- return;
26
- }
27
- const container = document.createElement("div");
28
- container.id = BUSY_INDICATOR_ROOT_ID;
29
- document.body.appendChild(container);
30
- render(h(BusyIndicator), container);
31
- })().finally(() => {
32
- busyIndicatorMountPromise = null;
33
- });
34
- return busyIndicatorMountPromise;
35
- };
36
- const setBusy = (show, options = {}) => {
37
- if (show) {
38
- busyIndicatorState.label = options.label ?? busyIndicatorState.label ?? "Loading...";
39
- busyIndicatorState.class = options.class;
40
- busyIndicatorState.overlayClass = options.overlayClass;
41
- void ensureBusyIndicatorMounted();
42
- }
43
- busyIndicatorState.show = show;
44
- if (!show) {
45
- busyIndicatorState.class = void 0;
46
- busyIndicatorState.overlayClass = void 0;
47
- }
48
- };
49
- const _sfc_main = /* @__PURE__ */ defineComponent({
50
- __name: "BusyIndicator",
51
- setup(__props) {
52
- return (_ctx, _cache) => {
53
- return openBlock(), createBlock(unref(Busy), {
54
- show: unref(busyIndicatorState).show,
55
- label: unref(busyIndicatorState).label,
56
- class: normalizeClass(unref(busyIndicatorState).class),
57
- "overlay-class": unref(busyIndicatorState).overlayClass
58
- }, null, 8, ["show", "label", "class", "overlay-class"]);
59
- };
60
- }
61
- });
62
- export {
63
- _sfc_main as _,
64
- busyIndicatorState as b,
65
- setBusy as s
66
- };
@@ -1,112 +0,0 @@
1
- import { defineComponent, openBlock, createElementBlock, normalizeClass, unref, renderSlot } from "vue";
2
- import { c as cn } from "./utils-Bz4m9VPB.js";
3
- const _sfc_main$5 = /* @__PURE__ */ defineComponent({
4
- __name: "CardAction",
5
- props: {
6
- class: {}
7
- },
8
- setup(__props) {
9
- const props = __props;
10
- return (_ctx, _cache) => {
11
- return openBlock(), createElementBlock("div", {
12
- "data-slot": "card-action",
13
- class: normalizeClass(unref(cn)("col-start-2 row-span-2 row-start-1 self-start justify-self-end", props.class))
14
- }, [
15
- renderSlot(_ctx.$slots, "default")
16
- ], 2);
17
- };
18
- }
19
- });
20
- const _sfc_main$4 = /* @__PURE__ */ defineComponent({
21
- __name: "CardContent",
22
- props: {
23
- class: {}
24
- },
25
- setup(__props) {
26
- const props = __props;
27
- return (_ctx, _cache) => {
28
- return openBlock(), createElementBlock("div", {
29
- "data-slot": "card-content",
30
- class: normalizeClass(unref(cn)("px-6", props.class))
31
- }, [
32
- renderSlot(_ctx.$slots, "default")
33
- ], 2);
34
- };
35
- }
36
- });
37
- const _sfc_main$3 = /* @__PURE__ */ defineComponent({
38
- __name: "CardDescription",
39
- props: {
40
- class: {}
41
- },
42
- setup(__props) {
43
- const props = __props;
44
- return (_ctx, _cache) => {
45
- return openBlock(), createElementBlock("p", {
46
- "data-slot": "card-description",
47
- class: normalizeClass(unref(cn)("text-muted-foreground text-sm", props.class))
48
- }, [
49
- renderSlot(_ctx.$slots, "default")
50
- ], 2);
51
- };
52
- }
53
- });
54
- const _sfc_main$2 = /* @__PURE__ */ defineComponent({
55
- __name: "CardFooter",
56
- props: {
57
- class: {}
58
- },
59
- setup(__props) {
60
- const props = __props;
61
- return (_ctx, _cache) => {
62
- return openBlock(), createElementBlock("div", {
63
- "data-slot": "card-footer",
64
- class: normalizeClass(unref(cn)("flex items-center px-6 [.border-t]:pt-6", props.class))
65
- }, [
66
- renderSlot(_ctx.$slots, "default")
67
- ], 2);
68
- };
69
- }
70
- });
71
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
72
- __name: "CardHeader",
73
- props: {
74
- class: {}
75
- },
76
- setup(__props) {
77
- const props = __props;
78
- return (_ctx, _cache) => {
79
- return openBlock(), createElementBlock("div", {
80
- "data-slot": "card-header",
81
- class: normalizeClass(unref(cn)("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6", props.class))
82
- }, [
83
- renderSlot(_ctx.$slots, "default")
84
- ], 2);
85
- };
86
- }
87
- });
88
- const _sfc_main = /* @__PURE__ */ defineComponent({
89
- __name: "CardTitle",
90
- props: {
91
- class: {}
92
- },
93
- setup(__props) {
94
- const props = __props;
95
- return (_ctx, _cache) => {
96
- return openBlock(), createElementBlock("h3", {
97
- "data-slot": "card-title",
98
- class: normalizeClass(unref(cn)("leading-none font-semibold", props.class))
99
- }, [
100
- renderSlot(_ctx.$slots, "default")
101
- ], 2);
102
- };
103
- }
104
- });
105
- export {
106
- _sfc_main$5 as _,
107
- _sfc_main$4 as a,
108
- _sfc_main$3 as b,
109
- _sfc_main$2 as c,
110
- _sfc_main$1 as d,
111
- _sfc_main as e
112
- };
@@ -1,4 +0,0 @@
1
- import { _ as _sfc_main } from "./ConfirmDialog.vue_vue_type_script_setup_true_lang-BAd1l1zF.js";
2
- export {
3
- _sfc_main as default
4
- };
@@ -1,230 +0,0 @@
1
- import { reactive, render, h, markRaw, defineComponent, computed, openBlock, createBlock, unref, withCtx, createElementVNode, resolveDynamicComponent, createVNode, createTextVNode, toDisplayString, createCommentVNode } from "vue";
2
- import { _ as _sfc_main$1, a as _sfc_main$2, d as _sfc_main$3, e as _sfc_main$4, b as _sfc_main$5, c as _sfc_main$6 } from "./AlertDialogTitle.vue_vue_type_script_setup_true_lang-CWCr2erD.js";
3
- import { Button as _sfc_main$7 } from "./button.js";
4
- import { I as Info } from "./info-DZrSmi42.js";
5
- const confirmDialogQueue = [];
6
- let nextConfirmDialogId = 0;
7
- const DIALOG_CLOSE_DURATION_MS = 300;
8
- let closeTimer = null;
9
- let confirmDialogMountPromise = null;
10
- const CONFIRM_DIALOG_ROOT_ID = "ui-vintage-confirm-dialog-root";
11
- const confirmDialogState = reactive({
12
- current: null,
13
- busy: false,
14
- isOpen: false
15
- });
16
- const markIcon = (icon) => icon ? markRaw(icon) : null;
17
- const ensureConfirmDialogMounted = () => {
18
- if (typeof document === "undefined") {
19
- return Promise.resolve();
20
- }
21
- const existingRoot = document.getElementById(CONFIRM_DIALOG_ROOT_ID);
22
- if (existingRoot) {
23
- return Promise.resolve();
24
- }
25
- if (confirmDialogMountPromise) {
26
- return confirmDialogMountPromise;
27
- }
28
- confirmDialogMountPromise = (async () => {
29
- const { default: ConfirmDialog } = await import("./ConfirmDialog-DEsvF0b_.js");
30
- if (document.getElementById(CONFIRM_DIALOG_ROOT_ID)) {
31
- return;
32
- }
33
- const container = document.createElement("div");
34
- container.id = CONFIRM_DIALOG_ROOT_ID;
35
- document.body.appendChild(container);
36
- render(h(ConfirmDialog), container);
37
- })().finally(() => {
38
- confirmDialogMountPromise = null;
39
- });
40
- return confirmDialogMountPromise;
41
- };
42
- const openNextConfirmDialog = () => {
43
- const nextDialog = confirmDialogQueue.shift() ?? null;
44
- confirmDialogState.current = nextDialog;
45
- confirmDialogState.isOpen = Boolean(nextDialog);
46
- };
47
- const enqueueConfirmDialog = (request) => {
48
- confirmDialogQueue.push(request);
49
- if (!confirmDialogState.current) {
50
- openNextConfirmDialog();
51
- }
52
- };
53
- const clearCurrentConfirmDialog = () => {
54
- confirmDialogState.busy = false;
55
- confirmDialogState.isOpen = false;
56
- confirmDialogState.current = null;
57
- openNextConfirmDialog();
58
- };
59
- const scheduleCloseCurrentConfirmDialog = () => {
60
- if (!confirmDialogState.current || !confirmDialogState.isOpen) {
61
- return;
62
- }
63
- confirmDialogState.isOpen = false;
64
- if (closeTimer) {
65
- clearTimeout(closeTimer);
66
- }
67
- closeTimer = setTimeout(() => {
68
- closeTimer = null;
69
- clearCurrentConfirmDialog();
70
- }, DIALOG_CLOSE_DURATION_MS);
71
- };
72
- const closeConfirmDialog = () => {
73
- const current = confirmDialogState.current;
74
- if (!current || !confirmDialogState.isOpen) {
75
- return;
76
- }
77
- current.resolve(false);
78
- scheduleCloseCurrentConfirmDialog();
79
- };
80
- const cancelActiveConfirmDialog = async () => {
81
- var _a, _b;
82
- const current = confirmDialogState.current;
83
- if (!current || confirmDialogState.busy) {
84
- return;
85
- }
86
- confirmDialogState.busy = true;
87
- try {
88
- await ((_b = (_a = current.options).onCancel) == null ? void 0 : _b.call(_a));
89
- current.resolve(false);
90
- } finally {
91
- scheduleCloseCurrentConfirmDialog();
92
- }
93
- };
94
- const confirmActiveDialog = async () => {
95
- var _a, _b;
96
- const current = confirmDialogState.current;
97
- if (!current || confirmDialogState.busy) {
98
- return;
99
- }
100
- confirmDialogState.busy = true;
101
- try {
102
- await ((_b = (_a = current.options).onConfirm) == null ? void 0 : _b.call(_a));
103
- current.resolve(true);
104
- } finally {
105
- scheduleCloseCurrentConfirmDialog();
106
- }
107
- };
108
- const showConfirmDialog = (options) => {
109
- void ensureConfirmDialogMounted();
110
- return new Promise((resolve) => {
111
- enqueueConfirmDialog({
112
- id: nextConfirmDialogId += 1,
113
- options: {
114
- title: options.title ?? "Confirm",
115
- message: options.message,
116
- confirmText: options.confirmText ?? "Confirm",
117
- cancelText: options.cancelText ?? "Cancel",
118
- confirmButtonType: options.confirmButtonType ?? "default",
119
- cancelButtonType: options.cancelButtonType ?? "outline",
120
- icon: markIcon(options.icon),
121
- confirmButtonIcon: markIcon(options.confirmButtonIcon),
122
- cancelButtonIcon: markIcon(options.cancelButtonIcon),
123
- onConfirm: options.onConfirm ?? null,
124
- onCancel: options.onCancel ?? null
125
- },
126
- resolve
127
- });
128
- });
129
- };
130
- const _hoisted_1 = { class: "px-5 pb-5 pt-5 sm:px-6 sm:pb-4 sm:pt-6" };
131
- const _hoisted_2 = { class: "flex flex-col gap-4 sm:flex-row sm:items-start" };
132
- const _hoisted_3 = { class: "flex size-12 shrink-0 self-center items-center justify-center rounded border border-[var(--border-light)] bg-[var(--bg-surface-light)] sm:size-10 sm:self-start dark:border-[var(--border-dark)] dark:bg-[var(--bg-surface-dark)]" };
133
- const _sfc_main = /* @__PURE__ */ defineComponent({
134
- __name: "ConfirmDialog",
135
- setup(__props) {
136
- const currentDialog = computed(() => confirmDialogState.current);
137
- const confirmIcon = computed(() => {
138
- var _a;
139
- return ((_a = currentDialog.value) == null ? void 0 : _a.options.icon) ?? Info;
140
- });
141
- const handleOpenChange = (open) => {
142
- if (!open) {
143
- closeConfirmDialog();
144
- }
145
- };
146
- return (_ctx, _cache) => {
147
- return openBlock(), createBlock(unref(_sfc_main$1), {
148
- open: unref(confirmDialogState).isOpen,
149
- "onUpdate:open": handleOpenChange
150
- }, {
151
- default: withCtx(() => [
152
- currentDialog.value ? (openBlock(), createBlock(unref(_sfc_main$2), { key: 0 }, {
153
- default: withCtx(() => [
154
- createElementVNode("div", _hoisted_1, [
155
- createElementVNode("div", _hoisted_2, [
156
- createElementVNode("div", _hoisted_3, [
157
- (openBlock(), createBlock(resolveDynamicComponent(confirmIcon.value), {
158
- "stroke-width": 1.8,
159
- class: "size-6 text-[var(--button-primary-light)] dark:text-[var(--button-primary-dark)]"
160
- }))
161
- ]),
162
- createVNode(unref(_sfc_main$3), { class: "sm:pt-0" }, {
163
- default: withCtx(() => [
164
- createVNode(unref(_sfc_main$4), null, {
165
- default: withCtx(() => [
166
- createTextVNode(toDisplayString(currentDialog.value.options.title), 1)
167
- ]),
168
- _: 1
169
- }),
170
- createVNode(unref(_sfc_main$5), null, {
171
- default: withCtx(() => [
172
- createTextVNode(toDisplayString(currentDialog.value.options.message), 1)
173
- ]),
174
- _: 1
175
- })
176
- ]),
177
- _: 1
178
- })
179
- ])
180
- ]),
181
- createVNode(unref(_sfc_main$6), null, {
182
- default: withCtx(() => [
183
- createVNode(unref(_sfc_main$7), {
184
- variant: currentDialog.value.options.cancelButtonType,
185
- disabled: unref(confirmDialogState).busy,
186
- onClick: unref(cancelActiveConfirmDialog)
187
- }, {
188
- default: withCtx(() => [
189
- currentDialog.value.options.cancelButtonIcon ? (openBlock(), createBlock(resolveDynamicComponent(currentDialog.value.options.cancelButtonIcon), {
190
- key: 0,
191
- class: "size-4"
192
- })) : createCommentVNode("", true),
193
- createTextVNode(" " + toDisplayString(currentDialog.value.options.cancelText), 1)
194
- ]),
195
- _: 1
196
- }, 8, ["variant", "disabled", "onClick"]),
197
- createVNode(unref(_sfc_main$7), {
198
- variant: currentDialog.value.options.confirmButtonType,
199
- disabled: unref(confirmDialogState).busy,
200
- onClick: unref(confirmActiveDialog)
201
- }, {
202
- default: withCtx(() => [
203
- currentDialog.value.options.confirmButtonIcon ? (openBlock(), createBlock(resolveDynamicComponent(currentDialog.value.options.confirmButtonIcon), {
204
- key: 0,
205
- class: "size-4"
206
- })) : createCommentVNode("", true),
207
- createTextVNode(" " + toDisplayString(currentDialog.value.options.confirmText), 1)
208
- ]),
209
- _: 1
210
- }, 8, ["variant", "disabled", "onClick"])
211
- ]),
212
- _: 1
213
- })
214
- ]),
215
- _: 1
216
- })) : createCommentVNode("", true)
217
- ]),
218
- _: 1
219
- }, 8, ["open"]);
220
- };
221
- }
222
- });
223
- export {
224
- _sfc_main as _,
225
- closeConfirmDialog as a,
226
- confirmActiveDialog as b,
227
- cancelActiveConfirmDialog as c,
228
- confirmDialogState as d,
229
- showConfirmDialog as s
230
- };