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