@sanity/ui 1.3.2 → 1.4.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
@@ -3076,9 +3076,9 @@ function getGlobalScope() {
3076
3076
  throw new Error("@sanity/ui: could not locate global scope");
3077
3077
  }
3078
3078
  const globalScope = getGlobalScope();
3079
- const key$7 = Symbol.for("@sanity/ui/context/theme");
3080
- globalScope[key$7] = globalScope[key$7] || react.createContext(null);
3081
- const ThemeContext = globalScope[key$7];
3079
+ const key$8 = Symbol.for("@sanity/ui/context/theme");
3080
+ globalScope[key$8] = globalScope[key$8] || react.createContext(null);
3081
+ const ThemeContext = globalScope[key$8];
3082
3082
  function ThemeProvider(props) {
3083
3083
  const parentTheme = react.useContext(ThemeContext);
3084
3084
  const {
@@ -3922,7 +3922,7 @@ function textBaseStyle(props) {
3922
3922
  return styled.css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n color: var(--card-fg-color);\n\n ", "\n\n ", "\n\n & code {\n font-family: ", ";\n border-radius: 1px;\n background-color: var(--card-code-bg-color);\n color: var(--card-code-fg-color);\n }\n\n & a {\n text-decoration: none;\n border-radius: 1px;\n color: var(--card-link-color);\n outline: none;\n\n @media (hover: hover) {\n &:hover {\n text-decoration: underline;\n }\n }\n\n &:focus {\n box-shadow: 0 0 0 1px var(--card-bg-color), 0 0 0 3px var(--card-focus-ring-color);\n }\n\n &:focus:not(:focus-visible) {\n box-shadow: none;\n }\n }\n\n & strong {\n font-weight: ", ";\n }\n\n & svg {\n /* Certain popular CSS libraries changes the defaults for SVG display */\n /* Make sure SVGs are rendered as inline elements */\n display: inline;\n }\n\n & [data-sanity-icon] {\n vertical-align: baseline;\n }\n "])), $accent && styled.css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n color: var(--card-accent-fg-color);\n "]))), $muted && styled.css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n color: var(--card-muted-fg-color);\n "]))), theme.sanity.fonts.code.family, weights.bold);
3923
3923
  }
3924
3924
  const Root$E = styled__default.default.div(responsiveTextFont, responsiveTextAlignStyle, textBaseStyle);
3925
- const SpanWithTextOverflow$2 = styled__default.default.span(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n display: block;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n"])));
3925
+ const SpanWithTextOverflow$2 = styled__default.default.span(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n display: block;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n overflow: clip;\n"])));
3926
3926
  const Text = react.forwardRef(function Text2(props, ref) {
3927
3927
  const {
3928
3928
  accent = false,
@@ -4399,7 +4399,7 @@ function labelBaseStyle(props) {
4399
4399
  return styled.css(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n text-transform: uppercase;\n\n ", "\n\n ", "\n\n & code {\n font-family: ", ";\n border-radius: 1px;\n }\n\n & a {\n text-decoration: none;\n border-radius: 1px;\n }\n\n & svg {\n /* Certain popular CSS libraries changes the defaults for SVG display */\n /* Make sure SVGs are rendered as inline elements */\n display: inline;\n }\n\n & [data-sanity-icon] {\n vertical-align: baseline;\n }\n "])), $accent && styled.css(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n color: var(--card-accent-fg-color);\n "]))), $muted && styled.css(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n color: var(--card-muted-fg-color);\n "]))), fonts.code.family);
4400
4400
  }
4401
4401
  const Root$z = styled__default.default.div(responsiveLabelFont, responsiveTextAlignStyle, labelBaseStyle);
4402
- const SpanWithTextOverflow$1 = styled__default.default.span(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n display: block;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n"])));
4402
+ const SpanWithTextOverflow$1 = styled__default.default.span(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n display: block;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n overflow: clip;\n"])));
4403
4403
  const Label = react.forwardRef(function Label2(props, ref) {
4404
4404
  const {
4405
4405
  accent,
@@ -5061,7 +5061,7 @@ function headingBaseStyle(props) {
5061
5061
  return styled.css(_templateObject24 || (_templateObject24 = _taggedTemplateLiteral(["\n ", "\n\n ", "\n\n & code {\n font-family: ", ";\n border-radius: 1px;\n }\n\n & a {\n text-decoration: none;\n border-radius: 1px;\n color: var(--card-link-color);\n outline: none;\n\n @media (hover: hover) {\n &:hover {\n text-decoration: underline;\n }\n }\n\n &:focus {\n box-shadow: 0 0 0 1px var(--card-bg-color), 0 0 0 3px var(--card-focus-ring-color);\n }\n\n &:focus:not(:focus-visible) {\n box-shadow: none;\n }\n }\n\n & svg {\n /* Certain popular CSS libraries changes the defaults for SVG display */\n /* Make sure SVGs are rendered as inline elements */\n display: inline;\n }\n\n & [data-sanity-icon] {\n vertical-align: baseline;\n }\n "])), $accent && styled.css(_templateObject25 || (_templateObject25 = _taggedTemplateLiteral(["\n color: var(--card-accent-fg-color);\n "]))), $muted && styled.css(_templateObject26 || (_templateObject26 = _taggedTemplateLiteral(["\n color: var(--card-muted-fg-color);\n "]))), theme.sanity.fonts.code.family);
5062
5062
  }
5063
5063
  const Root$p = styled__default.default.div(headingBaseStyle, responsiveTextAlignStyle, responsiveHeadingFont);
5064
- const SpanWithTextOverflow = styled__default.default.span(_templateObject27 || (_templateObject27 = _taggedTemplateLiteral(["\n display: block;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n"])));
5064
+ const SpanWithTextOverflow = styled__default.default.span(_templateObject27 || (_templateObject27 = _taggedTemplateLiteral(["\n display: block;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n overflow: clip;\n"])));
5065
5065
  const Heading = react.forwardRef(function Heading2(props, ref) {
5066
5066
  const {
5067
5067
  accent = false,
@@ -5168,9 +5168,9 @@ const KBD = react.forwardRef(function KBD2(props, ref) {
5168
5168
  })
5169
5169
  });
5170
5170
  });
5171
- const key$6 = Symbol.for("@sanity/ui/context/boundaryElement");
5172
- globalScope[key$6] = globalScope[key$6] || react.createContext(null);
5173
- const BoundaryElementContext = globalScope[key$6];
5171
+ const key$7 = Symbol.for("@sanity/ui/context/boundaryElement");
5172
+ globalScope[key$7] = globalScope[key$7] || react.createContext(null);
5173
+ const BoundaryElementContext = globalScope[key$7];
5174
5174
  function BoundaryElementProvider(props) {
5175
5175
  const {
5176
5176
  children,
@@ -5288,9 +5288,9 @@ function getLayerContext(contextValue) {
5288
5288
  }
5289
5289
  throw new Error("could not get layer context");
5290
5290
  }
5291
- const key$5 = Symbol.for("@sanity/ui/context/layer");
5292
- globalScope[key$5] = globalScope[key$5] || react.createContext(null);
5293
- const LayerContext = globalScope[key$5];
5291
+ const key$6 = Symbol.for("@sanity/ui/context/layer");
5292
+ globalScope[key$6] = globalScope[key$6] || react.createContext(null);
5293
+ const LayerContext = globalScope[key$6];
5294
5294
  function useLayer() {
5295
5295
  const value = react.useContext(LayerContext);
5296
5296
  if (!value) {
@@ -5527,7 +5527,7 @@ const Layer = react.forwardRef(function Layer2(props, ref) {
5527
5527
  })
5528
5528
  });
5529
5529
  });
5530
- const key$4 = Symbol.for("@sanity/ui/context/portal");
5530
+ const key$5 = Symbol.for("@sanity/ui/context/portal");
5531
5531
  const elementKey = Symbol.for("@sanity/ui/context/portal/element");
5532
5532
  globalScope[elementKey] = null;
5533
5533
  const defaultContextValue = {
@@ -5546,8 +5546,8 @@ const defaultContextValue = {
5546
5546
  return globalScope[elementKey];
5547
5547
  }
5548
5548
  };
5549
- globalScope[key$4] = globalScope[key$4] || react.createContext(defaultContextValue);
5550
- const PortalContext = globalScope[key$4];
5549
+ globalScope[key$5] = globalScope[key$5] || react.createContext(defaultContextValue);
5550
+ const PortalContext = globalScope[key$5];
5551
5551
  function usePortal() {
5552
5552
  const value = react.useContext(PortalContext);
5553
5553
  if (!value) {
@@ -5611,7 +5611,7 @@ function PortalProvider(props) {
5611
5611
  children
5612
5612
  });
5613
5613
  }
5614
- const Root$l = styled__default.default.div(_templateObject29 || (_templateObject29 = _taggedTemplateLiteral(["\n display: block;\n width: 0;\n height: 0;\n position: absolute;\n overflow: hidden;\n"])));
5614
+ const Root$l = styled__default.default.div(_templateObject29 || (_templateObject29 = _taggedTemplateLiteral(["\n display: block;\n width: 0;\n height: 0;\n position: absolute;\n overflow: hidden;\n overflow: clip;\n"])));
5615
5615
  const SrOnly = react.forwardRef(function SrOnly2(props, ref) {
5616
5616
  const {
5617
5617
  as,
@@ -5927,6 +5927,17 @@ const PopoverCard = react.memo(react.forwardRef(function PopoverCard2(props, ref
5927
5927
  });
5928
5928
  }));
5929
5929
  PopoverCard.displayName = "PopoverCard";
5930
+ const key$4 = Symbol.for("@sanity/ui/context/popover");
5931
+ globalScope[key$4] = globalScope[key$4] || react.createContext(null);
5932
+ const PopoverContext = globalScope[key$4];
5933
+ const useOnForcedUpdate = eventHandler => {
5934
+ const contextValue = react.useContext(PopoverContext);
5935
+ react.useEffect(() => {
5936
+ if ((contextValue == null ? void 0 : contextValue.lastUpdateId) !== null) {
5937
+ eventHandler == null ? void 0 : eventHandler();
5938
+ }
5939
+ }, [contextValue == null ? void 0 : contextValue.lastUpdateId]);
5940
+ };
5930
5941
  const Popover = react.memo(react.forwardRef(function Popover2(props, ref) {
5931
5942
  var _a, _b, _c, _d, _e;
5932
5943
  const theme = useTheme();
@@ -6033,9 +6044,13 @@ const Popover = react.memo(react.forwardRef(function Popover2(props, ref) {
6033
6044
  placement,
6034
6045
  reference: referenceRef,
6035
6046
  floating: floatingRef,
6047
+ update: floatingUpdate,
6036
6048
  middlewareData,
6037
6049
  strategy
6038
6050
  } = reactDom$1.useFloating(floatingProps);
6051
+ const handleForcedUpdate = react.useCallback(() => {
6052
+ floatingUpdate();
6053
+ }, [floatingUpdate]);
6039
6054
  const referenceHidden = (_c = middlewareData.hide) == null ? void 0 : _c.referenceHidden;
6040
6055
  const arrowX = (_d = middlewareData.arrow) == null ? void 0 : _d.x;
6041
6056
  const arrowY = (_e = middlewareData.arrow) == null ? void 0 : _e.y;
@@ -6064,6 +6079,7 @@ const Popover = react.memo(react.forwardRef(function Popover2(props, ref) {
6064
6079
  react.useEffect(() => {
6065
6080
  referenceRef(referenceElement || null);
6066
6081
  }, [referenceRef, referenceElement]);
6082
+ useOnForcedUpdate(handleForcedUpdate);
6067
6083
  if (disabled) {
6068
6084
  return childProp || /* @__PURE__ */jsxRuntime.jsx(jsxRuntime.Fragment, {});
6069
6085
  }
@@ -6103,6 +6119,35 @@ const Popover = react.memo(react.forwardRef(function Popover2(props, ref) {
6103
6119
  });
6104
6120
  }));
6105
6121
  Popover.displayName = "Popover";
6122
+ const PopoverProvider = _ref22 => {
6123
+ let {
6124
+ children
6125
+ } = _ref22;
6126
+ const [lastUpdateId, setUpdateId] = react.useState(null);
6127
+ const forceUpdate = react.useCallback(() => {
6128
+ const newId = Math.random().toString(36).substr(2, 9);
6129
+ setUpdateId(newId);
6130
+ }, []);
6131
+ const value = react.useMemo(() => ({
6132
+ version: 0,
6133
+ lastUpdateId,
6134
+ forceUpdate
6135
+ }), [lastUpdateId, forceUpdate]);
6136
+ return /* @__PURE__ */jsxRuntime.jsx(PopoverContext.Provider, {
6137
+ value,
6138
+ children
6139
+ });
6140
+ };
6141
+ function usePopover() {
6142
+ const value = react.useContext(PopoverContext);
6143
+ if (!value) {
6144
+ throw new Error("usePopover(): missing context value");
6145
+ }
6146
+ if (!isRecord(value) || value.version !== 0) {
6147
+ throw new Error("usePopover(): the context value is not compatible");
6148
+ }
6149
+ return value;
6150
+ }
6106
6151
  function radioBaseStyle() {
6107
6152
  return styled.css(_templateObject36 || (_templateObject36 = _taggedTemplateLiteral(["\n position: relative;\n\n &:not([hidden]) {\n display: inline-block;\n }\n\n &[data-read-only] {\n outline: 1px solid red;\n }\n "])));
6108
6153
  }
@@ -6934,10 +6979,10 @@ const InnerAutocomplete = react.forwardRef(function InnerAutocomplete2(props, re
6934
6979
  query,
6935
6980
  value
6936
6981
  } = state;
6937
- const defaultRenderOption = react.useCallback(_ref22 => {
6982
+ const defaultRenderOption = react.useCallback(_ref23 => {
6938
6983
  let {
6939
6984
  value: value2
6940
- } = _ref22;
6985
+ } = _ref23;
6941
6986
  return /* @__PURE__ */jsxRuntime.jsx(Card, {
6942
6987
  "data-as": "button",
6943
6988
  padding: paddingProp,
@@ -7384,10 +7429,10 @@ const Breadcrumbs = react.forwardRef(function Breadcrumbs2(props, ref) {
7384
7429
  }, itemIndex))
7385
7430
  });
7386
7431
  });
7387
- function dialogStyle(_ref23) {
7432
+ function dialogStyle(_ref24) {
7388
7433
  let {
7389
7434
  theme
7390
- } = _ref23;
7435
+ } = _ref24;
7391
7436
  const color = theme.sanity.color.base;
7392
7437
  return {
7393
7438
  "&:not([hidden])": {
@@ -7430,7 +7475,7 @@ function isTargetWithinScope(boundaryElement, portalElement, target) {
7430
7475
  }
7431
7476
  const Root$7 = styled__default.default(Layer)(responsivePaddingStyle, dialogStyle, responsiveDialogPositionStyle);
7432
7477
  const DialogContainer = styled__default.default(Container)(_templateObject66 || (_templateObject66 = _taggedTemplateLiteral(["\n &:not([hidden]) {\n display: flex;\n }\n width: 100%;\n height: 100%;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n"])));
7433
- const DialogCardRoot = styled__default.default(Card)(_templateObject67 || (_templateObject67 = _taggedTemplateLiteral(["\n &:not([hidden]) {\n display: flex;\n }\n width: 100%;\n min-height: 0;\n max-height: 100%;\n overflow: hidden;\n"])));
7478
+ const DialogCardRoot = styled__default.default(Card)(_templateObject67 || (_templateObject67 = _taggedTemplateLiteral(["\n &:not([hidden]) {\n display: flex;\n }\n width: 100%;\n min-height: 0;\n max-height: 100%;\n overflow: hidden;\n overflow: clip;\n"])));
7434
7479
  const DialogLayout = styled__default.default(Flex)(_templateObject68 || (_templateObject68 = _taggedTemplateLiteral(["\n flex: 1;\n min-height: 0;\n width: 100%;\n"])));
7435
7480
  const DialogHeader = styled__default.default(Card)(_templateObject69 || (_templateObject69 = _taggedTemplateLiteral(["\n position: relative;\n z-index: 2;\n\n &:after {\n content: '';\n display: block;\n position: absolute;\n left: 0;\n right: 0;\n bottom: -1px;\n border-bottom: 1px solid var(--card-hairline-soft-color);\n }\n"])));
7436
7481
  const DialogContent = styled__default.default(Box)(_templateObject70 || (_templateObject70 = _taggedTemplateLiteral(["\n position: relative;\n z-index: 1;\n overflow: auto;\n outline: none;\n"])));
@@ -8407,15 +8452,15 @@ const MenuItem = react.forwardRef(function MenuItem2(props, forwardedRef) {
8407
8452
  });
8408
8453
  const keyframe = styled.keyframes(_templateObject78 || (_templateObject78 = _taggedTemplateLiteral(["\n 0% {\n background-position: 100%;\n }\n 100% {\n background-position: -100%;\n }\n"])));
8409
8454
  const animation = styled.css(_templateObject79 || (_templateObject79 = _taggedTemplateLiteral(["\n background-image: linear-gradient(\n to right,\n var(--card-skeleton-color-from),\n var(--card-skeleton-color-to),\n var(--card-skeleton-color-from),\n var(--card-skeleton-color-from),\n var(--card-skeleton-color-from)\n );\n background-position: 100%;\n background-size: 200% 100%;\n background-attachment: fixed;\n animation-name: ", ";\n animation-timing-function: ease-in-out;\n animation-iteration-count: infinite;\n animation-duration: 2000ms;\n"])), keyframe);
8410
- const skeletonStyle = styled.css(_templateObject80 || (_templateObject80 = _taggedTemplateLiteral(["\n opacity: ", ";\n transition: opacity 200ms ease-in;\n\n @media screen and (prefers-reduced-motion: no-preference) {\n ", "\n }\n\n @media screen and (prefers-reduced-motion: reduce) {\n background-color: var(--card-skeleton-color-from);\n }\n"])), _ref24 => {
8455
+ const skeletonStyle = styled.css(_templateObject80 || (_templateObject80 = _taggedTemplateLiteral(["\n opacity: ", ";\n transition: opacity 200ms ease-in;\n\n @media screen and (prefers-reduced-motion: no-preference) {\n ", "\n }\n\n @media screen and (prefers-reduced-motion: reduce) {\n background-color: var(--card-skeleton-color-from);\n }\n"])), _ref25 => {
8411
8456
  let {
8412
8457
  $visible
8413
- } = _ref24;
8458
+ } = _ref25;
8414
8459
  return $visible ? 1 : 0;
8415
- }, _ref25 => {
8460
+ }, _ref26 => {
8416
8461
  let {
8417
8462
  $animated
8418
- } = _ref25;
8463
+ } = _ref26;
8419
8464
  return $animated ? animation : styled.css(_templateObject81 || (_templateObject81 = _taggedTemplateLiteral(["\n background-color: var(--card-skeleton-color-from);\n "])));
8420
8465
  });
8421
8466
  const Root$4 = styled__default.default(Box)(responsiveRadiusStyle, skeletonStyle);
@@ -8446,12 +8491,12 @@ const Skeleton = react.forwardRef(function Skeleton2(props, ref) {
8446
8491
  ref
8447
8492
  });
8448
8493
  });
8449
- const Root$3 = styled__default.default(Skeleton)(_ref26 => {
8494
+ const Root$3 = styled__default.default(Skeleton)(_ref27 => {
8450
8495
  let {
8451
8496
  $size,
8452
8497
  $style,
8453
8498
  theme
8454
- } = _ref26;
8499
+ } = _ref27;
8455
8500
  const {
8456
8501
  media
8457
8502
  } = theme.sanity;
@@ -8772,12 +8817,12 @@ function ToastProvider(props) {
8772
8817
  paddingY,
8773
8818
  children: /* @__PURE__ */jsxRuntime.jsx(framerMotion.AnimatePresence, {
8774
8819
  initial: false,
8775
- children: state.map(_ref27 => {
8820
+ children: state.map(_ref28 => {
8776
8821
  let {
8777
8822
  dismiss,
8778
8823
  id,
8779
8824
  params
8780
- } = _ref27;
8825
+ } = _ref28;
8781
8826
  return /* @__PURE__ */jsxRuntime.jsx(framerMotion.motion.div, {
8782
8827
  animate: {
8783
8828
  opacity: 1,
@@ -9293,6 +9338,7 @@ exports.MenuDivider = MenuDivider;
9293
9338
  exports.MenuGroup = MenuGroup;
9294
9339
  exports.MenuItem = MenuItem;
9295
9340
  exports.Popover = Popover;
9341
+ exports.PopoverProvider = PopoverProvider;
9296
9342
  exports.Portal = Portal;
9297
9343
  exports.PortalProvider = PortalProvider;
9298
9344
  exports.Radio = Radio;
@@ -9366,6 +9412,7 @@ exports.useForwardedRef = useForwardedRef;
9366
9412
  exports.useGlobalKeyDown = useGlobalKeyDown;
9367
9413
  exports.useLayer = useLayer;
9368
9414
  exports.useMediaIndex = useMediaIndex;
9415
+ exports.usePopover = usePopover;
9369
9416
  exports.usePortal = usePortal;
9370
9417
  exports.usePrefersDark = usePrefersDark;
9371
9418
  exports.usePrefersReducedMotion = usePrefersReducedMotion;