@sanity/ui 3.0.11 → 3.0.12-canary.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/index.mjs CHANGED
@@ -3,7 +3,7 @@ import { Arrow, Avatar, AvatarCounter, AvatarStack, Badge, BoundaryElementProvid
3
3
  import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
4
4
  import { c } from "react-compiler-runtime";
5
5
  import { SpinnerIcon, ChevronDownIcon, CloseIcon, ToggleArrowRightIcon } from "@sanity/icons";
6
- import { useState, useRef, useEffect, useImperativeHandle, Component, forwardRef, useReducer, cloneElement, useCallback, useMemo, Children, isValidElement, Fragment, useContext, useSyncExternalStore, startTransition, memo, useId } from "react";
6
+ import { useState, useRef, useEffect, useImperativeHandle, Component, forwardRef, useReducer, cloneElement, Children, isValidElement, Fragment, useContext, useSyncExternalStore, startTransition, memo, useId } from "react";
7
7
  import { styled, keyframes, css } from "styled-components";
8
8
  import { getTheme_v2 } from "@sanity/ui/theme";
9
9
  import { motion, AnimatePresence } from "framer-motion";
@@ -572,28 +572,83 @@ const StyledBreadcrumbs = styled.ol.withConfig({
572
572
  displayName: "ExpandButton",
573
573
  componentId: "sc-1es8h8q-1"
574
574
  })`appearance:none;margin:-4px;`, Breadcrumbs = forwardRef(function(props, ref) {
575
- const {
575
+ const $ = c(27);
576
+ let children, maxLength, restProps, separator, t0;
577
+ $[0] !== props ? ({
576
578
  children,
577
579
  maxLength,
578
580
  separator,
579
- space: spaceRaw = 2,
581
+ space: t0,
580
582
  ...restProps
581
- } = props, space = useArrayProp(spaceRaw), [open, setOpen] = useState(!1), expandElementRef = useRef(null), popoverElementRef = useRef(null), collapse = useCallback(() => setOpen(!1), []), expand = useCallback(() => setOpen(!0), []);
582
- useClickOutsideEvent(collapse, () => [expandElementRef.current, popoverElementRef.current]);
583
- const rawItems = useMemo(() => Children.toArray(children).filter(isValidElement), [children]), items = useMemo(() => {
584
- const len = rawItems.length;
585
- if (maxLength && len > maxLength) {
586
- const beforeLength = Math.ceil(maxLength / 2), afterLength = Math.floor(maxLength / 2);
587
- return [...rawItems.slice(0, beforeLength - 1), /* @__PURE__ */ jsx(Popover, { constrainSize: !0, content: /* @__PURE__ */ jsx(Stack, { as: "ol", overflow: "auto", padding: space, space, children: rawItems.slice(beforeLength - 1, len - afterLength) }), open, placement: "top", portal: !0, ref: popoverElementRef, children: /* @__PURE__ */ jsx(ExpandButton, { fontSize: 1, mode: "bleed", onClick: open ? collapse : expand, padding: 1, ref: expandElementRef, selected: open, text: "\u2026" }) }, "button"), ...rawItems.slice(len - afterLength)];
588
- }
589
- return rawItems;
590
- }, [collapse, expand, maxLength, open, rawItems, space]);
591
- return /* @__PURE__ */ jsx(StyledBreadcrumbs, { "data-ui": "Breadcrumbs", ...restProps, ref, children: items.map((item, itemIndex) => /* @__PURE__ */ jsxs(Fragment, { children: [
592
- itemIndex > 0 && /* @__PURE__ */ jsx(Box, { "aria-hidden": !0, as: "li", paddingX: space, children: separator || /* @__PURE__ */ jsx(Text, { muted: !0, children: "/" }) }),
593
- /* @__PURE__ */ jsx(Box, { as: "li", children: item })
594
- ] }, itemIndex)) });
583
+ } = props, $[0] = props, $[1] = children, $[2] = maxLength, $[3] = restProps, $[4] = separator, $[5] = t0) : (children = $[1], maxLength = $[2], restProps = $[3], separator = $[4], t0 = $[5]);
584
+ const space = useArrayProp(t0 === void 0 ? 2 : t0), [open, setOpen] = useState(!1), expandElementRef = useRef(null), popoverElementRef = useRef(null);
585
+ let t1;
586
+ $[6] === Symbol.for("react.memo_cache_sentinel") ? (t1 = () => setOpen(!1), $[6] = t1) : t1 = $[6];
587
+ const collapse = t1;
588
+ let t2;
589
+ $[7] === Symbol.for("react.memo_cache_sentinel") ? (t2 = () => setOpen(!0), $[7] = t2) : t2 = $[7];
590
+ const expand = t2;
591
+ let t3;
592
+ $[8] === Symbol.for("react.memo_cache_sentinel") ? (t3 = () => [expandElementRef.current, popoverElementRef.current], $[8] = t3) : t3 = $[8], useClickOutsideEvent(collapse, t3);
593
+ let t4;
594
+ $[9] !== children ? (t4 = Children.toArray(children).filter(isValidElement), $[9] = children, $[10] = t4) : t4 = $[10];
595
+ const rawItems = t4;
596
+ let t5;
597
+ $[11] !== maxLength || $[12] !== open || $[13] !== rawItems || $[14] !== space ? (t5 = {
598
+ collapse,
599
+ expand,
600
+ expandElementRef,
601
+ maxLength,
602
+ open,
603
+ popoverElementRef,
604
+ rawItems,
605
+ space
606
+ }, $[11] = maxLength, $[12] = open, $[13] = rawItems, $[14] = space, $[15] = t5) : t5 = $[15];
607
+ const items = useItems(t5);
608
+ let t6;
609
+ if ($[16] !== items || $[17] !== separator || $[18] !== space) {
610
+ let t72;
611
+ $[20] !== separator || $[21] !== space ? (t72 = (item, itemIndex) => /* @__PURE__ */ jsxs(Fragment, { children: [
612
+ itemIndex > 0 && /* @__PURE__ */ jsx(Box, { "aria-hidden": !0, as: "li", paddingX: space, children: separator || /* @__PURE__ */ jsx(Text, { muted: !0, children: "/" }) }),
613
+ /* @__PURE__ */ jsx(Box, { as: "li", children: item })
614
+ ] }, itemIndex), $[20] = separator, $[21] = space, $[22] = t72) : t72 = $[22], t6 = items.map(t72), $[16] = items, $[17] = separator, $[18] = space, $[19] = t6;
615
+ } else
616
+ t6 = $[19];
617
+ let t7;
618
+ return $[23] !== ref || $[24] !== restProps || $[25] !== t6 ? (t7 = /* @__PURE__ */ jsx(StyledBreadcrumbs, { "data-ui": "Breadcrumbs", ...restProps, ref, children: t6 }), $[23] = ref, $[24] = restProps, $[25] = t6, $[26] = t7) : t7 = $[26], t7;
595
619
  });
596
620
  Breadcrumbs.displayName = "ForwardRef(Breadcrumbs)";
621
+ function useItems(t0) {
622
+ const $ = c(28), {
623
+ collapse,
624
+ expand,
625
+ expandElementRef,
626
+ maxLength,
627
+ open,
628
+ popoverElementRef,
629
+ rawItems,
630
+ space
631
+ } = t0, len = rawItems.length;
632
+ if (maxLength && len > maxLength) {
633
+ const beforeLength = Math.ceil(maxLength / 2), afterLength = Math.floor(maxLength / 2);
634
+ let t1;
635
+ if ($[0] !== afterLength || $[1] !== beforeLength || $[2] !== collapse || $[3] !== expand || $[4] !== expandElementRef || $[5] !== len || $[6] !== open || $[7] !== popoverElementRef || $[8] !== rawItems || $[9] !== space) {
636
+ const t2 = rawItems.slice(0, beforeLength - 1);
637
+ let t3;
638
+ $[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];
639
+ let t4;
640
+ $[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];
641
+ const t5 = open ? collapse : expand;
642
+ let t6;
643
+ $[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];
644
+ let t7;
645
+ $[23] !== open || $[24] !== popoverElementRef || $[25] !== t4 || $[26] !== t6 ? (t7 = /* @__PURE__ */ jsx(Popover, { constrainSize: !0, content: t4, open, placement: "top", portal: !0, ref: popoverElementRef, children: t6 }, "button"), $[23] = open, $[24] = popoverElementRef, $[25] = t4, $[26] = t6, $[27] = t7) : t7 = $[27], t1 = [...t2, t7, ...rawItems.slice(len - afterLength)], $[0] = afterLength, $[1] = beforeLength, $[2] = collapse, $[3] = expand, $[4] = expandElementRef, $[5] = len, $[6] = open, $[7] = popoverElementRef, $[8] = rawItems, $[9] = space, $[10] = t1;
646
+ } else
647
+ t1 = $[10];
648
+ return t1;
649
+ }
650
+ return rawItems;
651
+ }
597
652
  function dialogStyle({
598
653
  theme
599
654
  }) {