kablui 0.1.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.
- package/LICENSE +21 -0
- package/README.md +207 -0
- package/dist/index.d.ts +1574 -0
- package/dist/kablui.css +1 -0
- package/dist/kablui.js +2934 -0
- package/dist/kablui.js.map +1 -0
- package/dist/kablui.umd.cjs +2 -0
- package/dist/kablui.umd.cjs.map +1 -0
- package/package.json +78 -0
package/dist/kablui.js
ADDED
|
@@ -0,0 +1,2934 @@
|
|
|
1
|
+
import { defineComponent as x, useModel as N, provide as G, computed as g, openBlock as f, createElementBlock as p, renderSlot as C, mergeModels as U, inject as S, withDirectives as Oe, normalizeClass as w, unref as v, vShow as Pe, watch as K, onBeforeUnmount as q, createElementVNode as j, toDisplayString as H, createCommentVNode as z, createBlock as V, resolveDynamicComponent as ae, withCtx as Y, toValue as O, ref as R, useAttrs as X, onMounted as ne, mergeProps as Z, getCurrentInstance as Ve, onScopeDispose as ie, useSlots as Fe, Teleport as de, toRef as it, watchEffect as st, nextTick as Q, withModifiers as He, normalizeStyle as ce, createVNode as he, createTextVNode as re, Fragment as ee, renderList as we, onUpdated as lt } from "vue";
|
|
2
|
+
const ot = "0.1.0", rt = {
|
|
3
|
+
version: ot
|
|
4
|
+
}, _e = Symbol("kablui-accordion"), $e = Symbol(
|
|
5
|
+
"kablui-accordion-item"
|
|
6
|
+
), ut = { "data-slot": "accordion" }, Ga = /* @__PURE__ */ x({
|
|
7
|
+
__name: "Accordion",
|
|
8
|
+
props: /* @__PURE__ */ U({
|
|
9
|
+
type: { default: "single" },
|
|
10
|
+
collapsible: { type: Boolean, default: !0 }
|
|
11
|
+
}, {
|
|
12
|
+
modelValue: {},
|
|
13
|
+
modelModifiers: {}
|
|
14
|
+
}),
|
|
15
|
+
emits: ["update:modelValue"],
|
|
16
|
+
setup(a) {
|
|
17
|
+
const e = a, t = N(a, "modelValue"), n = /* @__PURE__ */ new Map(), i = [];
|
|
18
|
+
function l(u) {
|
|
19
|
+
return e.type === "multiple" ? Array.isArray(t.value) && t.value.includes(u) : t.value === u;
|
|
20
|
+
}
|
|
21
|
+
function o(u) {
|
|
22
|
+
if (e.type === "multiple") {
|
|
23
|
+
const m = Array.isArray(t.value) ? [...t.value] : [], b = m.indexOf(u);
|
|
24
|
+
b >= 0 ? m.splice(b, 1) : m.push(u), t.value = m;
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (t.value === u) {
|
|
28
|
+
e.collapsible && (t.value = void 0);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
t.value = u;
|
|
32
|
+
}
|
|
33
|
+
function s(u, m, b) {
|
|
34
|
+
n.has(u) || i.push(u), n.set(u, { el: m, disabled: b });
|
|
35
|
+
}
|
|
36
|
+
function c(u) {
|
|
37
|
+
n.delete(u);
|
|
38
|
+
const m = i.indexOf(u);
|
|
39
|
+
m >= 0 && i.splice(m, 1);
|
|
40
|
+
}
|
|
41
|
+
function d() {
|
|
42
|
+
return i.map((u) => n.get(u)).filter((u) => !!u && !u.disabled && !!u.el).map((u) => u.el);
|
|
43
|
+
}
|
|
44
|
+
function r(u, m) {
|
|
45
|
+
var _, $;
|
|
46
|
+
const b = d();
|
|
47
|
+
if (b.length === 0) return;
|
|
48
|
+
const y = (_ = n.get(u)) == null ? void 0 : _.el, A = y ? b.indexOf(y) : -1;
|
|
49
|
+
if (A === -1) {
|
|
50
|
+
($ = b[0]) == null || $.focus();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
b[(A + m + b.length) % b.length].focus();
|
|
54
|
+
}
|
|
55
|
+
return G(_e, {
|
|
56
|
+
type: g(() => e.type),
|
|
57
|
+
collapsible: g(() => e.collapsible),
|
|
58
|
+
isOpen: l,
|
|
59
|
+
toggle: o,
|
|
60
|
+
registerTrigger: s,
|
|
61
|
+
unregisterTrigger: c,
|
|
62
|
+
focusRelative: r
|
|
63
|
+
}), (u, m) => (f(), p("div", ut, [
|
|
64
|
+
C(u.$slots, "default")
|
|
65
|
+
]));
|
|
66
|
+
}
|
|
67
|
+
}), dt = ["id", "aria-labelledby"], Wa = /* @__PURE__ */ x({
|
|
68
|
+
__name: "AccordionContent",
|
|
69
|
+
setup(a) {
|
|
70
|
+
const e = S($e, null);
|
|
71
|
+
e || console.warn("[kablui] AccordionContent must be used inside AccordionItem");
|
|
72
|
+
const t = g(() => !!(e != null && e.isOpen.value)), n = [
|
|
73
|
+
"px-1 pb-3 text-kablui-md text-kablui-muted-fg"
|
|
74
|
+
].join(" ");
|
|
75
|
+
return (i, l) => {
|
|
76
|
+
var o, s;
|
|
77
|
+
return Oe((f(), p("div", {
|
|
78
|
+
"data-slot": "accordion-content",
|
|
79
|
+
role: "region",
|
|
80
|
+
id: (o = v(e)) == null ? void 0 : o.contentId,
|
|
81
|
+
"aria-labelledby": (s = v(e)) == null ? void 0 : s.triggerId,
|
|
82
|
+
class: w(v(n))
|
|
83
|
+
}, [
|
|
84
|
+
C(i.$slots, "default")
|
|
85
|
+
], 10, dt)), [
|
|
86
|
+
[Pe, t.value]
|
|
87
|
+
]);
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
let Me = 0;
|
|
92
|
+
function P(a) {
|
|
93
|
+
return Me += 1, `kablui-${a}-${Me}`;
|
|
94
|
+
}
|
|
95
|
+
const ct = ["data-state", "data-disabled"], Ja = /* @__PURE__ */ x({
|
|
96
|
+
__name: "AccordionItem",
|
|
97
|
+
props: {
|
|
98
|
+
value: {},
|
|
99
|
+
disabled: { type: Boolean, default: !1 }
|
|
100
|
+
},
|
|
101
|
+
setup(a) {
|
|
102
|
+
const e = a, t = S(_e, null);
|
|
103
|
+
t || console.warn("[kablui] AccordionItem must be used inside Accordion");
|
|
104
|
+
const n = P("accordion-trigger"), i = P("accordion-content"), l = g(() => e.disabled), o = g(() => !!(t != null && t.isOpen(e.value)));
|
|
105
|
+
function s() {
|
|
106
|
+
!t || l.value || t.toggle(e.value);
|
|
107
|
+
}
|
|
108
|
+
return G($e, {
|
|
109
|
+
value: e.value,
|
|
110
|
+
disabled: l,
|
|
111
|
+
triggerId: n,
|
|
112
|
+
contentId: i,
|
|
113
|
+
isOpen: o,
|
|
114
|
+
toggle: s
|
|
115
|
+
}), (c, d) => (f(), p("div", {
|
|
116
|
+
"data-slot": "accordion-item",
|
|
117
|
+
"data-state": o.value ? "open" : "closed",
|
|
118
|
+
"data-disabled": a.disabled || void 0,
|
|
119
|
+
class: "border-b border-kablui-border"
|
|
120
|
+
}, [
|
|
121
|
+
C(c.$slots, "default")
|
|
122
|
+
], 8, ct));
|
|
123
|
+
}
|
|
124
|
+
}), ft = { class: "m-0" }, bt = ["id", "disabled", "aria-expanded", "aria-controls"], Qa = /* @__PURE__ */ x({
|
|
125
|
+
__name: "AccordionTrigger",
|
|
126
|
+
setup(a) {
|
|
127
|
+
const e = S(_e, null), t = S($e, null);
|
|
128
|
+
(!e || !t) && console.warn("[kablui] AccordionTrigger must be used inside AccordionItem");
|
|
129
|
+
const n = g(() => !!(t != null && t.isOpen.value)), i = g(() => !!(t != null && t.disabled.value));
|
|
130
|
+
let l = null;
|
|
131
|
+
function o(r) {
|
|
132
|
+
l = r instanceof HTMLButtonElement ? r : null, e && t && e.registerTrigger(t.value, l, i.value);
|
|
133
|
+
}
|
|
134
|
+
K(i, (r) => {
|
|
135
|
+
e && t && e.registerTrigger(t.value, l, r);
|
|
136
|
+
}), q(() => {
|
|
137
|
+
e && t && e.unregisterTrigger(t.value);
|
|
138
|
+
});
|
|
139
|
+
function s() {
|
|
140
|
+
t == null || t.toggle();
|
|
141
|
+
}
|
|
142
|
+
function c(r) {
|
|
143
|
+
if (!(!e || !t || i.value))
|
|
144
|
+
switch (r.key) {
|
|
145
|
+
case "Enter":
|
|
146
|
+
case " ":
|
|
147
|
+
r.preventDefault(), t.toggle();
|
|
148
|
+
break;
|
|
149
|
+
case "ArrowDown":
|
|
150
|
+
r.preventDefault(), e.focusRelative(t.value, 1);
|
|
151
|
+
break;
|
|
152
|
+
case "ArrowUp":
|
|
153
|
+
r.preventDefault(), e.focusRelative(t.value, -1);
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const d = [
|
|
158
|
+
"flex w-full items-center justify-between gap-2",
|
|
159
|
+
"px-1 py-3 text-left text-kablui-md font-kablui-medium text-kablui-fg",
|
|
160
|
+
"bg-transparent hover:bg-kablui-muted",
|
|
161
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-kablui-focus focus-visible:ring-offset-2 focus-visible:ring-offset-kablui-bg",
|
|
162
|
+
"disabled:opacity-50 disabled:pointer-events-none"
|
|
163
|
+
].join(" ");
|
|
164
|
+
return (r, u) => {
|
|
165
|
+
var m, b;
|
|
166
|
+
return f(), p("h3", ft, [
|
|
167
|
+
j("button", {
|
|
168
|
+
ref: o,
|
|
169
|
+
type: "button",
|
|
170
|
+
"data-slot": "accordion-trigger",
|
|
171
|
+
id: (m = v(t)) == null ? void 0 : m.triggerId,
|
|
172
|
+
class: w(v(d)),
|
|
173
|
+
disabled: i.value,
|
|
174
|
+
"aria-expanded": n.value ? "true" : "false",
|
|
175
|
+
"aria-controls": (b = v(t)) == null ? void 0 : b.contentId,
|
|
176
|
+
onClick: s,
|
|
177
|
+
onKeydown: c
|
|
178
|
+
}, [
|
|
179
|
+
C(r.$slots, "default")
|
|
180
|
+
], 42, bt)
|
|
181
|
+
]);
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
}), vt = ["role"], mt = { class: "min-w-0 flex-1" }, pt = {
|
|
185
|
+
key: 0,
|
|
186
|
+
class: "font-kablui-semibold"
|
|
187
|
+
}, Xa = /* @__PURE__ */ x({
|
|
188
|
+
__name: "Alert",
|
|
189
|
+
props: {
|
|
190
|
+
tone: { default: "neutral" },
|
|
191
|
+
title: {},
|
|
192
|
+
dismissible: { type: Boolean, default: !1 }
|
|
193
|
+
},
|
|
194
|
+
emits: ["dismiss"],
|
|
195
|
+
setup(a, { emit: e }) {
|
|
196
|
+
const t = e, n = [
|
|
197
|
+
"relative flex w-full gap-3 rounded-kablui-md border px-3 py-2.5",
|
|
198
|
+
"text-kablui-md"
|
|
199
|
+
].join(" "), i = {
|
|
200
|
+
neutral: "border-kablui-border bg-kablui-muted text-kablui-fg",
|
|
201
|
+
accent: "border-kablui-accent bg-kablui-accent text-kablui-accent-fg",
|
|
202
|
+
danger: "border-kablui-danger bg-kablui-danger text-kablui-danger-fg",
|
|
203
|
+
success: "border-kablui-success bg-kablui-success text-kablui-success-fg",
|
|
204
|
+
warning: "border-kablui-warning bg-kablui-warning text-kablui-warning-fg"
|
|
205
|
+
}, l = [
|
|
206
|
+
"ml-auto shrink-0 -mr-1 -mt-0.5 inline-flex size-6 items-center justify-center",
|
|
207
|
+
"rounded-kablui-sm text-current opacity-70 hover:opacity-100",
|
|
208
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-kablui-focus focus-visible:ring-offset-2 focus-visible:ring-offset-kablui-bg"
|
|
209
|
+
].join(" ");
|
|
210
|
+
function o() {
|
|
211
|
+
t("dismiss");
|
|
212
|
+
}
|
|
213
|
+
return (s, c) => (f(), p("div", {
|
|
214
|
+
role: a.tone === "danger" ? "alert" : "status",
|
|
215
|
+
class: w([v(n), i[a.tone]])
|
|
216
|
+
}, [
|
|
217
|
+
j("div", mt, [
|
|
218
|
+
a.title ? (f(), p("div", pt, H(a.title), 1)) : z("", !0),
|
|
219
|
+
j("div", {
|
|
220
|
+
class: w(a.title ? "mt-0.5" : void 0)
|
|
221
|
+
}, [
|
|
222
|
+
C(s.$slots, "default")
|
|
223
|
+
], 2)
|
|
224
|
+
]),
|
|
225
|
+
a.dismissible ? (f(), p("button", {
|
|
226
|
+
key: 0,
|
|
227
|
+
type: "button",
|
|
228
|
+
class: w(v(l)),
|
|
229
|
+
"aria-label": "Dismiss",
|
|
230
|
+
onClick: o
|
|
231
|
+
}, [...c[0] || (c[0] = [
|
|
232
|
+
j("span", { "aria-hidden": "true" }, "×", -1)
|
|
233
|
+
])], 2)) : z("", !0)
|
|
234
|
+
], 10, vt));
|
|
235
|
+
}
|
|
236
|
+
}), Za = /* @__PURE__ */ x({
|
|
237
|
+
__name: "Badge",
|
|
238
|
+
props: {
|
|
239
|
+
tone: { default: "neutral" },
|
|
240
|
+
size: { default: "md" }
|
|
241
|
+
},
|
|
242
|
+
setup(a) {
|
|
243
|
+
const e = [
|
|
244
|
+
"inline-flex items-center font-kablui-medium",
|
|
245
|
+
"rounded-kablui-full",
|
|
246
|
+
"whitespace-nowrap"
|
|
247
|
+
].join(" "), t = {
|
|
248
|
+
neutral: "bg-kablui-muted text-kablui-fg",
|
|
249
|
+
accent: "bg-kablui-accent text-kablui-accent-fg",
|
|
250
|
+
danger: "bg-kablui-danger text-kablui-danger-fg"
|
|
251
|
+
}, n = {
|
|
252
|
+
sm: "text-kablui-sm px-2 py-0.5",
|
|
253
|
+
md: "text-kablui-md px-2.5 py-1"
|
|
254
|
+
};
|
|
255
|
+
return (i, l) => (f(), p("span", {
|
|
256
|
+
class: w([v(e), t[a.tone], n[a.size]])
|
|
257
|
+
}, [
|
|
258
|
+
C(i.$slots, "default")
|
|
259
|
+
], 2));
|
|
260
|
+
}
|
|
261
|
+
}), gt = ["type", "disabled"], ke = /* @__PURE__ */ x({
|
|
262
|
+
__name: "Button",
|
|
263
|
+
props: {
|
|
264
|
+
variant: { default: "solid" },
|
|
265
|
+
size: { default: "md" },
|
|
266
|
+
disabled: { type: Boolean, default: !1 },
|
|
267
|
+
type: { default: "button" }
|
|
268
|
+
},
|
|
269
|
+
emits: ["click"],
|
|
270
|
+
setup(a, { emit: e }) {
|
|
271
|
+
const t = a, n = e, i = [
|
|
272
|
+
"inline-flex items-center justify-center gap-1.5 font-kablui-medium",
|
|
273
|
+
"rounded-kablui-md",
|
|
274
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-kablui-focus focus-visible:ring-offset-2 focus-visible:ring-offset-kablui-bg",
|
|
275
|
+
"disabled:opacity-50 disabled:pointer-events-none"
|
|
276
|
+
].join(" "), l = {
|
|
277
|
+
solid: "bg-kablui-accent text-kablui-accent-fg hover:opacity-90",
|
|
278
|
+
outline: "border border-kablui-border-strong bg-transparent text-kablui-fg hover:bg-kablui-muted",
|
|
279
|
+
ghost: "bg-transparent text-kablui-fg hover:bg-kablui-muted"
|
|
280
|
+
}, o = {
|
|
281
|
+
sm: "text-kablui-sm px-2 py-1",
|
|
282
|
+
md: "text-kablui-md px-3 py-1.5",
|
|
283
|
+
lg: "text-kablui-lg px-4 py-2"
|
|
284
|
+
};
|
|
285
|
+
function s(c) {
|
|
286
|
+
t.disabled || n("click", c);
|
|
287
|
+
}
|
|
288
|
+
return (c, d) => (f(), p("button", {
|
|
289
|
+
type: a.type,
|
|
290
|
+
disabled: a.disabled,
|
|
291
|
+
class: w([v(i), l[a.variant], o[a.size]]),
|
|
292
|
+
onClick: s
|
|
293
|
+
}, [
|
|
294
|
+
C(c.$slots, "default")
|
|
295
|
+
], 10, gt));
|
|
296
|
+
}
|
|
297
|
+
}), en = /* @__PURE__ */ x({
|
|
298
|
+
__name: "Card",
|
|
299
|
+
props: {
|
|
300
|
+
as: { default: "div" },
|
|
301
|
+
padding: { default: "none" }
|
|
302
|
+
},
|
|
303
|
+
setup(a) {
|
|
304
|
+
const e = [
|
|
305
|
+
"rounded-kablui-md border border-kablui-border bg-kablui-bg",
|
|
306
|
+
"text-kablui-fg shadow-kablui-sm"
|
|
307
|
+
].join(" "), t = {
|
|
308
|
+
none: "",
|
|
309
|
+
sm: "p-3",
|
|
310
|
+
md: "p-4"
|
|
311
|
+
};
|
|
312
|
+
return (n, i) => (f(), V(ae(a.as), {
|
|
313
|
+
class: w([v(e), t[a.padding]]),
|
|
314
|
+
"data-slot": "card"
|
|
315
|
+
}, {
|
|
316
|
+
default: Y(() => [
|
|
317
|
+
C(n.$slots, "default")
|
|
318
|
+
]),
|
|
319
|
+
_: 3
|
|
320
|
+
}, 8, ["class"]));
|
|
321
|
+
}
|
|
322
|
+
}), kt = "px-4 py-3 text-kablui-md text-kablui-fg", tn = /* @__PURE__ */ x({
|
|
323
|
+
__name: "CardBody",
|
|
324
|
+
setup(a) {
|
|
325
|
+
return (e, t) => (f(), p("div", {
|
|
326
|
+
class: w(kt),
|
|
327
|
+
"data-slot": "card-body"
|
|
328
|
+
}, [
|
|
329
|
+
C(e.$slots, "default")
|
|
330
|
+
]));
|
|
331
|
+
}
|
|
332
|
+
}), ht = "text-kablui-sm text-kablui-muted-fg", an = /* @__PURE__ */ x({
|
|
333
|
+
__name: "CardDescription",
|
|
334
|
+
setup(a) {
|
|
335
|
+
return (e, t) => (f(), p("p", {
|
|
336
|
+
class: w(ht),
|
|
337
|
+
"data-slot": "card-description"
|
|
338
|
+
}, [
|
|
339
|
+
C(e.$slots, "default")
|
|
340
|
+
]));
|
|
341
|
+
}
|
|
342
|
+
}), nn = /* @__PURE__ */ x({
|
|
343
|
+
__name: "CardFooter",
|
|
344
|
+
setup(a) {
|
|
345
|
+
const e = [
|
|
346
|
+
"flex flex-wrap items-center justify-end gap-2",
|
|
347
|
+
"border-t border-kablui-border px-4 py-3"
|
|
348
|
+
].join(" ");
|
|
349
|
+
return (t, n) => (f(), p("div", {
|
|
350
|
+
class: w(v(e)),
|
|
351
|
+
"data-slot": "card-footer"
|
|
352
|
+
}, [
|
|
353
|
+
C(t.$slots, "default")
|
|
354
|
+
], 2));
|
|
355
|
+
}
|
|
356
|
+
}), yt = "flex flex-col gap-1 px-4 pt-4 pb-2 text-kablui-fg", sn = /* @__PURE__ */ x({
|
|
357
|
+
__name: "CardHeader",
|
|
358
|
+
setup(a) {
|
|
359
|
+
return (e, t) => (f(), p("div", {
|
|
360
|
+
class: w(yt),
|
|
361
|
+
"data-slot": "card-header"
|
|
362
|
+
}, [
|
|
363
|
+
C(e.$slots, "default")
|
|
364
|
+
]));
|
|
365
|
+
}
|
|
366
|
+
}), xt = "font-kablui-semibold text-kablui-lg text-kablui-fg", ln = /* @__PURE__ */ x({
|
|
367
|
+
__name: "CardTitle",
|
|
368
|
+
props: {
|
|
369
|
+
as: { default: "h3" }
|
|
370
|
+
},
|
|
371
|
+
setup(a) {
|
|
372
|
+
return (e, t) => (f(), V(ae(a.as), {
|
|
373
|
+
class: w(xt),
|
|
374
|
+
"data-slot": "card-title"
|
|
375
|
+
}, {
|
|
376
|
+
default: Y(() => [
|
|
377
|
+
C(e.$slots, "default")
|
|
378
|
+
]),
|
|
379
|
+
_: 3
|
|
380
|
+
}));
|
|
381
|
+
}
|
|
382
|
+
}), Ke = Symbol("kablui-field");
|
|
383
|
+
function wt(a = {}) {
|
|
384
|
+
const e = a.id ?? P("control"), t = P("hint"), n = P("error"), i = R(!1), l = R(!1), o = g(() => !!O(a.invalid)), s = g(() => {
|
|
385
|
+
const d = [];
|
|
386
|
+
return i.value && d.push(t), l.value && d.push(n), d.length > 0 ? d.join(" ") : void 0;
|
|
387
|
+
}), c = {
|
|
388
|
+
controlId: e,
|
|
389
|
+
hintId: t,
|
|
390
|
+
errorId: n,
|
|
391
|
+
invalid: o,
|
|
392
|
+
describedBy: s,
|
|
393
|
+
setHasHint: (d) => {
|
|
394
|
+
i.value = d;
|
|
395
|
+
},
|
|
396
|
+
setHasError: (d) => {
|
|
397
|
+
l.value = d;
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
return G(Ke, c), c;
|
|
401
|
+
}
|
|
402
|
+
function me() {
|
|
403
|
+
return S(Ke, null);
|
|
404
|
+
}
|
|
405
|
+
function se(a) {
|
|
406
|
+
const e = me(), t = g(() => O(a.id) || (e == null ? void 0 : e.controlId)), n = g(() => !!(O(a.invalid) || e != null && e.invalid.value)), i = g(() => e == null ? void 0 : e.describedBy.value), l = g(() => n.value ? "true" : void 0);
|
|
407
|
+
return { id: t, invalid: n, describedBy: i, ariaInvalid: l };
|
|
408
|
+
}
|
|
409
|
+
const _t = ["id", "name", "value", "checked", "disabled", "aria-invalid", "aria-describedby", "aria-checked"], on = /* @__PURE__ */ x({
|
|
410
|
+
inheritAttrs: !1,
|
|
411
|
+
__name: "Checkbox",
|
|
412
|
+
props: /* @__PURE__ */ U({
|
|
413
|
+
indeterminate: { type: Boolean, default: !1 },
|
|
414
|
+
disabled: { type: Boolean, default: !1 },
|
|
415
|
+
invalid: { type: Boolean, default: !1 },
|
|
416
|
+
name: {},
|
|
417
|
+
value: { default: "on" },
|
|
418
|
+
id: {}
|
|
419
|
+
}, {
|
|
420
|
+
modelValue: { type: Boolean, default: !1 },
|
|
421
|
+
modelModifiers: {}
|
|
422
|
+
}),
|
|
423
|
+
emits: ["update:modelValue"],
|
|
424
|
+
setup(a) {
|
|
425
|
+
const e = a, t = N(a, "modelValue"), n = X(), i = R(null), l = se({
|
|
426
|
+
id: () => e.id,
|
|
427
|
+
invalid: () => e.invalid
|
|
428
|
+
});
|
|
429
|
+
function o() {
|
|
430
|
+
i.value && (i.value.indeterminate = e.indeterminate);
|
|
431
|
+
}
|
|
432
|
+
ne(o), K(() => e.indeterminate, o);
|
|
433
|
+
const s = [
|
|
434
|
+
"size-4 shrink-0 appearance-none rounded-kablui-sm border border-kablui-border bg-kablui-bg",
|
|
435
|
+
"checked:border-kablui-accent checked:bg-kablui-accent",
|
|
436
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-kablui-focus focus-visible:ring-offset-2 focus-visible:ring-offset-kablui-bg",
|
|
437
|
+
"disabled:opacity-50 disabled:pointer-events-none"
|
|
438
|
+
].join(" "), c = g(() => [
|
|
439
|
+
s,
|
|
440
|
+
l.invalid.value ? "border-kablui-danger" : ""
|
|
441
|
+
]);
|
|
442
|
+
function d(r) {
|
|
443
|
+
const u = r.target;
|
|
444
|
+
t.value = u.checked;
|
|
445
|
+
}
|
|
446
|
+
return (r, u) => (f(), p("input", Z({
|
|
447
|
+
ref_key: "inputRef",
|
|
448
|
+
ref: i,
|
|
449
|
+
type: "checkbox",
|
|
450
|
+
id: v(l).id.value,
|
|
451
|
+
name: a.name,
|
|
452
|
+
value: a.value,
|
|
453
|
+
checked: t.value,
|
|
454
|
+
disabled: a.disabled,
|
|
455
|
+
"aria-invalid": v(l).ariaInvalid.value,
|
|
456
|
+
"aria-describedby": v(l).describedBy.value,
|
|
457
|
+
"aria-checked": a.indeterminate ? "mixed" : t.value ? "true" : "false",
|
|
458
|
+
class: c.value
|
|
459
|
+
}, v(n), { onChange: d }), null, 16, _t));
|
|
460
|
+
}
|
|
461
|
+
}), rn = /* @__PURE__ */ x({
|
|
462
|
+
__name: "Cluster",
|
|
463
|
+
props: {
|
|
464
|
+
gap: { default: "md" },
|
|
465
|
+
align: { default: "center" },
|
|
466
|
+
justify: { default: "start" },
|
|
467
|
+
as: { default: "div" }
|
|
468
|
+
},
|
|
469
|
+
setup(a) {
|
|
470
|
+
const e = {
|
|
471
|
+
sm: "gap-2",
|
|
472
|
+
md: "gap-4",
|
|
473
|
+
lg: "gap-6"
|
|
474
|
+
}, t = {
|
|
475
|
+
start: "items-start",
|
|
476
|
+
center: "items-center",
|
|
477
|
+
end: "items-end",
|
|
478
|
+
stretch: "items-stretch",
|
|
479
|
+
baseline: "items-baseline"
|
|
480
|
+
}, n = {
|
|
481
|
+
start: "justify-start",
|
|
482
|
+
center: "justify-center",
|
|
483
|
+
end: "justify-end",
|
|
484
|
+
between: "justify-between",
|
|
485
|
+
around: "justify-around",
|
|
486
|
+
evenly: "justify-evenly"
|
|
487
|
+
};
|
|
488
|
+
return (i, l) => (f(), V(ae(a.as), {
|
|
489
|
+
class: w([
|
|
490
|
+
"flex flex-wrap",
|
|
491
|
+
e[a.gap],
|
|
492
|
+
t[a.align],
|
|
493
|
+
n[a.justify]
|
|
494
|
+
])
|
|
495
|
+
}, {
|
|
496
|
+
default: Y(() => [
|
|
497
|
+
C(i.$slots, "default")
|
|
498
|
+
]),
|
|
499
|
+
_: 3
|
|
500
|
+
}, 8, ["class"]));
|
|
501
|
+
}
|
|
502
|
+
}), un = /* @__PURE__ */ x({
|
|
503
|
+
__name: "Container",
|
|
504
|
+
props: {
|
|
505
|
+
size: { default: "md" },
|
|
506
|
+
as: { default: "div" }
|
|
507
|
+
},
|
|
508
|
+
setup(a) {
|
|
509
|
+
const e = {
|
|
510
|
+
sm: "max-w-screen-sm px-4",
|
|
511
|
+
md: "max-w-screen-md px-4",
|
|
512
|
+
lg: "max-w-screen-lg px-6"
|
|
513
|
+
};
|
|
514
|
+
return (t, n) => (f(), V(ae(a.as), {
|
|
515
|
+
class: w(["mx-auto w-full", e[a.size]])
|
|
516
|
+
}, {
|
|
517
|
+
default: Y(() => [
|
|
518
|
+
C(t.$slots, "default")
|
|
519
|
+
]),
|
|
520
|
+
_: 3
|
|
521
|
+
}, 8, ["class"]));
|
|
522
|
+
}
|
|
523
|
+
}), $t = {
|
|
524
|
+
dropdown: 1e3,
|
|
525
|
+
overlay: 1200,
|
|
526
|
+
modal: 1300,
|
|
527
|
+
toast: 1400,
|
|
528
|
+
tooltip: 1500
|
|
529
|
+
};
|
|
530
|
+
let Ct = 0;
|
|
531
|
+
const te = [], Ne = R(0), ye = /* @__PURE__ */ new WeakMap();
|
|
532
|
+
function ze() {
|
|
533
|
+
Ne.value += 1;
|
|
534
|
+
}
|
|
535
|
+
function pe(a) {
|
|
536
|
+
const e = ++Ct, t = R(!1), n = $t[a], i = g(() => (Ne.value, !t.value || te.length === 0 ? !1 : te[te.length - 1].id === e));
|
|
537
|
+
function l() {
|
|
538
|
+
t.value || (te.push({ id: e, layer: a }), t.value = !0, ze());
|
|
539
|
+
}
|
|
540
|
+
function o() {
|
|
541
|
+
if (!t.value) return;
|
|
542
|
+
const c = te.findIndex((d) => d.id === e);
|
|
543
|
+
c !== -1 && te.splice(c, 1), t.value = !1, ze();
|
|
544
|
+
}
|
|
545
|
+
const s = Ve();
|
|
546
|
+
if (s) {
|
|
547
|
+
const c = ye.get(s) ?? [];
|
|
548
|
+
c.push(i), ye.set(s, c);
|
|
549
|
+
}
|
|
550
|
+
return ie(o), { zIndex: n, isTop: i, register: l, unregister: o };
|
|
551
|
+
}
|
|
552
|
+
function It(a) {
|
|
553
|
+
if (!a) return null;
|
|
554
|
+
const e = ye.get(a);
|
|
555
|
+
return !e || e.length === 0 ? null : e.shift() ?? null;
|
|
556
|
+
}
|
|
557
|
+
let Tt = 0;
|
|
558
|
+
const J = [];
|
|
559
|
+
function Et() {
|
|
560
|
+
for (let a = J.length - 1; a >= 0; a -= 1) {
|
|
561
|
+
const e = J[a];
|
|
562
|
+
if (e.escape) return e;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
function At() {
|
|
566
|
+
for (let a = J.length - 1; a >= 0; a -= 1) {
|
|
567
|
+
const e = J[a];
|
|
568
|
+
if (e.outside) return e;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
function Ce(a, e) {
|
|
572
|
+
const t = ++Tt, n = Ve(), i = It(n);
|
|
573
|
+
let l = !1;
|
|
574
|
+
function o() {
|
|
575
|
+
return e.escape !== !1;
|
|
576
|
+
}
|
|
577
|
+
function s() {
|
|
578
|
+
return e.outside === !0;
|
|
579
|
+
}
|
|
580
|
+
function c(m) {
|
|
581
|
+
if (m && !l) {
|
|
582
|
+
J.push({
|
|
583
|
+
id: t,
|
|
584
|
+
onDismiss: e.onDismiss,
|
|
585
|
+
escape: o(),
|
|
586
|
+
outside: s()
|
|
587
|
+
}), l = !0;
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
if (!m && l) {
|
|
591
|
+
const b = J.findIndex((y) => y.id === t);
|
|
592
|
+
b !== -1 && J.splice(b, 1), l = !1;
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
if (m && l) {
|
|
596
|
+
const b = J.find((y) => y.id === t);
|
|
597
|
+
b && (b.onDismiss = e.onDismiss, b.escape = o(), b.outside = s());
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
function d() {
|
|
601
|
+
return i ? i.value : !0;
|
|
602
|
+
}
|
|
603
|
+
function r(m) {
|
|
604
|
+
if (m.key !== "Escape" || !o() || !O(e.active) || !d()) return;
|
|
605
|
+
const b = Et();
|
|
606
|
+
!b || b.id !== t || (m.preventDefault(), e.onDismiss());
|
|
607
|
+
}
|
|
608
|
+
function u(m) {
|
|
609
|
+
if (!s() || !O(e.active) || !d()) return;
|
|
610
|
+
const b = At();
|
|
611
|
+
if (!b || b.id !== t) return;
|
|
612
|
+
const y = a.value;
|
|
613
|
+
if (!y) return;
|
|
614
|
+
const A = m.target;
|
|
615
|
+
!(A instanceof Node) || y.contains(A) || e.onDismiss();
|
|
616
|
+
}
|
|
617
|
+
K(
|
|
618
|
+
() => O(e.active),
|
|
619
|
+
(m) => {
|
|
620
|
+
c(!!m);
|
|
621
|
+
},
|
|
622
|
+
{ immediate: !0 }
|
|
623
|
+
), document.addEventListener("keydown", r), document.addEventListener("pointerdown", u), ie(() => {
|
|
624
|
+
document.removeEventListener("keydown", r), document.removeEventListener("pointerdown", u), c(!1);
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
const Dt = [
|
|
628
|
+
"a[href]",
|
|
629
|
+
"button:not([disabled])",
|
|
630
|
+
'input:not([disabled]):not([type="hidden"])',
|
|
631
|
+
"select:not([disabled])",
|
|
632
|
+
"textarea:not([disabled])",
|
|
633
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
634
|
+
].join(",");
|
|
635
|
+
function Rt(a) {
|
|
636
|
+
if (a.hidden || a.closest("[hidden]") || a.getAttribute("aria-hidden") === "true") return !1;
|
|
637
|
+
let e = a;
|
|
638
|
+
for (; e; ) {
|
|
639
|
+
const t = getComputedStyle(e);
|
|
640
|
+
if (t.display === "none" || t.visibility === "hidden") return !1;
|
|
641
|
+
e = e.parentElement;
|
|
642
|
+
}
|
|
643
|
+
return !0;
|
|
644
|
+
}
|
|
645
|
+
function je(a) {
|
|
646
|
+
return Array.from(a.querySelectorAll(Dt)).filter(Rt);
|
|
647
|
+
}
|
|
648
|
+
function Bt(a, e) {
|
|
649
|
+
let t = null, n = !1;
|
|
650
|
+
const i = (s) => {
|
|
651
|
+
if (s.key !== "Tab") return;
|
|
652
|
+
const c = O(a);
|
|
653
|
+
if (!c) return;
|
|
654
|
+
const d = je(c);
|
|
655
|
+
if (d.length === 0) {
|
|
656
|
+
s.preventDefault();
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
const r = d[0], u = d[d.length - 1], m = document.activeElement, b = !m || !c.contains(m);
|
|
660
|
+
s.shiftKey ? (b || m === r) && (s.preventDefault(), u.focus()) : (b || m === u) && (s.preventDefault(), r.focus());
|
|
661
|
+
}, l = () => {
|
|
662
|
+
const s = O(a);
|
|
663
|
+
t = document.activeElement instanceof HTMLElement ? document.activeElement : null, n || (document.addEventListener("keydown", i, !0), n = !0), requestAnimationFrame(() => {
|
|
664
|
+
const d = O(a) ?? s;
|
|
665
|
+
if (!d) return;
|
|
666
|
+
const r = je(d);
|
|
667
|
+
r.length > 0 ? r[0].focus() : typeof d.focus == "function" && d.focus();
|
|
668
|
+
});
|
|
669
|
+
}, o = () => {
|
|
670
|
+
n && (document.removeEventListener("keydown", i, !0), n = !1);
|
|
671
|
+
const s = t;
|
|
672
|
+
t = null, s && typeof s.focus == "function" && s.focus();
|
|
673
|
+
};
|
|
674
|
+
K(
|
|
675
|
+
() => O(e.active),
|
|
676
|
+
(s) => {
|
|
677
|
+
s ? l() : o();
|
|
678
|
+
},
|
|
679
|
+
{ immediate: !0 }
|
|
680
|
+
), ie(() => {
|
|
681
|
+
n && o();
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
let ue = 0, xe = "";
|
|
685
|
+
function Mt() {
|
|
686
|
+
typeof document > "u" || (ue === 0 && (xe = document.body.style.overflow, document.body.style.overflow = "hidden"), ue += 1);
|
|
687
|
+
}
|
|
688
|
+
function Se() {
|
|
689
|
+
typeof document > "u" || ue !== 0 && (ue -= 1, ue === 0 && (document.body.style.overflow = xe, xe = ""));
|
|
690
|
+
}
|
|
691
|
+
function zt(a) {
|
|
692
|
+
let e = !1;
|
|
693
|
+
const t = (n) => {
|
|
694
|
+
n && !e ? (Mt(), e = !0) : !n && e && (Se(), e = !1);
|
|
695
|
+
};
|
|
696
|
+
K(
|
|
697
|
+
() => O(a),
|
|
698
|
+
(n) => t(n),
|
|
699
|
+
{ immediate: !0 }
|
|
700
|
+
), ie(() => {
|
|
701
|
+
e && (Se(), e = !1);
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
const jt = ["aria-labelledby", "aria-describedby"], St = { class: "min-w-0 flex-1" }, Lt = ["id"], Ot = ["id"], Pt = "absolute inset-0 bg-kablui-overlay", Vt = "flex items-start gap-3 px-4 pt-4", Ft = "font-kablui-semibold text-kablui-lg text-kablui-fg", Ht = "mt-1 text-kablui-sm text-kablui-muted-fg", Kt = "px-4 py-3 text-kablui-md", Nt = "flex flex-wrap items-center justify-end gap-2 border-t border-kablui-border px-4 py-3", dn = /* @__PURE__ */ x({
|
|
705
|
+
__name: "Dialog",
|
|
706
|
+
props: /* @__PURE__ */ U({
|
|
707
|
+
dismissible: { type: Boolean, default: !0 },
|
|
708
|
+
showClose: { type: Boolean, default: !1 },
|
|
709
|
+
to: { default: "body" }
|
|
710
|
+
}, {
|
|
711
|
+
open: { type: Boolean, default: !1 },
|
|
712
|
+
openModifiers: {}
|
|
713
|
+
}),
|
|
714
|
+
emits: ["update:open"],
|
|
715
|
+
setup(a) {
|
|
716
|
+
const e = a, t = N(a, "open"), n = Fe(), i = R(null), l = P("dialog-title"), o = P("dialog-description"), s = g(() => !!n.title), c = g(() => !!n.description), { register: d, unregister: r } = pe("modal");
|
|
717
|
+
K(
|
|
718
|
+
t,
|
|
719
|
+
(D) => {
|
|
720
|
+
D ? d() : r();
|
|
721
|
+
},
|
|
722
|
+
{ immediate: !0 }
|
|
723
|
+
);
|
|
724
|
+
function u() {
|
|
725
|
+
t.value = !1;
|
|
726
|
+
}
|
|
727
|
+
function m() {
|
|
728
|
+
e.dismissible && (t.value = !1);
|
|
729
|
+
}
|
|
730
|
+
zt(t), Bt(i, { active: t }), Ce(i, {
|
|
731
|
+
active: () => !!t.value && e.dismissible,
|
|
732
|
+
onDismiss: m,
|
|
733
|
+
escape: !0,
|
|
734
|
+
outside: !0
|
|
735
|
+
});
|
|
736
|
+
const b = [
|
|
737
|
+
"fixed inset-0 z-kablui-modal",
|
|
738
|
+
"flex items-center justify-center p-4"
|
|
739
|
+
].join(" "), y = [
|
|
740
|
+
"relative flex w-full max-w-md flex-col",
|
|
741
|
+
"rounded-kablui-md border border-kablui-border bg-kablui-bg text-kablui-fg",
|
|
742
|
+
"shadow-kablui-lg",
|
|
743
|
+
"outline-none"
|
|
744
|
+
].join(" "), A = [
|
|
745
|
+
"ml-auto shrink-0 -mr-1 -mt-0.5 inline-flex size-7 items-center justify-center",
|
|
746
|
+
"rounded-kablui-sm text-kablui-muted-fg hover:bg-kablui-muted hover:text-kablui-fg",
|
|
747
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-kablui-focus focus-visible:ring-offset-2 focus-visible:ring-offset-kablui-bg"
|
|
748
|
+
].join(" ");
|
|
749
|
+
return (D, _) => (f(), V(de, { to: a.to }, [
|
|
750
|
+
t.value ? (f(), p("div", {
|
|
751
|
+
key: 0,
|
|
752
|
+
class: w(v(b)),
|
|
753
|
+
"data-kablui-dialog": ""
|
|
754
|
+
}, [
|
|
755
|
+
j("div", {
|
|
756
|
+
class: w(Pt),
|
|
757
|
+
"aria-hidden": "true",
|
|
758
|
+
"data-kablui-dialog-backdrop": ""
|
|
759
|
+
}),
|
|
760
|
+
j("div", {
|
|
761
|
+
ref_key: "panelRef",
|
|
762
|
+
ref: i,
|
|
763
|
+
role: "dialog",
|
|
764
|
+
"aria-modal": "true",
|
|
765
|
+
"aria-labelledby": s.value ? v(l) : void 0,
|
|
766
|
+
"aria-describedby": c.value ? v(o) : void 0,
|
|
767
|
+
class: w(v(y)),
|
|
768
|
+
tabindex: "-1",
|
|
769
|
+
"data-kablui-dialog-panel": ""
|
|
770
|
+
}, [
|
|
771
|
+
s.value || c.value || a.showClose ? (f(), p("div", {
|
|
772
|
+
key: 0,
|
|
773
|
+
class: w(Vt)
|
|
774
|
+
}, [
|
|
775
|
+
j("div", St, [
|
|
776
|
+
s.value ? (f(), p("h2", {
|
|
777
|
+
key: 0,
|
|
778
|
+
id: v(l),
|
|
779
|
+
class: w(Ft)
|
|
780
|
+
}, [
|
|
781
|
+
C(D.$slots, "title")
|
|
782
|
+
], 8, Lt)) : z("", !0),
|
|
783
|
+
c.value ? (f(), p("p", {
|
|
784
|
+
key: 1,
|
|
785
|
+
id: v(o),
|
|
786
|
+
class: w([Ht, s.value ? void 0 : "mt-0"])
|
|
787
|
+
}, [
|
|
788
|
+
C(D.$slots, "description")
|
|
789
|
+
], 10, Ot)) : z("", !0)
|
|
790
|
+
]),
|
|
791
|
+
a.showClose ? (f(), p("button", {
|
|
792
|
+
key: 0,
|
|
793
|
+
type: "button",
|
|
794
|
+
class: w(v(A)),
|
|
795
|
+
"aria-label": "Close",
|
|
796
|
+
onClick: u
|
|
797
|
+
}, [..._[0] || (_[0] = [
|
|
798
|
+
j("span", { "aria-hidden": "true" }, "×", -1)
|
|
799
|
+
])], 2)) : z("", !0)
|
|
800
|
+
])) : z("", !0),
|
|
801
|
+
D.$slots.default ? (f(), p("div", {
|
|
802
|
+
key: 1,
|
|
803
|
+
class: w(Kt)
|
|
804
|
+
}, [
|
|
805
|
+
C(D.$slots, "default")
|
|
806
|
+
])) : z("", !0),
|
|
807
|
+
D.$slots.footer ? (f(), p("div", {
|
|
808
|
+
key: 2,
|
|
809
|
+
class: w(Nt)
|
|
810
|
+
}, [
|
|
811
|
+
C(D.$slots, "footer")
|
|
812
|
+
])) : z("", !0)
|
|
813
|
+
], 10, jt)
|
|
814
|
+
], 2)) : z("", !0)
|
|
815
|
+
], 8, ["to"]));
|
|
816
|
+
}
|
|
817
|
+
}), Ut = {
|
|
818
|
+
key: 0,
|
|
819
|
+
class: "text-kablui-muted-fg"
|
|
820
|
+
}, qt = {
|
|
821
|
+
key: 1,
|
|
822
|
+
class: "text-kablui-lg font-kablui-semibold text-kablui-fg"
|
|
823
|
+
}, Yt = {
|
|
824
|
+
key: 2,
|
|
825
|
+
class: "text-kablui-md max-w-sm"
|
|
826
|
+
}, Gt = {
|
|
827
|
+
key: 3,
|
|
828
|
+
class: "mt-1"
|
|
829
|
+
}, cn = /* @__PURE__ */ x({
|
|
830
|
+
__name: "Empty",
|
|
831
|
+
props: {
|
|
832
|
+
title: {}
|
|
833
|
+
},
|
|
834
|
+
setup(a) {
|
|
835
|
+
const e = [
|
|
836
|
+
"flex w-full flex-col items-center justify-center gap-3",
|
|
837
|
+
"px-4 py-8 text-center",
|
|
838
|
+
"text-kablui-muted-fg"
|
|
839
|
+
].join(" ");
|
|
840
|
+
return (t, n) => (f(), p("div", {
|
|
841
|
+
class: w(v(e))
|
|
842
|
+
}, [
|
|
843
|
+
t.$slots.icon ? (f(), p("div", Ut, [
|
|
844
|
+
C(t.$slots, "icon")
|
|
845
|
+
])) : z("", !0),
|
|
846
|
+
a.title ? (f(), p("div", qt, H(a.title), 1)) : z("", !0),
|
|
847
|
+
t.$slots.default ? (f(), p("div", Yt, [
|
|
848
|
+
C(t.$slots, "default")
|
|
849
|
+
])) : z("", !0),
|
|
850
|
+
t.$slots.action ? (f(), p("div", Gt, [
|
|
851
|
+
C(t.$slots, "action")
|
|
852
|
+
])) : z("", !0)
|
|
853
|
+
], 2));
|
|
854
|
+
}
|
|
855
|
+
}), Wt = {
|
|
856
|
+
class: "flex flex-col gap-1.5",
|
|
857
|
+
"data-slot": "field"
|
|
858
|
+
}, fn = /* @__PURE__ */ x({
|
|
859
|
+
__name: "Field",
|
|
860
|
+
props: {
|
|
861
|
+
invalid: { type: Boolean, default: !1 },
|
|
862
|
+
id: {}
|
|
863
|
+
},
|
|
864
|
+
setup(a) {
|
|
865
|
+
const e = a;
|
|
866
|
+
return wt({
|
|
867
|
+
invalid: it(e, "invalid"),
|
|
868
|
+
id: e.id
|
|
869
|
+
}), (t, n) => (f(), p("div", Wt, [
|
|
870
|
+
C(t.$slots, "default")
|
|
871
|
+
]));
|
|
872
|
+
}
|
|
873
|
+
}), Jt = ["id"], bn = /* @__PURE__ */ x({
|
|
874
|
+
__name: "FieldError",
|
|
875
|
+
setup(a) {
|
|
876
|
+
const e = me(), t = Fe(), n = g(() => {
|
|
877
|
+
var o;
|
|
878
|
+
const l = (o = t.default) == null ? void 0 : o.call(t, {});
|
|
879
|
+
return !l || l.length === 0 ? !1 : l.some((s) => typeof s.children == "string" ? s.children.trim().length > 0 : s.children != null);
|
|
880
|
+
}), i = g(() => n.value || !!(e != null && e.invalid.value));
|
|
881
|
+
return st(() => {
|
|
882
|
+
e == null || e.setHasError(i.value && n.value);
|
|
883
|
+
}), q(() => {
|
|
884
|
+
e == null || e.setHasError(!1);
|
|
885
|
+
}), (l, o) => {
|
|
886
|
+
var s;
|
|
887
|
+
return i.value && n.value ? (f(), p("p", {
|
|
888
|
+
key: 0,
|
|
889
|
+
id: (s = v(e)) == null ? void 0 : s.errorId,
|
|
890
|
+
role: "alert",
|
|
891
|
+
class: "text-kablui-sm text-kablui-danger",
|
|
892
|
+
"data-slot": "field-error"
|
|
893
|
+
}, [
|
|
894
|
+
C(l.$slots, "default")
|
|
895
|
+
], 8, Jt)) : z("", !0);
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
}), Qt = ["id"], vn = /* @__PURE__ */ x({
|
|
899
|
+
__name: "FieldHint",
|
|
900
|
+
setup(a) {
|
|
901
|
+
const e = me();
|
|
902
|
+
return ne(() => {
|
|
903
|
+
e == null || e.setHasHint(!0);
|
|
904
|
+
}), q(() => {
|
|
905
|
+
e == null || e.setHasHint(!1);
|
|
906
|
+
}), (t, n) => {
|
|
907
|
+
var i;
|
|
908
|
+
return f(), p("p", {
|
|
909
|
+
id: (i = v(e)) == null ? void 0 : i.hintId,
|
|
910
|
+
class: "text-kablui-sm text-kablui-muted-fg",
|
|
911
|
+
"data-slot": "field-hint"
|
|
912
|
+
}, [
|
|
913
|
+
C(t.$slots, "default")
|
|
914
|
+
], 8, Qt);
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
}), Xt = ["role", "aria-hidden", "aria-label", "title"], mn = /* @__PURE__ */ x({
|
|
918
|
+
__name: "Icon",
|
|
919
|
+
props: {
|
|
920
|
+
size: { default: "md" },
|
|
921
|
+
label: {},
|
|
922
|
+
title: {}
|
|
923
|
+
},
|
|
924
|
+
setup(a) {
|
|
925
|
+
const e = a, t = [
|
|
926
|
+
"inline-flex shrink-0 items-center justify-center",
|
|
927
|
+
"text-current",
|
|
928
|
+
"[&>svg]:size-full"
|
|
929
|
+
].join(" "), n = {
|
|
930
|
+
sm: "size-3",
|
|
931
|
+
md: "size-4",
|
|
932
|
+
lg: "size-5"
|
|
933
|
+
}, i = g(() => !e.label);
|
|
934
|
+
return (l, o) => (f(), p("span", {
|
|
935
|
+
class: w([v(t), n[a.size]]),
|
|
936
|
+
role: i.value ? void 0 : "img",
|
|
937
|
+
"aria-hidden": i.value ? !0 : void 0,
|
|
938
|
+
"aria-label": a.label || void 0,
|
|
939
|
+
title: a.title
|
|
940
|
+
}, [
|
|
941
|
+
C(l.$slots, "default")
|
|
942
|
+
], 10, Xt));
|
|
943
|
+
}
|
|
944
|
+
}), Zt = ["id", "type", "name", "disabled", "placeholder", "value", "aria-invalid", "aria-describedby"], pn = /* @__PURE__ */ x({
|
|
945
|
+
inheritAttrs: !1,
|
|
946
|
+
__name: "Input",
|
|
947
|
+
props: /* @__PURE__ */ U({
|
|
948
|
+
type: { default: "text" },
|
|
949
|
+
size: { default: "md" },
|
|
950
|
+
disabled: { type: Boolean, default: !1 },
|
|
951
|
+
invalid: { type: Boolean, default: !1 },
|
|
952
|
+
placeholder: {},
|
|
953
|
+
name: {},
|
|
954
|
+
id: {}
|
|
955
|
+
}, {
|
|
956
|
+
modelValue: { default: "" },
|
|
957
|
+
modelModifiers: {}
|
|
958
|
+
}),
|
|
959
|
+
emits: ["update:modelValue"],
|
|
960
|
+
setup(a) {
|
|
961
|
+
const e = a, t = N(a, "modelValue"), n = X(), i = se({
|
|
962
|
+
id: () => e.id,
|
|
963
|
+
invalid: () => e.invalid
|
|
964
|
+
}), l = [
|
|
965
|
+
"w-full border border-kablui-border bg-kablui-bg text-kablui-fg",
|
|
966
|
+
"rounded-kablui-md font-kablui-normal",
|
|
967
|
+
"placeholder:text-kablui-muted-fg",
|
|
968
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-kablui-focus focus-visible:ring-offset-2 focus-visible:ring-offset-kablui-bg",
|
|
969
|
+
"disabled:opacity-50 disabled:pointer-events-none"
|
|
970
|
+
].join(" "), o = {
|
|
971
|
+
sm: "text-kablui-sm px-2 py-1",
|
|
972
|
+
md: "text-kablui-md px-3 py-1.5",
|
|
973
|
+
lg: "text-kablui-lg px-4 py-2"
|
|
974
|
+
}, s = g(() => [
|
|
975
|
+
l,
|
|
976
|
+
o[e.size],
|
|
977
|
+
i.invalid.value ? "border-kablui-danger" : ""
|
|
978
|
+
]);
|
|
979
|
+
return (c, d) => (f(), p("input", Z({
|
|
980
|
+
id: v(i).id.value,
|
|
981
|
+
type: a.type,
|
|
982
|
+
name: a.name,
|
|
983
|
+
disabled: a.disabled,
|
|
984
|
+
placeholder: a.placeholder,
|
|
985
|
+
value: t.value,
|
|
986
|
+
"aria-invalid": v(i).ariaInvalid.value,
|
|
987
|
+
"aria-describedby": v(i).describedBy.value,
|
|
988
|
+
class: s.value
|
|
989
|
+
}, v(n), {
|
|
990
|
+
onInput: d[0] || (d[0] = (r) => t.value = r.target.value)
|
|
991
|
+
}), null, 16, Zt));
|
|
992
|
+
}
|
|
993
|
+
}), ea = ["for"], ta = {
|
|
994
|
+
key: 0,
|
|
995
|
+
class: "text-kablui-danger",
|
|
996
|
+
"aria-hidden": "true"
|
|
997
|
+
}, gn = /* @__PURE__ */ x({
|
|
998
|
+
inheritAttrs: !1,
|
|
999
|
+
__name: "Label",
|
|
1000
|
+
props: {
|
|
1001
|
+
required: { type: Boolean, default: !1 },
|
|
1002
|
+
for: {}
|
|
1003
|
+
},
|
|
1004
|
+
setup(a) {
|
|
1005
|
+
const e = a, t = X(), n = me(), i = g(() => e.for || (n == null ? void 0 : n.controlId));
|
|
1006
|
+
return (l, o) => (f(), p("label", Z({
|
|
1007
|
+
for: i.value,
|
|
1008
|
+
class: "inline-flex items-center gap-1 text-kablui-sm font-kablui-medium text-kablui-fg"
|
|
1009
|
+
}, v(t)), [
|
|
1010
|
+
C(l.$slots, "default"),
|
|
1011
|
+
a.required ? (f(), p("span", ta, "*")) : z("", !0)
|
|
1012
|
+
], 16, ea));
|
|
1013
|
+
}
|
|
1014
|
+
}), aa = ["href", "target", "rel", "aria-disabled", "tabindex"], kn = /* @__PURE__ */ x({
|
|
1015
|
+
__name: "Link",
|
|
1016
|
+
props: {
|
|
1017
|
+
href: {},
|
|
1018
|
+
external: { type: Boolean, default: !1 },
|
|
1019
|
+
disabled: { type: Boolean, default: !1 }
|
|
1020
|
+
},
|
|
1021
|
+
setup(a) {
|
|
1022
|
+
const e = a, t = [
|
|
1023
|
+
"text-kablui-accent underline underline-offset-2",
|
|
1024
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-kablui-focus focus-visible:ring-offset-2 focus-visible:ring-offset-kablui-bg",
|
|
1025
|
+
"aria-disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:text-kablui-muted-fg aria-disabled:no-underline"
|
|
1026
|
+
].join(" ");
|
|
1027
|
+
function n(l) {
|
|
1028
|
+
e.disabled && l.preventDefault();
|
|
1029
|
+
}
|
|
1030
|
+
function i(l) {
|
|
1031
|
+
e.disabled && (l.key === "Enter" || l.key === " ") && l.preventDefault();
|
|
1032
|
+
}
|
|
1033
|
+
return (l, o) => (f(), p("a", {
|
|
1034
|
+
href: a.href,
|
|
1035
|
+
target: a.external ? "_blank" : void 0,
|
|
1036
|
+
rel: a.external ? "noopener noreferrer" : void 0,
|
|
1037
|
+
"aria-disabled": a.disabled || void 0,
|
|
1038
|
+
tabindex: a.disabled ? -1 : void 0,
|
|
1039
|
+
class: w(v(t)),
|
|
1040
|
+
onClick: n,
|
|
1041
|
+
onKeydown: i
|
|
1042
|
+
}, [
|
|
1043
|
+
C(l.$slots, "default")
|
|
1044
|
+
], 42, aa));
|
|
1045
|
+
}
|
|
1046
|
+
}), fe = Symbol("kablui-menu"), hn = /* @__PURE__ */ x({
|
|
1047
|
+
__name: "Menu",
|
|
1048
|
+
props: /* @__PURE__ */ U({
|
|
1049
|
+
placement: { default: "bottom-start" }
|
|
1050
|
+
}, {
|
|
1051
|
+
open: { type: Boolean, default: !1 },
|
|
1052
|
+
openModifiers: {}
|
|
1053
|
+
}),
|
|
1054
|
+
emits: ["update:open"],
|
|
1055
|
+
setup(a) {
|
|
1056
|
+
const e = a, t = N(a, "open"), n = R(null), i = R(null), l = R(null), o = P("menu"), s = R(null), { register: c, unregister: d } = pe("dropdown");
|
|
1057
|
+
function r() {
|
|
1058
|
+
const $ = l.value;
|
|
1059
|
+
return $ ? [
|
|
1060
|
+
...$.querySelectorAll(
|
|
1061
|
+
'[data-slot="menu-item"]:not([disabled]):not([aria-disabled="true"])'
|
|
1062
|
+
)
|
|
1063
|
+
] : [];
|
|
1064
|
+
}
|
|
1065
|
+
function u() {
|
|
1066
|
+
var $;
|
|
1067
|
+
($ = r()[0]) == null || $.focus();
|
|
1068
|
+
}
|
|
1069
|
+
function m($, h) {
|
|
1070
|
+
var F;
|
|
1071
|
+
const I = r();
|
|
1072
|
+
if (I.length === 0) return;
|
|
1073
|
+
const E = $ ? I.indexOf($) : -1, M = E === -1 ? h > 0 ? 0 : I.length - 1 : (E + h + I.length) % I.length;
|
|
1074
|
+
(F = I[M]) == null || F.focus();
|
|
1075
|
+
}
|
|
1076
|
+
function b($) {
|
|
1077
|
+
var I;
|
|
1078
|
+
const h = r();
|
|
1079
|
+
h.length !== 0 && ((I = $ === "start" ? h[0] : h[h.length - 1]) == null || I.focus());
|
|
1080
|
+
}
|
|
1081
|
+
function y($, h) {
|
|
1082
|
+
t.value = $;
|
|
1083
|
+
}
|
|
1084
|
+
function A($) {
|
|
1085
|
+
y(!t.value);
|
|
1086
|
+
}
|
|
1087
|
+
function D() {
|
|
1088
|
+
t.value = !1;
|
|
1089
|
+
}
|
|
1090
|
+
function _() {
|
|
1091
|
+
t.value = !1;
|
|
1092
|
+
}
|
|
1093
|
+
return Ce(n, {
|
|
1094
|
+
active: t,
|
|
1095
|
+
onDismiss: _,
|
|
1096
|
+
escape: !0,
|
|
1097
|
+
outside: !0
|
|
1098
|
+
}), K(
|
|
1099
|
+
t,
|
|
1100
|
+
($, h) => {
|
|
1101
|
+
if ($) {
|
|
1102
|
+
c(), s.value = document.activeElement instanceof HTMLElement ? document.activeElement : null, Q(() => {
|
|
1103
|
+
u();
|
|
1104
|
+
});
|
|
1105
|
+
return;
|
|
1106
|
+
}
|
|
1107
|
+
d(), h && Q(() => {
|
|
1108
|
+
const I = s.value ?? i.value;
|
|
1109
|
+
I == null || I.focus(), s.value = null;
|
|
1110
|
+
});
|
|
1111
|
+
},
|
|
1112
|
+
{ immediate: !0 }
|
|
1113
|
+
), G(fe, {
|
|
1114
|
+
open: t,
|
|
1115
|
+
contentId: o,
|
|
1116
|
+
placement: g(() => e.placement),
|
|
1117
|
+
triggerRef: i,
|
|
1118
|
+
contentRef: l,
|
|
1119
|
+
setOpen: y,
|
|
1120
|
+
toggle: A,
|
|
1121
|
+
getEnabledItems: r,
|
|
1122
|
+
focusFirstItem: u,
|
|
1123
|
+
focusItemRelative: m,
|
|
1124
|
+
focusItemAtEdge: b,
|
|
1125
|
+
closeOnSelect: D
|
|
1126
|
+
}), ($, h) => (f(), p("div", {
|
|
1127
|
+
ref_key: "rootRef",
|
|
1128
|
+
ref: n,
|
|
1129
|
+
class: "relative inline-flex",
|
|
1130
|
+
"data-slot": "menu"
|
|
1131
|
+
}, [
|
|
1132
|
+
C($.$slots, "default")
|
|
1133
|
+
], 512));
|
|
1134
|
+
}
|
|
1135
|
+
}), na = {
|
|
1136
|
+
top: "bottom",
|
|
1137
|
+
bottom: "top",
|
|
1138
|
+
left: "right",
|
|
1139
|
+
right: "left"
|
|
1140
|
+
};
|
|
1141
|
+
function ia(a) {
|
|
1142
|
+
const [e, t] = a.split("-");
|
|
1143
|
+
return { side: e, align: t ?? "center" };
|
|
1144
|
+
}
|
|
1145
|
+
function ve(a, e, t, n) {
|
|
1146
|
+
switch (n) {
|
|
1147
|
+
case "start":
|
|
1148
|
+
return a;
|
|
1149
|
+
case "end":
|
|
1150
|
+
return a + e - t;
|
|
1151
|
+
case "center":
|
|
1152
|
+
default:
|
|
1153
|
+
return a + (e - t) / 2;
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
function Le(a, e, t, n) {
|
|
1157
|
+
switch (t) {
|
|
1158
|
+
case "top":
|
|
1159
|
+
return {
|
|
1160
|
+
x: ve(a.left, a.width, e.width, n),
|
|
1161
|
+
y: a.top - e.height
|
|
1162
|
+
};
|
|
1163
|
+
case "bottom":
|
|
1164
|
+
return {
|
|
1165
|
+
x: ve(a.left, a.width, e.width, n),
|
|
1166
|
+
y: a.bottom
|
|
1167
|
+
};
|
|
1168
|
+
case "left":
|
|
1169
|
+
return {
|
|
1170
|
+
x: a.left - e.width,
|
|
1171
|
+
y: ve(a.top, a.height, e.height, n)
|
|
1172
|
+
};
|
|
1173
|
+
case "right":
|
|
1174
|
+
return {
|
|
1175
|
+
x: a.right,
|
|
1176
|
+
y: ve(a.top, a.height, e.height, n)
|
|
1177
|
+
};
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
function sa(a, e, t, n, i, l) {
|
|
1181
|
+
switch (n) {
|
|
1182
|
+
case "top":
|
|
1183
|
+
return e < 0;
|
|
1184
|
+
case "bottom":
|
|
1185
|
+
return e + t.height > l;
|
|
1186
|
+
case "left":
|
|
1187
|
+
return a < 0;
|
|
1188
|
+
case "right":
|
|
1189
|
+
return a + t.width > i;
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
function la(a, e, t) {
|
|
1193
|
+
const n = a.getBoundingClientRect(), i = e.getBoundingClientRect(), { side: l, align: o } = ia(t);
|
|
1194
|
+
let { x: s, y: c } = Le(n, i, l, o);
|
|
1195
|
+
if (sa(s, c, i, l, window.innerWidth, window.innerHeight)) {
|
|
1196
|
+
const d = na[l];
|
|
1197
|
+
({ x: s, y: c } = Le(n, i, d, o));
|
|
1198
|
+
}
|
|
1199
|
+
return {
|
|
1200
|
+
position: "fixed",
|
|
1201
|
+
top: `${c}px`,
|
|
1202
|
+
left: `${s}px`
|
|
1203
|
+
};
|
|
1204
|
+
}
|
|
1205
|
+
function Ie(a, e, t) {
|
|
1206
|
+
const n = R({}), i = () => {
|
|
1207
|
+
if (!O(t.open)) {
|
|
1208
|
+
n.value = {};
|
|
1209
|
+
return;
|
|
1210
|
+
}
|
|
1211
|
+
const d = v(a), r = v(e);
|
|
1212
|
+
if (!d || !r) {
|
|
1213
|
+
n.value = {};
|
|
1214
|
+
return;
|
|
1215
|
+
}
|
|
1216
|
+
n.value = la(d, r, O(t.placement));
|
|
1217
|
+
}, l = () => {
|
|
1218
|
+
i();
|
|
1219
|
+
};
|
|
1220
|
+
let o = !1;
|
|
1221
|
+
const s = () => {
|
|
1222
|
+
o || typeof window > "u" || (o = !0, window.addEventListener("scroll", l, !0), window.addEventListener("resize", l));
|
|
1223
|
+
}, c = () => {
|
|
1224
|
+
!o || typeof window > "u" || (o = !1, window.removeEventListener("scroll", l, !0), window.removeEventListener("resize", l));
|
|
1225
|
+
};
|
|
1226
|
+
return K(
|
|
1227
|
+
[() => O(t.open), () => O(t.placement), a, e],
|
|
1228
|
+
([d]) => {
|
|
1229
|
+
d ? (s(), i()) : (c(), n.value = {});
|
|
1230
|
+
},
|
|
1231
|
+
{ immediate: !0, flush: "post" }
|
|
1232
|
+
), ie(() => {
|
|
1233
|
+
c();
|
|
1234
|
+
}), { style: n };
|
|
1235
|
+
}
|
|
1236
|
+
const oa = ["id", "data-placement"], yn = /* @__PURE__ */ x({
|
|
1237
|
+
__name: "MenuContent",
|
|
1238
|
+
setup(a) {
|
|
1239
|
+
const e = S(fe, null);
|
|
1240
|
+
e || console.warn("[kablui] MenuContent must be used inside Menu");
|
|
1241
|
+
const t = R(null), n = R(null);
|
|
1242
|
+
function i(r) {
|
|
1243
|
+
e && (e.contentRef.value = r instanceof HTMLElement ? r : null);
|
|
1244
|
+
}
|
|
1245
|
+
q(() => {
|
|
1246
|
+
e && (e.contentRef.value = null);
|
|
1247
|
+
});
|
|
1248
|
+
const l = g(() => !!(e != null && e.open.value)), o = g(() => (e == null ? void 0 : e.placement.value) ?? "bottom-start"), { style: s } = Ie(
|
|
1249
|
+
(e == null ? void 0 : e.triggerRef) ?? t,
|
|
1250
|
+
(e == null ? void 0 : e.contentRef) ?? n,
|
|
1251
|
+
{
|
|
1252
|
+
open: l,
|
|
1253
|
+
placement: o
|
|
1254
|
+
}
|
|
1255
|
+
);
|
|
1256
|
+
function c(r) {
|
|
1257
|
+
if (!e) return;
|
|
1258
|
+
const u = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
1259
|
+
switch (r.key) {
|
|
1260
|
+
case "ArrowDown":
|
|
1261
|
+
r.preventDefault(), e.focusItemRelative(u, 1);
|
|
1262
|
+
break;
|
|
1263
|
+
case "ArrowUp":
|
|
1264
|
+
r.preventDefault(), e.focusItemRelative(u, -1);
|
|
1265
|
+
break;
|
|
1266
|
+
case "Home":
|
|
1267
|
+
r.preventDefault(), e.focusItemAtEdge("start");
|
|
1268
|
+
break;
|
|
1269
|
+
case "End":
|
|
1270
|
+
r.preventDefault(), e.focusItemAtEdge("end");
|
|
1271
|
+
break;
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
const d = [
|
|
1275
|
+
"z-kablui-dropdown min-w-40 rounded-kablui-md border border-kablui-border bg-kablui-bg",
|
|
1276
|
+
"py-1 text-kablui-md text-kablui-fg shadow-kablui-md",
|
|
1277
|
+
"focus:outline-none"
|
|
1278
|
+
].join(" ");
|
|
1279
|
+
return (r, u) => (f(), V(de, { to: "body" }, [
|
|
1280
|
+
l.value && v(e) ? (f(), p("div", {
|
|
1281
|
+
key: 0,
|
|
1282
|
+
id: v(e).contentId,
|
|
1283
|
+
ref: i,
|
|
1284
|
+
role: "menu",
|
|
1285
|
+
tabindex: "-1",
|
|
1286
|
+
"data-slot": "menu-content",
|
|
1287
|
+
"data-placement": o.value,
|
|
1288
|
+
class: w(v(d)),
|
|
1289
|
+
style: ce(v(s)),
|
|
1290
|
+
onPointerdown: u[0] || (u[0] = He(() => {
|
|
1291
|
+
}, ["stop"])),
|
|
1292
|
+
onKeydown: c
|
|
1293
|
+
}, [
|
|
1294
|
+
C(r.$slots, "default")
|
|
1295
|
+
], 46, oa)) : z("", !0)
|
|
1296
|
+
]));
|
|
1297
|
+
}
|
|
1298
|
+
}), ra = ["disabled", "aria-disabled"], xn = /* @__PURE__ */ x({
|
|
1299
|
+
__name: "MenuItem",
|
|
1300
|
+
props: {
|
|
1301
|
+
disabled: { type: Boolean, default: !1 }
|
|
1302
|
+
},
|
|
1303
|
+
emits: ["select"],
|
|
1304
|
+
setup(a, { emit: e }) {
|
|
1305
|
+
const t = a, n = e, i = S(fe, null);
|
|
1306
|
+
i || console.warn("[kablui] MenuItem must be used inside Menu");
|
|
1307
|
+
function l() {
|
|
1308
|
+
t.disabled || (n("select"), i == null || i.closeOnSelect());
|
|
1309
|
+
}
|
|
1310
|
+
function o() {
|
|
1311
|
+
l();
|
|
1312
|
+
}
|
|
1313
|
+
function s(d) {
|
|
1314
|
+
(d.key === "Enter" || d.key === " ") && (d.preventDefault(), l());
|
|
1315
|
+
}
|
|
1316
|
+
const c = [
|
|
1317
|
+
"flex w-full cursor-pointer items-center px-3 py-1.5 text-left",
|
|
1318
|
+
"text-kablui-md text-kablui-fg rounded-kablui-sm",
|
|
1319
|
+
"hover:bg-kablui-muted",
|
|
1320
|
+
"focus:outline-none focus:bg-kablui-muted",
|
|
1321
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-kablui-focus focus-visible:ring-offset-2 focus-visible:ring-offset-kablui-bg",
|
|
1322
|
+
"disabled:pointer-events-none disabled:opacity-50"
|
|
1323
|
+
].join(" ");
|
|
1324
|
+
return (d, r) => (f(), p("button", {
|
|
1325
|
+
type: "button",
|
|
1326
|
+
role: "menuitem",
|
|
1327
|
+
"data-slot": "menu-item",
|
|
1328
|
+
tabindex: "-1",
|
|
1329
|
+
disabled: a.disabled || void 0,
|
|
1330
|
+
"aria-disabled": a.disabled ? "true" : void 0,
|
|
1331
|
+
class: w(v(c)),
|
|
1332
|
+
onClick: o,
|
|
1333
|
+
onKeydown: s
|
|
1334
|
+
}, [
|
|
1335
|
+
C(d.$slots, "default")
|
|
1336
|
+
], 42, ra));
|
|
1337
|
+
}
|
|
1338
|
+
}), ua = "my-1 h-px w-full shrink-0 border-0 border-t border-solid border-kablui-border", wn = /* @__PURE__ */ x({
|
|
1339
|
+
__name: "MenuSeparator",
|
|
1340
|
+
setup(a) {
|
|
1341
|
+
return S(fe, null) || console.warn("[kablui] MenuSeparator must be used inside Menu"), (t, n) => (f(), p("div", {
|
|
1342
|
+
role: "separator",
|
|
1343
|
+
"data-slot": "menu-separator",
|
|
1344
|
+
class: w(ua)
|
|
1345
|
+
}));
|
|
1346
|
+
}
|
|
1347
|
+
}), da = ["aria-expanded", "aria-controls"], _n = /* @__PURE__ */ x({
|
|
1348
|
+
__name: "MenuTrigger",
|
|
1349
|
+
setup(a) {
|
|
1350
|
+
const e = S(fe, null);
|
|
1351
|
+
e || console.warn("[kablui] MenuTrigger must be used inside Menu");
|
|
1352
|
+
function t(s) {
|
|
1353
|
+
e && (e.triggerRef.value = s instanceof HTMLElement ? s : null);
|
|
1354
|
+
}
|
|
1355
|
+
q(() => {
|
|
1356
|
+
e && (e.triggerRef.value = null);
|
|
1357
|
+
});
|
|
1358
|
+
const n = g(() => !!(e != null && e.open.value));
|
|
1359
|
+
function i() {
|
|
1360
|
+
e == null || e.toggle("pointer");
|
|
1361
|
+
}
|
|
1362
|
+
function l(s) {
|
|
1363
|
+
if (e)
|
|
1364
|
+
switch (s.key) {
|
|
1365
|
+
case "ArrowDown":
|
|
1366
|
+
case "ArrowUp":
|
|
1367
|
+
case "Enter":
|
|
1368
|
+
case " ":
|
|
1369
|
+
s.preventDefault(), e.open.value ? s.key === "Enter" || s.key === " " ? e.setOpen(!1) : s.key === "ArrowDown" ? e.focusFirstItem() : s.key === "ArrowUp" && e.focusItemAtEdge("end") : e.setOpen(!0, "keyboard");
|
|
1370
|
+
break;
|
|
1371
|
+
case "Escape":
|
|
1372
|
+
e.open.value && (s.preventDefault(), e.setOpen(!1));
|
|
1373
|
+
break;
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
const o = [
|
|
1377
|
+
"inline-flex items-center justify-center",
|
|
1378
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-kablui-focus focus-visible:ring-offset-2 focus-visible:ring-offset-kablui-bg"
|
|
1379
|
+
].join(" ");
|
|
1380
|
+
return (s, c) => {
|
|
1381
|
+
var d;
|
|
1382
|
+
return f(), p("button", {
|
|
1383
|
+
ref: t,
|
|
1384
|
+
type: "button",
|
|
1385
|
+
"data-slot": "menu-trigger",
|
|
1386
|
+
class: w(v(o)),
|
|
1387
|
+
"aria-haspopup": "menu",
|
|
1388
|
+
"aria-expanded": n.value ? "true" : "false",
|
|
1389
|
+
"aria-controls": (d = v(e)) == null ? void 0 : d.contentId,
|
|
1390
|
+
onClick: i,
|
|
1391
|
+
onKeydown: l
|
|
1392
|
+
}, [
|
|
1393
|
+
C(s.$slots, "default")
|
|
1394
|
+
], 42, da);
|
|
1395
|
+
};
|
|
1396
|
+
}
|
|
1397
|
+
}), ca = ["aria-label", "aria-disabled"], fa = {
|
|
1398
|
+
key: 0,
|
|
1399
|
+
class: "inline-flex min-w-8 items-center justify-center px-1 text-kablui-muted-fg",
|
|
1400
|
+
"aria-hidden": "true"
|
|
1401
|
+
}, $n = /* @__PURE__ */ x({
|
|
1402
|
+
__name: "Pagination",
|
|
1403
|
+
props: /* @__PURE__ */ U({
|
|
1404
|
+
pageCount: {},
|
|
1405
|
+
siblingCount: { default: 1 },
|
|
1406
|
+
disabled: { type: Boolean, default: !1 },
|
|
1407
|
+
label: { default: "Pagination" }
|
|
1408
|
+
}, {
|
|
1409
|
+
page: { default: 1 },
|
|
1410
|
+
pageModifiers: {}
|
|
1411
|
+
}),
|
|
1412
|
+
emits: ["update:page"],
|
|
1413
|
+
setup(a) {
|
|
1414
|
+
const e = a, t = N(a, "page");
|
|
1415
|
+
function n(r, u) {
|
|
1416
|
+
const m = Math.max(0, u - r + 1);
|
|
1417
|
+
return Array.from({ length: m }, (b, y) => r + y);
|
|
1418
|
+
}
|
|
1419
|
+
const i = g(() => {
|
|
1420
|
+
const r = Math.max(0, Math.floor(e.pageCount));
|
|
1421
|
+
if (r === 0) return [];
|
|
1422
|
+
const u = Math.max(0, Math.floor(e.siblingCount)), m = Math.min(Math.max(1, t.value), r);
|
|
1423
|
+
if (u * 2 + 5 >= r)
|
|
1424
|
+
return n(1, r);
|
|
1425
|
+
const y = Math.max(m - u, 1), A = Math.min(m + u, r), D = y > 2, _ = A < r - 1;
|
|
1426
|
+
if (!D && _) {
|
|
1427
|
+
const $ = 3 + 2 * u;
|
|
1428
|
+
return [...n(1, $), "ellipsis", r];
|
|
1429
|
+
}
|
|
1430
|
+
if (D && !_) {
|
|
1431
|
+
const $ = 3 + 2 * u;
|
|
1432
|
+
return [1, "ellipsis", ...n(r - $ + 1, r)];
|
|
1433
|
+
}
|
|
1434
|
+
return [
|
|
1435
|
+
1,
|
|
1436
|
+
"ellipsis",
|
|
1437
|
+
...n(y, A),
|
|
1438
|
+
"ellipsis",
|
|
1439
|
+
r
|
|
1440
|
+
];
|
|
1441
|
+
}), l = g(() => t.value <= 1), o = g(() => t.value >= e.pageCount);
|
|
1442
|
+
function s(r) {
|
|
1443
|
+
if (e.disabled) return;
|
|
1444
|
+
const u = Math.max(0, Math.floor(e.pageCount));
|
|
1445
|
+
r < 1 || r > u || r !== t.value && (t.value = r);
|
|
1446
|
+
}
|
|
1447
|
+
function c() {
|
|
1448
|
+
s(t.value - 1);
|
|
1449
|
+
}
|
|
1450
|
+
function d() {
|
|
1451
|
+
s(t.value + 1);
|
|
1452
|
+
}
|
|
1453
|
+
return (r, u) => (f(), p("nav", {
|
|
1454
|
+
"aria-label": a.label,
|
|
1455
|
+
"aria-disabled": a.disabled || void 0,
|
|
1456
|
+
class: "inline-flex items-center gap-1 text-kablui-fg"
|
|
1457
|
+
}, [
|
|
1458
|
+
he(ke, {
|
|
1459
|
+
variant: "outline",
|
|
1460
|
+
size: "sm",
|
|
1461
|
+
disabled: a.disabled || l.value,
|
|
1462
|
+
"aria-label": "Previous page",
|
|
1463
|
+
onClick: c
|
|
1464
|
+
}, {
|
|
1465
|
+
default: Y(() => [...u[0] || (u[0] = [
|
|
1466
|
+
re(" Previous ", -1)
|
|
1467
|
+
])]),
|
|
1468
|
+
_: 1
|
|
1469
|
+
}, 8, ["disabled"]),
|
|
1470
|
+
(f(!0), p(ee, null, we(i.value, (m, b) => (f(), p(ee, {
|
|
1471
|
+
key: `${m}-${b}`
|
|
1472
|
+
}, [
|
|
1473
|
+
m === "ellipsis" ? (f(), p("span", fa, " … ")) : (f(), V(ke, {
|
|
1474
|
+
key: 1,
|
|
1475
|
+
variant: m === t.value ? "solid" : "outline",
|
|
1476
|
+
size: "sm",
|
|
1477
|
+
disabled: a.disabled,
|
|
1478
|
+
"aria-label": `Page ${m}`,
|
|
1479
|
+
"aria-current": m === t.value ? "page" : void 0,
|
|
1480
|
+
onClick: (y) => s(m)
|
|
1481
|
+
}, {
|
|
1482
|
+
default: Y(() => [
|
|
1483
|
+
re(H(m), 1)
|
|
1484
|
+
]),
|
|
1485
|
+
_: 2
|
|
1486
|
+
}, 1032, ["variant", "disabled", "aria-label", "aria-current", "onClick"]))
|
|
1487
|
+
], 64))), 128)),
|
|
1488
|
+
he(ke, {
|
|
1489
|
+
variant: "outline",
|
|
1490
|
+
size: "sm",
|
|
1491
|
+
disabled: a.disabled || o.value,
|
|
1492
|
+
"aria-label": "Next page",
|
|
1493
|
+
onClick: d
|
|
1494
|
+
}, {
|
|
1495
|
+
default: Y(() => [...u[1] || (u[1] = [
|
|
1496
|
+
re(" Next ", -1)
|
|
1497
|
+
])]),
|
|
1498
|
+
_: 1
|
|
1499
|
+
}, 8, ["disabled"])
|
|
1500
|
+
], 8, ca));
|
|
1501
|
+
}
|
|
1502
|
+
}), Te = Symbol("kablui-popover"), Cn = /* @__PURE__ */ x({
|
|
1503
|
+
__name: "Popover",
|
|
1504
|
+
props: /* @__PURE__ */ U({
|
|
1505
|
+
placement: { default: "bottom-start" }
|
|
1506
|
+
}, {
|
|
1507
|
+
open: { type: Boolean, default: !1 },
|
|
1508
|
+
openModifiers: {}
|
|
1509
|
+
}),
|
|
1510
|
+
emits: ["update:open"],
|
|
1511
|
+
setup(a) {
|
|
1512
|
+
const e = a, t = N(a, "open"), n = R(null), i = R(null), l = R(null), o = P("popover"), s = R(!1), c = R(null), { register: d, unregister: r } = pe("dropdown");
|
|
1513
|
+
function u(y, A) {
|
|
1514
|
+
y && (s.value = A === "keyboard"), t.value = y;
|
|
1515
|
+
}
|
|
1516
|
+
function m(y) {
|
|
1517
|
+
u(!t.value, y);
|
|
1518
|
+
}
|
|
1519
|
+
function b() {
|
|
1520
|
+
t.value = !1;
|
|
1521
|
+
}
|
|
1522
|
+
return Ce(n, {
|
|
1523
|
+
active: t,
|
|
1524
|
+
onDismiss: b,
|
|
1525
|
+
escape: !0,
|
|
1526
|
+
outside: !0
|
|
1527
|
+
}), K(
|
|
1528
|
+
t,
|
|
1529
|
+
(y, A) => {
|
|
1530
|
+
if (y) {
|
|
1531
|
+
d(), c.value = document.activeElement instanceof HTMLElement ? document.activeElement : null, Q(() => {
|
|
1532
|
+
var D;
|
|
1533
|
+
s.value && ((D = l.value) == null || D.focus());
|
|
1534
|
+
});
|
|
1535
|
+
return;
|
|
1536
|
+
}
|
|
1537
|
+
r(), A && Q(() => {
|
|
1538
|
+
const D = c.value ?? i.value;
|
|
1539
|
+
D == null || D.focus(), s.value = !1, c.value = null;
|
|
1540
|
+
});
|
|
1541
|
+
},
|
|
1542
|
+
{ immediate: !0 }
|
|
1543
|
+
), G(Te, {
|
|
1544
|
+
open: t,
|
|
1545
|
+
contentId: o,
|
|
1546
|
+
placement: g(() => e.placement),
|
|
1547
|
+
triggerRef: i,
|
|
1548
|
+
contentRef: l,
|
|
1549
|
+
setOpen: u,
|
|
1550
|
+
toggle: m
|
|
1551
|
+
}), (y, A) => (f(), p("div", {
|
|
1552
|
+
ref_key: "rootRef",
|
|
1553
|
+
ref: n,
|
|
1554
|
+
class: "relative inline-flex",
|
|
1555
|
+
"data-slot": "popover"
|
|
1556
|
+
}, [
|
|
1557
|
+
C(y.$slots, "default")
|
|
1558
|
+
], 512));
|
|
1559
|
+
}
|
|
1560
|
+
}), ba = ["id", "data-placement"], In = /* @__PURE__ */ x({
|
|
1561
|
+
inheritAttrs: !1,
|
|
1562
|
+
__name: "PopoverContent",
|
|
1563
|
+
setup(a) {
|
|
1564
|
+
const e = X(), t = S(Te, null);
|
|
1565
|
+
t || console.warn("[kablui] PopoverContent must be used inside Popover");
|
|
1566
|
+
const n = R(null), i = R(null);
|
|
1567
|
+
function l(r) {
|
|
1568
|
+
t && (t.contentRef.value = r instanceof HTMLElement ? r : null);
|
|
1569
|
+
}
|
|
1570
|
+
q(() => {
|
|
1571
|
+
t && (t.contentRef.value = null);
|
|
1572
|
+
});
|
|
1573
|
+
const o = g(() => !!(t != null && t.open.value)), s = g(() => (t == null ? void 0 : t.placement.value) ?? "bottom-start"), { style: c } = Ie(
|
|
1574
|
+
(t == null ? void 0 : t.triggerRef) ?? n,
|
|
1575
|
+
(t == null ? void 0 : t.contentRef) ?? i,
|
|
1576
|
+
{
|
|
1577
|
+
open: o,
|
|
1578
|
+
placement: s
|
|
1579
|
+
}
|
|
1580
|
+
), d = [
|
|
1581
|
+
"z-kablui-dropdown rounded-kablui-md border border-kablui-border bg-kablui-bg",
|
|
1582
|
+
"p-3 text-kablui-md text-kablui-fg shadow-kablui-md",
|
|
1583
|
+
"focus:outline-none"
|
|
1584
|
+
].join(" ");
|
|
1585
|
+
return (r, u) => (f(), V(de, { to: "body" }, [
|
|
1586
|
+
o.value && v(t) ? (f(), p("div", Z({
|
|
1587
|
+
key: 0,
|
|
1588
|
+
id: v(t).contentId,
|
|
1589
|
+
ref: l,
|
|
1590
|
+
role: "dialog",
|
|
1591
|
+
tabindex: "-1",
|
|
1592
|
+
"data-slot": "popover-content",
|
|
1593
|
+
"data-placement": s.value,
|
|
1594
|
+
class: v(d),
|
|
1595
|
+
style: v(c)
|
|
1596
|
+
}, v(e), {
|
|
1597
|
+
onPointerdown: u[0] || (u[0] = He(() => {
|
|
1598
|
+
}, ["stop"]))
|
|
1599
|
+
}), [
|
|
1600
|
+
C(r.$slots, "default")
|
|
1601
|
+
], 16, ba)) : z("", !0)
|
|
1602
|
+
]));
|
|
1603
|
+
}
|
|
1604
|
+
}), va = ["aria-expanded", "aria-controls"], Tn = /* @__PURE__ */ x({
|
|
1605
|
+
__name: "PopoverTrigger",
|
|
1606
|
+
setup(a) {
|
|
1607
|
+
const e = S(Te, null);
|
|
1608
|
+
e || console.warn("[kablui] PopoverTrigger must be used inside Popover");
|
|
1609
|
+
function t(s) {
|
|
1610
|
+
e && (e.triggerRef.value = s instanceof HTMLElement ? s : null);
|
|
1611
|
+
}
|
|
1612
|
+
q(() => {
|
|
1613
|
+
e && (e.triggerRef.value = null);
|
|
1614
|
+
});
|
|
1615
|
+
const n = g(() => !!(e != null && e.open.value));
|
|
1616
|
+
function i() {
|
|
1617
|
+
e == null || e.toggle("pointer");
|
|
1618
|
+
}
|
|
1619
|
+
function l(s) {
|
|
1620
|
+
if (e)
|
|
1621
|
+
switch (s.key) {
|
|
1622
|
+
case "ArrowDown":
|
|
1623
|
+
case "Enter":
|
|
1624
|
+
case " ":
|
|
1625
|
+
s.preventDefault(), e.open.value ? (s.key === "Enter" || s.key === " ") && e.setOpen(!1) : e.setOpen(!0, "keyboard");
|
|
1626
|
+
break;
|
|
1627
|
+
case "Escape":
|
|
1628
|
+
e.open.value && (s.preventDefault(), e.setOpen(!1));
|
|
1629
|
+
break;
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
const o = [
|
|
1633
|
+
"inline-flex items-center justify-center",
|
|
1634
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-kablui-focus focus-visible:ring-offset-2 focus-visible:ring-offset-kablui-bg"
|
|
1635
|
+
].join(" ");
|
|
1636
|
+
return (s, c) => {
|
|
1637
|
+
var d;
|
|
1638
|
+
return f(), p("button", {
|
|
1639
|
+
ref: t,
|
|
1640
|
+
type: "button",
|
|
1641
|
+
"data-slot": "popover-trigger",
|
|
1642
|
+
class: w(v(o)),
|
|
1643
|
+
"aria-haspopup": "dialog",
|
|
1644
|
+
"aria-expanded": n.value ? "true" : "false",
|
|
1645
|
+
"aria-controls": (d = v(e)) == null ? void 0 : d.contentId,
|
|
1646
|
+
onClick: i,
|
|
1647
|
+
onKeydown: l
|
|
1648
|
+
}, [
|
|
1649
|
+
C(s.$slots, "default")
|
|
1650
|
+
], 42, va);
|
|
1651
|
+
};
|
|
1652
|
+
}
|
|
1653
|
+
}), ma = { class: "flex w-full flex-col gap-1" }, pa = {
|
|
1654
|
+
key: 0,
|
|
1655
|
+
class: "text-kablui-sm text-kablui-muted-fg"
|
|
1656
|
+
}, ga = ["aria-valuemax", "aria-valuenow", "aria-label", "aria-busy"], En = /* @__PURE__ */ x({
|
|
1657
|
+
__name: "Progress",
|
|
1658
|
+
props: {
|
|
1659
|
+
value: {},
|
|
1660
|
+
max: { default: 100 },
|
|
1661
|
+
indeterminate: { type: Boolean, default: !1 },
|
|
1662
|
+
label: {}
|
|
1663
|
+
},
|
|
1664
|
+
setup(a) {
|
|
1665
|
+
const e = a, t = g(
|
|
1666
|
+
() => e.indeterminate || e.value === void 0
|
|
1667
|
+
), n = g(() => {
|
|
1668
|
+
if (e.value === void 0) return;
|
|
1669
|
+
const c = e.max > 0 ? e.max : 100;
|
|
1670
|
+
return Math.min(Math.max(e.value, 0), c);
|
|
1671
|
+
}), i = g(() => {
|
|
1672
|
+
if (n.value === void 0) return 0;
|
|
1673
|
+
const c = e.max > 0 ? e.max : 100;
|
|
1674
|
+
return n.value / c * 100;
|
|
1675
|
+
}), l = [
|
|
1676
|
+
"relative h-2 w-full overflow-hidden rounded-kablui-full",
|
|
1677
|
+
"bg-kablui-muted"
|
|
1678
|
+
].join(" "), o = [
|
|
1679
|
+
"h-full rounded-kablui-full bg-kablui-accent",
|
|
1680
|
+
"transition-[width] duration-200 ease-out"
|
|
1681
|
+
].join(" "), s = [
|
|
1682
|
+
"absolute inset-y-0 w-1/3 rounded-kablui-full bg-kablui-accent",
|
|
1683
|
+
"animate-pulse"
|
|
1684
|
+
].join(" ");
|
|
1685
|
+
return (c, d) => (f(), p("div", ma, [
|
|
1686
|
+
a.label ? (f(), p("div", pa, H(a.label), 1)) : z("", !0),
|
|
1687
|
+
j("div", {
|
|
1688
|
+
role: "progressbar",
|
|
1689
|
+
"aria-valuemin": 0,
|
|
1690
|
+
"aria-valuemax": a.max,
|
|
1691
|
+
"aria-valuenow": t.value ? void 0 : n.value,
|
|
1692
|
+
"aria-label": a.label || void 0,
|
|
1693
|
+
"aria-busy": t.value ? !0 : void 0,
|
|
1694
|
+
class: w(v(l))
|
|
1695
|
+
}, [
|
|
1696
|
+
t.value ? (f(), p("div", {
|
|
1697
|
+
key: 0,
|
|
1698
|
+
class: w(v(s))
|
|
1699
|
+
}, null, 2)) : (f(), p("div", {
|
|
1700
|
+
key: 1,
|
|
1701
|
+
class: w(v(o)),
|
|
1702
|
+
style: ce({ width: `${i.value}%` })
|
|
1703
|
+
}, null, 6))
|
|
1704
|
+
], 10, ga)
|
|
1705
|
+
]));
|
|
1706
|
+
}
|
|
1707
|
+
}), Ue = Symbol("kablui-radio-group"), ka = ["id", "name", "value", "checked", "disabled", "aria-invalid"], An = /* @__PURE__ */ x({
|
|
1708
|
+
inheritAttrs: !1,
|
|
1709
|
+
__name: "Radio",
|
|
1710
|
+
props: {
|
|
1711
|
+
value: {},
|
|
1712
|
+
disabled: { type: Boolean, default: !1 },
|
|
1713
|
+
id: {}
|
|
1714
|
+
},
|
|
1715
|
+
setup(a) {
|
|
1716
|
+
const e = a, t = X(), n = S(Ue, null), i = R(null);
|
|
1717
|
+
n || console.warn("[kablui] Radio must be used inside RadioGroup");
|
|
1718
|
+
const l = g(() => e.disabled || !!(n != null && n.disabled.value)), o = g(() => (n == null ? void 0 : n.model.value) === e.value), s = g(() => !!(n != null && n.invalid.value));
|
|
1719
|
+
ne(() => {
|
|
1720
|
+
i.value && (n == null || n.register(i.value));
|
|
1721
|
+
}), q(() => {
|
|
1722
|
+
i.value && (n == null || n.unregister(i.value));
|
|
1723
|
+
});
|
|
1724
|
+
const c = [
|
|
1725
|
+
"size-4 shrink-0 appearance-none rounded-full border border-kablui-border bg-kablui-bg",
|
|
1726
|
+
"checked:border-kablui-accent checked:bg-kablui-accent",
|
|
1727
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-kablui-focus focus-visible:ring-offset-2 focus-visible:ring-offset-kablui-bg",
|
|
1728
|
+
"disabled:opacity-50 disabled:pointer-events-none"
|
|
1729
|
+
].join(" "), d = g(() => [
|
|
1730
|
+
c,
|
|
1731
|
+
s.value ? "border-kablui-danger" : ""
|
|
1732
|
+
]);
|
|
1733
|
+
function r() {
|
|
1734
|
+
!n || l.value || (n.model.value = e.value);
|
|
1735
|
+
}
|
|
1736
|
+
function u(m) {
|
|
1737
|
+
!n || l.value || !i.value || (m.key === "ArrowDown" || m.key === "ArrowRight" ? (m.preventDefault(), n.focusRelative(i.value, 1)) : (m.key === "ArrowUp" || m.key === "ArrowLeft") && (m.preventDefault(), n.focusRelative(i.value, -1)));
|
|
1738
|
+
}
|
|
1739
|
+
return (m, b) => {
|
|
1740
|
+
var y;
|
|
1741
|
+
return f(), p("input", Z({
|
|
1742
|
+
ref_key: "inputRef",
|
|
1743
|
+
ref: i,
|
|
1744
|
+
type: "radio",
|
|
1745
|
+
id: a.id,
|
|
1746
|
+
name: (y = v(n)) == null ? void 0 : y.name.value,
|
|
1747
|
+
value: a.value,
|
|
1748
|
+
checked: o.value,
|
|
1749
|
+
disabled: l.value,
|
|
1750
|
+
"aria-invalid": s.value ? "true" : void 0,
|
|
1751
|
+
class: d.value
|
|
1752
|
+
}, v(t), {
|
|
1753
|
+
onChange: r,
|
|
1754
|
+
onKeydown: u
|
|
1755
|
+
}), null, 16, ka);
|
|
1756
|
+
};
|
|
1757
|
+
}
|
|
1758
|
+
}), ha = ["id", "aria-invalid", "aria-describedby", "aria-orientation", "aria-disabled"], Dn = /* @__PURE__ */ x({
|
|
1759
|
+
__name: "RadioGroup",
|
|
1760
|
+
props: /* @__PURE__ */ U({
|
|
1761
|
+
name: {},
|
|
1762
|
+
disabled: { type: Boolean, default: !1 },
|
|
1763
|
+
invalid: { type: Boolean, default: !1 },
|
|
1764
|
+
orientation: { default: "vertical" },
|
|
1765
|
+
id: {}
|
|
1766
|
+
}, {
|
|
1767
|
+
modelValue: {},
|
|
1768
|
+
modelModifiers: {}
|
|
1769
|
+
}),
|
|
1770
|
+
emits: ["update:modelValue"],
|
|
1771
|
+
setup(a) {
|
|
1772
|
+
let e = 0;
|
|
1773
|
+
const t = a, n = N(a, "modelValue"), i = se({
|
|
1774
|
+
id: () => t.id,
|
|
1775
|
+
invalid: () => t.invalid
|
|
1776
|
+
}), l = `kablui-radio-${++e}`, o = g(() => t.name ?? l), s = /* @__PURE__ */ new Set();
|
|
1777
|
+
function c(b) {
|
|
1778
|
+
s.add(b);
|
|
1779
|
+
}
|
|
1780
|
+
function d(b) {
|
|
1781
|
+
s.delete(b);
|
|
1782
|
+
}
|
|
1783
|
+
function r() {
|
|
1784
|
+
return [...s].filter((b) => !b.disabled);
|
|
1785
|
+
}
|
|
1786
|
+
function u(b, y) {
|
|
1787
|
+
const A = r(), D = A.indexOf(b);
|
|
1788
|
+
if (D === -1 || A.length === 0) return;
|
|
1789
|
+
const _ = A[(D + y + A.length) % A.length];
|
|
1790
|
+
_.focus(), n.value = _.value;
|
|
1791
|
+
}
|
|
1792
|
+
G(Ue, {
|
|
1793
|
+
name: o,
|
|
1794
|
+
model: n,
|
|
1795
|
+
disabled: g(() => t.disabled),
|
|
1796
|
+
invalid: g(() => i.invalid.value),
|
|
1797
|
+
register: c,
|
|
1798
|
+
unregister: d,
|
|
1799
|
+
focusRelative: u
|
|
1800
|
+
});
|
|
1801
|
+
const m = {
|
|
1802
|
+
vertical: "flex-col gap-2",
|
|
1803
|
+
horizontal: "flex-row flex-wrap gap-3"
|
|
1804
|
+
};
|
|
1805
|
+
return (b, y) => (f(), p("div", {
|
|
1806
|
+
role: "radiogroup",
|
|
1807
|
+
id: v(i).id.value,
|
|
1808
|
+
"aria-invalid": v(i).ariaInvalid.value,
|
|
1809
|
+
"aria-describedby": v(i).describedBy.value,
|
|
1810
|
+
"aria-orientation": a.orientation,
|
|
1811
|
+
"aria-disabled": a.disabled || void 0,
|
|
1812
|
+
class: w(["flex", m[a.orientation]]),
|
|
1813
|
+
"data-slot": "radio-group"
|
|
1814
|
+
}, [
|
|
1815
|
+
C(b.$slots, "default")
|
|
1816
|
+
], 10, ha));
|
|
1817
|
+
}
|
|
1818
|
+
}), qe = Symbol("kablui-select"), ya = ["id", "disabled", "aria-expanded", "aria-invalid", "aria-describedby"], xa = { class: "truncate" }, wa = ["aria-labelledby", "aria-label", "aria-activedescendant"], _a = ["id", "aria-selected", "aria-disabled", "data-value", "onClick", "onMouseenter"], $a = ["name", "value", "disabled"], Rn = /* @__PURE__ */ x({
|
|
1819
|
+
inheritAttrs: !1,
|
|
1820
|
+
__name: "Select",
|
|
1821
|
+
props: /* @__PURE__ */ U({
|
|
1822
|
+
options: {},
|
|
1823
|
+
placeholder: { default: "Select…" },
|
|
1824
|
+
disabled: { type: Boolean, default: !1 },
|
|
1825
|
+
invalid: { type: Boolean, default: !1 },
|
|
1826
|
+
name: {},
|
|
1827
|
+
id: {},
|
|
1828
|
+
size: { default: "md" }
|
|
1829
|
+
}, {
|
|
1830
|
+
modelValue: {},
|
|
1831
|
+
modelModifiers: {}
|
|
1832
|
+
}),
|
|
1833
|
+
emits: ["update:modelValue"],
|
|
1834
|
+
setup(a) {
|
|
1835
|
+
const e = a, t = N(a, "modelValue"), n = X(), i = se({
|
|
1836
|
+
id: () => e.id,
|
|
1837
|
+
invalid: () => e.invalid
|
|
1838
|
+
}), l = R(!1), o = R(), s = R(null), c = R(null), d = R(null), r = `kablui-listbox-${Math.random().toString(36).slice(2, 9)}`, u = R([]);
|
|
1839
|
+
let m = "", b = null;
|
|
1840
|
+
const y = g(
|
|
1841
|
+
() => (e.options ?? []).map((k) => ({
|
|
1842
|
+
value: k.value,
|
|
1843
|
+
label: k.label,
|
|
1844
|
+
disabled: k.disabled,
|
|
1845
|
+
id: `${r}-option-${k.value}`
|
|
1846
|
+
}))
|
|
1847
|
+
), A = g(() => y.value.length > 0 ? y.value : u.value), D = g(() => A.value.filter((k) => !k.disabled)), _ = g(
|
|
1848
|
+
() => A.value.find((k) => k.value === t.value)
|
|
1849
|
+
), $ = g(() => {
|
|
1850
|
+
var k;
|
|
1851
|
+
return ((k = _.value) == null ? void 0 : k.label) ?? "";
|
|
1852
|
+
}), h = g(() => {
|
|
1853
|
+
var k;
|
|
1854
|
+
if (!(!l.value || !o.value))
|
|
1855
|
+
return (k = A.value.find((T) => T.value === o.value)) == null ? void 0 : k.id;
|
|
1856
|
+
});
|
|
1857
|
+
function I(k) {
|
|
1858
|
+
const T = [...u.value], B = T.findIndex((L) => L.value === k.value);
|
|
1859
|
+
B === -1 ? T.push(k) : T[B] = k, u.value = T;
|
|
1860
|
+
}
|
|
1861
|
+
function E(k) {
|
|
1862
|
+
u.value = u.value.filter((T) => T.value !== k);
|
|
1863
|
+
}
|
|
1864
|
+
function M(k, T) {
|
|
1865
|
+
const B = u.value.findIndex((nt) => nt.value === k);
|
|
1866
|
+
if (B === -1) return;
|
|
1867
|
+
const L = u.value[B], W = T.label || L.label || T.value;
|
|
1868
|
+
if (L.label === W && L.disabled === T.disabled && L.id === T.id)
|
|
1869
|
+
return;
|
|
1870
|
+
const be = [...u.value];
|
|
1871
|
+
be[B] = { ...T, label: W }, u.value = be;
|
|
1872
|
+
}
|
|
1873
|
+
function F(k) {
|
|
1874
|
+
o.value = k;
|
|
1875
|
+
}
|
|
1876
|
+
function le(k) {
|
|
1877
|
+
const T = A.value.find((B) => B.value === k);
|
|
1878
|
+
!T || T.disabled || (t.value = k, l.value = !1, o.value = k, Q(() => {
|
|
1879
|
+
var B;
|
|
1880
|
+
return (B = d.value) == null ? void 0 : B.focus();
|
|
1881
|
+
}));
|
|
1882
|
+
}
|
|
1883
|
+
function Ge() {
|
|
1884
|
+
var T;
|
|
1885
|
+
const k = t.value;
|
|
1886
|
+
return k && D.value.some((B) => B.value === k) ? k : (T = D.value[0]) == null ? void 0 : T.value;
|
|
1887
|
+
}
|
|
1888
|
+
function oe() {
|
|
1889
|
+
e.disabled || (l.value = !0, o.value = Ge(), Q(() => {
|
|
1890
|
+
var k;
|
|
1891
|
+
(k = c.value) == null || k.focus();
|
|
1892
|
+
}));
|
|
1893
|
+
}
|
|
1894
|
+
function Ee() {
|
|
1895
|
+
l.value = !1, Q(() => {
|
|
1896
|
+
var k;
|
|
1897
|
+
return (k = d.value) == null ? void 0 : k.focus();
|
|
1898
|
+
});
|
|
1899
|
+
}
|
|
1900
|
+
function We() {
|
|
1901
|
+
l.value ? Ee() : oe();
|
|
1902
|
+
}
|
|
1903
|
+
function Ae(k) {
|
|
1904
|
+
const T = D.value;
|
|
1905
|
+
if (T.length === 0) return;
|
|
1906
|
+
const B = T.findIndex((be) => be.value === o.value), W = ((B === -1 ? k > 0 ? -1 : 0 : B) + k + T.length) % T.length;
|
|
1907
|
+
o.value = T[W].value;
|
|
1908
|
+
}
|
|
1909
|
+
function De(k) {
|
|
1910
|
+
const T = D.value;
|
|
1911
|
+
T.length !== 0 && (o.value = k === "start" ? T[0].value : T[T.length - 1].value);
|
|
1912
|
+
}
|
|
1913
|
+
function Je(k) {
|
|
1914
|
+
m += k.toLowerCase(), b && clearTimeout(b), b = setTimeout(() => {
|
|
1915
|
+
m = "";
|
|
1916
|
+
}, 500);
|
|
1917
|
+
const T = D.value, B = Math.max(
|
|
1918
|
+
0,
|
|
1919
|
+
T.findIndex((L) => L.value === o.value)
|
|
1920
|
+
);
|
|
1921
|
+
for (let L = 0; L < T.length; L++) {
|
|
1922
|
+
const W = T[(B + L) % T.length];
|
|
1923
|
+
if (W.label.toLowerCase().startsWith(m)) {
|
|
1924
|
+
o.value = W.value, l.value || (t.value = W.value);
|
|
1925
|
+
return;
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
function Re(k) {
|
|
1930
|
+
if (!e.disabled)
|
|
1931
|
+
switch (k.key) {
|
|
1932
|
+
case "ArrowDown":
|
|
1933
|
+
k.preventDefault(), l.value ? Ae(1) : oe();
|
|
1934
|
+
break;
|
|
1935
|
+
case "ArrowUp":
|
|
1936
|
+
k.preventDefault(), l.value ? Ae(-1) : oe();
|
|
1937
|
+
break;
|
|
1938
|
+
case "Home":
|
|
1939
|
+
l.value && (k.preventDefault(), De("start"));
|
|
1940
|
+
break;
|
|
1941
|
+
case "End":
|
|
1942
|
+
l.value && (k.preventDefault(), De("end"));
|
|
1943
|
+
break;
|
|
1944
|
+
case "Enter":
|
|
1945
|
+
case " ":
|
|
1946
|
+
k.preventDefault(), l.value ? o.value && le(o.value) : oe();
|
|
1947
|
+
break;
|
|
1948
|
+
case "Escape":
|
|
1949
|
+
l.value && (k.preventDefault(), Ee());
|
|
1950
|
+
break;
|
|
1951
|
+
default:
|
|
1952
|
+
k.key.length === 1 && !k.ctrlKey && !k.metaKey && !k.altKey && (k.preventDefault(), l.value || oe(), Je(k.key));
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
function Qe(k) {
|
|
1956
|
+
Re(k);
|
|
1957
|
+
}
|
|
1958
|
+
function Be(k) {
|
|
1959
|
+
if (!l.value || !s.value) return;
|
|
1960
|
+
const T = k.target;
|
|
1961
|
+
s.value.contains(T) || (l.value = !1);
|
|
1962
|
+
}
|
|
1963
|
+
ne(() => {
|
|
1964
|
+
document.addEventListener("pointerdown", Be);
|
|
1965
|
+
}), q(() => {
|
|
1966
|
+
document.removeEventListener("pointerdown", Be), b && clearTimeout(b);
|
|
1967
|
+
}), G(qe, {
|
|
1968
|
+
listboxId: r,
|
|
1969
|
+
model: t,
|
|
1970
|
+
activeValue: o,
|
|
1971
|
+
open: l,
|
|
1972
|
+
register: I,
|
|
1973
|
+
unregister: E,
|
|
1974
|
+
update: M,
|
|
1975
|
+
selectValue: le,
|
|
1976
|
+
setActiveValue: F,
|
|
1977
|
+
disabled: g(() => e.disabled)
|
|
1978
|
+
});
|
|
1979
|
+
const Xe = [
|
|
1980
|
+
"inline-flex w-full items-center justify-between gap-2 border border-kablui-border bg-kablui-bg text-kablui-fg",
|
|
1981
|
+
"rounded-kablui-md font-kablui-normal",
|
|
1982
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-kablui-focus focus-visible:ring-offset-2 focus-visible:ring-offset-kablui-bg",
|
|
1983
|
+
"disabled:opacity-50 disabled:pointer-events-none"
|
|
1984
|
+
].join(" "), Ze = {
|
|
1985
|
+
sm: "text-kablui-sm px-2 py-1",
|
|
1986
|
+
md: "text-kablui-md px-3 py-1.5",
|
|
1987
|
+
lg: "text-kablui-lg px-4 py-2"
|
|
1988
|
+
}, et = g(() => [
|
|
1989
|
+
Xe,
|
|
1990
|
+
Ze[e.size],
|
|
1991
|
+
i.invalid.value ? "border-kablui-danger" : "",
|
|
1992
|
+
$.value ? "" : "text-kablui-muted-fg"
|
|
1993
|
+
]), tt = g(() => i.id.value), at = g(
|
|
1994
|
+
() => i.id.value ? void 0 : e.placeholder
|
|
1995
|
+
);
|
|
1996
|
+
return (k, T) => (f(), p("div", {
|
|
1997
|
+
ref_key: "rootRef",
|
|
1998
|
+
ref: s,
|
|
1999
|
+
class: "relative w-full",
|
|
2000
|
+
"data-slot": "select"
|
|
2001
|
+
}, [
|
|
2002
|
+
j("button", Z({
|
|
2003
|
+
ref_key: "triggerRef",
|
|
2004
|
+
ref: d,
|
|
2005
|
+
type: "button",
|
|
2006
|
+
id: v(i).id.value,
|
|
2007
|
+
disabled: a.disabled,
|
|
2008
|
+
"aria-haspopup": "listbox",
|
|
2009
|
+
"aria-expanded": l.value ? "true" : "false",
|
|
2010
|
+
"aria-controls": r,
|
|
2011
|
+
"aria-invalid": v(i).ariaInvalid.value,
|
|
2012
|
+
"aria-describedby": v(i).describedBy.value,
|
|
2013
|
+
class: et.value
|
|
2014
|
+
}, v(n), {
|
|
2015
|
+
onClick: We,
|
|
2016
|
+
onKeydown: Re
|
|
2017
|
+
}), [
|
|
2018
|
+
j("span", xa, H($.value || a.placeholder), 1),
|
|
2019
|
+
T[0] || (T[0] = j("svg", {
|
|
2020
|
+
class: "size-4 shrink-0 text-kablui-muted-fg",
|
|
2021
|
+
viewBox: "0 0 24 24",
|
|
2022
|
+
fill: "none",
|
|
2023
|
+
stroke: "currentColor",
|
|
2024
|
+
"stroke-width": "2",
|
|
2025
|
+
"aria-hidden": "true"
|
|
2026
|
+
}, [
|
|
2027
|
+
j("path", { d: "M6 9l6 6 6-6" })
|
|
2028
|
+
], -1))
|
|
2029
|
+
], 16, ya),
|
|
2030
|
+
Oe(j("div", {
|
|
2031
|
+
id: r,
|
|
2032
|
+
ref_key: "listboxRef",
|
|
2033
|
+
ref: c,
|
|
2034
|
+
role: "listbox",
|
|
2035
|
+
tabindex: "-1",
|
|
2036
|
+
"aria-labelledby": tt.value,
|
|
2037
|
+
"aria-label": at.value,
|
|
2038
|
+
"aria-activedescendant": h.value,
|
|
2039
|
+
class: "absolute z-10 mt-1 max-h-60 w-full overflow-auto rounded-kablui-md border border-kablui-border bg-kablui-bg p-1 shadow-kablui-sm",
|
|
2040
|
+
onKeydown: Qe
|
|
2041
|
+
}, [
|
|
2042
|
+
y.value.length ? (f(!0), p(ee, { key: 0 }, we(y.value, (B) => (f(), p("div", {
|
|
2043
|
+
id: B.id,
|
|
2044
|
+
key: B.value,
|
|
2045
|
+
role: "option",
|
|
2046
|
+
"aria-selected": t.value === B.value ? "true" : "false",
|
|
2047
|
+
"aria-disabled": B.disabled || void 0,
|
|
2048
|
+
"data-value": B.value,
|
|
2049
|
+
class: w([
|
|
2050
|
+
"flex w-full cursor-pointer items-center px-3 py-1.5 text-kablui-md text-kablui-fg rounded-kablui-sm",
|
|
2051
|
+
o.value === B.value ? "bg-kablui-muted" : "",
|
|
2052
|
+
t.value === B.value ? "font-kablui-medium" : "",
|
|
2053
|
+
B.disabled ? "opacity-50 pointer-events-none" : "hover:bg-kablui-muted"
|
|
2054
|
+
]),
|
|
2055
|
+
onClick: (L) => le(B.value),
|
|
2056
|
+
onMouseenter: (L) => !B.disabled && F(B.value)
|
|
2057
|
+
}, H(B.label), 43, _a))), 128)) : C(k.$slots, "default", {}, void 0, void 0, 1)
|
|
2058
|
+
], 40, wa), [
|
|
2059
|
+
[Pe, l.value]
|
|
2060
|
+
]),
|
|
2061
|
+
a.name ? (f(), p("input", {
|
|
2062
|
+
key: 0,
|
|
2063
|
+
type: "hidden",
|
|
2064
|
+
name: a.name,
|
|
2065
|
+
value: t.value ?? "",
|
|
2066
|
+
disabled: a.disabled
|
|
2067
|
+
}, null, 8, $a)) : z("", !0)
|
|
2068
|
+
], 512));
|
|
2069
|
+
}
|
|
2070
|
+
}), Ca = ["id", "aria-selected", "aria-disabled", "data-value"], Bn = /* @__PURE__ */ x({
|
|
2071
|
+
__name: "SelectItem",
|
|
2072
|
+
props: {
|
|
2073
|
+
value: {},
|
|
2074
|
+
disabled: { type: Boolean, default: !1 },
|
|
2075
|
+
label: {}
|
|
2076
|
+
},
|
|
2077
|
+
setup(a) {
|
|
2078
|
+
const e = a, t = S(qe, null), n = R(null);
|
|
2079
|
+
t || console.warn("[kablui] SelectItem must be used inside Select");
|
|
2080
|
+
const i = g(() => t ? `${t.listboxId}-option-${e.value}` : void 0);
|
|
2081
|
+
function l() {
|
|
2082
|
+
var u, m;
|
|
2083
|
+
return e.label || ((m = (u = n.value) == null ? void 0 : u.textContent) == null ? void 0 : m.trim()) || e.value;
|
|
2084
|
+
}
|
|
2085
|
+
function o() {
|
|
2086
|
+
return {
|
|
2087
|
+
value: e.value,
|
|
2088
|
+
label: l(),
|
|
2089
|
+
disabled: e.disabled,
|
|
2090
|
+
id: i.value ?? e.value
|
|
2091
|
+
};
|
|
2092
|
+
}
|
|
2093
|
+
ne(() => {
|
|
2094
|
+
t == null || t.register(o());
|
|
2095
|
+
}), lt(() => {
|
|
2096
|
+
t == null || t.update(e.value, o());
|
|
2097
|
+
}), q(() => {
|
|
2098
|
+
t == null || t.unregister(e.value);
|
|
2099
|
+
});
|
|
2100
|
+
const s = g(() => (t == null ? void 0 : t.model.value) === e.value), c = g(() => (t == null ? void 0 : t.activeValue.value) === e.value), d = g(
|
|
2101
|
+
() => [
|
|
2102
|
+
"flex w-full cursor-pointer items-center px-3 py-1.5 text-kablui-md text-kablui-fg",
|
|
2103
|
+
"rounded-kablui-sm",
|
|
2104
|
+
c.value ? "bg-kablui-muted" : "",
|
|
2105
|
+
s.value ? "font-kablui-medium" : "",
|
|
2106
|
+
e.disabled ? "opacity-50 pointer-events-none" : "hover:bg-kablui-muted"
|
|
2107
|
+
].join(" ")
|
|
2108
|
+
);
|
|
2109
|
+
function r() {
|
|
2110
|
+
e.disabled || t == null || t.selectValue(e.value);
|
|
2111
|
+
}
|
|
2112
|
+
return (u, m) => (f(), p("div", {
|
|
2113
|
+
ref_key: "rootRef",
|
|
2114
|
+
ref: n,
|
|
2115
|
+
id: i.value,
|
|
2116
|
+
role: "option",
|
|
2117
|
+
"aria-selected": s.value ? "true" : "false",
|
|
2118
|
+
"aria-disabled": a.disabled || void 0,
|
|
2119
|
+
"data-value": a.value,
|
|
2120
|
+
class: w(d.value),
|
|
2121
|
+
onClick: r,
|
|
2122
|
+
onMouseenter: m[0] || (m[0] = (b) => {
|
|
2123
|
+
var y;
|
|
2124
|
+
return !a.disabled && ((y = v(t)) == null ? void 0 : y.setActiveValue(a.value));
|
|
2125
|
+
})
|
|
2126
|
+
}, [
|
|
2127
|
+
C(u.$slots, "default", {}, () => [
|
|
2128
|
+
re(H(a.value), 1)
|
|
2129
|
+
])
|
|
2130
|
+
], 42, Ca));
|
|
2131
|
+
}
|
|
2132
|
+
}), Ia = ["role", "aria-hidden", "aria-orientation"], Ta = "shrink-0 border-0 border-solid", Mn = /* @__PURE__ */ x({
|
|
2133
|
+
__name: "Separator",
|
|
2134
|
+
props: {
|
|
2135
|
+
orientation: { default: "horizontal" },
|
|
2136
|
+
semantic: { type: Boolean, default: !1 }
|
|
2137
|
+
},
|
|
2138
|
+
setup(a) {
|
|
2139
|
+
const e = {
|
|
2140
|
+
decorative: "border-kablui-border",
|
|
2141
|
+
semantic: "border-kablui-border-strong"
|
|
2142
|
+
}, t = {
|
|
2143
|
+
horizontal: "w-full border-t",
|
|
2144
|
+
vertical: "h-full border-l"
|
|
2145
|
+
};
|
|
2146
|
+
return (n, i) => (f(), p("div", {
|
|
2147
|
+
role: a.semantic ? "separator" : void 0,
|
|
2148
|
+
"aria-hidden": a.semantic ? void 0 : !0,
|
|
2149
|
+
"aria-orientation": a.semantic && a.orientation === "vertical" ? "vertical" : void 0,
|
|
2150
|
+
class: w([
|
|
2151
|
+
Ta,
|
|
2152
|
+
e[a.semantic ? "semantic" : "decorative"],
|
|
2153
|
+
t[a.orientation]
|
|
2154
|
+
])
|
|
2155
|
+
}, null, 10, Ia));
|
|
2156
|
+
}
|
|
2157
|
+
}), Ea = "block bg-kablui-muted", zn = /* @__PURE__ */ x({
|
|
2158
|
+
__name: "Skeleton",
|
|
2159
|
+
props: {
|
|
2160
|
+
width: {},
|
|
2161
|
+
height: {},
|
|
2162
|
+
circle: { type: Boolean, default: !1 },
|
|
2163
|
+
animated: { type: Boolean, default: !0 }
|
|
2164
|
+
},
|
|
2165
|
+
setup(a) {
|
|
2166
|
+
const e = {
|
|
2167
|
+
rect: "rounded-kablui-md",
|
|
2168
|
+
circle: "rounded-kablui-full"
|
|
2169
|
+
};
|
|
2170
|
+
return (t, n) => (f(), p("div", {
|
|
2171
|
+
"aria-hidden": "true",
|
|
2172
|
+
class: w([
|
|
2173
|
+
Ea,
|
|
2174
|
+
e[a.circle ? "circle" : "rect"],
|
|
2175
|
+
a.animated ? "animate-pulse" : void 0
|
|
2176
|
+
]),
|
|
2177
|
+
style: ce({
|
|
2178
|
+
width: a.width ?? (a.circle ? "2.5rem" : "100%"),
|
|
2179
|
+
height: a.height ?? (a.circle ? "2.5rem" : "1rem")
|
|
2180
|
+
})
|
|
2181
|
+
}, null, 6));
|
|
2182
|
+
}
|
|
2183
|
+
}), Aa = ["aria-busy", "aria-label"], Da = {
|
|
2184
|
+
key: 0,
|
|
2185
|
+
class: "sr-only"
|
|
2186
|
+
}, jn = /* @__PURE__ */ x({
|
|
2187
|
+
__name: "Spinner",
|
|
2188
|
+
props: {
|
|
2189
|
+
size: { default: "md" },
|
|
2190
|
+
label: {}
|
|
2191
|
+
},
|
|
2192
|
+
setup(a) {
|
|
2193
|
+
const e = [
|
|
2194
|
+
"inline-block shrink-0 rounded-kablui-full border-2 border-current border-t-transparent",
|
|
2195
|
+
"animate-spin"
|
|
2196
|
+
].join(" "), t = {
|
|
2197
|
+
sm: "size-3",
|
|
2198
|
+
md: "size-4",
|
|
2199
|
+
lg: "size-5"
|
|
2200
|
+
};
|
|
2201
|
+
return (n, i) => (f(), p("span", {
|
|
2202
|
+
role: "status",
|
|
2203
|
+
"aria-busy": a.label ? !0 : void 0,
|
|
2204
|
+
"aria-label": a.label || void 0,
|
|
2205
|
+
class: "inline-flex items-center"
|
|
2206
|
+
}, [
|
|
2207
|
+
j("span", {
|
|
2208
|
+
class: w([v(e), t[a.size]]),
|
|
2209
|
+
"aria-hidden": "true"
|
|
2210
|
+
}, null, 2),
|
|
2211
|
+
a.label ? (f(), p("span", Da, H(a.label), 1)) : z("", !0)
|
|
2212
|
+
], 8, Aa));
|
|
2213
|
+
}
|
|
2214
|
+
}), Ra = /* @__PURE__ */ x({
|
|
2215
|
+
__name: "Stack",
|
|
2216
|
+
props: {
|
|
2217
|
+
gap: { default: "md" },
|
|
2218
|
+
align: { default: "stretch" },
|
|
2219
|
+
as: { default: "div" }
|
|
2220
|
+
},
|
|
2221
|
+
setup(a) {
|
|
2222
|
+
const e = {
|
|
2223
|
+
sm: "gap-2",
|
|
2224
|
+
md: "gap-4",
|
|
2225
|
+
lg: "gap-6"
|
|
2226
|
+
}, t = {
|
|
2227
|
+
start: "items-start",
|
|
2228
|
+
center: "items-center",
|
|
2229
|
+
end: "items-end",
|
|
2230
|
+
stretch: "items-stretch",
|
|
2231
|
+
baseline: "items-baseline"
|
|
2232
|
+
};
|
|
2233
|
+
return (n, i) => (f(), V(ae(a.as), {
|
|
2234
|
+
class: w(["flex flex-col", e[a.gap], t[a.align]])
|
|
2235
|
+
}, {
|
|
2236
|
+
default: Y(() => [
|
|
2237
|
+
C(n.$slots, "default")
|
|
2238
|
+
]),
|
|
2239
|
+
_: 3
|
|
2240
|
+
}, 8, ["class"]));
|
|
2241
|
+
}
|
|
2242
|
+
}), Ba = ["id", "disabled", "aria-checked", "aria-invalid", "aria-describedby"], Ma = ["name", "value", "disabled"], Sn = /* @__PURE__ */ x({
|
|
2243
|
+
inheritAttrs: !1,
|
|
2244
|
+
__name: "Switch",
|
|
2245
|
+
props: /* @__PURE__ */ U({
|
|
2246
|
+
disabled: { type: Boolean, default: !1 },
|
|
2247
|
+
invalid: { type: Boolean, default: !1 },
|
|
2248
|
+
name: {},
|
|
2249
|
+
id: {},
|
|
2250
|
+
value: { default: "on" }
|
|
2251
|
+
}, {
|
|
2252
|
+
modelValue: { type: Boolean, default: !1 },
|
|
2253
|
+
modelModifiers: {}
|
|
2254
|
+
}),
|
|
2255
|
+
emits: ["update:modelValue"],
|
|
2256
|
+
setup(a) {
|
|
2257
|
+
const e = a, t = N(a, "modelValue"), n = X(), i = se({
|
|
2258
|
+
id: () => e.id,
|
|
2259
|
+
invalid: () => e.invalid
|
|
2260
|
+
}), l = g(
|
|
2261
|
+
() => [
|
|
2262
|
+
"relative inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border border-kablui-border",
|
|
2263
|
+
"transition-colors",
|
|
2264
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-kablui-focus focus-visible:ring-offset-2 focus-visible:ring-offset-kablui-bg",
|
|
2265
|
+
"disabled:cursor-not-allowed disabled:opacity-50 disabled:pointer-events-none",
|
|
2266
|
+
t.value ? "bg-kablui-accent border-kablui-accent" : "bg-kablui-muted",
|
|
2267
|
+
i.invalid.value ? "border-kablui-danger" : ""
|
|
2268
|
+
].join(" ")
|
|
2269
|
+
), o = g(
|
|
2270
|
+
() => [
|
|
2271
|
+
"pointer-events-none inline-block size-3.5 rounded-full bg-kablui-bg shadow-kablui-sm",
|
|
2272
|
+
"transition-transform",
|
|
2273
|
+
t.value ? "translate-x-4" : "translate-x-0.5"
|
|
2274
|
+
].join(" ")
|
|
2275
|
+
);
|
|
2276
|
+
function s() {
|
|
2277
|
+
e.disabled || (t.value = !t.value);
|
|
2278
|
+
}
|
|
2279
|
+
function c(d) {
|
|
2280
|
+
(d.key === " " || d.key === "Enter") && (d.preventDefault(), s());
|
|
2281
|
+
}
|
|
2282
|
+
return (d, r) => (f(), p(ee, null, [
|
|
2283
|
+
j("button", Z({
|
|
2284
|
+
type: "button",
|
|
2285
|
+
role: "switch",
|
|
2286
|
+
id: v(i).id.value,
|
|
2287
|
+
disabled: a.disabled,
|
|
2288
|
+
"aria-checked": t.value ? "true" : "false",
|
|
2289
|
+
"aria-invalid": v(i).ariaInvalid.value,
|
|
2290
|
+
"aria-describedby": v(i).describedBy.value,
|
|
2291
|
+
class: l.value
|
|
2292
|
+
}, v(n), {
|
|
2293
|
+
onClick: s,
|
|
2294
|
+
onKeydown: c
|
|
2295
|
+
}), [
|
|
2296
|
+
j("span", {
|
|
2297
|
+
class: w(o.value),
|
|
2298
|
+
"aria-hidden": "true"
|
|
2299
|
+
}, null, 2)
|
|
2300
|
+
], 16, Ba),
|
|
2301
|
+
a.name ? (f(), p("input", {
|
|
2302
|
+
key: 0,
|
|
2303
|
+
type: "hidden",
|
|
2304
|
+
name: a.name,
|
|
2305
|
+
value: t.value ? a.value : "",
|
|
2306
|
+
disabled: a.disabled
|
|
2307
|
+
}, null, 8, Ma)) : z("", !0)
|
|
2308
|
+
], 64));
|
|
2309
|
+
}
|
|
2310
|
+
}), ge = Symbol("kablui-tabs"), za = ["id", "disabled", "aria-selected", "aria-controls", "tabindex"], Ln = /* @__PURE__ */ x({
|
|
2311
|
+
__name: "Tab",
|
|
2312
|
+
props: {
|
|
2313
|
+
value: {},
|
|
2314
|
+
disabled: { type: Boolean, default: !1 }
|
|
2315
|
+
},
|
|
2316
|
+
setup(a) {
|
|
2317
|
+
const e = a, t = S(ge, null), n = R(null);
|
|
2318
|
+
t || console.warn("[kablui] Tab must be used inside Tabs");
|
|
2319
|
+
const i = g(() => !!(t != null && t.isSelected(e.value))), l = g(() => t == null ? void 0 : t.getTabId(e.value)), o = g(() => t == null ? void 0 : t.getPanelId(e.value)), s = g(() => (t == null ? void 0 : t.orientation.value) ?? "horizontal"), c = g(() => t != null && t.isTabbable(e.value) ? 0 : -1);
|
|
2320
|
+
ne(() => {
|
|
2321
|
+
!t || !n.value || t.registerTab({
|
|
2322
|
+
value: e.value,
|
|
2323
|
+
disabled: e.disabled,
|
|
2324
|
+
el: n.value
|
|
2325
|
+
});
|
|
2326
|
+
}), q(() => {
|
|
2327
|
+
t == null || t.unregisterTab(e.value);
|
|
2328
|
+
}), K(
|
|
2329
|
+
() => e.disabled,
|
|
2330
|
+
(b) => {
|
|
2331
|
+
t == null || t.updateTab(e.value, { disabled: b });
|
|
2332
|
+
}
|
|
2333
|
+
), K(n, (b) => {
|
|
2334
|
+
!t || !b || t.updateTab(e.value, { el: b, disabled: e.disabled });
|
|
2335
|
+
});
|
|
2336
|
+
function d() {
|
|
2337
|
+
var b;
|
|
2338
|
+
!t || e.disabled || (t.select(e.value), (b = n.value) == null || b.focus());
|
|
2339
|
+
}
|
|
2340
|
+
function r(b) {
|
|
2341
|
+
if (!t || e.disabled) return;
|
|
2342
|
+
const y = s.value === "horizontal", A = s.value === "vertical";
|
|
2343
|
+
switch (b.key) {
|
|
2344
|
+
case "ArrowRight":
|
|
2345
|
+
if (!y) return;
|
|
2346
|
+
b.preventDefault(), t.focusRelative(e.value, 1);
|
|
2347
|
+
break;
|
|
2348
|
+
case "ArrowLeft":
|
|
2349
|
+
if (!y) return;
|
|
2350
|
+
b.preventDefault(), t.focusRelative(e.value, -1);
|
|
2351
|
+
break;
|
|
2352
|
+
case "ArrowDown":
|
|
2353
|
+
if (!A) return;
|
|
2354
|
+
b.preventDefault(), t.focusRelative(e.value, 1);
|
|
2355
|
+
break;
|
|
2356
|
+
case "ArrowUp":
|
|
2357
|
+
if (!A) return;
|
|
2358
|
+
b.preventDefault(), t.focusRelative(e.value, -1);
|
|
2359
|
+
break;
|
|
2360
|
+
case "Home":
|
|
2361
|
+
b.preventDefault(), t.focusFirst();
|
|
2362
|
+
break;
|
|
2363
|
+
case "End":
|
|
2364
|
+
b.preventDefault(), t.focusLast();
|
|
2365
|
+
break;
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
const u = [
|
|
2369
|
+
"inline-flex items-center justify-center gap-1.5",
|
|
2370
|
+
"px-3 py-2 text-kablui-md font-kablui-medium",
|
|
2371
|
+
"text-kablui-muted-fg bg-transparent",
|
|
2372
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-kablui-focus focus-visible:ring-offset-2 focus-visible:ring-offset-kablui-bg",
|
|
2373
|
+
"disabled:opacity-50 disabled:pointer-events-none"
|
|
2374
|
+
].join(" "), m = g(() => i.value ? s.value === "horizontal" ? "border-b-2 border-kablui-accent text-kablui-accent" : "border-r-2 border-kablui-accent text-kablui-accent" : s.value === "horizontal" ? "border-b-2 border-transparent hover:text-kablui-fg" : "border-r-2 border-transparent hover:text-kablui-fg");
|
|
2375
|
+
return (b, y) => (f(), p("button", {
|
|
2376
|
+
ref_key: "buttonRef",
|
|
2377
|
+
ref: n,
|
|
2378
|
+
type: "button",
|
|
2379
|
+
role: "tab",
|
|
2380
|
+
"data-slot": "tab",
|
|
2381
|
+
id: l.value,
|
|
2382
|
+
disabled: a.disabled || void 0,
|
|
2383
|
+
"aria-selected": i.value ? "true" : "false",
|
|
2384
|
+
"aria-controls": o.value,
|
|
2385
|
+
tabindex: c.value,
|
|
2386
|
+
class: w([v(u), m.value]),
|
|
2387
|
+
onClick: d,
|
|
2388
|
+
onKeydown: r
|
|
2389
|
+
}, [
|
|
2390
|
+
C(b.$slots, "default")
|
|
2391
|
+
], 42, za));
|
|
2392
|
+
}
|
|
2393
|
+
}), ja = ["aria-orientation"], On = /* @__PURE__ */ x({
|
|
2394
|
+
__name: "TabList",
|
|
2395
|
+
setup(a) {
|
|
2396
|
+
const e = S(ge, null);
|
|
2397
|
+
e || console.warn("[kablui] TabList must be used inside Tabs");
|
|
2398
|
+
const t = g(() => (e == null ? void 0 : e.orientation.value) ?? "horizontal"), n = {
|
|
2399
|
+
horizontal: "flex-row border-b border-kablui-border",
|
|
2400
|
+
vertical: "flex-col border-r border-kablui-border"
|
|
2401
|
+
};
|
|
2402
|
+
return (i, l) => (f(), p("div", {
|
|
2403
|
+
role: "tablist",
|
|
2404
|
+
"data-slot": "tab-list",
|
|
2405
|
+
"aria-orientation": t.value,
|
|
2406
|
+
class: w(["flex", n[t.value]])
|
|
2407
|
+
}, [
|
|
2408
|
+
C(i.$slots, "default")
|
|
2409
|
+
], 10, ja));
|
|
2410
|
+
}
|
|
2411
|
+
}), Sa = ["id", "aria-labelledby", "hidden", "tabindex"], Pn = /* @__PURE__ */ x({
|
|
2412
|
+
__name: "TabPanel",
|
|
2413
|
+
props: {
|
|
2414
|
+
value: {}
|
|
2415
|
+
},
|
|
2416
|
+
setup(a) {
|
|
2417
|
+
const e = a, t = S(ge, null);
|
|
2418
|
+
t || console.warn("[kablui] TabPanel must be used inside Tabs");
|
|
2419
|
+
const n = g(() => !!(t != null && t.isSelected(e.value))), i = g(() => t == null ? void 0 : t.getPanelId(e.value)), l = g(() => t == null ? void 0 : t.getTabId(e.value));
|
|
2420
|
+
return (o, s) => (f(), p("div", {
|
|
2421
|
+
role: "tabpanel",
|
|
2422
|
+
"data-slot": "tab-panel",
|
|
2423
|
+
id: i.value,
|
|
2424
|
+
"aria-labelledby": l.value,
|
|
2425
|
+
hidden: !n.value,
|
|
2426
|
+
tabindex: n.value ? 0 : void 0,
|
|
2427
|
+
class: "px-1 py-3 text-kablui-md text-kablui-fg"
|
|
2428
|
+
}, [
|
|
2429
|
+
C(o.$slots, "default")
|
|
2430
|
+
], 8, Sa));
|
|
2431
|
+
}
|
|
2432
|
+
}), La = ["data-orientation"], Vn = /* @__PURE__ */ x({
|
|
2433
|
+
__name: "Tabs",
|
|
2434
|
+
props: /* @__PURE__ */ U({
|
|
2435
|
+
orientation: { default: "horizontal" }
|
|
2436
|
+
}, {
|
|
2437
|
+
modelValue: {},
|
|
2438
|
+
modelModifiers: {}
|
|
2439
|
+
}),
|
|
2440
|
+
emits: ["update:modelValue"],
|
|
2441
|
+
setup(a) {
|
|
2442
|
+
const e = a, t = N(a, "modelValue"), n = P("tabs"), i = R([]);
|
|
2443
|
+
function l(h) {
|
|
2444
|
+
return `${n}-tab-${h}`;
|
|
2445
|
+
}
|
|
2446
|
+
function o(h) {
|
|
2447
|
+
return `${n}-panel-${h}`;
|
|
2448
|
+
}
|
|
2449
|
+
function s(h) {
|
|
2450
|
+
const I = [...i.value], E = I.findIndex((M) => M.value === h.value);
|
|
2451
|
+
E === -1 ? I.push(h) : I[E] = h, i.value = I;
|
|
2452
|
+
}
|
|
2453
|
+
function c(h) {
|
|
2454
|
+
i.value = i.value.filter((I) => I.value !== h);
|
|
2455
|
+
}
|
|
2456
|
+
function d(h, I) {
|
|
2457
|
+
const E = [...i.value], M = E.findIndex((F) => F.value === h);
|
|
2458
|
+
M !== -1 && (E[M] = { ...E[M], ...I, value: h }, i.value = E);
|
|
2459
|
+
}
|
|
2460
|
+
function r() {
|
|
2461
|
+
return i.value.filter((h) => !h.disabled);
|
|
2462
|
+
}
|
|
2463
|
+
function u(h) {
|
|
2464
|
+
return t.value === h;
|
|
2465
|
+
}
|
|
2466
|
+
function m(h) {
|
|
2467
|
+
const I = i.value.find((M) => M.value === h);
|
|
2468
|
+
if (!I || I.disabled) return !1;
|
|
2469
|
+
if (t.value != null) return t.value === h;
|
|
2470
|
+
const E = r()[0];
|
|
2471
|
+
return (E == null ? void 0 : E.value) === h;
|
|
2472
|
+
}
|
|
2473
|
+
function b(h) {
|
|
2474
|
+
const I = i.value.find((E) => E.value === h);
|
|
2475
|
+
!I || I.disabled || (t.value = h);
|
|
2476
|
+
}
|
|
2477
|
+
function y(h) {
|
|
2478
|
+
t.value = h.value, h.el.focus();
|
|
2479
|
+
}
|
|
2480
|
+
function A(h, I) {
|
|
2481
|
+
const E = r(), M = E.findIndex((le) => le.value === h);
|
|
2482
|
+
if (M === -1 || E.length === 0) return;
|
|
2483
|
+
const F = E[(M + I + E.length) % E.length];
|
|
2484
|
+
y(F);
|
|
2485
|
+
}
|
|
2486
|
+
function D() {
|
|
2487
|
+
const h = r();
|
|
2488
|
+
h.length !== 0 && y(h[0]);
|
|
2489
|
+
}
|
|
2490
|
+
function _() {
|
|
2491
|
+
const h = r();
|
|
2492
|
+
h.length !== 0 && y(h[h.length - 1]);
|
|
2493
|
+
}
|
|
2494
|
+
G(ge, {
|
|
2495
|
+
model: t,
|
|
2496
|
+
orientation: g(() => e.orientation),
|
|
2497
|
+
registerTab: s,
|
|
2498
|
+
unregisterTab: c,
|
|
2499
|
+
updateTab: d,
|
|
2500
|
+
getTabId: l,
|
|
2501
|
+
getPanelId: o,
|
|
2502
|
+
select: b,
|
|
2503
|
+
focusRelative: A,
|
|
2504
|
+
focusFirst: D,
|
|
2505
|
+
focusLast: _,
|
|
2506
|
+
isSelected: u,
|
|
2507
|
+
isTabbable: m
|
|
2508
|
+
});
|
|
2509
|
+
const $ = {
|
|
2510
|
+
horizontal: "flex-col",
|
|
2511
|
+
vertical: "flex-row"
|
|
2512
|
+
};
|
|
2513
|
+
return (h, I) => (f(), p("div", {
|
|
2514
|
+
"data-slot": "tabs",
|
|
2515
|
+
class: w(["flex gap-0", $[a.orientation]]),
|
|
2516
|
+
"data-orientation": a.orientation
|
|
2517
|
+
}, [
|
|
2518
|
+
C(h.$slots, "default")
|
|
2519
|
+
], 10, La));
|
|
2520
|
+
}
|
|
2521
|
+
}), Fn = /* @__PURE__ */ x({
|
|
2522
|
+
__name: "Text",
|
|
2523
|
+
props: {
|
|
2524
|
+
as: { default: "p" },
|
|
2525
|
+
size: { default: "md" },
|
|
2526
|
+
weight: { default: "normal" },
|
|
2527
|
+
tone: { default: "default" }
|
|
2528
|
+
},
|
|
2529
|
+
setup(a) {
|
|
2530
|
+
const e = {
|
|
2531
|
+
sm: "text-kablui-sm",
|
|
2532
|
+
md: "text-kablui-md",
|
|
2533
|
+
lg: "text-kablui-lg"
|
|
2534
|
+
}, t = {
|
|
2535
|
+
normal: "font-kablui-normal",
|
|
2536
|
+
medium: "font-kablui-medium",
|
|
2537
|
+
semibold: "font-kablui-semibold"
|
|
2538
|
+
}, n = {
|
|
2539
|
+
default: "text-kablui-fg",
|
|
2540
|
+
muted: "text-kablui-muted-fg",
|
|
2541
|
+
accent: "text-kablui-accent",
|
|
2542
|
+
danger: "text-kablui-danger"
|
|
2543
|
+
};
|
|
2544
|
+
return (i, l) => (f(), V(ae(a.as), {
|
|
2545
|
+
class: w([e[a.size], t[a.weight], n[a.tone]])
|
|
2546
|
+
}, {
|
|
2547
|
+
default: Y(() => [
|
|
2548
|
+
C(i.$slots, "default")
|
|
2549
|
+
]),
|
|
2550
|
+
_: 3
|
|
2551
|
+
}, 8, ["class"]));
|
|
2552
|
+
}
|
|
2553
|
+
}), Oa = ["id", "name", "rows", "disabled", "placeholder", "value", "aria-invalid", "aria-describedby"], Hn = /* @__PURE__ */ x({
|
|
2554
|
+
inheritAttrs: !1,
|
|
2555
|
+
__name: "Textarea",
|
|
2556
|
+
props: /* @__PURE__ */ U({
|
|
2557
|
+
size: { default: "md" },
|
|
2558
|
+
rows: { default: 3 },
|
|
2559
|
+
disabled: { type: Boolean, default: !1 },
|
|
2560
|
+
invalid: { type: Boolean, default: !1 },
|
|
2561
|
+
placeholder: {},
|
|
2562
|
+
name: {},
|
|
2563
|
+
id: {}
|
|
2564
|
+
}, {
|
|
2565
|
+
modelValue: { default: "" },
|
|
2566
|
+
modelModifiers: {}
|
|
2567
|
+
}),
|
|
2568
|
+
emits: ["update:modelValue"],
|
|
2569
|
+
setup(a) {
|
|
2570
|
+
const e = a, t = N(a, "modelValue"), n = X(), i = se({
|
|
2571
|
+
id: () => e.id,
|
|
2572
|
+
invalid: () => e.invalid
|
|
2573
|
+
}), l = [
|
|
2574
|
+
"w-full border border-kablui-border bg-kablui-bg text-kablui-fg",
|
|
2575
|
+
"rounded-kablui-md font-kablui-normal",
|
|
2576
|
+
"placeholder:text-kablui-muted-fg",
|
|
2577
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-kablui-focus focus-visible:ring-offset-2 focus-visible:ring-offset-kablui-bg",
|
|
2578
|
+
"disabled:opacity-50 disabled:pointer-events-none"
|
|
2579
|
+
].join(" "), o = {
|
|
2580
|
+
sm: "text-kablui-sm px-2 py-1",
|
|
2581
|
+
md: "text-kablui-md px-3 py-1.5",
|
|
2582
|
+
lg: "text-kablui-lg px-4 py-2"
|
|
2583
|
+
}, s = g(() => [
|
|
2584
|
+
l,
|
|
2585
|
+
o[e.size],
|
|
2586
|
+
i.invalid.value ? "border-kablui-danger" : ""
|
|
2587
|
+
]);
|
|
2588
|
+
return (c, d) => (f(), p("textarea", Z({
|
|
2589
|
+
id: v(i).id.value,
|
|
2590
|
+
name: a.name,
|
|
2591
|
+
rows: a.rows,
|
|
2592
|
+
disabled: a.disabled,
|
|
2593
|
+
placeholder: a.placeholder,
|
|
2594
|
+
value: t.value,
|
|
2595
|
+
"aria-invalid": v(i).ariaInvalid.value,
|
|
2596
|
+
"aria-describedby": v(i).describedBy.value,
|
|
2597
|
+
class: s.value
|
|
2598
|
+
}, v(n), {
|
|
2599
|
+
onInput: d[0] || (d[0] = (r) => t.value = r.target.value)
|
|
2600
|
+
}), null, 16, Oa));
|
|
2601
|
+
}
|
|
2602
|
+
}), Pa = ["role", "aria-labelledby", "aria-describedby"], Va = { class: "min-w-0 flex-1" }, Fa = ["id"], Ha = ["id"], Ka = /* @__PURE__ */ x({
|
|
2603
|
+
__name: "Toast",
|
|
2604
|
+
props: {
|
|
2605
|
+
tone: { default: "neutral" },
|
|
2606
|
+
title: {},
|
|
2607
|
+
description: {},
|
|
2608
|
+
actionLabel: {}
|
|
2609
|
+
},
|
|
2610
|
+
emits: ["dismiss", "action"],
|
|
2611
|
+
setup(a, { emit: e }) {
|
|
2612
|
+
const t = e, n = P("toast-title"), i = P("toast-description"), l = [
|
|
2613
|
+
"pointer-events-auto relative flex w-80 max-w-[calc(100vw-2rem)] gap-3",
|
|
2614
|
+
"rounded-kablui-md border px-3 py-2.5 shadow-kablui-md",
|
|
2615
|
+
"text-kablui-md"
|
|
2616
|
+
].join(" "), o = {
|
|
2617
|
+
neutral: "border-kablui-border bg-kablui-bg text-kablui-fg",
|
|
2618
|
+
accent: "border-kablui-accent bg-kablui-accent text-kablui-accent-fg",
|
|
2619
|
+
danger: "border-kablui-danger bg-kablui-danger text-kablui-danger-fg",
|
|
2620
|
+
success: "border-kablui-success bg-kablui-success text-kablui-success-fg",
|
|
2621
|
+
warning: "border-kablui-warning bg-kablui-warning text-kablui-warning-fg"
|
|
2622
|
+
}, s = [
|
|
2623
|
+
"shrink-0 -mr-1 -mt-0.5 inline-flex size-6 items-center justify-center",
|
|
2624
|
+
"rounded-kablui-sm text-current opacity-70 hover:opacity-100",
|
|
2625
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-kablui-focus focus-visible:ring-offset-2 focus-visible:ring-offset-kablui-bg"
|
|
2626
|
+
].join(" "), c = [
|
|
2627
|
+
"mt-1.5 inline-flex items-center text-kablui-sm font-kablui-medium",
|
|
2628
|
+
"underline underline-offset-2 opacity-90 hover:opacity-100",
|
|
2629
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-kablui-focus focus-visible:ring-offset-2 focus-visible:ring-offset-kablui-bg"
|
|
2630
|
+
].join(" ");
|
|
2631
|
+
function d() {
|
|
2632
|
+
t("dismiss");
|
|
2633
|
+
}
|
|
2634
|
+
function r() {
|
|
2635
|
+
t("action");
|
|
2636
|
+
}
|
|
2637
|
+
return (u, m) => (f(), p("div", {
|
|
2638
|
+
role: a.tone === "danger" ? "alert" : "status",
|
|
2639
|
+
"aria-labelledby": v(n),
|
|
2640
|
+
"aria-describedby": a.description ? v(i) : void 0,
|
|
2641
|
+
class: w([v(l), o[a.tone]]),
|
|
2642
|
+
"data-kablui-toast": ""
|
|
2643
|
+
}, [
|
|
2644
|
+
j("div", Va, [
|
|
2645
|
+
j("div", {
|
|
2646
|
+
id: v(n),
|
|
2647
|
+
class: "font-kablui-semibold"
|
|
2648
|
+
}, H(a.title), 9, Fa),
|
|
2649
|
+
a.description ? (f(), p("div", {
|
|
2650
|
+
key: 0,
|
|
2651
|
+
id: v(i),
|
|
2652
|
+
class: "mt-0.5 text-kablui-sm opacity-90"
|
|
2653
|
+
}, H(a.description), 9, Ha)) : z("", !0),
|
|
2654
|
+
a.actionLabel ? (f(), p("button", {
|
|
2655
|
+
key: 1,
|
|
2656
|
+
type: "button",
|
|
2657
|
+
class: w(v(c)),
|
|
2658
|
+
onClick: r
|
|
2659
|
+
}, H(a.actionLabel), 3)) : z("", !0)
|
|
2660
|
+
]),
|
|
2661
|
+
j("button", {
|
|
2662
|
+
type: "button",
|
|
2663
|
+
class: w(v(s)),
|
|
2664
|
+
"aria-label": "Dismiss",
|
|
2665
|
+
onClick: d
|
|
2666
|
+
}, [...m[0] || (m[0] = [
|
|
2667
|
+
j("span", { "aria-hidden": "true" }, "×", -1)
|
|
2668
|
+
])], 2)
|
|
2669
|
+
], 10, Pa));
|
|
2670
|
+
}
|
|
2671
|
+
}), Ye = Symbol("kablui-toast"), Na = ["data-placement"], Ua = 5e3, Kn = /* @__PURE__ */ x({
|
|
2672
|
+
__name: "ToastProvider",
|
|
2673
|
+
props: {
|
|
2674
|
+
placement: { default: "bottom-end" },
|
|
2675
|
+
maxVisible: { default: 3 },
|
|
2676
|
+
to: { default: "body" }
|
|
2677
|
+
},
|
|
2678
|
+
setup(a) {
|
|
2679
|
+
const e = a, t = R([]), n = R([]), i = /* @__PURE__ */ new Map(), { zIndex: l } = pe("toast"), o = g(() => t.value.length > 0);
|
|
2680
|
+
function s(_) {
|
|
2681
|
+
const $ = i.get(_);
|
|
2682
|
+
$ !== void 0 && (clearTimeout($), i.delete(_));
|
|
2683
|
+
}
|
|
2684
|
+
function c(_) {
|
|
2685
|
+
if (_.duration <= 0) return;
|
|
2686
|
+
s(_.id);
|
|
2687
|
+
const $ = setTimeout(() => {
|
|
2688
|
+
u(_.id);
|
|
2689
|
+
}, _.duration);
|
|
2690
|
+
i.set(_.id, $);
|
|
2691
|
+
}
|
|
2692
|
+
function d() {
|
|
2693
|
+
for (; t.value.length < e.maxVisible && n.value.length > 0; ) {
|
|
2694
|
+
const _ = n.value.shift();
|
|
2695
|
+
if (!_) break;
|
|
2696
|
+
t.value.push(_), c(_);
|
|
2697
|
+
}
|
|
2698
|
+
}
|
|
2699
|
+
function r(_) {
|
|
2700
|
+
const $ = {
|
|
2701
|
+
id: P("toast"),
|
|
2702
|
+
tone: _.tone ?? "neutral",
|
|
2703
|
+
title: _.title,
|
|
2704
|
+
description: _.description,
|
|
2705
|
+
duration: _.duration ?? Ua,
|
|
2706
|
+
action: _.action
|
|
2707
|
+
};
|
|
2708
|
+
return t.value.length < e.maxVisible ? (t.value.push($), c($)) : n.value.push($), $.id;
|
|
2709
|
+
}
|
|
2710
|
+
function u(_) {
|
|
2711
|
+
s(_);
|
|
2712
|
+
const $ = t.value.findIndex((I) => I.id === _);
|
|
2713
|
+
if ($ !== -1) {
|
|
2714
|
+
t.value.splice($, 1), d();
|
|
2715
|
+
return;
|
|
2716
|
+
}
|
|
2717
|
+
const h = n.value.findIndex((I) => I.id === _);
|
|
2718
|
+
h !== -1 && n.value.splice(h, 1);
|
|
2719
|
+
}
|
|
2720
|
+
function m(_) {
|
|
2721
|
+
var $;
|
|
2722
|
+
($ = _.action) == null || $.onClick();
|
|
2723
|
+
}
|
|
2724
|
+
G(Ye, { toast: r, dismiss: u }), ie(() => {
|
|
2725
|
+
for (const _ of [...i.keys()]) s(_);
|
|
2726
|
+
});
|
|
2727
|
+
const b = {
|
|
2728
|
+
"top-start": "top-4 left-4",
|
|
2729
|
+
"top-end": "top-4 right-4",
|
|
2730
|
+
"bottom-start": "bottom-4 left-4",
|
|
2731
|
+
"bottom-end": "bottom-4 right-4"
|
|
2732
|
+
}, y = g(() => e.placement.startsWith("top")), A = g(
|
|
2733
|
+
() => ["pointer-events-none fixed z-kablui-toast", b[e.placement]].join(" ")
|
|
2734
|
+
), D = g(
|
|
2735
|
+
() => y.value ? [...t.value].reverse() : t.value
|
|
2736
|
+
);
|
|
2737
|
+
return (_, $) => (f(), p(ee, null, [
|
|
2738
|
+
C(_.$slots, "default"),
|
|
2739
|
+
(f(), V(de, { to: a.to }, [
|
|
2740
|
+
o.value ? (f(), p("div", {
|
|
2741
|
+
key: 0,
|
|
2742
|
+
class: w(A.value),
|
|
2743
|
+
style: ce({ zIndex: v(l) }),
|
|
2744
|
+
"data-kablui-toast-region": "",
|
|
2745
|
+
"data-placement": a.placement
|
|
2746
|
+
}, [
|
|
2747
|
+
he(Ra, {
|
|
2748
|
+
gap: "sm",
|
|
2749
|
+
align: a.placement.endsWith("end") ? "end" : "start"
|
|
2750
|
+
}, {
|
|
2751
|
+
default: Y(() => [
|
|
2752
|
+
(f(!0), p(ee, null, we(D.value, (h) => {
|
|
2753
|
+
var I;
|
|
2754
|
+
return f(), V(Ka, {
|
|
2755
|
+
key: h.id,
|
|
2756
|
+
tone: h.tone,
|
|
2757
|
+
title: h.title,
|
|
2758
|
+
description: h.description,
|
|
2759
|
+
"action-label": (I = h.action) == null ? void 0 : I.label,
|
|
2760
|
+
onDismiss: (E) => u(h.id),
|
|
2761
|
+
onAction: (E) => m(h)
|
|
2762
|
+
}, null, 8, ["tone", "title", "description", "action-label", "onDismiss", "onAction"]);
|
|
2763
|
+
}), 128))
|
|
2764
|
+
]),
|
|
2765
|
+
_: 1
|
|
2766
|
+
}, 8, ["align"])
|
|
2767
|
+
], 14, Na)) : z("", !0)
|
|
2768
|
+
], 8, ["to"]))
|
|
2769
|
+
], 64));
|
|
2770
|
+
}
|
|
2771
|
+
}), qa = ["id", "data-placement"], Nn = /* @__PURE__ */ x({
|
|
2772
|
+
__name: "Tooltip",
|
|
2773
|
+
props: {
|
|
2774
|
+
content: {},
|
|
2775
|
+
placement: { default: "top" },
|
|
2776
|
+
delay: { default: 300 }
|
|
2777
|
+
},
|
|
2778
|
+
setup(a) {
|
|
2779
|
+
const e = a, t = R(!1), n = R(null), i = R(null), l = P("tooltip");
|
|
2780
|
+
let o = null, s = null, c = null;
|
|
2781
|
+
const { style: d } = Ie(n, i, {
|
|
2782
|
+
open: t,
|
|
2783
|
+
placement: () => e.placement
|
|
2784
|
+
});
|
|
2785
|
+
function r() {
|
|
2786
|
+
o && (clearTimeout(o), o = null), s && (clearTimeout(s), s = null);
|
|
2787
|
+
}
|
|
2788
|
+
function u() {
|
|
2789
|
+
return typeof window > "u" || typeof window.matchMedia != "function" ? !0 : window.matchMedia("(hover: hover)").matches;
|
|
2790
|
+
}
|
|
2791
|
+
function m() {
|
|
2792
|
+
const E = n.value;
|
|
2793
|
+
return E ? E.querySelector(
|
|
2794
|
+
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
2795
|
+
) ?? E : null;
|
|
2796
|
+
}
|
|
2797
|
+
function b(E) {
|
|
2798
|
+
const M = m();
|
|
2799
|
+
c && c !== M && (c.getAttribute("aria-describedby") === l && c.removeAttribute("aria-describedby"), c = null), M && (c = M, E ? M.setAttribute("aria-describedby", l) : M.getAttribute("aria-describedby") === l && M.removeAttribute("aria-describedby"));
|
|
2800
|
+
}
|
|
2801
|
+
function y() {
|
|
2802
|
+
r(), o = setTimeout(() => {
|
|
2803
|
+
o = null, t.value = !0;
|
|
2804
|
+
}, e.delay);
|
|
2805
|
+
}
|
|
2806
|
+
function A() {
|
|
2807
|
+
r(), s = setTimeout(() => {
|
|
2808
|
+
s = null, t.value = !1;
|
|
2809
|
+
}, 0);
|
|
2810
|
+
}
|
|
2811
|
+
function D() {
|
|
2812
|
+
u() && y();
|
|
2813
|
+
}
|
|
2814
|
+
function _() {
|
|
2815
|
+
u() && A();
|
|
2816
|
+
}
|
|
2817
|
+
function $() {
|
|
2818
|
+
y();
|
|
2819
|
+
}
|
|
2820
|
+
function h(E) {
|
|
2821
|
+
const M = n.value, F = E.relatedTarget;
|
|
2822
|
+
M && F instanceof Node && M.contains(F) || A();
|
|
2823
|
+
}
|
|
2824
|
+
K(t, async (E) => {
|
|
2825
|
+
await Q(), b(E);
|
|
2826
|
+
}), q(() => {
|
|
2827
|
+
r(), b(!1);
|
|
2828
|
+
});
|
|
2829
|
+
const I = [
|
|
2830
|
+
"z-kablui-tooltip pointer-events-none max-w-xs rounded-kablui-md",
|
|
2831
|
+
"border border-kablui-border bg-kablui-bg px-2 py-1",
|
|
2832
|
+
"text-kablui-sm text-kablui-fg shadow-kablui-md"
|
|
2833
|
+
].join(" ");
|
|
2834
|
+
return (E, M) => (f(), p(ee, null, [
|
|
2835
|
+
j("span", {
|
|
2836
|
+
ref_key: "anchorRef",
|
|
2837
|
+
ref: n,
|
|
2838
|
+
class: "inline-flex",
|
|
2839
|
+
"data-slot": "tooltip",
|
|
2840
|
+
onPointerenter: D,
|
|
2841
|
+
onPointerleave: _,
|
|
2842
|
+
onFocusin: $,
|
|
2843
|
+
onFocusout: h
|
|
2844
|
+
}, [
|
|
2845
|
+
C(E.$slots, "default")
|
|
2846
|
+
], 544),
|
|
2847
|
+
(f(), V(de, { to: "body" }, [
|
|
2848
|
+
t.value ? (f(), p("div", {
|
|
2849
|
+
key: 0,
|
|
2850
|
+
id: v(l),
|
|
2851
|
+
ref_key: "floatingRef",
|
|
2852
|
+
ref: i,
|
|
2853
|
+
role: "tooltip",
|
|
2854
|
+
"data-slot": "tooltip-content",
|
|
2855
|
+
"data-placement": a.placement,
|
|
2856
|
+
class: w(v(I)),
|
|
2857
|
+
style: ce(v(d))
|
|
2858
|
+
}, [
|
|
2859
|
+
C(E.$slots, "content", {}, () => [
|
|
2860
|
+
re(H(a.content), 1)
|
|
2861
|
+
])
|
|
2862
|
+
], 14, qa)) : z("", !0)
|
|
2863
|
+
]))
|
|
2864
|
+
], 64));
|
|
2865
|
+
}
|
|
2866
|
+
});
|
|
2867
|
+
function Un() {
|
|
2868
|
+
const a = S(Ye, null);
|
|
2869
|
+
if (!a)
|
|
2870
|
+
throw new Error("useToast() must be used within a <ToastProvider>.");
|
|
2871
|
+
return a;
|
|
2872
|
+
}
|
|
2873
|
+
const qn = rt.version;
|
|
2874
|
+
export {
|
|
2875
|
+
Ga as Accordion,
|
|
2876
|
+
Wa as AccordionContent,
|
|
2877
|
+
Ja as AccordionItem,
|
|
2878
|
+
Qa as AccordionTrigger,
|
|
2879
|
+
Xa as Alert,
|
|
2880
|
+
Za as Badge,
|
|
2881
|
+
ke as Button,
|
|
2882
|
+
en as Card,
|
|
2883
|
+
tn as CardBody,
|
|
2884
|
+
an as CardDescription,
|
|
2885
|
+
nn as CardFooter,
|
|
2886
|
+
sn as CardHeader,
|
|
2887
|
+
ln as CardTitle,
|
|
2888
|
+
on as Checkbox,
|
|
2889
|
+
rn as Cluster,
|
|
2890
|
+
un as Container,
|
|
2891
|
+
dn as Dialog,
|
|
2892
|
+
cn as Empty,
|
|
2893
|
+
fn as Field,
|
|
2894
|
+
bn as FieldError,
|
|
2895
|
+
vn as FieldHint,
|
|
2896
|
+
mn as Icon,
|
|
2897
|
+
pn as Input,
|
|
2898
|
+
gn as Label,
|
|
2899
|
+
kn as Link,
|
|
2900
|
+
hn as Menu,
|
|
2901
|
+
yn as MenuContent,
|
|
2902
|
+
xn as MenuItem,
|
|
2903
|
+
wn as MenuSeparator,
|
|
2904
|
+
_n as MenuTrigger,
|
|
2905
|
+
$n as Pagination,
|
|
2906
|
+
Cn as Popover,
|
|
2907
|
+
In as PopoverContent,
|
|
2908
|
+
Tn as PopoverTrigger,
|
|
2909
|
+
En as Progress,
|
|
2910
|
+
An as Radio,
|
|
2911
|
+
Dn as RadioGroup,
|
|
2912
|
+
Rn as Select,
|
|
2913
|
+
Bn as SelectItem,
|
|
2914
|
+
Mn as Separator,
|
|
2915
|
+
zn as Skeleton,
|
|
2916
|
+
jn as Spinner,
|
|
2917
|
+
Ra as Stack,
|
|
2918
|
+
Sn as Switch,
|
|
2919
|
+
Ln as Tab,
|
|
2920
|
+
On as TabList,
|
|
2921
|
+
Pn as TabPanel,
|
|
2922
|
+
Vn as Tabs,
|
|
2923
|
+
Fn as Text,
|
|
2924
|
+
Hn as Textarea,
|
|
2925
|
+
Ka as Toast,
|
|
2926
|
+
Kn as ToastProvider,
|
|
2927
|
+
Nn as Tooltip,
|
|
2928
|
+
wt as provideField,
|
|
2929
|
+
me as useField,
|
|
2930
|
+
se as useFieldControlAttrs,
|
|
2931
|
+
Un as useToast,
|
|
2932
|
+
qn as version
|
|
2933
|
+
};
|
|
2934
|
+
//# sourceMappingURL=kablui.js.map
|