@sanity/ui 2.8.2 → 2.8.4

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.js CHANGED
@@ -4977,8 +4977,8 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
4977
4977
  appearance: none;
4978
4978
  margin: -4px;
4979
4979
  `, Breadcrumbs = react.forwardRef(function(props, ref) {
4980
- const { children, maxLength, separator, space: spaceRaw = 2, ...restProps } = props, space = useArrayProp(spaceRaw), [open, setOpen] = react.useState(!1), [expandElement, setExpandElement] = react.useState(null), [popoverElement, setPopoverElement] = react.useState(null), collapse = react.useCallback(() => setOpen(!1), []), expand = react.useCallback(() => setOpen(!0), []);
4981
- useClickOutside(collapse, [expandElement, popoverElement]);
4980
+ const { children, maxLength, separator, space: spaceRaw = 2, ...restProps } = props, space = useArrayProp(spaceRaw), [open, setOpen] = react.useState(!1), expandElementRef = react.useRef(null), popoverElementRef = react.useRef(null), collapse = react.useCallback(() => setOpen(!1), []), expand = react.useCallback(() => setOpen(!0), []);
4981
+ useClickOutsideEvent(collapse, () => [expandElementRef.current, popoverElementRef.current]);
4982
4982
  const rawItems = react.useMemo(() => react.Children.toArray(children).filter(react.isValidElement), [children]), items = react.useMemo(() => {
4983
4983
  const len = rawItems.length;
4984
4984
  if (maxLength && len > maxLength) {
@@ -4993,7 +4993,7 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
4993
4993
  open,
4994
4994
  placement: "top",
4995
4995
  portal: !0,
4996
- ref: setPopoverElement,
4996
+ ref: popoverElementRef,
4997
4997
  children: /* @__PURE__ */ jsxRuntime.jsx(
4998
4998
  ExpandButton,
4999
4999
  {
@@ -5001,7 +5001,7 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
5001
5001
  mode: "bleed",
5002
5002
  onClick: open ? collapse : expand,
5003
5003
  padding: 1,
5004
- ref: setExpandElement,
5004
+ ref: expandElementRef,
5005
5005
  selected: open,
5006
5006
  text: "\u2026"
5007
5007
  }
@@ -5127,8 +5127,8 @@ const Root$7 = styledComponents.styled(Layer)(responsivePaddingStyle, dialogStyl
5127
5127
  scheme,
5128
5128
  shadow: shadowProp,
5129
5129
  width: widthProp
5130
- } = props, portal = usePortal(), portalElement = portalProp ? ((_a = portal.elements) == null ? void 0 : _a[portalProp]) || null : portal.element, boundaryElement = useBoundaryElement().element, radius = useArrayProp(radiusProp), shadow = useArrayProp(shadowProp), width = useArrayProp(widthProp), ref = react.useRef(null), [rootElement, setRootElement] = react.useState(null), contentRef = react.useRef(null), layer = useLayer(), { isTopLayer } = layer, labelId = `${id}_label`, showCloseButton = !!onClose && hideCloseButton === !1, showHeader = !!header || showCloseButton;
5131
- react.useImperativeHandle(forwardedRef, () => ref.current), react.useImperativeHandle(
5130
+ } = props, portal = usePortal(), portalElement = portalProp ? ((_a = portal.elements) == null ? void 0 : _a[portalProp]) || null : portal.element, boundaryElement = useBoundaryElement().element, radius = useArrayProp(radiusProp), shadow = useArrayProp(shadowProp), width = useArrayProp(widthProp), ref = react.useRef(null), contentRef = react.useRef(null), layer = useLayer(), { isTopLayer } = layer, labelId = `${id}_label`, showCloseButton = !!onClose && hideCloseButton === !1, showHeader = !!header || showCloseButton;
5131
+ return react.useImperativeHandle(forwardedRef, () => ref.current), react.useImperativeHandle(
5132
5132
  forwardedContentRef,
5133
5133
  () => contentRef.current
5134
5134
  ), react.useEffect(() => {
@@ -5142,21 +5142,13 @@ const Root$7 = styledComponents.styled(Layer)(responsivePaddingStyle, dialogStyl
5142
5142
  },
5143
5143
  [boundaryElement, isTopLayer, onClose, portalElement]
5144
5144
  )
5145
- ), useClickOutside(
5146
- react.useCallback(
5147
- (event) => {
5148
- if (!isTopLayer || !onClickOutside) return;
5149
- const target = event.target;
5150
- target && !isTargetWithinScope(boundaryElement, portalElement, target) || onClickOutside();
5151
- },
5152
- [boundaryElement, isTopLayer, onClickOutside, portalElement]
5153
- ),
5154
- [rootElement]
5155
- );
5156
- const setRef = react.useCallback((el) => {
5157
- setRootElement(el), ref.current = el;
5158
- }, []);
5159
- return /* @__PURE__ */ jsxRuntime.jsx(DialogContainer, { "data-ui": "DialogCard", width, children: /* @__PURE__ */ jsxRuntime.jsx(DialogCardRoot, { radius, ref: setRef, scheme, shadow, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogLayout, { direction: "column", children: [
5145
+ ), useClickOutsideEvent(
5146
+ isTopLayer && onClickOutside && ((event) => {
5147
+ const target = event.target;
5148
+ target && !isTargetWithinScope(boundaryElement, portalElement, target) || onClickOutside();
5149
+ }),
5150
+ () => [ref.current]
5151
+ ), /* @__PURE__ */ jsxRuntime.jsx(DialogContainer, { "data-ui": "DialogCard", width, children: /* @__PURE__ */ jsxRuntime.jsx(DialogCardRoot, { radius, ref, scheme, shadow, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogLayout, { direction: "column", children: [
5160
5152
  showHeader && /* @__PURE__ */ jsxRuntime.jsx(DialogHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(Flex, { align: "center", padding: 3, children: [
5161
5153
  /* @__PURE__ */ jsxRuntime.jsx(Box, { flex: 1, padding: 2, children: header && /* @__PURE__ */ jsxRuntime.jsx(Text, { id: labelId, size: 1, weight: "semibold", children: header }) }),
5162
5154
  showCloseButton && /* @__PURE__ */ jsxRuntime.jsx(Box, { flex: "none", children: /* @__PURE__ */ jsxRuntime.jsx(