@sanity/ui 3.0.0-static.31 → 3.0.0-static.32

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.
Files changed (35) hide show
  1. package/dist/_chunks-cjs/_visual-editing.cjs +49 -47
  2. package/dist/_chunks-cjs/_visual-editing.cjs.map +1 -1
  3. package/dist/_chunks-es/_visual-editing.js +49 -47
  4. package/dist/_chunks-es/_visual-editing.js.map +1 -1
  5. package/dist/css/index.cjs +1 -3
  6. package/dist/css/index.cjs.map +1 -1
  7. package/dist/css/index.css +1 -1
  8. package/dist/css/index.d.cts +1 -1
  9. package/dist/css/index.d.ts +1 -1
  10. package/dist/css/index.js +1 -3
  11. package/dist/css/index.js.map +1 -1
  12. package/dist/index.cjs +80 -79
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +1 -1
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.js +82 -81
  17. package/dist/index.js.map +1 -1
  18. package/package.json +1 -1
  19. package/src/core/{primitives/root/Root.tsx → Root.tsx} +5 -3
  20. package/src/core/{primitives/root/RootProvider.tsx → RootProvider.tsx} +5 -5
  21. package/src/core/__workshop__/boundary.tsx +28 -0
  22. package/src/core/__workshop__/index.ts +14 -0
  23. package/src/core/index.ts +4 -2
  24. package/src/core/primitives/card/card.tsx +4 -3
  25. package/src/core/primitives/card/useCard.ts +8 -2
  26. package/src/core/primitives/grid/types.ts +1 -1
  27. package/src/core/primitives/popover/popover.tsx +1 -4
  28. package/src/core/primitives/tooltip/tooltip.tsx +1 -4
  29. package/src/core/utils/portal/portal.tsx +1 -5
  30. package/src/css/components/toast/toast.css.ts +2 -2
  31. package/src/css/primitives/root/root.css.ts +5 -1
  32. package/src/css/primitives/root/root.ts +1 -1
  33. package/src/css/props/gridColumnStart/types.ts +1 -1
  34. package/src/core/primitives/root/__workshop__/boundary.tsx +0 -5
  35. package/src/core/primitives/root/__workshop__/index.ts +0 -8
@@ -540,7 +540,10 @@ function getElementRef(element) {
540
540
  return mayWarn ? element.ref : (getter = Object.getOwnPropertyDescriptor(element, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning, mayWarn ? element.props.ref : element.props.ref || element.ref);
541
541
  }
542
542
  function useCard() {
543
- return react.useContext(CardContext);
543
+ const card = react.useContext(CardContext);
544
+ if (!card)
545
+ throw new Error("useCard(): missing context value");
546
+ return card;
544
547
  }
545
548
  const key = "@sanity/ui/context/portal", elementKey = Symbol.for(`${key}/element`), elementMap = globalScope;
546
549
  elementMap[elementKey] = null;
@@ -566,11 +569,10 @@ function Portal(props) {
566
569
  } = props, card = useCard(), portal = usePortal(), portalElement = (name ? portal.elements && portal.elements[name] : portal.element) || portal.elements?.default;
567
570
  if (!portalElement)
568
571
  return null;
569
- const t0 = card?.scheme || "light";
572
+ let t0;
573
+ $[0] !== card.scheme || $[1] !== children ? (t0 = /* @__PURE__ */ jsxRuntime.jsx(CardProvider, { tone: "transparent", scheme: card.scheme, children }), $[0] = card.scheme, $[1] = children, $[2] = t0) : t0 = $[2];
570
574
  let t1;
571
- $[0] !== children || $[1] !== t0 ? (t1 = /* @__PURE__ */ jsxRuntime.jsx(CardProvider, { tone: "transparent", scheme: t0, children }), $[0] = children, $[1] = t0, $[2] = t1) : t1 = $[2];
572
- let t2;
573
- return $[3] !== portalElement || $[4] !== t1 ? (t2 = reactDom.createPortal(t1, portalElement), $[3] = portalElement, $[4] = t1, $[5] = t2) : t2 = $[5], t2;
575
+ return $[3] !== portalElement || $[4] !== t0 ? (t1 = reactDom.createPortal(t0, portalElement), $[3] = portalElement, $[4] = t0, $[5] = t1) : t1 = $[5], t1;
574
576
  }
575
577
  function getLayerContext(contextValue) {
576
578
  if (!isRecord(contextValue) || contextValue.version !== 0)
@@ -790,7 +792,7 @@ function Card(props) {
790
792
  tone: t5,
791
793
  ...rest
792
794
  } = t0, $[0] = t0, $[1] = className, $[2] = disabled, $[3] = pressed, $[4] = rest, $[5] = schemeProp, $[6] = selected, $[7] = style, $[8] = t1, $[9] = t2, $[10] = t3, $[11] = t4, $[12] = t5) : (className = $[1], disabled = $[2], pressed = $[3], rest = $[4], schemeProp = $[5], selected = $[6], style = $[7], t1 = $[8], t2 = $[9], t3 = $[10], t4 = $[11], t5 = $[12]);
793
- const checkered = t1 === void 0 ? !1 : t1, focusRing = t2 === void 0 ? !1 : t2, as = t3 === void 0 ? DEFAULT_CARD_ELEMENT : t3, radius = t4 === void 0 ? 0 : t4, toneProp = t5 === void 0 ? "default" : t5, parent = useCard(), tone = toneProp === "inherit" ? parent?.tone : toneProp, scheme = schemeProp === void 0 ? parent?.scheme : schemeProp, t6 = scheme === parent?.scheme ? void 0 : scheme;
795
+ const checkered = t1 === void 0 ? !1 : t1, focusRing = t2 === void 0 ? !1 : t2, as = t3 === void 0 ? DEFAULT_CARD_ELEMENT : t3, radius = t4 === void 0 ? 0 : t4, toneProp = t5 === void 0 ? "default" : t5, parent = react.useContext(CardContext), tone = toneProp === "inherit" ? parent?.tone : toneProp, scheme = schemeProp === void 0 ? parent?.scheme : schemeProp, t6 = scheme === parent?.scheme ? void 0 : scheme;
794
796
  let t7;
795
797
  $[13] !== className || $[14] !== t6 || $[15] !== tone ? (t7 = css.card({
796
798
  className,
@@ -806,7 +808,7 @@ function Card(props) {
806
808
  const t14 = scheme ?? "light", t15 = tone ?? "default", t16 = parent?.unstable_CompatProvider;
807
809
  let t17;
808
810
  if ($[28] !== node || $[29] !== t14 || $[30] !== t15 || $[31] !== t16 ? (t17 = /* @__PURE__ */ jsxRuntime.jsx(CardProvider, { scheme: t14, tone: t15, unstable_CompatProvider: t16, children: node }), $[28] = node, $[29] = t14, $[30] = t15, $[31] = t16, $[32] = t17) : t17 = $[32], node = t17, parent?.unstable_CompatProvider) {
809
- const CompatProvider = parent.unstable_CompatProvider, t18 = scheme ?? "light", t19 = tone ?? parent?.tone ?? "default";
811
+ const CompatProvider = parent.unstable_CompatProvider, t18 = scheme ?? "light", t19 = tone ?? parent.tone;
810
812
  let t20;
811
813
  return $[33] !== CompatProvider || $[34] !== node || $[35] !== t18 || $[36] !== t19 ? (t20 = /* @__PURE__ */ jsxRuntime.jsx(CompatProvider, { scheme: t18, tone: t19, children: node }), $[33] = CompatProvider, $[34] = node, $[35] = t18, $[36] = t19, $[37] = t20) : t20 = $[37], t20;
812
814
  }
@@ -1170,7 +1172,7 @@ function Popover(props) {
1170
1172
  /* @__PURE__ */ jsxRuntime.jsx(PopoverLayer, { ...rest, __unstable_margins: margins, animate, arrow: arrowProp, arrowRef: setArrow, arrowX, arrowY, as, className: css.popover({
1171
1173
  className
1172
1174
  }), hidden: referenceHidden, maxWidth: widthProp, overflow, padding, placement, radius, ref: setFloating, scheme, shadow, originX, originY, strategy, x, y, zOffset, children: content })
1173
- ] }), children = open && (portal ? /* @__PURE__ */ jsxRuntime.jsx(Portal, { __unstable_name: typeof portal == "string" ? portal : void 0, children: /* @__PURE__ */ jsxRuntime.jsx(CardProvider, { tone: tone === "inherit" ? card?.tone ?? "default" : tone, scheme: scheme ?? "light", children: node_1 }) }) : node_1);
1175
+ ] }), children = open && (portal ? /* @__PURE__ */ jsxRuntime.jsx(Portal, { __unstable_name: typeof portal == "string" ? portal : void 0, children: /* @__PURE__ */ jsxRuntime.jsx(CardProvider, { tone: tone === "inherit" ? card.tone : tone, scheme: scheme ?? "light", children: node_1 }) }) : node_1);
1174
1176
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1175
1177
  animate ? /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children }) : children,
1176
1178
  child
@@ -1989,44 +1991,6 @@ function usePrefersDark(t0) {
1989
1991
  function _temp$1() {
1990
1992
  return !1;
1991
1993
  }
1992
- function PortalProvider(props) {
1993
- const $ = compilerRuntime.c(7), {
1994
- boundaryElement,
1995
- children,
1996
- element,
1997
- __unstable_elements: elementsProp
1998
- } = props, elements = useUnique(elementsProp), fallbackElement = react.useSyncExternalStore(emptySubscribe, _temp, _temp2);
1999
- let t0;
2000
- const t1 = boundaryElement || null, t2 = element || fallbackElement;
2001
- let t3;
2002
- $[0] !== elements || $[1] !== t1 || $[2] !== t2 ? (t3 = {
2003
- version: 0,
2004
- boundaryElement: t1,
2005
- element: t2,
2006
- elements
2007
- }, $[0] = elements, $[1] = t1, $[2] = t2, $[3] = t3) : t3 = $[3], t0 = t3;
2008
- const value = t0;
2009
- let t4;
2010
- return $[4] !== children || $[5] !== value ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(PortalContext.Provider, { value, children }), $[4] = children, $[5] = value, $[6] = t4) : t4 = $[6], t4;
2011
- }
2012
- function _temp2() {
2013
- return null;
2014
- }
2015
- function _temp() {
2016
- return document.body;
2017
- }
2018
- const emptySubscribe = () => () => {
2019
- };
2020
- function useUnique(value) {
2021
- const valueRef = react.useRef(value);
2022
- return _isEqual(valueRef.current, value) || (valueRef.current = value), valueRef.current;
2023
- }
2024
- function _isEqual(objA, objB) {
2025
- if (!objA || !objB)
2026
- return objA === objB;
2027
- const keysA = Object.keys(objA), keysB = Object.keys(objB);
2028
- return keysA.length !== keysB.length ? !1 : keysA.every((key2) => objA[key2] === objB[key2]);
2029
- }
2030
1994
  function useDelayedState(initialState) {
2031
1995
  const $ = compilerRuntime.c(3), [state, setState] = react.useState(initialState), delayedAction = react.useRef(void 0);
2032
1996
  let t0;
@@ -2239,7 +2203,7 @@ function Tooltip(props) {
2239
2203
  }), originX, originY, padding, placement, radius, ref: setFloating, scheme, shadow, style: {
2240
2204
  ...floatingStyles,
2241
2205
  maxWidth: tooltipMaxWidth > 0 ? `${tooltipMaxWidth}px` : void 0
2242
- }, tone, zOffset, children: content }), children = showTooltip && (portalProp ? /* @__PURE__ */ jsxRuntime.jsx(Portal, { __unstable_name: typeof portalProp == "string" ? portalProp : void 0, children: /* @__PURE__ */ jsxRuntime.jsx(CardProvider, { tone: tone === "inherit" ? card?.tone ?? "default" : tone, scheme: scheme ?? "light", children: node_0 }) }) : node_0);
2206
+ }, tone, zOffset, children: content }), children = showTooltip && (portalProp ? /* @__PURE__ */ jsxRuntime.jsx(Portal, { __unstable_name: typeof portalProp == "string" ? portalProp : void 0, children: /* @__PURE__ */ jsxRuntime.jsx(CardProvider, { tone: tone === "inherit" ? card.tone : tone, scheme: scheme ?? "light", children: node_0 }) }) : node_0);
2243
2207
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2244
2208
  animate ? /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children }) : children,
2245
2209
  child
@@ -2269,6 +2233,44 @@ function useCloseOnMouseLeave(t0) {
2269
2233
  let t3;
2270
2234
  $[7] !== isInsideGroup || $[8] !== showTooltip ? (t3 = [isInsideGroup, showTooltip], $[7] = isInsideGroup, $[8] = showTooltip, $[9] = t3) : t3 = $[9], react.useEffect(t2, t3);
2271
2235
  }
2236
+ function PortalProvider(props) {
2237
+ const $ = compilerRuntime.c(7), {
2238
+ boundaryElement,
2239
+ children,
2240
+ element,
2241
+ __unstable_elements: elementsProp
2242
+ } = props, elements = useUnique(elementsProp), fallbackElement = react.useSyncExternalStore(emptySubscribe, _temp, _temp2);
2243
+ let t0;
2244
+ const t1 = boundaryElement || null, t2 = element || fallbackElement;
2245
+ let t3;
2246
+ $[0] !== elements || $[1] !== t1 || $[2] !== t2 ? (t3 = {
2247
+ version: 0,
2248
+ boundaryElement: t1,
2249
+ element: t2,
2250
+ elements
2251
+ }, $[0] = elements, $[1] = t1, $[2] = t2, $[3] = t3) : t3 = $[3], t0 = t3;
2252
+ const value = t0;
2253
+ let t4;
2254
+ return $[4] !== children || $[5] !== value ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(PortalContext.Provider, { value, children }), $[4] = children, $[5] = value, $[6] = t4) : t4 = $[6], t4;
2255
+ }
2256
+ function _temp2() {
2257
+ return null;
2258
+ }
2259
+ function _temp() {
2260
+ return document.body;
2261
+ }
2262
+ const emptySubscribe = () => () => {
2263
+ };
2264
+ function useUnique(value) {
2265
+ const valueRef = react.useRef(value);
2266
+ return _isEqual(valueRef.current, value) || (valueRef.current = value), valueRef.current;
2267
+ }
2268
+ function _isEqual(objA, objB) {
2269
+ if (!objA || !objB)
2270
+ return objA === objB;
2271
+ const keysA = Object.keys(objA), keysB = Object.keys(objB);
2272
+ return keysA.length !== keysB.length ? !1 : keysA.every((key2) => objA[key2] === objB[key2]);
2273
+ }
2272
2274
  exports.AnimatedSpinnerIcon = AnimatedSpinnerIcon;
2273
2275
  exports.Arrow = Arrow;
2274
2276
  exports.BoundaryElementContext = BoundaryElementContext;