@sanity/ui 2.16.13 → 2.16.14

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
@@ -396,13 +396,38 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = ["Control", "Shift", "Alt", "Enter", "H
396
396
  selected: active,
397
397
  tabIndex: listFocused && active ? 0 : -1
398
398
  }) }, option_0.value);
399
- }) }) }), [activeValue, currentOption, filteredOptions, handleOptionSelect, handleListBoxKeyDown, id, listBox, listBoxId, listFocused, loading, renderOption]), results = useMemo(() => renderPopover ? renderPopover({
400
- content: content2,
401
- hidden: !expanded,
402
- inputElement: inputElementRef.current,
403
- onMouseEnter: handlePopoverMouseEnter,
404
- onMouseLeave: handlePopoverMouseLeave
405
- }, resultsPopoverElementRef) : filteredOptionsLen === 0 ? null : /* @__PURE__ */ jsx(Popover, { arrow: !1, constrainSize: !0, content: content2, fallbackPlacements: AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS, matchReferenceWidth: !0, onMouseEnter: handlePopoverMouseEnter, onMouseLeave: handlePopoverMouseLeave, open: expanded, overflow: "auto", placement: AUTOCOMPLETE_POPOVER_PLACEMENT, portal: !0, radius, ref: resultsPopoverElementRef, referenceElement: inputElementRef.current, ...popover }), [content2, expanded, filteredOptionsLen, handlePopoverMouseEnter, handlePopoverMouseLeave, popover, radius, renderPopover]);
399
+ }) }) }), [activeValue, currentOption, filteredOptions, handleOptionSelect, handleListBoxKeyDown, id, listBox, listBoxId, listFocused, loading, renderOption]), results = useMemo(() => renderPopover ? renderPopover(
400
+ // eslint-disable-next-line react-hooks/refs
401
+ {
402
+ content: content2,
403
+ hidden: !expanded,
404
+ // eslint-disable-next-line react-hooks/refs
405
+ inputElement: inputElementRef.current,
406
+ onMouseEnter: handlePopoverMouseEnter,
407
+ onMouseLeave: handlePopoverMouseLeave
408
+ },
409
+ // eslint-disable-next-line react-hooks/refs
410
+ resultsPopoverElementRef
411
+ ) : filteredOptionsLen === 0 ? null : /* @__PURE__ */ jsx(
412
+ Popover,
413
+ {
414
+ arrow: !1,
415
+ constrainSize: !0,
416
+ content: content2,
417
+ fallbackPlacements: AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS,
418
+ matchReferenceWidth: !0,
419
+ onMouseEnter: handlePopoverMouseEnter,
420
+ onMouseLeave: handlePopoverMouseLeave,
421
+ open: expanded,
422
+ overflow: "auto",
423
+ placement: AUTOCOMPLETE_POPOVER_PLACEMENT,
424
+ portal: !0,
425
+ radius,
426
+ ref: resultsPopoverElementRef,
427
+ referenceElement: inputElementRef.current,
428
+ ...popover
429
+ }
430
+ ), [content2, expanded, filteredOptionsLen, handlePopoverMouseEnter, handlePopoverMouseLeave, popover, radius, renderPopover]);
406
431
  return /* @__PURE__ */ jsxs(StyledAutocomplete, { "data-ui": "Autocomplete", onBlur: handleRootBlur, onFocus: handleRootFocus, onKeyDown: handleRootKeyDown, ref: rootElementRef, children: [
407
432
  input,
408
433
  results
@@ -670,15 +695,15 @@ function DialogProvider(props) {
670
695
  position,
671
696
  zOffset
672
697
  } = props;
673
- let t0, t1;
674
- $[0] !== position || $[1] !== zOffset ? (t1 = {
698
+ let t0;
699
+ $[0] !== position || $[1] !== zOffset ? (t0 = {
675
700
  version: 0,
676
701
  position,
677
702
  zOffset
678
- }, $[0] = position, $[1] = zOffset, $[2] = t1) : t1 = $[2], t0 = t1;
703
+ }, $[0] = position, $[1] = zOffset, $[2] = t0) : t0 = $[2];
679
704
  const contextValue = t0;
680
- let t2;
681
- return $[3] !== children || $[4] !== contextValue ? (t2 = /* @__PURE__ */ jsx(DialogContext.Provider, { value: contextValue, children }), $[3] = children, $[4] = contextValue, $[5] = t2) : t2 = $[5], t2;
705
+ let t1;
706
+ return $[3] !== children || $[4] !== contextValue ? (t1 = /* @__PURE__ */ jsx(DialogContext.Provider, { value: contextValue, children }), $[3] = children, $[4] = contextValue, $[5] = t1) : t1 = $[5], t1;
682
707
  }
683
708
  DialogProvider.displayName = "DialogProvider";
684
709
  const MenuButton = forwardRef(function(props, forwardedRef) {
@@ -781,8 +806,8 @@ const MenuButton = forwardRef(function(props, forwardedRef) {
781
806
  shouldFocus
782
807
  }), $[28] = buttonElement, $[29] = handleBlur, $[30] = handleItemClick, $[31] = handleMenuClickOutside, $[32] = handleMenuEscape, $[33] = id, $[34] = menuProp, $[35] = shouldFocus, $[36] = t17) : t17 = $[36];
783
808
  const menu = t17;
784
- let t18, t19;
785
- $[37] !== buttonProp || $[38] !== handleMouseDown || $[39] !== id || $[40] !== open ? (t19 = buttonProp && cloneElement(buttonProp, {
809
+ let t18;
810
+ $[37] !== buttonProp || $[38] !== handleMouseDown || $[39] !== id || $[40] !== open ? (t18 = buttonProp && cloneElement(buttonProp, {
786
811
  "data-ui": "MenuButton",
787
812
  id,
788
813
  onClick: handleButtonClick,
@@ -792,14 +817,14 @@ const MenuButton = forwardRef(function(props, forwardedRef) {
792
817
  "aria-expanded": open,
793
818
  ref: setButtonElement,
794
819
  selected: buttonProp.props.selected ?? open
795
- }), $[37] = buttonProp, $[38] = handleMouseDown, $[39] = id, $[40] = open, $[41] = t19) : t19 = $[41], t18 = t19;
820
+ }), $[37] = buttonProp, $[38] = handleMouseDown, $[39] = id, $[40] = open, $[41] = t18) : t18 = $[41];
796
821
  const button = t18;
797
- let t20, t21;
798
- $[42] !== buttonElement ? (t20 = () => buttonElement, t21 = [buttonElement], $[42] = buttonElement, $[43] = t20, $[44] = t21) : (t20 = $[43], t21 = $[44]), useImperativeHandle(forwardedRef, t20, t21);
799
- let t22, t23;
800
- $[45] !== popover ? (t23 = popover || {}, $[45] = popover, $[46] = t23) : t23 = $[46];
801
- let t24;
802
- $[47] !== deprecated_boundaryElement || $[48] !== deprecated_placement || $[49] !== deprecated_popoverRadius || $[50] !== deprecated_popoverScheme || $[51] !== deprecated_portal || $[52] !== deprecated_preventOverflow || $[53] !== t23 ? (t24 = {
822
+ let t19, t20;
823
+ $[42] !== buttonElement ? (t19 = () => buttonElement, t20 = [buttonElement], $[42] = buttonElement, $[43] = t19, $[44] = t20) : (t19 = $[43], t20 = $[44]), useImperativeHandle(forwardedRef, t19, t20);
824
+ let t21;
825
+ $[45] !== popover ? (t21 = popover || {}, $[45] = popover, $[46] = t21) : t21 = $[46];
826
+ let t22;
827
+ $[47] !== deprecated_boundaryElement || $[48] !== deprecated_placement || $[49] !== deprecated_popoverRadius || $[50] !== deprecated_popoverScheme || $[51] !== deprecated_portal || $[52] !== deprecated_preventOverflow || $[53] !== t21 ? (t22 = {
803
828
  boundaryElement: deprecated_boundaryElement,
804
829
  overflow: "auto",
805
830
  placement: deprecated_placement,
@@ -807,13 +832,13 @@ const MenuButton = forwardRef(function(props, forwardedRef) {
807
832
  preventOverflow: deprecated_preventOverflow,
808
833
  radius: deprecated_popoverRadius,
809
834
  scheme: deprecated_popoverScheme,
810
- ...t23
811
- }, $[47] = deprecated_boundaryElement, $[48] = deprecated_placement, $[49] = deprecated_popoverRadius, $[50] = deprecated_popoverScheme, $[51] = deprecated_portal, $[52] = deprecated_preventOverflow, $[53] = t23, $[54] = t24) : t24 = $[54], t22 = t24;
835
+ ...t21
836
+ }, $[47] = deprecated_boundaryElement, $[48] = deprecated_placement, $[49] = deprecated_popoverRadius, $[50] = deprecated_popoverScheme, $[51] = deprecated_portal, $[52] = deprecated_preventOverflow, $[53] = t21, $[54] = t22) : t22 = $[54];
812
837
  const popoverProps = t22;
813
- let t25;
814
- $[55] !== button ? (t25 = button || /* @__PURE__ */ jsx(Fragment$1, {}), $[55] = button, $[56] = t25) : t25 = $[56];
815
- let t26;
816
- return $[57] !== menu || $[58] !== open || $[59] !== popoverProps || $[60] !== t25 ? (t26 = /* @__PURE__ */ jsx(Popover, { "data-ui": "MenuButton__popover", ...popoverProps, content: menu, open, children: t25 }), $[57] = menu, $[58] = open, $[59] = popoverProps, $[60] = t25, $[61] = t26) : t26 = $[61], t26;
838
+ let t23;
839
+ $[55] !== button ? (t23 = button || /* @__PURE__ */ jsx(Fragment$1, {}), $[55] = button, $[56] = t23) : t23 = $[56];
840
+ let t24;
841
+ return $[57] !== menu || $[58] !== open || $[59] !== popoverProps || $[60] !== t23 ? (t24 = /* @__PURE__ */ jsx(Popover, { "data-ui": "MenuButton__popover", ...popoverProps, content: menu, open, children: t23 }), $[57] = menu, $[58] = open, $[59] = popoverProps, $[60] = t23, $[61] = t24) : t24 = $[61], t24;
817
842
  });
818
843
  MenuButton.displayName = "ForwardRef(MenuButton)";
819
844
  function _temp$2(v) {
@@ -1159,8 +1184,8 @@ function ToastProvider(props) {
1159
1184
  let t1;
1160
1185
  $[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = [], $[0] = t1) : t1 = $[0];
1161
1186
  const [state, setState] = useState(t1), mounted = useMounted();
1162
- let t2, t3;
1163
- $[1] === Symbol.for("react.memo_cache_sentinel") ? (t3 = {
1187
+ let t2;
1188
+ $[1] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {
1164
1189
  version: 0,
1165
1190
  push: (params) => {
1166
1191
  const id = params.id || generateToastId(), duration = params.duration || 5e3;
@@ -1181,15 +1206,15 @@ function ToastProvider(props) {
1181
1206
  });
1182
1207
  }), id;
1183
1208
  }
1184
- }, $[1] = t3) : t3 = $[1], t2 = t3;
1209
+ }, $[1] = t2) : t2 = $[1];
1185
1210
  const value = t2;
1211
+ let t3;
1212
+ $[2] !== gap || $[3] !== mounted || $[4] !== padding || $[5] !== paddingX || $[6] !== paddingY || $[7] !== state || $[8] !== zOffset ? (t3 = mounted && /* @__PURE__ */ jsx(LayerProvider, { zOffset, children: /* @__PURE__ */ jsx(ToastLayer, { padding, paddingX, paddingY, gap, children: /* @__PURE__ */ jsx(AnimatePresence, { initial: !1, mode: "popLayout", children: state.map(_temp) }) }) }), $[2] = gap, $[3] = mounted, $[4] = padding, $[5] = paddingX, $[6] = paddingY, $[7] = state, $[8] = zOffset, $[9] = t3) : t3 = $[9];
1186
1213
  let t4;
1187
- $[2] !== gap || $[3] !== mounted || $[4] !== padding || $[5] !== paddingX || $[6] !== paddingY || $[7] !== state || $[8] !== zOffset ? (t4 = mounted && /* @__PURE__ */ jsx(LayerProvider, { zOffset, children: /* @__PURE__ */ jsx(ToastLayer, { padding, paddingX, paddingY, gap, children: /* @__PURE__ */ jsx(AnimatePresence, { initial: !1, mode: "popLayout", children: state.map(_temp) }) }) }), $[2] = gap, $[3] = mounted, $[4] = padding, $[5] = paddingX, $[6] = paddingY, $[7] = state, $[8] = zOffset, $[9] = t4) : t4 = $[9];
1188
- let t5;
1189
- return $[10] !== children || $[11] !== t4 ? (t5 = /* @__PURE__ */ jsxs(ToastContext.Provider, { value, children: [
1214
+ return $[10] !== children || $[11] !== t3 ? (t4 = /* @__PURE__ */ jsxs(ToastContext.Provider, { value, children: [
1190
1215
  children,
1191
- t4
1192
- ] }), $[10] = children, $[11] = t4, $[12] = t5) : t5 = $[12], t5;
1216
+ t3
1217
+ ] }), $[10] = children, $[11] = t3, $[12] = t4) : t4 = $[12], t4;
1193
1218
  }
1194
1219
  function _temp(t0) {
1195
1220
  const {
@@ -1273,27 +1298,27 @@ const TreeContext = createGlobalScopedContext("@sanity/ui/context/tree", null),
1273
1298
  ...restProps
1274
1299
  } = props, $[0] = props, $[1] = children, $[2] = onFocus, $[3] = restProps, $[4] = t0) : (children = $[1], onFocus = $[2], restProps = $[3], t0 = $[4]);
1275
1300
  const space = t0 === void 0 ? 1 : t0, ref = useRef(null), [focusedElement, setFocusedElement] = useState(null), focusedElementRef = useRef(focusedElement);
1276
- let t1, t2;
1277
- $[5] === Symbol.for("react.memo_cache_sentinel") ? (t2 = [], $[5] = t2) : t2 = $[5], t1 = t2;
1301
+ let t1;
1302
+ $[5] === Symbol.for("react.memo_cache_sentinel") ? (t1 = [], $[5] = t1) : t1 = $[5];
1278
1303
  const path = t1;
1304
+ let t2;
1305
+ $[6] === Symbol.for("react.memo_cache_sentinel") ? (t2 = [], $[6] = t2) : t2 = $[6];
1306
+ const [itemElements, setItemElements] = useState(t2);
1279
1307
  let t3;
1280
- $[6] === Symbol.for("react.memo_cache_sentinel") ? (t3 = [], $[6] = t3) : t3 = $[6];
1281
- const [itemElements, setItemElements] = useState(t3);
1308
+ $[7] === Symbol.for("react.memo_cache_sentinel") ? (t3 = {}, $[7] = t3) : t3 = $[7];
1309
+ const [state, setState] = useState(t3), stateRef = useRef(state);
1282
1310
  let t4;
1283
- $[7] === Symbol.for("react.memo_cache_sentinel") ? (t4 = {}, $[7] = t4) : t4 = $[7];
1284
- const [state, setState] = useState(t4), stateRef = useRef(state);
1285
- let t5;
1286
- $[8] === Symbol.for("react.memo_cache_sentinel") ? (t5 = () => ref.current, $[8] = t5) : t5 = $[8], useImperativeHandle(forwardedRef, t5);
1287
- let t6, t7;
1288
- $[9] !== focusedElement ? (t6 = () => {
1311
+ $[8] === Symbol.for("react.memo_cache_sentinel") ? (t4 = () => ref.current, $[8] = t4) : t4 = $[8], useImperativeHandle(forwardedRef, t4);
1312
+ let t5, t6;
1313
+ $[9] !== focusedElement ? (t5 = () => {
1289
1314
  focusedElementRef.current = focusedElement;
1290
- }, t7 = [focusedElement], $[9] = focusedElement, $[10] = t6, $[11] = t7) : (t6 = $[10], t7 = $[11]), useEffect(t6, t7);
1291
- let t8, t9;
1292
- $[12] !== state ? (t8 = () => {
1315
+ }, t6 = [focusedElement], $[9] = focusedElement, $[10] = t5, $[11] = t6) : (t5 = $[10], t6 = $[11]), useEffect(t5, t6);
1316
+ let t7, t8;
1317
+ $[12] !== state ? (t7 = () => {
1293
1318
  stateRef.current = state;
1294
- }, t9 = [state], $[12] = state, $[13] = t8, $[14] = t9) : (t8 = $[13], t9 = $[14]), useEffect(t8, t9);
1295
- let t10;
1296
- $[15] === Symbol.for("react.memo_cache_sentinel") ? (t10 = (element, path_0, expanded, selected) => (setState((s) => ({
1319
+ }, t8 = [state], $[12] = state, $[13] = t7, $[14] = t8) : (t7 = $[13], t8 = $[14]), useEffect(t7, t8);
1320
+ let t9;
1321
+ $[15] === Symbol.for("react.memo_cache_sentinel") ? (t9 = (element, path_0, expanded, selected) => (setState((s) => ({
1297
1322
  ...s,
1298
1323
  [path_0]: {
1299
1324
  element,
@@ -1306,10 +1331,10 @@ const TreeContext = createGlobalScopedContext("@sanity/ui/context/tree", null),
1306
1331
  };
1307
1332
  return delete newState[path_0], newState;
1308
1333
  });
1309
- }), $[15] = t10) : t10 = $[15];
1310
- const registerItem = t10;
1311
- let t11;
1312
- $[16] === Symbol.for("react.memo_cache_sentinel") ? (t11 = (path_1, expanded_0) => {
1334
+ }), $[15] = t9) : t9 = $[15];
1335
+ const registerItem = t9;
1336
+ let t10;
1337
+ $[16] === Symbol.for("react.memo_cache_sentinel") ? (t10 = (path_1, expanded_0) => {
1313
1338
  setState((s_1) => {
1314
1339
  const itemState = s_1[path_1];
1315
1340
  return itemState ? {
@@ -1320,14 +1345,12 @@ const TreeContext = createGlobalScopedContext("@sanity/ui/context/tree", null),
1320
1345
  }
1321
1346
  } : s_1;
1322
1347
  });
1323
- }, $[16] = t11) : t11 = $[16];
1324
- const setExpanded = t11;
1348
+ }, $[16] = t10) : t10 = $[16];
1349
+ const setExpanded = t10, t11 = focusedElement || itemElements[0] || null;
1325
1350
  let t12;
1326
- const t13 = focusedElement || itemElements[0] || null;
1327
- let t14;
1328
- $[17] !== space || $[18] !== state || $[19] !== t13 ? (t14 = {
1351
+ $[17] !== space || $[18] !== state || $[19] !== t11 ? (t12 = {
1329
1352
  version: 0,
1330
- focusedElement: t13,
1353
+ focusedElement: t11,
1331
1354
  level: 0,
1332
1355
  path,
1333
1356
  registerItem,
@@ -1335,10 +1358,10 @@ const TreeContext = createGlobalScopedContext("@sanity/ui/context/tree", null),
1335
1358
  setFocusedElement,
1336
1359
  space,
1337
1360
  state
1338
- }, $[17] = space, $[18] = state, $[19] = t13, $[20] = t14) : t14 = $[20], t12 = t14;
1361
+ }, $[17] = space, $[18] = state, $[19] = t11, $[20] = t12) : t12 = $[20];
1339
1362
  const contextValue = t12;
1340
- let t15;
1341
- $[21] !== itemElements ? (t15 = (event) => {
1363
+ let t13;
1364
+ $[21] !== itemElements ? (t13 = (event) => {
1342
1365
  if (focusedElementRef.current) {
1343
1366
  if (event.key === "ArrowDown") {
1344
1367
  event.preventDefault();
@@ -1397,26 +1420,26 @@ const TreeContext = createGlobalScopedContext("@sanity/ui/context/tree", null),
1397
1420
  return;
1398
1421
  }
1399
1422
  }
1400
- }, $[21] = itemElements, $[22] = t15) : t15 = $[22];
1401
- const handleKeyDown = t15;
1402
- let t16;
1403
- $[23] !== onFocus ? (t16 = (event_0) => {
1423
+ }, $[21] = itemElements, $[22] = t13) : t13 = $[22];
1424
+ const handleKeyDown = t13;
1425
+ let t14;
1426
+ $[23] !== onFocus ? (t14 = (event_0) => {
1404
1427
  setFocusedElement(event_0.target), onFocus?.(event_0);
1405
- }, $[23] = onFocus, $[24] = t16) : t16 = $[24];
1406
- const handleFocus = t16;
1407
- let t17;
1408
- $[25] === Symbol.for("react.memo_cache_sentinel") ? (t17 = () => {
1428
+ }, $[23] = onFocus, $[24] = t14) : t14 = $[24];
1429
+ const handleFocus = t14;
1430
+ let t15;
1431
+ $[25] === Symbol.for("react.memo_cache_sentinel") ? (t15 = () => {
1409
1432
  if (!ref.current)
1410
1433
  return;
1411
1434
  const _itemElements = Array.from(ref.current.querySelectorAll('[data-ui="TreeItem"]'));
1412
1435
  setItemElements(_itemElements);
1413
- }, $[25] = t17) : t17 = $[25];
1436
+ }, $[25] = t15) : t15 = $[25];
1437
+ let t16;
1438
+ $[26] !== children ? (t16 = [children], $[26] = children, $[27] = t16) : t16 = $[27], useEffect(t15, t16);
1439
+ let t17;
1440
+ $[28] !== children || $[29] !== handleFocus || $[30] !== handleKeyDown || $[31] !== restProps || $[32] !== space ? (t17 = /* @__PURE__ */ jsx(Stack, { as: "ul", "data-ui": "Tree", ...restProps, onFocus: handleFocus, onKeyDown: handleKeyDown, ref, role: "tree", space, children }), $[28] = children, $[29] = handleFocus, $[30] = handleKeyDown, $[31] = restProps, $[32] = space, $[33] = t17) : t17 = $[33];
1414
1441
  let t18;
1415
- $[26] !== children ? (t18 = [children], $[26] = children, $[27] = t18) : t18 = $[27], useEffect(t17, t18);
1416
- let t19;
1417
- $[28] !== children || $[29] !== handleFocus || $[30] !== handleKeyDown || $[31] !== restProps || $[32] !== space ? (t19 = /* @__PURE__ */ jsx(Stack, { as: "ul", "data-ui": "Tree", ...restProps, onFocus: handleFocus, onKeyDown: handleKeyDown, ref, role: "tree", space, children }), $[28] = children, $[29] = handleFocus, $[30] = handleKeyDown, $[31] = restProps, $[32] = space, $[33] = t19) : t19 = $[33];
1418
- let t20;
1419
- return $[34] !== contextValue || $[35] !== t19 ? (t20 = /* @__PURE__ */ jsx(TreeContext.Provider, { value: contextValue, children: t19 }), $[34] = contextValue, $[35] = t19, $[36] = t20) : t20 = $[36], t20;
1442
+ return $[34] !== contextValue || $[35] !== t17 ? (t18 = /* @__PURE__ */ jsx(TreeContext.Provider, { value: contextValue, children: t17 }), $[34] = contextValue, $[35] = t17, $[36] = t18) : t18 = $[36], t18;
1420
1443
  }));
1421
1444
  Tree.displayName = "Memo(ForwardRef(Tree))";
1422
1445
  function treeItemRootStyle() {