@iris-ui-kit/vue 0.2.5 → 0.2.6
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/admin.cjs +51 -10
- package/dist/admin.cjs.map +1 -1
- package/dist/admin.js +1 -1
- package/dist/{chunk-SJYXNBXY.js → chunk-NI5QJ6SZ.js} +53 -12
- package/dist/chunk-NI5QJ6SZ.js.map +1 -0
- package/dist/index.cjs +51 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +4 -4
- package/dist/chunk-SJYXNBXY.js.map +0 -1
package/dist/admin.cjs
CHANGED
|
@@ -395,6 +395,22 @@ var IrisNavMenu = vue.defineComponent({
|
|
|
395
395
|
emit("select", node.key, node);
|
|
396
396
|
};
|
|
397
397
|
const hovered = vue.ref(null);
|
|
398
|
+
const hoveredBranches = vue.ref([]);
|
|
399
|
+
const focusedBranches = vue.ref([]);
|
|
400
|
+
const setBranchInteraction = (state, key, enabled) => {
|
|
401
|
+
const current = state.value;
|
|
402
|
+
if (enabled) {
|
|
403
|
+
if (!current.includes(key)) state.value = [...current, key];
|
|
404
|
+
} else if (current.includes(key)) {
|
|
405
|
+
state.value = current.filter((item) => item !== key);
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
const interactionKeyAtDepth = (keys, depth) => keys.find((key) => core.findNavPath(props.items, key).length === depth + 1);
|
|
409
|
+
const horizontalBranchVisible = (key, depth) => {
|
|
410
|
+
const hoveredAtDepth = interactionKeyAtDepth(hoveredBranches.value, depth);
|
|
411
|
+
if (hoveredAtDepth) return hoveredAtDepth === key;
|
|
412
|
+
return interactionKeyAtDepth(focusedBranches.value, depth) === key;
|
|
413
|
+
};
|
|
398
414
|
const itemStyle = (opts) => {
|
|
399
415
|
const bg = opts.active ? "var(--iris-primary)" : opts.hovered && !opts.disabled ? "var(--iris-surface)" : "transparent";
|
|
400
416
|
return {
|
|
@@ -473,6 +489,8 @@ var IrisNavMenu = vue.defineComponent({
|
|
|
473
489
|
const renderItem = (node, depth) => {
|
|
474
490
|
const branch = core.isBranch(node);
|
|
475
491
|
const open = expanded.value.includes(node.key);
|
|
492
|
+
const horizontal = props.orientation === "horizontal";
|
|
493
|
+
const shown = horizontal ? horizontalBranchVisible(node.key, depth) : open;
|
|
476
494
|
const active = node.key === props.activeKey;
|
|
477
495
|
const trail = branch && !active && activePath.value.includes(node.key);
|
|
478
496
|
const row = vue.h(
|
|
@@ -484,10 +502,10 @@ var IrisNavMenu = vue.defineComponent({
|
|
|
484
502
|
"data-branch": branch ? "true" : void 0,
|
|
485
503
|
"data-active": active ? "true" : void 0,
|
|
486
504
|
"data-active-trail": trail ? "true" : void 0,
|
|
487
|
-
"data-open": branch &&
|
|
505
|
+
"data-open": branch && shown ? "true" : void 0,
|
|
488
506
|
"data-depth": String(depth),
|
|
489
507
|
disabled: node.disabled,
|
|
490
|
-
"aria-expanded": branch ?
|
|
508
|
+
"aria-expanded": branch ? shown ? "true" : "false" : void 0,
|
|
491
509
|
"aria-current": active ? "page" : void 0,
|
|
492
510
|
style: itemStyle({
|
|
493
511
|
depth,
|
|
@@ -515,14 +533,14 @@ var IrisNavMenu = vue.defineComponent({
|
|
|
515
533
|
),
|
|
516
534
|
badgeNode(node),
|
|
517
535
|
branch ? vue.h(IrisIcon, {
|
|
518
|
-
name:
|
|
536
|
+
name: horizontal ? "chevron-down" : "chevron-right",
|
|
519
537
|
size: 16,
|
|
520
538
|
style: { marginInlineStart: badgeNode(node) ? "6px" : "auto", opacity: "0.6" }
|
|
521
539
|
}) : null
|
|
522
540
|
]
|
|
523
541
|
);
|
|
524
|
-
const groupStyle =
|
|
525
|
-
if (!branch || !open)
|
|
542
|
+
const groupStyle = horizontal && depth === 0 ? { position: "relative" } : void 0;
|
|
543
|
+
if (!branch || !horizontal && !open)
|
|
526
544
|
return vue.h(
|
|
527
545
|
"div",
|
|
528
546
|
{ key: node.key, "data-iris-nav-group": branch ? "" : void 0, style: groupStyle },
|
|
@@ -530,7 +548,24 @@ var IrisNavMenu = vue.defineComponent({
|
|
|
530
548
|
);
|
|
531
549
|
return vue.h(
|
|
532
550
|
"div",
|
|
533
|
-
{
|
|
551
|
+
{
|
|
552
|
+
key: node.key,
|
|
553
|
+
"data-iris-nav-group": "",
|
|
554
|
+
"data-open": shown ? "true" : void 0,
|
|
555
|
+
style: groupStyle,
|
|
556
|
+
...horizontal ? {
|
|
557
|
+
onMouseenter: () => setBranchInteraction(hoveredBranches, node.key, true),
|
|
558
|
+
onMouseleave: () => setBranchInteraction(hoveredBranches, node.key, false),
|
|
559
|
+
onFocusin: () => setBranchInteraction(focusedBranches, node.key, true),
|
|
560
|
+
onFocusout: (event) => {
|
|
561
|
+
const group = event.currentTarget;
|
|
562
|
+
const next = event.relatedTarget;
|
|
563
|
+
if (!next || !group.contains(next)) {
|
|
564
|
+
setBranchInteraction(focusedBranches, node.key, false);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
} : {}
|
|
568
|
+
},
|
|
534
569
|
[
|
|
535
570
|
row,
|
|
536
571
|
vue.h(
|
|
@@ -538,9 +573,11 @@ var IrisNavMenu = vue.defineComponent({
|
|
|
538
573
|
{
|
|
539
574
|
"data-iris-nav-children": "",
|
|
540
575
|
role: "group",
|
|
541
|
-
|
|
576
|
+
"aria-hidden": horizontal && !shown ? "true" : void 0,
|
|
577
|
+
style: horizontal && depth === 0 ? {
|
|
578
|
+
display: shown ? "block" : "none",
|
|
542
579
|
position: "absolute",
|
|
543
|
-
insetBlockStart: "
|
|
580
|
+
insetBlockStart: "100%",
|
|
544
581
|
insetInlineStart: "0",
|
|
545
582
|
zIndex: "60",
|
|
546
583
|
minWidth: "220px",
|
|
@@ -549,7 +586,7 @@ var IrisNavMenu = vue.defineComponent({
|
|
|
549
586
|
borderRadius: "var(--iris-radius-md, 6px)",
|
|
550
587
|
background: "var(--iris-surface)",
|
|
551
588
|
boxShadow: "var(--iris-shadow-md)"
|
|
552
|
-
} : void 0
|
|
589
|
+
} : horizontal ? { display: shown ? "block" : "none" } : void 0
|
|
553
590
|
},
|
|
554
591
|
(node.children ?? []).map((child) => renderItem(child, depth + 1))
|
|
555
592
|
)
|
|
@@ -558,7 +595,11 @@ var IrisNavMenu = vue.defineComponent({
|
|
|
558
595
|
};
|
|
559
596
|
const onKeydown = (e) => {
|
|
560
597
|
const root = e.currentTarget;
|
|
561
|
-
const buttons = Array.from(
|
|
598
|
+
const buttons = Array.from(
|
|
599
|
+
root.querySelectorAll("[data-iris-nav-item]")
|
|
600
|
+
).filter(
|
|
601
|
+
(button) => !button.closest('[data-iris-nav-children][aria-hidden="true"]')
|
|
602
|
+
);
|
|
562
603
|
if (buttons.length === 0) return;
|
|
563
604
|
const idx = buttons.indexOf(document.activeElement);
|
|
564
605
|
const focusAt = (i) => buttons[(i + buttons.length) % buttons.length]?.focus();
|