@hebatzy/ui 0.0.0-stage → 0.3.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/dist/index.mjs ADDED
@@ -0,0 +1,1235 @@
1
+ import { defineComponent as Y, openBlock as n, createElementBlock as s, normalizeClass as H, renderSlot as S, mergeProps as fe, useModel as Fe, ref as M, useId as ze, computed as C, useSlots as ua, createTextVNode as K, toDisplayString as x, createCommentVNode as v, createElementVNode as r, withDirectives as ve, vModelText as Ge, vModelSelect as ca, vModelDynamic as fa, mergeModels as Ce, createBlock as Te, Teleport as Qe, createVNode as Be, Transition as He, withCtx as Se, shallowReactive as Re, shallowRef as va, watch as Q, onBeforeUnmount as ya, Fragment as ae, renderList as ye, withModifiers as j, nextTick as Me, inject as Ye, unref as pa } from "vue";
2
+ const ma = /* @__PURE__ */ Y({
3
+ name: "HebaBadge",
4
+ __name: "HebaBadge",
5
+ props: {
6
+ variant: { default: "secondary" },
7
+ size: { default: "md" }
8
+ },
9
+ setup(t) {
10
+ const d = {
11
+ sm: "heba:px-2 heba:py-0.5 heba:text-xs",
12
+ md: "heba:px-2.5 heba:py-1 heba:text-xs",
13
+ lg: "heba:px-3 heba:py-1.5 heba:text-sm"
14
+ }, b = {
15
+ secondary: "heba:bg-secondary-200 heba:text-secondary-900",
16
+ info: "heba:bg-info-600 heba:text-info-100",
17
+ success: "heba:bg-success-600 heba:text-success-100",
18
+ warning: "heba:bg-warning-800 heba:text-warning-100",
19
+ danger: "heba:bg-danger-600 heba:text-danger-100"
20
+ };
21
+ return (o, h) => (n(), s("span", {
22
+ class: H([
23
+ "heba:inline-flex heba:items-center heba:font-semibold heba:rounded-md",
24
+ d[t.size],
25
+ b[t.variant]
26
+ ])
27
+ }, [
28
+ S(o.$slots, "default")
29
+ ], 2));
30
+ }
31
+ }), ga = ["disabled"], xa = /* @__PURE__ */ Y({
32
+ name: "HebaButton",
33
+ inheritAttrs: !1,
34
+ __name: "HebaButton",
35
+ props: {
36
+ variant: { default: "info" },
37
+ size: { default: "md" },
38
+ rounded: { default: "md" },
39
+ disabled: { type: Boolean, default: !1 }
40
+ },
41
+ setup(t) {
42
+ const d = {
43
+ none: "heba:rounded-none",
44
+ sm: "heba:rounded-sm",
45
+ md: "heba:rounded-md",
46
+ lg: "heba:rounded-lg",
47
+ xl: "heba:rounded-xl",
48
+ "2xl": "heba:rounded-2xl",
49
+ full: "heba:rounded-full"
50
+ }, b = {
51
+ sm: "heba:px-2.5 heba:py-1 heba:text-xs",
52
+ md: "heba:px-4 heba:py-2 heba:text-sm",
53
+ lg: "heba:px-6 heba:py-3 heba:text-base"
54
+ }, o = {
55
+ info: "heba:bg-info-600 heba:text-white heba:hover:bg-info-700",
56
+ secondary: "heba:bg-secondary-50 heba:text-black heba:hover:bg-secondary-200 heba:border heba:border-secondary-300",
57
+ success: "heba:bg-success-600 heba:text-white heba:hover:bg-success-700",
58
+ warning: "heba:bg-warning-600 heba:text-white heba:hover:bg-warning-700",
59
+ danger: "heba:bg-danger-600 heba:text-white heba:hover:bg-danger-700"
60
+ };
61
+ return (h, y) => (n(), s("button", fe({
62
+ class: [
63
+ "heba:inline-flex heba:items-center heba:justify-content-center heba:font-medium heba:cursor-pointer heba:transition-colors heba:duration-150",
64
+ b[t.size],
65
+ o[t.variant],
66
+ d[t.rounded],
67
+ { "heba:opacity-50 heba:cursor-not-allowed": t.disabled }
68
+ ],
69
+ disabled: t.disabled
70
+ }, h.$attrs), [
71
+ S(h.$slots, "default")
72
+ ], 16, ga));
73
+ }
74
+ }), wa = { class: "heba:flex heba:flex-col heba:gap-1" }, ka = ["for"], $a = {
75
+ key: 0,
76
+ class: "heba:text-danger-500 heba:ml-0.5"
77
+ }, Ma = {
78
+ key: 1,
79
+ class: "heba:text-xs heba:mb-1 heba:text-secondary-500"
80
+ }, Ca = { class: "heba:relative heba:flex heba:items-center" }, Ba = {
81
+ key: 0,
82
+ class: "heba:absolute heba:left-3 heba:flex heba:items-center heba:pointer-events-none heba:text-secondary-500"
83
+ }, Ha = ["id", "placeholder", "disabled", "readonly", "rows"], Sa = ["id", "disabled"], za = {
84
+ value: "",
85
+ disabled: "",
86
+ hidden: ""
87
+ }, Ta = ["id", "type", "placeholder", "disabled", "readonly"], La = {
88
+ key: 4,
89
+ class: "heba:absolute heba:right-3 heba:flex heba:items-center heba:pointer-events-none heba:text-secondary-500"
90
+ }, Aa = {
91
+ key: 5,
92
+ class: "heba:absolute heba:right-3 heba:flex heba:items-center heba:pointer-events-none heba:text-secondary-500"
93
+ }, Va = {
94
+ key: 2,
95
+ class: "heba:text-xs heba:text-danger-600"
96
+ }, Oa = /* @__PURE__ */ Y({
97
+ name: "HebaInput",
98
+ inheritAttrs: !1,
99
+ __name: "HebaInput",
100
+ props: /* @__PURE__ */ Ce({
101
+ label: {},
102
+ placeholder: {},
103
+ type: { default: "text" },
104
+ error: {},
105
+ hint: {},
106
+ disabled: { type: Boolean, default: !1 },
107
+ readonly: { type: Boolean, default: !1 },
108
+ required: { type: Boolean, default: !1 },
109
+ rows: { default: 3 }
110
+ }, {
111
+ modelValue: {},
112
+ modelModifiers: {}
113
+ }),
114
+ emits: ["update:modelValue"],
115
+ setup(t) {
116
+ const d = t, b = Fe(t, "modelValue"), o = M(!1), h = ze(), y = C(() => `heba-input-${h}`), z = ua(), $ = C(() => {
117
+ const g = [
118
+ "heba:w-full heba:rounded-lg heba:border heba:bg-white heba:text-sm heba:text-secondary-900",
119
+ "heba:placeholder:text-secondary-400",
120
+ "heba:transition-colors heba:duration-150 heba:outline-none",
121
+ "heba:disabled:bg-secondary-100 heba:disabled:text-secondary-400 heba:disabled:cursor-not-allowed",
122
+ "heba:read-only:cursor-default",
123
+ d.type === "textarea" ? "heba:px-3 heba:py-2" : "heba:px-3 heba:h-9",
124
+ z.prepend ? "heba:pl-9" : ""
125
+ ];
126
+ return d.disabled ? g.push("heba:border-secondary-200") : d.error ? g.push(
127
+ "heba:border-danger-500 heba:focus:border-danger-500 heba:focus:ring-2 heba:focus:ring-danger-200"
128
+ ) : g.push(
129
+ "heba:border-secondary-300 heba:focus:border-info-500 heba:focus:ring-2 heba:focus:ring-info-100"
130
+ ), g;
131
+ });
132
+ return (g, c) => (n(), s("div", wa, [
133
+ t.label ? (n(), s("label", {
134
+ key: 0,
135
+ for: y.value,
136
+ class: H([
137
+ "heba:text-sm heba:font-semibold",
138
+ t.disabled ? "heba:text-secondary-400" : "heba:text-secondary-900",
139
+ t.error ? "heba:text-danger-600" : ""
140
+ ])
141
+ }, [
142
+ K(x(t.label) + " ", 1),
143
+ t.required ? (n(), s("span", $a, "*")) : v("", !0)
144
+ ], 10, ka)) : v("", !0),
145
+ t.hint ? (n(), s("p", Ma, x(t.hint), 1)) : v("", !0),
146
+ r("div", Ca, [
147
+ g.$slots.prepend ? (n(), s("div", Ba, [
148
+ S(g.$slots, "prepend")
149
+ ])) : v("", !0),
150
+ t.type === "textarea" ? ve((n(), s("textarea", fe({
151
+ key: 1,
152
+ id: y.value,
153
+ "onUpdate:modelValue": c[0] || (c[0] = (p) => b.value = p),
154
+ placeholder: t.placeholder,
155
+ disabled: t.disabled,
156
+ readonly: t.readonly,
157
+ rows: t.rows,
158
+ class: $.value
159
+ }, g.$attrs, {
160
+ onFocus: c[1] || (c[1] = (p) => o.value = !0),
161
+ onBlur: c[2] || (c[2] = (p) => o.value = !1)
162
+ }), null, 16, Ha)), [
163
+ [Ge, b.value]
164
+ ]) : t.type === "select" ? ve((n(), s("select", fe({
165
+ key: 2,
166
+ id: y.value,
167
+ "onUpdate:modelValue": c[3] || (c[3] = (p) => b.value = p),
168
+ disabled: t.disabled,
169
+ class: [$.value, "heba:appearance-none heba:cursor-pointer"]
170
+ }, g.$attrs, {
171
+ onFocus: c[4] || (c[4] = (p) => o.value = !0),
172
+ onBlur: c[5] || (c[5] = (p) => o.value = !1)
173
+ }), [
174
+ r("option", za, x(t.placeholder), 1),
175
+ S(g.$slots, "default")
176
+ ], 16, Sa)), [
177
+ [ca, b.value]
178
+ ]) : ve((n(), s("input", fe({
179
+ key: 3,
180
+ id: y.value,
181
+ "onUpdate:modelValue": c[6] || (c[6] = (p) => b.value = p),
182
+ type: t.type,
183
+ placeholder: t.placeholder,
184
+ disabled: t.disabled,
185
+ readonly: t.readonly,
186
+ class: $.value
187
+ }, g.$attrs, {
188
+ onFocus: c[7] || (c[7] = (p) => o.value = !0),
189
+ onBlur: c[8] || (c[8] = (p) => o.value = !1)
190
+ }), null, 16, Ta)), [
191
+ [fa, b.value]
192
+ ]),
193
+ t.type === "select" ? (n(), s("div", La, [...c[9] || (c[9] = [
194
+ r("svg", {
195
+ class: "heba:w-4 heba:h-4",
196
+ viewBox: "0 0 20 20",
197
+ fill: "currentColor"
198
+ }, [
199
+ r("path", {
200
+ "fill-rule": "evenodd",
201
+ d: "M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",
202
+ "clip-rule": "evenodd"
203
+ })
204
+ ], -1)
205
+ ])])) : g.$slots.append ? (n(), s("div", Aa, [
206
+ S(g.$slots, "append")
207
+ ])) : v("", !0)
208
+ ]),
209
+ t.error ? (n(), s("p", Va, x(t.error), 1)) : v("", !0)
210
+ ]));
211
+ }
212
+ }), Ea = {
213
+ key: 0,
214
+ class: "heba:px-6 heba:pt-6 heba:pb-0"
215
+ }, Ia = { class: "heba:flex heba:justify-between heba:items-start" }, Da = { class: "flex heba:flex-col" }, ja = { class: "heba:text-sm heba:text-secondary-400" }, Ka = { class: "heba:px-6 heba:py-4 heba:text-sm heba:text-secondary-500 heba:leading-relaxed heba:flex-1" }, Ua = {
216
+ key: 1,
217
+ class: "heba:px-6 heba:pb-6 heba:pt-2 heba:flex heba:items-center heba:justify-end heba:gap-3"
218
+ }, qa = /* @__PURE__ */ Y({
219
+ name: "HebaModal",
220
+ __name: "HebaModal",
221
+ props: /* @__PURE__ */ Ce({
222
+ title: {},
223
+ subtitle: {},
224
+ size: { default: "md" },
225
+ closeOnBackdrop: { type: Boolean, default: !0 }
226
+ }, {
227
+ modelValue: { type: Boolean, default: !1 },
228
+ modelModifiers: {}
229
+ }),
230
+ emits: /* @__PURE__ */ Ce(["on:close"], ["update:modelValue"]),
231
+ setup(t, { emit: d }) {
232
+ const b = t, o = d, h = Fe(t, "modelValue"), z = `heba-modal-title-${ze()}`, $ = {
233
+ sm: "heba:max-w-sm",
234
+ md: "heba:max-w-md",
235
+ lg: "heba:max-w-lg"
236
+ };
237
+ function g() {
238
+ b.closeOnBackdrop && (h.value = !1);
239
+ }
240
+ function c() {
241
+ o("on:close"), h.value = !1;
242
+ }
243
+ return (p, J) => (n(), Te(Qe, { to: "body" }, [
244
+ Be(He, {
245
+ "enter-active-class": "heba:transition heba:duration-200 heba:ease-out",
246
+ "enter-from-class": "heba:opacity-0",
247
+ "enter-to-class": "heba:opacity-100",
248
+ "leave-active-class": "heba:transition heba:duration-150 heba:ease-in",
249
+ "leave-from-class": "heba:opacity-100",
250
+ "leave-to-class": "heba:opacity-0"
251
+ }, {
252
+ default: Se(() => [
253
+ t.modelValue ? (n(), s("div", {
254
+ key: 0,
255
+ class: "heba:fixed heba:inset-0 heba:z-50 heba:flex heba:items-center heba:justify-center heba:p-4",
256
+ role: "dialog",
257
+ "aria-modal": "true",
258
+ "aria-labelledby": z
259
+ }, [
260
+ r("div", {
261
+ class: "heba:absolute heba:inset-0 heba:bg-black/40",
262
+ onMousedown: g
263
+ }, null, 32),
264
+ Be(He, {
265
+ "enter-active-class": "heba:transition heba:duration-200 heba:ease-out",
266
+ "enter-from-class": "heba:opacity-0 heba:scale-95",
267
+ "enter-to-class": "heba:opacity-100 heba:scale-100",
268
+ "leave-active-class": "heba:transition heba:duration-150 heba:ease-in",
269
+ "leave-from-class": "heba:opacity-100 heba:scale-100",
270
+ "leave-to-class": "heba:opacity-0 heba:scale-95"
271
+ }, {
272
+ default: Se(() => [
273
+ t.modelValue ? (n(), s("div", {
274
+ key: 0,
275
+ class: H([
276
+ "heba:relative heba:bg-white heba:rounded-2xl heba:shadow-xl heba:w-full heba:flex heba:flex-col",
277
+ $[t.size]
278
+ ])
279
+ }, [
280
+ t.title || p.$slots.header ? (n(), s("div", Ea, [
281
+ S(p.$slots, "header", {}, () => [
282
+ r("div", Ia, [
283
+ r("div", Da, [
284
+ r("h2", {
285
+ id: z,
286
+ class: "heba:text-lg heba:font-bold heba:text-secondary-900 heba:leading-snug"
287
+ }, x(t.title), 1),
288
+ r("p", ja, x(t.subtitle), 1)
289
+ ]),
290
+ r("button", {
291
+ onClick: c,
292
+ class: "heba:cursor-pointer"
293
+ }, [...J[0] || (J[0] = [
294
+ r("i", { class: "fa-solid fa-xmark" }, null, -1)
295
+ ])])
296
+ ])
297
+ ])
298
+ ])) : v("", !0),
299
+ r("div", Ka, [
300
+ S(p.$slots, "default")
301
+ ]),
302
+ p.$slots.footer ? (n(), s("div", Ua, [
303
+ S(p.$slots, "footer")
304
+ ])) : v("", !0)
305
+ ], 2)) : v("", !0)
306
+ ]),
307
+ _: 3
308
+ })
309
+ ])) : v("", !0)
310
+ ]),
311
+ _: 3
312
+ })
313
+ ]));
314
+ }
315
+ }), Pa = {
316
+ key: 0,
317
+ class: "heba:ml-0.5 heba:text-danger-500"
318
+ }, Na = {
319
+ key: 1,
320
+ class: "heba:text-xs heba:mb-1 heba:text-secondary-500"
321
+ }, Ra = { class: "heba:relative" }, Fa = ["tabindex", "aria-expanded", "aria-labelledby", "aria-disabled", "aria-readonly", "aria-invalid", "aria-activedescendant"], Ga = {
322
+ key: 0,
323
+ class: "heba:truncate heba:text-secondary-400"
324
+ }, Qa = {
325
+ key: 0,
326
+ role: "status",
327
+ "aria-label": "Memuat pilihan",
328
+ class: "heba:h-2.5 heba:w-12 heba:animate-pulse heba:rounded heba:bg-secondary-300"
329
+ }, Ya = {
330
+ key: 1,
331
+ class: "heba:min-w-0 heba:truncate"
332
+ }, Ja = ["aria-label", "onClick"], Wa = {
333
+ key: 0,
334
+ role: "status",
335
+ "aria-label": "Memuat pilihan",
336
+ class: "heba:h-3 heba:w-28 heba:animate-pulse heba:rounded heba:bg-secondary-200"
337
+ }, Xa = {
338
+ key: 1,
339
+ class: "heba:min-w-0 heba:truncate"
340
+ }, Za = {
341
+ key: 2,
342
+ class: "heba:min-w-0 heba:truncate heba:text-danger-600"
343
+ }, _a = { class: "heba:flex heba:shrink-0 heba:items-center heba:gap-1" }, et = {
344
+ key: 0,
345
+ class: "heba:border-b heba:border-secondary-100 heba:p-2"
346
+ }, at = { class: "heba:relative heba:flex heba:items-center" }, tt = ["aria-activedescendant", "placeholder"], lt = {
347
+ key: 0,
348
+ class: "heba:pointer-events-none heba:absolute heba:right-2.5 heba:h-4 heba:w-4 heba:animate-spin heba:text-secondary-400",
349
+ viewBox: "0 0 24 24",
350
+ fill: "none",
351
+ "aria-hidden": "true"
352
+ }, ot = {
353
+ key: 0,
354
+ role: "status",
355
+ class: "heba:flex heba:items-center heba:justify-center heba:gap-2 heba:text-secondary-500"
356
+ }, nt = {
357
+ key: 1,
358
+ role: "alert",
359
+ class: "heba:flex heba:flex-col heba:items-center heba:gap-2 heba:text-danger-600"
360
+ }, st = {
361
+ key: 2,
362
+ class: "heba:text-secondary-500"
363
+ }, rt = ["aria-multiselectable", "aria-labelledby"], it = ["id", "aria-selected", "onMouseenter", "onClick"], bt = { class: "heba:min-w-0 heba:flex-1" }, dt = { class: "heba:block heba:truncate" }, ht = {
364
+ key: 0,
365
+ class: "heba:h-4 heba:w-4 heba:shrink-0 heba:text-info-600",
366
+ viewBox: "0 0 20 20",
367
+ fill: "currentColor",
368
+ "aria-hidden": "true"
369
+ }, ut = {
370
+ key: 0,
371
+ role: "presentation",
372
+ class: "heba:flex heba:items-center heba:gap-2 heba:px-3 heba:py-2 heba:text-xs heba:text-secondary-500"
373
+ }, ct = {
374
+ key: 1,
375
+ role: "presentation",
376
+ class: "heba:flex heba:items-center heba:justify-between heba:gap-2 heba:px-3 heba:py-2 heba:text-xs heba:text-danger-600"
377
+ }, ft = {
378
+ key: 2,
379
+ class: "heba:text-xs heba:text-danger-600"
380
+ }, vt = /* @__PURE__ */ Y({
381
+ name: "HebaSelect2",
382
+ __name: "HebaSelect2",
383
+ props: {
384
+ modelValue: { default: null },
385
+ options: { default: () => [] },
386
+ multiple: { type: Boolean },
387
+ searchable: { type: Boolean },
388
+ clearable: { type: Boolean },
389
+ disabled: { type: Boolean },
390
+ readonly: { type: Boolean },
391
+ labelKey: { default: "label" },
392
+ valueKey: { default: "value" },
393
+ remote: { type: Boolean },
394
+ loading: { type: Boolean },
395
+ debounce: { default: 300 },
396
+ limit: { default: 20 },
397
+ fetchOptions: {},
398
+ fetchSelectedOptions: {},
399
+ fallbackLabel: {},
400
+ label: {},
401
+ placeholder: { default: "Pilih..." },
402
+ searchPlaceholder: { default: "Cari..." },
403
+ emptyText: { default: "Tidak ada data" },
404
+ error: {},
405
+ hint: {},
406
+ required: { type: Boolean }
407
+ },
408
+ emits: ["update:modelValue", "update:selected", "search", "load", "change", "clear", "open", "close", "error"],
409
+ setup(t, { expose: d, emit: b }) {
410
+ const o = t, h = b, y = ze(), z = `heba-select2-label-${y}`, $ = `heba-select2-listbox-${y}`, g = M(null), c = M(null), p = M(null), J = M(null), k = M(!1), Ae = M(!1), O = M(""), w = M(-1), f = (e) => String(e);
411
+ function Ve(e) {
412
+ return typeof e == "string" && e !== "" || typeof e == "number" && !Number.isNaN(e);
413
+ }
414
+ function U(e, a = o.valueKey) {
415
+ if (!e || typeof e != "object") return;
416
+ const l = e[a];
417
+ return Ve(l) ? l : void 0;
418
+ }
419
+ function Oe(e, a) {
420
+ const l = e[o.labelKey];
421
+ return l == null || l === "" ? String(a) : String(l);
422
+ }
423
+ const T = Re(/* @__PURE__ */ new Map()), q = Re(/* @__PURE__ */ new Map()), re = /* @__PURE__ */ new Set();
424
+ let te = 0;
425
+ const ie = C(() => {
426
+ const e = /* @__PURE__ */ new Map();
427
+ for (const a of o.options) {
428
+ const l = U(a);
429
+ l !== void 0 && !e.has(f(l)) && e.set(f(l), a);
430
+ }
431
+ return e;
432
+ });
433
+ function Ee(e) {
434
+ return ie.value.get(e) ?? T.get(e) ?? null;
435
+ }
436
+ const P = C(() => {
437
+ const e = o.modelValue, a = Array.isArray(e) ? e : [e], l = /* @__PURE__ */ new Set(), i = [];
438
+ for (const u of a)
439
+ if (!(!Ve(u) || l.has(f(u))) && (l.add(f(u)), i.push(u), !o.multiple))
440
+ break;
441
+ return i;
442
+ }), We = C(() => new Set(P.value.map(f))), W = C(
443
+ () => P.value.map((e) => {
444
+ const a = f(e), l = Ee(a);
445
+ if (l)
446
+ return {
447
+ key: a,
448
+ value: e,
449
+ option: l,
450
+ label: Oe(l, e),
451
+ status: "ready"
452
+ };
453
+ const i = q.get(a) ?? "missing";
454
+ let u;
455
+ return i === "loading" ? u = "Memuat..." : i === "error" ? u = `Gagal memuat (${e})` : u = o.fallbackLabel ? o.fallbackLabel(e) : `Tidak ditemukan (${e})`, { key: a, value: e, option: null, label: u, status: i };
456
+ })
457
+ ), X = C(() => !o.disabled && !o.readonly), Xe = C(
458
+ () => o.clearable && X.value && P.value.length > 0
459
+ ), Ze = C(
460
+ () => W.value.some((e) => e.status === "error")
461
+ );
462
+ function Ie() {
463
+ const e = [];
464
+ for (const a of P.value) {
465
+ const l = f(a), i = ie.value.get(l);
466
+ if (i) {
467
+ T.get(l) !== i && T.set(l, i);
468
+ continue;
469
+ }
470
+ T.has(l) || re.has(l) || e.push(a);
471
+ }
472
+ e.length && o.fetchSelectedOptions && _e(o.fetchSelectedOptions, e);
473
+ }
474
+ async function _e(e, a) {
475
+ const l = te, i = a.map(f);
476
+ for (const u of i)
477
+ re.add(u), q.set(u, "loading");
478
+ if (!(typeof window > "u"))
479
+ try {
480
+ const u = await e(o.multiple ? a : a[0]);
481
+ if (l !== te) return;
482
+ const V = Array.isArray(u) ? u : u ? [u] : [];
483
+ for (const L of V) {
484
+ const m = U(L);
485
+ m !== void 0 && (T.has(f(m)) || T.set(f(m), L));
486
+ }
487
+ for (const L of i) q.delete(L);
488
+ } catch (u) {
489
+ if (l !== te) return;
490
+ for (const V of i) q.set(V, "error");
491
+ h("error", u, { type: "selected", values: a });
492
+ }
493
+ }
494
+ function De() {
495
+ const e = [...q].filter(([, a]) => a === "error").map(([a]) => a);
496
+ for (const a of e)
497
+ q.delete(a), re.delete(a);
498
+ Ie();
499
+ }
500
+ const Z = va([]), _ = M(!1), N = M(!1), le = M(!1), ee = M(!1), R = M(!1);
501
+ let be = 0, de = !1, oe = null, ne = 0, E = null, pe;
502
+ const je = C(
503
+ () => o.loading || R.value || _.value
504
+ );
505
+ function ea(e, a) {
506
+ if (Array.isArray(e))
507
+ return { data: e, more: e.length >= o.limit };
508
+ const l = Array.isArray(e == null ? void 0 : e.data) ? e.data : [];
509
+ return typeof (e == null ? void 0 : e.hasMore) == "boolean" ? { data: l, more: e.hasMore } : typeof (e == null ? void 0 : e.total) == "number" ? { data: l, more: a * o.limit < e.total } : { data: l, more: l.length >= o.limit };
510
+ }
511
+ async function se(e) {
512
+ const a = o.fetchOptions;
513
+ if (!a) return;
514
+ const l = O.value, i = ++ne;
515
+ E == null || E.abort();
516
+ const u = new AbortController();
517
+ E = u, R.value = !1, ee.value = !1, e === 1 ? (_.value = !0, N.value = !1, le.value = !1) : N.value = !0;
518
+ try {
519
+ const V = await a({
520
+ search: l,
521
+ page: e,
522
+ limit: o.limit,
523
+ signal: u.signal
524
+ });
525
+ if (i !== ne) return;
526
+ const { data: L, more: m } = ea(V, e), I = /* @__PURE__ */ new Set();
527
+ if (e > 1)
528
+ for (const D of Z.value) {
529
+ const G = U(D);
530
+ G !== void 0 && I.add(f(G));
531
+ }
532
+ const B = [];
533
+ for (const D of L) {
534
+ const G = U(D);
535
+ G !== void 0 && (T.set(f(G), D), !I.has(f(G)) && (I.add(f(G)), B.push(D)));
536
+ }
537
+ Z.value = e === 1 ? B : [...Z.value, ...B], be = e, de = m && B.length > 0, oe = l, h("load", { search: l, page: e, options: L, hasMore: de }), Me(la);
538
+ } catch (V) {
539
+ if (i !== ne) return;
540
+ e === 1 ? (le.value = !0, Z.value = [], oe = null) : ee.value = !0, h("error", V, { type: "options", search: l, page: e });
541
+ } finally {
542
+ i === ne && (_.value = !1, N.value = !1);
543
+ }
544
+ }
545
+ function he() {
546
+ !o.fetchOptions || !de || _.value || N.value || R.value || ee.value || se(be + 1);
547
+ }
548
+ function me() {
549
+ se(ee.value ? be + 1 : 1);
550
+ }
551
+ function ge() {
552
+ ne++, E == null || E.abort(), E = null, clearTimeout(pe), R.value = !1, _.value = !1, N.value = !1;
553
+ }
554
+ function xe() {
555
+ ge(), le.value = !1, ee.value = !1, Z.value = [], be = 0, de = !1, oe = null;
556
+ }
557
+ function aa() {
558
+ xe(), k.value && se(1);
559
+ }
560
+ function ta(e) {
561
+ const a = e.currentTarget;
562
+ a.scrollTop + a.clientHeight >= a.scrollHeight - 40 && he();
563
+ }
564
+ function la() {
565
+ const e = J.value;
566
+ e && e.clientHeight > 0 && e.scrollHeight <= e.clientHeight && he();
567
+ }
568
+ const A = C(() => {
569
+ const e = O.value.trim().toLocaleLowerCase(), a = o.remote && !o.fetchOptions, l = o.fetchOptions ? Z.value : [], i = new Set(ie.value.keys());
570
+ for (const m of l) {
571
+ const I = U(m);
572
+ I !== void 0 && i.add(f(I));
573
+ }
574
+ const u = /* @__PURE__ */ new Set(), V = [], L = (m, I) => {
575
+ const B = U(m);
576
+ if (B === void 0 || u.has(f(B))) return;
577
+ const D = Oe(m, B);
578
+ I && e && !D.toLocaleLowerCase().includes(e) || (u.add(f(B)), V.push({
579
+ key: f(B),
580
+ value: B,
581
+ label: D,
582
+ option: m,
583
+ selected: We.value.has(f(B))
584
+ }));
585
+ };
586
+ if (!a || !e)
587
+ for (const m of W.value)
588
+ m.option && !i.has(m.key) && L(m.option, !0);
589
+ for (const m of o.options) L(m, !a);
590
+ for (const m of l) L(m, !1);
591
+ return V;
592
+ }), Ke = C(
593
+ () => k.value && A.value[w.value] ? `${$}-${w.value}` : void 0
594
+ ), oa = C(() => o.disabled ? "heba:cursor-not-allowed heba:border-secondary-200 heba:bg-secondary-100 heba:text-secondary-400" : o.readonly ? "heba:cursor-default heba:border-secondary-300 heba:bg-white heba:text-secondary-900" : o.error ? k.value ? "heba:cursor-pointer heba:border-danger-500 heba:bg-white heba:text-secondary-900 heba:ring-2 heba:ring-danger-200" : "heba:cursor-pointer heba:border-danger-500 heba:bg-white heba:text-secondary-900 heba:focus:ring-2 heba:focus:ring-danger-200" : k.value ? "heba:cursor-pointer heba:border-info-500 heba:bg-white heba:text-secondary-900 heba:ring-2 heba:ring-info-100" : "heba:cursor-pointer heba:border-secondary-300 heba:bg-white heba:text-secondary-900 heba:focus:border-info-500 heba:focus:ring-2 heba:focus:ring-info-100");
595
+ function na(e) {
596
+ let a = "heba:bg-secondary-100 heba:text-secondary-700";
597
+ return o.disabled ? a = "heba:bg-secondary-200 heba:text-secondary-500" : (e.status === "missing" || e.status === "error") && (a = "heba:bg-danger-50 heba:text-danger-700"), [
598
+ "heba:inline-flex heba:max-w-full heba:items-center heba:gap-1 heba:rounded-md heba:px-2 heba:py-0.5 heba:text-xs heba:font-medium",
599
+ a
600
+ ];
601
+ }
602
+ function ue() {
603
+ var e;
604
+ (e = c.value) == null || e.focus();
605
+ }
606
+ function sa() {
607
+ const e = c.value;
608
+ if (!e) return !1;
609
+ const a = e.getBoundingClientRect(), l = window.innerHeight - a.bottom;
610
+ return l < 320 && a.top > l;
611
+ }
612
+ function we() {
613
+ if (!X.value || k.value) return;
614
+ Ae.value = sa(), k.value = !0;
615
+ const e = A.value.findIndex(
616
+ (a) => a.selected
617
+ );
618
+ w.value = e >= 0 ? e : A.value.length ? 0 : -1, document.addEventListener("mousedown", ke, !0), h("open"), o.fetchOptions && oe !== O.value && se(1), Me(() => {
619
+ var a;
620
+ o.searchable && ((a = p.value) == null || a.focus()), qe();
621
+ });
622
+ }
623
+ function F(e = !1) {
624
+ k.value && (k.value = !1, document.removeEventListener("mousedown", ke, !0), oe === "" ? ge() : xe(), O.value = "", h("close"), e && ue());
625
+ }
626
+ function ke(e) {
627
+ var l;
628
+ const a = e.target;
629
+ a && ((l = g.value) != null && l.contains(a)) || F();
630
+ }
631
+ function ra(e) {
632
+ !X.value || e.button !== 0 || (e.preventDefault(), k.value ? F(!0) : (ue(), we()));
633
+ }
634
+ function ia(e) {
635
+ if (X.value) {
636
+ if (!k.value) {
637
+ ["Enter", " ", "ArrowDown", "ArrowUp"].includes(e.key) && (e.preventDefault(), we());
638
+ return;
639
+ }
640
+ if (e.key === " ") {
641
+ e.preventDefault(), Pe();
642
+ return;
643
+ }
644
+ Ue(e);
645
+ }
646
+ }
647
+ function Ue(e) {
648
+ e.key === "ArrowDown" || e.key === "ArrowUp" ? (e.preventDefault(), ba(e.key === "ArrowDown" ? 1 : -1)) : e.key === "Enter" ? (e.preventDefault(), Pe()) : e.key === "Escape" ? (e.preventDefault(), e.stopPropagation(), F(!0)) : e.key === "Tab" && F();
649
+ }
650
+ function ba(e) {
651
+ const a = A.value.length;
652
+ a && (w.value = Math.min(
653
+ Math.max(w.value + e, 0),
654
+ a - 1
655
+ ), e > 0 && w.value === a - 1 && he(), Me(qe));
656
+ }
657
+ function qe() {
658
+ var a, l;
659
+ const e = (a = J.value) == null ? void 0 : a.querySelectorAll('[role="option"]')[w.value];
660
+ (l = e == null ? void 0 : e.scrollIntoView) == null || l.call(e, { block: "nearest" });
661
+ }
662
+ function Pe() {
663
+ const e = A.value[w.value];
664
+ e && Ne(e);
665
+ }
666
+ function ce(e) {
667
+ h("update:modelValue", e);
668
+ const l = (e === null ? [] : Array.isArray(e) ? e : [e]).map((i) => Ee(f(i))).filter((i) => i !== null);
669
+ h("change", e, o.multiple ? l : l[0] ?? null);
670
+ }
671
+ function Ne(e) {
672
+ if (T.set(e.key, e.option), o.multiple) {
673
+ const a = P.value;
674
+ ce(
675
+ e.selected ? a.filter((l) => f(l) !== e.key) : [...a, e.value]
676
+ );
677
+ return;
678
+ }
679
+ e.selected || ce(e.value), F(!0);
680
+ }
681
+ function da(e) {
682
+ ce(P.value.filter((a) => f(a) !== e));
683
+ }
684
+ function ha() {
685
+ ce(o.multiple ? [] : null), h("clear");
686
+ }
687
+ Q(
688
+ () => o.valueKey,
689
+ (e) => {
690
+ te++;
691
+ const a = [...T.values()];
692
+ T.clear();
693
+ for (const l of a) {
694
+ const i = U(l, e);
695
+ i !== void 0 && T.set(f(i), l);
696
+ }
697
+ re.clear(), q.clear();
698
+ },
699
+ { flush: "sync" }
700
+ ), Q(
701
+ [() => P.value.map(f).join("\0"), ie],
702
+ Ie,
703
+ { immediate: !0 }
704
+ );
705
+ let $e = [];
706
+ return Q(
707
+ () => W.value.flatMap((e) => e.option ? [e.option] : []),
708
+ (e) => {
709
+ e.length === $e.length && e.every((a, l) => a === $e[l]) || ($e = e, h("update:selected", o.multiple ? e : e[0] ?? null));
710
+ },
711
+ { immediate: !0 }
712
+ ), Q(O, (e) => {
713
+ if (w.value = A.value.length ? 0 : -1, clearTimeout(pe), R.value = !1, !o.fetchOptions && !o.remote) {
714
+ h("search", e);
715
+ return;
716
+ }
717
+ const a = () => {
718
+ R.value = !1, h("search", e), o.fetchOptions && k.value && se(1);
719
+ };
720
+ k.value && o.debounce > 0 ? (R.value = !0, pe = setTimeout(a, o.debounce)) : a();
721
+ }), Q(
722
+ () => o.fetchOptions,
723
+ () => {
724
+ k.value || xe();
725
+ }
726
+ ), Q(
727
+ () => A.value.length,
728
+ (e) => {
729
+ e ? (w.value < 0 || w.value >= e) && (w.value = Math.min(Math.max(w.value, 0), e - 1)) : w.value = -1;
730
+ }
731
+ ), Q(X, (e) => {
732
+ e || F();
733
+ }), ya(() => {
734
+ document.removeEventListener("mousedown", ke, !0), ge(), te++;
735
+ }), d({
736
+ open: we,
737
+ close: () => F(),
738
+ focus: ue,
739
+ reload: aa,
740
+ loadMore: he,
741
+ retry: me,
742
+ retrySelected: De
743
+ }), (e, a) => (n(), s("div", {
744
+ ref_key: "rootEl",
745
+ ref: g,
746
+ class: "heba:flex heba:flex-col heba:gap-1"
747
+ }, [
748
+ t.label ? (n(), s("label", {
749
+ key: 0,
750
+ id: z,
751
+ class: H([
752
+ "heba:text-sm heba:font-semibold",
753
+ t.error ? "heba:text-danger-600" : t.disabled ? "heba:text-secondary-400" : "heba:text-secondary-900"
754
+ ]),
755
+ onClick: ue
756
+ }, [
757
+ K(x(t.label) + " ", 1),
758
+ t.required ? (n(), s("span", Pa, "*")) : v("", !0)
759
+ ], 2)) : v("", !0),
760
+ t.hint ? (n(), s("p", Na, x(t.hint), 1)) : v("", !0),
761
+ r("div", Ra, [
762
+ r("div", {
763
+ ref_key: "controlEl",
764
+ ref: c,
765
+ role: "combobox",
766
+ "aria-haspopup": "listbox",
767
+ tabindex: t.disabled ? -1 : 0,
768
+ "aria-expanded": k.value,
769
+ "aria-controls": $,
770
+ "aria-labelledby": t.label ? z : void 0,
771
+ "aria-disabled": t.disabled || void 0,
772
+ "aria-readonly": t.readonly || void 0,
773
+ "aria-invalid": t.error ? !0 : void 0,
774
+ "aria-activedescendant": t.searchable ? void 0 : Ke.value,
775
+ class: H([
776
+ "heba:flex heba:min-h-10 heba:w-full heba:items-center heba:gap-2 heba:rounded-lg heba:border heba:px-3 heba:text-sm heba:outline-none heba:transition-colors heba:duration-150",
777
+ oa.value
778
+ ]),
779
+ onMousedown: ra,
780
+ onKeydown: ia
781
+ }, [
782
+ r("div", {
783
+ class: H([
784
+ "heba:flex heba:min-w-0 heba:flex-1 heba:items-center heba:py-1.5",
785
+ t.multiple ? "heba:flex-wrap heba:gap-1.5" : ""
786
+ ])
787
+ }, [
788
+ W.value.length ? t.multiple ? (n(!0), s(ae, { key: 1 }, ye(W.value, (l) => (n(), s("span", {
789
+ key: l.key,
790
+ class: H(na(l))
791
+ }, [
792
+ l.status === "loading" ? (n(), s("span", Qa)) : (n(), s("span", Ya, [
793
+ l.option ? S(e.$slots, "selected", {
794
+ option: l.option,
795
+ label: l.label,
796
+ value: l.value
797
+ }, () => [
798
+ K(x(l.label), 1)
799
+ ], void 0, 0) : (n(), s(ae, { key: 1 }, [
800
+ K(x(l.label), 1)
801
+ ], 64))
802
+ ])),
803
+ X.value ? (n(), s("button", {
804
+ key: 2,
805
+ type: "button",
806
+ class: "heba:-mr-0.5 heba:rounded heba:p-0.5 heba:opacity-60 heba:transition-opacity heba:hover:opacity-100",
807
+ "aria-label": `Hapus ${l.label}`,
808
+ onMousedown: a[0] || (a[0] = j(() => {
809
+ }, ["stop", "prevent"])),
810
+ onClick: j((i) => da(l.key), ["stop"])
811
+ }, [...a[6] || (a[6] = [
812
+ r("svg", {
813
+ class: "heba:h-3 heba:w-3",
814
+ viewBox: "0 0 20 20",
815
+ fill: "currentColor",
816
+ "aria-hidden": "true"
817
+ }, [
818
+ r("path", { d: "M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z" })
819
+ ], -1)
820
+ ])], 40, Ja)) : v("", !0)
821
+ ], 2))), 128)) : (n(!0), s(ae, { key: 2 }, ye(W.value, (l) => (n(), s(ae, {
822
+ key: l.key
823
+ }, [
824
+ l.status === "loading" ? (n(), s("span", Wa)) : l.option ? (n(), s("span", Xa, [
825
+ S(e.$slots, "selected", {
826
+ option: l.option,
827
+ label: l.label,
828
+ value: l.value
829
+ }, () => [
830
+ K(x(l.label), 1)
831
+ ])
832
+ ])) : (n(), s("span", Za, x(l.label), 1))
833
+ ], 64))), 128)) : (n(), s("span", Ga, x(t.placeholder), 1))
834
+ ], 2),
835
+ r("div", _a, [
836
+ Ze.value && !t.disabled ? (n(), s("button", {
837
+ key: 0,
838
+ type: "button",
839
+ class: "heba:rounded heba:p-0.5 heba:text-danger-500 heba:hover:bg-danger-50",
840
+ "aria-label": "Muat ulang pilihan",
841
+ title: "Muat ulang pilihan",
842
+ onMousedown: a[1] || (a[1] = j(() => {
843
+ }, ["stop", "prevent"])),
844
+ onClick: j(De, ["stop"])
845
+ }, [...a[7] || (a[7] = [
846
+ r("svg", {
847
+ class: "heba:h-4 heba:w-4",
848
+ viewBox: "0 0 20 20",
849
+ fill: "currentColor",
850
+ "aria-hidden": "true"
851
+ }, [
852
+ r("path", {
853
+ "fill-rule": "evenodd",
854
+ d: "M15.312 11.424a5.5 5.5 0 01-9.201 2.466l-.312-.311h2.433a.75.75 0 000-1.5H3.989a.75.75 0 00-.75.75v4.242a.75.75 0 001.5 0v-2.43l.31.31a7 7 0 0011.712-3.138.75.75 0 00-1.449-.39zm1.23-3.723a.75.75 0 00.219-.53V2.929a.75.75 0 00-1.5 0V5.36l-.31-.31A7 7 0 003.239 8.188a.75.75 0 101.448.389A5.5 5.5 0 0113.89 6.11l.311.31h-2.432a.75.75 0 000 1.5h4.243a.75.75 0 00.53-.219z",
855
+ "clip-rule": "evenodd"
856
+ })
857
+ ], -1)
858
+ ])], 32)) : v("", !0),
859
+ Xe.value ? (n(), s("button", {
860
+ key: 1,
861
+ type: "button",
862
+ class: "heba:rounded heba:p-0.5 heba:text-secondary-400 heba:hover:bg-secondary-100 heba:hover:text-secondary-600",
863
+ "aria-label": "Kosongkan pilihan",
864
+ onMousedown: a[2] || (a[2] = j(() => {
865
+ }, ["stop", "prevent"])),
866
+ onClick: j(ha, ["stop"])
867
+ }, [...a[8] || (a[8] = [
868
+ r("svg", {
869
+ class: "heba:h-4 heba:w-4",
870
+ viewBox: "0 0 20 20",
871
+ fill: "currentColor",
872
+ "aria-hidden": "true"
873
+ }, [
874
+ r("path", { d: "M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z" })
875
+ ], -1)
876
+ ])], 32)) : v("", !0),
877
+ t.readonly ? v("", !0) : (n(), s("svg", {
878
+ key: 2,
879
+ class: H([
880
+ "heba:h-4 heba:w-4 heba:transition-transform heba:duration-150",
881
+ t.disabled ? "heba:text-secondary-300" : "heba:text-secondary-500",
882
+ k.value ? "heba:rotate-180" : ""
883
+ ]),
884
+ viewBox: "0 0 20 20",
885
+ fill: "currentColor",
886
+ "aria-hidden": "true"
887
+ }, [...a[9] || (a[9] = [
888
+ r("path", {
889
+ "fill-rule": "evenodd",
890
+ d: "M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",
891
+ "clip-rule": "evenodd"
892
+ }, null, -1)
893
+ ])], 2))
894
+ ])
895
+ ], 42, Fa),
896
+ k.value ? (n(), s("div", {
897
+ key: 0,
898
+ class: H([
899
+ "heba:absolute heba:inset-x-0 heba:z-50 heba:overflow-hidden heba:rounded-lg heba:border heba:border-secondary-200 heba:bg-white heba:shadow-lg",
900
+ Ae.value ? "heba:bottom-full heba:mb-1" : "heba:top-full heba:mt-1"
901
+ ])
902
+ }, [
903
+ t.searchable ? (n(), s("div", et, [
904
+ r("div", at, [
905
+ a[11] || (a[11] = r("svg", {
906
+ class: "heba:pointer-events-none heba:absolute heba:left-2.5 heba:h-4 heba:w-4 heba:text-secondary-400",
907
+ viewBox: "0 0 20 20",
908
+ fill: "currentColor",
909
+ "aria-hidden": "true"
910
+ }, [
911
+ r("path", {
912
+ "fill-rule": "evenodd",
913
+ d: "M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z",
914
+ "clip-rule": "evenodd"
915
+ })
916
+ ], -1)),
917
+ ve(r("input", {
918
+ ref_key: "searchEl",
919
+ ref: p,
920
+ "onUpdate:modelValue": a[3] || (a[3] = (l) => O.value = l),
921
+ type: "text",
922
+ autocomplete: "off",
923
+ "aria-label": "Cari opsi",
924
+ "aria-autocomplete": "list",
925
+ "aria-controls": $,
926
+ "aria-activedescendant": Ke.value,
927
+ placeholder: t.searchPlaceholder,
928
+ class: "heba:h-9 heba:w-full heba:rounded-md heba:border heba:border-secondary-300 heba:bg-white heba:pl-8 heba:pr-8 heba:text-sm heba:text-secondary-900 heba:outline-none heba:placeholder:text-secondary-400 heba:focus:border-info-500 heba:focus:ring-2 heba:focus:ring-info-100",
929
+ onKeydown: Ue
930
+ }, null, 40, tt), [
931
+ [Ge, O.value]
932
+ ]),
933
+ je.value && A.value.length ? (n(), s("svg", lt, [...a[10] || (a[10] = [
934
+ r("circle", {
935
+ class: "heba:opacity-25",
936
+ cx: "12",
937
+ cy: "12",
938
+ r: "10",
939
+ stroke: "currentColor",
940
+ "stroke-width": "4"
941
+ }, null, -1),
942
+ r("path", {
943
+ class: "heba:opacity-75",
944
+ fill: "currentColor",
945
+ d: "M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"
946
+ }, null, -1)
947
+ ])])) : v("", !0)
948
+ ])
949
+ ])) : v("", !0),
950
+ A.value.length ? (n(), s("ul", {
951
+ key: 2,
952
+ id: $,
953
+ ref_key: "listEl",
954
+ ref: J,
955
+ role: "listbox",
956
+ "aria-multiselectable": t.multiple || void 0,
957
+ "aria-labelledby": t.label ? z : void 0,
958
+ class: "heba:max-h-60 heba:overflow-y-auto heba:py-1",
959
+ onScrollPassive: ta,
960
+ onMousedown: a[5] || (a[5] = j(() => {
961
+ }, ["prevent"]))
962
+ }, [
963
+ (n(!0), s(ae, null, ye(A.value, (l, i) => (n(), s("li", {
964
+ id: `${$}-${i}`,
965
+ key: l.key,
966
+ role: "option",
967
+ "aria-selected": l.selected,
968
+ class: H([
969
+ "heba:flex heba:cursor-pointer heba:items-center heba:gap-2 heba:px-3 heba:py-2 heba:text-sm",
970
+ i === w.value ? "heba:bg-secondary-100" : "",
971
+ l.selected ? "heba:font-medium heba:text-info-700" : "heba:text-secondary-900"
972
+ ]),
973
+ onMouseenter: (u) => w.value = i,
974
+ onClick: (u) => Ne(l)
975
+ }, [
976
+ r("span", bt, [
977
+ S(e.$slots, "option", {
978
+ option: l.option,
979
+ label: l.label,
980
+ value: l.value,
981
+ selected: l.selected,
982
+ active: i === w.value
983
+ }, () => [
984
+ r("span", dt, x(l.label), 1)
985
+ ])
986
+ ]),
987
+ l.selected ? (n(), s("svg", ht, [...a[14] || (a[14] = [
988
+ r("path", {
989
+ "fill-rule": "evenodd",
990
+ d: "M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z",
991
+ "clip-rule": "evenodd"
992
+ }, null, -1)
993
+ ])])) : v("", !0)
994
+ ], 42, it))), 128)),
995
+ N.value || _.value && !t.searchable ? (n(), s("li", ut, [
996
+ a[15] || (a[15] = r("svg", {
997
+ class: "heba:h-3.5 heba:w-3.5 heba:animate-spin",
998
+ viewBox: "0 0 24 24",
999
+ fill: "none",
1000
+ "aria-hidden": "true"
1001
+ }, [
1002
+ r("circle", {
1003
+ class: "heba:opacity-25",
1004
+ cx: "12",
1005
+ cy: "12",
1006
+ r: "10",
1007
+ stroke: "currentColor",
1008
+ "stroke-width": "4"
1009
+ }),
1010
+ r("path", {
1011
+ class: "heba:opacity-75",
1012
+ fill: "currentColor",
1013
+ d: "M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"
1014
+ })
1015
+ ], -1)),
1016
+ K(" " + x(N.value ? "Memuat lebih banyak..." : "Memuat..."), 1)
1017
+ ])) : le.value || ee.value ? (n(), s("li", ct, [
1018
+ a[16] || (a[16] = r("span", null, "Gagal memuat data.", -1)),
1019
+ r("button", {
1020
+ type: "button",
1021
+ class: "heba:font-semibold heba:underline-offset-2 heba:hover:underline",
1022
+ onClick: me
1023
+ }, " Coba lagi ")
1024
+ ])) : v("", !0)
1025
+ ], 40, rt)) : (n(), s("div", {
1026
+ key: 1,
1027
+ class: "heba:px-3 heba:py-6 heba:text-center heba:text-sm",
1028
+ onMousedown: a[4] || (a[4] = j(() => {
1029
+ }, ["prevent"]))
1030
+ }, [
1031
+ je.value ? (n(), s("div", ot, [...a[12] || (a[12] = [
1032
+ r("svg", {
1033
+ class: "heba:h-4 heba:w-4 heba:animate-spin",
1034
+ viewBox: "0 0 24 24",
1035
+ fill: "none",
1036
+ "aria-hidden": "true"
1037
+ }, [
1038
+ r("circle", {
1039
+ class: "heba:opacity-25",
1040
+ cx: "12",
1041
+ cy: "12",
1042
+ r: "10",
1043
+ stroke: "currentColor",
1044
+ "stroke-width": "4"
1045
+ }),
1046
+ r("path", {
1047
+ class: "heba:opacity-75",
1048
+ fill: "currentColor",
1049
+ d: "M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"
1050
+ })
1051
+ ], -1),
1052
+ K(" Memuat... ", -1)
1053
+ ])])) : le.value ? (n(), s("div", nt, [
1054
+ a[13] || (a[13] = r("span", null, "Gagal memuat data.", -1)),
1055
+ r("button", {
1056
+ type: "button",
1057
+ class: "heba:rounded-md heba:border heba:border-danger-200 heba:px-3 heba:py-1 heba:text-xs heba:font-semibold heba:hover:bg-danger-50",
1058
+ onClick: me
1059
+ }, " Coba lagi ")
1060
+ ])) : (n(), s("div", st, [
1061
+ S(e.$slots, "empty", { search: O.value }, () => [
1062
+ K(x(t.emptyText), 1)
1063
+ ])
1064
+ ]))
1065
+ ], 32))
1066
+ ], 2)) : v("", !0)
1067
+ ]),
1068
+ t.error ? (n(), s("p", ft, x(t.error), 1)) : v("", !0)
1069
+ ], 512));
1070
+ }
1071
+ }), yt = {
1072
+ key: 0,
1073
+ class: "heba:flex heba:items-center heba:gap-3 heba:bg-white heba:rounded-xl heba:shadow-lg heba:overflow-hidden heba:min-w-72 heba:max-w-sm heba:pr-4 heba:py-3",
1074
+ role: "alert"
1075
+ }, pt = {
1076
+ key: 0,
1077
+ class: "heba:w-4 heba:h-4 heba:text-white",
1078
+ viewBox: "0 0 20 20",
1079
+ fill: "currentColor"
1080
+ }, mt = {
1081
+ key: 1,
1082
+ class: "heba:w-4 heba:h-4 heba:text-white",
1083
+ viewBox: "0 0 20 20",
1084
+ fill: "currentColor"
1085
+ }, gt = {
1086
+ key: 2,
1087
+ class: "heba:w-4 heba:h-4 heba:text-white",
1088
+ viewBox: "0 0 20 20",
1089
+ fill: "currentColor"
1090
+ }, xt = {
1091
+ key: 3,
1092
+ class: "heba:w-4 heba:h-4 heba:text-white",
1093
+ viewBox: "0 0 20 20",
1094
+ fill: "currentColor"
1095
+ }, wt = { class: "heba:text-sm heba:font-semibold heba:text-secondary-900 heba:flex-1" }, Je = /* @__PURE__ */ Y({
1096
+ __name: "HebaToast",
1097
+ props: {
1098
+ message: {},
1099
+ variant: { default: "info" },
1100
+ visible: { type: Boolean, default: !0 }
1101
+ },
1102
+ setup(t) {
1103
+ const d = t, b = C(() => ({
1104
+ success: "heba:bg-success-500",
1105
+ danger: "heba:bg-danger-500",
1106
+ warning: "heba:bg-warning-600",
1107
+ info: "heba:bg-info-500"
1108
+ })[d.variant]), o = C(() => ({
1109
+ success: "heba:bg-success-500",
1110
+ danger: "heba:bg-danger-500",
1111
+ warning: "heba:bg-warning-600",
1112
+ info: "heba:bg-info-500"
1113
+ })[d.variant]);
1114
+ return (h, y) => (n(), Te(He, {
1115
+ "enter-active-class": "heba:transition heba:duration-300 heba:ease-out",
1116
+ "enter-from-class": "heba:translate-x-full heba:opacity-0",
1117
+ "enter-to-class": "heba:translate-x-0 heba:opacity-100",
1118
+ "leave-active-class": "heba:transition heba:duration-200 heba:ease-in",
1119
+ "leave-from-class": "heba:translate-x-0 heba:opacity-100",
1120
+ "leave-to-class": "heba:translate-x-full heba:opacity-0"
1121
+ }, {
1122
+ default: Se(() => [
1123
+ t.visible ? (n(), s("div", yt, [
1124
+ r("div", {
1125
+ class: H(["heba:w-1 heba:self-stretch heba:rounded-r-full heba:shrink-0", b.value])
1126
+ }, null, 2),
1127
+ r("div", {
1128
+ class: H(["heba:flex heba:items-center heba:justify-center heba:w-8 heba:h-8 heba:rounded-full heba:shrink-0", o.value])
1129
+ }, [
1130
+ t.variant === "success" ? (n(), s("svg", pt, [...y[0] || (y[0] = [
1131
+ r("path", {
1132
+ "fill-rule": "evenodd",
1133
+ d: "M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z",
1134
+ "clip-rule": "evenodd"
1135
+ }, null, -1)
1136
+ ])])) : t.variant === "danger" ? (n(), s("svg", mt, [...y[1] || (y[1] = [
1137
+ r("path", { d: "M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z" }, null, -1)
1138
+ ])])) : t.variant === "warning" ? (n(), s("svg", gt, [...y[2] || (y[2] = [
1139
+ r("path", {
1140
+ "fill-rule": "evenodd",
1141
+ d: "M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495zM10 5a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 0110 5zm0 9a1 1 0 100-2 1 1 0 000 2z",
1142
+ "clip-rule": "evenodd"
1143
+ }, null, -1)
1144
+ ])])) : (n(), s("svg", xt, [...y[3] || (y[3] = [
1145
+ r("path", {
1146
+ "fill-rule": "evenodd",
1147
+ d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",
1148
+ "clip-rule": "evenodd"
1149
+ }, null, -1)
1150
+ ])]))
1151
+ ], 2),
1152
+ r("p", wt, x(t.message), 1)
1153
+ ])) : v("", !0)
1154
+ ]),
1155
+ _: 1
1156
+ }));
1157
+ }
1158
+ }), Le = Symbol.for("heba-toast");
1159
+ let kt = 0;
1160
+ function $t() {
1161
+ const t = M([]);
1162
+ function d(b, o = "info", h = 3e3) {
1163
+ const y = ++kt;
1164
+ t.value.push({ id: y, message: b, variant: o, visible: !0 }), setTimeout(() => {
1165
+ const z = t.value.find(($) => $.id === y);
1166
+ z && (z.visible = !1), setTimeout(() => {
1167
+ t.value = t.value.filter(($) => $.id !== y);
1168
+ }, 250);
1169
+ }, h);
1170
+ }
1171
+ return { toasts: t, add: d };
1172
+ }
1173
+ const Mt = { class: "heba:fixed heba:top-4 heba:right-4 heba:z-[9999] heba:flex heba:flex-col heba:gap-3 heba:pointer-events-none" }, Ct = /* @__PURE__ */ Y({
1174
+ __name: "HebaToastContainer",
1175
+ setup(t) {
1176
+ const { toasts: d } = Ye(Le);
1177
+ return (b, o) => (n(), Te(Qe, { to: "body" }, [
1178
+ r("div", Mt, [
1179
+ (n(!0), s(ae, null, ye(pa(d), (h) => (n(), s("div", {
1180
+ key: h.id,
1181
+ class: "heba:pointer-events-auto"
1182
+ }, [
1183
+ Be(Je, {
1184
+ message: h.message,
1185
+ variant: h.variant,
1186
+ visible: h.visible
1187
+ }, null, 8, ["message", "variant", "visible"])
1188
+ ]))), 128))
1189
+ ])
1190
+ ]));
1191
+ }
1192
+ }), Bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1193
+ __proto__: null,
1194
+ HebaBadge: ma,
1195
+ HebaButton: xa,
1196
+ HebaInput: Oa,
1197
+ HebaModal: qa,
1198
+ HebaSelect2: vt,
1199
+ HebaToast: Je,
1200
+ HebaToastContainer: Ct
1201
+ }, Symbol.toStringTag, { value: "Module" }));
1202
+ function St() {
1203
+ const t = Ye(Le);
1204
+ if (!t)
1205
+ throw new Error("[HebaUI] useToast() requires HebaToastContainer to be mounted and HebaUI plugin installed.");
1206
+ return {
1207
+ success: (d, b) => t.add(d, "success", b),
1208
+ danger: (d, b) => t.add(d, "danger", b),
1209
+ warning: (d, b) => t.add(d, "warning", b),
1210
+ info: (d, b) => t.add(d, "info", b),
1211
+ show: (d, b = "info", o) => t.add(d, b, o)
1212
+ };
1213
+ }
1214
+ const zt = {
1215
+ install(t) {
1216
+ for (const [b, o] of Object.entries(Bt))
1217
+ t.component(b, o);
1218
+ const d = $t();
1219
+ t.provide(Le, d);
1220
+ }
1221
+ };
1222
+ export {
1223
+ ma as HebaBadge,
1224
+ xa as HebaButton,
1225
+ Oa as HebaInput,
1226
+ qa as HebaModal,
1227
+ vt as HebaSelect2,
1228
+ Je as HebaToast,
1229
+ Ct as HebaToastContainer,
1230
+ zt as HebaUI,
1231
+ Le as TOAST_STATE_KEY,
1232
+ $t as createToastState,
1233
+ zt as default,
1234
+ St as useToast
1235
+ };