@sanity/ui 3.1.13 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks-cjs/_visual-editing.js +276 -252
- package/dist/_chunks-cjs/_visual-editing.js.map +1 -1
- package/dist/_chunks-es/_visual-editing.mjs +276 -252
- package/dist/_chunks-es/_visual-editing.mjs.map +1 -1
- package/dist/_visual-editing.d.mts +66 -1
- package/dist/_visual-editing.d.ts +66 -1
- package/dist/index.d.mts +86 -1
- package/dist/index.d.ts +86 -1
- package/dist/index.js +97 -93
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +97 -93
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/core/components/breadcrumbs/breadcrumbs.test.tsx +51 -0
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +7 -3
- package/src/core/components/hotkeys/hotkeys.test.tsx +42 -0
- package/src/core/components/hotkeys/hotkeys.tsx +7 -3
- package/src/core/components/menu/menu.spacing.test.tsx +63 -0
- package/src/core/components/menu/menu.tsx +8 -2
- package/src/core/components/menu/menuGroup.spacing.test.tsx +69 -0
- package/src/core/components/menu/menuGroup.tsx +8 -2
- package/src/core/components/menu/menuItem.spacing.test.tsx +59 -0
- package/src/core/components/menu/menuItem.tsx +8 -2
- package/src/core/components/tab/tabList.test.tsx +48 -0
- package/src/core/components/tree/tree.test.tsx +55 -0
- package/src/core/components/tree/tree.tsx +10 -4
- package/src/core/components/tree/treeGroup.tsx +2 -2
- package/src/core/components/tree/treeItem.test.tsx +65 -0
- package/src/core/components/tree/treeItem.tsx +8 -2
- package/src/core/components/tree/types.ts +4 -0
- package/src/core/hooks/useDelayed.test.ts +20 -0
- package/src/core/hooks/useDelayedState.ts +9 -1
- package/src/core/primitives/box/box.test.tsx +134 -0
- package/src/core/primitives/box/box.tsx +18 -6
- package/src/core/primitives/button/button.test.tsx +38 -0
- package/src/core/primitives/button/button.tsx +8 -3
- package/src/core/primitives/grid/grid.test.tsx +78 -0
- package/src/core/primitives/grid/grid.tsx +17 -4
- package/src/core/primitives/inline/inline.test.tsx +51 -0
- package/src/core/primitives/inline/inline.tsx +9 -3
- package/src/core/primitives/select/select.test.tsx +52 -0
- package/src/core/primitives/select/select.tsx +8 -2
- package/src/core/primitives/stack/stack.test.tsx +57 -0
- package/src/core/primitives/stack/stack.tsx +7 -2
- package/src/core/primitives/textInput/textInput.test.tsx +48 -0
- package/src/core/primitives/textInput/textInput.tsx +7 -2
- package/src/core/primitives/types.ts +33 -0
package/dist/index.mjs
CHANGED
|
@@ -576,32 +576,33 @@ const StyledBreadcrumbs = styled.ol.withConfig({
|
|
|
576
576
|
displayName: "ExpandButton",
|
|
577
577
|
componentId: "sc-1es8h8q-1"
|
|
578
578
|
})`appearance:none;margin:-4px;`, Breadcrumbs = forwardRef(function(props, ref) {
|
|
579
|
-
const $ = c(
|
|
580
|
-
let children, maxLength, restProps, separator, t0;
|
|
579
|
+
const $ = c(30);
|
|
580
|
+
let children, gap, maxLength, restProps, separator, t0;
|
|
581
581
|
$[0] !== props ? ({
|
|
582
582
|
children,
|
|
583
|
+
gap,
|
|
583
584
|
maxLength,
|
|
584
585
|
separator,
|
|
585
586
|
space: t0,
|
|
586
587
|
...restProps
|
|
587
|
-
} = props, $[0] = props, $[1] = children, $[2] =
|
|
588
|
-
const
|
|
589
|
-
let t1;
|
|
590
|
-
$[6] !== spaceRaw ? (t1 = _getArrayProp(spaceRaw), $[6] = spaceRaw, $[7] = t1) : t1 = $[7];
|
|
591
|
-
const space = t1, [open, setOpen] = useState(!1), expandElementRef = useRef(null), popoverElementRef = useRef(null);
|
|
588
|
+
} = props, $[0] = props, $[1] = children, $[2] = gap, $[3] = maxLength, $[4] = restProps, $[5] = separator, $[6] = t0) : (children = $[1], gap = $[2], maxLength = $[3], restProps = $[4], separator = $[5], t0 = $[6]);
|
|
589
|
+
const t1 = gap === void 0 ? t0 === void 0 ? 2 : t0 : gap;
|
|
592
590
|
let t2;
|
|
593
|
-
$[
|
|
594
|
-
const
|
|
591
|
+
$[7] !== t1 ? (t2 = _getArrayProp(t1), $[7] = t1, $[8] = t2) : t2 = $[8];
|
|
592
|
+
const space = t2, [open, setOpen] = useState(!1), expandElementRef = useRef(null), popoverElementRef = useRef(null);
|
|
595
593
|
let t3;
|
|
596
|
-
$[9] === Symbol.for("react.memo_cache_sentinel") ? (t3 = () => setOpen(!
|
|
597
|
-
const
|
|
594
|
+
$[9] === Symbol.for("react.memo_cache_sentinel") ? (t3 = () => setOpen(!1), $[9] = t3) : t3 = $[9];
|
|
595
|
+
const collapse = t3;
|
|
598
596
|
let t4;
|
|
599
|
-
$[10] === Symbol.for("react.memo_cache_sentinel") ? (t4 = () =>
|
|
597
|
+
$[10] === Symbol.for("react.memo_cache_sentinel") ? (t4 = () => setOpen(!0), $[10] = t4) : t4 = $[10];
|
|
598
|
+
const expand = t4;
|
|
600
599
|
let t5;
|
|
601
|
-
$[11]
|
|
602
|
-
const rawItems = t5;
|
|
600
|
+
$[11] === Symbol.for("react.memo_cache_sentinel") ? (t5 = () => [expandElementRef.current, popoverElementRef.current], $[11] = t5) : t5 = $[11], useClickOutsideEvent(collapse, t5);
|
|
603
601
|
let t6;
|
|
604
|
-
$[
|
|
602
|
+
$[12] !== children ? (t6 = Children.toArray(children).filter(isValidElement), $[12] = children, $[13] = t6) : t6 = $[13];
|
|
603
|
+
const rawItems = t6;
|
|
604
|
+
let t7;
|
|
605
|
+
$[14] !== maxLength || $[15] !== open || $[16] !== rawItems || $[17] !== space ? (t7 = {
|
|
605
606
|
collapse,
|
|
606
607
|
expand,
|
|
607
608
|
expandElementRef,
|
|
@@ -610,19 +611,19 @@ const StyledBreadcrumbs = styled.ol.withConfig({
|
|
|
610
611
|
popoverElementRef,
|
|
611
612
|
rawItems,
|
|
612
613
|
space
|
|
613
|
-
}, $[
|
|
614
|
-
const items = useItems(
|
|
615
|
-
let
|
|
616
|
-
if ($[
|
|
617
|
-
let
|
|
618
|
-
$[
|
|
614
|
+
}, $[14] = maxLength, $[15] = open, $[16] = rawItems, $[17] = space, $[18] = t7) : t7 = $[18];
|
|
615
|
+
const items = useItems(t7);
|
|
616
|
+
let t8;
|
|
617
|
+
if ($[19] !== items || $[20] !== separator || $[21] !== space) {
|
|
618
|
+
let t92;
|
|
619
|
+
$[23] !== separator || $[24] !== space ? (t92 = (item, itemIndex) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
619
620
|
itemIndex > 0 && /* @__PURE__ */ jsx(Box, { "aria-hidden": !0, as: "li", paddingX: space, children: separator || /* @__PURE__ */ jsx(Text, { muted: !0, children: "/" }) }),
|
|
620
621
|
/* @__PURE__ */ jsx(Box, { as: "li", children: item })
|
|
621
|
-
] }, itemIndex), $[
|
|
622
|
+
] }, itemIndex), $[23] = separator, $[24] = space, $[25] = t92) : t92 = $[25], t8 = items.map(t92), $[19] = items, $[20] = separator, $[21] = space, $[22] = t8;
|
|
622
623
|
} else
|
|
623
|
-
|
|
624
|
-
let
|
|
625
|
-
return $[
|
|
624
|
+
t8 = $[22];
|
|
625
|
+
let t9;
|
|
626
|
+
return $[26] !== ref || $[27] !== restProps || $[28] !== t8 ? (t9 = /* @__PURE__ */ jsx(StyledBreadcrumbs, { "data-ui": "Breadcrumbs", ...restProps, ref, children: t8 }), $[26] = ref, $[27] = restProps, $[28] = t8, $[29] = t9) : t9 = $[29], t9;
|
|
626
627
|
});
|
|
627
628
|
Breadcrumbs.displayName = "ForwardRef(Breadcrumbs)";
|
|
628
629
|
function useItems(t0) {
|
|
@@ -644,7 +645,7 @@ function useItems(t0) {
|
|
|
644
645
|
let t3;
|
|
645
646
|
$[11] !== afterLength || $[12] !== beforeLength || $[13] !== len || $[14] !== rawItems ? (t3 = rawItems.slice(beforeLength - 1, len - afterLength), $[11] = afterLength, $[12] = beforeLength, $[13] = len, $[14] = rawItems, $[15] = t3) : t3 = $[15];
|
|
646
647
|
let t4;
|
|
647
|
-
$[16] !== space || $[17] !== t3 ? (t4 = /* @__PURE__ */ jsx(Stack, { as: "ol", overflow: "auto", padding: space, space, children: t3 }), $[16] = space, $[17] = t3, $[18] = t4) : t4 = $[18];
|
|
648
|
+
$[16] !== space || $[17] !== t3 ? (t4 = /* @__PURE__ */ jsx(Stack, { as: "ol", overflow: "auto", padding: space, gap: space, children: t3 }), $[16] = space, $[17] = t3, $[18] = t4) : t4 = $[18];
|
|
648
649
|
const t5 = open ? collapse : expand;
|
|
649
650
|
let t6;
|
|
650
651
|
$[19] !== expandElementRef || $[20] !== open || $[21] !== t5 ? (t6 = /* @__PURE__ */ jsx(ExpandButton, { fontSize: 1, mode: "bleed", onClick: t5, padding: 1, ref: expandElementRef, selected: open, text: "\u2026" }), $[19] = expandElementRef, $[20] = open, $[21] = t5, $[22] = t6) : t6 = $[22];
|
|
@@ -1520,36 +1521,37 @@ function _focusItemElement(el) {
|
|
|
1520
1521
|
}
|
|
1521
1522
|
}
|
|
1522
1523
|
const TreeContext = createGlobalScopedContext("@sanity/ui/context/tree", null), Tree = forwardRef(function(props, forwardedRef) {
|
|
1523
|
-
const $ = c(
|
|
1524
|
-
let children, onFocus, restProps, t0;
|
|
1524
|
+
const $ = c(38);
|
|
1525
|
+
let children, gap, onFocus, restProps, t0;
|
|
1525
1526
|
$[0] !== props ? ({
|
|
1526
1527
|
children,
|
|
1528
|
+
gap,
|
|
1527
1529
|
space: t0,
|
|
1528
1530
|
onFocus,
|
|
1529
1531
|
...restProps
|
|
1530
|
-
} = props, $[0] = props, $[1] = children, $[2] =
|
|
1531
|
-
const
|
|
1532
|
+
} = props, $[0] = props, $[1] = children, $[2] = gap, $[3] = onFocus, $[4] = restProps, $[5] = t0) : (children = $[1], gap = $[2], onFocus = $[3], restProps = $[4], t0 = $[5]);
|
|
1533
|
+
const spacing = gap === void 0 ? t0 === void 0 ? 1 : t0 : gap, ref = useRef(null), [focusedElement, setFocusedElement] = useState(null), focusedElementRef = useRef(focusedElement);
|
|
1532
1534
|
let t1;
|
|
1533
|
-
$[
|
|
1535
|
+
$[6] === Symbol.for("react.memo_cache_sentinel") ? (t1 = [], $[6] = t1) : t1 = $[6];
|
|
1534
1536
|
const path = t1;
|
|
1535
1537
|
let t2;
|
|
1536
|
-
$[
|
|
1538
|
+
$[7] === Symbol.for("react.memo_cache_sentinel") ? (t2 = [], $[7] = t2) : t2 = $[7];
|
|
1537
1539
|
const [itemElements, setItemElements] = useState(t2);
|
|
1538
1540
|
let t3;
|
|
1539
|
-
$[
|
|
1541
|
+
$[8] === Symbol.for("react.memo_cache_sentinel") ? (t3 = {}, $[8] = t3) : t3 = $[8];
|
|
1540
1542
|
const [state, setState] = useState(t3), stateRef = useRef(state);
|
|
1541
1543
|
let t4;
|
|
1542
|
-
$[
|
|
1544
|
+
$[9] === Symbol.for("react.memo_cache_sentinel") ? (t4 = () => ref.current, $[9] = t4) : t4 = $[9], useImperativeHandle(forwardedRef, t4);
|
|
1543
1545
|
let t5, t6;
|
|
1544
|
-
$[
|
|
1546
|
+
$[10] !== focusedElement ? (t5 = () => {
|
|
1545
1547
|
focusedElementRef.current = focusedElement;
|
|
1546
|
-
}, t6 = [focusedElement], $[
|
|
1548
|
+
}, t6 = [focusedElement], $[10] = focusedElement, $[11] = t5, $[12] = t6) : (t5 = $[11], t6 = $[12]), useEffect(t5, t6);
|
|
1547
1549
|
let t7, t8;
|
|
1548
|
-
$[
|
|
1550
|
+
$[13] !== state ? (t7 = () => {
|
|
1549
1551
|
stateRef.current = state;
|
|
1550
|
-
}, t8 = [state], $[
|
|
1552
|
+
}, t8 = [state], $[13] = state, $[14] = t7, $[15] = t8) : (t7 = $[14], t8 = $[15]), useEffect(t7, t8);
|
|
1551
1553
|
let t9;
|
|
1552
|
-
$[
|
|
1554
|
+
$[16] === Symbol.for("react.memo_cache_sentinel") ? (t9 = (element, path_0, expanded, selected) => (setState((s) => ({
|
|
1553
1555
|
...s,
|
|
1554
1556
|
[path_0]: {
|
|
1555
1557
|
element,
|
|
@@ -1562,10 +1564,10 @@ const TreeContext = createGlobalScopedContext("@sanity/ui/context/tree", null),
|
|
|
1562
1564
|
};
|
|
1563
1565
|
return delete newState[path_0], newState;
|
|
1564
1566
|
});
|
|
1565
|
-
}), $[
|
|
1567
|
+
}), $[16] = t9) : t9 = $[16];
|
|
1566
1568
|
const registerItem = t9;
|
|
1567
1569
|
let t10;
|
|
1568
|
-
$[
|
|
1570
|
+
$[17] === Symbol.for("react.memo_cache_sentinel") ? (t10 = (path_1, expanded_0) => {
|
|
1569
1571
|
setState((s_1) => {
|
|
1570
1572
|
const itemState = s_1[path_1];
|
|
1571
1573
|
return itemState ? {
|
|
@@ -1576,10 +1578,10 @@ const TreeContext = createGlobalScopedContext("@sanity/ui/context/tree", null),
|
|
|
1576
1578
|
}
|
|
1577
1579
|
} : s_1;
|
|
1578
1580
|
});
|
|
1579
|
-
}, $[
|
|
1581
|
+
}, $[17] = t10) : t10 = $[17];
|
|
1580
1582
|
const setExpanded = t10, t11 = focusedElement || itemElements[0] || null;
|
|
1581
1583
|
let t12;
|
|
1582
|
-
$[
|
|
1584
|
+
$[18] !== spacing || $[19] !== state || $[20] !== t11 ? (t12 = {
|
|
1583
1585
|
version: 0,
|
|
1584
1586
|
focusedElement: t11,
|
|
1585
1587
|
level: 0,
|
|
@@ -1587,12 +1589,13 @@ const TreeContext = createGlobalScopedContext("@sanity/ui/context/tree", null),
|
|
|
1587
1589
|
registerItem,
|
|
1588
1590
|
setExpanded,
|
|
1589
1591
|
setFocusedElement,
|
|
1590
|
-
|
|
1592
|
+
gap: spacing,
|
|
1593
|
+
space: spacing,
|
|
1591
1594
|
state
|
|
1592
|
-
}, $[
|
|
1595
|
+
}, $[18] = spacing, $[19] = state, $[20] = t11, $[21] = t12) : t12 = $[21];
|
|
1593
1596
|
const contextValue = t12;
|
|
1594
1597
|
let t13;
|
|
1595
|
-
$[
|
|
1598
|
+
$[22] !== itemElements ? (t13 = (event) => {
|
|
1596
1599
|
if (focusedElementRef.current) {
|
|
1597
1600
|
if (event.key === "ArrowDown") {
|
|
1598
1601
|
event.preventDefault();
|
|
@@ -1651,26 +1654,26 @@ const TreeContext = createGlobalScopedContext("@sanity/ui/context/tree", null),
|
|
|
1651
1654
|
return;
|
|
1652
1655
|
}
|
|
1653
1656
|
}
|
|
1654
|
-
}, $[
|
|
1657
|
+
}, $[22] = itemElements, $[23] = t13) : t13 = $[23];
|
|
1655
1658
|
const handleKeyDown = t13;
|
|
1656
1659
|
let t14;
|
|
1657
|
-
$[
|
|
1660
|
+
$[24] !== onFocus ? (t14 = (event_0) => {
|
|
1658
1661
|
setFocusedElement(event_0.target), onFocus?.(event_0);
|
|
1659
|
-
}, $[
|
|
1662
|
+
}, $[24] = onFocus, $[25] = t14) : t14 = $[25];
|
|
1660
1663
|
const handleFocus = t14;
|
|
1661
1664
|
let t15;
|
|
1662
|
-
$[
|
|
1665
|
+
$[26] === Symbol.for("react.memo_cache_sentinel") ? (t15 = () => {
|
|
1663
1666
|
if (!ref.current)
|
|
1664
1667
|
return;
|
|
1665
1668
|
const _itemElements = Array.from(ref.current.querySelectorAll('[data-ui="TreeItem"]'));
|
|
1666
1669
|
setItemElements(_itemElements);
|
|
1667
|
-
}, $[
|
|
1670
|
+
}, $[26] = t15) : t15 = $[26];
|
|
1668
1671
|
let t16;
|
|
1669
|
-
$[
|
|
1672
|
+
$[27] !== children ? (t16 = [children], $[27] = children, $[28] = t16) : t16 = $[28], useEffect(t15, t16);
|
|
1670
1673
|
let t17;
|
|
1671
|
-
$[
|
|
1674
|
+
$[29] !== children || $[30] !== handleFocus || $[31] !== handleKeyDown || $[32] !== restProps || $[33] !== spacing ? (t17 = /* @__PURE__ */ jsx(Stack, { as: "ul", "data-ui": "Tree", ...restProps, onFocus: handleFocus, onKeyDown: handleKeyDown, ref, role: "tree", gap: spacing, children }), $[29] = children, $[30] = handleFocus, $[31] = handleKeyDown, $[32] = restProps, $[33] = spacing, $[34] = t17) : t17 = $[34];
|
|
1672
1675
|
let t18;
|
|
1673
|
-
return $[
|
|
1676
|
+
return $[35] !== contextValue || $[36] !== t17 ? (t18 = /* @__PURE__ */ jsx(TreeContext.Provider, { value: contextValue, children: t17 }), $[35] = contextValue, $[36] = t17, $[37] = t18) : t18 = $[37], t18;
|
|
1674
1677
|
});
|
|
1675
1678
|
Tree.displayName = "ForwardRef(Tree)";
|
|
1676
1679
|
function treeItemRootStyle() {
|
|
@@ -1781,7 +1784,7 @@ function TreeGroup(props) {
|
|
|
1781
1784
|
} = props, $[0] = props, $[1] = children, $[2] = restProps, $[3] = t0) : (children = $[1], restProps = $[2], t0 = $[3]);
|
|
1782
1785
|
const expanded = t0 === void 0 ? !1 : t0, tree = useTree(), t1 = !expanded;
|
|
1783
1786
|
let t2;
|
|
1784
|
-
return $[4] !== children || $[5] !== restProps || $[6] !== t1 || $[7] !== tree.
|
|
1787
|
+
return $[4] !== children || $[5] !== restProps || $[6] !== t1 || $[7] !== tree.gap ? (t2 = /* @__PURE__ */ jsx(Stack, { as: "ul", "data-ui": "TreeGroup", ...restProps, hidden: t1, marginTop: tree.gap, role: "group", gap: tree.gap, children }), $[4] = children, $[5] = restProps, $[6] = t1, $[7] = tree.gap, $[8] = t2) : t2 = $[8], t2;
|
|
1785
1788
|
}
|
|
1786
1789
|
const StyledTreeItem = /* @__PURE__ */ styled.li.withConfig({
|
|
1787
1790
|
displayName: "StyledTreeItem",
|
|
@@ -1796,8 +1799,8 @@ const StyledTreeItem = /* @__PURE__ */ styled.li.withConfig({
|
|
|
1796
1799
|
componentId: "sc-iiskig-2"
|
|
1797
1800
|
})`& > svg{transition:transform 100ms;}`;
|
|
1798
1801
|
function TreeItem(props) {
|
|
1799
|
-
const $ = c(
|
|
1800
|
-
let IconComponent, children, href, idProp, linkAs, muted, onClick, restProps, t0, t1, t2, t3, t4, text, weight;
|
|
1802
|
+
const $ = c(114);
|
|
1803
|
+
let IconComponent, children, gap, href, idProp, linkAs, muted, onClick, restProps, t0, t1, t2, t3, t4, text, weight;
|
|
1801
1804
|
$[0] !== props ? ({
|
|
1802
1805
|
children,
|
|
1803
1806
|
expanded: t0,
|
|
@@ -1810,16 +1813,17 @@ function TreeItem(props) {
|
|
|
1810
1813
|
onClick,
|
|
1811
1814
|
padding: t2,
|
|
1812
1815
|
selected: t3,
|
|
1816
|
+
gap,
|
|
1813
1817
|
space: t4,
|
|
1814
1818
|
text,
|
|
1815
1819
|
weight,
|
|
1816
1820
|
...restProps
|
|
1817
|
-
} = props, $[0] = props, $[1] = IconComponent, $[2] = children, $[3] =
|
|
1818
|
-
const expandedProp = t0 === void 0 ? !1 : t0, fontSize = t1 === void 0 ? 1 : t1, padding = t2 === void 0 ? 2 : t2, selected = t3 === void 0 ? !1 : t3,
|
|
1821
|
+
} = props, $[0] = props, $[1] = IconComponent, $[2] = children, $[3] = gap, $[4] = href, $[5] = idProp, $[6] = linkAs, $[7] = muted, $[8] = onClick, $[9] = restProps, $[10] = t0, $[11] = t1, $[12] = t2, $[13] = t3, $[14] = t4, $[15] = text, $[16] = weight) : (IconComponent = $[1], children = $[2], gap = $[3], href = $[4], idProp = $[5], linkAs = $[6], muted = $[7], onClick = $[8], restProps = $[9], t0 = $[10], t1 = $[11], t2 = $[12], t3 = $[13], t4 = $[14], text = $[15], weight = $[16]);
|
|
1822
|
+
const expandedProp = t0 === void 0 ? !1 : t0, fontSize = t1 === void 0 ? 1 : t1, padding = t2 === void 0 ? 2 : t2, selected = t3 === void 0 ? !1 : t3, spacing = gap === void 0 ? t4 === void 0 ? 2 : t4 : gap, [rootElement, _setRootElement] = useState(null);
|
|
1819
1823
|
let t5;
|
|
1820
|
-
$[
|
|
1824
|
+
$[17] === Symbol.for("react.memo_cache_sentinel") ? (t5 = (node) => {
|
|
1821
1825
|
startTransition(() => _setRootElement(node));
|
|
1822
|
-
}, $[
|
|
1826
|
+
}, $[17] = t5) : t5 = $[17];
|
|
1823
1827
|
const setRootElement = t5, treeitemRef = useRef(null), tree = useTree(), {
|
|
1824
1828
|
path,
|
|
1825
1829
|
registerItem,
|
|
@@ -1827,89 +1831,89 @@ function TreeItem(props) {
|
|
|
1827
1831
|
setFocusedElement
|
|
1828
1832
|
} = tree, _id = useId(), id = idProp || _id;
|
|
1829
1833
|
let t6, t7;
|
|
1830
|
-
if ($[
|
|
1834
|
+
if ($[18] !== id || $[19] !== path) {
|
|
1831
1835
|
const itemPath = path.concat([id || ""]);
|
|
1832
|
-
t6 = itemPath, t7 = itemPath.join("/"), $[
|
|
1836
|
+
t6 = itemPath, t7 = itemPath.join("/"), $[18] = id, $[19] = path, $[20] = t6, $[21] = t7;
|
|
1833
1837
|
} else
|
|
1834
|
-
t6 = $[
|
|
1838
|
+
t6 = $[20], t7 = $[21];
|
|
1835
1839
|
let t8;
|
|
1836
|
-
$[
|
|
1840
|
+
$[22] !== t6 || $[23] !== t7 ? (t8 = [t6, t7], $[22] = t6, $[23] = t7, $[24] = t8) : t8 = $[24];
|
|
1837
1841
|
const [itemPath_0, itemKey] = t8, itemState = tree.state[itemKey], focused = tree.focusedElement === rootElement, expanded = itemState?.expanded === void 0 ? expandedProp : itemState?.expanded || !1, tabIndex = tree.focusedElement && tree.focusedElement === rootElement ? 0 : -1, t9 = tree.level + 1;
|
|
1838
1842
|
let t10;
|
|
1839
|
-
$[
|
|
1843
|
+
$[25] !== itemPath_0 || $[26] !== t9 || $[27] !== tree ? (t10 = {
|
|
1840
1844
|
...tree,
|
|
1841
1845
|
level: t9,
|
|
1842
1846
|
path: itemPath_0
|
|
1843
|
-
}, $[
|
|
1847
|
+
}, $[25] = itemPath_0, $[26] = t9, $[27] = tree, $[28] = t10) : t10 = $[28];
|
|
1844
1848
|
const contextValue = t10;
|
|
1845
1849
|
let t11;
|
|
1846
|
-
$[
|
|
1850
|
+
$[29] !== expanded || $[30] !== itemKey || $[31] !== onClick || $[32] !== rootElement || $[33] !== setExpanded || $[34] !== setFocusedElement ? (t11 = (event) => {
|
|
1847
1851
|
onClick && onClick(event);
|
|
1848
1852
|
const target = event.target;
|
|
1849
1853
|
target instanceof HTMLElement && (target.getAttribute("data-ui") === "TreeItem" || target.closest('[data-ui="TreeItem__box"]')) && (event.stopPropagation(), setExpanded(itemKey, !expanded), setFocusedElement(rootElement));
|
|
1850
|
-
}, $[
|
|
1854
|
+
}, $[29] = expanded, $[30] = itemKey, $[31] = onClick, $[32] = rootElement, $[33] = setExpanded, $[34] = setFocusedElement, $[35] = t11) : t11 = $[35];
|
|
1851
1855
|
const handleClick = t11;
|
|
1852
1856
|
let t12;
|
|
1853
|
-
$[
|
|
1857
|
+
$[36] !== focused || $[37] !== rootElement ? (t12 = (event_0) => {
|
|
1854
1858
|
focused && event_0.key === "Enter" && (treeitemRef.current || rootElement)?.click();
|
|
1855
|
-
}, $[
|
|
1859
|
+
}, $[36] = focused, $[37] = rootElement, $[38] = t12) : t12 = $[38];
|
|
1856
1860
|
const handleKeyDown = t12;
|
|
1857
1861
|
let t13, t14;
|
|
1858
|
-
$[
|
|
1862
|
+
$[39] !== expanded || $[40] !== itemKey || $[41] !== registerItem || $[42] !== rootElement || $[43] !== selected ? (t13 = () => {
|
|
1859
1863
|
if (rootElement)
|
|
1860
1864
|
return registerItem(rootElement, itemKey, expanded, selected);
|
|
1861
|
-
}, t14 = [expanded, itemKey, registerItem, rootElement, selected], $[
|
|
1865
|
+
}, t14 = [expanded, itemKey, registerItem, rootElement, selected], $[39] = expanded, $[40] = itemKey, $[41] = registerItem, $[42] = rootElement, $[43] = selected, $[44] = t13, $[45] = t14) : (t13 = $[44], t14 = $[45]), useEffect(t13, t14);
|
|
1862
1866
|
const t15 = IconComponent || children ? "visible" : "hidden";
|
|
1863
1867
|
let t16;
|
|
1864
|
-
$[
|
|
1868
|
+
$[46] !== t15 ? (t16 = {
|
|
1865
1869
|
visibility: t15,
|
|
1866
1870
|
pointerEvents: "none"
|
|
1867
|
-
}, $[
|
|
1871
|
+
}, $[46] = t15, $[47] = t16) : t16 = $[47];
|
|
1868
1872
|
let t17;
|
|
1869
|
-
$[
|
|
1873
|
+
$[48] !== IconComponent || $[49] !== fontSize || $[50] !== muted || $[51] !== weight ? (t17 = IconComponent && /* @__PURE__ */ jsx(Text, { muted, size: fontSize, weight, children: /* @__PURE__ */ jsx(IconComponent, {}) }), $[48] = IconComponent, $[49] = fontSize, $[50] = muted, $[51] = weight, $[52] = t17) : t17 = $[52];
|
|
1870
1874
|
let t18;
|
|
1871
|
-
$[
|
|
1875
|
+
$[53] !== IconComponent || $[54] !== expanded || $[55] !== fontSize || $[56] !== muted || $[57] !== weight ? (t18 = !IconComponent && /* @__PURE__ */ jsx(ToggleArrowText, { muted, size: fontSize, weight, children: /* @__PURE__ */ jsx(ToggleArrowRightIcon, { style: {
|
|
1872
1876
|
transform: expanded ? "rotate(90deg)" : void 0
|
|
1873
|
-
} }) }), $[
|
|
1877
|
+
} }) }), $[53] = IconComponent, $[54] = expanded, $[55] = fontSize, $[56] = muted, $[57] = weight, $[58] = t18) : t18 = $[58];
|
|
1874
1878
|
let t19;
|
|
1875
|
-
$[
|
|
1879
|
+
$[59] !== spacing || $[60] !== t16 || $[61] !== t17 || $[62] !== t18 ? (t19 = /* @__PURE__ */ jsxs(Box, { marginRight: spacing, style: t16, children: [
|
|
1876
1880
|
t17,
|
|
1877
1881
|
t18
|
|
1878
|
-
] }), $[
|
|
1882
|
+
] }), $[59] = spacing, $[60] = t16, $[61] = t17, $[62] = t18, $[63] = t19) : t19 = $[63];
|
|
1879
1883
|
let t20;
|
|
1880
|
-
$[
|
|
1884
|
+
$[64] !== fontSize || $[65] !== muted || $[66] !== text || $[67] !== weight ? (t20 = /* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsx(Text, { muted, size: fontSize, textOverflow: "ellipsis", weight, children: text }) }), $[64] = fontSize, $[65] = muted, $[66] = text, $[67] = weight, $[68] = t20) : t20 = $[68];
|
|
1881
1885
|
let t21;
|
|
1882
|
-
$[
|
|
1886
|
+
$[69] !== padding || $[70] !== t19 || $[71] !== t20 ? (t21 = /* @__PURE__ */ jsxs(Flex, { padding, children: [
|
|
1883
1887
|
t19,
|
|
1884
1888
|
t20
|
|
1885
|
-
] }), $[
|
|
1889
|
+
] }), $[69] = padding, $[70] = t19, $[71] = t20, $[72] = t21) : t21 = $[72];
|
|
1886
1890
|
const content2 = t21;
|
|
1887
1891
|
if (href) {
|
|
1888
1892
|
const t222 = selected ? "" : void 0;
|
|
1889
1893
|
let t232;
|
|
1890
|
-
$[
|
|
1894
|
+
$[73] !== content2 || $[74] !== expanded || $[75] !== href || $[76] !== linkAs || $[77] !== tabIndex || $[78] !== tree.level ? (t232 = /* @__PURE__ */ jsx(TreeItemBox, { $level: tree.level, "aria-expanded": expanded, as: linkAs, "data-ui": "TreeItem__box", href, ref: treeitemRef, role: "treeitem", tabIndex, children: content2 }), $[73] = content2, $[74] = expanded, $[75] = href, $[76] = linkAs, $[77] = tabIndex, $[78] = tree.level, $[79] = t232) : t232 = $[79];
|
|
1891
1895
|
let t242;
|
|
1892
|
-
$[
|
|
1896
|
+
$[80] !== children || $[81] !== expanded ? (t242 = children && /* @__PURE__ */ jsx(TreeGroup, { hidden: !expanded, children }), $[80] = children, $[81] = expanded, $[82] = t242) : t242 = $[82];
|
|
1893
1897
|
let t252;
|
|
1894
|
-
$[
|
|
1898
|
+
$[83] !== contextValue || $[84] !== t242 ? (t252 = /* @__PURE__ */ jsx(TreeContext.Provider, { value: contextValue, children: t242 }), $[83] = contextValue, $[84] = t242, $[85] = t252) : t252 = $[85];
|
|
1895
1899
|
let t262;
|
|
1896
|
-
return $[
|
|
1900
|
+
return $[86] !== handleClick || $[87] !== id || $[88] !== itemKey || $[89] !== restProps || $[90] !== t222 || $[91] !== t232 || $[92] !== t252 ? (t262 = /* @__PURE__ */ jsxs(StyledTreeItem, { "data-selected": t222, "data-tree-id": id, "data-tree-key": itemKey, "data-ui": "TreeItem", ...restProps, onClick: handleClick, ref: setRootElement, role: "none", children: [
|
|
1897
1901
|
t232,
|
|
1898
1902
|
t252
|
|
1899
|
-
] }), $[
|
|
1903
|
+
] }), $[86] = handleClick, $[87] = id, $[88] = itemKey, $[89] = restProps, $[90] = t222, $[91] = t232, $[92] = t252, $[93] = t262) : t262 = $[93], t262;
|
|
1900
1904
|
}
|
|
1901
1905
|
const t22 = selected ? "" : void 0;
|
|
1902
1906
|
let t23;
|
|
1903
|
-
$[
|
|
1907
|
+
$[94] !== content2 || $[95] !== tree.level ? (t23 = /* @__PURE__ */ jsx(TreeItemBox, { $level: tree.level, as: "div", "data-ui": "TreeItem__box", children: content2 }), $[94] = content2, $[95] = tree.level, $[96] = t23) : t23 = $[96];
|
|
1904
1908
|
let t24;
|
|
1905
|
-
$[
|
|
1909
|
+
$[97] !== children || $[98] !== expanded ? (t24 = children && /* @__PURE__ */ jsx(TreeGroup, { expanded, children }), $[97] = children, $[98] = expanded, $[99] = t24) : t24 = $[99];
|
|
1906
1910
|
let t25;
|
|
1907
|
-
$[
|
|
1911
|
+
$[100] !== contextValue || $[101] !== t24 ? (t25 = /* @__PURE__ */ jsx(TreeContext.Provider, { value: contextValue, children: t24 }), $[100] = contextValue, $[101] = t24, $[102] = t25) : t25 = $[102];
|
|
1908
1912
|
let t26;
|
|
1909
|
-
return $[
|
|
1913
|
+
return $[103] !== expanded || $[104] !== handleClick || $[105] !== handleKeyDown || $[106] !== id || $[107] !== itemKey || $[108] !== restProps || $[109] !== t22 || $[110] !== t23 || $[111] !== t25 || $[112] !== tabIndex ? (t26 = /* @__PURE__ */ jsxs(StyledTreeItem, { "data-selected": t22, "data-ui": "TreeItem", "data-tree-id": id, "data-tree-key": itemKey, ...restProps, "aria-expanded": expanded, onClick: handleClick, onKeyDown: handleKeyDown, ref: setRootElement, role: "treeitem", tabIndex, children: [
|
|
1910
1914
|
t23,
|
|
1911
1915
|
t25
|
|
1912
|
-
] }), $[
|
|
1916
|
+
] }), $[103] = expanded, $[104] = handleClick, $[105] = handleKeyDown, $[106] = id, $[107] = itemKey, $[108] = restProps, $[109] = t22, $[110] = t23, $[111] = t25, $[112] = tabIndex, $[113] = t26) : t26 = $[113], t26;
|
|
1913
1917
|
}
|
|
1914
1918
|
TreeItem.displayName = "TreeItem";
|
|
1915
1919
|
export {
|