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