@sanity/ui 2.10.18 → 2.11.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.js CHANGED
@@ -6091,13 +6091,14 @@ function useMenu() {
6091
6091
  return value;
6092
6092
  }
6093
6093
  function MenuGroup(props) {
6094
- const $ = reactCompilerRuntime.c(77);
6095
- let IconComponent, children, onClick, popover, restProps, t0, t1, t2, t3, t4, t5, text;
6094
+ const $ = reactCompilerRuntime.c(79);
6095
+ let IconComponent, children, menuProps, onClick, popover, restProps, t0, t1, t2, t3, t4, t5, text;
6096
6096
  $[0] !== props ? ({
6097
6097
  as: t0,
6098
6098
  children,
6099
6099
  fontSize: t1,
6100
6100
  icon: IconComponent,
6101
+ menu: menuProps,
6101
6102
  onClick,
6102
6103
  padding: t2,
6103
6104
  popover,
@@ -6106,7 +6107,7 @@ function MenuGroup(props) {
6106
6107
  text,
6107
6108
  tone: t5,
6108
6109
  ...restProps
6109
- } = props, $[0] = props, $[1] = IconComponent, $[2] = children, $[3] = onClick, $[4] = popover, $[5] = restProps, $[6] = t0, $[7] = t1, $[8] = t2, $[9] = t3, $[10] = t4, $[11] = t5, $[12] = text) : (IconComponent = $[1], children = $[2], onClick = $[3], popover = $[4], restProps = $[5], t0 = $[6], t1 = $[7], t2 = $[8], t3 = $[9], t4 = $[10], t5 = $[11], text = $[12]);
6110
+ } = props, $[0] = props, $[1] = IconComponent, $[2] = children, $[3] = menuProps, $[4] = onClick, $[5] = popover, $[6] = restProps, $[7] = t0, $[8] = t1, $[9] = t2, $[10] = t3, $[11] = t4, $[12] = t5, $[13] = text) : (IconComponent = $[1], children = $[2], menuProps = $[3], onClick = $[4], popover = $[5], restProps = $[6], t0 = $[7], t1 = $[8], t2 = $[9], t3 = $[10], t4 = $[11], t5 = $[12], text = $[13]);
6110
6111
  const as = t0 === void 0 ? "button" : t0, fontSize2 = t1 === void 0 ? 1 : t1, padding = t2 === void 0 ? 3 : t2, radius = t3 === void 0 ? 2 : t3, space = t4 === void 0 ? 3 : t4, tone = t5 === void 0 ? "default" : t5, menu = useMenu(), {
6111
6112
  scheme
6112
6113
  } = useRootTheme(), {
@@ -6119,80 +6120,80 @@ function MenuGroup(props) {
6119
6120
  registerElement
6120
6121
  } = menu, onItemMouseEnter = _onItemMouseEnter ?? menu.onMouseEnter, [rootElement, setRootElement] = react.useState(null), [open, setOpen] = react.useState(!1), [shouldFocus, setShouldFocus] = react.useState(null), active = !!activeElement && activeElement === rootElement, [withinMenu, setWithinMenu] = react.useState(!1);
6121
6122
  let t6;
6122
- $[13] !== onItemMouseEnter ? (t6 = (event) => {
6123
+ $[14] !== onItemMouseEnter ? (t6 = (event) => {
6123
6124
  setWithinMenu(!1), onItemMouseEnter(event), setOpen(!0);
6124
- }, $[13] = onItemMouseEnter, $[14] = t6) : t6 = $[14];
6125
+ }, $[14] = onItemMouseEnter, $[15] = t6) : t6 = $[15];
6125
6126
  const handleMouseEnter = t6;
6126
6127
  let t7;
6127
- $[15] !== rootElement ? (t7 = (event_0) => {
6128
+ $[16] !== rootElement ? (t7 = (event_0) => {
6128
6129
  event_0.key === "ArrowLeft" && (event_0.stopPropagation(), setOpen(!1), requestAnimationFrame(() => {
6129
6130
  rootElement?.focus();
6130
6131
  }));
6131
- }, $[15] = rootElement, $[16] = t7) : t7 = $[16];
6132
+ }, $[16] = rootElement, $[17] = t7) : t7 = $[17];
6132
6133
  const handleMenuKeyDown = t7;
6133
6134
  let t8;
6134
- $[17] !== onClick ? (t8 = (event_1) => {
6135
+ $[18] !== onClick ? (t8 = (event_1) => {
6135
6136
  onClick?.(event_1), setShouldFocus("first"), setOpen(!0);
6136
- }, $[17] = onClick, $[18] = t8) : t8 = $[18];
6137
+ }, $[18] = onClick, $[19] = t8) : t8 = $[19];
6137
6138
  const handleClick = t8;
6138
6139
  let t9;
6139
- $[19] !== onItemClick ? (t9 = () => {
6140
+ $[20] !== onItemClick ? (t9 = () => {
6140
6141
  setOpen(!1), onItemClick?.();
6141
- }, $[19] = onItemClick, $[20] = t9) : t9 = $[20];
6142
+ }, $[20] = onItemClick, $[21] = t9) : t9 = $[21];
6142
6143
  const handleChildItemClick = t9;
6143
6144
  let t10;
6144
- $[21] === Symbol.for("react.memo_cache_sentinel") ? (t10 = () => setWithinMenu(!0), $[21] = t10) : t10 = $[21];
6145
+ $[22] === Symbol.for("react.memo_cache_sentinel") ? (t10 = () => setWithinMenu(!0), $[22] = t10) : t10 = $[22];
6145
6146
  const handleMenuMouseEnter = t10;
6146
6147
  let t11, t12;
6147
- $[22] !== mount || $[23] !== rootElement ? (t11 = () => mount(rootElement), t12 = [mount, rootElement], $[22] = mount, $[23] = rootElement, $[24] = t11, $[25] = t12) : (t11 = $[24], t12 = $[25]), react.useEffect(t11, t12);
6148
+ $[23] !== mount || $[24] !== rootElement ? (t11 = () => mount(rootElement), t12 = [mount, rootElement], $[23] = mount, $[24] = rootElement, $[25] = t11, $[26] = t12) : (t11 = $[25], t12 = $[26]), react.useEffect(t11, t12);
6148
6149
  let t13, t14;
6149
- $[26] !== active ? (t13 = () => {
6150
+ $[27] !== active ? (t13 = () => {
6150
6151
  active || setOpen(!1);
6151
- }, t14 = [active], $[26] = active, $[27] = t13, $[28] = t14) : (t13 = $[27], t14 = $[28]), react.useEffect(t13, t14);
6152
+ }, t14 = [active], $[27] = active, $[28] = t13, $[29] = t14) : (t13 = $[28], t14 = $[29]), react.useEffect(t13, t14);
6152
6153
  let t15, t16;
6153
- $[29] !== open ? (t15 = () => {
6154
+ $[30] !== open ? (t15 = () => {
6154
6155
  open || setWithinMenu(!1);
6155
- }, t16 = [open], $[29] = open, $[30] = t15, $[31] = t16) : (t15 = $[30], t16 = $[31]), react.useEffect(t15, t16);
6156
+ }, t16 = [open], $[30] = open, $[31] = t15, $[32] = t16) : (t15 = $[31], t16 = $[32]), react.useEffect(t15, t16);
6156
6157
  let t17, t18;
6157
- $[32] !== shouldFocus ? (t17 = () => {
6158
+ $[33] !== shouldFocus ? (t17 = () => {
6158
6159
  if (!shouldFocus)
6159
6160
  return;
6160
6161
  const rafId = requestAnimationFrame(() => setShouldFocus(null));
6161
6162
  return () => cancelAnimationFrame(rafId);
6162
- }, t18 = [shouldFocus], $[32] = shouldFocus, $[33] = t17, $[34] = t18) : (t17 = $[33], t18 = $[34]), react.useEffect(t17, t18);
6163
+ }, t18 = [shouldFocus], $[33] = shouldFocus, $[34] = t17, $[35] = t18) : (t17 = $[34], t18 = $[35]), react.useEffect(t17, t18);
6163
6164
  let t19;
6164
- $[35] !== children || $[36] !== handleChildItemClick || $[37] !== handleMenuKeyDown || $[38] !== onClickOutside || $[39] !== onEscape || $[40] !== registerElement || $[41] !== shouldFocus ? (t19 = /* @__PURE__ */ jsxRuntime.jsx(Menu, { onClickOutside, onEscape, onItemClick: handleChildItemClick, onKeyDown: handleMenuKeyDown, onMouseEnter: handleMenuMouseEnter, registerElement, shouldFocus, children }), $[35] = children, $[36] = handleChildItemClick, $[37] = handleMenuKeyDown, $[38] = onClickOutside, $[39] = onEscape, $[40] = registerElement, $[41] = shouldFocus, $[42] = t19) : t19 = $[42];
6165
+ $[36] !== children || $[37] !== handleChildItemClick || $[38] !== handleMenuKeyDown || $[39] !== menuProps || $[40] !== onClickOutside || $[41] !== onEscape || $[42] !== registerElement || $[43] !== shouldFocus ? (t19 = /* @__PURE__ */ jsxRuntime.jsx(Menu, { ...menuProps, onClickOutside, onEscape, onItemClick: handleChildItemClick, onKeyDown: handleMenuKeyDown, onMouseEnter: handleMenuMouseEnter, registerElement, shouldFocus, children }), $[36] = children, $[37] = handleChildItemClick, $[38] = handleMenuKeyDown, $[39] = menuProps, $[40] = onClickOutside, $[41] = onEscape, $[42] = registerElement, $[43] = shouldFocus, $[44] = t19) : t19 = $[44];
6165
6166
  const childMenu = t19;
6166
6167
  let t20;
6167
- $[43] === Symbol.for("react.memo_cache_sentinel") ? (t20 = (event_2) => {
6168
+ $[45] === Symbol.for("react.memo_cache_sentinel") ? (t20 = (event_2) => {
6168
6169
  const target = event_2.currentTarget;
6169
6170
  if (document.activeElement === target && event_2.key === "ArrowRight") {
6170
6171
  setShouldFocus("first"), setOpen(!0), setWithinMenu(!0);
6171
6172
  return;
6172
6173
  }
6173
- }, $[43] = t20) : t20 = $[43];
6174
+ }, $[45] = t20) : t20 = $[45];
6174
6175
  const handleKeyDown = t20, t21 = as === "button" ? withinMenu : void 0, t22 = as !== "button" ? withinMenu : void 0, t23 = !withinMenu && active ? "" : void 0, t24 = useArrayProp(radius), t25 = as === "button" ? "button" : void 0;
6175
6176
  let t26;
6176
- $[44] !== IconComponent || $[45] !== fontSize2 ? (t26 = IconComponent && /* @__PURE__ */ jsxRuntime.jsxs(Text, { size: fontSize2, children: [
6177
+ $[46] !== IconComponent || $[47] !== fontSize2 ? (t26 = IconComponent && /* @__PURE__ */ jsxRuntime.jsxs(Text, { size: fontSize2, children: [
6177
6178
  react.isValidElement(IconComponent) && IconComponent,
6178
6179
  ReactIs.isValidElementType(IconComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconComponent, {})
6179
- ] }), $[44] = IconComponent, $[45] = fontSize2, $[46] = t26) : t26 = $[46];
6180
+ ] }), $[46] = IconComponent, $[47] = fontSize2, $[48] = t26) : t26 = $[48];
6180
6181
  let t27;
6181
- $[47] !== fontSize2 || $[48] !== text ? (t27 = /* @__PURE__ */ jsxRuntime.jsx(Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(Text, { size: fontSize2, textOverflow: "ellipsis", weight: "medium", children: text }) }), $[47] = fontSize2, $[48] = text, $[49] = t27) : t27 = $[49];
6182
+ $[49] !== fontSize2 || $[50] !== text ? (t27 = /* @__PURE__ */ jsxRuntime.jsx(Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(Text, { size: fontSize2, textOverflow: "ellipsis", weight: "medium", children: text }) }), $[49] = fontSize2, $[50] = text, $[51] = t27) : t27 = $[51];
6182
6183
  let t28;
6183
- $[50] === Symbol.for("react.memo_cache_sentinel") ? (t28 = /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronRightIcon, {}), $[50] = t28) : t28 = $[50];
6184
+ $[52] === Symbol.for("react.memo_cache_sentinel") ? (t28 = /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronRightIcon, {}), $[52] = t28) : t28 = $[52];
6184
6185
  let t29;
6185
- $[51] !== fontSize2 ? (t29 = /* @__PURE__ */ jsxRuntime.jsx(Text, { size: fontSize2, children: t28 }), $[51] = fontSize2, $[52] = t29) : t29 = $[52];
6186
+ $[53] !== fontSize2 ? (t29 = /* @__PURE__ */ jsxRuntime.jsx(Text, { size: fontSize2, children: t28 }), $[53] = fontSize2, $[54] = t29) : t29 = $[54];
6186
6187
  let t30;
6187
- $[53] !== padding || $[54] !== space || $[55] !== t26 || $[56] !== t27 || $[57] !== t29 ? (t30 = /* @__PURE__ */ jsxRuntime.jsxs(Flex, { gap: space, padding, children: [
6188
+ $[55] !== padding || $[56] !== space || $[57] !== t26 || $[58] !== t27 || $[59] !== t29 ? (t30 = /* @__PURE__ */ jsxRuntime.jsxs(Flex, { gap: space, padding, children: [
6188
6189
  t26,
6189
6190
  t27,
6190
6191
  t29
6191
- ] }), $[53] = padding, $[54] = space, $[55] = t26, $[56] = t27, $[57] = t29, $[58] = t30) : t30 = $[58];
6192
+ ] }), $[55] = padding, $[56] = space, $[57] = t26, $[58] = t27, $[59] = t29, $[60] = t30) : t30 = $[60];
6192
6193
  let t31;
6193
- $[59] !== as || $[60] !== handleClick || $[61] !== handleMouseEnter || $[62] !== restProps || $[63] !== scheme || $[64] !== t21 || $[65] !== t22 || $[66] !== t23 || $[67] !== t24 || $[68] !== t25 || $[69] !== t30 || $[70] !== tone ? (t31 = /* @__PURE__ */ jsxRuntime.jsx(Selectable, { "data-as": as, "data-ui": "MenuGroup", forwardedAs: as, ...restProps, "aria-pressed": t21, "data-pressed": t22, "data-selected": t23, $radius: t24, $tone: tone, $scheme: scheme, onClick: handleClick, onKeyDown: handleKeyDown, onMouseEnter: handleMouseEnter, ref: setRootElement, tabIndex: -1, type: t25, children: t30 }), $[59] = as, $[60] = handleClick, $[61] = handleMouseEnter, $[62] = restProps, $[63] = scheme, $[64] = t21, $[65] = t22, $[66] = t23, $[67] = t24, $[68] = t25, $[69] = t30, $[70] = tone, $[71] = t31) : t31 = $[71];
6194
+ $[61] !== as || $[62] !== handleClick || $[63] !== handleMouseEnter || $[64] !== restProps || $[65] !== scheme || $[66] !== t21 || $[67] !== t22 || $[68] !== t23 || $[69] !== t24 || $[70] !== t25 || $[71] !== t30 || $[72] !== tone ? (t31 = /* @__PURE__ */ jsxRuntime.jsx(Selectable, { "data-as": as, "data-ui": "MenuGroup", forwardedAs: as, ...restProps, "aria-pressed": t21, "data-pressed": t22, "data-selected": t23, $radius: t24, $tone: tone, $scheme: scheme, onClick: handleClick, onKeyDown: handleKeyDown, onMouseEnter: handleMouseEnter, ref: setRootElement, tabIndex: -1, type: t25, children: t30 }), $[61] = as, $[62] = handleClick, $[63] = handleMouseEnter, $[64] = restProps, $[65] = scheme, $[66] = t21, $[67] = t22, $[68] = t23, $[69] = t24, $[70] = t25, $[71] = t30, $[72] = tone, $[73] = t31) : t31 = $[73];
6194
6195
  let t32;
6195
- return $[72] !== childMenu || $[73] !== open || $[74] !== popover || $[75] !== t31 ? (t32 = /* @__PURE__ */ jsxRuntime.jsx(Popover, { ...popover, content: childMenu, "data-ui": "MenuGroup__popover", open, children: t31 }), $[72] = childMenu, $[73] = open, $[74] = popover, $[75] = t31, $[76] = t32) : t32 = $[76], t32;
6196
+ return $[74] !== childMenu || $[75] !== open || $[76] !== popover || $[77] !== t31 ? (t32 = /* @__PURE__ */ jsxRuntime.jsx(Popover, { ...popover, content: childMenu, "data-ui": "MenuGroup__popover", open, children: t31 }), $[74] = childMenu, $[75] = open, $[76] = popover, $[77] = t31, $[78] = t32) : t32 = $[78], t32;
6196
6197
  }
6197
6198
  MenuGroup.displayName = "MenuGroup";
6198
6199
  const MenuItem = react.forwardRef(function(props, forwardedRef) {