@sanity/ui 3.0.0-static.30 → 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.
- package/dist/_chunks-cjs/_visual-editing.cjs +62 -61
- package/dist/_chunks-cjs/_visual-editing.cjs.map +1 -1
- package/dist/_chunks-cjs/refractor.cjs.map +1 -1
- package/dist/_chunks-es/_visual-editing.js +62 -61
- package/dist/_chunks-es/_visual-editing.js.map +1 -1
- package/dist/_chunks-es/refractor.js.map +1 -1
- package/dist/css/index.cjs +1 -3
- package/dist/css/index.cjs.map +1 -1
- package/dist/css/index.css +1 -1
- package/dist/css/index.d.cts +7228 -7228
- package/dist/css/index.d.ts +7228 -7228
- package/dist/css/index.js +1 -3
- package/dist/css/index.js.map +1 -1
- package/dist/index.cjs +91 -88
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -12
- package/dist/index.d.ts +12 -12
- package/dist/index.js +93 -90
- package/dist/index.js.map +1 -1
- package/dist/theme.cjs.map +1 -1
- package/dist/theme.js.map +1 -1
- package/package.json +25 -25
- package/src/core/{primitives/root/Root.tsx → Root.tsx} +5 -3
- package/src/core/{primitives/root/RootProvider.tsx → RootProvider.tsx} +5 -5
- package/src/core/__DEV__.ts +0 -1
- package/src/core/__workshop__/boundary.tsx +28 -0
- package/src/core/__workshop__/index.ts +14 -0
- package/src/core/_compat/theme/theme.test.tsx +4 -3
- package/src/core/components/dialog/dialogCard.tsx +9 -2
- package/src/core/components/menu/menu.test.tsx +8 -7
- package/src/core/components/toast/toast.test.tsx +8 -7
- package/src/core/hooks/usePrefersDark.hydration.test.tsx +1 -1
- package/src/core/hooks/usePrefersReducedMotion.hydration.test.tsx +1 -1
- package/src/core/index.ts +4 -2
- package/src/core/lib/createGlobalScopedContext.ts +5 -2
- package/src/core/lib/globalScope.ts +1 -1
- package/src/core/primitives/card/card.tsx +4 -3
- package/src/core/primitives/card/useCard.ts +8 -2
- package/src/core/primitives/code/refractor.tsx +1 -1
- package/src/core/primitives/grid/types.ts +1 -1
- package/src/core/primitives/layer/layer.test.tsx +8 -7
- package/src/core/primitives/popover/popover.tsx +5 -33
- package/src/core/primitives/textArea/textArea.tsx +0 -2
- package/src/core/primitives/tooltip/tooltip.tsx +1 -4
- package/src/core/primitives/types.ts +11 -11
- package/src/core/types/props.ts +1 -0
- package/src/core/utils/boundaryElement/boundaryElement.test.tsx +8 -7
- package/src/core/utils/getElementRef.ts +2 -0
- package/src/core/utils/portal/portal.test.tsx +8 -7
- package/src/core/utils/portal/portal.tsx +1 -5
- package/src/core/utils/portal/portalContext.ts +10 -7
- package/src/css/components/dialog/dialog.css.ts +2 -2
- package/src/css/components/toast/toast.css.ts +2 -2
- package/src/css/primitives/button/button.css.ts +0 -2
- package/src/css/primitives/root/root.css.ts +5 -1
- package/src/css/primitives/root/root.ts +1 -1
- package/src/css/props/gridColumnStart/types.ts +1 -1
- package/src/theme/v0/css.ts +2 -0
- package/src/theme/v2/build/merge.ts +2 -0
- package/src/theme/v3/merge.ts +2 -0
- package/src/core/primitives/root/__workshop__/boundary.tsx +0 -5
- package/src/core/primitives/root/__workshop__/index.ts +0 -8
|
@@ -10,7 +10,10 @@ function getGlobalScope() {
|
|
|
10
10
|
const globalScope = getGlobalScope();
|
|
11
11
|
function createGlobalScopedContext(key2, defaultValue) {
|
|
12
12
|
const symbol = Symbol.for(key2);
|
|
13
|
-
|
|
13
|
+
if (typeof document > "u")
|
|
14
|
+
return react.createContext(defaultValue);
|
|
15
|
+
const symbolMap = globalScope;
|
|
16
|
+
return symbolMap[symbol] = symbolMap[symbol] || react.createContext(defaultValue), symbolMap[symbol];
|
|
14
17
|
}
|
|
15
18
|
const CardContext = createGlobalScopedContext("@sanity/ui/context/card", null);
|
|
16
19
|
function CardProvider(props) {
|
|
@@ -532,16 +535,23 @@ function useBoundaryElement() {
|
|
|
532
535
|
throw new Error("useBoundaryElement(): the context value is not compatible");
|
|
533
536
|
return value || DEFAULT_VALUE;
|
|
534
537
|
}
|
|
538
|
+
function getElementRef(element) {
|
|
539
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
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
|
+
}
|
|
535
542
|
function useCard() {
|
|
536
|
-
|
|
543
|
+
const card = react.useContext(CardContext);
|
|
544
|
+
if (!card)
|
|
545
|
+
throw new Error("useCard(): missing context value");
|
|
546
|
+
return card;
|
|
537
547
|
}
|
|
538
|
-
const key = "@sanity/ui/context/portal", elementKey = Symbol.for(`${key}/element`);
|
|
539
|
-
|
|
548
|
+
const key = "@sanity/ui/context/portal", elementKey = Symbol.for(`${key}/element`), elementMap = globalScope;
|
|
549
|
+
elementMap[elementKey] = null;
|
|
540
550
|
const defaultContextValue = {
|
|
541
551
|
version: 0,
|
|
542
552
|
boundaryElement: null,
|
|
543
553
|
get element() {
|
|
544
|
-
return typeof document > "u" ? null : (
|
|
554
|
+
return typeof document > "u" ? null : (elementMap[elementKey] || (elementMap[elementKey] = document.createElement("div"), elementMap[elementKey].setAttribute("data-portal", ""), document.body.appendChild(elementMap[elementKey])), elementMap[elementKey]);
|
|
545
555
|
}
|
|
546
556
|
}, PortalContext = createGlobalScopedContext(key, defaultContextValue);
|
|
547
557
|
function usePortal() {
|
|
@@ -559,11 +569,10 @@ function Portal(props) {
|
|
|
559
569
|
} = props, card = useCard(), portal = usePortal(), portalElement = (name ? portal.elements && portal.elements[name] : portal.element) || portal.elements?.default;
|
|
560
570
|
if (!portalElement)
|
|
561
571
|
return null;
|
|
562
|
-
|
|
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];
|
|
563
574
|
let t1;
|
|
564
|
-
$[
|
|
565
|
-
let t2;
|
|
566
|
-
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;
|
|
567
576
|
}
|
|
568
577
|
function getLayerContext(contextValue) {
|
|
569
578
|
if (!isRecord(contextValue) || contextValue.version !== 0)
|
|
@@ -783,7 +792,7 @@ function Card(props) {
|
|
|
783
792
|
tone: t5,
|
|
784
793
|
...rest
|
|
785
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]);
|
|
786
|
-
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 =
|
|
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;
|
|
787
796
|
let t7;
|
|
788
797
|
$[13] !== className || $[14] !== t6 || $[15] !== tone ? (t7 = css.card({
|
|
789
798
|
className,
|
|
@@ -799,7 +808,7 @@ function Card(props) {
|
|
|
799
808
|
const t14 = scheme ?? "light", t15 = tone ?? "default", t16 = parent?.unstable_CompatProvider;
|
|
800
809
|
let t17;
|
|
801
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) {
|
|
802
|
-
const CompatProvider = parent.unstable_CompatProvider, t18 = scheme ?? "light", t19 = tone ?? parent
|
|
811
|
+
const CompatProvider = parent.unstable_CompatProvider, t18 = scheme ?? "light", t19 = tone ?? parent.tone;
|
|
803
812
|
let t20;
|
|
804
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;
|
|
805
814
|
}
|
|
@@ -1148,8 +1157,8 @@ function Popover(props) {
|
|
|
1148
1157
|
}, []), setFloating = react.useCallback((node) => {
|
|
1149
1158
|
ref.current = node, refs.setFloating(node);
|
|
1150
1159
|
}, [refs]), setReference = react.useCallback((node_0) => {
|
|
1151
|
-
refs.setReference(node_0);
|
|
1152
|
-
const childRef = getElementRef
|
|
1160
|
+
if (refs.setReference(node_0), !childProp) return;
|
|
1161
|
+
const childRef = getElementRef(childProp);
|
|
1153
1162
|
typeof childRef == "function" ? childRef(node_0) : childRef && (childRef.current = node_0);
|
|
1154
1163
|
}, [childProp, refs]), child = react.useMemo(() => referenceElement ? childProp : childProp ? react.cloneElement(childProp, {
|
|
1155
1164
|
ref: setReference
|
|
@@ -1163,16 +1172,12 @@ function Popover(props) {
|
|
|
1163
1172
|
/* @__PURE__ */ jsxRuntime.jsx(PopoverLayer, { ...rest, __unstable_margins: margins, animate, arrow: arrowProp, arrowRef: setArrow, arrowX, arrowY, as, className: css.popover({
|
|
1164
1173
|
className
|
|
1165
1174
|
}), hidden: referenceHidden, maxWidth: widthProp, overflow, padding, placement, radius, ref: setFloating, scheme, shadow, originX, originY, strategy, x, y, zOffset, children: content })
|
|
1166
|
-
] }), children = open && (portal ? /* @__PURE__ */ jsxRuntime.jsx(Portal, { __unstable_name: typeof portal == "string" ? portal : void 0, children: /* @__PURE__ */ jsxRuntime.jsx(CardProvider, { tone: tone === "inherit" ? card
|
|
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);
|
|
1167
1176
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1168
1177
|
animate ? /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children }) : children,
|
|
1169
1178
|
child
|
|
1170
1179
|
] });
|
|
1171
1180
|
}
|
|
1172
|
-
function getElementRef$1(element) {
|
|
1173
|
-
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
1174
|
-
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);
|
|
1175
|
-
}
|
|
1176
1181
|
const DEFAULT_SELECTABLE_ELEMENT = "button";
|
|
1177
1182
|
function Selectable(props) {
|
|
1178
1183
|
const $ = compilerRuntime.c(16), t0 = props;
|
|
@@ -1986,44 +1991,6 @@ function usePrefersDark(t0) {
|
|
|
1986
1991
|
function _temp$1() {
|
|
1987
1992
|
return !1;
|
|
1988
1993
|
}
|
|
1989
|
-
function PortalProvider(props) {
|
|
1990
|
-
const $ = compilerRuntime.c(7), {
|
|
1991
|
-
boundaryElement,
|
|
1992
|
-
children,
|
|
1993
|
-
element,
|
|
1994
|
-
__unstable_elements: elementsProp
|
|
1995
|
-
} = props, elements = useUnique(elementsProp), fallbackElement = react.useSyncExternalStore(emptySubscribe, _temp, _temp2);
|
|
1996
|
-
let t0;
|
|
1997
|
-
const t1 = boundaryElement || null, t2 = element || fallbackElement;
|
|
1998
|
-
let t3;
|
|
1999
|
-
$[0] !== elements || $[1] !== t1 || $[2] !== t2 ? (t3 = {
|
|
2000
|
-
version: 0,
|
|
2001
|
-
boundaryElement: t1,
|
|
2002
|
-
element: t2,
|
|
2003
|
-
elements
|
|
2004
|
-
}, $[0] = elements, $[1] = t1, $[2] = t2, $[3] = t3) : t3 = $[3], t0 = t3;
|
|
2005
|
-
const value = t0;
|
|
2006
|
-
let t4;
|
|
2007
|
-
return $[4] !== children || $[5] !== value ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(PortalContext.Provider, { value, children }), $[4] = children, $[5] = value, $[6] = t4) : t4 = $[6], t4;
|
|
2008
|
-
}
|
|
2009
|
-
function _temp2() {
|
|
2010
|
-
return null;
|
|
2011
|
-
}
|
|
2012
|
-
function _temp() {
|
|
2013
|
-
return document.body;
|
|
2014
|
-
}
|
|
2015
|
-
const emptySubscribe = () => () => {
|
|
2016
|
-
};
|
|
2017
|
-
function useUnique(value) {
|
|
2018
|
-
const valueRef = react.useRef(value);
|
|
2019
|
-
return _isEqual(valueRef.current, value) || (valueRef.current = value), valueRef.current;
|
|
2020
|
-
}
|
|
2021
|
-
function _isEqual(objA, objB) {
|
|
2022
|
-
if (!objA || !objB)
|
|
2023
|
-
return objA === objB;
|
|
2024
|
-
const keysA = Object.keys(objA), keysB = Object.keys(objB);
|
|
2025
|
-
return keysA.length !== keysB.length ? !1 : keysA.every((key2) => objA[key2] === objB[key2]);
|
|
2026
|
-
}
|
|
2027
1994
|
function useDelayedState(initialState) {
|
|
2028
1995
|
const $ = compilerRuntime.c(3), [state, setState] = react.useState(initialState), delayedAction = react.useRef(void 0);
|
|
2029
1996
|
let t0;
|
|
@@ -2039,10 +2006,6 @@ function useDelayedState(initialState) {
|
|
|
2039
2006
|
let t1;
|
|
2040
2007
|
return $[1] !== state ? (t1 = [state, onStateChange], $[1] = state, $[2] = t1) : t1 = $[2], t1;
|
|
2041
2008
|
}
|
|
2042
|
-
function getElementRef(element) {
|
|
2043
|
-
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
2044
|
-
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);
|
|
2045
|
-
}
|
|
2046
2009
|
const DEFAULT_TOOLTIP_ARROW_WIDTH = 15, DEFAULT_TOOLTIP_ARROW_HEIGHT = 6, DEFAULT_TOOLTIP_ARROW_RADIUS = 2, DEFAULT_TOOLTIP_DISTANCE = 4, DEFAULT_TOOLTIP_PADDING = 4, DEFAULT_FALLBACK_PLACEMENTS = {
|
|
2047
2010
|
top: ["top-end", "top-start", "bottom", "left", "right"],
|
|
2048
2011
|
"top-start": ["top", "top-end", "bottom-start", "left-start", "right-start"],
|
|
@@ -2240,7 +2203,7 @@ function Tooltip(props) {
|
|
|
2240
2203
|
}), originX, originY, padding, placement, radius, ref: setFloating, scheme, shadow, style: {
|
|
2241
2204
|
...floatingStyles,
|
|
2242
2205
|
maxWidth: tooltipMaxWidth > 0 ? `${tooltipMaxWidth}px` : void 0
|
|
2243
|
-
}, 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
|
|
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);
|
|
2244
2207
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2245
2208
|
animate ? /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children }) : children,
|
|
2246
2209
|
child
|
|
@@ -2270,6 +2233,44 @@ function useCloseOnMouseLeave(t0) {
|
|
|
2270
2233
|
let t3;
|
|
2271
2234
|
$[7] !== isInsideGroup || $[8] !== showTooltip ? (t3 = [isInsideGroup, showTooltip], $[7] = isInsideGroup, $[8] = showTooltip, $[9] = t3) : t3 = $[9], react.useEffect(t2, t3);
|
|
2272
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
|
+
}
|
|
2273
2274
|
exports.AnimatedSpinnerIcon = AnimatedSpinnerIcon;
|
|
2274
2275
|
exports.Arrow = Arrow;
|
|
2275
2276
|
exports.BoundaryElementContext = BoundaryElementContext;
|