@sanity/ui 2.8.8 → 2.8.10-canary.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/_chunks-cjs/getTheme_v2.js +7 -10
- package/dist/_chunks-cjs/getTheme_v2.js.map +1 -1
- package/dist/_chunks-es/getTheme_v2.mjs +7 -10
- package/dist/_chunks-es/getTheme_v2.mjs.map +1 -1
- package/dist/_legacy/getTheme_v2.esm.js +7 -10
- package/dist/_legacy/getTheme_v2.esm.js.map +1 -1
- package/dist/index.esm.js +98 -144
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +98 -144
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +98 -144
- package/dist/index.mjs.map +1 -1
- package/dist/theme.esm.js +218 -235
- package/dist/theme.esm.js.map +1 -1
- package/dist/theme.js +218 -235
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +218 -235
- package/dist/theme.mjs.map +1 -1
- package/package.json +56 -64
- package/src/core/primitives/popover/popover.tsx +28 -2
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ function rem(pixelValue) {
|
|
|
32
32
|
return pixelValue === 0 ? 0 : `${pixelValue / 16}rem`;
|
|
33
33
|
}
|
|
34
34
|
function _responsive(media, values, callback) {
|
|
35
|
-
return (
|
|
35
|
+
return (values?.map(callback) || []).map((statement, mediaIndex) => mediaIndex === 0 ? statement : { [`@media screen and (min-width: ${media[mediaIndex - 1]}px)`]: statement });
|
|
36
36
|
}
|
|
37
37
|
function _getArrayProp(val, defaultVal) {
|
|
38
38
|
return val === void 0 ? defaultVal || EMPTY_ARRAY : Array.isArray(val) ? val : [val];
|
|
@@ -118,7 +118,7 @@ function responsiveTextFont(props) {
|
|
|
118
118
|
return responsiveFont("text", props);
|
|
119
119
|
}
|
|
120
120
|
function useArrayProp(val, defaultVal) {
|
|
121
|
-
const __perf_hash__ = react.useMemo(() => JSON.stringify(val
|
|
121
|
+
const __perf_hash__ = react.useMemo(() => JSON.stringify(val ?? defaultVal), [defaultVal, val]);
|
|
122
122
|
return react.useMemo(
|
|
123
123
|
() => _getArrayProp(val, defaultVal),
|
|
124
124
|
// Improve performance: Keep object identify for a given hash of the value
|
|
@@ -173,7 +173,7 @@ function useClickOutsideEvent(listener, elementsArg = () => EMPTY_ARRAY, boundar
|
|
|
173
173
|
const target = evt.target;
|
|
174
174
|
if (!(target instanceof Node))
|
|
175
175
|
return;
|
|
176
|
-
const resolvedBoundaryElement = boundaryElement
|
|
176
|
+
const resolvedBoundaryElement = boundaryElement?.();
|
|
177
177
|
if (resolvedBoundaryElement && !resolvedBoundaryElement.contains(target))
|
|
178
178
|
return;
|
|
179
179
|
const elements = elementsArg().flat();
|
|
@@ -192,8 +192,7 @@ function useClickOutsideEvent(listener, elementsArg = () => EMPTY_ARRAY, boundar
|
|
|
192
192
|
}
|
|
193
193
|
function useCustomValidity(ref, customValidity) {
|
|
194
194
|
react.useEffect(() => {
|
|
195
|
-
|
|
196
|
-
(_a = ref.current) == null || _a.setCustomValidity(customValidity || "");
|
|
195
|
+
ref.current?.setCustomValidity(customValidity || "");
|
|
197
196
|
}, [customValidity, ref]);
|
|
198
197
|
}
|
|
199
198
|
var resizeObservers = [], hasActiveObservations = function() {
|
|
@@ -243,7 +242,7 @@ var freeze = function(obj) {
|
|
|
243
242
|
var _a;
|
|
244
243
|
if (obj instanceof Element)
|
|
245
244
|
return !0;
|
|
246
|
-
var scope = (_a = obj
|
|
245
|
+
var scope = (_a = obj?.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView;
|
|
247
246
|
return !!(scope && obj instanceof scope.Element);
|
|
248
247
|
}, isReplacedElement = function(target) {
|
|
249
248
|
switch (target.tagName) {
|
|
@@ -526,8 +525,7 @@ function useElementSize(element) {
|
|
|
526
525
|
}, [element]), size2;
|
|
527
526
|
}
|
|
528
527
|
function useElementRect(element) {
|
|
529
|
-
|
|
530
|
-
return (elementSize == null ? void 0 : elementSize._contentRect) || null;
|
|
528
|
+
return useElementSize(element)?._contentRect || null;
|
|
531
529
|
}
|
|
532
530
|
function useForwardedRef(ref) {
|
|
533
531
|
const innerRef = react.useRef(null);
|
|
@@ -569,9 +567,9 @@ const ThemeContext = createGlobalScopedContext(
|
|
|
569
567
|
function ThemeProvider(props) {
|
|
570
568
|
const parentTheme = react.useContext(ThemeContext), {
|
|
571
569
|
children,
|
|
572
|
-
scheme =
|
|
573
|
-
theme: rootTheme =
|
|
574
|
-
tone =
|
|
570
|
+
scheme = parentTheme?.scheme || "light",
|
|
571
|
+
theme: rootTheme = parentTheme?.theme || null,
|
|
572
|
+
tone = parentTheme?.tone || "default"
|
|
575
573
|
} = props, themeContext = react.useMemo(() => rootTheme ? {
|
|
576
574
|
version: 0,
|
|
577
575
|
theme: rootTheme,
|
|
@@ -649,8 +647,7 @@ function responsiveBorderStyle() {
|
|
|
649
647
|
return [border, borderTop, borderRight, borderBottom, borderLeft];
|
|
650
648
|
}
|
|
651
649
|
function border(props) {
|
|
652
|
-
|
|
653
|
-
const { card, media } = theme.getTheme_v2(props.theme), borderStyle = `${(_b = (_a = card.border) == null ? void 0 : _a.width) != null ? _b : 1}px solid var(--card-border-color)`;
|
|
650
|
+
const { card, media } = theme.getTheme_v2(props.theme), borderStyle = `${card.border?.width ?? 1}px solid var(--card-border-color)`;
|
|
654
651
|
return _responsive(
|
|
655
652
|
media,
|
|
656
653
|
props.$border,
|
|
@@ -658,8 +655,7 @@ function border(props) {
|
|
|
658
655
|
);
|
|
659
656
|
}
|
|
660
657
|
function borderTop(props) {
|
|
661
|
-
|
|
662
|
-
const { card, media } = theme.getTheme_v2(props.theme), borderStyle = `${(_b = (_a = card.border) == null ? void 0 : _a.width) != null ? _b : 1}px solid var(--card-border-color)`;
|
|
658
|
+
const { card, media } = theme.getTheme_v2(props.theme), borderStyle = `${card.border?.width ?? 1}px solid var(--card-border-color)`;
|
|
663
659
|
return _responsive(
|
|
664
660
|
media,
|
|
665
661
|
props.$borderTop,
|
|
@@ -667,8 +663,7 @@ function borderTop(props) {
|
|
|
667
663
|
);
|
|
668
664
|
}
|
|
669
665
|
function borderRight(props) {
|
|
670
|
-
|
|
671
|
-
const { card, media } = theme.getTheme_v2(props.theme), borderStyle = `${(_b = (_a = card.border) == null ? void 0 : _a.width) != null ? _b : 1}px solid var(--card-border-color)`;
|
|
666
|
+
const { card, media } = theme.getTheme_v2(props.theme), borderStyle = `${card.border?.width ?? 1}px solid var(--card-border-color)`;
|
|
672
667
|
return _responsive(
|
|
673
668
|
media,
|
|
674
669
|
props.$borderRight,
|
|
@@ -676,8 +671,7 @@ function borderRight(props) {
|
|
|
676
671
|
);
|
|
677
672
|
}
|
|
678
673
|
function borderBottom(props) {
|
|
679
|
-
|
|
680
|
-
const { card, media } = theme.getTheme_v2(props.theme), borderStyle = `${(_b = (_a = card.border) == null ? void 0 : _a.width) != null ? _b : 1}px solid var(--card-border-color)`;
|
|
674
|
+
const { card, media } = theme.getTheme_v2(props.theme), borderStyle = `${card.border?.width ?? 1}px solid var(--card-border-color)`;
|
|
681
675
|
return _responsive(
|
|
682
676
|
media,
|
|
683
677
|
props.$borderBottom,
|
|
@@ -685,8 +679,7 @@ function borderBottom(props) {
|
|
|
685
679
|
);
|
|
686
680
|
}
|
|
687
681
|
function borderLeft(props) {
|
|
688
|
-
|
|
689
|
-
const { card, media } = theme.getTheme_v2(props.theme), borderStyle = `${(_b = (_a = card.border) == null ? void 0 : _a.width) != null ? _b : 1}px solid var(--card-border-color)`;
|
|
682
|
+
const { card, media } = theme.getTheme_v2(props.theme), borderStyle = `${card.border?.width ?? 1}px solid var(--card-border-color)`;
|
|
690
683
|
return _responsive(
|
|
691
684
|
media,
|
|
692
685
|
props.$borderLeft,
|
|
@@ -1914,7 +1907,7 @@ function _cardColorStyle(base, color, checkered = !1) {
|
|
|
1914
1907
|
function buttonBaseStyles(props) {
|
|
1915
1908
|
const { $width } = props, { style } = theme.getTheme_v2(props.theme);
|
|
1916
1909
|
return styledComponents.css`
|
|
1917
|
-
${style
|
|
1910
|
+
${style?.button};
|
|
1918
1911
|
|
|
1919
1912
|
-webkit-font-smoothing: inherit;
|
|
1920
1913
|
appearance: none;
|
|
@@ -1957,7 +1950,6 @@ function combineBoxShadow(...boxShadows) {
|
|
|
1957
1950
|
return boxShadows.filter(Boolean).join(",");
|
|
1958
1951
|
}
|
|
1959
1952
|
function buttonColorStyles(props) {
|
|
1960
|
-
var _a;
|
|
1961
1953
|
const { $mode } = props, { button, color: baseColor, style } = theme.getTheme_v2(props.theme), shadow = props.$mode === "ghost", mode = baseColor.button[$mode] || baseColor.button.default, color = mode[props.$tone] || mode.default, border2 = {
|
|
1962
1954
|
width: button.border.width,
|
|
1963
1955
|
color: "var(--card-border-color)"
|
|
@@ -1995,7 +1987,7 @@ function buttonColorStyles(props) {
|
|
|
1995
1987
|
"&[data-selected]": _cardColorStyle(baseColor, color.pressed)
|
|
1996
1988
|
}
|
|
1997
1989
|
},
|
|
1998
|
-
|
|
1990
|
+
style?.button?.root
|
|
1999
1991
|
].filter(Boolean);
|
|
2000
1992
|
}
|
|
2001
1993
|
const Root$t = styledComponents.styled.button(responsiveRadiusStyle, buttonBaseStyles, buttonColorStyles), LoadingBox = styledComponents.styled.div`
|
|
@@ -2131,7 +2123,6 @@ function cardBaseStyle(props) {
|
|
|
2131
2123
|
`;
|
|
2132
2124
|
}
|
|
2133
2125
|
function cardColorStyle(props) {
|
|
2134
|
-
var _a;
|
|
2135
2126
|
const { $checkered, $focusRing, $muted } = props, { card, color, style } = theme.getTheme_v2(props.theme), border2 = { width: card.border.width, color: "var(--card-border-color)" };
|
|
2136
2127
|
return styledComponents.css`
|
|
2137
2128
|
color-scheme: ${color._dark ? "dark" : "light"};
|
|
@@ -2217,7 +2208,7 @@ function cardColorStyle(props) {
|
|
|
2217
2208
|
}
|
|
2218
2209
|
}
|
|
2219
2210
|
|
|
2220
|
-
${
|
|
2211
|
+
${style?.card?.root}
|
|
2221
2212
|
`;
|
|
2222
2213
|
}
|
|
2223
2214
|
const Root$s = styledComponents.styled(Box)(responsiveBorderStyle, responsiveRadiusStyle, responsiveShadowStyle, cardStyle), Card = react.forwardRef(function(props, ref) {
|
|
@@ -2710,8 +2701,7 @@ KBD.displayName = "ForwardRef(KBD)";
|
|
|
2710
2701
|
const origin = {
|
|
2711
2702
|
name: "@sanity/ui/origin",
|
|
2712
2703
|
fn({ middlewareData, placement, rects }) {
|
|
2713
|
-
|
|
2714
|
-
const [side] = placement.split("-"), floatingWidth = rects.floating.width, floatingHeight = rects.floating.height, shiftX = ((_a = middlewareData.shift) == null ? void 0 : _a.x) || 0, shiftY = ((_b = middlewareData.shift) == null ? void 0 : _b.y) || 0;
|
|
2704
|
+
const [side] = placement.split("-"), floatingWidth = rects.floating.width, floatingHeight = rects.floating.height, shiftX = middlewareData.shift?.x || 0, shiftY = middlewareData.shift?.y || 0;
|
|
2715
2705
|
if (floatingWidth <= 0 || floatingHeight <= 0)
|
|
2716
2706
|
return {};
|
|
2717
2707
|
const isVerticalPlacement = ["bottom", "top"].includes(side), { originX, originY } = isVerticalPlacement ? {
|
|
@@ -2893,10 +2883,7 @@ function findMinBreakpoints(media, width) {
|
|
|
2893
2883
|
return ret;
|
|
2894
2884
|
}
|
|
2895
2885
|
const ElementQuery = react.forwardRef(function(props, forwardedRef) {
|
|
2896
|
-
const theme2 = useTheme_v2(), { children, media = theme2.media, ...restProps } = props, ref = react.useRef(null), [element, setElement] = react.useState(null), elementSize = useElementSize(element), width = react.useMemo(() =>
|
|
2897
|
-
var _a;
|
|
2898
|
-
return (_a = elementSize == null ? void 0 : elementSize.border.width) != null ? _a : window.innerWidth;
|
|
2899
|
-
}, [elementSize]), max = react.useMemo(() => findMaxBreakpoints(media, width), [media, width]), min = react.useMemo(() => findMinBreakpoints(media, width), [media, width]);
|
|
2886
|
+
const theme2 = useTheme_v2(), { children, media = theme2.media, ...restProps } = props, ref = react.useRef(null), [element, setElement] = react.useState(null), elementSize = useElementSize(element), width = react.useMemo(() => elementSize?.border.width ?? window.innerWidth, [elementSize]), max = react.useMemo(() => findMaxBreakpoints(media, width), [media, width]), min = react.useMemo(() => findMinBreakpoints(media, width), [media, width]);
|
|
2900
2887
|
react.useImperativeHandle(forwardedRef, () => ref.current);
|
|
2901
2888
|
const setRef = react.useCallback((el) => {
|
|
2902
2889
|
ref.current = el, setElement(el);
|
|
@@ -2914,11 +2901,8 @@ const ElementQuery = react.forwardRef(function(props, forwardedRef) {
|
|
|
2914
2901
|
);
|
|
2915
2902
|
});
|
|
2916
2903
|
ElementQuery.displayName = "ForwardRef(ElementQuery)";
|
|
2917
|
-
var __defProp = Object.defineProperty, __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key2] = value, __publicField = (obj, key2, value) => __defNormalProp(obj, key2 + "", value);
|
|
2918
2904
|
class ErrorBoundary extends react.Component {
|
|
2919
|
-
|
|
2920
|
-
super(...arguments), __publicField(this, "state", { error: null });
|
|
2921
|
-
}
|
|
2905
|
+
state = { error: null };
|
|
2922
2906
|
static getDerivedStateFromError(error) {
|
|
2923
2907
|
return { error };
|
|
2924
2908
|
}
|
|
@@ -2928,7 +2912,7 @@ class ErrorBoundary extends react.Component {
|
|
|
2928
2912
|
render() {
|
|
2929
2913
|
const { error } = this.state;
|
|
2930
2914
|
if (error) {
|
|
2931
|
-
const message = typeof
|
|
2915
|
+
const message = typeof error?.message == "string" ? error.message : "Error";
|
|
2932
2916
|
return /* @__PURE__ */ jsxRuntime.jsx(Code, { children: message });
|
|
2933
2917
|
}
|
|
2934
2918
|
return this.props.children;
|
|
@@ -3033,24 +3017,22 @@ function _isScrollable(el) {
|
|
|
3033
3017
|
return style.overflowX.includes("auto") || style.overflowX.includes("scroll") || style.overflowY.includes("auto") || style.overflowY.includes("scroll");
|
|
3034
3018
|
}
|
|
3035
3019
|
function LayerProvider(props) {
|
|
3036
|
-
|
|
3037
|
-
const { children, zOffset: zOffsetProp = 0 } = props, parentContextValue = react.useContext(LayerContext), parent = parentContextValue && getLayerContext(parentContextValue), parentRegisterChild = parent == null ? void 0 : parent.registerChild, level = ((_a = parent == null ? void 0 : parent.level) != null ? _a : 0) + 1, zOffset = useArrayProp(zOffsetProp), maxMediaIndex = zOffset.length - 1, mediaIndex = Math.min(useMediaIndex(), maxMediaIndex), zIndex = parent ? parent.zIndex + zOffset[mediaIndex] : zOffset[mediaIndex], [, setChildLayers] = react.useState({}), [size2, setSize] = react.useState(0), isTopLayer = size2 === 0, registerChild = react.useCallback(
|
|
3020
|
+
const { children, zOffset: zOffsetProp = 0 } = props, parentContextValue = react.useContext(LayerContext), parent = parentContextValue && getLayerContext(parentContextValue), parentRegisterChild = parent?.registerChild, level = (parent?.level ?? 0) + 1, zOffset = useArrayProp(zOffsetProp), maxMediaIndex = zOffset.length - 1, mediaIndex = Math.min(useMediaIndex(), maxMediaIndex), zIndex = parent ? parent.zIndex + zOffset[mediaIndex] : zOffset[mediaIndex], [, setChildLayers] = react.useState({}), [size2, setSize] = react.useState(0), isTopLayer = size2 === 0, registerChild = react.useCallback(
|
|
3038
3021
|
(childLevel) => {
|
|
3039
|
-
const parentDispose = parentRegisterChild
|
|
3022
|
+
const parentDispose = parentRegisterChild?.(childLevel);
|
|
3040
3023
|
return childLevel !== void 0 ? setChildLayers((state) => {
|
|
3041
|
-
|
|
3042
|
-
const prevLen = (_a2 = state[childLevel]) != null ? _a2 : 0, nextState = { ...state, [childLevel]: prevLen + 1 };
|
|
3024
|
+
const prevLen = state[childLevel] ?? 0, nextState = { ...state, [childLevel]: prevLen + 1 };
|
|
3043
3025
|
return setSize(Object.keys(nextState).length), nextState;
|
|
3044
3026
|
}) : setSize((v) => v + 1), () => {
|
|
3045
3027
|
childLevel !== void 0 ? setChildLayers((state) => {
|
|
3046
3028
|
const nextState = { ...state };
|
|
3047
3029
|
return nextState[childLevel] === 1 ? (delete nextState[childLevel], setSize(Object.keys(nextState).length)) : nextState[childLevel] -= 1, nextState;
|
|
3048
|
-
}) : setSize((v) => v - 1), parentDispose
|
|
3030
|
+
}) : setSize((v) => v - 1), parentDispose?.();
|
|
3049
3031
|
};
|
|
3050
3032
|
},
|
|
3051
3033
|
[parentRegisterChild]
|
|
3052
3034
|
);
|
|
3053
|
-
react.useEffect(() => parentRegisterChild
|
|
3035
|
+
react.useEffect(() => parentRegisterChild?.(level), [level, parentRegisterChild]);
|
|
3054
3036
|
const value = react.useMemo(
|
|
3055
3037
|
() => ({
|
|
3056
3038
|
version: 0,
|
|
@@ -3068,11 +3050,11 @@ LayerProvider.displayName = "LayerProvider";
|
|
|
3068
3050
|
const Root$j = styledComponents.styled.div({ position: "relative" }), LayerChildren = react.forwardRef(function(props, forwardedRef) {
|
|
3069
3051
|
const { children, onActivate, onFocus, style = EMPTY_RECORD, ...restProps } = props, { zIndex, isTopLayer } = useLayer(), lastFocusedRef = react.useRef(null), ref = react.useRef(null), isTopLayerRef = react.useRef(isTopLayer);
|
|
3070
3052
|
react.useImperativeHandle(forwardedRef, () => ref.current), react.useEffect(() => {
|
|
3071
|
-
isTopLayerRef.current !== isTopLayer && isTopLayer &&
|
|
3053
|
+
isTopLayerRef.current !== isTopLayer && isTopLayer && onActivate?.({ activeElement: lastFocusedRef.current }), isTopLayerRef.current = isTopLayer;
|
|
3072
3054
|
}, [isTopLayer, onActivate]);
|
|
3073
3055
|
const handleFocus = react.useCallback(
|
|
3074
3056
|
(event) => {
|
|
3075
|
-
onFocus
|
|
3057
|
+
onFocus?.(event);
|
|
3076
3058
|
const rootElement = ref.current, target = document.activeElement;
|
|
3077
3059
|
!isTopLayer || !rootElement || !target || isHTMLElement(target) && containsOrEqualsElement(rootElement, target) && (lastFocusedRef.current = target);
|
|
3078
3060
|
},
|
|
@@ -3102,8 +3084,7 @@ function usePortal() {
|
|
|
3102
3084
|
return value;
|
|
3103
3085
|
}
|
|
3104
3086
|
function Portal(props) {
|
|
3105
|
-
|
|
3106
|
-
const { children, __unstable_name: name } = props, portal = usePortal(), portalElement = (name ? portal.elements && portal.elements[name] : portal.element) || ((_a = portal.elements) == null ? void 0 : _a.default);
|
|
3087
|
+
const { children, __unstable_name: name } = props, portal = usePortal(), portalElement = (name ? portal.elements && portal.elements[name] : portal.element) || portal.elements?.default;
|
|
3107
3088
|
return portalElement ? reactDom.createPortal(children, portalElement) : null;
|
|
3108
3089
|
}
|
|
3109
3090
|
Portal.displayName = "Portal";
|
|
@@ -3243,7 +3224,7 @@ function calcMaxWidth(params) {
|
|
|
3243
3224
|
const { boundaryWidth, currentWidth } = params;
|
|
3244
3225
|
if (!(currentWidth === void 0 && boundaryWidth === void 0))
|
|
3245
3226
|
return Math.min(
|
|
3246
|
-
currentWidth
|
|
3227
|
+
currentWidth ?? 1 / 0,
|
|
3247
3228
|
(boundaryWidth || 1 / 0) - DEFAULT_POPOVER_PADDING * 2
|
|
3248
3229
|
);
|
|
3249
3230
|
}
|
|
@@ -3286,7 +3267,7 @@ const MotionCard$1 = styledComponents.styled(framerMotion.motion(Card))`
|
|
|
3286
3267
|
} = props, { zIndex } = useLayer(), margins = react.useMemo(
|
|
3287
3268
|
() => marginsProp || DEFAULT_POPOVER_MARGINS,
|
|
3288
3269
|
[marginsProp]
|
|
3289
|
-
), x = (xProp
|
|
3270
|
+
), x = (xProp ?? 0) + margins[3], y = (yProp ?? 0) + margins[0], rootStyle2 = react.useMemo(
|
|
3290
3271
|
() => ({
|
|
3291
3272
|
left: x,
|
|
3292
3273
|
originX,
|
|
@@ -3342,7 +3323,6 @@ const MotionCard$1 = styledComponents.styled(framerMotion.motion(Card))`
|
|
|
3342
3323
|
PopoverCard.displayName = "Memo(ForwardRef(PopoverCard))";
|
|
3343
3324
|
const Popover = react.memo(
|
|
3344
3325
|
react.forwardRef(function(props, forwardedRef) {
|
|
3345
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
3346
3326
|
const { container, layer } = useTheme_v2(), boundaryElementContext = useBoundaryElement(), {
|
|
3347
3327
|
__unstable_margins: margins = DEFAULT_POPOVER_MARGINS,
|
|
3348
3328
|
animate: _animate = !1,
|
|
@@ -3352,9 +3332,9 @@ const Popover = react.memo(
|
|
|
3352
3332
|
constrainSize = !1,
|
|
3353
3333
|
content,
|
|
3354
3334
|
disabled,
|
|
3355
|
-
fallbackPlacements =
|
|
3335
|
+
fallbackPlacements = props.fallbackPlacements ?? DEFAULT_FALLBACK_PLACEMENTS$1[props.placement ?? "bottom"],
|
|
3356
3336
|
matchReferenceWidth,
|
|
3357
|
-
floatingBoundary =
|
|
3337
|
+
floatingBoundary = props.boundaryElement ?? boundaryElementContext.element,
|
|
3358
3338
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3359
3339
|
onActivate,
|
|
3360
3340
|
open,
|
|
@@ -3364,7 +3344,7 @@ const Popover = react.memo(
|
|
|
3364
3344
|
portal,
|
|
3365
3345
|
preventOverflow = !0,
|
|
3366
3346
|
radius: radiusProp = 3,
|
|
3367
|
-
referenceBoundary =
|
|
3347
|
+
referenceBoundary = props.boundaryElement ?? boundaryElementContext.element,
|
|
3368
3348
|
referenceElement,
|
|
3369
3349
|
scheme,
|
|
3370
3350
|
shadow: shadowProp = 3,
|
|
@@ -3373,12 +3353,12 @@ const Popover = react.memo(
|
|
|
3373
3353
|
zOffset: zOffsetProp = layer.popover.zOffset,
|
|
3374
3354
|
updateRef,
|
|
3375
3355
|
...restProps
|
|
3376
|
-
} = props, animate = usePrefersReducedMotion() ? !1 : _animate, boundarySize =
|
|
3356
|
+
} = props, animate = usePrefersReducedMotion() ? !1 : _animate, boundarySize = useElementSize(boundaryElement)?.border, padding = useArrayProp(paddingProp), radius = useArrayProp(radiusProp), shadow = useArrayProp(shadowProp), widthArrayProp = useArrayProp(widthProp), zOffset = useArrayProp(zOffsetProp), ref = react.useRef(null), arrowRef = react.useRef(null), rootBoundary = "viewport";
|
|
3377
3357
|
react.useImperativeHandle(
|
|
3378
3358
|
forwardedRef,
|
|
3379
3359
|
() => ref.current
|
|
3380
3360
|
);
|
|
3381
|
-
const mediaIndex = useMediaIndex(), boundaryWidth = constrainSize || preventOverflow ? boundarySize
|
|
3361
|
+
const mediaIndex = useMediaIndex(), boundaryWidth = constrainSize || preventOverflow ? boundarySize?.width : void 0, width = calcCurrentWidth({
|
|
3382
3362
|
container,
|
|
3383
3363
|
mediaIndex,
|
|
3384
3364
|
width: widthArrayProp
|
|
@@ -3413,7 +3393,7 @@ const Popover = react.memo(
|
|
|
3413
3393
|
const _currentWidth = widthRef.current, _maxWidth = maxWidthRef.current;
|
|
3414
3394
|
matchReferenceWidth ? elements.floating.style.width = `${referenceWidth}px` : _currentWidth !== void 0 && (elements.floating.style.width = `${_currentWidth}px`), constrainSize && (elements.floating.style.maxWidth = `${Math.min(
|
|
3415
3395
|
availableWidth,
|
|
3416
|
-
_maxWidth
|
|
3396
|
+
_maxWidth ?? 1 / 0
|
|
3417
3397
|
)}px`, elements.floating.style.maxHeight = `${availableHeight}px`);
|
|
3418
3398
|
},
|
|
3419
3399
|
boundaryElement: floatingBoundary || void 0,
|
|
@@ -3454,7 +3434,7 @@ const Popover = react.memo(
|
|
|
3454
3434
|
middleware,
|
|
3455
3435
|
placement: placementProp,
|
|
3456
3436
|
whileElementsMounted: reactDom$1.autoUpdate
|
|
3457
|
-
}), referenceHidden =
|
|
3437
|
+
}), referenceHidden = middlewareData.hide?.referenceHidden, arrowX = middlewareData.arrow?.x, arrowY = middlewareData.arrow?.y, originX = middlewareData["@sanity/ui/origin"]?.originX, originY = middlewareData["@sanity/ui/origin"]?.originY, setArrow = react.useCallback((arrowEl) => {
|
|
3458
3438
|
arrowRef.current = arrowEl;
|
|
3459
3439
|
}, []), setFloating = react.useCallback(
|
|
3460
3440
|
(node) => {
|
|
@@ -3464,7 +3444,7 @@ const Popover = react.memo(
|
|
|
3464
3444
|
), setReference = react.useCallback(
|
|
3465
3445
|
(node) => {
|
|
3466
3446
|
refs.setReference(node);
|
|
3467
|
-
const childRef = childProp
|
|
3447
|
+
const childRef = getElementRef(childProp);
|
|
3468
3448
|
typeof childRef == "function" ? childRef(node) : childRef && (childRef.current = node);
|
|
3469
3449
|
},
|
|
3470
3450
|
[childProp, refs]
|
|
@@ -3524,6 +3504,10 @@ const Popover = react.memo(
|
|
|
3524
3504
|
})
|
|
3525
3505
|
);
|
|
3526
3506
|
Popover.displayName = "Memo(ForwardRef(Popover))";
|
|
3507
|
+
function getElementRef(element) {
|
|
3508
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
3509
|
+
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);
|
|
3510
|
+
}
|
|
3527
3511
|
function radioBaseStyle() {
|
|
3528
3512
|
return styledComponents.css`
|
|
3529
3513
|
position: relative;
|
|
@@ -4159,8 +4143,7 @@ const CLEAR_BUTTON_BOX_STYLE = { zIndex: 2 }, Root$b = styledComponents.styled(C
|
|
|
4159
4143
|
event.preventDefault(), event.stopPropagation();
|
|
4160
4144
|
}, []), handleClearClick = react.useCallback(
|
|
4161
4145
|
(event) => {
|
|
4162
|
-
|
|
4163
|
-
event.preventDefault(), event.stopPropagation(), onClear && onClear(), (_a = ref.current) == null || _a.focus();
|
|
4146
|
+
event.preventDefault(), event.stopPropagation(), onClear && onClear(), ref.current?.focus();
|
|
4164
4147
|
},
|
|
4165
4148
|
[onClear, ref]
|
|
4166
4149
|
), prefixNode = react.useMemo(
|
|
@@ -4388,7 +4371,7 @@ function useTooltipDelayGroup() {
|
|
|
4388
4371
|
return react.useContext(TooltipDelayGroupContext);
|
|
4389
4372
|
}
|
|
4390
4373
|
function TooltipDelayGroupProvider(props) {
|
|
4391
|
-
const { children, delay } = props, [isGroupActive, setIsGroupActive] = useDelayedState(!1), [openTooltipId, setOpenTooltipId] = useDelayedState(null), openDelay = typeof delay == "number" ? delay :
|
|
4374
|
+
const { children, delay } = props, [isGroupActive, setIsGroupActive] = useDelayedState(!1), [openTooltipId, setOpenTooltipId] = useDelayedState(null), openDelay = typeof delay == "number" ? delay : delay?.open || 0, closeDelay = typeof delay == "number" ? delay : delay?.close || 0, value = react.useMemo(
|
|
4392
4375
|
() => ({
|
|
4393
4376
|
isGroupActive,
|
|
4394
4377
|
setIsGroupActive,
|
|
@@ -4406,15 +4389,14 @@ TooltipDelayGroupProvider.displayName = "TooltipDelayGroupProvider";
|
|
|
4406
4389
|
const Root$a = styledComponents.styled(Layer)`
|
|
4407
4390
|
pointer-events: none;
|
|
4408
4391
|
`, Tooltip = react.forwardRef(function(props, forwardedRef) {
|
|
4409
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
4410
4392
|
const boundaryElementContext = useBoundaryElement(), { layer } = useTheme_v2(), {
|
|
4411
4393
|
animate: _animate = !1,
|
|
4412
4394
|
arrow: arrowProp = !1,
|
|
4413
|
-
boundaryElement = boundaryElementContext
|
|
4395
|
+
boundaryElement = boundaryElementContext?.element,
|
|
4414
4396
|
children: childProp,
|
|
4415
4397
|
content,
|
|
4416
4398
|
disabled,
|
|
4417
|
-
fallbackPlacements: fallbackPlacementsProp =
|
|
4399
|
+
fallbackPlacements: fallbackPlacementsProp = props.fallbackPlacements ?? DEFAULT_FALLBACK_PLACEMENTS[props.placement ?? "bottom"],
|
|
4418
4400
|
padding = 2,
|
|
4419
4401
|
placement: placementProp = "bottom",
|
|
4420
4402
|
portal: portalProp,
|
|
@@ -4426,7 +4408,7 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4426
4408
|
...restProps
|
|
4427
4409
|
} = props, animate = usePrefersReducedMotion() ? !1 : _animate, fallbackPlacements = useArrayProp(fallbackPlacementsProp), ref = react.useRef(null), [referenceElement, setReferenceElement] = react.useState(null), arrowRef = react.useRef(null), rootBoundary = "viewport", [tooltipMaxWidth, setTooltipMaxWidth] = react.useState(0);
|
|
4428
4410
|
react.useImperativeHandle(forwardedRef, () => ref.current);
|
|
4429
|
-
const portal = usePortal(), portalElement = typeof portalProp == "string" ?
|
|
4411
|
+
const portal = usePortal(), portalElement = typeof portalProp == "string" ? portal.elements?.[portalProp] || null : portal.element, middleware = react.useMemo(() => {
|
|
4430
4412
|
const ret = [];
|
|
4431
4413
|
return ret.push(
|
|
4432
4414
|
reactDom$1.flip({
|
|
@@ -4446,7 +4428,7 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4446
4428
|
middleware,
|
|
4447
4429
|
placement: placementProp,
|
|
4448
4430
|
whileElementsMounted: reactDom$1.autoUpdate
|
|
4449
|
-
}), arrowX =
|
|
4431
|
+
}), arrowX = middlewareData.arrow?.x, arrowY = middlewareData.arrow?.y, originX = middlewareData["@sanity/ui/origin"]?.originX, originY = middlewareData["@sanity/ui/origin"]?.originY, tooltipId = react.useId(), [isOpen, setIsOpen] = useDelayedState(!1), delayGroupContext = useTooltipDelayGroup(), showTooltip = isOpen || delayGroupContext?.openTooltipId === tooltipId, isInsideGroup = delayGroupContext !== null, openDelayProp = typeof delay == "number" ? delay : delay?.open || 0, closeDelayProp = typeof delay == "number" ? delay : delay?.close || 0, openDelay = isInsideGroup ? delayGroupContext.openDelay : openDelayProp, closeDelay = isInsideGroup ? delayGroupContext.closeDelay : closeDelayProp, handleIsOpenChange = react.useCallback(
|
|
4450
4432
|
(open, immediate) => {
|
|
4451
4433
|
if (isInsideGroup)
|
|
4452
4434
|
if (open) {
|
|
@@ -4462,40 +4444,34 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4462
4444
|
[isInsideGroup, delayGroupContext, openDelay, tooltipId, closeDelay, setIsOpen]
|
|
4463
4445
|
), handleBlur = react.useCallback(
|
|
4464
4446
|
(e) => {
|
|
4465
|
-
|
|
4466
|
-
handleIsOpenChange(!1), (_b2 = (_a2 = childProp == null ? void 0 : childProp.props) == null ? void 0 : _a2.onBlur) == null || _b2.call(_a2, e);
|
|
4447
|
+
handleIsOpenChange(!1), childProp?.props?.onBlur?.(e);
|
|
4467
4448
|
},
|
|
4468
|
-
[childProp
|
|
4449
|
+
[childProp?.props, handleIsOpenChange]
|
|
4469
4450
|
), handleClick = react.useCallback(
|
|
4470
4451
|
(e) => {
|
|
4471
|
-
|
|
4472
|
-
handleIsOpenChange(!1, !0), (_b2 = childProp == null ? void 0 : (_a2 = childProp.props).onClick) == null || _b2.call(_a2, e);
|
|
4452
|
+
handleIsOpenChange(!1, !0), childProp?.props.onClick?.(e);
|
|
4473
4453
|
},
|
|
4474
|
-
[childProp
|
|
4454
|
+
[childProp?.props, handleIsOpenChange]
|
|
4475
4455
|
), handleContextMenu = react.useCallback(
|
|
4476
4456
|
(e) => {
|
|
4477
|
-
|
|
4478
|
-
handleIsOpenChange(!1, !0), (_b2 = childProp == null ? void 0 : (_a2 = childProp.props).onContextMenu) == null || _b2.call(_a2, e);
|
|
4457
|
+
handleIsOpenChange(!1, !0), childProp?.props.onContextMenu?.(e);
|
|
4479
4458
|
},
|
|
4480
|
-
[childProp
|
|
4459
|
+
[childProp?.props, handleIsOpenChange]
|
|
4481
4460
|
), handleFocus = react.useCallback(
|
|
4482
4461
|
(e) => {
|
|
4483
|
-
|
|
4484
|
-
handleIsOpenChange(!0), (_b2 = (_a2 = childProp == null ? void 0 : childProp.props) == null ? void 0 : _a2.onFocus) == null || _b2.call(_a2, e);
|
|
4462
|
+
handleIsOpenChange(!0), childProp?.props?.onFocus?.(e);
|
|
4485
4463
|
},
|
|
4486
|
-
[childProp
|
|
4464
|
+
[childProp?.props, handleIsOpenChange]
|
|
4487
4465
|
), handleMouseEnter = react.useCallback(
|
|
4488
4466
|
(e) => {
|
|
4489
|
-
|
|
4490
|
-
handleIsOpenChange(!0), (_b2 = (_a2 = childProp == null ? void 0 : childProp.props) == null ? void 0 : _a2.onMouseEnter) == null || _b2.call(_a2, e);
|
|
4467
|
+
handleIsOpenChange(!0), childProp?.props?.onMouseEnter?.(e);
|
|
4491
4468
|
},
|
|
4492
|
-
[childProp
|
|
4469
|
+
[childProp?.props, handleIsOpenChange]
|
|
4493
4470
|
), handleMouseLeave = react.useCallback(
|
|
4494
4471
|
(e) => {
|
|
4495
|
-
|
|
4496
|
-
handleIsOpenChange(!1), (_b2 = (_a2 = childProp == null ? void 0 : childProp.props) == null ? void 0 : _a2.onMouseLeave) == null || _b2.call(_a2, e);
|
|
4472
|
+
handleIsOpenChange(!1), childProp?.props?.onMouseLeave?.(e);
|
|
4497
4473
|
},
|
|
4498
|
-
[childProp
|
|
4474
|
+
[childProp?.props, handleIsOpenChange]
|
|
4499
4475
|
);
|
|
4500
4476
|
useCloseOnMouseLeave({ handleIsOpenChange, referenceElement, showTooltip }), react.useEffect(() => {
|
|
4501
4477
|
disabled && showTooltip && handleIsOpenChange(!1);
|
|
@@ -4512,7 +4488,7 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4512
4488
|
}, [handleIsOpenChange, showTooltip]), react.useLayoutEffect(() => {
|
|
4513
4489
|
const availableWidths = [
|
|
4514
4490
|
...boundaryElement ? [boundaryElement.offsetWidth] : [],
|
|
4515
|
-
|
|
4491
|
+
portalElement?.offsetWidth || document.body.offsetWidth
|
|
4516
4492
|
];
|
|
4517
4493
|
setTooltipMaxWidth(Math.min(...availableWidths) - DEFAULT_TOOLTIP_PADDING * 2);
|
|
4518
4494
|
}, [boundaryElement, portalElement]);
|
|
@@ -4527,7 +4503,7 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4527
4503
|
},
|
|
4528
4504
|
[refs]
|
|
4529
4505
|
), childRef = react.useRef(null);
|
|
4530
|
-
react.useImperativeHandle(childProp
|
|
4506
|
+
react.useImperativeHandle(childProp?.ref, () => childRef.current);
|
|
4531
4507
|
const child = react.useMemo(() => childProp ? react.cloneElement(childProp, {
|
|
4532
4508
|
onBlur: handleBlur,
|
|
4533
4509
|
onFocus: handleFocus,
|
|
@@ -4750,17 +4726,15 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
|
|
|
4750
4726
|
},
|
|
4751
4727
|
[onBlur, onQueryChange, relatedElements]
|
|
4752
4728
|
), handleRootFocus = react.useCallback((event) => {
|
|
4753
|
-
const listBoxElement = listBoxElementRef.current, focusedElement = event.target instanceof HTMLElement ? event.target : null, listFocused2 =
|
|
4729
|
+
const listBoxElement = listBoxElementRef.current, focusedElement = event.target instanceof HTMLElement ? event.target : null, listFocused2 = listBoxElement?.contains(focusedElement) || !1;
|
|
4754
4730
|
listFocused2 !== listFocusedRef.current && (listFocusedRef.current = listFocused2, dispatch({ type: "root/setListFocused", listFocused: listFocused2 }));
|
|
4755
4731
|
}, []), handleOptionSelect = react.useCallback(
|
|
4756
4732
|
(v) => {
|
|
4757
|
-
|
|
4758
|
-
dispatch({ type: "value/change", value: v }), popoverMouseWithinRef.current = !1, onSelect && onSelect(v), valueRef.current = v, onChange && onChange(v), onQueryChange && onQueryChange(null), (_a = inputElementRef.current) == null || _a.focus();
|
|
4733
|
+
dispatch({ type: "value/change", value: v }), popoverMouseWithinRef.current = !1, onSelect && onSelect(v), valueRef.current = v, onChange && onChange(v), onQueryChange && onQueryChange(null), inputElementRef.current?.focus();
|
|
4759
4734
|
},
|
|
4760
4735
|
[onChange, onSelect, onQueryChange]
|
|
4761
4736
|
), handleRootKeyDown = react.useCallback(
|
|
4762
4737
|
(event) => {
|
|
4763
|
-
var _a, _b;
|
|
4764
4738
|
if (event.key === "ArrowDown") {
|
|
4765
4739
|
if (event.preventDefault(), !filteredOptionsLen) return;
|
|
4766
4740
|
const activeOption = filteredOptions.find((o) => o.value === activeValue), activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1, nextActiveOption = filteredOptions[(activeIndex + 1) % filteredOptionsLen];
|
|
@@ -4774,12 +4748,12 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
|
|
|
4774
4748
|
return;
|
|
4775
4749
|
}
|
|
4776
4750
|
if (event.key === "Escape") {
|
|
4777
|
-
dispatch({ type: "root/escape" }), popoverMouseWithinRef.current = !1, onQueryChange && onQueryChange(null),
|
|
4751
|
+
dispatch({ type: "root/escape" }), popoverMouseWithinRef.current = !1, onQueryChange && onQueryChange(null), inputElementRef.current?.focus();
|
|
4778
4752
|
return;
|
|
4779
4753
|
}
|
|
4780
4754
|
const target = event.target, listEl = listBoxElementRef.current;
|
|
4781
|
-
if ((listEl === target || listEl
|
|
4782
|
-
|
|
4755
|
+
if ((listEl === target || listEl?.contains(target)) && !AUTOCOMPLETE_LISTBOX_IGNORE_KEYS.includes(event.key)) {
|
|
4756
|
+
inputElementRef.current?.focus();
|
|
4783
4757
|
return;
|
|
4784
4758
|
}
|
|
4785
4759
|
},
|
|
@@ -4805,8 +4779,7 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
|
|
|
4805
4779
|
}, []), handlePopoverMouseLeave = react.useCallback(() => {
|
|
4806
4780
|
popoverMouseWithinRef.current = !1;
|
|
4807
4781
|
}, []), handleClearButtonClick = react.useCallback(() => {
|
|
4808
|
-
|
|
4809
|
-
dispatch({ type: "root/clear" }), valueRef.current = "", onChange && onChange(""), onQueryChange && onQueryChange(null), (_a = inputElementRef.current) == null || _a.focus();
|
|
4782
|
+
dispatch({ type: "root/clear" }), valueRef.current = "", onChange && onChange(""), onQueryChange && onQueryChange(null), inputElementRef.current?.focus();
|
|
4810
4783
|
}, [onChange, onQueryChange]), handleClearButtonFocus = react.useCallback(() => {
|
|
4811
4784
|
dispatch({ type: "input/focus" });
|
|
4812
4785
|
}, []);
|
|
@@ -4845,10 +4818,7 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
|
|
|
4845
4818
|
[openButton]
|
|
4846
4819
|
), handleOpenClick = react.useCallback(
|
|
4847
4820
|
(event) => {
|
|
4848
|
-
dispatchOpen(), openButtonProps.onClick && openButtonProps.onClick(event), _raf(() =>
|
|
4849
|
-
var _a;
|
|
4850
|
-
return (_a = inputElementRef.current) == null ? void 0 : _a.focus();
|
|
4851
|
-
});
|
|
4821
|
+
dispatchOpen(), openButtonProps.onClick && openButtonProps.onClick(event), _raf(() => inputElementRef.current?.focus());
|
|
4852
4822
|
},
|
|
4853
4823
|
[openButtonProps, dispatchOpen]
|
|
4854
4824
|
), openButtonNode = react.useMemo(
|
|
@@ -4911,8 +4881,7 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
|
|
|
4911
4881
|
}
|
|
4912
4882
|
), handleListBoxKeyDown = react.useCallback(
|
|
4913
4883
|
(event) => {
|
|
4914
|
-
|
|
4915
|
-
event.key === "Tab" && listFocused && ((_a = inputElementRef.current) == null || _a.focus());
|
|
4884
|
+
event.key === "Tab" && listFocused && inputElementRef.current?.focus();
|
|
4916
4885
|
},
|
|
4917
4886
|
[listFocused]
|
|
4918
4887
|
), content = react.useMemo(() => filteredOptions.length === 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -5167,7 +5136,6 @@ const Root$7 = styledComponents.styled(Layer)(responsivePaddingStyle, dialogStyl
|
|
|
5167
5136
|
position: relative;
|
|
5168
5137
|
z-index: 3;
|
|
5169
5138
|
`, DialogCard = react.forwardRef(function(props, forwardedRef) {
|
|
5170
|
-
var _a;
|
|
5171
5139
|
const {
|
|
5172
5140
|
__unstable_autoFocus: autoFocus,
|
|
5173
5141
|
__unstable_hideCloseButton: hideCloseButton,
|
|
@@ -5183,7 +5151,7 @@ const Root$7 = styledComponents.styled(Layer)(responsivePaddingStyle, dialogStyl
|
|
|
5183
5151
|
scheme,
|
|
5184
5152
|
shadow: shadowProp,
|
|
5185
5153
|
width: widthProp
|
|
5186
|
-
} = props, portal = usePortal(), portalElement = portalProp ?
|
|
5154
|
+
} = props, portal = usePortal(), portalElement = portalProp ? portal.elements?.[portalProp] || null : portal.element, boundaryElement = useBoundaryElement().element, radius = useArrayProp(radiusProp), shadow = useArrayProp(shadowProp), width = useArrayProp(widthProp), ref = react.useRef(null), contentRef = react.useRef(null), layer = useLayer(), { isTopLayer } = layer, labelId = `${id}_label`, showCloseButton = !!onClose && hideCloseButton === !1, showHeader = !!header || showCloseButton;
|
|
5187
5155
|
return react.useImperativeHandle(forwardedRef, () => ref.current), react.useImperativeHandle(
|
|
5188
5156
|
forwardedContentRef,
|
|
5189
5157
|
() => contentRef.current
|
|
@@ -5225,7 +5193,6 @@ const Root$7 = styledComponents.styled(Layer)(responsivePaddingStyle, dialogStyl
|
|
|
5225
5193
|
});
|
|
5226
5194
|
DialogCard.displayName = "ForwardRef(DialogCard)";
|
|
5227
5195
|
const Dialog = react.forwardRef(function(props, ref) {
|
|
5228
|
-
var _a;
|
|
5229
5196
|
const dialog = useDialog(), { layer } = useTheme_v2(), {
|
|
5230
5197
|
__unstable_autoFocus: autoFocus = !0,
|
|
5231
5198
|
__unstable_hideCloseButton: hideCloseButton = !1,
|
|
@@ -5248,9 +5215,9 @@ const Dialog = react.forwardRef(function(props, ref) {
|
|
|
5248
5215
|
zOffset: zOffsetProp = dialog.zOffset || layer.dialog.zOffset,
|
|
5249
5216
|
animate: _animate = !1,
|
|
5250
5217
|
...restProps
|
|
5251
|
-
} = props, animate = usePrefersReducedMotion() ? !1 : _animate, portal = usePortal(), portalElement = portalProp ?
|
|
5218
|
+
} = props, animate = usePrefersReducedMotion() ? !1 : _animate, portal = usePortal(), portalElement = portalProp ? portal.elements?.[portalProp] || null : portal.element, boundaryElement = useBoundaryElement().element, cardRadius = useArrayProp(cardRadiusProp), padding = useArrayProp(paddingProp), position = useArrayProp(positionProp), width = useArrayProp(widthProp), zOffset = useArrayProp(zOffsetProp), preDivRef = react.useRef(null), postDivRef = react.useRef(null), cardRef = react.useRef(null), focusedElementRef = react.useRef(null), handleFocus = react.useCallback(
|
|
5252
5219
|
(event) => {
|
|
5253
|
-
onFocus
|
|
5220
|
+
onFocus?.(event);
|
|
5254
5221
|
const target = event.target, cardElement = cardRef.current;
|
|
5255
5222
|
if (cardElement && target === preDivRef.current) {
|
|
5256
5223
|
focusLastDescendant(cardElement);
|
|
@@ -5461,8 +5428,7 @@ function useMenuController(props) {
|
|
|
5461
5428
|
},
|
|
5462
5429
|
[setActiveIndex]
|
|
5463
5430
|
), handleItemMouseLeave = react.useCallback(() => {
|
|
5464
|
-
|
|
5465
|
-
setActiveIndex(-2), (_a = rootElementRef.current) == null || _a.focus();
|
|
5431
|
+
setActiveIndex(-2), rootElementRef.current?.focus();
|
|
5466
5432
|
}, [rootElementRef, setActiveIndex]);
|
|
5467
5433
|
return react.useEffect(() => {
|
|
5468
5434
|
if (!mounted) return;
|
|
@@ -5484,8 +5450,7 @@ function useMenuController(props) {
|
|
|
5484
5450
|
}
|
|
5485
5451
|
return;
|
|
5486
5452
|
}
|
|
5487
|
-
|
|
5488
|
-
element == null || element.focus();
|
|
5453
|
+
(elementsRef.current[activeIndex] || null)?.focus();
|
|
5489
5454
|
});
|
|
5490
5455
|
return () => cancelAnimationFrame(rafId);
|
|
5491
5456
|
}, [activeIndex, mounted, setActiveIndex, shouldFocus]), {
|
|
@@ -5673,20 +5638,17 @@ const MenuButton = react.forwardRef(function(props, forwardedRef) {
|
|
|
5673
5638
|
shouldFocus
|
|
5674
5639
|
]
|
|
5675
5640
|
), menu = menuProp && react.cloneElement(menuProp, menuProps), ref = react.useRef(null), button = react.useMemo(
|
|
5676
|
-
() => {
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
|
|
5686
|
-
|
|
5687
|
-
selected: (_a = buttonProp.props.selected) != null ? _a : open
|
|
5688
|
-
});
|
|
5689
|
-
},
|
|
5641
|
+
() => buttonProp && react.cloneElement(buttonProp, {
|
|
5642
|
+
"data-ui": "MenuButton",
|
|
5643
|
+
id,
|
|
5644
|
+
onClick: handleButtonClick,
|
|
5645
|
+
onKeyDown: handleButtonKeyDown,
|
|
5646
|
+
onMouseDown: handleMouseDown,
|
|
5647
|
+
"aria-haspopup": !0,
|
|
5648
|
+
"aria-expanded": open,
|
|
5649
|
+
ref,
|
|
5650
|
+
selected: buttonProp.props.selected ?? open
|
|
5651
|
+
}),
|
|
5690
5652
|
[buttonProp, handleButtonClick, handleButtonKeyDown, handleMouseDown, id, open]
|
|
5691
5653
|
);
|
|
5692
5654
|
react.useImperativeHandle(
|
|
@@ -5751,7 +5713,6 @@ function selectableBaseStyle() {
|
|
|
5751
5713
|
`;
|
|
5752
5714
|
}
|
|
5753
5715
|
function selectableColorStyle(props) {
|
|
5754
|
-
var _a;
|
|
5755
5716
|
const { $tone } = props, { color, style } = theme.getTheme_v2(props.theme), tone = color.selectable[$tone];
|
|
5756
5717
|
return styledComponents.css`
|
|
5757
5718
|
${_cardColorStyle(color, tone.enabled)}
|
|
@@ -5820,7 +5781,7 @@ function selectableColorStyle(props) {
|
|
|
5820
5781
|
}
|
|
5821
5782
|
}
|
|
5822
5783
|
|
|
5823
|
-
${
|
|
5784
|
+
${style?.card?.root}
|
|
5824
5785
|
`;
|
|
5825
5786
|
}
|
|
5826
5787
|
const Selectable = styledComponents.styled(Box)(
|
|
@@ -5867,17 +5828,17 @@ function MenuGroup(props) {
|
|
|
5867
5828
|
), handleMenuKeyDown = react.useCallback(
|
|
5868
5829
|
(event) => {
|
|
5869
5830
|
event.key === "ArrowLeft" && (event.stopPropagation(), setOpen(!1), requestAnimationFrame(() => {
|
|
5870
|
-
rootElement
|
|
5831
|
+
rootElement?.focus();
|
|
5871
5832
|
}));
|
|
5872
5833
|
},
|
|
5873
5834
|
[rootElement]
|
|
5874
5835
|
), handleClick = react.useCallback(
|
|
5875
5836
|
(event) => {
|
|
5876
|
-
onClick
|
|
5837
|
+
onClick?.(event), setShouldFocus("first"), setOpen(!0);
|
|
5877
5838
|
},
|
|
5878
5839
|
[onClick]
|
|
5879
5840
|
), handleChildItemClick = react.useCallback(() => {
|
|
5880
|
-
setOpen(!1), onItemClick
|
|
5841
|
+
setOpen(!1), onItemClick?.();
|
|
5881
5842
|
}, [onItemClick]), handleMenuMouseEnter = react.useCallback(() => setWithinMenu(!0), []);
|
|
5882
5843
|
react.useEffect(() => mount(rootElement), [mount, rootElement]), react.useEffect(() => {
|
|
5883
5844
|
active || setOpen(!1);
|
|
@@ -6380,8 +6341,7 @@ function ToastProvider(props) {
|
|
|
6380
6341
|
[prefersReducedMotion]
|
|
6381
6342
|
), value = react.useMemo(() => ({ version: 0, push: (params) => {
|
|
6382
6343
|
const setState = (state2) => react.startTransition(() => _setState(state2)), id = params.id || String(toastId++), duration = params.duration || 5e3, dismiss = () => {
|
|
6383
|
-
|
|
6384
|
-
const timeoutId = (_a = toastsRef.current[id]) == null ? void 0 : _a.timeoutId;
|
|
6344
|
+
const timeoutId = toastsRef.current[id]?.timeoutId;
|
|
6385
6345
|
setState((prevState) => {
|
|
6386
6346
|
const idx = prevState.findIndex((t) => t.id === id);
|
|
6387
6347
|
if (idx > -1) {
|
|
@@ -6443,7 +6403,6 @@ function useToast() {
|
|
|
6443
6403
|
return value;
|
|
6444
6404
|
}
|
|
6445
6405
|
function _findPrevItemElement(state, itemElements, focusedElement) {
|
|
6446
|
-
var _a;
|
|
6447
6406
|
const idx = itemElements.indexOf(focusedElement), els = itemElements.slice(0, idx), len = els.length;
|
|
6448
6407
|
for (let i = len - 1; i >= 0; i -= 1) {
|
|
6449
6408
|
const itemKey = els[i].getAttribute("data-tree-key");
|
|
@@ -6456,7 +6415,7 @@ function _findPrevItemElement(state, itemElements, focusedElement) {
|
|
|
6456
6415
|
for (let j = 0; j < segments.length; j += 1) {
|
|
6457
6416
|
p.push(segments[j]);
|
|
6458
6417
|
const k = p.join("/");
|
|
6459
|
-
if (!
|
|
6418
|
+
if (!state[k]?.expanded) {
|
|
6460
6419
|
expanded = !1;
|
|
6461
6420
|
break;
|
|
6462
6421
|
}
|
|
@@ -6467,7 +6426,6 @@ function _findPrevItemElement(state, itemElements, focusedElement) {
|
|
|
6467
6426
|
return null;
|
|
6468
6427
|
}
|
|
6469
6428
|
function _findNextItemElement(state, itemElements, focusedElement) {
|
|
6470
|
-
var _a;
|
|
6471
6429
|
const idx = itemElements.indexOf(focusedElement), els = itemElements.slice(idx), len = itemElements.length;
|
|
6472
6430
|
for (let i = 1; i < len; i += 1) {
|
|
6473
6431
|
if (!els[i])
|
|
@@ -6482,7 +6440,7 @@ function _findNextItemElement(state, itemElements, focusedElement) {
|
|
|
6482
6440
|
for (let j = 0; j < segments.length; j += 1) {
|
|
6483
6441
|
p.push(segments[j]);
|
|
6484
6442
|
const k = p.join("/");
|
|
6485
|
-
if (!
|
|
6443
|
+
if (!state[k]?.expanded) {
|
|
6486
6444
|
expanded = !1;
|
|
6487
6445
|
break;
|
|
6488
6446
|
}
|
|
@@ -6540,7 +6498,6 @@ const TreeContext = createGlobalScopedContext(
|
|
|
6540
6498
|
[focusedElement, itemElements, path, registerItem, setExpanded, space, state]
|
|
6541
6499
|
), handleKeyDown = react.useCallback(
|
|
6542
6500
|
(event) => {
|
|
6543
|
-
var _a;
|
|
6544
6501
|
if (focusedElementRef.current) {
|
|
6545
6502
|
if (event.key === "ArrowDown") {
|
|
6546
6503
|
event.preventDefault();
|
|
@@ -6585,7 +6542,7 @@ const TreeContext = createGlobalScopedContext(
|
|
|
6585
6542
|
event.preventDefault();
|
|
6586
6543
|
const focusedKey = focusedElementRef.current.getAttribute("data-tree-key");
|
|
6587
6544
|
if (!focusedKey) return;
|
|
6588
|
-
|
|
6545
|
+
stateRef.current[focusedKey]?.expanded || setState((s) => {
|
|
6589
6546
|
const itemState = s[focusedKey];
|
|
6590
6547
|
return itemState ? { ...s, [focusedKey]: { ...itemState, expanded: !0 } } : s;
|
|
6591
6548
|
});
|
|
@@ -6596,7 +6553,7 @@ const TreeContext = createGlobalScopedContext(
|
|
|
6596
6553
|
[itemElements]
|
|
6597
6554
|
), handleFocus = react.useCallback(
|
|
6598
6555
|
(event) => {
|
|
6599
|
-
setFocusedElement(event.target), onFocus
|
|
6556
|
+
setFocusedElement(event.target), onFocus?.(event);
|
|
6600
6557
|
},
|
|
6601
6558
|
[onFocus]
|
|
6602
6559
|
);
|
|
@@ -6751,7 +6708,7 @@ const TreeGroup = react.memo(function(props) {
|
|
|
6751
6708
|
text,
|
|
6752
6709
|
weight,
|
|
6753
6710
|
...restProps
|
|
6754
|
-
} = props, rootRef = react.useRef(null), treeitemRef = react.useRef(null), tree = useTree(), { path, registerItem, setExpanded, setFocusedElement } = tree, _id = react.useId(), id = idProp || _id, itemPath = react.useMemo(() => path.concat([id || ""]), [id, path]), itemKey = itemPath.join("/"), itemState = tree.state[itemKey], focused = tree.focusedElement === rootRef.current, expanded =
|
|
6711
|
+
} = props, rootRef = react.useRef(null), treeitemRef = react.useRef(null), tree = useTree(), { path, registerItem, setExpanded, setFocusedElement } = tree, _id = react.useId(), id = idProp || _id, itemPath = react.useMemo(() => path.concat([id || ""]), [id, path]), itemKey = itemPath.join("/"), itemState = tree.state[itemKey], focused = tree.focusedElement === rootRef.current, expanded = itemState?.expanded === void 0 ? expandedProp : itemState?.expanded || !1, tabIndex = tree.focusedElement && tree.focusedElement === rootRef.current ? 0 : -1, contextValue = react.useMemo(
|
|
6755
6712
|
() => ({ ...tree, level: tree.level + 1, path: itemPath }),
|
|
6756
6713
|
[itemPath, tree]
|
|
6757
6714
|
), handleClick = react.useCallback(
|
|
@@ -6763,10 +6720,7 @@ const TreeGroup = react.memo(function(props) {
|
|
|
6763
6720
|
[expanded, itemKey, onClick, setExpanded, setFocusedElement]
|
|
6764
6721
|
), handleKeyDown = react.useCallback(
|
|
6765
6722
|
(event) => {
|
|
6766
|
-
|
|
6767
|
-
const el = treeitemRef.current || rootRef.current;
|
|
6768
|
-
el == null || el.click();
|
|
6769
|
-
}
|
|
6723
|
+
focused && event.key === "Enter" && (treeitemRef.current || rootRef.current)?.click();
|
|
6770
6724
|
},
|
|
6771
6725
|
[focused]
|
|
6772
6726
|
);
|