akaza-ui 0.0.1-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +115 -0
  3. package/dist/akaza-ui.cjs +3292 -0
  4. package/dist/akaza-ui.cjs.map +1 -0
  5. package/dist/akaza-ui.css +384 -0
  6. package/dist/akaza-ui.js +3292 -0
  7. package/dist/akaza-ui.js.map +1 -0
  8. package/dist/nuxt.cjs +43 -0
  9. package/dist/nuxt.cjs.map +1 -0
  10. package/dist/nuxt.js +44 -0
  11. package/dist/nuxt.js.map +1 -0
  12. package/dist/types/components/accordion/Accordion.vue.d.ts +51 -0
  13. package/dist/types/components/accordion/index.d.ts +37 -0
  14. package/dist/types/components/alert-dialog/AlertDialog.vue.d.ts +60 -0
  15. package/dist/types/components/alert-dialog/index.d.ts +21 -0
  16. package/dist/types/components/avatar/Avatar.vue.d.ts +25 -0
  17. package/dist/types/components/avatar/index.d.ts +17 -0
  18. package/dist/types/components/button/Button.vue.d.ts +23 -0
  19. package/dist/types/components/button/index.d.ts +20 -0
  20. package/dist/types/components/checkbox/Checkbox.vue.d.ts +33 -0
  21. package/dist/types/components/checkbox/index.d.ts +29 -0
  22. package/dist/types/components/collapsible/Collapsible.vue.d.ts +48 -0
  23. package/dist/types/components/collapsible/index.d.ts +13 -0
  24. package/dist/types/components/dialog/Dialog.vue.d.ts +61 -0
  25. package/dist/types/components/dialog/index.d.ts +21 -0
  26. package/dist/types/components/drawer/Drawer.vue.d.ts +63 -0
  27. package/dist/types/components/drawer/index.d.ts +23 -0
  28. package/dist/types/components/menu/Menu.vue.d.ts +102 -0
  29. package/dist/types/components/menu/MenuPanel.vue.d.ts +14 -0
  30. package/dist/types/components/menu/context.d.ts +17 -0
  31. package/dist/types/components/menu/index.d.ts +54 -0
  32. package/dist/types/components/overlay/OverlayProvider.vue.d.ts +2 -0
  33. package/dist/types/components/overlay/index.d.ts +1 -0
  34. package/dist/types/components/popover/Popover.vue.d.ts +55 -0
  35. package/dist/types/components/popover/index.d.ts +14 -0
  36. package/dist/types/components/progress/Progress.vue.d.ts +32 -0
  37. package/dist/types/components/progress/index.d.ts +14 -0
  38. package/dist/types/components/radio-group/RadioGroup.vue.d.ts +37 -0
  39. package/dist/types/components/radio-group/index.d.ts +30 -0
  40. package/dist/types/components/separator/Separator.vue.d.ts +3 -0
  41. package/dist/types/components/separator/index.d.ts +6 -0
  42. package/dist/types/components/switch/Switch.vue.d.ts +33 -0
  43. package/dist/types/components/switch/index.d.ts +29 -0
  44. package/dist/types/components/tabs/Tabs.vue.d.ts +37 -0
  45. package/dist/types/components/tabs/index.d.ts +28 -0
  46. package/dist/types/components/toggle/Toggle.vue.d.ts +29 -0
  47. package/dist/types/components/toggle/index.d.ts +11 -0
  48. package/dist/types/components/tooltip/Tooltip.vue.d.ts +38 -0
  49. package/dist/types/components/tooltip/index.d.ts +17 -0
  50. package/dist/types/composables/alert-dialog/index.d.ts +2 -0
  51. package/dist/types/composables/alert-dialog/useAlertDialog.d.ts +8 -0
  52. package/dist/types/composables/dialog/index.d.ts +2 -0
  53. package/dist/types/composables/dialog/useDialog.d.ts +8 -0
  54. package/dist/types/composables/drawer/index.d.ts +2 -0
  55. package/dist/types/composables/drawer/useDrawer.d.ts +9 -0
  56. package/dist/types/composables/menu/index.d.ts +2 -0
  57. package/dist/types/composables/menu/useMenu.d.ts +8 -0
  58. package/dist/types/composables/overlay/index.d.ts +2 -0
  59. package/dist/types/composables/overlay/useOverlay.d.ts +46 -0
  60. package/dist/types/composables/popover/index.d.ts +2 -0
  61. package/dist/types/composables/popover/usePopover.d.ts +8 -0
  62. package/dist/types/composables/tooltip/index.d.ts +2 -0
  63. package/dist/types/composables/tooltip/useTooltip.d.ts +12 -0
  64. package/dist/types/index.d.ts +20 -0
  65. package/dist/types/types.d.ts +17 -0
  66. package/dist/types/utils/dismissableLayer.d.ts +4 -0
  67. package/dist/types/utils/focusScope.d.ts +10 -0
  68. package/dist/types/utils/focusable.d.ts +1 -0
  69. package/package.json +92 -0
@@ -0,0 +1,3292 @@
1
+ import { toRef as toRef$1, readonly, customRef, ref, onMounted, nextTick, effectScope, watch, getCurrentScope, onScopeDispose, getCurrentInstance, reactive, computed, shallowRef, toValue, unref, defineComponent, useModel, useTemplateRef, openBlock, createBlock, resolveDynamicComponent, withCtx, createElementBlock, Fragment, renderList, normalizeClass, createElementVNode, renderSlot, createTextVNode, toDisplayString, createCommentVNode, mergeModels, onUnmounted, useId, Teleport, createVNode, Transition, normalizeStyle, normalizeProps, guardReactiveProps, withDirectives, vShow, useSlots, withKeys, withModifiers, inject, resolveComponent, provide, mergeProps } from "vue";
2
+ function tryOnScopeDispose(fn) {
3
+ if (getCurrentScope()) {
4
+ onScopeDispose(fn);
5
+ return true;
6
+ }
7
+ return false;
8
+ }
9
+ // @__NO_SIDE_EFFECTS__
10
+ function createGlobalState(stateFactory) {
11
+ let initialized = false;
12
+ let state;
13
+ const scope = effectScope(true);
14
+ return (...args) => {
15
+ if (!initialized) {
16
+ state = scope.run(() => stateFactory(...args));
17
+ initialized = true;
18
+ }
19
+ return state;
20
+ };
21
+ }
22
+ // @__NO_SIDE_EFFECTS__
23
+ function createSharedComposable(composable) {
24
+ let subscribers = 0;
25
+ let state;
26
+ let scope;
27
+ const dispose = () => {
28
+ subscribers -= 1;
29
+ if (scope && subscribers <= 0) {
30
+ scope.stop();
31
+ state = void 0;
32
+ scope = void 0;
33
+ }
34
+ };
35
+ return (...args) => {
36
+ subscribers += 1;
37
+ if (!scope) {
38
+ scope = effectScope(true);
39
+ state = scope.run(() => composable(...args));
40
+ }
41
+ tryOnScopeDispose(dispose);
42
+ return state;
43
+ };
44
+ }
45
+ const isClient = typeof window !== "undefined" && typeof document !== "undefined";
46
+ typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
47
+ const toString = Object.prototype.toString;
48
+ const isObject = (val) => toString.call(val) === "[object Object]";
49
+ const noop = () => {
50
+ };
51
+ const isIOS = /* @__PURE__ */ getIsIOS();
52
+ function getIsIOS() {
53
+ var _a, _b;
54
+ return isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((_b = window == null ? void 0 : window.navigator) == null ? void 0 : _b.maxTouchPoints) > 2 && /iPad|Macintosh/.test(window == null ? void 0 : window.navigator.userAgent));
55
+ }
56
+ function toRef(...args) {
57
+ if (args.length !== 1)
58
+ return toRef$1(...args);
59
+ const r = args[0];
60
+ return typeof r === "function" ? readonly(customRef(() => ({ get: r, set: noop }))) : ref(r);
61
+ }
62
+ function toArray(value) {
63
+ return Array.isArray(value) ? value : [value];
64
+ }
65
+ function getLifeCycleTarget(target) {
66
+ return getCurrentInstance();
67
+ }
68
+ function tryOnMounted(fn, sync = true, target) {
69
+ const instance = getLifeCycleTarget();
70
+ if (instance)
71
+ onMounted(fn, target);
72
+ else if (sync)
73
+ fn();
74
+ else
75
+ nextTick(fn);
76
+ }
77
+ function watchImmediate(source, cb, options) {
78
+ return watch(
79
+ source,
80
+ cb,
81
+ {
82
+ ...options,
83
+ immediate: true
84
+ }
85
+ );
86
+ }
87
+ const defaultWindow = isClient ? window : void 0;
88
+ function unrefElement(elRef) {
89
+ var _a;
90
+ const plain = toValue(elRef);
91
+ return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
92
+ }
93
+ function useEventListener(...args) {
94
+ const cleanups = [];
95
+ const cleanup = () => {
96
+ cleanups.forEach((fn) => fn());
97
+ cleanups.length = 0;
98
+ };
99
+ const register = (el, event, listener, options) => {
100
+ el.addEventListener(event, listener, options);
101
+ return () => el.removeEventListener(event, listener, options);
102
+ };
103
+ const firstParamTargets = computed(() => {
104
+ const test = toArray(toValue(args[0])).filter((e) => e != null);
105
+ return test.every((e) => typeof e !== "string") ? test : void 0;
106
+ });
107
+ const stopWatch = watchImmediate(
108
+ () => {
109
+ var _a, _b;
110
+ return [
111
+ (_b = (_a = firstParamTargets.value) == null ? void 0 : _a.map((e) => unrefElement(e))) != null ? _b : [defaultWindow].filter((e) => e != null),
112
+ toArray(toValue(firstParamTargets.value ? args[1] : args[0])),
113
+ toArray(unref(firstParamTargets.value ? args[2] : args[1])),
114
+ // @ts-expect-error - TypeScript gets the correct types, but somehow still complains
115
+ toValue(firstParamTargets.value ? args[3] : args[2])
116
+ ];
117
+ },
118
+ ([raw_targets, raw_events, raw_listeners, raw_options]) => {
119
+ cleanup();
120
+ if (!(raw_targets == null ? void 0 : raw_targets.length) || !(raw_events == null ? void 0 : raw_events.length) || !(raw_listeners == null ? void 0 : raw_listeners.length))
121
+ return;
122
+ const optionsClone = isObject(raw_options) ? { ...raw_options } : raw_options;
123
+ cleanups.push(
124
+ ...raw_targets.flatMap(
125
+ (el) => raw_events.flatMap(
126
+ (event) => raw_listeners.map((listener) => register(el, event, listener, optionsClone))
127
+ )
128
+ )
129
+ );
130
+ },
131
+ { flush: "post" }
132
+ );
133
+ const stop = () => {
134
+ stopWatch();
135
+ cleanup();
136
+ };
137
+ tryOnScopeDispose(cleanup);
138
+ return stop;
139
+ }
140
+ let _iOSWorkaround = false;
141
+ function onClickOutside(target, handler, options = {}) {
142
+ const { window: window2 = defaultWindow, ignore = [], capture = true, detectIframe = false, controls = false } = options;
143
+ if (!window2) {
144
+ return controls ? { stop: noop, cancel: noop, trigger: noop } : noop;
145
+ }
146
+ if (isIOS && !_iOSWorkaround) {
147
+ _iOSWorkaround = true;
148
+ const listenerOptions = { passive: true };
149
+ Array.from(window2.document.body.children).forEach((el) => el.addEventListener("click", noop, listenerOptions));
150
+ window2.document.documentElement.addEventListener("click", noop, listenerOptions);
151
+ }
152
+ let shouldListen = true;
153
+ const shouldIgnore = (event) => {
154
+ return toValue(ignore).some((target2) => {
155
+ if (typeof target2 === "string") {
156
+ return Array.from(window2.document.querySelectorAll(target2)).some((el) => el === event.target || event.composedPath().includes(el));
157
+ } else {
158
+ const el = unrefElement(target2);
159
+ return el && (event.target === el || event.composedPath().includes(el));
160
+ }
161
+ });
162
+ };
163
+ function hasMultipleRoots(target2) {
164
+ const vm = toValue(target2);
165
+ return vm && vm.$.subTree.shapeFlag === 16;
166
+ }
167
+ function checkMultipleRoots(target2, event) {
168
+ const vm = toValue(target2);
169
+ const children = vm.$.subTree && vm.$.subTree.children;
170
+ if (children == null || !Array.isArray(children))
171
+ return false;
172
+ return children.some((child) => child.el === event.target || event.composedPath().includes(child.el));
173
+ }
174
+ const listener = (event) => {
175
+ const el = unrefElement(target);
176
+ if (event.target == null)
177
+ return;
178
+ if (!(el instanceof Element) && hasMultipleRoots(target) && checkMultipleRoots(target, event))
179
+ return;
180
+ if (!el || el === event.target || event.composedPath().includes(el))
181
+ return;
182
+ if ("detail" in event && event.detail === 0)
183
+ shouldListen = !shouldIgnore(event);
184
+ if (!shouldListen) {
185
+ shouldListen = true;
186
+ return;
187
+ }
188
+ handler(event);
189
+ };
190
+ let isProcessingClick = false;
191
+ const cleanup = [
192
+ useEventListener(window2, "click", (event) => {
193
+ if (!isProcessingClick) {
194
+ isProcessingClick = true;
195
+ setTimeout(() => {
196
+ isProcessingClick = false;
197
+ }, 0);
198
+ listener(event);
199
+ }
200
+ }, { passive: true, capture }),
201
+ useEventListener(window2, "pointerdown", (e) => {
202
+ const el = unrefElement(target);
203
+ shouldListen = !shouldIgnore(e) && !!(el && !e.composedPath().includes(el));
204
+ }, { passive: true }),
205
+ detectIframe && useEventListener(window2, "blur", (event) => {
206
+ setTimeout(() => {
207
+ var _a;
208
+ const el = unrefElement(target);
209
+ if (((_a = window2.document.activeElement) == null ? void 0 : _a.tagName) === "IFRAME" && !(el == null ? void 0 : el.contains(window2.document.activeElement))) {
210
+ handler(event);
211
+ }
212
+ }, 0);
213
+ }, { passive: true })
214
+ ].filter(Boolean);
215
+ const stop = () => cleanup.forEach((fn) => fn());
216
+ if (controls) {
217
+ return {
218
+ stop,
219
+ cancel: () => {
220
+ shouldListen = false;
221
+ },
222
+ trigger: (event) => {
223
+ shouldListen = true;
224
+ listener(event);
225
+ shouldListen = false;
226
+ }
227
+ };
228
+ }
229
+ return stop;
230
+ }
231
+ function createKeyPredicate(keyFilter) {
232
+ if (typeof keyFilter === "function")
233
+ return keyFilter;
234
+ else if (typeof keyFilter === "string")
235
+ return (event) => event.key === keyFilter;
236
+ else if (Array.isArray(keyFilter))
237
+ return (event) => keyFilter.includes(event.key);
238
+ return () => true;
239
+ }
240
+ function onKeyStroke(...args) {
241
+ let key;
242
+ let handler;
243
+ let options = {};
244
+ if (args.length === 3) {
245
+ key = args[0];
246
+ handler = args[1];
247
+ options = args[2];
248
+ } else if (args.length === 2) {
249
+ if (typeof args[1] === "object") {
250
+ key = true;
251
+ handler = args[0];
252
+ options = args[1];
253
+ } else {
254
+ key = args[0];
255
+ handler = args[1];
256
+ }
257
+ } else {
258
+ key = true;
259
+ handler = args[0];
260
+ }
261
+ const {
262
+ target = defaultWindow,
263
+ eventName = "keydown",
264
+ passive = false,
265
+ dedupe = false
266
+ } = options;
267
+ const predicate = createKeyPredicate(key);
268
+ const listener = (e) => {
269
+ if (e.repeat && toValue(dedupe))
270
+ return;
271
+ if (predicate(e))
272
+ handler(e);
273
+ };
274
+ return useEventListener(target, eventName, listener, passive);
275
+ }
276
+ function usePointerSwipe(target, options = {}) {
277
+ const targetRef = toRef(target);
278
+ const {
279
+ threshold = 50,
280
+ onSwipe,
281
+ onSwipeEnd,
282
+ onSwipeStart,
283
+ disableTextSelect = false
284
+ } = options;
285
+ const posStart = reactive({ x: 0, y: 0 });
286
+ const updatePosStart = (x, y) => {
287
+ posStart.x = x;
288
+ posStart.y = y;
289
+ };
290
+ const posEnd = reactive({ x: 0, y: 0 });
291
+ const updatePosEnd = (x, y) => {
292
+ posEnd.x = x;
293
+ posEnd.y = y;
294
+ };
295
+ const distanceX = computed(() => posStart.x - posEnd.x);
296
+ const distanceY = computed(() => posStart.y - posEnd.y);
297
+ const { max, abs } = Math;
298
+ const isThresholdExceeded = computed(() => max(abs(distanceX.value), abs(distanceY.value)) >= threshold);
299
+ const isSwiping = shallowRef(false);
300
+ const isPointerDown = shallowRef(false);
301
+ const direction = computed(() => {
302
+ if (!isThresholdExceeded.value)
303
+ return "none";
304
+ if (abs(distanceX.value) > abs(distanceY.value)) {
305
+ return distanceX.value > 0 ? "left" : "right";
306
+ } else {
307
+ return distanceY.value > 0 ? "up" : "down";
308
+ }
309
+ });
310
+ const eventIsAllowed = (e) => {
311
+ var _a, _b, _c;
312
+ const isReleasingButton = e.buttons === 0;
313
+ const isPrimaryButton = e.buttons === 1;
314
+ return (_c = (_b = (_a = options.pointerTypes) == null ? void 0 : _a.includes(e.pointerType)) != null ? _b : isReleasingButton || isPrimaryButton) != null ? _c : true;
315
+ };
316
+ const listenerOptions = { passive: true };
317
+ const stops = [
318
+ useEventListener(target, "pointerdown", (e) => {
319
+ if (!eventIsAllowed(e))
320
+ return;
321
+ isPointerDown.value = true;
322
+ const eventTarget = e.target;
323
+ eventTarget == null ? void 0 : eventTarget.setPointerCapture(e.pointerId);
324
+ const { clientX: x, clientY: y } = e;
325
+ updatePosStart(x, y);
326
+ updatePosEnd(x, y);
327
+ onSwipeStart == null ? void 0 : onSwipeStart(e);
328
+ }, listenerOptions),
329
+ useEventListener(target, "pointermove", (e) => {
330
+ if (!eventIsAllowed(e))
331
+ return;
332
+ if (!isPointerDown.value)
333
+ return;
334
+ const { clientX: x, clientY: y } = e;
335
+ updatePosEnd(x, y);
336
+ if (!isSwiping.value && isThresholdExceeded.value)
337
+ isSwiping.value = true;
338
+ if (isSwiping.value)
339
+ onSwipe == null ? void 0 : onSwipe(e);
340
+ }, listenerOptions),
341
+ useEventListener(target, "pointerup", (e) => {
342
+ if (!eventIsAllowed(e))
343
+ return;
344
+ if (isSwiping.value)
345
+ onSwipeEnd == null ? void 0 : onSwipeEnd(e, direction.value);
346
+ isPointerDown.value = false;
347
+ isSwiping.value = false;
348
+ }, listenerOptions)
349
+ ];
350
+ tryOnMounted(() => {
351
+ var _a, _b, _c, _d, _e, _f, _g, _h;
352
+ (_b = (_a = targetRef.value) == null ? void 0 : _a.style) == null ? void 0 : _b.setProperty("touch-action", "pan-y");
353
+ if (disableTextSelect) {
354
+ (_d = (_c = targetRef.value) == null ? void 0 : _c.style) == null ? void 0 : _d.setProperty("-webkit-user-select", "none");
355
+ (_f = (_e = targetRef.value) == null ? void 0 : _e.style) == null ? void 0 : _f.setProperty("-ms-user-select", "none");
356
+ (_h = (_g = targetRef.value) == null ? void 0 : _g.style) == null ? void 0 : _h.setProperty("user-select", "none");
357
+ }
358
+ });
359
+ const stop = () => stops.forEach((s) => s());
360
+ return {
361
+ isSwiping: readonly(isSwiping),
362
+ direction: readonly(direction),
363
+ posStart: readonly(posStart),
364
+ posEnd: readonly(posEnd),
365
+ distanceX,
366
+ distanceY,
367
+ stop
368
+ };
369
+ }
370
+ const _hoisted_1$e = ["data-akaza-state", "data-akaza-disabled"];
371
+ const _hoisted_2$d = ["id", "aria-expanded", "aria-controls", "disabled", "data-akaza-state", "data-akaza-disabled", "onClick"];
372
+ const _hoisted_3$6 = ["data-akaza-state"];
373
+ const _hoisted_4$5 = ["id", "aria-labelledby", "data-akaza-state"];
374
+ const _hoisted_5$1 = { class: "akaza-accordion-content-inner" };
375
+ const _sfc_main$i = /* @__PURE__ */ defineComponent({
376
+ __name: "Accordion",
377
+ props: /* @__PURE__ */ mergeModels({
378
+ items: {},
379
+ valueKey: {},
380
+ labelKey: {},
381
+ contentKey: {},
382
+ disabledKey: { default: "disabled" },
383
+ type: { default: "single" },
384
+ collapsible: { type: Boolean, default: false },
385
+ disabled: { type: Boolean, default: false },
386
+ orientation: { default: "vertical" },
387
+ unmountOnHide: { type: Boolean, default: false },
388
+ as: { default: "div" },
389
+ ui: {}
390
+ }, {
391
+ "modelValue": { default: "" },
392
+ "modelModifiers": {}
393
+ }),
394
+ emits: /* @__PURE__ */ mergeModels(["value-change"], ["update:modelValue"]),
395
+ setup(__props, { emit: __emit }) {
396
+ const emit = __emit;
397
+ const model = useModel(__props, "modelValue");
398
+ const rootRef = useTemplateRef("rootRef");
399
+ function getValue(item) {
400
+ if (__props.valueKey) return String(item[__props.valueKey]);
401
+ if (typeof item === "string" || typeof item === "number") return String(item);
402
+ return String(item.value ?? item.label ?? item);
403
+ }
404
+ function getLabel(item) {
405
+ if (__props.labelKey) return String(item[__props.labelKey] ?? "");
406
+ return String(item.label ?? getValue(item));
407
+ }
408
+ function getContent(item) {
409
+ if (__props.contentKey) return item[__props.contentKey];
410
+ return item.content;
411
+ }
412
+ function isItemDisabled(item) {
413
+ if (__props.disabled) return true;
414
+ return Boolean(item[__props.disabledKey]);
415
+ }
416
+ function isOpen(item) {
417
+ const v = getValue(item);
418
+ if (__props.type === "single") return model.value === v;
419
+ return Array.isArray(model.value) && model.value.includes(v);
420
+ }
421
+ function toggle(item, event) {
422
+ if (isItemDisabled(item)) return;
423
+ const v = getValue(item);
424
+ let nextValue;
425
+ if (__props.type === "single") {
426
+ const current = model.value ?? "";
427
+ nextValue = current === v && __props.collapsible ? "" : v;
428
+ } else {
429
+ const current = Array.isArray(model.value) ? model.value : [];
430
+ nextValue = current.includes(v) ? current.filter((x) => x !== v) : [...current, v];
431
+ }
432
+ let canceled = false;
433
+ emit("value-change", nextValue, { reason: "trigger", ...event && { event }, cancel: () => {
434
+ canceled = true;
435
+ } });
436
+ if (!canceled) model.value = nextValue;
437
+ }
438
+ function triggerId(item) {
439
+ return `akaza-accordion-trigger-${getValue(item)}`;
440
+ }
441
+ function panelId(item) {
442
+ return `akaza-accordion-panel-${getValue(item)}`;
443
+ }
444
+ onKeyStroke(["ArrowDown", "ArrowUp", "ArrowRight", "ArrowLeft", "Home", "End"], (e) => {
445
+ var _a;
446
+ if (!rootRef.value) return;
447
+ const triggers = Array.from(
448
+ rootRef.value.querySelectorAll(".akaza-accordion-trigger:not([disabled])")
449
+ );
450
+ if (!triggers.includes(document.activeElement)) return;
451
+ const isVertical = __props.orientation === "vertical";
452
+ const isPrev = isVertical && e.key === "ArrowUp" || !isVertical && e.key === "ArrowLeft";
453
+ const isNext = isVertical && e.key === "ArrowDown" || !isVertical && e.key === "ArrowRight";
454
+ if (!isPrev && !isNext && e.key !== "Home" && e.key !== "End") return;
455
+ e.preventDefault();
456
+ const currentIdx = triggers.indexOf(document.activeElement);
457
+ let next = currentIdx;
458
+ if (isPrev) next = currentIdx > 0 ? currentIdx - 1 : triggers.length - 1;
459
+ else if (isNext) next = currentIdx < triggers.length - 1 ? currentIdx + 1 : 0;
460
+ else if (e.key === "Home") next = 0;
461
+ else if (e.key === "End") next = triggers.length - 1;
462
+ (_a = triggers[next]) == null ? void 0 : _a.focus();
463
+ });
464
+ return (_ctx, _cache) => {
465
+ return openBlock(), createBlock(resolveDynamicComponent(__props.as), {
466
+ ref_key: "rootRef",
467
+ ref: rootRef,
468
+ "data-akaza-orientation": __props.orientation,
469
+ class: "akaza-accordion"
470
+ }, {
471
+ default: withCtx(() => [
472
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.items, (item) => {
473
+ var _a, _b, _c;
474
+ return openBlock(), createElementBlock("div", {
475
+ key: getValue(item),
476
+ "data-akaza-state": isOpen(item) ? "open" : "closed",
477
+ "data-akaza-disabled": isItemDisabled(item) ? "" : void 0,
478
+ class: normalizeClass([(_a = __props.ui) == null ? void 0 : _a.item, "akaza-accordion-item"])
479
+ }, [
480
+ createElementVNode("button", {
481
+ type: "button",
482
+ id: triggerId(item),
483
+ "aria-expanded": isOpen(item),
484
+ "aria-controls": panelId(item),
485
+ disabled: isItemDisabled(item),
486
+ class: normalizeClass([(_b = __props.ui) == null ? void 0 : _b.trigger, "akaza-accordion-trigger"]),
487
+ "data-akaza-state": isOpen(item) ? "open" : "closed",
488
+ "data-akaza-disabled": isItemDisabled(item) ? "" : void 0,
489
+ onClick: ($event) => toggle(item, $event)
490
+ }, [
491
+ renderSlot(_ctx.$slots, "trigger", {
492
+ item,
493
+ value: getValue(item),
494
+ isOpen: isOpen(item),
495
+ toggle: () => toggle(item)
496
+ }, () => [
497
+ createTextVNode(toDisplayString(getLabel(item)), 1)
498
+ ]),
499
+ renderSlot(_ctx.$slots, "icon", {
500
+ isOpen: isOpen(item),
501
+ item
502
+ }, () => {
503
+ var _a2;
504
+ return [
505
+ (openBlock(), createElementBlock("svg", {
506
+ class: normalizeClass([(_a2 = __props.ui) == null ? void 0 : _a2.icon, "akaza-accordion-icon"]),
507
+ "data-akaza-state": isOpen(item) ? "open" : "closed",
508
+ xmlns: "http://www.w3.org/2000/svg",
509
+ width: "16",
510
+ height: "16",
511
+ viewBox: "0 0 24 24",
512
+ fill: "none",
513
+ stroke: "currentColor",
514
+ "stroke-width": "2",
515
+ "stroke-linecap": "round",
516
+ "stroke-linejoin": "round",
517
+ "aria-hidden": "true"
518
+ }, [..._cache[0] || (_cache[0] = [
519
+ createElementVNode("polyline", { points: "6 9 12 15 18 9" }, null, -1)
520
+ ])], 10, _hoisted_3$6))
521
+ ];
522
+ })
523
+ ], 10, _hoisted_2$d),
524
+ createElementVNode("div", {
525
+ id: panelId(item),
526
+ role: "region",
527
+ "aria-labelledby": triggerId(item),
528
+ class: "akaza-accordion-content",
529
+ "data-akaza-state": isOpen(item) ? "open" : "closed"
530
+ }, [
531
+ createElementVNode("div", _hoisted_5$1, [
532
+ createElementVNode("div", {
533
+ class: normalizeClass([(_c = __props.ui) == null ? void 0 : _c.content, "akaza-accordion-content-body"])
534
+ }, [
535
+ !__props.unmountOnHide || isOpen(item) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
536
+ item.slot && _ctx.$slots[item.slot] ? renderSlot(_ctx.$slots, item.slot, {
537
+ key: 0,
538
+ item,
539
+ value: getValue(item),
540
+ isOpen: isOpen(item)
541
+ }) : renderSlot(_ctx.$slots, "content", {
542
+ key: 1,
543
+ item,
544
+ value: getValue(item),
545
+ isOpen: isOpen(item)
546
+ }, () => [
547
+ createTextVNode(toDisplayString(getContent(item)), 1)
548
+ ])
549
+ ], 64)) : createCommentVNode("", true)
550
+ ], 2)
551
+ ])
552
+ ], 8, _hoisted_4$5)
553
+ ], 10, _hoisted_1$e);
554
+ }), 128))
555
+ ]),
556
+ _: 3
557
+ }, 8, ["data-akaza-orientation"]);
558
+ };
559
+ }
560
+ });
561
+ function useAlertDialog(modelRef) {
562
+ const isOpen = modelRef ?? ref(false);
563
+ function open() {
564
+ isOpen.value = true;
565
+ }
566
+ function close() {
567
+ isOpen.value = false;
568
+ }
569
+ function toggle() {
570
+ isOpen.value = !isOpen.value;
571
+ }
572
+ return { isOpen, open, close, toggle };
573
+ }
574
+ const FOCUSABLE_SELECTORS = [
575
+ "a[href]",
576
+ "area[href]",
577
+ 'input:not([disabled]):not([type="hidden"])',
578
+ "select:not([disabled])",
579
+ "textarea:not([disabled])",
580
+ "button:not([disabled])",
581
+ "iframe",
582
+ '[tabindex]:not([tabindex="-1"])',
583
+ '[contenteditable="true"]',
584
+ "details > summary:first-child"
585
+ ].join(",");
586
+ function getFocusableElements(container) {
587
+ return Array.from(container.querySelectorAll(FOCUSABLE_SELECTORS)).filter((el) => {
588
+ const style = window.getComputedStyle(el);
589
+ return !el.closest('[aria-hidden="true"]') && style.display !== "none" && style.visibility !== "hidden";
590
+ });
591
+ }
592
+ const useScopeStack = /* @__PURE__ */ createGlobalState(() => {
593
+ const stack = [];
594
+ return {
595
+ add(scope) {
596
+ const top = stack[stack.length - 1];
597
+ if (top && top !== scope) top.pause();
598
+ const idx = stack.indexOf(scope);
599
+ if (idx !== -1) stack.splice(idx, 1);
600
+ stack.push(scope);
601
+ },
602
+ remove(scope) {
603
+ var _a;
604
+ const idx = stack.indexOf(scope);
605
+ if (idx !== -1) stack.splice(idx, 1);
606
+ (_a = stack[stack.length - 1]) == null ? void 0 : _a.resume();
607
+ }
608
+ };
609
+ });
610
+ function useFocusScope(containerRef, options = {}) {
611
+ let previouslyFocused = null;
612
+ const scope = {
613
+ paused: false,
614
+ pause() {
615
+ this.paused = true;
616
+ },
617
+ resume() {
618
+ this.paused = false;
619
+ }
620
+ };
621
+ const { add, remove } = useScopeStack();
622
+ function handleKeyDown(event) {
623
+ if (scope.paused || event.key !== "Tab" || !containerRef.value) return;
624
+ const focusable = getFocusableElements(containerRef.value);
625
+ if (focusable.length === 0) {
626
+ event.preventDefault();
627
+ return;
628
+ }
629
+ const first = focusable[0];
630
+ const last = focusable[focusable.length - 1];
631
+ if (event.shiftKey) {
632
+ if (document.activeElement === first || document.activeElement === containerRef.value) {
633
+ event.preventDefault();
634
+ last.focus();
635
+ }
636
+ } else {
637
+ if (document.activeElement === last) {
638
+ event.preventDefault();
639
+ first.focus();
640
+ }
641
+ }
642
+ }
643
+ function activate() {
644
+ previouslyFocused = document.activeElement;
645
+ if (containerRef.value) {
646
+ const initial = options.initialFocusSelector ? containerRef.value.querySelector(options.initialFocusSelector) : null;
647
+ if (initial) {
648
+ initial.focus();
649
+ } else {
650
+ const focusable = getFocusableElements(containerRef.value);
651
+ (focusable[0] ?? containerRef.value).focus();
652
+ }
653
+ }
654
+ document.addEventListener("keydown", handleKeyDown);
655
+ add(scope);
656
+ }
657
+ function deactivate() {
658
+ remove(scope);
659
+ document.removeEventListener("keydown", handleKeyDown);
660
+ previouslyFocused == null ? void 0 : previouslyFocused.focus();
661
+ previouslyFocused = null;
662
+ }
663
+ onUnmounted(deactivate);
664
+ return { activate, deactivate };
665
+ }
666
+ const _hoisted_1$d = ["id"];
667
+ const _hoisted_2$c = ["id"];
668
+ const _sfc_main$h = /* @__PURE__ */ defineComponent({
669
+ __name: "AlertDialog",
670
+ props: /* @__PURE__ */ mergeModels({
671
+ as: { default: "div" },
672
+ teleport: { type: [String, Boolean], default: "body" },
673
+ transition: { type: [String, Boolean], default: "akaza-alert-dialog" },
674
+ duration: { default: 150 },
675
+ title: {},
676
+ description: {},
677
+ ui: {}
678
+ }, {
679
+ "modelValue": { type: Boolean, ...{ default: false } },
680
+ "modelModifiers": {}
681
+ }),
682
+ emits: /* @__PURE__ */ mergeModels(["open-change"], ["update:modelValue"]),
683
+ setup(__props, { expose: __expose, emit: __emit }) {
684
+ const emit = __emit;
685
+ const model = useModel(__props, "modelValue");
686
+ const { isOpen, open: _open, close: _close } = useAlertDialog(model);
687
+ const contentRef = useTemplateRef("contentRef");
688
+ const titleId = useId();
689
+ const descriptionId = useId();
690
+ const { activate, deactivate } = useFocusScope(contentRef, { initialFocusSelector: "[data-akaza-cancel]" });
691
+ watch(isOpen, async (val) => {
692
+ if (val) {
693
+ await nextTick();
694
+ activate();
695
+ } else {
696
+ deactivate();
697
+ }
698
+ });
699
+ function handleChange(open2, reason, event) {
700
+ let canceled = false;
701
+ emit("open-change", open2, { reason, ...event && { event }, cancel: () => {
702
+ canceled = true;
703
+ } });
704
+ if (canceled) return;
705
+ open2 ? _open() : _close();
706
+ }
707
+ function open(reason = "programmatic", event) {
708
+ handleChange(true, reason, event);
709
+ }
710
+ function close(reason = "programmatic", event) {
711
+ handleChange(false, reason, event);
712
+ }
713
+ function toggle(reason = "programmatic", event) {
714
+ handleChange(!isOpen.value, reason, event);
715
+ }
716
+ __expose({ open, close, toggle, titleId, descriptionId });
717
+ return (_ctx, _cache) => {
718
+ return openBlock(), createElementBlock(Fragment, null, [
719
+ renderSlot(_ctx.$slots, "trigger", {
720
+ isOpen: unref(isOpen),
721
+ open,
722
+ close,
723
+ toggle
724
+ }),
725
+ (openBlock(), createBlock(Teleport, {
726
+ to: typeof __props.teleport === "string" ? __props.teleport : "body",
727
+ disabled: __props.teleport === false
728
+ }, [
729
+ createVNode(Transition, { name: "akaza-alert-dialog-overlay" }, {
730
+ default: withCtx(() => {
731
+ var _a;
732
+ return [
733
+ unref(isOpen) ? (openBlock(), createElementBlock("div", {
734
+ key: 0,
735
+ class: normalizeClass([(_a = __props.ui) == null ? void 0 : _a.overlay, "akaza-alert-dialog-overlay"]),
736
+ style: normalizeStyle({ "--akaza-dialog-duration": `${__props.duration}ms` }),
737
+ "data-akaza-state": "open"
738
+ }, null, 6)) : createCommentVNode("", true)
739
+ ];
740
+ }),
741
+ _: 1
742
+ }),
743
+ createVNode(Transition, normalizeProps(guardReactiveProps(typeof __props.transition === "string" ? { name: __props.transition } : {})), {
744
+ default: withCtx(() => {
745
+ var _a;
746
+ return [
747
+ unref(isOpen) ? (openBlock(), createBlock(resolveDynamicComponent(__props.as), {
748
+ key: 0,
749
+ ref_key: "contentRef",
750
+ ref: contentRef,
751
+ role: "alertdialog",
752
+ "aria-modal": "true",
753
+ "aria-labelledby": _ctx.$slots.title || __props.title ? unref(titleId) : void 0,
754
+ "aria-describedby": _ctx.$slots.description || __props.description ? unref(descriptionId) : void 0,
755
+ class: normalizeClass([(_a = __props.ui) == null ? void 0 : _a.content, "akaza-alert-dialog-content"]),
756
+ style: normalizeStyle({ "--akaza-dialog-duration": `${__props.duration}ms` }),
757
+ "data-akaza-state": "open",
758
+ tabindex: "-1"
759
+ }, {
760
+ default: withCtx(() => {
761
+ var _a2, _b, _c, _d;
762
+ return [
763
+ _ctx.$slots.header || _ctx.$slots.title || __props.title ? (openBlock(), createElementBlock("div", {
764
+ key: 0,
765
+ class: normalizeClass([(_a2 = __props.ui) == null ? void 0 : _a2.header, "akaza-alert-dialog-header"])
766
+ }, [
767
+ renderSlot(_ctx.$slots, "header", {
768
+ close,
769
+ titleId: unref(titleId)
770
+ }, () => {
771
+ var _a3;
772
+ return [
773
+ _ctx.$slots.title || __props.title ? (openBlock(), createElementBlock("div", {
774
+ key: 0,
775
+ id: unref(titleId),
776
+ class: normalizeClass([(_a3 = __props.ui) == null ? void 0 : _a3.title, "akaza-alert-dialog-title"])
777
+ }, [
778
+ renderSlot(_ctx.$slots, "title", {}, () => [
779
+ createTextVNode(toDisplayString(__props.title), 1)
780
+ ])
781
+ ], 10, _hoisted_1$d)) : createCommentVNode("", true)
782
+ ];
783
+ })
784
+ ], 2)) : createCommentVNode("", true),
785
+ createElementVNode("div", {
786
+ class: normalizeClass([(_b = __props.ui) == null ? void 0 : _b.body, "akaza-alert-dialog-body"])
787
+ }, [
788
+ _ctx.$slots.description || __props.description ? (openBlock(), createElementBlock("div", {
789
+ key: 0,
790
+ id: unref(descriptionId),
791
+ class: normalizeClass([(_c = __props.ui) == null ? void 0 : _c.description, "akaza-alert-dialog-description"])
792
+ }, [
793
+ renderSlot(_ctx.$slots, "description", {}, () => [
794
+ createTextVNode(toDisplayString(__props.description), 1)
795
+ ])
796
+ ], 10, _hoisted_2$c)) : createCommentVNode("", true),
797
+ renderSlot(_ctx.$slots, "body", {
798
+ close,
799
+ descriptionId: unref(descriptionId)
800
+ })
801
+ ], 2),
802
+ _ctx.$slots.footer ? (openBlock(), createElementBlock("div", {
803
+ key: 1,
804
+ class: normalizeClass([(_d = __props.ui) == null ? void 0 : _d.footer, "akaza-alert-dialog-footer"])
805
+ }, [
806
+ renderSlot(_ctx.$slots, "footer", { close })
807
+ ], 2)) : createCommentVNode("", true)
808
+ ];
809
+ }),
810
+ _: 3
811
+ }, 8, ["aria-labelledby", "aria-describedby", "class", "style"])) : createCommentVNode("", true)
812
+ ];
813
+ }),
814
+ _: 3
815
+ }, 16)
816
+ ], 8, ["to", "disabled"]))
817
+ ], 64);
818
+ };
819
+ }
820
+ });
821
+ const _hoisted_1$c = ["src", "alt"];
822
+ const _hoisted_2$b = ["data-akaza-status"];
823
+ const _sfc_main$g = /* @__PURE__ */ defineComponent({
824
+ __name: "Avatar",
825
+ props: {
826
+ as: { default: "span" },
827
+ src: {},
828
+ alt: { default: "" },
829
+ text: {},
830
+ delayMs: { default: 0 },
831
+ ui: {}
832
+ },
833
+ setup(__props) {
834
+ const imageStatus = ref("idle");
835
+ const showFallback = ref(false);
836
+ onMounted(() => {
837
+ if (!__props.src) {
838
+ imageStatus.value = "error";
839
+ showFallback.value = true;
840
+ return;
841
+ }
842
+ imageStatus.value = "loading";
843
+ if (__props.delayMs > 0) {
844
+ setTimeout(() => {
845
+ if (imageStatus.value !== "loaded") {
846
+ showFallback.value = true;
847
+ }
848
+ }, __props.delayMs);
849
+ } else {
850
+ showFallback.value = true;
851
+ }
852
+ const img = new Image();
853
+ img.addEventListener("load", () => {
854
+ imageStatus.value = "loaded";
855
+ });
856
+ img.addEventListener("error", () => {
857
+ imageStatus.value = "error";
858
+ showFallback.value = true;
859
+ });
860
+ img.src = __props.src;
861
+ });
862
+ return (_ctx, _cache) => {
863
+ var _a;
864
+ return openBlock(), createBlock(resolveDynamicComponent(__props.as), {
865
+ "data-akaza-status": imageStatus.value,
866
+ class: normalizeClass([(_a = __props.ui) == null ? void 0 : _a.root, "akaza-avatar"])
867
+ }, {
868
+ default: withCtx(() => {
869
+ var _a2;
870
+ return [
871
+ renderSlot(_ctx.$slots, "image", {
872
+ src: __props.src,
873
+ alt: __props.alt,
874
+ status: imageStatus.value
875
+ }, () => {
876
+ var _a3;
877
+ return [
878
+ withDirectives(createElementVNode("img", {
879
+ src: __props.src,
880
+ alt: __props.alt,
881
+ class: normalizeClass([(_a3 = __props.ui) == null ? void 0 : _a3.image, "akaza-avatar-image"])
882
+ }, null, 10, _hoisted_1$c), [
883
+ [vShow, imageStatus.value === "loaded"]
884
+ ])
885
+ ];
886
+ }),
887
+ showFallback.value && imageStatus.value !== "loaded" ? (openBlock(), createElementBlock("span", {
888
+ key: 0,
889
+ "aria-hidden": "true",
890
+ "data-akaza-status": imageStatus.value,
891
+ class: normalizeClass([(_a2 = __props.ui) == null ? void 0 : _a2.fallback, "akaza-avatar-fallback"])
892
+ }, [
893
+ renderSlot(_ctx.$slots, "fallback", { status: imageStatus.value }, () => [
894
+ createTextVNode(toDisplayString(__props.text), 1)
895
+ ])
896
+ ], 10, _hoisted_2$b)) : createCommentVNode("", true)
897
+ ];
898
+ }),
899
+ _: 3
900
+ }, 8, ["data-akaza-status", "class"]);
901
+ };
902
+ }
903
+ });
904
+ const _sfc_main$f = /* @__PURE__ */ defineComponent({
905
+ __name: "Button",
906
+ props: {
907
+ as: { default: "button" },
908
+ type: { default: "button" },
909
+ disabled: { type: Boolean, default: false },
910
+ focusableWhenDisabled: { type: Boolean, default: false },
911
+ loading: { type: Boolean, default: false },
912
+ loadingAuto: { type: Boolean, default: false },
913
+ onClick: { type: Function }
914
+ },
915
+ emits: ["click"],
916
+ setup(__props, { emit: __emit }) {
917
+ const emit = __emit;
918
+ const autoLoading = ref(false);
919
+ const isLoading = computed(() => __props.loading || autoLoading.value);
920
+ const isDisabled = computed(() => __props.disabled || isLoading.value);
921
+ async function handleClick(event) {
922
+ if (isDisabled.value) {
923
+ event.preventDefault();
924
+ event.stopImmediatePropagation();
925
+ return;
926
+ }
927
+ if (__props.loadingAuto && __props.onClick) {
928
+ const result = __props.onClick(event);
929
+ if (result instanceof Promise) {
930
+ autoLoading.value = true;
931
+ try {
932
+ await result;
933
+ } finally {
934
+ autoLoading.value = false;
935
+ }
936
+ }
937
+ return;
938
+ }
939
+ emit("click", event);
940
+ }
941
+ return (_ctx, _cache) => {
942
+ return openBlock(), createBlock(resolveDynamicComponent(__props.as), {
943
+ type: __props.as === "button" ? __props.type : void 0,
944
+ disabled: __props.as === "button" && isDisabled.value && !__props.focusableWhenDisabled ? true : void 0,
945
+ "aria-disabled": isDisabled.value ? true : void 0,
946
+ "aria-busy": isLoading.value ? true : void 0,
947
+ tabindex: __props.focusableWhenDisabled ? 0 : isDisabled.value ? -1 : void 0,
948
+ "data-akaza-disabled": __props.disabled || void 0,
949
+ "data-akaza-loading": isLoading.value || void 0,
950
+ "data-akaza-state": isLoading.value ? "loading" : __props.disabled ? "disabled" : "enabled",
951
+ class: "akaza-button",
952
+ onClick: handleClick
953
+ }, {
954
+ default: withCtx(() => [
955
+ !isLoading.value ? renderSlot(_ctx.$slots, "default", { key: 0 }) : renderSlot(_ctx.$slots, "loading", { key: 1 }, () => [
956
+ _cache[0] || (_cache[0] = createElementVNode("svg", {
957
+ class: "akaza-button-spinner",
958
+ xmlns: "http://www.w3.org/2000/svg",
959
+ width: "16",
960
+ height: "16",
961
+ viewBox: "0 0 24 24",
962
+ fill: "none",
963
+ stroke: "currentColor",
964
+ "stroke-width": "2",
965
+ "stroke-linecap": "round",
966
+ "stroke-linejoin": "round",
967
+ "aria-hidden": "true"
968
+ }, [
969
+ createElementVNode("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" })
970
+ ], -1)),
971
+ _cache[1] || (_cache[1] = createElementVNode("span", { class: "sr-only" }, "Loading…", -1))
972
+ ])
973
+ ]),
974
+ _: 3
975
+ }, 8, ["type", "disabled", "aria-disabled", "aria-busy", "tabindex", "data-akaza-disabled", "data-akaza-loading", "data-akaza-state"]);
976
+ };
977
+ }
978
+ });
979
+ const _hoisted_1$b = ["id", "aria-checked", "aria-labelledby", "aria-describedby", "data-akaza-state", "data-akaza-disabled", "disabled"];
980
+ const _hoisted_2$a = ["data-akaza-state"];
981
+ const _hoisted_3$5 = ["name", "value", "checked", "required"];
982
+ const _hoisted_4$4 = {
983
+ key: 1,
984
+ class: "akaza-checkbox-text"
985
+ };
986
+ const _sfc_main$e = /* @__PURE__ */ defineComponent({
987
+ __name: "Checkbox",
988
+ props: /* @__PURE__ */ mergeModels({
989
+ disabled: { type: Boolean, default: false },
990
+ id: {},
991
+ name: {},
992
+ required: { type: Boolean, default: false },
993
+ trueValue: { default: true },
994
+ falseValue: { default: false },
995
+ label: {},
996
+ description: {},
997
+ ui: {}
998
+ }, {
999
+ "modelValue": { type: [Boolean, String], ...{ default: false } },
1000
+ "modelModifiers": {}
1001
+ }),
1002
+ emits: /* @__PURE__ */ mergeModels(["value-change"], ["update:modelValue"]),
1003
+ setup(__props, { emit: __emit }) {
1004
+ const emit = __emit;
1005
+ const model = useModel(__props, "modelValue");
1006
+ const slots = useSlots();
1007
+ const autoId = useId();
1008
+ const buttonId = computed(() => __props.id ?? `akaza-checkbox-${autoId}`);
1009
+ const labelId = `akaza-checkbox-label-${autoId}`;
1010
+ const descriptionId = `akaza-checkbox-desc-${autoId}`;
1011
+ const hasLabel = computed(() => !!(__props.label || slots.label));
1012
+ const hasDescription = computed(() => !!(__props.description || slots.description));
1013
+ const isChecked = computed(() => model.value === __props.trueValue);
1014
+ const isIndeterminate = computed(() => model.value === "indeterminate");
1015
+ function toggle(reason = "click", event) {
1016
+ if (__props.disabled) return;
1017
+ const nextValue = isChecked.value ? __props.falseValue : __props.trueValue;
1018
+ let canceled = false;
1019
+ emit("value-change", nextValue, { reason, ...event && { event }, cancel: () => {
1020
+ canceled = true;
1021
+ } });
1022
+ if (canceled) return;
1023
+ model.value = nextValue;
1024
+ }
1025
+ return (_ctx, _cache) => {
1026
+ var _a, _b, _c, _d, _e;
1027
+ return openBlock(), createElementBlock("span", {
1028
+ class: normalizeClass([(_a = __props.ui) == null ? void 0 : _a.wrapper, "akaza-checkbox-wrapper"])
1029
+ }, [
1030
+ createElementVNode("button", {
1031
+ type: "button",
1032
+ role: "checkbox",
1033
+ id: buttonId.value,
1034
+ "aria-checked": isIndeterminate.value ? "mixed" : isChecked.value,
1035
+ "aria-labelledby": hasLabel.value ? labelId : void 0,
1036
+ "aria-describedby": hasDescription.value ? descriptionId : void 0,
1037
+ class: normalizeClass([(_b = __props.ui) == null ? void 0 : _b.root, "akaza-checkbox"]),
1038
+ "data-akaza-state": isChecked.value ? "checked" : isIndeterminate.value ? "indeterminate" : "unchecked",
1039
+ "data-akaza-disabled": __props.disabled || void 0,
1040
+ disabled: __props.disabled,
1041
+ onClick: _cache[0] || (_cache[0] = ($event) => toggle("click", $event)),
1042
+ onKeydown: _cache[1] || (_cache[1] = withKeys(withModifiers(($event) => toggle("keyboard", $event), ["prevent"]), ["space"]))
1043
+ }, [
1044
+ (!isChecked.value && !isIndeterminate.value ? false : true) ? (openBlock(), createElementBlock("span", {
1045
+ key: 0,
1046
+ class: normalizeClass([(_c = __props.ui) == null ? void 0 : _c.indicator, "akaza-checkbox-indicator"]),
1047
+ "data-akaza-state": isChecked.value ? "checked" : "indeterminate"
1048
+ }, [
1049
+ renderSlot(_ctx.$slots, "indicator", { checked: model.value })
1050
+ ], 10, _hoisted_2$a)) : createCommentVNode("", true)
1051
+ ], 42, _hoisted_1$b),
1052
+ __props.name ? (openBlock(), createElementBlock("input", {
1053
+ key: 0,
1054
+ type: "checkbox",
1055
+ name: __props.name,
1056
+ value: String(__props.trueValue),
1057
+ checked: isChecked.value,
1058
+ required: __props.required,
1059
+ "aria-hidden": "true",
1060
+ tabindex: "-1",
1061
+ class: "akaza-checkbox-input"
1062
+ }, null, 8, _hoisted_3$5)) : createCommentVNode("", true),
1063
+ hasLabel.value || hasDescription.value ? (openBlock(), createElementBlock("span", _hoisted_4$4, [
1064
+ hasLabel.value ? (openBlock(), createElementBlock("span", {
1065
+ key: 0,
1066
+ id: labelId,
1067
+ class: normalizeClass([(_d = __props.ui) == null ? void 0 : _d.label, "akaza-checkbox-label"])
1068
+ }, [
1069
+ renderSlot(_ctx.$slots, "label", {}, () => [
1070
+ createTextVNode(toDisplayString(__props.label), 1)
1071
+ ])
1072
+ ], 2)) : createCommentVNode("", true),
1073
+ hasDescription.value ? (openBlock(), createElementBlock("span", {
1074
+ key: 1,
1075
+ id: descriptionId,
1076
+ class: normalizeClass([(_e = __props.ui) == null ? void 0 : _e.description, "akaza-checkbox-description"])
1077
+ }, [
1078
+ renderSlot(_ctx.$slots, "description", {}, () => [
1079
+ createTextVNode(toDisplayString(__props.description), 1)
1080
+ ])
1081
+ ], 2)) : createCommentVNode("", true)
1082
+ ])) : createCommentVNode("", true)
1083
+ ], 2);
1084
+ };
1085
+ }
1086
+ });
1087
+ const _hoisted_1$a = ["aria-expanded", "data-akaza-state", "data-akaza-disabled", "disabled"];
1088
+ const _hoisted_2$9 = ["data-akaza-state"];
1089
+ const _hoisted_3$4 = ["data-akaza-state"];
1090
+ const _hoisted_4$3 = { class: "akaza-collapsible-content-inner" };
1091
+ const _sfc_main$d = /* @__PURE__ */ defineComponent({
1092
+ __name: "Collapsible",
1093
+ props: /* @__PURE__ */ mergeModels({
1094
+ as: { default: "div" },
1095
+ disabled: { type: Boolean, default: false },
1096
+ unmountOnHide: { type: Boolean, default: false },
1097
+ ui: {}
1098
+ }, {
1099
+ "modelValue": { type: Boolean, ...{ default: false } },
1100
+ "modelModifiers": {}
1101
+ }),
1102
+ emits: /* @__PURE__ */ mergeModels(["open-change"], ["update:modelValue"]),
1103
+ setup(__props, { expose: __expose, emit: __emit }) {
1104
+ const emit = __emit;
1105
+ const model = useModel(__props, "modelValue");
1106
+ const panelId = `akaza-collapsible-panel-${useId()}`;
1107
+ function handleChange(nextOpen, reason, event) {
1108
+ if (__props.disabled && nextOpen) return;
1109
+ let canceled = false;
1110
+ emit("open-change", nextOpen, { reason, ...event && { event }, cancel: () => {
1111
+ canceled = true;
1112
+ } });
1113
+ if (canceled) return;
1114
+ model.value = nextOpen;
1115
+ }
1116
+ function open(reason = "programmatic", event) {
1117
+ handleChange(true, reason, event);
1118
+ }
1119
+ function close(reason = "programmatic", event) {
1120
+ handleChange(false, reason, event);
1121
+ }
1122
+ function toggle(reason = "programmatic", event) {
1123
+ handleChange(!model.value, reason, event);
1124
+ }
1125
+ __expose({ open, close, toggle });
1126
+ return (_ctx, _cache) => {
1127
+ var _a;
1128
+ return openBlock(), createBlock(resolveDynamicComponent(__props.as), {
1129
+ class: normalizeClass([(_a = __props.ui) == null ? void 0 : _a.root, "akaza-collapsible"]),
1130
+ "data-akaza-state": model.value ? "open" : "closed",
1131
+ "data-akaza-disabled": __props.disabled || void 0
1132
+ }, {
1133
+ default: withCtx(() => {
1134
+ var _a2, _b;
1135
+ return [
1136
+ createElementVNode("button", {
1137
+ type: "button",
1138
+ "aria-expanded": model.value,
1139
+ "aria-controls": panelId,
1140
+ class: normalizeClass([(_a2 = __props.ui) == null ? void 0 : _a2.trigger, "akaza-collapsible-trigger"]),
1141
+ "data-akaza-state": model.value ? "open" : "closed",
1142
+ "data-akaza-disabled": __props.disabled || void 0,
1143
+ disabled: __props.disabled,
1144
+ onClick: _cache[0] || (_cache[0] = ($event) => toggle("trigger", $event))
1145
+ }, [
1146
+ renderSlot(_ctx.$slots, "trigger", {
1147
+ isOpen: model.value,
1148
+ open,
1149
+ close,
1150
+ toggle
1151
+ }),
1152
+ renderSlot(_ctx.$slots, "icon", { isOpen: model.value }, () => [
1153
+ (openBlock(), createElementBlock("svg", {
1154
+ class: "akaza-collapsible-icon",
1155
+ "data-akaza-state": model.value ? "open" : "closed",
1156
+ xmlns: "http://www.w3.org/2000/svg",
1157
+ width: "16",
1158
+ height: "16",
1159
+ viewBox: "0 0 24 24",
1160
+ fill: "none",
1161
+ stroke: "currentColor",
1162
+ "stroke-width": "2",
1163
+ "stroke-linecap": "round",
1164
+ "stroke-linejoin": "round",
1165
+ "aria-hidden": "true"
1166
+ }, [..._cache[1] || (_cache[1] = [
1167
+ createElementVNode("polyline", { points: "6 9 12 15 18 9" }, null, -1)
1168
+ ])], 8, _hoisted_2$9))
1169
+ ])
1170
+ ], 10, _hoisted_1$a),
1171
+ createElementVNode("div", {
1172
+ id: panelId,
1173
+ role: "region",
1174
+ class: "akaza-collapsible-content",
1175
+ "data-akaza-state": model.value ? "open" : "closed"
1176
+ }, [
1177
+ createElementVNode("div", _hoisted_4$3, [
1178
+ createElementVNode("div", {
1179
+ class: normalizeClass([(_b = __props.ui) == null ? void 0 : _b.content, "akaza-collapsible-content-body"])
1180
+ }, [
1181
+ !__props.unmountOnHide || model.value ? renderSlot(_ctx.$slots, "content", {
1182
+ key: 0,
1183
+ isOpen: model.value,
1184
+ close
1185
+ }) : createCommentVNode("", true)
1186
+ ], 2)
1187
+ ])
1188
+ ], 8, _hoisted_3$4)
1189
+ ];
1190
+ }),
1191
+ _: 3
1192
+ }, 8, ["class", "data-akaza-state", "data-akaza-disabled"]);
1193
+ };
1194
+ }
1195
+ });
1196
+ function useDialog(modelRef) {
1197
+ const isOpen = modelRef ?? ref(false);
1198
+ function open() {
1199
+ isOpen.value = true;
1200
+ }
1201
+ function close() {
1202
+ isOpen.value = false;
1203
+ }
1204
+ function toggle() {
1205
+ isOpen.value = !isOpen.value;
1206
+ }
1207
+ return { isOpen, open, close, toggle };
1208
+ }
1209
+ const useLayerStack = /* @__PURE__ */ createGlobalState(() => {
1210
+ const layers = [];
1211
+ return layers;
1212
+ });
1213
+ function useDismissableLayer(onDismiss) {
1214
+ const layers = useLayerStack();
1215
+ function register() {
1216
+ layers.push(onDismiss);
1217
+ }
1218
+ function unregister() {
1219
+ const idx = layers.lastIndexOf(onDismiss);
1220
+ if (idx !== -1) layers.splice(idx, 1);
1221
+ }
1222
+ onKeyStroke("Escape", (event) => {
1223
+ const isTop = layers[layers.length - 1] === onDismiss;
1224
+ if (!isTop) return;
1225
+ event.preventDefault();
1226
+ onDismiss(event);
1227
+ });
1228
+ onUnmounted(unregister);
1229
+ return { register, unregister };
1230
+ }
1231
+ const _hoisted_1$9 = ["id"];
1232
+ const _hoisted_2$8 = ["id"];
1233
+ const _sfc_main$c = /* @__PURE__ */ defineComponent({
1234
+ __name: "Dialog",
1235
+ props: /* @__PURE__ */ mergeModels({
1236
+ as: { default: "div" },
1237
+ title: {},
1238
+ description: {},
1239
+ closeOnBackdropClick: { type: Boolean, default: true },
1240
+ fullscreen: { type: Boolean, default: false },
1241
+ teleport: { type: [String, Boolean], default: "body" },
1242
+ transition: { type: [String, Boolean], default: "akaza-dialog" },
1243
+ duration: { default: 100 },
1244
+ ui: {}
1245
+ }, {
1246
+ "modelValue": { type: Boolean, ...{ default: false } },
1247
+ "modelModifiers": {}
1248
+ }),
1249
+ emits: /* @__PURE__ */ mergeModels(["open-change"], ["update:modelValue"]),
1250
+ setup(__props, { expose: __expose, emit: __emit }) {
1251
+ const emit = __emit;
1252
+ const model = useModel(__props, "modelValue");
1253
+ const { isOpen, open: _open, close: _close } = useDialog(model);
1254
+ const contentRef = useTemplateRef("contentRef");
1255
+ const titleId = useId();
1256
+ const descriptionId = useId();
1257
+ const { activate, deactivate } = useFocusScope(contentRef);
1258
+ const { register, unregister } = useDismissableLayer((event) => close("escape", event));
1259
+ function handleChange(nextOpen, reason, event) {
1260
+ let canceled = false;
1261
+ emit("open-change", nextOpen, { reason, ...event && { event }, cancel: () => {
1262
+ canceled = true;
1263
+ } });
1264
+ if (canceled) return;
1265
+ nextOpen ? _open() : _close();
1266
+ }
1267
+ function open(reason = "programmatic", event) {
1268
+ handleChange(true, reason, event);
1269
+ }
1270
+ function close(reason = "programmatic", event) {
1271
+ handleChange(false, reason, event);
1272
+ }
1273
+ function toggle(reason = "programmatic", event) {
1274
+ handleChange(!isOpen.value, reason, event);
1275
+ }
1276
+ watch(isOpen, async (val) => {
1277
+ if (val) {
1278
+ await nextTick();
1279
+ activate();
1280
+ register();
1281
+ } else {
1282
+ deactivate();
1283
+ unregister();
1284
+ }
1285
+ });
1286
+ function onBackdropClick(event) {
1287
+ if (__props.closeOnBackdropClick) close("backdrop-click", event);
1288
+ }
1289
+ __expose({ open, close, toggle, titleId, descriptionId });
1290
+ return (_ctx, _cache) => {
1291
+ return openBlock(), createElementBlock(Fragment, null, [
1292
+ renderSlot(_ctx.$slots, "trigger", {
1293
+ isOpen: unref(isOpen),
1294
+ open,
1295
+ close,
1296
+ toggle
1297
+ }),
1298
+ (openBlock(), createBlock(Teleport, {
1299
+ to: typeof __props.teleport === "string" ? __props.teleport : "body",
1300
+ disabled: __props.teleport === false
1301
+ }, [
1302
+ createVNode(Transition, { name: "akaza-dialog-overlay" }, {
1303
+ default: withCtx(() => {
1304
+ var _a;
1305
+ return [
1306
+ unref(isOpen) ? (openBlock(), createElementBlock("div", {
1307
+ key: 0,
1308
+ class: normalizeClass([(_a = __props.ui) == null ? void 0 : _a.overlay, "akaza-dialog-overlay"]),
1309
+ style: normalizeStyle({ "--akaza-dialog-duration": `${__props.duration}ms` }),
1310
+ "data-akaza-state": "open",
1311
+ onClick: onBackdropClick
1312
+ }, [
1313
+ renderSlot(_ctx.$slots, "overlay")
1314
+ ], 6)) : createCommentVNode("", true)
1315
+ ];
1316
+ }),
1317
+ _: 3
1318
+ }),
1319
+ createVNode(Transition, normalizeProps(guardReactiveProps(typeof __props.transition === "string" ? { name: __props.transition } : {})), {
1320
+ default: withCtx(() => {
1321
+ var _a;
1322
+ return [
1323
+ unref(isOpen) ? (openBlock(), createBlock(resolveDynamicComponent(__props.as), {
1324
+ key: 0,
1325
+ ref_key: "contentRef",
1326
+ ref: contentRef,
1327
+ role: "dialog",
1328
+ "aria-modal": "true",
1329
+ "aria-labelledby": _ctx.$slots.title || __props.title ? unref(titleId) : void 0,
1330
+ "aria-describedby": _ctx.$slots.description || __props.description ? unref(descriptionId) : void 0,
1331
+ class: normalizeClass([(_a = __props.ui) == null ? void 0 : _a.content, "akaza-dialog-content"]),
1332
+ style: normalizeStyle({ "--akaza-dialog-duration": `${__props.duration}ms` }),
1333
+ "data-akaza-fullscreen": __props.fullscreen || void 0,
1334
+ "data-akaza-state": "open",
1335
+ tabindex: "-1"
1336
+ }, {
1337
+ default: withCtx(() => {
1338
+ var _a2, _b, _c, _d;
1339
+ return [
1340
+ _ctx.$slots.header || _ctx.$slots.title || __props.title ? (openBlock(), createElementBlock("div", {
1341
+ key: 0,
1342
+ class: normalizeClass([(_a2 = __props.ui) == null ? void 0 : _a2.header, "akaza-dialog-header"])
1343
+ }, [
1344
+ renderSlot(_ctx.$slots, "header", {
1345
+ close,
1346
+ titleId: unref(titleId)
1347
+ }, () => {
1348
+ var _a3;
1349
+ return [
1350
+ createElementVNode("div", {
1351
+ id: unref(titleId),
1352
+ class: normalizeClass([(_a3 = __props.ui) == null ? void 0 : _a3.title, "akaza-dialog-title"])
1353
+ }, [
1354
+ renderSlot(_ctx.$slots, "title", {}, () => [
1355
+ createTextVNode(toDisplayString(__props.title), 1)
1356
+ ])
1357
+ ], 10, _hoisted_1$9)
1358
+ ];
1359
+ })
1360
+ ], 2)) : createCommentVNode("", true),
1361
+ createElementVNode("div", {
1362
+ class: normalizeClass([(_b = __props.ui) == null ? void 0 : _b.body, "akaza-dialog-body"])
1363
+ }, [
1364
+ _ctx.$slots.description || __props.description ? (openBlock(), createElementBlock("div", {
1365
+ key: 0,
1366
+ id: unref(descriptionId),
1367
+ class: normalizeClass([(_c = __props.ui) == null ? void 0 : _c.description, "akaza-dialog-description"])
1368
+ }, [
1369
+ renderSlot(_ctx.$slots, "description", {}, () => [
1370
+ createTextVNode(toDisplayString(__props.description), 1)
1371
+ ])
1372
+ ], 10, _hoisted_2$8)) : createCommentVNode("", true),
1373
+ renderSlot(_ctx.$slots, "body", {
1374
+ close,
1375
+ descriptionId: unref(descriptionId)
1376
+ })
1377
+ ], 2),
1378
+ _ctx.$slots.footer ? (openBlock(), createElementBlock("div", {
1379
+ key: 1,
1380
+ class: normalizeClass([(_d = __props.ui) == null ? void 0 : _d.footer, "akaza-dialog-footer"])
1381
+ }, [
1382
+ renderSlot(_ctx.$slots, "footer", { close })
1383
+ ], 2)) : createCommentVNode("", true)
1384
+ ];
1385
+ }),
1386
+ _: 3
1387
+ }, 8, ["aria-labelledby", "aria-describedby", "class", "style", "data-akaza-fullscreen"])) : createCommentVNode("", true)
1388
+ ];
1389
+ }),
1390
+ _: 3
1391
+ }, 16)
1392
+ ], 8, ["to", "disabled"]))
1393
+ ], 64);
1394
+ };
1395
+ }
1396
+ });
1397
+ function useDrawer(modelRef) {
1398
+ const isOpen = modelRef ?? ref(false);
1399
+ function open() {
1400
+ isOpen.value = true;
1401
+ }
1402
+ function close() {
1403
+ isOpen.value = false;
1404
+ }
1405
+ function toggle() {
1406
+ isOpen.value = !isOpen.value;
1407
+ }
1408
+ return { isOpen, open, close, toggle };
1409
+ }
1410
+ const _hoisted_1$8 = ["id"];
1411
+ const _hoisted_2$7 = ["id"];
1412
+ const DISMISS_THRESHOLD = 100;
1413
+ const TRANSITION_DURATION = 300;
1414
+ const _sfc_main$b = /* @__PURE__ */ defineComponent({
1415
+ __name: "Drawer",
1416
+ props: /* @__PURE__ */ mergeModels({
1417
+ as: { default: "div" },
1418
+ title: {},
1419
+ description: {},
1420
+ side: { default: "right" },
1421
+ inset: { default: 0 },
1422
+ closeOnBackdropClick: { type: Boolean, default: true },
1423
+ swipeToClose: { type: Boolean, default: true },
1424
+ teleport: { type: [String, Boolean], default: "body" },
1425
+ ui: {}
1426
+ }, {
1427
+ "modelValue": { type: Boolean, ...{ default: false } },
1428
+ "modelModifiers": {}
1429
+ }),
1430
+ emits: /* @__PURE__ */ mergeModels(["open-change"], ["update:modelValue"]),
1431
+ setup(__props, { expose: __expose, emit: __emit }) {
1432
+ const emit = __emit;
1433
+ const model = useModel(__props, "modelValue");
1434
+ const { isOpen, open: _open, close: _close } = useDrawer(model);
1435
+ function handleChange(nextOpen, reason, event) {
1436
+ let canceled = false;
1437
+ emit("open-change", nextOpen, { reason, ...event && { event }, cancel: () => {
1438
+ canceled = true;
1439
+ } });
1440
+ if (canceled) return;
1441
+ nextOpen ? _open() : _close();
1442
+ }
1443
+ function open(reason = "programmatic", event) {
1444
+ handleChange(true, reason, event);
1445
+ }
1446
+ function close(reason = "programmatic", event) {
1447
+ handleChange(false, reason, event);
1448
+ }
1449
+ function toggle(reason = "programmatic", event) {
1450
+ handleChange(!isOpen.value, reason, event);
1451
+ }
1452
+ const contentRef = useTemplateRef("contentRef");
1453
+ const overlayRef = useTemplateRef("overlayRef");
1454
+ const titleId = useId();
1455
+ const descriptionId = useId();
1456
+ const { activate, deactivate } = useFocusScope(contentRef);
1457
+ const { register, unregister } = useDismissableLayer((event) => close("escape", event));
1458
+ watch(isOpen, async (val) => {
1459
+ if (val) {
1460
+ await nextTick();
1461
+ activate();
1462
+ register();
1463
+ } else {
1464
+ deactivate();
1465
+ unregister();
1466
+ }
1467
+ });
1468
+ function onOverlayClick(event) {
1469
+ if (__props.closeOnBackdropClick) close("backdrop-click", event);
1470
+ }
1471
+ const insetValue = computed(
1472
+ () => typeof __props.inset === "number" ? `${__props.inset}px` : __props.inset
1473
+ );
1474
+ const drawerStyle = computed(() => ({
1475
+ "--akaza-drawer-inset": insetValue.value,
1476
+ borderRadius: __props.inset && Number(__props.inset) !== 0 ? "12px" : void 0
1477
+ }));
1478
+ function getSwipeAxis() {
1479
+ return __props.side === "left" || __props.side === "right" ? "x" : "y";
1480
+ }
1481
+ function getOffscreenValue(axis) {
1482
+ if (axis === "x") return __props.side === "right" ? "110%" : "-110%";
1483
+ return __props.side === "bottom" ? "110%" : "-110%";
1484
+ }
1485
+ function getMovement(dX, dY) {
1486
+ switch (__props.side) {
1487
+ case "right":
1488
+ return Math.max(0, -dX);
1489
+ case "left":
1490
+ return Math.max(0, dX);
1491
+ case "bottom":
1492
+ return Math.max(0, -dY);
1493
+ case "top":
1494
+ return Math.max(0, dY);
1495
+ default:
1496
+ return 0;
1497
+ }
1498
+ }
1499
+ function setSwipeVars(movement) {
1500
+ var _a;
1501
+ if (!contentRef.value) return;
1502
+ const axis = getSwipeAxis();
1503
+ const sign = __props.side === "right" || __props.side === "bottom" ? 1 : -1;
1504
+ contentRef.value.style.setProperty(`--drawer-swipe-movement-${axis}`, `${sign * movement}px`);
1505
+ const progress = String(Math.min(1, movement / DISMISS_THRESHOLD));
1506
+ contentRef.value.style.setProperty("--drawer-swipe-progress", progress);
1507
+ (_a = overlayRef.value) == null ? void 0 : _a.style.setProperty("--drawer-swipe-progress", progress);
1508
+ }
1509
+ function clearSwipeVars() {
1510
+ var _a, _b, _c, _d;
1511
+ (_a = contentRef.value) == null ? void 0 : _a.style.removeProperty("--drawer-swipe-movement-x");
1512
+ (_b = contentRef.value) == null ? void 0 : _b.style.removeProperty("--drawer-swipe-movement-y");
1513
+ (_c = contentRef.value) == null ? void 0 : _c.style.removeProperty("--drawer-swipe-progress");
1514
+ (_d = overlayRef.value) == null ? void 0 : _d.style.removeProperty("--drawer-swipe-progress");
1515
+ }
1516
+ const { distanceX, distanceY } = usePointerSwipe(contentRef, {
1517
+ threshold: 10,
1518
+ onSwipe() {
1519
+ if (!__props.swipeToClose || !contentRef.value) return;
1520
+ const movement = getMovement(distanceX.value, distanceY.value);
1521
+ if (movement <= 0) return;
1522
+ contentRef.value.setAttribute("data-swiping", "");
1523
+ setSwipeVars(movement);
1524
+ },
1525
+ onSwipeEnd() {
1526
+ if (!contentRef.value) return;
1527
+ const movement = getMovement(distanceX.value, distanceY.value);
1528
+ if (__props.swipeToClose && movement >= DISMISS_THRESHOLD) {
1529
+ close("swipe");
1530
+ } else {
1531
+ contentRef.value.removeAttribute("data-swiping");
1532
+ clearSwipeVars();
1533
+ }
1534
+ }
1535
+ });
1536
+ function onBeforeEnter(el) {
1537
+ const h = el;
1538
+ h.style.transition = "none";
1539
+ h.style.setProperty(`--drawer-swipe-movement-${getSwipeAxis()}`, getOffscreenValue(getSwipeAxis()));
1540
+ }
1541
+ function onEnter(el, done) {
1542
+ const h = el;
1543
+ const axis = getSwipeAxis();
1544
+ h.style.transition = "";
1545
+ void h.offsetWidth;
1546
+ h.style.removeProperty(`--drawer-swipe-movement-${axis}`);
1547
+ const fallback = setTimeout(done, TRANSITION_DURATION + 50);
1548
+ h.addEventListener("transitionend", (e) => {
1549
+ if (e.propertyName === "transform") {
1550
+ clearTimeout(fallback);
1551
+ done();
1552
+ }
1553
+ }, { once: true });
1554
+ }
1555
+ function onLeave(el, done) {
1556
+ const h = el;
1557
+ h.removeAttribute("data-swiping");
1558
+ const axis = getSwipeAxis();
1559
+ void h.offsetWidth;
1560
+ h.style.setProperty(`--drawer-swipe-movement-${axis}`, getOffscreenValue(axis));
1561
+ const fallback = setTimeout(done, TRANSITION_DURATION + 50);
1562
+ h.addEventListener("transitionend", (e) => {
1563
+ if (e.propertyName === "transform") {
1564
+ clearTimeout(fallback);
1565
+ done();
1566
+ }
1567
+ }, { once: true });
1568
+ }
1569
+ function onAfterLeave() {
1570
+ clearSwipeVars();
1571
+ }
1572
+ __expose({ open, close, toggle, titleId, descriptionId });
1573
+ return (_ctx, _cache) => {
1574
+ return openBlock(), createElementBlock(Fragment, null, [
1575
+ renderSlot(_ctx.$slots, "trigger", {
1576
+ isOpen: unref(isOpen),
1577
+ open,
1578
+ close,
1579
+ toggle
1580
+ }),
1581
+ (openBlock(), createBlock(Teleport, {
1582
+ to: typeof __props.teleport === "string" ? __props.teleport : "body",
1583
+ disabled: __props.teleport === false
1584
+ }, [
1585
+ createVNode(Transition, { name: "akaza-drawer-overlay" }, {
1586
+ default: withCtx(() => {
1587
+ var _a;
1588
+ return [
1589
+ unref(isOpen) ? (openBlock(), createElementBlock("div", {
1590
+ key: 0,
1591
+ ref_key: "overlayRef",
1592
+ ref: overlayRef,
1593
+ class: normalizeClass([(_a = __props.ui) == null ? void 0 : _a.overlay, "akaza-drawer-overlay"]),
1594
+ "data-akaza-state": "open",
1595
+ onClick: onOverlayClick
1596
+ }, null, 2)) : createCommentVNode("", true)
1597
+ ];
1598
+ }),
1599
+ _: 1
1600
+ }),
1601
+ createVNode(Transition, {
1602
+ css: false,
1603
+ onBeforeEnter,
1604
+ onEnter,
1605
+ onLeave,
1606
+ onAfterLeave
1607
+ }, {
1608
+ default: withCtx(() => {
1609
+ var _a;
1610
+ return [
1611
+ unref(isOpen) ? (openBlock(), createBlock(resolveDynamicComponent(__props.as), {
1612
+ key: 0,
1613
+ ref_key: "contentRef",
1614
+ ref: contentRef,
1615
+ role: "dialog",
1616
+ "aria-modal": "true",
1617
+ "aria-labelledby": _ctx.$slots.title || __props.title ? unref(titleId) : void 0,
1618
+ "aria-describedby": _ctx.$slots.description || __props.description ? unref(descriptionId) : void 0,
1619
+ class: normalizeClass([(_a = __props.ui) == null ? void 0 : _a.content, "akaza-drawer"]),
1620
+ style: normalizeStyle(drawerStyle.value),
1621
+ "data-akaza-side": __props.side,
1622
+ "data-akaza-state": "open",
1623
+ tabindex: "-1"
1624
+ }, {
1625
+ default: withCtx(() => {
1626
+ var _a2, _b, _c, _d;
1627
+ return [
1628
+ renderSlot(_ctx.$slots, "handle"),
1629
+ _ctx.$slots.header || _ctx.$slots.title || __props.title ? (openBlock(), createElementBlock("div", {
1630
+ key: 0,
1631
+ class: normalizeClass([(_a2 = __props.ui) == null ? void 0 : _a2.header, "akaza-drawer-header"])
1632
+ }, [
1633
+ renderSlot(_ctx.$slots, "header", {
1634
+ close,
1635
+ titleId: unref(titleId)
1636
+ }, () => {
1637
+ var _a3;
1638
+ return [
1639
+ createElementVNode("div", {
1640
+ id: unref(titleId),
1641
+ class: normalizeClass([(_a3 = __props.ui) == null ? void 0 : _a3.title, "akaza-drawer-title"])
1642
+ }, [
1643
+ renderSlot(_ctx.$slots, "title", {}, () => [
1644
+ createTextVNode(toDisplayString(__props.title), 1)
1645
+ ])
1646
+ ], 10, _hoisted_1$8)
1647
+ ];
1648
+ })
1649
+ ], 2)) : createCommentVNode("", true),
1650
+ createElementVNode("div", {
1651
+ class: normalizeClass([(_b = __props.ui) == null ? void 0 : _b.body, "akaza-drawer-body"])
1652
+ }, [
1653
+ _ctx.$slots.description || __props.description ? (openBlock(), createElementBlock("div", {
1654
+ key: 0,
1655
+ id: unref(descriptionId),
1656
+ class: normalizeClass([(_c = __props.ui) == null ? void 0 : _c.description, "akaza-drawer-description"])
1657
+ }, [
1658
+ renderSlot(_ctx.$slots, "description", {}, () => [
1659
+ createTextVNode(toDisplayString(__props.description), 1)
1660
+ ])
1661
+ ], 10, _hoisted_2$7)) : createCommentVNode("", true),
1662
+ renderSlot(_ctx.$slots, "body", {
1663
+ close,
1664
+ descriptionId: unref(descriptionId)
1665
+ })
1666
+ ], 2),
1667
+ _ctx.$slots.footer ? (openBlock(), createElementBlock("div", {
1668
+ key: 1,
1669
+ class: normalizeClass([(_d = __props.ui) == null ? void 0 : _d.footer, "akaza-drawer-footer"])
1670
+ }, [
1671
+ renderSlot(_ctx.$slots, "footer", { close })
1672
+ ], 2)) : createCommentVNode("", true)
1673
+ ];
1674
+ }),
1675
+ _: 3
1676
+ }, 8, ["aria-labelledby", "aria-describedby", "class", "style", "data-akaza-side"])) : createCommentVNode("", true)
1677
+ ];
1678
+ }),
1679
+ _: 3
1680
+ })
1681
+ ], 8, ["to", "disabled"]))
1682
+ ], 64);
1683
+ };
1684
+ }
1685
+ });
1686
+ function useMenu(modelRef) {
1687
+ const isOpen = modelRef ?? ref(false);
1688
+ function open() {
1689
+ isOpen.value = true;
1690
+ }
1691
+ function close() {
1692
+ isOpen.value = false;
1693
+ }
1694
+ function toggle() {
1695
+ isOpen.value = !isOpen.value;
1696
+ }
1697
+ return { isOpen, open, close, toggle };
1698
+ }
1699
+ const MENU_CONTEXT_KEY = Symbol("MenuContext");
1700
+ const _hoisted_1$7 = ["aria-checked", "aria-disabled", "data-akaza-disabled", "data-akaza-state", "tabindex", "onClick", "onKeydown"];
1701
+ const _hoisted_2$6 = ["aria-checked", "aria-disabled", "data-akaza-disabled", "data-akaza-state", "tabindex", "onClick", "onKeydown"];
1702
+ const _hoisted_3$3 = ["onMouseenter"];
1703
+ const _hoisted_4$2 = ["aria-expanded", "aria-disabled", "data-akaza-disabled", "data-akaza-value", "tabindex"];
1704
+ const _hoisted_5 = ["data-akaza-submenu", "onKeydown"];
1705
+ const _hoisted_6 = ["aria-disabled", "data-akaza-disabled", "tabindex", "onClick", "onKeydown"];
1706
+ const FOCUSABLE = '[role="menuitem"]:not([aria-disabled]),[role="menuitemcheckbox"]:not([aria-disabled]),[role="menuitemradio"]:not([aria-disabled])';
1707
+ const _sfc_main$a = /* @__PURE__ */ defineComponent({
1708
+ ...{ name: "MenuPanel" },
1709
+ __name: "MenuPanel",
1710
+ props: {
1711
+ items: {}
1712
+ },
1713
+ setup(__props, { expose: __expose }) {
1714
+ const ctx = inject(MENU_CONTEXT_KEY);
1715
+ const panelRef = useTemplateRef("panelRef");
1716
+ const activeSubmenu = ref(null);
1717
+ function getItems(container) {
1718
+ const el = container ?? panelRef.value;
1719
+ if (!el) return [];
1720
+ return Array.from(el.querySelectorAll(FOCUSABLE)).filter(
1721
+ (item) => item.closest('[role="menu"]') === el
1722
+ );
1723
+ }
1724
+ function highlightItem(el) {
1725
+ const root = el.closest('[role="menu"]');
1726
+ getItems(root).forEach((i) => i.removeAttribute("data-akaza-highlighted"));
1727
+ el.setAttribute("data-akaza-highlighted", "");
1728
+ el.focus();
1729
+ }
1730
+ let typeaheadBuffer = "";
1731
+ let typeaheadTimer;
1732
+ function onTypeahead(char, itemEls) {
1733
+ typeaheadBuffer += char.toLowerCase();
1734
+ clearTimeout(typeaheadTimer);
1735
+ typeaheadTimer = setTimeout(() => {
1736
+ typeaheadBuffer = "";
1737
+ }, 500);
1738
+ const match = itemEls.find(
1739
+ (el) => {
1740
+ var _a;
1741
+ return (_a = el.textContent) == null ? void 0 : _a.trim().toLowerCase().startsWith(typeaheadBuffer);
1742
+ }
1743
+ );
1744
+ if (match) highlightItem(match);
1745
+ }
1746
+ function onPanelKeydown(e) {
1747
+ const itemEls = getItems();
1748
+ if (!itemEls.length) return;
1749
+ const current = itemEls.indexOf(document.activeElement);
1750
+ switch (e.key) {
1751
+ case "ArrowDown": {
1752
+ e.preventDefault();
1753
+ const next = itemEls[current < itemEls.length - 1 ? current + 1 : 0];
1754
+ if (next) highlightItem(next);
1755
+ break;
1756
+ }
1757
+ case "ArrowUp": {
1758
+ e.preventDefault();
1759
+ const prev = itemEls[current > 0 ? current - 1 : itemEls.length - 1];
1760
+ if (prev) highlightItem(prev);
1761
+ break;
1762
+ }
1763
+ case "Home": {
1764
+ e.preventDefault();
1765
+ const first = itemEls[0];
1766
+ if (first) highlightItem(first);
1767
+ break;
1768
+ }
1769
+ case "End": {
1770
+ e.preventDefault();
1771
+ const last = itemEls[itemEls.length - 1];
1772
+ if (last) highlightItem(last);
1773
+ break;
1774
+ }
1775
+ case "ArrowRight": {
1776
+ e.preventDefault();
1777
+ const target = document.activeElement;
1778
+ if ((target == null ? void 0 : target.getAttribute("aria-haspopup")) === "menu") {
1779
+ const val = target.getAttribute("data-akaza-value");
1780
+ if (val) {
1781
+ activeSubmenu.value = val;
1782
+ nextTick(() => {
1783
+ var _a, _b;
1784
+ const sub = (_a = panelRef.value) == null ? void 0 : _a.querySelector(
1785
+ `.akaza-menu-submenu-content[data-akaza-submenu="${val}"] > [role="menu"]`
1786
+ );
1787
+ const first = (_b = getItems(sub)) == null ? void 0 : _b[0];
1788
+ if (first) highlightItem(first);
1789
+ });
1790
+ }
1791
+ }
1792
+ break;
1793
+ }
1794
+ case "ArrowLeft":
1795
+ case "Escape": {
1796
+ e.preventDefault();
1797
+ break;
1798
+ }
1799
+ default: {
1800
+ if (e.key.length === 1 && !e.ctrlKey && !e.metaKey) {
1801
+ e.preventDefault();
1802
+ onTypeahead(e.key, itemEls);
1803
+ }
1804
+ }
1805
+ }
1806
+ }
1807
+ let submenuCloseTimer;
1808
+ function openSubmenu(item) {
1809
+ if (item.disabled) return;
1810
+ clearTimeout(submenuCloseTimer);
1811
+ activeSubmenu.value = ctx.getItemValue(item);
1812
+ }
1813
+ function closeSubmenuDelayed() {
1814
+ submenuCloseTimer = setTimeout(() => {
1815
+ activeSubmenu.value = null;
1816
+ }, 150);
1817
+ }
1818
+ function cancelSubmenuClose() {
1819
+ clearTimeout(submenuCloseTimer);
1820
+ }
1821
+ function onSubmenuKeydown(e, item) {
1822
+ var _a;
1823
+ if (e.key === "ArrowLeft" || e.key === "Escape") {
1824
+ e.preventDefault();
1825
+ e.stopPropagation();
1826
+ activeSubmenu.value = null;
1827
+ const trigger = (_a = panelRef.value) == null ? void 0 : _a.querySelector(
1828
+ `[data-akaza-value="${ctx.getItemValue(item)}"]`
1829
+ );
1830
+ trigger == null ? void 0 : trigger.focus();
1831
+ }
1832
+ }
1833
+ function hasRootSlot(name) {
1834
+ return !!ctx.rootSlots[name];
1835
+ }
1836
+ __expose({ panelRef, getItems, highlightItem });
1837
+ return (_ctx, _cache) => {
1838
+ const _component_MenuPanel = resolveComponent("MenuPanel", true);
1839
+ return openBlock(), createElementBlock("div", {
1840
+ ref_key: "panelRef",
1841
+ ref: panelRef,
1842
+ role: "menu",
1843
+ "aria-orientation": "vertical",
1844
+ onKeydown: onPanelKeydown
1845
+ }, [
1846
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.items, (group, gi) => {
1847
+ var _a, _b;
1848
+ return openBlock(), createElementBlock(Fragment, { key: gi }, [
1849
+ gi > 0 ? (openBlock(), createElementBlock("div", {
1850
+ key: 0,
1851
+ role: "separator",
1852
+ class: normalizeClass([(_a = unref(ctx).ui) == null ? void 0 : _a.separator, "akaza-menu-separator"])
1853
+ }, null, 2)) : createCommentVNode("", true),
1854
+ createElementVNode("div", {
1855
+ class: normalizeClass([(_b = unref(ctx).ui) == null ? void 0 : _b.group, "akaza-menu-group"]),
1856
+ role: "group"
1857
+ }, [
1858
+ (openBlock(true), createElementBlock(Fragment, null, renderList(group, (item, ii) => {
1859
+ var _a2, _b2, _c, _d, _e, _f;
1860
+ return openBlock(), createElementBlock(Fragment, {
1861
+ key: item.value ?? `${gi}-${ii}`
1862
+ }, [
1863
+ item.type === "separator" ? (openBlock(), createElementBlock("div", {
1864
+ key: 0,
1865
+ role: "separator",
1866
+ class: normalizeClass([(_a2 = unref(ctx).ui) == null ? void 0 : _a2.separator, "akaza-menu-separator"])
1867
+ }, null, 2)) : item.type === "label" ? (openBlock(), createElementBlock("div", {
1868
+ key: 1,
1869
+ class: normalizeClass([(_b2 = unref(ctx).ui) == null ? void 0 : _b2.label, "akaza-menu-label"])
1870
+ }, [
1871
+ hasRootSlot(item.slot ?? "label") ? (openBlock(), createBlock(resolveDynamicComponent(() => unref(ctx).rootSlots[item.slot ?? "label"]({ item })), { key: 0 })) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
1872
+ createTextVNode(toDisplayString(item.label), 1)
1873
+ ], 64))
1874
+ ], 2)) : item.type === "checkbox" ? (openBlock(), createElementBlock("div", {
1875
+ key: 2,
1876
+ role: "menuitemcheckbox",
1877
+ "aria-checked": item.checked ?? false,
1878
+ "aria-disabled": item.disabled || void 0,
1879
+ "data-akaza-disabled": item.disabled || void 0,
1880
+ "data-akaza-state": item.checked ? "checked" : "unchecked",
1881
+ tabindex: item.disabled ? -1 : 0,
1882
+ class: normalizeClass([(_c = unref(ctx).ui) == null ? void 0 : _c.item, "akaza-menu-item akaza-menu-checkbox-item"]),
1883
+ onClick: ($event) => unref(ctx).onCheckboxSelect(item, $event),
1884
+ onKeydown: [
1885
+ withKeys(withModifiers(($event) => unref(ctx).onCheckboxSelect(item, $event), ["prevent"]), ["enter"]),
1886
+ withKeys(withModifiers(($event) => unref(ctx).onCheckboxSelect(item, $event), ["prevent"]), ["space"])
1887
+ ]
1888
+ }, [
1889
+ hasRootSlot(item.slot ?? "checkbox-item") ? (openBlock(), createBlock(resolveDynamicComponent(
1890
+ () => unref(ctx).rootSlots[item.slot ?? "checkbox-item"]({
1891
+ item,
1892
+ checked: item.checked
1893
+ })
1894
+ ), { key: 0 })) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
1895
+ createTextVNode(toDisplayString(item.label), 1)
1896
+ ], 64))
1897
+ ], 42, _hoisted_1$7)) : item.type === "radio" ? (openBlock(), createElementBlock("div", {
1898
+ key: 3,
1899
+ role: "menuitemradio",
1900
+ "aria-checked": unref(ctx).isRadioChecked(item),
1901
+ "aria-disabled": item.disabled || void 0,
1902
+ "data-akaza-disabled": item.disabled || void 0,
1903
+ "data-akaza-state": unref(ctx).isRadioChecked(item) ? "checked" : "unchecked",
1904
+ tabindex: item.disabled ? -1 : 0,
1905
+ class: normalizeClass([(_d = unref(ctx).ui) == null ? void 0 : _d.item, "akaza-menu-item akaza-menu-radio-item"]),
1906
+ onClick: ($event) => unref(ctx).onRadioSelect(item, $event),
1907
+ onKeydown: [
1908
+ withKeys(withModifiers(($event) => unref(ctx).onRadioSelect(item, $event), ["prevent"]), ["enter"]),
1909
+ withKeys(withModifiers(($event) => unref(ctx).onRadioSelect(item, $event), ["prevent"]), ["space"])
1910
+ ]
1911
+ }, [
1912
+ hasRootSlot(item.slot ?? "radio-item") ? (openBlock(), createBlock(resolveDynamicComponent(
1913
+ () => unref(ctx).rootSlots[item.slot ?? "radio-item"]({
1914
+ item,
1915
+ checked: unref(ctx).isRadioChecked(item)
1916
+ })
1917
+ ), { key: 0 })) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
1918
+ createTextVNode(toDisplayString(item.label), 1)
1919
+ ], 64))
1920
+ ], 42, _hoisted_2$6)) : item.children ? (openBlock(), createElementBlock("div", {
1921
+ key: 4,
1922
+ class: "akaza-menu-submenu",
1923
+ onMouseenter: ($event) => openSubmenu(item),
1924
+ onMouseleave: _cache[2] || (_cache[2] = ($event) => closeSubmenuDelayed())
1925
+ }, [
1926
+ createElementVNode("div", {
1927
+ role: "menuitem",
1928
+ "aria-haspopup": "menu",
1929
+ "aria-expanded": activeSubmenu.value === unref(ctx).getItemValue(item),
1930
+ "aria-disabled": item.disabled || void 0,
1931
+ "data-akaza-disabled": item.disabled || void 0,
1932
+ "data-akaza-value": unref(ctx).getItemValue(item),
1933
+ tabindex: item.disabled ? -1 : 0,
1934
+ class: normalizeClass([(_e = unref(ctx).ui) == null ? void 0 : _e.item, "akaza-menu-item akaza-menu-submenu-trigger"])
1935
+ }, [
1936
+ hasRootSlot(item.slot ?? "item") ? (openBlock(), createBlock(resolveDynamicComponent(
1937
+ () => unref(ctx).rootSlots[item.slot ?? "item"]({
1938
+ item,
1939
+ hasSubmenu: true
1940
+ })
1941
+ ), { key: 0 })) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
1942
+ createTextVNode(toDisplayString(item.label), 1)
1943
+ ], 64))
1944
+ ], 10, _hoisted_4$2),
1945
+ createVNode(Transition, { name: "akaza-menu" }, {
1946
+ default: withCtx(() => {
1947
+ var _a3;
1948
+ return [
1949
+ activeSubmenu.value === unref(ctx).getItemValue(item) ? (openBlock(), createElementBlock("div", {
1950
+ key: 0,
1951
+ "data-akaza-submenu": unref(ctx).getItemValue(item),
1952
+ class: normalizeClass([(_a3 = unref(ctx).ui) == null ? void 0 : _a3.submenuContent, "akaza-menu-content akaza-menu-submenu-content"]),
1953
+ onKeydown: withModifiers(($event) => onSubmenuKeydown($event, item), ["stop"]),
1954
+ onMouseenter: _cache[0] || (_cache[0] = ($event) => cancelSubmenuClose()),
1955
+ onMouseleave: _cache[1] || (_cache[1] = ($event) => closeSubmenuDelayed())
1956
+ }, [
1957
+ createVNode(_component_MenuPanel, {
1958
+ items: unref(ctx).normalizeItems(item.children)
1959
+ }, null, 8, ["items"])
1960
+ ], 42, _hoisted_5)) : createCommentVNode("", true)
1961
+ ];
1962
+ }),
1963
+ _: 2
1964
+ }, 1024)
1965
+ ], 40, _hoisted_3$3)) : (openBlock(), createElementBlock("div", {
1966
+ key: 5,
1967
+ role: "menuitem",
1968
+ "aria-disabled": item.disabled || void 0,
1969
+ "data-akaza-disabled": item.disabled || void 0,
1970
+ tabindex: item.disabled ? -1 : 0,
1971
+ class: normalizeClass([(_f = unref(ctx).ui) == null ? void 0 : _f.item, "akaza-menu-item"]),
1972
+ onClick: ($event) => unref(ctx).onItemSelect(item, $event),
1973
+ onKeydown: [
1974
+ withKeys(withModifiers(($event) => unref(ctx).onItemSelect(item, $event), ["prevent"]), ["enter"]),
1975
+ withKeys(withModifiers(($event) => unref(ctx).onItemSelect(item, $event), ["prevent"]), ["space"])
1976
+ ]
1977
+ }, [
1978
+ hasRootSlot(item.slot ?? "item") ? (openBlock(), createBlock(resolveDynamicComponent(
1979
+ () => unref(ctx).rootSlots[item.slot ?? "item"]({
1980
+ item,
1981
+ hasSubmenu: false
1982
+ })
1983
+ ), { key: 0 })) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
1984
+ createTextVNode(toDisplayString(item.label), 1)
1985
+ ], 64))
1986
+ ], 42, _hoisted_6))
1987
+ ], 64);
1988
+ }), 128))
1989
+ ], 2)
1990
+ ], 64);
1991
+ }), 128))
1992
+ ], 544);
1993
+ };
1994
+ }
1995
+ });
1996
+ const _hoisted_1$6 = ["data-akaza-state"];
1997
+ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
1998
+ __name: "Menu",
1999
+ props: /* @__PURE__ */ mergeModels({
2000
+ as: { default: "div" },
2001
+ items: {},
2002
+ side: { default: "bottom" },
2003
+ align: { default: "start" },
2004
+ sideOffset: { default: 4 },
2005
+ closeOnSelect: { type: Boolean, default: true },
2006
+ radioValues: {},
2007
+ teleport: { type: [String, Boolean], default: false },
2008
+ ui: {}
2009
+ }, {
2010
+ "modelValue": { type: Boolean, ...{ default: false } },
2011
+ "modelModifiers": {}
2012
+ }),
2013
+ emits: /* @__PURE__ */ mergeModels(["open-change", "select", "check-change", "radio-change", "update:radioValues"], ["update:modelValue"]),
2014
+ setup(__props, { expose: __expose, emit: __emit }) {
2015
+ const emit = __emit;
2016
+ const model = useModel(__props, "modelValue");
2017
+ const { isOpen, open: _open, close: _close } = useMenu(model);
2018
+ function handleChange(nextOpen, reason, event) {
2019
+ let canceled = false;
2020
+ emit("open-change", nextOpen, { reason, ...event && { event }, cancel: () => {
2021
+ canceled = true;
2022
+ } });
2023
+ if (canceled) return;
2024
+ nextOpen ? _open() : _close();
2025
+ }
2026
+ function open(reason = "programmatic", event) {
2027
+ handleChange(true, reason, event);
2028
+ }
2029
+ function close(reason = "programmatic", event) {
2030
+ handleChange(false, reason, event);
2031
+ }
2032
+ function toggle(reason = "programmatic", event) {
2033
+ handleChange(!isOpen.value, reason, event);
2034
+ }
2035
+ const menuId = useId();
2036
+ const rootRef = useTemplateRef("rootRef");
2037
+ const panelRef = useTemplateRef("panelRef");
2038
+ function normalizeItems(raw) {
2039
+ if (!(raw == null ? void 0 : raw.length)) return [];
2040
+ return Array.isArray(raw[0]) ? raw : [raw];
2041
+ }
2042
+ const normalizedGroups = computed(() => normalizeItems(__props.items));
2043
+ function getItemValue(item) {
2044
+ return item.value ?? item.label ?? "";
2045
+ }
2046
+ const positionStyle = computed(() => {
2047
+ const offset = `${__props.sideOffset}px`;
2048
+ const s = {};
2049
+ if (__props.side === "bottom") s.top = `calc(100% + ${offset})`;
2050
+ else if (__props.side === "top") s.bottom = `calc(100% + ${offset})`;
2051
+ else if (__props.side === "right") s.left = `calc(100% + ${offset})`;
2052
+ else if (__props.side === "left") s.right = `calc(100% + ${offset})`;
2053
+ if (__props.side === "top" || __props.side === "bottom") {
2054
+ if (__props.align === "start") s.left = "0";
2055
+ else if (__props.align === "end") s.right = "0";
2056
+ else {
2057
+ s.left = "50%";
2058
+ s.transform = "translateX(-50%)";
2059
+ }
2060
+ } else {
2061
+ if (__props.align === "start") s.top = "0";
2062
+ else if (__props.align === "end") s.bottom = "0";
2063
+ else {
2064
+ s.top = "50%";
2065
+ s.transform = "translateY(-50%)";
2066
+ }
2067
+ }
2068
+ return s;
2069
+ });
2070
+ watch(isOpen, async (val) => {
2071
+ var _a, _b, _c;
2072
+ if (val) {
2073
+ await nextTick();
2074
+ const first = (_b = (_a = panelRef.value) == null ? void 0 : _a.getItems()) == null ? void 0 : _b[0];
2075
+ if (first) (_c = panelRef.value) == null ? void 0 : _c.highlightItem(first);
2076
+ }
2077
+ });
2078
+ onClickOutside(rootRef, (e) => {
2079
+ if (isOpen.value) close("outside-click", e);
2080
+ });
2081
+ const NAV_KEYS = /* @__PURE__ */ new Set(["ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight", "Home", "End", "Escape"]);
2082
+ function onContentKeydown(e) {
2083
+ if (NAV_KEYS.has(e.key) || e.key.length === 1 && !e.ctrlKey && !e.metaKey) {
2084
+ e.stopPropagation();
2085
+ }
2086
+ if (e.key === "Escape") {
2087
+ e.preventDefault();
2088
+ close("escape", e);
2089
+ }
2090
+ }
2091
+ function onItemSelect(item, event) {
2092
+ var _a;
2093
+ if (item.disabled) return;
2094
+ let canceled = false;
2095
+ emit("select", item, { reason: "select", event, cancel: () => {
2096
+ canceled = true;
2097
+ } });
2098
+ if (canceled) return;
2099
+ (_a = item.onSelect) == null ? void 0 : _a.call(item);
2100
+ if (__props.closeOnSelect) close("select", event);
2101
+ }
2102
+ function onCheckboxSelect(item, event) {
2103
+ var _a;
2104
+ if (item.disabled) return;
2105
+ const next = !item.checked;
2106
+ let canceled = false;
2107
+ emit("check-change", item, next, { reason: "select", event, cancel: () => {
2108
+ canceled = true;
2109
+ } });
2110
+ if (canceled) return;
2111
+ (_a = item.onUpdateChecked) == null ? void 0 : _a.call(item, next);
2112
+ }
2113
+ function isRadioChecked(item) {
2114
+ var _a;
2115
+ return ((_a = __props.radioValues) == null ? void 0 : _a[item.radioGroup ?? ""]) === item.value;
2116
+ }
2117
+ function onRadioSelect(item, event) {
2118
+ if (item.disabled) return;
2119
+ const group = item.radioGroup ?? "";
2120
+ const value = item.value ?? "";
2121
+ let canceled = false;
2122
+ emit("radio-change", group, value, { reason: "select", event, cancel: () => {
2123
+ canceled = true;
2124
+ } });
2125
+ if (canceled) return;
2126
+ if (__props.radioValues) {
2127
+ emit("update:radioValues", { ...__props.radioValues, [group]: value });
2128
+ }
2129
+ }
2130
+ const slots = useSlots();
2131
+ provide(MENU_CONTEXT_KEY, {
2132
+ ui: __props.ui,
2133
+ radioValues: __props.radioValues,
2134
+ closeOnSelect: __props.closeOnSelect,
2135
+ closeMenu: close,
2136
+ onItemSelect,
2137
+ onCheckboxSelect,
2138
+ onRadioSelect,
2139
+ isRadioChecked,
2140
+ getItemValue,
2141
+ normalizeItems,
2142
+ rootSlots: slots
2143
+ });
2144
+ const triggerProps = computed(() => ({
2145
+ "aria-haspopup": "menu",
2146
+ "aria-expanded": isOpen.value,
2147
+ "aria-controls": isOpen.value ? menuId : void 0
2148
+ }));
2149
+ __expose({ open, close, toggle });
2150
+ return (_ctx, _cache) => {
2151
+ return openBlock(), createElementBlock("div", {
2152
+ ref_key: "rootRef",
2153
+ ref: rootRef,
2154
+ "data-akaza-state": unref(isOpen) ? "open" : "closed",
2155
+ class: "akaza-menu-root"
2156
+ }, [
2157
+ renderSlot(_ctx.$slots, "trigger", {
2158
+ isOpen: unref(isOpen),
2159
+ open,
2160
+ close,
2161
+ toggle,
2162
+ triggerProps: triggerProps.value
2163
+ }),
2164
+ __props.teleport !== false ? (openBlock(), createBlock(Teleport, {
2165
+ key: 0,
2166
+ to: typeof __props.teleport === "string" ? __props.teleport : "body"
2167
+ }, [
2168
+ createVNode(Transition, { name: "akaza-menu" }, {
2169
+ default: withCtx(() => {
2170
+ var _a;
2171
+ return [
2172
+ unref(isOpen) ? (openBlock(), createBlock(resolveDynamicComponent(__props.as), {
2173
+ key: 0,
2174
+ id: unref(menuId),
2175
+ class: normalizeClass([(_a = __props.ui) == null ? void 0 : _a.content, "akaza-menu-content"]),
2176
+ style: normalizeStyle(positionStyle.value),
2177
+ "data-akaza-side": __props.side,
2178
+ "data-akaza-align": __props.align,
2179
+ "data-akaza-state": "open",
2180
+ onKeydown: onContentKeydown
2181
+ }, {
2182
+ default: withCtx(() => [
2183
+ createVNode(_sfc_main$a, {
2184
+ ref_key: "panelRef",
2185
+ ref: panelRef,
2186
+ items: normalizedGroups.value
2187
+ }, null, 8, ["items"])
2188
+ ]),
2189
+ _: 1
2190
+ }, 40, ["id", "class", "style", "data-akaza-side", "data-akaza-align"])) : createCommentVNode("", true)
2191
+ ];
2192
+ }),
2193
+ _: 1
2194
+ })
2195
+ ], 8, ["to"])) : createCommentVNode("", true),
2196
+ __props.teleport === false ? (openBlock(), createBlock(Transition, {
2197
+ key: 1,
2198
+ name: "akaza-menu"
2199
+ }, {
2200
+ default: withCtx(() => {
2201
+ var _a;
2202
+ return [
2203
+ unref(isOpen) ? (openBlock(), createBlock(resolveDynamicComponent(__props.as), {
2204
+ key: 0,
2205
+ id: unref(menuId),
2206
+ class: normalizeClass([(_a = __props.ui) == null ? void 0 : _a.content, "akaza-menu-content"]),
2207
+ style: normalizeStyle(positionStyle.value),
2208
+ "data-akaza-side": __props.side,
2209
+ "data-akaza-align": __props.align,
2210
+ "data-akaza-state": "open",
2211
+ onKeydown: onContentKeydown
2212
+ }, {
2213
+ default: withCtx(() => [
2214
+ createVNode(_sfc_main$a, {
2215
+ ref_key: "panelRef",
2216
+ ref: panelRef,
2217
+ items: normalizedGroups.value
2218
+ }, null, 8, ["items"])
2219
+ ]),
2220
+ _: 1
2221
+ }, 40, ["id", "class", "style", "data-akaza-side", "data-akaza-align"])) : createCommentVNode("", true)
2222
+ ];
2223
+ }),
2224
+ _: 1
2225
+ })) : createCommentVNode("", true)
2226
+ ], 8, _hoisted_1$6);
2227
+ };
2228
+ }
2229
+ });
2230
+ let _idCounter = 0;
2231
+ function _useOverlay() {
2232
+ const overlays = reactive([]);
2233
+ function create(component, options) {
2234
+ const id = ++_idCounter;
2235
+ const raw = {
2236
+ id,
2237
+ component,
2238
+ props: { ...options == null ? void 0 : options.props },
2239
+ modelValue: false,
2240
+ destroyOnClose: (options == null ? void 0 : options.destroyOnClose) ?? false,
2241
+ resolve: null,
2242
+ _close: () => {
2243
+ }
2244
+ // filled in below
2245
+ };
2246
+ function getEntry() {
2247
+ return overlays.find((o) => o.id === id);
2248
+ }
2249
+ function unmount() {
2250
+ const idx = overlays.findIndex((o) => o.id === id);
2251
+ if (idx !== -1) overlays.splice(idx, 1);
2252
+ }
2253
+ function close(value) {
2254
+ const entry = getEntry();
2255
+ if (entry) entry.modelValue = false;
2256
+ if (raw.resolve) {
2257
+ raw.resolve(value);
2258
+ raw.resolve = null;
2259
+ }
2260
+ if (raw.destroyOnClose) unmount();
2261
+ }
2262
+ raw._close = close;
2263
+ function open(props) {
2264
+ if (!overlays.find((o) => o.id === id)) overlays.push(raw);
2265
+ const entry = getEntry();
2266
+ if (props) Object.assign(entry.props, props);
2267
+ entry.modelValue = true;
2268
+ const result = new Promise((resolve) => {
2269
+ raw.resolve = resolve;
2270
+ });
2271
+ return { result };
2272
+ }
2273
+ function patch(props) {
2274
+ const entry = getEntry();
2275
+ if (entry) Object.assign(entry.props, props);
2276
+ }
2277
+ function isOpen() {
2278
+ const entry = getEntry();
2279
+ return (entry == null ? void 0 : entry.modelValue) ?? false;
2280
+ }
2281
+ if (options == null ? void 0 : options.defaultOpen) {
2282
+ open();
2283
+ }
2284
+ return { open, close, patch, unmount, isOpen };
2285
+ }
2286
+ return { overlays, create };
2287
+ }
2288
+ const useOverlay = /* @__PURE__ */ createSharedComposable(_useOverlay);
2289
+ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
2290
+ __name: "OverlayProvider",
2291
+ setup(__props) {
2292
+ const { overlays } = useOverlay();
2293
+ function onModelClose(overlay) {
2294
+ overlay._close(void 0);
2295
+ }
2296
+ function onCloseEvent(overlay, value) {
2297
+ overlay._close(value);
2298
+ }
2299
+ return (_ctx, _cache) => {
2300
+ return openBlock(true), createElementBlock(Fragment, null, renderList(unref(overlays), (overlay) => {
2301
+ return openBlock(), createBlock(resolveDynamicComponent(overlay.component), mergeProps({
2302
+ key: overlay.id
2303
+ }, { ref_for: true }, overlay.props, {
2304
+ "model-value": overlay.modelValue,
2305
+ "onUpdate:modelValue": (val) => {
2306
+ if (!val) onModelClose(overlay);
2307
+ },
2308
+ onClose: (val) => onCloseEvent(overlay, val)
2309
+ }), null, 16, ["model-value", "onUpdate:modelValue", "onClose"]);
2310
+ }), 128);
2311
+ };
2312
+ }
2313
+ });
2314
+ function usePopover(modelRef) {
2315
+ const isOpen = modelRef ?? ref(false);
2316
+ function open() {
2317
+ isOpen.value = true;
2318
+ }
2319
+ function close() {
2320
+ isOpen.value = false;
2321
+ }
2322
+ function toggle() {
2323
+ isOpen.value = !isOpen.value;
2324
+ }
2325
+ return { isOpen, open, close, toggle };
2326
+ }
2327
+ const _hoisted_1$5 = ["data-akaza-state"];
2328
+ const _hoisted_2$5 = ["id", "data-akaza-side", "data-akaza-align"];
2329
+ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
2330
+ __name: "Popover",
2331
+ props: /* @__PURE__ */ mergeModels({
2332
+ side: { default: "bottom" },
2333
+ align: { default: "start" },
2334
+ sideOffset: { default: 6 },
2335
+ teleport: { type: [String, Boolean], default: "body" },
2336
+ transition: { type: [String, Boolean], default: "akaza-popover" },
2337
+ ui: {}
2338
+ }, {
2339
+ "modelValue": { type: Boolean, ...{ default: false } },
2340
+ "modelModifiers": {}
2341
+ }),
2342
+ emits: /* @__PURE__ */ mergeModels(["open-change"], ["update:modelValue"]),
2343
+ setup(__props, { expose: __expose, emit: __emit }) {
2344
+ const emit = __emit;
2345
+ const model = useModel(__props, "modelValue");
2346
+ const { open: _open, close: _close } = usePopover(model);
2347
+ function handleChange(nextOpen, reason, event) {
2348
+ let canceled = false;
2349
+ emit("open-change", nextOpen, { reason, ...event && { event }, cancel: () => {
2350
+ canceled = true;
2351
+ } });
2352
+ if (canceled) return;
2353
+ nextOpen ? _open() : _close();
2354
+ }
2355
+ function open(reason = "programmatic", event) {
2356
+ handleChange(true, reason, event);
2357
+ }
2358
+ function close(reason = "programmatic", event) {
2359
+ handleChange(false, reason, event);
2360
+ }
2361
+ function toggle(reason = "programmatic", event) {
2362
+ handleChange(!model.value, reason, event);
2363
+ }
2364
+ const popoverId = useId();
2365
+ const rootRef = useTemplateRef("rootRef");
2366
+ const contentRef = useTemplateRef("contentRef");
2367
+ onClickOutside(
2368
+ rootRef,
2369
+ (e) => {
2370
+ if (model.value) close("outside-click", e);
2371
+ },
2372
+ { ignore: [contentRef] }
2373
+ );
2374
+ onKeyStroke("Escape", (e) => {
2375
+ if (model.value) {
2376
+ e.preventDefault();
2377
+ close("escape", e);
2378
+ }
2379
+ });
2380
+ const posStyle = ref({ top: "-9999px", left: "-9999px" });
2381
+ const actualSide = ref(__props.side);
2382
+ function computePosition() {
2383
+ if (!rootRef.value || !contentRef.value) return;
2384
+ const t = rootRef.value.getBoundingClientRect();
2385
+ const c = contentRef.value.getBoundingClientRect();
2386
+ const vw = window.innerWidth;
2387
+ const vh = window.innerHeight;
2388
+ const gap = __props.sideOffset;
2389
+ const order = [__props.side, "bottom", "top", "right", "left"];
2390
+ const candidates = [...new Set(order)];
2391
+ let chosen = candidates[candidates.length - 1];
2392
+ for (const d of candidates) {
2393
+ if (d === "top" && t.top >= c.height + gap) {
2394
+ chosen = d;
2395
+ break;
2396
+ }
2397
+ if (d === "bottom" && vh - t.bottom >= c.height + gap) {
2398
+ chosen = d;
2399
+ break;
2400
+ }
2401
+ if (d === "right" && vw - t.right >= c.width + gap) {
2402
+ chosen = d;
2403
+ break;
2404
+ }
2405
+ if (d === "left" && t.left >= c.width + gap) {
2406
+ chosen = d;
2407
+ break;
2408
+ }
2409
+ }
2410
+ let top = 0;
2411
+ let left = 0;
2412
+ if (chosen === "top") top = t.top - c.height - gap;
2413
+ else if (chosen === "bottom") top = t.bottom + gap;
2414
+ else if (chosen === "left") left = t.left - c.width - gap;
2415
+ else left = t.right + gap;
2416
+ if (chosen === "top" || chosen === "bottom") {
2417
+ if (__props.align === "start") left = t.left;
2418
+ else if (__props.align === "end") left = t.right - c.width;
2419
+ else left = t.left + t.width / 2 - c.width / 2;
2420
+ } else {
2421
+ if (__props.align === "start") top = t.top;
2422
+ else if (__props.align === "end") top = t.bottom - c.height;
2423
+ else top = t.top + t.height / 2 - c.height / 2;
2424
+ }
2425
+ top = Math.max(4, Math.min(top, vh - c.height - 4));
2426
+ left = Math.max(4, Math.min(left, vw - c.width - 4));
2427
+ actualSide.value = chosen;
2428
+ posStyle.value = { top: `${top}px`, left: `${left}px` };
2429
+ }
2430
+ function addListeners() {
2431
+ window.addEventListener("scroll", computePosition, { passive: true, capture: true });
2432
+ window.addEventListener("resize", computePosition, { passive: true });
2433
+ }
2434
+ function removeListeners() {
2435
+ window.removeEventListener("scroll", computePosition, { capture: true });
2436
+ window.removeEventListener("resize", computePosition);
2437
+ }
2438
+ watch(model, async (val) => {
2439
+ if (val) {
2440
+ await nextTick();
2441
+ requestAnimationFrame(computePosition);
2442
+ addListeners();
2443
+ } else {
2444
+ removeListeners();
2445
+ }
2446
+ });
2447
+ onUnmounted(removeListeners);
2448
+ const triggerProps = computed(() => ({
2449
+ "aria-haspopup": "dialog",
2450
+ "aria-expanded": model.value,
2451
+ "aria-controls": model.value ? popoverId : void 0
2452
+ }));
2453
+ __expose({ open, close, toggle });
2454
+ return (_ctx, _cache) => {
2455
+ return openBlock(), createElementBlock("div", {
2456
+ ref_key: "rootRef",
2457
+ ref: rootRef,
2458
+ "data-akaza-state": model.value ? "open" : "closed",
2459
+ class: "akaza-popover-root"
2460
+ }, [
2461
+ renderSlot(_ctx.$slots, "trigger", {
2462
+ isOpen: model.value,
2463
+ open,
2464
+ close,
2465
+ toggle,
2466
+ triggerProps: triggerProps.value
2467
+ }),
2468
+ (openBlock(), createBlock(Teleport, {
2469
+ to: typeof __props.teleport === "string" ? __props.teleport : "body",
2470
+ disabled: __props.teleport === false
2471
+ }, [
2472
+ createVNode(Transition, mergeProps(typeof __props.transition === "string" ? { name: __props.transition } : {}, {
2473
+ css: __props.transition !== false
2474
+ }), {
2475
+ default: withCtx(() => {
2476
+ var _a;
2477
+ return [
2478
+ model.value ? (openBlock(), createElementBlock("div", {
2479
+ key: 0,
2480
+ id: unref(popoverId),
2481
+ ref_key: "contentRef",
2482
+ ref: contentRef,
2483
+ class: normalizeClass([(_a = __props.ui) == null ? void 0 : _a.content, "akaza-popover-content"]),
2484
+ style: normalizeStyle(posStyle.value),
2485
+ "data-akaza-side": actualSide.value,
2486
+ "data-akaza-align": __props.align,
2487
+ "data-akaza-state": "open"
2488
+ }, [
2489
+ renderSlot(_ctx.$slots, "content", { close })
2490
+ ], 14, _hoisted_2$5)) : createCommentVNode("", true)
2491
+ ];
2492
+ }),
2493
+ _: 3
2494
+ }, 16, ["css"])
2495
+ ], 8, ["to", "disabled"]))
2496
+ ], 8, _hoisted_1$5);
2497
+ };
2498
+ }
2499
+ });
2500
+ const _hoisted_1$4 = ["aria-label", "aria-valuemin", "aria-valuemax", "aria-valuenow", "aria-valuetext", "data-akaza-state", "data-akaza-orientation"];
2501
+ const _hoisted_2$4 = ["data-akaza-state"];
2502
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
2503
+ __name: "Progress",
2504
+ props: /* @__PURE__ */ mergeModels({
2505
+ min: { default: 0 },
2506
+ max: { default: 100 },
2507
+ orientation: { default: "horizontal" },
2508
+ ariaLabel: {},
2509
+ getValueLabel: { type: Function },
2510
+ ui: {}
2511
+ }, {
2512
+ "modelValue": { default: null },
2513
+ "modelModifiers": {}
2514
+ }),
2515
+ emits: ["update:modelValue"],
2516
+ setup(__props) {
2517
+ const model = useModel(__props, "modelValue");
2518
+ const state = computed(() => {
2519
+ if (model.value === null) return "indeterminate";
2520
+ return model.value >= __props.max ? "complete" : "loading";
2521
+ });
2522
+ const percentage = computed(() => {
2523
+ if (model.value === null) return null;
2524
+ const range = __props.max - __props.min;
2525
+ if (range <= 0) return 0;
2526
+ return Math.min(100, Math.max(0, (model.value - __props.min) / range * 100));
2527
+ });
2528
+ const ariaValueText = computed(() => {
2529
+ if (__props.getValueLabel) return __props.getValueLabel(model.value, __props.max);
2530
+ return void 0;
2531
+ });
2532
+ return (_ctx, _cache) => {
2533
+ var _a, _b;
2534
+ return openBlock(), createElementBlock("div", {
2535
+ role: "progressbar",
2536
+ "aria-label": __props.ariaLabel,
2537
+ "aria-valuemin": __props.min,
2538
+ "aria-valuemax": __props.max,
2539
+ "aria-valuenow": model.value ?? void 0,
2540
+ "aria-valuetext": ariaValueText.value,
2541
+ class: normalizeClass([(_a = __props.ui) == null ? void 0 : _a.root, "akaza-progress"]),
2542
+ "data-akaza-state": state.value,
2543
+ "data-akaza-orientation": __props.orientation,
2544
+ style: normalizeStyle(percentage.value !== null ? { "--akaza-progress-percentage": `${percentage.value}%` } : {})
2545
+ }, [
2546
+ createElementVNode("div", {
2547
+ class: normalizeClass([(_b = __props.ui) == null ? void 0 : _b.indicator, "akaza-progress-indicator"]),
2548
+ "data-akaza-state": state.value
2549
+ }, [
2550
+ renderSlot(_ctx.$slots, "indicator", {
2551
+ value: model.value,
2552
+ percentage: percentage.value,
2553
+ max: __props.max,
2554
+ min: __props.min,
2555
+ state: state.value
2556
+ })
2557
+ ], 10, _hoisted_2$4)
2558
+ ], 14, _hoisted_1$4);
2559
+ };
2560
+ }
2561
+ });
2562
+ const _hoisted_1$3 = ["name", "value", "required"];
2563
+ const _hoisted_2$3 = ["aria-checked", "tabindex", "data-akaza-state", "data-akaza-disabled", "disabled", "onClick", "onKeydown"];
2564
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
2565
+ __name: "RadioGroup",
2566
+ props: /* @__PURE__ */ mergeModels({
2567
+ options: {},
2568
+ valueKey: {},
2569
+ labelKey: { default: "label" },
2570
+ descriptionKey: { default: "description" },
2571
+ disabled: { type: Boolean, default: false },
2572
+ orientation: { default: "vertical" },
2573
+ as: { default: "div" },
2574
+ legend: {},
2575
+ loop: { type: Boolean, default: true },
2576
+ name: {},
2577
+ required: { type: Boolean },
2578
+ ariaLabel: {},
2579
+ ariaLabelledby: {},
2580
+ getItemDisabled: { type: Function },
2581
+ ui: {}
2582
+ }, {
2583
+ "modelValue": { default: "" },
2584
+ "modelModifiers": {}
2585
+ }),
2586
+ emits: ["update:modelValue"],
2587
+ setup(__props) {
2588
+ const model = useModel(__props, "modelValue");
2589
+ function getValue(option) {
2590
+ if (__props.valueKey) return String(option[__props.valueKey]);
2591
+ if (typeof option === "string" || typeof option === "number") return String(option);
2592
+ return String((option == null ? void 0 : option.value) ?? (option == null ? void 0 : option.id) ?? option);
2593
+ }
2594
+ function getLabel(option) {
2595
+ if (typeof option === "string" || typeof option === "number") return String(option);
2596
+ if (__props.labelKey && (option == null ? void 0 : option[__props.labelKey]) !== void 0) return String(option[__props.labelKey]);
2597
+ return (option == null ? void 0 : option.label) !== void 0 ? String(option.label) : void 0;
2598
+ }
2599
+ function getDescription(option) {
2600
+ if (__props.descriptionKey && (option == null ? void 0 : option[__props.descriptionKey]) !== void 0) return String(option[__props.descriptionKey]);
2601
+ return (option == null ? void 0 : option.description) !== void 0 ? String(option.description) : void 0;
2602
+ }
2603
+ function isItemDisabled(option) {
2604
+ if (__props.disabled) return true;
2605
+ if (__props.getItemDisabled) return __props.getItemDisabled(option);
2606
+ return (option == null ? void 0 : option.disabled) === true;
2607
+ }
2608
+ const itemEls = [];
2609
+ function setItemRef(el, index) {
2610
+ itemEls[index] = el;
2611
+ }
2612
+ function focusItem(index) {
2613
+ var _a;
2614
+ (_a = itemEls[index]) == null ? void 0 : _a.focus();
2615
+ }
2616
+ function getRovingIndex() {
2617
+ const selectedIdx = __props.options.findIndex((o) => getValue(o) === model.value && !isItemDisabled(o));
2618
+ if (selectedIdx >= 0) return selectedIdx;
2619
+ return __props.options.findIndex((o) => !isItemDisabled(o));
2620
+ }
2621
+ function getTabIndex(index) {
2622
+ if (__props.disabled) return -1;
2623
+ return index === getRovingIndex() ? 0 : -1;
2624
+ }
2625
+ function select(option) {
2626
+ if (!isItemDisabled(option)) model.value = getValue(option);
2627
+ }
2628
+ function handleKeyDown(event, index) {
2629
+ const isVertical = __props.orientation === "vertical";
2630
+ const isPrev = event.key === (isVertical ? "ArrowUp" : "ArrowLeft");
2631
+ const isNext = event.key === (isVertical ? "ArrowDown" : "ArrowRight");
2632
+ const isHome = event.key === "Home";
2633
+ const isEnd = event.key === "End";
2634
+ const isSpace = event.key === " ";
2635
+ if (isSpace) {
2636
+ event.preventDefault();
2637
+ select(__props.options[index]);
2638
+ return;
2639
+ }
2640
+ if (!isPrev && !isNext && !isHome && !isEnd) return;
2641
+ event.preventDefault();
2642
+ const count = __props.options.length;
2643
+ let target = index;
2644
+ if (isPrev) {
2645
+ let candidate = __props.loop ? (index - 1 + count) % count : index - 1;
2646
+ let steps = 0;
2647
+ while (candidate >= 0 && candidate < count && isItemDisabled(__props.options[candidate]) && steps < count) {
2648
+ candidate = __props.loop ? (candidate - 1 + count) % count : candidate - 1;
2649
+ steps++;
2650
+ }
2651
+ if (candidate >= 0 && candidate < count && !isItemDisabled(__props.options[candidate])) target = candidate;
2652
+ } else if (isNext) {
2653
+ let candidate = __props.loop ? (index + 1) % count : index + 1;
2654
+ let steps = 0;
2655
+ while (candidate >= 0 && candidate < count && isItemDisabled(__props.options[candidate]) && steps < count) {
2656
+ candidate = __props.loop ? (candidate + 1) % count : candidate + 1;
2657
+ steps++;
2658
+ }
2659
+ if (candidate >= 0 && candidate < count && !isItemDisabled(__props.options[candidate])) target = candidate;
2660
+ } else if (isHome) {
2661
+ let candidate = 0;
2662
+ while (candidate < count - 1 && isItemDisabled(__props.options[candidate])) candidate++;
2663
+ if (!isItemDisabled(__props.options[candidate])) target = candidate;
2664
+ } else if (isEnd) {
2665
+ let candidate = count - 1;
2666
+ while (candidate > 0 && isItemDisabled(__props.options[candidate])) candidate--;
2667
+ if (!isItemDisabled(__props.options[candidate])) target = candidate;
2668
+ }
2669
+ if (target !== index) {
2670
+ model.value = getValue(__props.options[target]);
2671
+ focusItem(target);
2672
+ }
2673
+ }
2674
+ return (_ctx, _cache) => {
2675
+ return openBlock(), createBlock(resolveDynamicComponent(__props.as), {
2676
+ role: "radiogroup",
2677
+ "aria-label": __props.ariaLabel ?? __props.legend,
2678
+ "aria-labelledby": __props.ariaLabelledby,
2679
+ "aria-orientation": __props.orientation,
2680
+ "aria-required": __props.required || void 0,
2681
+ "data-akaza-orientation": __props.orientation,
2682
+ "data-akaza-disabled": __props.disabled || void 0,
2683
+ class: "akaza-radio-group"
2684
+ }, {
2685
+ default: withCtx(() => [
2686
+ __props.name ? (openBlock(), createElementBlock("input", {
2687
+ key: 0,
2688
+ type: "hidden",
2689
+ name: __props.name,
2690
+ value: model.value,
2691
+ required: __props.required
2692
+ }, null, 8, _hoisted_1$3)) : createCommentVNode("", true),
2693
+ renderSlot(_ctx.$slots, "legend", { legend: __props.legend }, () => {
2694
+ var _a;
2695
+ return [
2696
+ __props.legend ? (openBlock(), createElementBlock("span", {
2697
+ key: 0,
2698
+ class: normalizeClass([(_a = __props.ui) == null ? void 0 : _a.legend, "akaza-radio-group-legend"])
2699
+ }, toDisplayString(__props.legend), 3)) : createCommentVNode("", true)
2700
+ ];
2701
+ }),
2702
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.options, (option, index) => {
2703
+ var _a;
2704
+ return openBlock(), createElementBlock("button", {
2705
+ key: getValue(option),
2706
+ ref_for: true,
2707
+ ref: (el) => setItemRef(el, index),
2708
+ type: "button",
2709
+ role: "radio",
2710
+ "aria-checked": model.value === getValue(option),
2711
+ tabindex: getTabIndex(index),
2712
+ class: normalizeClass([(_a = __props.ui) == null ? void 0 : _a.item, "akaza-radio-group-item"]),
2713
+ "data-akaza-state": model.value === getValue(option) ? "checked" : "unchecked",
2714
+ "data-akaza-disabled": isItemDisabled(option) || void 0,
2715
+ disabled: isItemDisabled(option),
2716
+ onClick: ($event) => select(option),
2717
+ onKeydown: ($event) => handleKeyDown($event, index)
2718
+ }, [
2719
+ renderSlot(_ctx.$slots, "item", {
2720
+ option,
2721
+ value: getValue(option),
2722
+ label: getLabel(option),
2723
+ description: getDescription(option),
2724
+ isChecked: model.value === getValue(option),
2725
+ isDisabled: isItemDisabled(option),
2726
+ select: () => select(option)
2727
+ })
2728
+ ], 42, _hoisted_2$3);
2729
+ }), 128))
2730
+ ]),
2731
+ _: 3
2732
+ }, 8, ["aria-label", "aria-labelledby", "aria-orientation", "aria-required", "data-akaza-orientation", "data-akaza-disabled"]);
2733
+ };
2734
+ }
2735
+ });
2736
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
2737
+ __name: "Separator",
2738
+ props: {
2739
+ as: { default: "div" },
2740
+ orientation: { default: "horizontal" },
2741
+ decorative: { type: Boolean, default: false }
2742
+ },
2743
+ setup(__props) {
2744
+ return (_ctx, _cache) => {
2745
+ return openBlock(), createBlock(resolveDynamicComponent(__props.as), {
2746
+ role: __props.decorative ? "none" : "separator",
2747
+ "aria-orientation": !__props.decorative ? __props.orientation : void 0,
2748
+ "data-akaza-orientation": __props.orientation,
2749
+ class: "akaza-separator"
2750
+ }, null, 8, ["role", "aria-orientation", "data-akaza-orientation"]);
2751
+ };
2752
+ }
2753
+ });
2754
+ const _hoisted_1$2 = ["id", "aria-checked", "aria-label", "aria-labelledby", "aria-describedby", "data-akaza-state", "data-akaza-disabled", "disabled"];
2755
+ const _hoisted_2$2 = ["data-akaza-state"];
2756
+ const _hoisted_3$2 = ["name", "value", "checked", "required"];
2757
+ const _hoisted_4$1 = {
2758
+ key: 1,
2759
+ class: "akaza-switch-text"
2760
+ };
2761
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
2762
+ __name: "Switch",
2763
+ props: /* @__PURE__ */ mergeModels({
2764
+ disabled: { type: Boolean, default: false },
2765
+ id: {},
2766
+ name: {},
2767
+ required: { type: Boolean, default: false },
2768
+ trueValue: { type: [Boolean, String, Number], default: true },
2769
+ falseValue: { type: [Boolean, String, Number], default: false },
2770
+ label: {},
2771
+ description: {},
2772
+ ariaLabel: {},
2773
+ ui: {}
2774
+ }, {
2775
+ "modelValue": { type: [Boolean, String, Number], ...{ default: false } },
2776
+ "modelModifiers": {}
2777
+ }),
2778
+ emits: /* @__PURE__ */ mergeModels(["value-change"], ["update:modelValue"]),
2779
+ setup(__props, { emit: __emit }) {
2780
+ const emit = __emit;
2781
+ const model = useModel(__props, "modelValue");
2782
+ const slots = useSlots();
2783
+ const autoId = useId();
2784
+ const buttonId = computed(() => __props.id ?? `akaza-switch-${autoId}`);
2785
+ const labelId = `akaza-switch-label-${autoId}`;
2786
+ const descriptionId = `akaza-switch-desc-${autoId}`;
2787
+ const hasLabel = computed(() => !!(__props.label || slots.label));
2788
+ const hasDescription = computed(() => !!(__props.description || slots.description));
2789
+ const isChecked = computed(() => model.value === __props.trueValue);
2790
+ function toggle(reason = "click", event) {
2791
+ if (__props.disabled) return;
2792
+ const nextValue = isChecked.value ? __props.falseValue : __props.trueValue;
2793
+ let canceled = false;
2794
+ emit("value-change", nextValue, { reason, ...event && { event }, cancel: () => {
2795
+ canceled = true;
2796
+ } });
2797
+ if (canceled) return;
2798
+ model.value = nextValue;
2799
+ }
2800
+ return (_ctx, _cache) => {
2801
+ var _a, _b, _c, _d, _e;
2802
+ return openBlock(), createElementBlock("span", {
2803
+ class: normalizeClass([(_a = __props.ui) == null ? void 0 : _a.wrapper, "akaza-switch-wrapper"])
2804
+ }, [
2805
+ createElementVNode("button", {
2806
+ type: "button",
2807
+ role: "switch",
2808
+ id: buttonId.value,
2809
+ "aria-checked": isChecked.value,
2810
+ "aria-label": !hasLabel.value ? __props.ariaLabel : void 0,
2811
+ "aria-labelledby": hasLabel.value ? labelId : void 0,
2812
+ "aria-describedby": hasDescription.value ? descriptionId : void 0,
2813
+ class: normalizeClass([(_b = __props.ui) == null ? void 0 : _b.root, "akaza-switch"]),
2814
+ "data-akaza-state": isChecked.value ? "checked" : "unchecked",
2815
+ "data-akaza-disabled": __props.disabled || void 0,
2816
+ disabled: __props.disabled,
2817
+ onClick: _cache[0] || (_cache[0] = ($event) => toggle("click", $event)),
2818
+ onKeydown: [
2819
+ _cache[1] || (_cache[1] = withKeys(withModifiers(($event) => toggle("keyboard", $event), ["prevent"]), ["space"])),
2820
+ _cache[2] || (_cache[2] = withKeys(withModifiers(($event) => toggle("keyboard", $event), ["prevent"]), ["enter"]))
2821
+ ]
2822
+ }, [
2823
+ createElementVNode("span", {
2824
+ class: normalizeClass([(_c = __props.ui) == null ? void 0 : _c.thumb, "akaza-switch-thumb"]),
2825
+ "data-akaza-state": isChecked.value ? "checked" : "unchecked"
2826
+ }, [
2827
+ renderSlot(_ctx.$slots, "thumb", { checked: isChecked.value })
2828
+ ], 10, _hoisted_2$2)
2829
+ ], 42, _hoisted_1$2),
2830
+ __props.name ? (openBlock(), createElementBlock("input", {
2831
+ key: 0,
2832
+ type: "checkbox",
2833
+ name: __props.name,
2834
+ value: String(__props.trueValue),
2835
+ checked: isChecked.value,
2836
+ required: __props.required,
2837
+ "aria-hidden": "true",
2838
+ tabindex: "-1",
2839
+ class: "akaza-switch-input"
2840
+ }, null, 8, _hoisted_3$2)) : createCommentVNode("", true),
2841
+ hasLabel.value || hasDescription.value ? (openBlock(), createElementBlock("span", _hoisted_4$1, [
2842
+ hasLabel.value ? (openBlock(), createElementBlock("span", {
2843
+ key: 0,
2844
+ id: labelId,
2845
+ class: normalizeClass([(_d = __props.ui) == null ? void 0 : _d.label, "akaza-switch-label"])
2846
+ }, [
2847
+ renderSlot(_ctx.$slots, "label", {}, () => [
2848
+ createTextVNode(toDisplayString(__props.label), 1)
2849
+ ])
2850
+ ], 2)) : createCommentVNode("", true),
2851
+ hasDescription.value ? (openBlock(), createElementBlock("span", {
2852
+ key: 1,
2853
+ id: descriptionId,
2854
+ class: normalizeClass([(_e = __props.ui) == null ? void 0 : _e.description, "akaza-switch-description"])
2855
+ }, [
2856
+ renderSlot(_ctx.$slots, "description", {}, () => [
2857
+ createTextVNode(toDisplayString(__props.description), 1)
2858
+ ])
2859
+ ], 2)) : createCommentVNode("", true)
2860
+ ])) : createCommentVNode("", true)
2861
+ ], 2);
2862
+ };
2863
+ }
2864
+ });
2865
+ const _hoisted_1$1 = ["data-akaza-orientation"];
2866
+ const _hoisted_2$1 = ["aria-label", "aria-orientation"];
2867
+ const _hoisted_3$1 = ["id", "aria-selected", "aria-controls", "aria-disabled", "tabindex", "data-akaza-state", "data-akaza-value", "data-akaza-disabled", "disabled", "onClick", "onKeydown"];
2868
+ const _hoisted_4 = ["id", "aria-labelledby", "data-akaza-state"];
2869
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
2870
+ __name: "Tabs",
2871
+ props: /* @__PURE__ */ mergeModels({
2872
+ items: {},
2873
+ orientation: { default: "horizontal" },
2874
+ activationMode: { default: "automatic" },
2875
+ unmountOnHide: { type: Boolean, default: false },
2876
+ ariaLabel: {},
2877
+ labelKey: { default: "label" },
2878
+ ui: {}
2879
+ }, {
2880
+ "modelValue": { default: "" },
2881
+ "modelModifiers": {}
2882
+ }),
2883
+ emits: ["update:modelValue"],
2884
+ setup(__props) {
2885
+ const model = useModel(__props, "modelValue");
2886
+ function getLabel(item) {
2887
+ if (__props.labelKey && item[__props.labelKey] !== void 0) return String(item[__props.labelKey]);
2888
+ return item.label ?? item.value;
2889
+ }
2890
+ function isActive(item) {
2891
+ return model.value === item.value;
2892
+ }
2893
+ const rovingValue = computed(() => {
2894
+ var _a;
2895
+ if (model.value && __props.items.some((i) => i.value === model.value && !i.disabled)) return model.value;
2896
+ return ((_a = __props.items.find((i) => !i.disabled)) == null ? void 0 : _a.value) ?? "";
2897
+ });
2898
+ const tabEls = [];
2899
+ function setTabRef(el, index) {
2900
+ tabEls[index] = el;
2901
+ }
2902
+ const listRef = ref(null);
2903
+ const indicatorStyle = ref({ left: "0px", width: "0px", top: "0px", height: "0px" });
2904
+ function updateIndicator() {
2905
+ if (!listRef.value) return;
2906
+ const activeIdx = __props.items.findIndex((i) => isActive(i));
2907
+ const activeEl = activeIdx >= 0 ? tabEls[activeIdx] : null;
2908
+ if (!activeEl) return;
2909
+ const containerRect = listRef.value.getBoundingClientRect();
2910
+ const tabRect = activeEl.getBoundingClientRect();
2911
+ if (__props.orientation === "horizontal") {
2912
+ indicatorStyle.value = { left: `${tabRect.left - containerRect.left}px`, width: `${tabRect.width}px`, top: "", height: "" };
2913
+ } else {
2914
+ indicatorStyle.value = { top: `${tabRect.top - containerRect.top}px`, height: `${tabRect.height}px`, left: "", width: "" };
2915
+ }
2916
+ }
2917
+ watch(() => model.value, async () => {
2918
+ await nextTick();
2919
+ updateIndicator();
2920
+ });
2921
+ onMounted(async () => {
2922
+ await nextTick();
2923
+ updateIndicator();
2924
+ });
2925
+ onKeyStroke(["ArrowRight", "ArrowLeft", "ArrowDown", "ArrowUp", "Home", "End"], (e) => {
2926
+ var _a, _b, _c, _d;
2927
+ if (!((_a = listRef.value) == null ? void 0 : _a.contains(document.activeElement))) return;
2928
+ const enabled = __props.items.filter((i) => !i.disabled);
2929
+ if (enabled.length === 0) return;
2930
+ const isHorizontal = __props.orientation === "horizontal";
2931
+ const isPrev = isHorizontal && e.key === "ArrowLeft" || !isHorizontal && e.key === "ArrowUp";
2932
+ const isNext = isHorizontal && e.key === "ArrowRight" || !isHorizontal && e.key === "ArrowDown";
2933
+ if (!isPrev && !isNext && e.key !== "Home" && e.key !== "End") return;
2934
+ e.preventDefault();
2935
+ const focusedValue = ((_c = (_b = document.activeElement) == null ? void 0 : _b.dataset) == null ? void 0 : _c.akazaValue) ?? "";
2936
+ const fromIdx = enabled.findIndex((i) => i.value === focusedValue);
2937
+ const currentIdx = fromIdx >= 0 ? fromIdx : enabled.findIndex((i) => i.value === model.value);
2938
+ let nextIdx = currentIdx;
2939
+ if (isPrev) nextIdx = currentIdx > 0 ? currentIdx - 1 : enabled.length - 1;
2940
+ else if (isNext) nextIdx = currentIdx < enabled.length - 1 ? currentIdx + 1 : 0;
2941
+ else if (e.key === "Home") nextIdx = 0;
2942
+ else if (e.key === "End") nextIdx = enabled.length - 1;
2943
+ const nextItem = enabled[nextIdx];
2944
+ if (!nextItem) return;
2945
+ const nextOrigIdx = __props.items.findIndex((i) => i.value === nextItem.value);
2946
+ (_d = tabEls[nextOrigIdx]) == null ? void 0 : _d.focus();
2947
+ if (__props.activationMode === "automatic") model.value = nextItem.value;
2948
+ });
2949
+ function activate(item) {
2950
+ if (!item.disabled) model.value = item.value;
2951
+ }
2952
+ return (_ctx, _cache) => {
2953
+ var _a, _b, _c, _d;
2954
+ return openBlock(), createElementBlock("div", {
2955
+ "data-akaza-orientation": __props.orientation,
2956
+ class: normalizeClass([(_a = __props.ui) == null ? void 0 : _a.root, "akaza-tabs"])
2957
+ }, [
2958
+ createElementVNode("div", {
2959
+ ref_key: "listRef",
2960
+ ref: listRef,
2961
+ role: "tablist",
2962
+ "aria-label": __props.ariaLabel,
2963
+ "aria-orientation": __props.orientation,
2964
+ class: normalizeClass([(_b = __props.ui) == null ? void 0 : _b.list, "akaza-tab-list"])
2965
+ }, [
2966
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.items, (item, index) => {
2967
+ var _a2;
2968
+ return openBlock(), createElementBlock("button", {
2969
+ key: item.value,
2970
+ ref_for: true,
2971
+ ref: (el) => setTabRef(el, index),
2972
+ type: "button",
2973
+ role: "tab",
2974
+ id: `akaza-tab-${item.value}`,
2975
+ "aria-selected": isActive(item),
2976
+ "aria-controls": `akaza-panel-${item.value}`,
2977
+ "aria-disabled": item.disabled || void 0,
2978
+ tabindex: rovingValue.value === item.value ? 0 : -1,
2979
+ "data-akaza-state": isActive(item) ? "active" : "inactive",
2980
+ "data-akaza-value": item.value,
2981
+ "data-akaza-disabled": item.disabled || void 0,
2982
+ disabled: item.disabled,
2983
+ class: normalizeClass([(_a2 = __props.ui) == null ? void 0 : _a2.tab, "akaza-tab"]),
2984
+ onClick: ($event) => activate(item),
2985
+ onKeydown: [
2986
+ withKeys(withModifiers(($event) => activate(item), ["prevent"]), ["enter"]),
2987
+ withKeys(withModifiers(($event) => activate(item), ["prevent"]), ["space"])
2988
+ ]
2989
+ }, [
2990
+ renderSlot(_ctx.$slots, "tab", {
2991
+ item,
2992
+ isActive: isActive(item),
2993
+ select: () => activate(item)
2994
+ }, () => [
2995
+ createTextVNode(toDisplayString(getLabel(item)), 1)
2996
+ ])
2997
+ ], 42, _hoisted_3$1);
2998
+ }), 128)),
2999
+ createElementVNode("span", {
3000
+ class: normalizeClass(["akaza-tab-indicator", (_c = __props.ui) == null ? void 0 : _c.indicator]),
3001
+ style: normalizeStyle(indicatorStyle.value),
3002
+ "aria-hidden": "true"
3003
+ }, null, 6)
3004
+ ], 10, _hoisted_2$1),
3005
+ createElementVNode("div", {
3006
+ class: normalizeClass([(_d = __props.ui) == null ? void 0 : _d.panels, "akaza-tab-panels"])
3007
+ }, [
3008
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.items, (item) => {
3009
+ var _a2;
3010
+ return openBlock(), createElementBlock(Fragment, {
3011
+ key: item.value
3012
+ }, [
3013
+ !__props.unmountOnHide || isActive(item) ? withDirectives((openBlock(), createElementBlock("div", {
3014
+ key: 0,
3015
+ id: `akaza-panel-${item.value}`,
3016
+ role: "tabpanel",
3017
+ "aria-labelledby": `akaza-tab-${item.value}`,
3018
+ tabindex: 0,
3019
+ "data-akaza-state": isActive(item) ? "active" : "inactive",
3020
+ class: normalizeClass([(_a2 = __props.ui) == null ? void 0 : _a2.panel, "akaza-tab-panel"])
3021
+ }, [
3022
+ renderSlot(_ctx.$slots, `panel-${item.value}`, {
3023
+ item,
3024
+ isActive: isActive(item)
3025
+ })
3026
+ ], 10, _hoisted_4)), [
3027
+ [vShow, isActive(item)]
3028
+ ]) : createCommentVNode("", true)
3029
+ ], 64);
3030
+ }), 128))
3031
+ ], 2)
3032
+ ], 10, _hoisted_1$1);
3033
+ };
3034
+ }
3035
+ });
3036
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
3037
+ __name: "Toggle",
3038
+ props: /* @__PURE__ */ mergeModels({
3039
+ as: { default: "button" },
3040
+ disabled: { type: Boolean, default: false },
3041
+ value: {},
3042
+ ariaLabel: {},
3043
+ ui: {}
3044
+ }, {
3045
+ "modelValue": { type: Boolean, ...{ default: false } },
3046
+ "modelModifiers": {}
3047
+ }),
3048
+ emits: ["update:modelValue"],
3049
+ setup(__props) {
3050
+ const model = useModel(__props, "modelValue");
3051
+ function toggle() {
3052
+ if (!__props.disabled) model.value = !model.value;
3053
+ }
3054
+ return (_ctx, _cache) => {
3055
+ var _a;
3056
+ return openBlock(), createBlock(resolveDynamicComponent(__props.as), {
3057
+ type: __props.as === "button" ? "button" : void 0,
3058
+ "aria-pressed": model.value,
3059
+ "aria-label": __props.ariaLabel,
3060
+ "data-akaza-state": model.value ? "on" : "off",
3061
+ "data-akaza-disabled": __props.disabled || void 0,
3062
+ disabled: __props.as === "button" ? __props.disabled : void 0,
3063
+ class: normalizeClass([(_a = __props.ui) == null ? void 0 : _a.root, "akaza-toggle"]),
3064
+ onClick: toggle
3065
+ }, {
3066
+ default: withCtx(() => [
3067
+ renderSlot(_ctx.$slots, "default", {
3068
+ pressed: model.value,
3069
+ state: model.value ? "on" : "off"
3070
+ })
3071
+ ]),
3072
+ _: 3
3073
+ }, 8, ["type", "aria-pressed", "aria-label", "data-akaza-state", "data-akaza-disabled", "disabled", "class"]);
3074
+ };
3075
+ }
3076
+ });
3077
+ function useTooltip(modelRef, options = {}) {
3078
+ const isOpen = modelRef ?? ref(false);
3079
+ const { delayDuration = 300, closeDelay = 0 } = options;
3080
+ let openTimer = null;
3081
+ let closeTimer = null;
3082
+ function open() {
3083
+ if (closeTimer) {
3084
+ clearTimeout(closeTimer);
3085
+ closeTimer = null;
3086
+ }
3087
+ openTimer = setTimeout(() => {
3088
+ isOpen.value = true;
3089
+ }, delayDuration);
3090
+ }
3091
+ function close() {
3092
+ if (openTimer) {
3093
+ clearTimeout(openTimer);
3094
+ openTimer = null;
3095
+ }
3096
+ closeTimer = setTimeout(() => {
3097
+ isOpen.value = false;
3098
+ }, closeDelay);
3099
+ }
3100
+ function toggle() {
3101
+ isOpen.value ? close() : open();
3102
+ }
3103
+ return { isOpen, open, close, toggle };
3104
+ }
3105
+ const _hoisted_1 = ["aria-describedby", "data-akaza-state"];
3106
+ const _hoisted_2 = ["id", "data-akaza-direction"];
3107
+ const _hoisted_3 = {
3108
+ key: 0,
3109
+ class: "akaza-tooltip-arrow",
3110
+ "aria-hidden": "true"
3111
+ };
3112
+ const GAP = 8;
3113
+ const _sfc_main = /* @__PURE__ */ defineComponent({
3114
+ __name: "Tooltip",
3115
+ props: /* @__PURE__ */ mergeModels({
3116
+ direction: { default: "top" },
3117
+ delayDuration: { default: 300 },
3118
+ closeDelay: { default: 0 },
3119
+ disabled: { type: Boolean, default: false },
3120
+ arrow: { type: Boolean, default: false },
3121
+ teleport: { type: [String, Boolean], default: "body" },
3122
+ transition: { type: [String, Boolean], default: "akaza-tooltip" },
3123
+ ui: {}
3124
+ }, {
3125
+ "modelValue": { type: Boolean, ...{ default: false } },
3126
+ "modelModifiers": {}
3127
+ }),
3128
+ emits: ["update:modelValue"],
3129
+ setup(__props) {
3130
+ const model = useModel(__props, "modelValue");
3131
+ const { open: _open, close: _close } = useTooltip(model, { delayDuration: __props.delayDuration, closeDelay: __props.closeDelay });
3132
+ function open() {
3133
+ if (!__props.disabled) _open();
3134
+ }
3135
+ function close() {
3136
+ if (!__props.disabled || model.value) _close();
3137
+ }
3138
+ const tooltipId = useId();
3139
+ const triggerRef = useTemplateRef("triggerRef");
3140
+ const contentRef = useTemplateRef("contentRef");
3141
+ const posStyle = ref({ top: "-9999px", left: "-9999px" });
3142
+ const actualDirection = ref(__props.direction);
3143
+ function computePosition() {
3144
+ if (!triggerRef.value || !contentRef.value) return;
3145
+ const t = triggerRef.value.getBoundingClientRect();
3146
+ const c = contentRef.value.getBoundingClientRect();
3147
+ const vw = window.innerWidth;
3148
+ const vh = window.innerHeight;
3149
+ const order = [__props.direction, "top", "bottom", "right", "left"];
3150
+ const candidates = [...new Set(order)];
3151
+ let chosen = candidates[candidates.length - 1];
3152
+ for (const d of candidates) {
3153
+ if (d === "top" && t.top >= c.height + GAP) {
3154
+ chosen = d;
3155
+ break;
3156
+ }
3157
+ if (d === "bottom" && vh - t.bottom >= c.height + GAP) {
3158
+ chosen = d;
3159
+ break;
3160
+ }
3161
+ if (d === "right" && vw - t.right >= c.width + GAP) {
3162
+ chosen = d;
3163
+ break;
3164
+ }
3165
+ if (d === "left" && t.left >= c.width + GAP) {
3166
+ chosen = d;
3167
+ break;
3168
+ }
3169
+ }
3170
+ let top = 0;
3171
+ let left = 0;
3172
+ if (chosen === "top") {
3173
+ top = t.top - c.height - GAP;
3174
+ left = t.left + t.width / 2 - c.width / 2;
3175
+ } else if (chosen === "bottom") {
3176
+ top = t.bottom + GAP;
3177
+ left = t.left + t.width / 2 - c.width / 2;
3178
+ } else if (chosen === "left") {
3179
+ top = t.top + t.height / 2 - c.height / 2;
3180
+ left = t.left - c.width - GAP;
3181
+ } else {
3182
+ top = t.top + t.height / 2 - c.height / 2;
3183
+ left = t.right + GAP;
3184
+ }
3185
+ top = Math.max(4, Math.min(top, vh - c.height - 4));
3186
+ left = Math.max(4, Math.min(left, vw - c.width - 4));
3187
+ actualDirection.value = chosen;
3188
+ posStyle.value = { top: `${top}px`, left: `${left}px` };
3189
+ }
3190
+ const posReady = ref(false);
3191
+ let posCleanup = null;
3192
+ watch(model, async (val) => {
3193
+ if (val) {
3194
+ posReady.value = false;
3195
+ await nextTick();
3196
+ computePosition();
3197
+ posReady.value = true;
3198
+ const update = () => computePosition();
3199
+ window.addEventListener("scroll", update, { passive: true, capture: true });
3200
+ window.addEventListener("resize", update, { passive: true });
3201
+ posCleanup = () => {
3202
+ window.removeEventListener("scroll", update, { capture: true });
3203
+ window.removeEventListener("resize", update);
3204
+ };
3205
+ } else {
3206
+ posReady.value = false;
3207
+ posCleanup == null ? void 0 : posCleanup();
3208
+ posCleanup = null;
3209
+ }
3210
+ });
3211
+ onUnmounted(() => posCleanup == null ? void 0 : posCleanup());
3212
+ onKeyStroke("Escape", (e) => {
3213
+ var _a;
3214
+ if (model.value) {
3215
+ e.preventDefault();
3216
+ close();
3217
+ (_a = triggerRef.value) == null ? void 0 : _a.focus();
3218
+ }
3219
+ });
3220
+ return (_ctx, _cache) => {
3221
+ var _a, _b;
3222
+ return openBlock(), createElementBlock("span", {
3223
+ class: normalizeClass([(_a = __props.ui) == null ? void 0 : _a.root, "akaza-tooltip-root"])
3224
+ }, [
3225
+ createElementVNode("span", {
3226
+ ref_key: "triggerRef",
3227
+ ref: triggerRef,
3228
+ "aria-describedby": model.value ? unref(tooltipId) : void 0,
3229
+ "data-akaza-state": model.value ? "open" : "closed",
3230
+ class: normalizeClass([(_b = __props.ui) == null ? void 0 : _b.trigger, "akaza-tooltip-trigger"]),
3231
+ onMouseenter: open,
3232
+ onMouseleave: close,
3233
+ onFocus: open,
3234
+ onBlur: close
3235
+ }, [
3236
+ renderSlot(_ctx.$slots, "trigger", { isOpen: model.value })
3237
+ ], 42, _hoisted_1),
3238
+ (openBlock(), createBlock(Teleport, {
3239
+ to: typeof __props.teleport === "string" ? __props.teleport : "body",
3240
+ disabled: __props.teleport === false
3241
+ }, [
3242
+ createVNode(Transition, mergeProps(typeof __props.transition === "string" ? { name: __props.transition } : {}, {
3243
+ css: __props.transition !== false
3244
+ }), {
3245
+ default: withCtx(() => {
3246
+ var _a2;
3247
+ return [
3248
+ model.value ? (openBlock(), createElementBlock("div", {
3249
+ key: 0,
3250
+ id: unref(tooltipId),
3251
+ ref_key: "contentRef",
3252
+ ref: contentRef,
3253
+ role: "tooltip",
3254
+ class: normalizeClass([(_a2 = __props.ui) == null ? void 0 : _a2.content, "akaza-tooltip-content"]),
3255
+ "data-akaza-state": "open",
3256
+ "data-akaza-direction": actualDirection.value,
3257
+ style: normalizeStyle([posStyle.value, posReady.value ? {} : { visibility: "hidden" }])
3258
+ }, [
3259
+ renderSlot(_ctx.$slots, "content", { close }),
3260
+ __props.arrow ? (openBlock(), createElementBlock("span", _hoisted_3)) : createCommentVNode("", true)
3261
+ ], 14, _hoisted_2)) : createCommentVNode("", true)
3262
+ ];
3263
+ }),
3264
+ _: 3
3265
+ }, 16, ["css"])
3266
+ ], 8, ["to", "disabled"]))
3267
+ ], 2);
3268
+ };
3269
+ }
3270
+ });
3271
+ export {
3272
+ _sfc_main$i as Accordion,
3273
+ _sfc_main$h as AlertDialog,
3274
+ _sfc_main$g as Avatar,
3275
+ _sfc_main$f as Button,
3276
+ _sfc_main$e as Checkbox,
3277
+ _sfc_main$d as Collapsible,
3278
+ _sfc_main$c as Dialog,
3279
+ _sfc_main$b as Drawer,
3280
+ _sfc_main$9 as Menu,
3281
+ _sfc_main$8 as OverlayProvider,
3282
+ _sfc_main$7 as Popover,
3283
+ _sfc_main$6 as Progress,
3284
+ _sfc_main$5 as RadioGroup,
3285
+ _sfc_main$4 as Separator,
3286
+ _sfc_main$3 as Switch,
3287
+ _sfc_main$2 as Tabs,
3288
+ _sfc_main$1 as Toggle,
3289
+ _sfc_main as Tooltip,
3290
+ useOverlay
3291
+ };
3292
+ //# sourceMappingURL=akaza-ui.js.map