@sanity/ui 3.0.0-static.30 → 3.0.0-static.31
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 +13 -14
- 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 +13 -14
- package/dist/_chunks-es/_visual-editing.js.map +1 -1
- package/dist/_chunks-es/refractor.js.map +1 -1
- package/dist/css/index.css +1 -1
- package/dist/css/index.d.cts +7227 -7227
- package/dist/css/index.d.ts +7227 -7227
- package/dist/index.cjs +11 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +11 -9
- 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/__DEV__.ts +0 -1
- 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/lib/createGlobalScopedContext.ts +5 -2
- package/src/core/lib/globalScope.ts +1 -1
- package/src/core/primitives/code/refractor.tsx +1 -1
- package/src/core/primitives/layer/layer.test.tsx +8 -7
- package/src/core/primitives/popover/popover.tsx +4 -29
- package/src/core/primitives/textArea/textArea.tsx +0 -2
- 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/portalContext.ts +10 -7
- package/src/css/components/dialog/dialog.css.ts +2 -2
- package/src/css/primitives/button/button.css.ts +0 -2
- 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
|
@@ -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,20 @@ 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
|
return react.useContext(CardContext);
|
|
537
544
|
}
|
|
538
|
-
const key = "@sanity/ui/context/portal", elementKey = Symbol.for(`${key}/element`);
|
|
539
|
-
|
|
545
|
+
const key = "@sanity/ui/context/portal", elementKey = Symbol.for(`${key}/element`), elementMap = globalScope;
|
|
546
|
+
elementMap[elementKey] = null;
|
|
540
547
|
const defaultContextValue = {
|
|
541
548
|
version: 0,
|
|
542
549
|
boundaryElement: null,
|
|
543
550
|
get element() {
|
|
544
|
-
return typeof document > "u" ? null : (
|
|
551
|
+
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
552
|
}
|
|
546
553
|
}, PortalContext = createGlobalScopedContext(key, defaultContextValue);
|
|
547
554
|
function usePortal() {
|
|
@@ -1148,8 +1155,8 @@ function Popover(props) {
|
|
|
1148
1155
|
}, []), setFloating = react.useCallback((node) => {
|
|
1149
1156
|
ref.current = node, refs.setFloating(node);
|
|
1150
1157
|
}, [refs]), setReference = react.useCallback((node_0) => {
|
|
1151
|
-
refs.setReference(node_0);
|
|
1152
|
-
const childRef = getElementRef
|
|
1158
|
+
if (refs.setReference(node_0), !childProp) return;
|
|
1159
|
+
const childRef = getElementRef(childProp);
|
|
1153
1160
|
typeof childRef == "function" ? childRef(node_0) : childRef && (childRef.current = node_0);
|
|
1154
1161
|
}, [childProp, refs]), child = react.useMemo(() => referenceElement ? childProp : childProp ? react.cloneElement(childProp, {
|
|
1155
1162
|
ref: setReference
|
|
@@ -1169,10 +1176,6 @@ function Popover(props) {
|
|
|
1169
1176
|
child
|
|
1170
1177
|
] });
|
|
1171
1178
|
}
|
|
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
1179
|
const DEFAULT_SELECTABLE_ELEMENT = "button";
|
|
1177
1180
|
function Selectable(props) {
|
|
1178
1181
|
const $ = compilerRuntime.c(16), t0 = props;
|
|
@@ -2039,10 +2042,6 @@ function useDelayedState(initialState) {
|
|
|
2039
2042
|
let t1;
|
|
2040
2043
|
return $[1] !== state ? (t1 = [state, onStateChange], $[1] = state, $[2] = t1) : t1 = $[2], t1;
|
|
2041
2044
|
}
|
|
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
2045
|
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
2046
|
top: ["top-end", "top-start", "bottom", "left", "right"],
|
|
2048
2047
|
"top-start": ["top", "top-end", "bottom-start", "left-start", "right-start"],
|