@robuust-digital/vue-components 2.0.0-rc.3 → 2.0.0-rc.5

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.
@@ -0,0 +1,202 @@
1
+ import { ref as g, computed as y, createBlock as x, openBlock as B, unref as t, withCtx as d, createVNode as n, withModifiers as D, createElementVNode as a, normalizeClass as E, renderSlot as u, createCommentVNode as L, createTextVNode as T, toDisplayString as h } from "vue";
2
+ import { TransitionRoot as F, Dialog as I, TransitionChild as $, DialogPanel as N, DialogTitle as C } from "@headlessui/vue";
3
+ import { _ as S } from "./ButtonBase-CQjlJ85F.js";
4
+ import { r as w } from "./XMarkIcon-90mcPzBs.js";
5
+ function R(l) {
6
+ const c = g(null), s = g(!1), v = y(() => l.as === "form"), b = y(() => `${l.id}-title`), m = y(() => `${l.id}-content`), f = y(() => {
7
+ var r;
8
+ return (r = c.value) == null ? void 0 : r.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
9
+ });
10
+ return {
11
+ contentRef: c,
12
+ ready: s,
13
+ isForm: v,
14
+ titleId: b,
15
+ descriptionId: m,
16
+ initialFocusElement: f
17
+ };
18
+ }
19
+ const V = {
20
+ role: "presentation",
21
+ class: "fixed inset-0 z-10 w-screen overflow-y-auto"
22
+ }, q = { class: "flex min-h-full justify-center p-4 items-center sm:p-0" }, z = { class: "rvc-modal-header" }, j = { class: "flex items-center justify-between" }, M = { class: "ml-3 flex h-7 items-center" }, A = ["id"], P = { class: "rvc-modal-footer" }, O = {
23
+ __name: "Modal",
24
+ props: {
25
+ as: {
26
+ type: String,
27
+ default: "div"
28
+ },
29
+ id: {
30
+ type: String,
31
+ required: !0
32
+ },
33
+ title: {
34
+ type: String,
35
+ required: !0
36
+ },
37
+ showClose: {
38
+ type: Boolean
39
+ },
40
+ spinning: {
41
+ type: Boolean
42
+ },
43
+ submitLabel: {
44
+ type: String,
45
+ default: "Confirm"
46
+ },
47
+ cancelLabel: {
48
+ type: String,
49
+ default: "Cancel"
50
+ },
51
+ panelClass: {
52
+ type: String,
53
+ default: "sm:max-w-lg"
54
+ }
55
+ },
56
+ emits: ["modal:open", "modal:close", "modal:save", "modal:closed"],
57
+ setup(l, { emit: c }) {
58
+ const s = c, v = l, {
59
+ contentRef: b,
60
+ ready: m,
61
+ isForm: f,
62
+ titleId: r,
63
+ descriptionId: p,
64
+ initialFocusElement: k
65
+ } = R(v);
66
+ return (i, e) => (B(), x(t(F), { as: "template" }, {
67
+ default: d(() => [
68
+ n(t(I), {
69
+ as: l.as,
70
+ class: "rvc-modal",
71
+ static: "",
72
+ "aria-modal": "true",
73
+ role: "dialog",
74
+ "initial-focus": t(k),
75
+ "aria-labelledby": t(r),
76
+ onClose: e[6] || (e[6] = (o) => i.$emit("modal:close")),
77
+ onSubmit: e[7] || (e[7] = D((o) => s("modal:save", o), ["prevent"]))
78
+ }, {
79
+ default: d(() => [
80
+ n(t($), {
81
+ as: "template",
82
+ enter: "ease-out duration-300",
83
+ "enter-from": "opacity-0",
84
+ "enter-to": "opacity-100",
85
+ leave: "ease-in duration-200",
86
+ "leave-from": "opacity-100",
87
+ "leave-to": "opacity-0",
88
+ onBeforeEnter: e[0] || (e[0] = (o) => s("modal:open"))
89
+ }, {
90
+ default: d(() => e[8] || (e[8] = [
91
+ a("div", {
92
+ "aria-hidden": "true",
93
+ class: "fixed inset-0 transition-opacity rvc-modal-backdrop"
94
+ }, null, -1)
95
+ ])),
96
+ _: 1
97
+ }),
98
+ a("div", V, [
99
+ a("div", q, [
100
+ n(t($), {
101
+ as: "template",
102
+ enter: "ease-out duration-300",
103
+ "enter-from": "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
104
+ "enter-to": "opacity-100 translate-y-0 sm:scale-100",
105
+ leave: "ease-in duration-200",
106
+ "leave-from": "opacity-100 translate-y-0 sm:scale-100",
107
+ "leave-to": "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
108
+ onBeforeEnter: e[4] || (e[4] = (o) => m.value = !0),
109
+ onAfterLeave: e[5] || (e[5] = (o) => (m.value = !1, s("modal:closed")))
110
+ }, {
111
+ default: d(() => [
112
+ n(t(N), {
113
+ class: E(["rvc-modal-panel", l.panelClass]),
114
+ "aria-busy": l.spinning,
115
+ "aria-describedby": t(p)
116
+ }, {
117
+ default: d(() => [
118
+ a("header", z, [
119
+ u(i.$slots, "header", { title: l.title }, () => [
120
+ a("div", j, [
121
+ u(i.$slots, "title", {
122
+ id: t(r),
123
+ dialogTitle: t(C),
124
+ title: l.title
125
+ }, () => [
126
+ n(t(C), {
127
+ id: t(r),
128
+ class: "rvc-modal-title"
129
+ }, {
130
+ default: d(() => [
131
+ T(h(l.title), 1)
132
+ ]),
133
+ _: 1
134
+ }, 8, ["id"])
135
+ ]),
136
+ l.showClose ? u(i.$slots, "close", {
137
+ key: 0,
138
+ icon: t(w),
139
+ emitClose: () => s("drawer:close")
140
+ }, () => [
141
+ a("div", M, [
142
+ a("button", {
143
+ type: "button",
144
+ class: "relative rvc-modal-close",
145
+ "aria-label": "Close panel",
146
+ onClick: e[1] || (e[1] = (o) => s("modal:close"))
147
+ }, [
148
+ n(t(w), {
149
+ class: "size-full",
150
+ "aria-hidden": "true"
151
+ })
152
+ ])
153
+ ])
154
+ ]) : L("", !0)
155
+ ])
156
+ ])
157
+ ]),
158
+ a("div", {
159
+ id: t(p),
160
+ ref_key: "contentRef",
161
+ ref: b,
162
+ class: "rvc-modal-content"
163
+ }, [
164
+ u(i.$slots, "default", { ready: t(m) })
165
+ ], 8, A),
166
+ a("footer", P, [
167
+ u(i.$slots, "footer", { loading: l.spinning }, () => [
168
+ n(S, {
169
+ type: t(f) ? "submit" : "button",
170
+ label: l.submitLabel,
171
+ spinning: l.spinning,
172
+ disabled: l.spinning,
173
+ onClick: e[2] || (e[2] = (o) => !t(f) && i.$emit("modal:save"))
174
+ }, null, 8, ["type", "label", "spinning", "disabled"]),
175
+ n(S, {
176
+ type: "button",
177
+ color: "light",
178
+ label: l.cancelLabel,
179
+ onClick: e[3] || (e[3] = (o) => i.$emit("modal:close"))
180
+ }, null, 8, ["label"])
181
+ ])
182
+ ])
183
+ ]),
184
+ _: 3
185
+ }, 8, ["class", "aria-busy", "aria-describedby"])
186
+ ]),
187
+ _: 3
188
+ })
189
+ ])
190
+ ])
191
+ ]),
192
+ _: 3
193
+ }, 8, ["as", "initial-focus", "aria-labelledby"])
194
+ ]),
195
+ _: 3
196
+ }));
197
+ }
198
+ };
199
+ export {
200
+ O as _,
201
+ R as u
202
+ };