@codeandfunction/callaloo 4.7.6 → 4.8.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.
@@ -0,0 +1,176 @@
1
+ import '../components/Modals/CLModal/CLModal.css';
2
+ import { defineComponent as W, useTemplateRef as F, useSlots as U, ref as Z, computed as m, watch as j, onMounted as q, onBeforeUnmount as A, createElementBlock as p, createCommentVNode as v, openBlock as w, normalizeStyle as y, normalizeClass as l, unref as n, createElementVNode as d, createBlock as B, renderSlot as $, withCtx as G, createTextVNode as J, toDisplayString as K } from "vue";
3
+ import { _ as P } from "./CLButton.vue_vue_type_style_index_0_lang-MvhnNzVW.js";
4
+ import { _ as Q } from "./CLHeading.vue_vue_type_style_index_0_lang-DH5oJc1C.js";
5
+ import { CLMode as k, CLColors as T, CLColorVariants as N, CLBorderRadius as X, CLIconSizes as Y, CLIconNames as ee, CLHeadingTypes as oe } from "../index.js";
6
+ import { g as te } from "./utils-D00IXMTR.js";
7
+ import { useTheme as ne } from "../composables/useTheme.js";
8
+ import { useEsc as le } from "../composables/useEsc.js";
9
+ import { c as S, i as a } from "./helper-qUkciePY.js";
10
+ const se = () => {
11
+ const { colors: t, darkMode: _ } = ne(), f = _.value ? k.Dark : k.Light, r = te({
12
+ color: T.Neutral,
13
+ colors: t.value,
14
+ mode: f,
15
+ variant: N.Solid
16
+ }), c = _.value ? "black" : "white";
17
+ return {
18
+ "--clll-modal-overlay-bg": r?.bg ?? "transparent",
19
+ "--clll-modal-content-bg": c,
20
+ "--clll-modal-theme-radius": "var(--clll-default-radius)"
21
+ };
22
+ }, ae = ["id", "data-testid"], re = ["aria-labelledby"], we = /* @__PURE__ */ W({
23
+ name: "CLModal",
24
+ __name: "CLModal",
25
+ props: {
26
+ borderRadius: { default: void 0 },
27
+ close: { type: Boolean, default: !0 },
28
+ closeBorderRadius: { default: X.Full },
29
+ dismissible: { type: Boolean, default: !0 },
30
+ fullscreen: { type: Boolean, default: !1 },
31
+ isOpen: { type: Boolean, default: !1 },
32
+ maxWidth: { default: "640px" },
33
+ modalId: {},
34
+ onClose: { type: Function, default: void 0 },
35
+ overlay: { type: Boolean, default: !0 },
36
+ testId: { default: "clll-modal" },
37
+ title: { default: void 0 },
38
+ zIndex: { default: 100 }
39
+ },
40
+ emits: ["modal-open", "modal-close"],
41
+ setup(t, { emit: _ }) {
42
+ const f = _, r = F("modal-window"), c = U(), o = t, e = "clll-modal", x = "clll-prevent-scroll", u = Z(), I = () => {
43
+ a && window?.document.body.classList.add(x);
44
+ }, C = () => {
45
+ a && window?.document.body.classList.remove(x);
46
+ }, R = m(() => [
47
+ e
48
+ ]), E = m(() => [
49
+ `${e}__window`,
50
+ o.fullscreen ? `${e}__window--fullscreen` : ""
51
+ ]), M = m(() => [
52
+ `${e}__content`,
53
+ o.borderRadius ? `${e}__content--${o.borderRadius}` : "",
54
+ o.close ? `${e}__content--has-close-button` : `${e}__content--has-no-close-button`,
55
+ c.body ? `${e}__content--has-body` : `${e}__content--has-no-body`,
56
+ c.footer ? `${e}__content--has-footer` : `${e}__content--has-no-footer`,
57
+ c.header || o.title ? `${e}__content--has-header` : `${e}__content--has-no-header`,
58
+ o.title ? `${e}__content--has-title` : `${e}__content--has-no-title`
59
+ ]), O = m(() => o.zIndex === "auto" || S(o.zIndex) ? o.zIndex : o.zIndex.toString()), V = m(() => o.zIndex === "auto" ? o.zIndex : ((S(o.zIndex) ? parseInt(o.zIndex, 10) : o.zIndex) + 100).toString()), H = (s) => {
60
+ try {
61
+ const i = s?.target, g = r.value;
62
+ return a && g && !g.contains(i) ? !0 : void 0;
63
+ } catch (i) {
64
+ console.error(i);
65
+ return;
66
+ }
67
+ }, b = (s) => {
68
+ try {
69
+ H(s) && (a && window.removeEventListener("mousedown", b), L());
70
+ } catch (i) {
71
+ console.error(i);
72
+ }
73
+ }, h = () => {
74
+ a && window.removeEventListener("mousedown", b);
75
+ }, z = () => {
76
+ a && (u.value && a && window.clearTimeout(u.value), h(), C());
77
+ }, L = () => {
78
+ o.isOpen && (o.onClose?.(), z());
79
+ };
80
+ j(o, (s) => {
81
+ s.isOpen ? (f("modal-open"), I(), r.value && r.value.focus(), a && s.dismissible && (h(), u.value = window.setTimeout(() => {
82
+ window.addEventListener("mousedown", b);
83
+ }, 100))) : (r.value && r.value.blur(), C(), h(), u.value && a && window.clearTimeout(u.value), f("modal-close"));
84
+ }), q(() => {
85
+ o.isOpen && a && (I(), r.value && r.value.focus());
86
+ });
87
+ const { clearEventListeners: D } = le({ escHandler: o.dismissible ? L : void 0 });
88
+ return A(() => {
89
+ z(), D();
90
+ }), (s, i) => t.isOpen ? (w(), p("div", {
91
+ key: 0,
92
+ id: t.modalId,
93
+ class: l(n(R)),
94
+ "data-testid": t.testId,
95
+ style: y({ ...n(se)(), zIndex: n(O) })
96
+ }, [
97
+ d("div", {
98
+ class: l(n(E)),
99
+ style: y({ zIndex: n(V) })
100
+ }, [
101
+ d("div", {
102
+ ref: "modal-window",
103
+ "aria-modal": "true",
104
+ "aria-labelledby": `${e}__content__header__title`,
105
+ class: l(n(M)),
106
+ role: "dialog",
107
+ tabindex: -1,
108
+ style: y({ "--clll-modal-max-width": t.maxWidth })
109
+ }, [
110
+ d("div", {
111
+ class: l(`${e}__close-button`)
112
+ }, [
113
+ t.onClose && t.close ? (w(), B(n(P), {
114
+ key: 0,
115
+ "aria-label": "Close modal",
116
+ "border-radius": t.closeBorderRadius,
117
+ color: n(T).Neutral,
118
+ "icon-before": n(ee).Delete,
119
+ "icon-size": n(Y).Tiny,
120
+ "on-click": t.onClose,
121
+ "test-id": `${e}__close-button`,
122
+ variant: n(N).Text
123
+ }, null, 8, ["border-radius", "color", "icon-before", "icon-size", "on-click", "test-id", "variant"])) : v("", !0)
124
+ ], 2),
125
+ d("div", {
126
+ class: l(`${e}__content__header`)
127
+ }, [
128
+ d("div", {
129
+ class: l(`${e}__content__title`)
130
+ }, [
131
+ d("div", {
132
+ class: l(`${e}__content__header__container`)
133
+ }, [
134
+ t.title ? (w(), B(n(Q), {
135
+ key: 0,
136
+ id: `${e}__content__header__title`,
137
+ class: l(`${e}__content__header__title`),
138
+ type: n(oe).Section
139
+ }, {
140
+ default: G(() => [
141
+ J(K(t.title), 1)
142
+ ]),
143
+ _: 1
144
+ }, 8, ["id", "class", "type"])) : v("", !0),
145
+ $(s.$slots, "header")
146
+ ], 2)
147
+ ], 2)
148
+ ], 2),
149
+ d("div", {
150
+ class: l(`${e}__content__scroller`)
151
+ }, [
152
+ d("div", {
153
+ class: l(`${e}__content__body`)
154
+ }, [
155
+ $(s.$slots, "body")
156
+ ], 2)
157
+ ], 2),
158
+ d("div", {
159
+ class: l(`${e}__content__footer`)
160
+ }, [
161
+ $(s.$slots, "footer")
162
+ ], 2)
163
+ ], 14, re)
164
+ ], 6),
165
+ t.overlay ? (w(), p("div", {
166
+ key: 0,
167
+ ref: "overlay-ref",
168
+ class: l(`${e}__overlay`),
169
+ style: y({ zIndex: t.zIndex })
170
+ }, null, 6)) : v("", !0)
171
+ ], 14, ae)) : v("", !0);
172
+ }
173
+ });
174
+ export {
175
+ we as _
176
+ };
@@ -0,0 +1,9 @@
1
+ const s = (t, r) => {
2
+ const o = t.__vccOpts || t;
3
+ for (const [c, e] of r)
4
+ o[c] = e;
5
+ return o;
6
+ };
7
+ export {
8
+ s as _
9
+ };