@sanity/ui 2.3.4-canary.0 → 2.3.5

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.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { buildTheme, createColorTheme as createColorTheme$1, hexToRgb as hexToRgb$1, hslToRgb as hslToRgb$1, multiply as multiply$1, parseColor as parseColor$1, rgbToHex as rgbToHex$1, rgbToHsl as rgbToHsl$1, rgba as rgba$1, screen as screen$1, getTheme_v2, getScopedTheme } from "@sanity/ui/theme";
2
2
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
3
- import { useMemo, useState, useRef, useEffect, createContext, useContext, useSyncExternalStore, useImperativeHandle, forwardRef, useId, useCallback, Children, cloneElement, isValidElement, Component, memo, useReducer, Fragment as Fragment$1, startTransition } from "react";
3
+ import { useMemo, useState, useRef, useEffect, createContext, useContext, useSyncExternalStore, useImperativeHandle, forwardRef, useId, useCallback, Children, isValidElement, cloneElement, Component, memo, useReducer, Fragment as Fragment$1, startTransition } from "react";
4
4
  import ReactIs, { isValidElementType } from "react-is";
5
5
  import { ThemeProvider as ThemeProvider$1, useTheme as useTheme$1, css, styled, keyframes } from "styled-components";
6
6
  import { SpinnerIcon, CheckmarkIcon, RemoveIcon, ChevronDownIcon, CloseIcon, ChevronRightIcon, ToggleArrowRightIcon } from "@sanity/icons";
@@ -1559,8 +1559,9 @@ const Root$z = styled.div(responsiveAvatarStackSizeStyle, avatarStackStyle), Ava
1559
1559
  maxLength: maxLengthProp = 4,
1560
1560
  size: sizeProp = 1,
1561
1561
  ...restProps
1562
- } = props, children = Children.toArray(childrenProp).filter(
1563
- (child) => typeof child != "string"
1562
+ } = props, children = useMemo(
1563
+ () => Children.toArray(childrenProp).filter(isValidElement),
1564
+ [childrenProp]
1564
1565
  ), maxLength = Math.max(maxLengthProp, 0), size2 = useArrayProp(sizeProp), len = children.length, visibleCount = maxLength - 1, extraCount = len - visibleCount, visibleChildren = extraCount > 1 ? children.slice(extraCount, len) : children;
1565
1566
  return /* @__PURE__ */ jsxs(Root$z, { "data-ui": "AvatarStack", ...restProps, ref, $size: size2, children: [
1566
1567
  len === 0 && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(AvatarCounter, { count: len, size: size2 }) }),
@@ -2634,7 +2635,7 @@ function inlineSpaceStyle(props) {
2634
2635
  }
2635
2636
  const Root$m = styled(Box)(inlineBaseStyle, inlineSpaceStyle), Inline = forwardRef(function(props, ref) {
2636
2637
  const { as, children: childrenProp, space, ...restProps } = props, children = useMemo(
2637
- () => Children.map(childrenProp, (child) => /* @__PURE__ */ jsx("div", { children: child })),
2638
+ () => Children.map(childrenProp, (child) => child && /* @__PURE__ */ jsx("div", { children: child })),
2638
2639
  [childrenProp]
2639
2640
  );
2640
2641
  return /* @__PURE__ */ jsx(
@@ -4951,10 +4952,7 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
4951
4952
  `, Breadcrumbs = forwardRef(function(props, ref) {
4952
4953
  const { children, maxLength, separator, space: spaceRaw = 2, ...restProps } = props, space = useArrayProp(spaceRaw), [open, setOpen] = useState(!1), [expandElement, setExpandElement] = useState(null), [popoverElement, setPopoverElement] = useState(null), collapse = useCallback(() => setOpen(!1), []), expand = useCallback(() => setOpen(!0), []);
4953
4954
  useClickOutside(collapse, [expandElement, popoverElement]);
4954
- const rawItems = useMemo(
4955
- () => Children.toArray(children).filter((child) => isValidElement(child)),
4956
- [children]
4957
- ), items = useMemo(() => {
4955
+ const rawItems = useMemo(() => Children.toArray(children).filter(isValidElement), [children]), items = useMemo(() => {
4958
4956
  const len = rawItems.length;
4959
4957
  if (maxLength && len > maxLength) {
4960
4958
  const beforeLength = Math.ceil(maxLength / 2), afterLength = Math.floor(maxLength / 2);
@@ -5605,17 +5603,20 @@ const Root$5 = styled(Box)`
5605
5603
  shouldFocus
5606
5604
  ]
5607
5605
  ), menu = menuProp && cloneElement(menuProp, menuProps), ref = useRef(null), button = useMemo(
5608
- () => buttonProp && cloneElement(buttonProp, {
5609
- "data-ui": "MenuButton",
5610
- id,
5611
- onClick: handleButtonClick,
5612
- onKeyDown: handleButtonKeyDown,
5613
- onMouseDown: handleMouseDown,
5614
- "aria-haspopup": !0,
5615
- "aria-expanded": open,
5616
- ref,
5617
- selected: open
5618
- }),
5606
+ () => {
5607
+ var _a;
5608
+ return buttonProp && cloneElement(buttonProp, {
5609
+ "data-ui": "MenuButton",
5610
+ id,
5611
+ onClick: handleButtonClick,
5612
+ onKeyDown: handleButtonKeyDown,
5613
+ onMouseDown: handleMouseDown,
5614
+ "aria-haspopup": !0,
5615
+ "aria-expanded": open,
5616
+ ref,
5617
+ selected: (_a = buttonProp.props.selected) != null ? _a : open
5618
+ });
5619
+ },
5619
5620
  [buttonProp, handleButtonClick, handleButtonKeyDown, handleMouseDown, id, open]
5620
5621
  );
5621
5622
  useImperativeHandle(
@@ -6467,7 +6468,7 @@ const key = Symbol.for("@sanity/ui/context/tree"), TreeContext = createGlobalSco
6467
6468
  ref.current.querySelectorAll('[data-ui="TreeItem"]')
6468
6469
  );
6469
6470
  setItemElements(_itemElements);
6470
- }, [children, ref]), /* @__PURE__ */ jsx(TreeContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
6471
+ }, [children]), /* @__PURE__ */ jsx(TreeContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
6471
6472
  Stack,
6472
6473
  {
6473
6474
  as: "ul",