@sanity/ui 2.8.8 → 2.8.9
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 +94 -144
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +94 -144
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +94 -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 +32 -32
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 = childProp?.ref;
|
|
3468
3448
|
typeof childRef == "function" ? childRef(node) : childRef && (childRef.current = node);
|
|
3469
3449
|
},
|
|
3470
3450
|
[childProp, refs]
|
|
@@ -4159,8 +4139,7 @@ const CLEAR_BUTTON_BOX_STYLE = { zIndex: 2 }, Root$b = styledComponents.styled(C
|
|
|
4159
4139
|
event.preventDefault(), event.stopPropagation();
|
|
4160
4140
|
}, []), handleClearClick = react.useCallback(
|
|
4161
4141
|
(event) => {
|
|
4162
|
-
|
|
4163
|
-
event.preventDefault(), event.stopPropagation(), onClear && onClear(), (_a = ref.current) == null || _a.focus();
|
|
4142
|
+
event.preventDefault(), event.stopPropagation(), onClear && onClear(), ref.current?.focus();
|
|
4164
4143
|
},
|
|
4165
4144
|
[onClear, ref]
|
|
4166
4145
|
), prefixNode = react.useMemo(
|
|
@@ -4388,7 +4367,7 @@ function useTooltipDelayGroup() {
|
|
|
4388
4367
|
return react.useContext(TooltipDelayGroupContext);
|
|
4389
4368
|
}
|
|
4390
4369
|
function TooltipDelayGroupProvider(props) {
|
|
4391
|
-
const { children, delay } = props, [isGroupActive, setIsGroupActive] = useDelayedState(!1), [openTooltipId, setOpenTooltipId] = useDelayedState(null), openDelay = typeof delay == "number" ? delay :
|
|
4370
|
+
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
4371
|
() => ({
|
|
4393
4372
|
isGroupActive,
|
|
4394
4373
|
setIsGroupActive,
|
|
@@ -4406,15 +4385,14 @@ TooltipDelayGroupProvider.displayName = "TooltipDelayGroupProvider";
|
|
|
4406
4385
|
const Root$a = styledComponents.styled(Layer)`
|
|
4407
4386
|
pointer-events: none;
|
|
4408
4387
|
`, Tooltip = react.forwardRef(function(props, forwardedRef) {
|
|
4409
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
4410
4388
|
const boundaryElementContext = useBoundaryElement(), { layer } = useTheme_v2(), {
|
|
4411
4389
|
animate: _animate = !1,
|
|
4412
4390
|
arrow: arrowProp = !1,
|
|
4413
|
-
boundaryElement = boundaryElementContext
|
|
4391
|
+
boundaryElement = boundaryElementContext?.element,
|
|
4414
4392
|
children: childProp,
|
|
4415
4393
|
content,
|
|
4416
4394
|
disabled,
|
|
4417
|
-
fallbackPlacements: fallbackPlacementsProp =
|
|
4395
|
+
fallbackPlacements: fallbackPlacementsProp = props.fallbackPlacements ?? DEFAULT_FALLBACK_PLACEMENTS[props.placement ?? "bottom"],
|
|
4418
4396
|
padding = 2,
|
|
4419
4397
|
placement: placementProp = "bottom",
|
|
4420
4398
|
portal: portalProp,
|
|
@@ -4426,7 +4404,7 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4426
4404
|
...restProps
|
|
4427
4405
|
} = 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
4406
|
react.useImperativeHandle(forwardedRef, () => ref.current);
|
|
4429
|
-
const portal = usePortal(), portalElement = typeof portalProp == "string" ?
|
|
4407
|
+
const portal = usePortal(), portalElement = typeof portalProp == "string" ? portal.elements?.[portalProp] || null : portal.element, middleware = react.useMemo(() => {
|
|
4430
4408
|
const ret = [];
|
|
4431
4409
|
return ret.push(
|
|
4432
4410
|
reactDom$1.flip({
|
|
@@ -4446,7 +4424,7 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4446
4424
|
middleware,
|
|
4447
4425
|
placement: placementProp,
|
|
4448
4426
|
whileElementsMounted: reactDom$1.autoUpdate
|
|
4449
|
-
}), arrowX =
|
|
4427
|
+
}), 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
4428
|
(open, immediate) => {
|
|
4451
4429
|
if (isInsideGroup)
|
|
4452
4430
|
if (open) {
|
|
@@ -4462,40 +4440,34 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4462
4440
|
[isInsideGroup, delayGroupContext, openDelay, tooltipId, closeDelay, setIsOpen]
|
|
4463
4441
|
), handleBlur = react.useCallback(
|
|
4464
4442
|
(e) => {
|
|
4465
|
-
|
|
4466
|
-
handleIsOpenChange(!1), (_b2 = (_a2 = childProp == null ? void 0 : childProp.props) == null ? void 0 : _a2.onBlur) == null || _b2.call(_a2, e);
|
|
4443
|
+
handleIsOpenChange(!1), childProp?.props?.onBlur?.(e);
|
|
4467
4444
|
},
|
|
4468
|
-
[childProp
|
|
4445
|
+
[childProp?.props, handleIsOpenChange]
|
|
4469
4446
|
), handleClick = react.useCallback(
|
|
4470
4447
|
(e) => {
|
|
4471
|
-
|
|
4472
|
-
handleIsOpenChange(!1, !0), (_b2 = childProp == null ? void 0 : (_a2 = childProp.props).onClick) == null || _b2.call(_a2, e);
|
|
4448
|
+
handleIsOpenChange(!1, !0), childProp?.props.onClick?.(e);
|
|
4473
4449
|
},
|
|
4474
|
-
[childProp
|
|
4450
|
+
[childProp?.props, handleIsOpenChange]
|
|
4475
4451
|
), handleContextMenu = react.useCallback(
|
|
4476
4452
|
(e) => {
|
|
4477
|
-
|
|
4478
|
-
handleIsOpenChange(!1, !0), (_b2 = childProp == null ? void 0 : (_a2 = childProp.props).onContextMenu) == null || _b2.call(_a2, e);
|
|
4453
|
+
handleIsOpenChange(!1, !0), childProp?.props.onContextMenu?.(e);
|
|
4479
4454
|
},
|
|
4480
|
-
[childProp
|
|
4455
|
+
[childProp?.props, handleIsOpenChange]
|
|
4481
4456
|
), handleFocus = react.useCallback(
|
|
4482
4457
|
(e) => {
|
|
4483
|
-
|
|
4484
|
-
handleIsOpenChange(!0), (_b2 = (_a2 = childProp == null ? void 0 : childProp.props) == null ? void 0 : _a2.onFocus) == null || _b2.call(_a2, e);
|
|
4458
|
+
handleIsOpenChange(!0), childProp?.props?.onFocus?.(e);
|
|
4485
4459
|
},
|
|
4486
|
-
[childProp
|
|
4460
|
+
[childProp?.props, handleIsOpenChange]
|
|
4487
4461
|
), handleMouseEnter = react.useCallback(
|
|
4488
4462
|
(e) => {
|
|
4489
|
-
|
|
4490
|
-
handleIsOpenChange(!0), (_b2 = (_a2 = childProp == null ? void 0 : childProp.props) == null ? void 0 : _a2.onMouseEnter) == null || _b2.call(_a2, e);
|
|
4463
|
+
handleIsOpenChange(!0), childProp?.props?.onMouseEnter?.(e);
|
|
4491
4464
|
},
|
|
4492
|
-
[childProp
|
|
4465
|
+
[childProp?.props, handleIsOpenChange]
|
|
4493
4466
|
), handleMouseLeave = react.useCallback(
|
|
4494
4467
|
(e) => {
|
|
4495
|
-
|
|
4496
|
-
handleIsOpenChange(!1), (_b2 = (_a2 = childProp == null ? void 0 : childProp.props) == null ? void 0 : _a2.onMouseLeave) == null || _b2.call(_a2, e);
|
|
4468
|
+
handleIsOpenChange(!1), childProp?.props?.onMouseLeave?.(e);
|
|
4497
4469
|
},
|
|
4498
|
-
[childProp
|
|
4470
|
+
[childProp?.props, handleIsOpenChange]
|
|
4499
4471
|
);
|
|
4500
4472
|
useCloseOnMouseLeave({ handleIsOpenChange, referenceElement, showTooltip }), react.useEffect(() => {
|
|
4501
4473
|
disabled && showTooltip && handleIsOpenChange(!1);
|
|
@@ -4512,7 +4484,7 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4512
4484
|
}, [handleIsOpenChange, showTooltip]), react.useLayoutEffect(() => {
|
|
4513
4485
|
const availableWidths = [
|
|
4514
4486
|
...boundaryElement ? [boundaryElement.offsetWidth] : [],
|
|
4515
|
-
|
|
4487
|
+
portalElement?.offsetWidth || document.body.offsetWidth
|
|
4516
4488
|
];
|
|
4517
4489
|
setTooltipMaxWidth(Math.min(...availableWidths) - DEFAULT_TOOLTIP_PADDING * 2);
|
|
4518
4490
|
}, [boundaryElement, portalElement]);
|
|
@@ -4527,7 +4499,7 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4527
4499
|
},
|
|
4528
4500
|
[refs]
|
|
4529
4501
|
), childRef = react.useRef(null);
|
|
4530
|
-
react.useImperativeHandle(childProp
|
|
4502
|
+
react.useImperativeHandle(childProp?.ref, () => childRef.current);
|
|
4531
4503
|
const child = react.useMemo(() => childProp ? react.cloneElement(childProp, {
|
|
4532
4504
|
onBlur: handleBlur,
|
|
4533
4505
|
onFocus: handleFocus,
|
|
@@ -4750,17 +4722,15 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
|
|
|
4750
4722
|
},
|
|
4751
4723
|
[onBlur, onQueryChange, relatedElements]
|
|
4752
4724
|
), handleRootFocus = react.useCallback((event) => {
|
|
4753
|
-
const listBoxElement = listBoxElementRef.current, focusedElement = event.target instanceof HTMLElement ? event.target : null, listFocused2 =
|
|
4725
|
+
const listBoxElement = listBoxElementRef.current, focusedElement = event.target instanceof HTMLElement ? event.target : null, listFocused2 = listBoxElement?.contains(focusedElement) || !1;
|
|
4754
4726
|
listFocused2 !== listFocusedRef.current && (listFocusedRef.current = listFocused2, dispatch({ type: "root/setListFocused", listFocused: listFocused2 }));
|
|
4755
4727
|
}, []), handleOptionSelect = react.useCallback(
|
|
4756
4728
|
(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();
|
|
4729
|
+
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
4730
|
},
|
|
4760
4731
|
[onChange, onSelect, onQueryChange]
|
|
4761
4732
|
), handleRootKeyDown = react.useCallback(
|
|
4762
4733
|
(event) => {
|
|
4763
|
-
var _a, _b;
|
|
4764
4734
|
if (event.key === "ArrowDown") {
|
|
4765
4735
|
if (event.preventDefault(), !filteredOptionsLen) return;
|
|
4766
4736
|
const activeOption = filteredOptions.find((o) => o.value === activeValue), activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1, nextActiveOption = filteredOptions[(activeIndex + 1) % filteredOptionsLen];
|
|
@@ -4774,12 +4744,12 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
|
|
|
4774
4744
|
return;
|
|
4775
4745
|
}
|
|
4776
4746
|
if (event.key === "Escape") {
|
|
4777
|
-
dispatch({ type: "root/escape" }), popoverMouseWithinRef.current = !1, onQueryChange && onQueryChange(null),
|
|
4747
|
+
dispatch({ type: "root/escape" }), popoverMouseWithinRef.current = !1, onQueryChange && onQueryChange(null), inputElementRef.current?.focus();
|
|
4778
4748
|
return;
|
|
4779
4749
|
}
|
|
4780
4750
|
const target = event.target, listEl = listBoxElementRef.current;
|
|
4781
|
-
if ((listEl === target || listEl
|
|
4782
|
-
|
|
4751
|
+
if ((listEl === target || listEl?.contains(target)) && !AUTOCOMPLETE_LISTBOX_IGNORE_KEYS.includes(event.key)) {
|
|
4752
|
+
inputElementRef.current?.focus();
|
|
4783
4753
|
return;
|
|
4784
4754
|
}
|
|
4785
4755
|
},
|
|
@@ -4805,8 +4775,7 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
|
|
|
4805
4775
|
}, []), handlePopoverMouseLeave = react.useCallback(() => {
|
|
4806
4776
|
popoverMouseWithinRef.current = !1;
|
|
4807
4777
|
}, []), handleClearButtonClick = react.useCallback(() => {
|
|
4808
|
-
|
|
4809
|
-
dispatch({ type: "root/clear" }), valueRef.current = "", onChange && onChange(""), onQueryChange && onQueryChange(null), (_a = inputElementRef.current) == null || _a.focus();
|
|
4778
|
+
dispatch({ type: "root/clear" }), valueRef.current = "", onChange && onChange(""), onQueryChange && onQueryChange(null), inputElementRef.current?.focus();
|
|
4810
4779
|
}, [onChange, onQueryChange]), handleClearButtonFocus = react.useCallback(() => {
|
|
4811
4780
|
dispatch({ type: "input/focus" });
|
|
4812
4781
|
}, []);
|
|
@@ -4845,10 +4814,7 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
|
|
|
4845
4814
|
[openButton]
|
|
4846
4815
|
), handleOpenClick = react.useCallback(
|
|
4847
4816
|
(event) => {
|
|
4848
|
-
dispatchOpen(), openButtonProps.onClick && openButtonProps.onClick(event), _raf(() =>
|
|
4849
|
-
var _a;
|
|
4850
|
-
return (_a = inputElementRef.current) == null ? void 0 : _a.focus();
|
|
4851
|
-
});
|
|
4817
|
+
dispatchOpen(), openButtonProps.onClick && openButtonProps.onClick(event), _raf(() => inputElementRef.current?.focus());
|
|
4852
4818
|
},
|
|
4853
4819
|
[openButtonProps, dispatchOpen]
|
|
4854
4820
|
), openButtonNode = react.useMemo(
|
|
@@ -4911,8 +4877,7 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
|
|
|
4911
4877
|
}
|
|
4912
4878
|
), handleListBoxKeyDown = react.useCallback(
|
|
4913
4879
|
(event) => {
|
|
4914
|
-
|
|
4915
|
-
event.key === "Tab" && listFocused && ((_a = inputElementRef.current) == null || _a.focus());
|
|
4880
|
+
event.key === "Tab" && listFocused && inputElementRef.current?.focus();
|
|
4916
4881
|
},
|
|
4917
4882
|
[listFocused]
|
|
4918
4883
|
), content = react.useMemo(() => filteredOptions.length === 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -5167,7 +5132,6 @@ const Root$7 = styledComponents.styled(Layer)(responsivePaddingStyle, dialogStyl
|
|
|
5167
5132
|
position: relative;
|
|
5168
5133
|
z-index: 3;
|
|
5169
5134
|
`, DialogCard = react.forwardRef(function(props, forwardedRef) {
|
|
5170
|
-
var _a;
|
|
5171
5135
|
const {
|
|
5172
5136
|
__unstable_autoFocus: autoFocus,
|
|
5173
5137
|
__unstable_hideCloseButton: hideCloseButton,
|
|
@@ -5183,7 +5147,7 @@ const Root$7 = styledComponents.styled(Layer)(responsivePaddingStyle, dialogStyl
|
|
|
5183
5147
|
scheme,
|
|
5184
5148
|
shadow: shadowProp,
|
|
5185
5149
|
width: widthProp
|
|
5186
|
-
} = props, portal = usePortal(), portalElement = portalProp ?
|
|
5150
|
+
} = 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
5151
|
return react.useImperativeHandle(forwardedRef, () => ref.current), react.useImperativeHandle(
|
|
5188
5152
|
forwardedContentRef,
|
|
5189
5153
|
() => contentRef.current
|
|
@@ -5225,7 +5189,6 @@ const Root$7 = styledComponents.styled(Layer)(responsivePaddingStyle, dialogStyl
|
|
|
5225
5189
|
});
|
|
5226
5190
|
DialogCard.displayName = "ForwardRef(DialogCard)";
|
|
5227
5191
|
const Dialog = react.forwardRef(function(props, ref) {
|
|
5228
|
-
var _a;
|
|
5229
5192
|
const dialog = useDialog(), { layer } = useTheme_v2(), {
|
|
5230
5193
|
__unstable_autoFocus: autoFocus = !0,
|
|
5231
5194
|
__unstable_hideCloseButton: hideCloseButton = !1,
|
|
@@ -5248,9 +5211,9 @@ const Dialog = react.forwardRef(function(props, ref) {
|
|
|
5248
5211
|
zOffset: zOffsetProp = dialog.zOffset || layer.dialog.zOffset,
|
|
5249
5212
|
animate: _animate = !1,
|
|
5250
5213
|
...restProps
|
|
5251
|
-
} = props, animate = usePrefersReducedMotion() ? !1 : _animate, portal = usePortal(), portalElement = portalProp ?
|
|
5214
|
+
} = 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
5215
|
(event) => {
|
|
5253
|
-
onFocus
|
|
5216
|
+
onFocus?.(event);
|
|
5254
5217
|
const target = event.target, cardElement = cardRef.current;
|
|
5255
5218
|
if (cardElement && target === preDivRef.current) {
|
|
5256
5219
|
focusLastDescendant(cardElement);
|
|
@@ -5461,8 +5424,7 @@ function useMenuController(props) {
|
|
|
5461
5424
|
},
|
|
5462
5425
|
[setActiveIndex]
|
|
5463
5426
|
), handleItemMouseLeave = react.useCallback(() => {
|
|
5464
|
-
|
|
5465
|
-
setActiveIndex(-2), (_a = rootElementRef.current) == null || _a.focus();
|
|
5427
|
+
setActiveIndex(-2), rootElementRef.current?.focus();
|
|
5466
5428
|
}, [rootElementRef, setActiveIndex]);
|
|
5467
5429
|
return react.useEffect(() => {
|
|
5468
5430
|
if (!mounted) return;
|
|
@@ -5484,8 +5446,7 @@ function useMenuController(props) {
|
|
|
5484
5446
|
}
|
|
5485
5447
|
return;
|
|
5486
5448
|
}
|
|
5487
|
-
|
|
5488
|
-
element == null || element.focus();
|
|
5449
|
+
(elementsRef.current[activeIndex] || null)?.focus();
|
|
5489
5450
|
});
|
|
5490
5451
|
return () => cancelAnimationFrame(rafId);
|
|
5491
5452
|
}, [activeIndex, mounted, setActiveIndex, shouldFocus]), {
|
|
@@ -5673,20 +5634,17 @@ const MenuButton = react.forwardRef(function(props, forwardedRef) {
|
|
|
5673
5634
|
shouldFocus
|
|
5674
5635
|
]
|
|
5675
5636
|
), 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
|
-
},
|
|
5637
|
+
() => buttonProp && react.cloneElement(buttonProp, {
|
|
5638
|
+
"data-ui": "MenuButton",
|
|
5639
|
+
id,
|
|
5640
|
+
onClick: handleButtonClick,
|
|
5641
|
+
onKeyDown: handleButtonKeyDown,
|
|
5642
|
+
onMouseDown: handleMouseDown,
|
|
5643
|
+
"aria-haspopup": !0,
|
|
5644
|
+
"aria-expanded": open,
|
|
5645
|
+
ref,
|
|
5646
|
+
selected: buttonProp.props.selected ?? open
|
|
5647
|
+
}),
|
|
5690
5648
|
[buttonProp, handleButtonClick, handleButtonKeyDown, handleMouseDown, id, open]
|
|
5691
5649
|
);
|
|
5692
5650
|
react.useImperativeHandle(
|
|
@@ -5751,7 +5709,6 @@ function selectableBaseStyle() {
|
|
|
5751
5709
|
`;
|
|
5752
5710
|
}
|
|
5753
5711
|
function selectableColorStyle(props) {
|
|
5754
|
-
var _a;
|
|
5755
5712
|
const { $tone } = props, { color, style } = theme.getTheme_v2(props.theme), tone = color.selectable[$tone];
|
|
5756
5713
|
return styledComponents.css`
|
|
5757
5714
|
${_cardColorStyle(color, tone.enabled)}
|
|
@@ -5820,7 +5777,7 @@ function selectableColorStyle(props) {
|
|
|
5820
5777
|
}
|
|
5821
5778
|
}
|
|
5822
5779
|
|
|
5823
|
-
${
|
|
5780
|
+
${style?.card?.root}
|
|
5824
5781
|
`;
|
|
5825
5782
|
}
|
|
5826
5783
|
const Selectable = styledComponents.styled(Box)(
|
|
@@ -5867,17 +5824,17 @@ function MenuGroup(props) {
|
|
|
5867
5824
|
), handleMenuKeyDown = react.useCallback(
|
|
5868
5825
|
(event) => {
|
|
5869
5826
|
event.key === "ArrowLeft" && (event.stopPropagation(), setOpen(!1), requestAnimationFrame(() => {
|
|
5870
|
-
rootElement
|
|
5827
|
+
rootElement?.focus();
|
|
5871
5828
|
}));
|
|
5872
5829
|
},
|
|
5873
5830
|
[rootElement]
|
|
5874
5831
|
), handleClick = react.useCallback(
|
|
5875
5832
|
(event) => {
|
|
5876
|
-
onClick
|
|
5833
|
+
onClick?.(event), setShouldFocus("first"), setOpen(!0);
|
|
5877
5834
|
},
|
|
5878
5835
|
[onClick]
|
|
5879
5836
|
), handleChildItemClick = react.useCallback(() => {
|
|
5880
|
-
setOpen(!1), onItemClick
|
|
5837
|
+
setOpen(!1), onItemClick?.();
|
|
5881
5838
|
}, [onItemClick]), handleMenuMouseEnter = react.useCallback(() => setWithinMenu(!0), []);
|
|
5882
5839
|
react.useEffect(() => mount(rootElement), [mount, rootElement]), react.useEffect(() => {
|
|
5883
5840
|
active || setOpen(!1);
|
|
@@ -6380,8 +6337,7 @@ function ToastProvider(props) {
|
|
|
6380
6337
|
[prefersReducedMotion]
|
|
6381
6338
|
), value = react.useMemo(() => ({ version: 0, push: (params) => {
|
|
6382
6339
|
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;
|
|
6340
|
+
const timeoutId = toastsRef.current[id]?.timeoutId;
|
|
6385
6341
|
setState((prevState) => {
|
|
6386
6342
|
const idx = prevState.findIndex((t) => t.id === id);
|
|
6387
6343
|
if (idx > -1) {
|
|
@@ -6443,7 +6399,6 @@ function useToast() {
|
|
|
6443
6399
|
return value;
|
|
6444
6400
|
}
|
|
6445
6401
|
function _findPrevItemElement(state, itemElements, focusedElement) {
|
|
6446
|
-
var _a;
|
|
6447
6402
|
const idx = itemElements.indexOf(focusedElement), els = itemElements.slice(0, idx), len = els.length;
|
|
6448
6403
|
for (let i = len - 1; i >= 0; i -= 1) {
|
|
6449
6404
|
const itemKey = els[i].getAttribute("data-tree-key");
|
|
@@ -6456,7 +6411,7 @@ function _findPrevItemElement(state, itemElements, focusedElement) {
|
|
|
6456
6411
|
for (let j = 0; j < segments.length; j += 1) {
|
|
6457
6412
|
p.push(segments[j]);
|
|
6458
6413
|
const k = p.join("/");
|
|
6459
|
-
if (!
|
|
6414
|
+
if (!state[k]?.expanded) {
|
|
6460
6415
|
expanded = !1;
|
|
6461
6416
|
break;
|
|
6462
6417
|
}
|
|
@@ -6467,7 +6422,6 @@ function _findPrevItemElement(state, itemElements, focusedElement) {
|
|
|
6467
6422
|
return null;
|
|
6468
6423
|
}
|
|
6469
6424
|
function _findNextItemElement(state, itemElements, focusedElement) {
|
|
6470
|
-
var _a;
|
|
6471
6425
|
const idx = itemElements.indexOf(focusedElement), els = itemElements.slice(idx), len = itemElements.length;
|
|
6472
6426
|
for (let i = 1; i < len; i += 1) {
|
|
6473
6427
|
if (!els[i])
|
|
@@ -6482,7 +6436,7 @@ function _findNextItemElement(state, itemElements, focusedElement) {
|
|
|
6482
6436
|
for (let j = 0; j < segments.length; j += 1) {
|
|
6483
6437
|
p.push(segments[j]);
|
|
6484
6438
|
const k = p.join("/");
|
|
6485
|
-
if (!
|
|
6439
|
+
if (!state[k]?.expanded) {
|
|
6486
6440
|
expanded = !1;
|
|
6487
6441
|
break;
|
|
6488
6442
|
}
|
|
@@ -6540,7 +6494,6 @@ const TreeContext = createGlobalScopedContext(
|
|
|
6540
6494
|
[focusedElement, itemElements, path, registerItem, setExpanded, space, state]
|
|
6541
6495
|
), handleKeyDown = react.useCallback(
|
|
6542
6496
|
(event) => {
|
|
6543
|
-
var _a;
|
|
6544
6497
|
if (focusedElementRef.current) {
|
|
6545
6498
|
if (event.key === "ArrowDown") {
|
|
6546
6499
|
event.preventDefault();
|
|
@@ -6585,7 +6538,7 @@ const TreeContext = createGlobalScopedContext(
|
|
|
6585
6538
|
event.preventDefault();
|
|
6586
6539
|
const focusedKey = focusedElementRef.current.getAttribute("data-tree-key");
|
|
6587
6540
|
if (!focusedKey) return;
|
|
6588
|
-
|
|
6541
|
+
stateRef.current[focusedKey]?.expanded || setState((s) => {
|
|
6589
6542
|
const itemState = s[focusedKey];
|
|
6590
6543
|
return itemState ? { ...s, [focusedKey]: { ...itemState, expanded: !0 } } : s;
|
|
6591
6544
|
});
|
|
@@ -6596,7 +6549,7 @@ const TreeContext = createGlobalScopedContext(
|
|
|
6596
6549
|
[itemElements]
|
|
6597
6550
|
), handleFocus = react.useCallback(
|
|
6598
6551
|
(event) => {
|
|
6599
|
-
setFocusedElement(event.target), onFocus
|
|
6552
|
+
setFocusedElement(event.target), onFocus?.(event);
|
|
6600
6553
|
},
|
|
6601
6554
|
[onFocus]
|
|
6602
6555
|
);
|
|
@@ -6751,7 +6704,7 @@ const TreeGroup = react.memo(function(props) {
|
|
|
6751
6704
|
text,
|
|
6752
6705
|
weight,
|
|
6753
6706
|
...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 =
|
|
6707
|
+
} = 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
6708
|
() => ({ ...tree, level: tree.level + 1, path: itemPath }),
|
|
6756
6709
|
[itemPath, tree]
|
|
6757
6710
|
), handleClick = react.useCallback(
|
|
@@ -6763,10 +6716,7 @@ const TreeGroup = react.memo(function(props) {
|
|
|
6763
6716
|
[expanded, itemKey, onClick, setExpanded, setFocusedElement]
|
|
6764
6717
|
), handleKeyDown = react.useCallback(
|
|
6765
6718
|
(event) => {
|
|
6766
|
-
|
|
6767
|
-
const el = treeitemRef.current || rootRef.current;
|
|
6768
|
-
el == null || el.click();
|
|
6769
|
-
}
|
|
6719
|
+
focused && event.key === "Enter" && (treeitemRef.current || rootRef.current)?.click();
|
|
6770
6720
|
},
|
|
6771
6721
|
[focused]
|
|
6772
6722
|
);
|