akaza-ui 0.0.1-alpha → 0.0.2-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/dist/akaza-ui.cjs +94 -36
- package/dist/akaza-ui.cjs.map +1 -1
- package/dist/akaza-ui.css +4 -1
- package/dist/akaza-ui.js +94 -36
- package/dist/akaza-ui.js.map +1 -1
- package/package.json +1 -1
package/dist/akaza-ui.cjs
CHANGED
|
@@ -2019,9 +2019,13 @@ const _sfc_main$9 = /* @__PURE__ */ vue.defineComponent({
|
|
|
2019
2019
|
const { isOpen, open: _open, close: _close } = useMenu(model);
|
|
2020
2020
|
function handleChange(nextOpen, reason, event) {
|
|
2021
2021
|
let canceled = false;
|
|
2022
|
-
emit("open-change", nextOpen, {
|
|
2023
|
-
|
|
2024
|
-
|
|
2022
|
+
emit("open-change", nextOpen, {
|
|
2023
|
+
reason,
|
|
2024
|
+
...event && { event },
|
|
2025
|
+
cancel: () => {
|
|
2026
|
+
canceled = true;
|
|
2027
|
+
}
|
|
2028
|
+
});
|
|
2025
2029
|
if (canceled) return;
|
|
2026
2030
|
nextOpen ? _open() : _close();
|
|
2027
2031
|
}
|
|
@@ -2080,7 +2084,15 @@ const _sfc_main$9 = /* @__PURE__ */ vue.defineComponent({
|
|
|
2080
2084
|
onClickOutside(rootRef, (e) => {
|
|
2081
2085
|
if (isOpen.value) close("outside-click", e);
|
|
2082
2086
|
});
|
|
2083
|
-
const NAV_KEYS = /* @__PURE__ */ new Set([
|
|
2087
|
+
const NAV_KEYS = /* @__PURE__ */ new Set([
|
|
2088
|
+
"ArrowDown",
|
|
2089
|
+
"ArrowUp",
|
|
2090
|
+
"ArrowLeft",
|
|
2091
|
+
"ArrowRight",
|
|
2092
|
+
"Home",
|
|
2093
|
+
"End",
|
|
2094
|
+
"Escape"
|
|
2095
|
+
]);
|
|
2084
2096
|
function onContentKeydown(e) {
|
|
2085
2097
|
if (NAV_KEYS.has(e.key) || e.key.length === 1 && !e.ctrlKey && !e.metaKey) {
|
|
2086
2098
|
e.stopPropagation();
|
|
@@ -2094,9 +2106,13 @@ const _sfc_main$9 = /* @__PURE__ */ vue.defineComponent({
|
|
|
2094
2106
|
var _a;
|
|
2095
2107
|
if (item.disabled) return;
|
|
2096
2108
|
let canceled = false;
|
|
2097
|
-
emit("select", item, {
|
|
2098
|
-
|
|
2099
|
-
|
|
2109
|
+
emit("select", item, {
|
|
2110
|
+
reason: "select",
|
|
2111
|
+
event,
|
|
2112
|
+
cancel: () => {
|
|
2113
|
+
canceled = true;
|
|
2114
|
+
}
|
|
2115
|
+
});
|
|
2100
2116
|
if (canceled) return;
|
|
2101
2117
|
(_a = item.onSelect) == null ? void 0 : _a.call(item);
|
|
2102
2118
|
if (__props.closeOnSelect) close("select", event);
|
|
@@ -2106,9 +2122,13 @@ const _sfc_main$9 = /* @__PURE__ */ vue.defineComponent({
|
|
|
2106
2122
|
if (item.disabled) return;
|
|
2107
2123
|
const next = !item.checked;
|
|
2108
2124
|
let canceled = false;
|
|
2109
|
-
emit("check-change", item, next, {
|
|
2110
|
-
|
|
2111
|
-
|
|
2125
|
+
emit("check-change", item, next, {
|
|
2126
|
+
reason: "select",
|
|
2127
|
+
event,
|
|
2128
|
+
cancel: () => {
|
|
2129
|
+
canceled = true;
|
|
2130
|
+
}
|
|
2131
|
+
});
|
|
2112
2132
|
if (canceled) return;
|
|
2113
2133
|
(_a = item.onUpdateChecked) == null ? void 0 : _a.call(item, next);
|
|
2114
2134
|
}
|
|
@@ -2121,9 +2141,13 @@ const _sfc_main$9 = /* @__PURE__ */ vue.defineComponent({
|
|
|
2121
2141
|
const group = item.radioGroup ?? "";
|
|
2122
2142
|
const value = item.value ?? "";
|
|
2123
2143
|
let canceled = false;
|
|
2124
|
-
emit("radio-change", group, value, {
|
|
2125
|
-
|
|
2126
|
-
|
|
2144
|
+
emit("radio-change", group, value, {
|
|
2145
|
+
reason: "select",
|
|
2146
|
+
event,
|
|
2147
|
+
cancel: () => {
|
|
2148
|
+
canceled = true;
|
|
2149
|
+
}
|
|
2150
|
+
});
|
|
2127
2151
|
if (canceled) return;
|
|
2128
2152
|
if (__props.radioValues) {
|
|
2129
2153
|
emit("update:radioValues", { ...__props.radioValues, [group]: value });
|
|
@@ -2334,7 +2358,7 @@ const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({
|
|
|
2334
2358
|
side: { default: "bottom" },
|
|
2335
2359
|
align: { default: "start" },
|
|
2336
2360
|
sideOffset: { default: 6 },
|
|
2337
|
-
teleport: { type: [String, Boolean], default:
|
|
2361
|
+
teleport: { type: [String, Boolean], default: false },
|
|
2338
2362
|
transition: { type: [String, Boolean], default: "akaza-popover" },
|
|
2339
2363
|
ui: {}
|
|
2340
2364
|
}, {
|
|
@@ -2348,9 +2372,13 @@ const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({
|
|
|
2348
2372
|
const { open: _open, close: _close } = usePopover(model);
|
|
2349
2373
|
function handleChange(nextOpen, reason, event) {
|
|
2350
2374
|
let canceled = false;
|
|
2351
|
-
emit("open-change", nextOpen, {
|
|
2352
|
-
|
|
2353
|
-
|
|
2375
|
+
emit("open-change", nextOpen, {
|
|
2376
|
+
reason,
|
|
2377
|
+
...event && { event },
|
|
2378
|
+
cancel: () => {
|
|
2379
|
+
canceled = true;
|
|
2380
|
+
}
|
|
2381
|
+
});
|
|
2354
2382
|
if (canceled) return;
|
|
2355
2383
|
nextOpen ? _open() : _close();
|
|
2356
2384
|
}
|
|
@@ -2366,6 +2394,8 @@ const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({
|
|
|
2366
2394
|
const popoverId = vue.useId();
|
|
2367
2395
|
const rootRef = vue.useTemplateRef("rootRef");
|
|
2368
2396
|
const contentRef = vue.useTemplateRef("contentRef");
|
|
2397
|
+
let positionFrame = 0;
|
|
2398
|
+
let resizeObserver;
|
|
2369
2399
|
onClickOutside(
|
|
2370
2400
|
rootRef,
|
|
2371
2401
|
(e) => {
|
|
@@ -2381,10 +2411,23 @@ const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({
|
|
|
2381
2411
|
});
|
|
2382
2412
|
const posStyle = vue.ref({ top: "-9999px", left: "-9999px" });
|
|
2383
2413
|
const actualSide = vue.ref(__props.side);
|
|
2414
|
+
const contentStyle = vue.computed(() => ({
|
|
2415
|
+
...posStyle.value,
|
|
2416
|
+
position: __props.teleport === false ? "absolute" : "fixed"
|
|
2417
|
+
}));
|
|
2418
|
+
function schedulePosition() {
|
|
2419
|
+
cancelAnimationFrame(positionFrame);
|
|
2420
|
+
positionFrame = requestAnimationFrame(() => {
|
|
2421
|
+
positionFrame = requestAnimationFrame(() => {
|
|
2422
|
+
computePosition();
|
|
2423
|
+
});
|
|
2424
|
+
});
|
|
2425
|
+
}
|
|
2384
2426
|
function computePosition() {
|
|
2385
2427
|
if (!rootRef.value || !contentRef.value) return;
|
|
2386
2428
|
const t = rootRef.value.getBoundingClientRect();
|
|
2387
|
-
const
|
|
2429
|
+
const contentWidth = contentRef.value.offsetWidth;
|
|
2430
|
+
const contentHeight = contentRef.value.offsetHeight;
|
|
2388
2431
|
const vw = window.innerWidth;
|
|
2389
2432
|
const vh = window.innerHeight;
|
|
2390
2433
|
const gap = __props.sideOffset;
|
|
@@ -2392,61 +2435,76 @@ const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({
|
|
|
2392
2435
|
const candidates = [...new Set(order)];
|
|
2393
2436
|
let chosen = candidates[candidates.length - 1];
|
|
2394
2437
|
for (const d of candidates) {
|
|
2395
|
-
if (d === "top" && t.top >=
|
|
2438
|
+
if (d === "top" && t.top >= contentHeight + gap) {
|
|
2396
2439
|
chosen = d;
|
|
2397
2440
|
break;
|
|
2398
2441
|
}
|
|
2399
|
-
if (d === "bottom" && vh - t.bottom >=
|
|
2442
|
+
if (d === "bottom" && vh - t.bottom >= contentHeight + gap) {
|
|
2400
2443
|
chosen = d;
|
|
2401
2444
|
break;
|
|
2402
2445
|
}
|
|
2403
|
-
if (d === "right" && vw - t.right >=
|
|
2446
|
+
if (d === "right" && vw - t.right >= contentWidth + gap) {
|
|
2404
2447
|
chosen = d;
|
|
2405
2448
|
break;
|
|
2406
2449
|
}
|
|
2407
|
-
if (d === "left" && t.left >=
|
|
2450
|
+
if (d === "left" && t.left >= contentWidth + gap) {
|
|
2408
2451
|
chosen = d;
|
|
2409
2452
|
break;
|
|
2410
2453
|
}
|
|
2411
2454
|
}
|
|
2412
2455
|
let top = 0;
|
|
2413
2456
|
let left = 0;
|
|
2414
|
-
if (chosen === "top") top = t.top -
|
|
2457
|
+
if (chosen === "top") top = t.top - contentHeight - gap;
|
|
2415
2458
|
else if (chosen === "bottom") top = t.bottom + gap;
|
|
2416
|
-
else if (chosen === "left") left = t.left -
|
|
2459
|
+
else if (chosen === "left") left = t.left - contentWidth - gap;
|
|
2417
2460
|
else left = t.right + gap;
|
|
2418
2461
|
if (chosen === "top" || chosen === "bottom") {
|
|
2419
2462
|
if (__props.align === "start") left = t.left;
|
|
2420
|
-
else if (__props.align === "end") left = t.right -
|
|
2421
|
-
else left = t.left + t.width / 2 -
|
|
2463
|
+
else if (__props.align === "end") left = t.right - contentWidth;
|
|
2464
|
+
else left = t.left + t.width / 2 - contentWidth / 2;
|
|
2422
2465
|
} else {
|
|
2423
2466
|
if (__props.align === "start") top = t.top;
|
|
2424
|
-
else if (__props.align === "end") top = t.bottom -
|
|
2425
|
-
else top = t.top + t.height / 2 -
|
|
2467
|
+
else if (__props.align === "end") top = t.bottom - contentHeight;
|
|
2468
|
+
else top = t.top + t.height / 2 - contentHeight / 2;
|
|
2426
2469
|
}
|
|
2427
|
-
top = Math.max(4, Math.min(top, vh -
|
|
2428
|
-
left = Math.max(4, Math.min(left, vw -
|
|
2470
|
+
top = Math.max(4, Math.min(top, vh - contentHeight - 4));
|
|
2471
|
+
left = Math.max(4, Math.min(left, vw - contentWidth - 4));
|
|
2429
2472
|
actualSide.value = chosen;
|
|
2430
|
-
posStyle.value = { top: `${top}px`, left: `${left}px` };
|
|
2473
|
+
posStyle.value = __props.teleport === false ? { top: `${top - t.top}px`, left: `${left - t.left}px` } : { top: `${top}px`, left: `${left}px` };
|
|
2431
2474
|
}
|
|
2432
2475
|
function addListeners() {
|
|
2433
|
-
|
|
2476
|
+
if (__props.teleport !== false) {
|
|
2477
|
+
window.addEventListener("scroll", computePosition, { passive: true, capture: true });
|
|
2478
|
+
}
|
|
2434
2479
|
window.addEventListener("resize", computePosition, { passive: true });
|
|
2480
|
+
if (typeof ResizeObserver !== "undefined" && contentRef.value) {
|
|
2481
|
+
resizeObserver = new ResizeObserver(() => {
|
|
2482
|
+
computePosition();
|
|
2483
|
+
});
|
|
2484
|
+
resizeObserver.observe(contentRef.value);
|
|
2485
|
+
}
|
|
2435
2486
|
}
|
|
2436
2487
|
function removeListeners() {
|
|
2437
|
-
|
|
2488
|
+
if (__props.teleport !== false) {
|
|
2489
|
+
window.removeEventListener("scroll", computePosition, { capture: true });
|
|
2490
|
+
}
|
|
2438
2491
|
window.removeEventListener("resize", computePosition);
|
|
2492
|
+
resizeObserver == null ? void 0 : resizeObserver.disconnect();
|
|
2493
|
+
resizeObserver = void 0;
|
|
2439
2494
|
}
|
|
2440
2495
|
vue.watch(model, async (val) => {
|
|
2441
2496
|
if (val) {
|
|
2442
2497
|
await vue.nextTick();
|
|
2443
|
-
requestAnimationFrame(computePosition);
|
|
2444
2498
|
addListeners();
|
|
2499
|
+
schedulePosition();
|
|
2445
2500
|
} else {
|
|
2446
2501
|
removeListeners();
|
|
2447
2502
|
}
|
|
2448
2503
|
});
|
|
2449
|
-
vue.onUnmounted(
|
|
2504
|
+
vue.onUnmounted(() => {
|
|
2505
|
+
cancelAnimationFrame(positionFrame);
|
|
2506
|
+
removeListeners();
|
|
2507
|
+
});
|
|
2450
2508
|
const triggerProps = vue.computed(() => ({
|
|
2451
2509
|
"aria-haspopup": "dialog",
|
|
2452
2510
|
"aria-expanded": model.value,
|
|
@@ -2483,7 +2541,7 @@ const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({
|
|
|
2483
2541
|
ref_key: "contentRef",
|
|
2484
2542
|
ref: contentRef,
|
|
2485
2543
|
class: vue.normalizeClass([(_a = __props.ui) == null ? void 0 : _a.content, "akaza-popover-content"]),
|
|
2486
|
-
style: vue.normalizeStyle(
|
|
2544
|
+
style: vue.normalizeStyle(contentStyle.value),
|
|
2487
2545
|
"data-akaza-side": actualSide.value,
|
|
2488
2546
|
"data-akaza-align": __props.align,
|
|
2489
2547
|
"data-akaza-state": "open"
|