@sanity/ui 2.2.0 → 2.3.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/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.esm.js +124 -113
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +123 -112
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +124 -113
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -9
- package/src/core/components/autocomplete/autocomplete.tsx +9 -12
- package/src/core/components/dialog/dialog.tsx +20 -32
- package/src/core/components/menu/menu.tsx +8 -6
- package/src/core/components/menu/menuItem.tsx +10 -10
- package/src/core/components/tab/tab.tsx +9 -12
- package/src/core/components/tree/tree.tsx +21 -8
- package/src/core/hooks/useForwardedRef.ts +9 -11
- package/src/core/hooks/useIsomorphicEffect.ts +1 -0
- package/src/core/primitives/checkbox/checkbox.tsx +10 -5
- package/src/core/primitives/popover/popover.tsx +13 -13
- package/src/core/primitives/radio/radio.tsx +8 -3
- package/src/core/primitives/select/select.tsx +8 -3
- package/src/core/primitives/switch/switch.tsx +8 -4
- package/src/core/primitives/textArea/textArea.tsx +8 -3
- package/src/core/primitives/textInput/textInput.tsx +16 -4
- package/src/core/primitives/tooltip/tooltip.tsx +8 -5
- package/src/core/utils/elementQuery/elementQuery.tsx +10 -11
- package/src/core/utils/layer/layer.tsx +8 -13
- package/src/core/utils/virtualList/virtualList.tsx +10 -8
package/dist/index.js
CHANGED
|
@@ -621,12 +621,9 @@ function getServerSnapshot() {
|
|
|
621
621
|
function usePrefersReducedMotion() {
|
|
622
622
|
return react.useSyncExternalStore(subscribe$1, getSnapshot, getServerSnapshot);
|
|
623
623
|
}
|
|
624
|
-
const useIsomorphicEffect = typeof window < "u" ? react.useLayoutEffect : react.useEffect;
|
|
625
624
|
function useForwardedRef(ref) {
|
|
626
625
|
const innerRef = react.useRef(null);
|
|
627
|
-
return
|
|
628
|
-
ref && (typeof ref == "function" ? ref(innerRef.current) : ref.current = innerRef.current);
|
|
629
|
-
}), innerRef;
|
|
626
|
+
return react.useImperativeHandle(ref, () => innerRef.current), innerRef;
|
|
630
627
|
}
|
|
631
628
|
function useCustomValidity(ref, customValidity) {
|
|
632
629
|
react.useEffect(() => {
|
|
@@ -2374,10 +2371,13 @@ const Root$r = styledComponents.styled.div(checkboxBaseStyles), Input$5 = styled
|
|
|
2374
2371
|
readOnly,
|
|
2375
2372
|
style,
|
|
2376
2373
|
...restProps
|
|
2377
|
-
} = props, ref =
|
|
2378
|
-
return
|
|
2374
|
+
} = props, ref = react.useRef(null);
|
|
2375
|
+
return react.useImperativeHandle(
|
|
2376
|
+
forwardedRef,
|
|
2377
|
+
() => ref.current
|
|
2378
|
+
), react.useEffect(() => {
|
|
2379
2379
|
ref.current && (ref.current.indeterminate = indeterminate || !1);
|
|
2380
|
-
}, [indeterminate, ref
|
|
2380
|
+
}, [indeterminate]), useCustomValidity(ref, customValidity), /* @__PURE__ */ jsxRuntime.jsxs(Root$r, { className, "data-ui": "Checkbox", style, children: [
|
|
2381
2381
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2382
2382
|
Input$5,
|
|
2383
2383
|
{
|
|
@@ -2852,16 +2852,15 @@ function findMinBreakpoints(media, width) {
|
|
|
2852
2852
|
media[i] <= width && ret.push(i);
|
|
2853
2853
|
return ret;
|
|
2854
2854
|
}
|
|
2855
|
-
const ElementQuery = react.forwardRef(function(props,
|
|
2856
|
-
const theme2 = useTheme_v2(), { children, media = theme2.media, ...restProps } = props,
|
|
2855
|
+
const ElementQuery = react.forwardRef(function(props, forwardedRef) {
|
|
2856
|
+
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(() => {
|
|
2857
2857
|
var _a;
|
|
2858
2858
|
return (_a = elementSize == null ? void 0 : elementSize.border.width) != null ? _a : window.innerWidth;
|
|
2859
|
-
}, [elementSize]), max = react.useMemo(() => findMaxBreakpoints(media, width), [media, width]), min = react.useMemo(() => findMinBreakpoints(media, width), [media, width])
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
);
|
|
2859
|
+
}, [elementSize]), max = react.useMemo(() => findMaxBreakpoints(media, width), [media, width]), min = react.useMemo(() => findMinBreakpoints(media, width), [media, width]);
|
|
2860
|
+
react.useImperativeHandle(forwardedRef, () => ref.current);
|
|
2861
|
+
const setRef = react.useCallback((el) => {
|
|
2862
|
+
ref.current = el, setElement(el);
|
|
2863
|
+
}, []);
|
|
2865
2864
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2866
2865
|
"div",
|
|
2867
2866
|
{
|
|
@@ -3021,30 +3020,20 @@ function LayerProvider(props) {
|
|
|
3021
3020
|
);
|
|
3022
3021
|
return /* @__PURE__ */ jsxRuntime.jsx(LayerContext.Provider, { value, children });
|
|
3023
3022
|
}
|
|
3024
|
-
const Root$j = styledComponents.styled.div({ position: "relative" }), LayerChildren = react.forwardRef(function(props,
|
|
3025
|
-
const { children, onActivate, onFocus, style = EMPTY_RECORD, ...restProps } = props, { zIndex, isTopLayer } = useLayer(), lastFocusedRef = react.useRef(null),
|
|
3026
|
-
react.useEffect(() => {
|
|
3023
|
+
const Root$j = styledComponents.styled.div({ position: "relative" }), LayerChildren = react.forwardRef(function(props, forwardedRef) {
|
|
3024
|
+
const { children, onActivate, onFocus, style = EMPTY_RECORD, ...restProps } = props, { zIndex, isTopLayer } = useLayer(), lastFocusedRef = react.useRef(null), ref = react.useRef(null), isTopLayerRef = react.useRef(isTopLayer);
|
|
3025
|
+
react.useImperativeHandle(forwardedRef, () => ref.current), react.useEffect(() => {
|
|
3027
3026
|
isTopLayerRef.current !== isTopLayer && isTopLayer && (onActivate == null || onActivate({ activeElement: lastFocusedRef.current })), isTopLayerRef.current = isTopLayer;
|
|
3028
3027
|
}, [isTopLayer, onActivate]);
|
|
3029
3028
|
const handleFocus = react.useCallback(
|
|
3030
3029
|
(event) => {
|
|
3031
3030
|
onFocus == null || onFocus(event);
|
|
3032
|
-
const rootElement =
|
|
3031
|
+
const rootElement = ref.current, target = document.activeElement;
|
|
3033
3032
|
!isTopLayer || !rootElement || !target || isHTMLElement(target) && containsOrEqualsElement(rootElement, target) && (lastFocusedRef.current = target);
|
|
3034
3033
|
},
|
|
3035
|
-
[
|
|
3036
|
-
);
|
|
3037
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3038
|
-
Root$j,
|
|
3039
|
-
{
|
|
3040
|
-
...restProps,
|
|
3041
|
-
"data-ui": "Layer",
|
|
3042
|
-
onFocus: handleFocus,
|
|
3043
|
-
ref: forwardedRef,
|
|
3044
|
-
style: { ...style, zIndex },
|
|
3045
|
-
children
|
|
3046
|
-
}
|
|
3034
|
+
[isTopLayer, onFocus]
|
|
3047
3035
|
);
|
|
3036
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Root$j, { ...restProps, "data-ui": "Layer", onFocus: handleFocus, ref, style: { ...style, zIndex }, children });
|
|
3048
3037
|
}), Layer = react.forwardRef(function(props, ref) {
|
|
3049
3038
|
const { children, zOffset = 1, ...restProps } = props;
|
|
3050
3039
|
return /* @__PURE__ */ jsxRuntime.jsx(LayerProvider, { zOffset, children: /* @__PURE__ */ jsxRuntime.jsx(LayerChildren, { ...restProps, ref, children }) });
|
|
@@ -3110,15 +3099,15 @@ const emptySubscribe$1 = () => () => {
|
|
|
3110
3099
|
position: absolute;
|
|
3111
3100
|
left: 0;
|
|
3112
3101
|
right: 0;
|
|
3113
|
-
`, VirtualList = react.forwardRef(function(props,
|
|
3114
|
-
const { as = "div", gap = 0, getItemKey, items = [], onChange, renderItem, ...restProps } = props, { space } = useTheme_v2(),
|
|
3115
|
-
react.useEffect(() => {
|
|
3102
|
+
`, VirtualList = react.forwardRef(function(props, forwardedRef) {
|
|
3103
|
+
const { as = "div", gap = 0, getItemKey, items = [], onChange, renderItem, ...restProps } = props, { space } = useTheme_v2(), ref = react.useRef(null), wrapperRef = react.useRef(null), [scrollTop, setScrollTop] = react.useState(0), [scrollHeight, setScrollHeight] = react.useState(0), [itemHeight, setItemHeight] = react.useState(-1);
|
|
3104
|
+
react.useImperativeHandle(forwardedRef, () => ref.current), react.useEffect(() => {
|
|
3116
3105
|
if (!wrapperRef.current) return;
|
|
3117
3106
|
const firstElement = wrapperRef.current.firstChild;
|
|
3118
3107
|
firstElement instanceof HTMLElement && setItemHeight(firstElement.offsetHeight);
|
|
3119
3108
|
}, [renderItem]), react.useEffect(() => {
|
|
3120
|
-
if (!
|
|
3121
|
-
let _scrollEl =
|
|
3109
|
+
if (!ref.current) return;
|
|
3110
|
+
let _scrollEl = ref.current.parentNode;
|
|
3122
3111
|
for (; _scrollEl && !_isScrollable(_scrollEl); )
|
|
3123
3112
|
_scrollEl = _scrollEl.parentNode;
|
|
3124
3113
|
if (_scrollEl) {
|
|
@@ -3143,7 +3132,7 @@ const emptySubscribe$1 = () => () => {
|
|
|
3143
3132
|
return window.addEventListener("scroll", handleScroll, { passive: !0 }), window.addEventListener("resize", handleResize), setScrollHeight(window.innerHeight), handleScroll(), () => {
|
|
3144
3133
|
window.removeEventListener("scroll", handleScroll), window.removeEventListener("resize", handleResize);
|
|
3145
3134
|
};
|
|
3146
|
-
}, [
|
|
3135
|
+
}, []);
|
|
3147
3136
|
const len = items.length, height = itemHeight ? len * (itemHeight + space[gap]) - space[gap] : 0, fromIndex = height ? Math.max(Math.floor(scrollTop / height * len) - 2, 0) : 0, toIndex = height ? Math.ceil((scrollTop + scrollHeight) / height * len) + 1 : 0;
|
|
3148
3137
|
react.useEffect(() => {
|
|
3149
3138
|
onChange && onChange({ fromIndex, gap: space[gap], itemHeight, scrollHeight, scrollTop, toIndex });
|
|
@@ -3152,7 +3141,7 @@ const emptySubscribe$1 = () => () => {
|
|
|
3152
3141
|
const itemIndex = fromIndex + _itemIndex, node = renderItem(item), key2 = getItemKey ? getItemKey(item, itemIndex) : itemIndex;
|
|
3153
3142
|
return /* @__PURE__ */ jsxRuntime.jsx(ItemWrapper, { style: { top: itemIndex * (itemHeight + space[gap]) }, children: node }, key2);
|
|
3154
3143
|
}), [fromIndex, gap, getItemKey, itemHeight, items, renderItem, space, toIndex]), wrapperStyle = react.useMemo(() => ({ height }), [height]);
|
|
3155
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Root$h, { as, "data-ui": "VirtualList", ...restProps, ref
|
|
3144
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Root$h, { as, "data-ui": "VirtualList", ...restProps, ref, children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref: wrapperRef, style: wrapperStyle, children }) });
|
|
3156
3145
|
}), DEFAULT_POPOVER_DISTANCE = 4, DEFAULT_POPOVER_PADDING = 4, DEFAULT_POPOVER_ARROW_WIDTH = 19, DEFAULT_POPOVER_ARROW_HEIGHT = 8, DEFAULT_POPOVER_ARROW_RADIUS = 2, DEFAULT_POPOVER_MARGINS = [0, 0, 0, 0], DEFAULT_FALLBACK_PLACEMENTS$1 = {
|
|
3157
3146
|
top: ["bottom", "left", "right"],
|
|
3158
3147
|
"top-start": ["bottom-start", "left-start", "right-start"],
|
|
@@ -3298,7 +3287,7 @@ const MotionCard$1 = styledComponents.styled(framerMotion.motion(Card))`
|
|
|
3298
3287
|
);
|
|
3299
3288
|
PopoverCard.displayName = "PopoverCard";
|
|
3300
3289
|
const Popover = react.memo(
|
|
3301
|
-
react.forwardRef(function(props,
|
|
3290
|
+
react.forwardRef(function(props, forwardedRef) {
|
|
3302
3291
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
3303
3292
|
const { container, layer } = useTheme_v2(), boundaryElementContext = useBoundaryElement(), {
|
|
3304
3293
|
__unstable_margins: margins = DEFAULT_POPOVER_MARGINS,
|
|
@@ -3330,7 +3319,12 @@ const Popover = react.memo(
|
|
|
3330
3319
|
zOffset: zOffsetProp = layer.popover.zOffset,
|
|
3331
3320
|
updateRef,
|
|
3332
3321
|
...restProps
|
|
3333
|
-
} = props, animate = usePrefersReducedMotion() ? !1 : _animate, boundarySize = (_e = useElementSize(boundaryElement)) == null ? void 0 : _e.border, padding = useArrayProp(paddingProp), radius = useArrayProp(radiusProp), shadow = useArrayProp(shadowProp), widthArrayProp = useArrayProp(widthProp), zOffset = useArrayProp(zOffsetProp),
|
|
3322
|
+
} = props, animate = usePrefersReducedMotion() ? !1 : _animate, boundarySize = (_e = useElementSize(boundaryElement)) == null ? void 0 : _e.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";
|
|
3323
|
+
react.useImperativeHandle(
|
|
3324
|
+
forwardedRef,
|
|
3325
|
+
() => ref.current
|
|
3326
|
+
);
|
|
3327
|
+
const mediaIndex = useMediaIndex(), boundaryWidth = constrainSize || preventOverflow ? boundarySize == null ? void 0 : boundarySize.width : void 0, width = calcCurrentWidth({
|
|
3334
3328
|
container,
|
|
3335
3329
|
mediaIndex,
|
|
3336
3330
|
width: widthArrayProp
|
|
@@ -3344,11 +3338,11 @@ const Popover = react.memo(
|
|
|
3344
3338
|
}, [maxWidth]);
|
|
3345
3339
|
const referenceWidthRef = react.useRef();
|
|
3346
3340
|
react.useEffect(() => {
|
|
3347
|
-
const floatingElement =
|
|
3341
|
+
const floatingElement = ref.current;
|
|
3348
3342
|
if (!open || !floatingElement) return;
|
|
3349
3343
|
const referenceWidth = referenceWidthRef.current;
|
|
3350
3344
|
matchReferenceWidth ? referenceWidth !== void 0 && (floatingElement.style.width = `${referenceWidth}px`) : width !== void 0 && (floatingElement.style.width = `${width}px`), typeof maxWidth == "number" && (floatingElement.style.maxWidth = `${maxWidth}px`);
|
|
3351
|
-
}, [width,
|
|
3345
|
+
}, [width, matchReferenceWidth, maxWidth, open]);
|
|
3352
3346
|
const middleware = react.useMemo(() => {
|
|
3353
3347
|
const ret = [];
|
|
3354
3348
|
return (constrainSize || preventOverflow) && ret.push(
|
|
@@ -3410,9 +3404,9 @@ const Popover = react.memo(
|
|
|
3410
3404
|
arrowRef.current = arrowEl;
|
|
3411
3405
|
}, []), setFloating = react.useCallback(
|
|
3412
3406
|
(node) => {
|
|
3413
|
-
|
|
3407
|
+
ref.current = node, refs.setFloating(node);
|
|
3414
3408
|
},
|
|
3415
|
-
[
|
|
3409
|
+
[refs]
|
|
3416
3410
|
), setReference = react.useCallback(
|
|
3417
3411
|
(node) => {
|
|
3418
3412
|
refs.setReference(node);
|
|
@@ -3585,8 +3579,11 @@ function inputElementStyle(props) {
|
|
|
3585
3579
|
`;
|
|
3586
3580
|
}
|
|
3587
3581
|
const Root$g = styledComponents.styled.div(radioBaseStyle), Input$4 = styledComponents.styled.input(inputElementStyle), Radio = react.forwardRef(function(props, forwardedRef) {
|
|
3588
|
-
const { className, disabled, style, customValidity, readOnly, ...restProps } = props, ref =
|
|
3589
|
-
return
|
|
3582
|
+
const { className, disabled, style, customValidity, readOnly, ...restProps } = props, ref = react.useRef(null);
|
|
3583
|
+
return react.useImperativeHandle(
|
|
3584
|
+
forwardedRef,
|
|
3585
|
+
() => ref.current
|
|
3586
|
+
), useCustomValidity(ref, customValidity), /* @__PURE__ */ jsxRuntime.jsxs(Root$g, { className, "data-ui": "Radio", style, children: [
|
|
3590
3587
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3591
3588
|
Input$4,
|
|
3592
3589
|
{
|
|
@@ -3747,8 +3744,11 @@ const selectStyle = {
|
|
|
3747
3744
|
readOnly,
|
|
3748
3745
|
space = 3,
|
|
3749
3746
|
...restProps
|
|
3750
|
-
} = props, ref =
|
|
3751
|
-
return
|
|
3747
|
+
} = props, ref = react.useRef(null);
|
|
3748
|
+
return react.useImperativeHandle(
|
|
3749
|
+
forwardedRef,
|
|
3750
|
+
() => ref.current
|
|
3751
|
+
), useCustomValidity(ref, customValidity), /* @__PURE__ */ jsxRuntime.jsxs(Root$f, { "data-ui": "Select", children: [
|
|
3752
3752
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3753
3753
|
Input$3,
|
|
3754
3754
|
{
|
|
@@ -3942,10 +3942,13 @@ function switchThumbStyles(props) {
|
|
|
3942
3942
|
`;
|
|
3943
3943
|
}
|
|
3944
3944
|
const Root$d = styledComponents.styled.span(switchBaseStyles), Input$2 = styledComponents.styled.input(switchInputStyles), Representation = styledComponents.styled.span(switchRepresentationStyles), Track = styledComponents.styled.span(switchTrackStyles), Thumb = styledComponents.styled.span(switchThumbStyles), Switch = react.forwardRef(function(props, forwardedRef) {
|
|
3945
|
-
const { checked, className, disabled, indeterminate, readOnly, style, ...restProps } = props, ref =
|
|
3946
|
-
return react.
|
|
3945
|
+
const { checked, className, disabled, indeterminate, readOnly, style, ...restProps } = props, ref = react.useRef(null);
|
|
3946
|
+
return react.useImperativeHandle(
|
|
3947
|
+
forwardedRef,
|
|
3948
|
+
() => ref.current
|
|
3949
|
+
), react.useEffect(() => {
|
|
3947
3950
|
ref.current && (ref.current.indeterminate = indeterminate || !1);
|
|
3948
|
-
}, [indeterminate
|
|
3951
|
+
}, [indeterminate]), /* @__PURE__ */ jsxRuntime.jsxs(Root$d, { className, "data-ui": "Switch", style, children: [
|
|
3949
3952
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3950
3953
|
Input$2,
|
|
3951
3954
|
{
|
|
@@ -3984,8 +3987,11 @@ const Root$d = styledComponents.styled.span(switchBaseStyles), Input$2 = styledC
|
|
|
3984
3987
|
radius = 2,
|
|
3985
3988
|
weight,
|
|
3986
3989
|
...restProps
|
|
3987
|
-
} = props, ref =
|
|
3988
|
-
return
|
|
3990
|
+
} = props, ref = react.useRef(null), rootTheme = useRootTheme();
|
|
3991
|
+
return react.useImperativeHandle(
|
|
3992
|
+
forwardedRef,
|
|
3993
|
+
() => ref.current
|
|
3994
|
+
), useCustomValidity(ref, customValidity), /* @__PURE__ */ jsxRuntime.jsx(Root$c, { "data-ui": "TextArea", children: /* @__PURE__ */ jsxRuntime.jsxs(InputRoot$1, { children: [
|
|
3989
3995
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3990
3996
|
Input$1,
|
|
3991
3997
|
{
|
|
@@ -4080,8 +4086,11 @@ const Root$d = styledComponents.styled.span(switchBaseStyles), Input$2 = styledC
|
|
|
4080
4086
|
type = "text",
|
|
4081
4087
|
weight,
|
|
4082
4088
|
...restProps
|
|
4083
|
-
} = props, ref =
|
|
4084
|
-
|
|
4089
|
+
} = props, ref = react.useRef(null), rootTheme = useRootTheme(), fontSize2 = useArrayProp(fontSizeProp), padding = useArrayProp(paddingProp), radius = useArrayProp(radiusProp), space = useArrayProp(spaceProp), $hasClearButton = !!clearButton, $hasIcon = !!icon, $hasIconRight = !!iconRight, $hasSuffix = !!suffix, $hasPrefix = !!prefix;
|
|
4090
|
+
react.useImperativeHandle(
|
|
4091
|
+
forwardedRef,
|
|
4092
|
+
() => ref.current
|
|
4093
|
+
), useCustomValidity(ref, customValidity);
|
|
4085
4094
|
const handleClearMouseDown = react.useCallback((event) => {
|
|
4086
4095
|
event.preventDefault(), event.stopPropagation();
|
|
4087
4096
|
}, []), handleClearClick = react.useCallback(
|
|
@@ -4328,7 +4337,7 @@ function TooltipDelayGroupProvider(props) {
|
|
|
4328
4337
|
const Root$a = styledComponents.styled(Layer)`
|
|
4329
4338
|
pointer-events: none;
|
|
4330
4339
|
max-width: ${({ $maxWidth }) => $maxWidth}px;
|
|
4331
|
-
`, Tooltip = react.forwardRef(function(props,
|
|
4340
|
+
`, Tooltip = react.forwardRef(function(props, forwardedRef) {
|
|
4332
4341
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
4333
4342
|
const boundaryElementContext = useBoundaryElement(), { layer } = useTheme_v2(), {
|
|
4334
4343
|
animate: _animate = !1,
|
|
@@ -4347,7 +4356,9 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4347
4356
|
zOffset = layer.tooltip.zOffset,
|
|
4348
4357
|
delay,
|
|
4349
4358
|
...restProps
|
|
4350
|
-
} = props, animate = usePrefersReducedMotion() ? !1 : _animate, fallbackPlacements = useArrayProp(fallbackPlacementsProp),
|
|
4359
|
+
} = props, animate = usePrefersReducedMotion() ? !1 : _animate, fallbackPlacements = useArrayProp(fallbackPlacementsProp), ref = react.useRef(null), [referenceElement, setReferenceElement] = react.useState(null), arrowRef = react.useRef(null), rootBoundary = "viewport";
|
|
4360
|
+
react.useImperativeHandle(forwardedRef, () => ref.current);
|
|
4361
|
+
const portal = usePortal(), portalElement = typeof portalProp == "string" ? ((_c = portal.elements) == null ? void 0 : _c[portalProp]) || null : portal.element, documentBodyOffsetWidth = react.useSyncExternalStore(
|
|
4351
4362
|
emptySubscribe,
|
|
4352
4363
|
() => document.body.offsetWidth,
|
|
4353
4364
|
// We don't actually know what the width of the body is during SSR, so we'll just assume it's 800px or larger
|
|
@@ -4457,9 +4468,9 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4457
4468
|
[update]
|
|
4458
4469
|
), setFloating = react.useCallback(
|
|
4459
4470
|
(node) => {
|
|
4460
|
-
|
|
4471
|
+
ref.current = node, refs.setFloating(node);
|
|
4461
4472
|
},
|
|
4462
|
-
[
|
|
4473
|
+
[refs]
|
|
4463
4474
|
), childRef = childProp == null ? void 0 : childProp.ref, setReference = react.useCallback(
|
|
4464
4475
|
(node) => {
|
|
4465
4476
|
typeof childRef == "function" ? childRef(node) : childRef && (childRef.current = node), setReferenceElement(node);
|
|
@@ -4593,7 +4604,7 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
|
|
|
4593
4604
|
"Meta",
|
|
4594
4605
|
"Tab",
|
|
4595
4606
|
"CapsLock"
|
|
4596
|
-
], AUTOCOMPLETE_POPOVER_PLACEMENT = "bottom-start", AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS = ["bottom-start", "top-start"], DEFAULT_RENDER_VALUE = (value, option) => option ? option.value : value, DEFAULT_FILTER_OPTION = (query, option) => option.value.toLowerCase().indexOf(query.toLowerCase()) > -1, InnerAutocomplete = react.forwardRef(function(props,
|
|
4607
|
+
], AUTOCOMPLETE_POPOVER_PLACEMENT = "bottom-start", AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS = ["bottom-start", "top-start"], DEFAULT_RENDER_VALUE = (value, option) => option ? option.value : value, DEFAULT_FILTER_OPTION = (query, option) => option.value.toLowerCase().indexOf(query.toLowerCase()) > -1, InnerAutocomplete = react.forwardRef(function(props, forwardedRef) {
|
|
4597
4608
|
const {
|
|
4598
4609
|
border: border2 = !0,
|
|
4599
4610
|
customValidity,
|
|
@@ -4632,7 +4643,12 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
|
|
|
4632
4643
|
}), { activeValue, focused, listFocused, query, value } = state, defaultRenderOption = react.useCallback(
|
|
4633
4644
|
({ value: value2 }) => /* @__PURE__ */ jsxRuntime.jsx(Card, { "data-as": "button", padding: paddingProp, radius: 2, tone: "inherit", children: /* @__PURE__ */ jsxRuntime.jsx(Text, { size: fontSize2, textOverflow: "ellipsis", children: value2 }) }),
|
|
4634
4645
|
[fontSize2, paddingProp]
|
|
4635
|
-
), renderOption = typeof renderOptionProp == "function" ? renderOptionProp : defaultRenderOption, filterOption = typeof filterOptionProp == "function" ? filterOptionProp : DEFAULT_FILTER_OPTION, rootElementRef = react.useRef(null), resultsPopoverElementRef = react.useRef(null), inputElementRef = react.useRef(null), listBoxElementRef = react.useRef(null), listFocusedRef = react.useRef(!1), valueRef = react.useRef(value), valuePropRef = react.useRef(valueProp), popoverMouseWithinRef = react.useRef(!1)
|
|
4646
|
+
), renderOption = typeof renderOptionProp == "function" ? renderOptionProp : defaultRenderOption, filterOption = typeof filterOptionProp == "function" ? filterOptionProp : DEFAULT_FILTER_OPTION, rootElementRef = react.useRef(null), resultsPopoverElementRef = react.useRef(null), inputElementRef = react.useRef(null), listBoxElementRef = react.useRef(null), listFocusedRef = react.useRef(!1), valueRef = react.useRef(value), valuePropRef = react.useRef(valueProp), popoverMouseWithinRef = react.useRef(!1);
|
|
4647
|
+
react.useImperativeHandle(
|
|
4648
|
+
forwardedRef,
|
|
4649
|
+
() => inputElementRef.current
|
|
4650
|
+
);
|
|
4651
|
+
const listBoxId = `${id}-listbox`, options = Array.isArray(optionsProp) ? optionsProp : EMPTY_ARRAY, padding = useArrayProp(paddingProp), currentOption = react.useMemo(
|
|
4636
4652
|
() => value !== null ? options.find((o) => o.value === value) : void 0,
|
|
4637
4653
|
[options, value]
|
|
4638
4654
|
), filteredOptions = react.useMemo(
|
|
@@ -4736,12 +4752,7 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
|
|
|
4736
4752
|
}
|
|
4737
4753
|
}
|
|
4738
4754
|
}, [activeValue, filteredOptions]);
|
|
4739
|
-
const
|
|
4740
|
-
(el) => {
|
|
4741
|
-
inputElementRef.current = el, forwardedRef.current = el;
|
|
4742
|
-
},
|
|
4743
|
-
[forwardedRef]
|
|
4744
|
-
), clearButton = react.useMemo(() => {
|
|
4755
|
+
const clearButton = react.useMemo(() => {
|
|
4745
4756
|
if (!loading && !disabled && value)
|
|
4746
4757
|
return {
|
|
4747
4758
|
"aria-label": "Clear",
|
|
@@ -4816,7 +4827,7 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
|
|
|
4816
4827
|
prefix,
|
|
4817
4828
|
radius,
|
|
4818
4829
|
readOnly,
|
|
4819
|
-
ref:
|
|
4830
|
+
ref: inputElementRef,
|
|
4820
4831
|
role: "combobox",
|
|
4821
4832
|
spellCheck: !1,
|
|
4822
4833
|
suffix: suffix || openButtonNode,
|
|
@@ -5078,13 +5089,13 @@ const Root$7 = styledComponents.styled(Layer)(responsivePaddingStyle, dialogStyl
|
|
|
5078
5089
|
`, DialogFooter = styledComponents.styled(Box)`
|
|
5079
5090
|
position: relative;
|
|
5080
5091
|
z-index: 3;
|
|
5081
|
-
`, DialogCard = react.forwardRef(function(props,
|
|
5092
|
+
`, DialogCard = react.forwardRef(function(props, forwardedRef) {
|
|
5082
5093
|
var _a;
|
|
5083
5094
|
const {
|
|
5084
5095
|
__unstable_autoFocus: autoFocus,
|
|
5085
5096
|
__unstable_hideCloseButton: hideCloseButton,
|
|
5086
5097
|
children,
|
|
5087
|
-
contentRef,
|
|
5098
|
+
contentRef: forwardedContentRef,
|
|
5088
5099
|
footer,
|
|
5089
5100
|
header,
|
|
5090
5101
|
id,
|
|
@@ -5095,10 +5106,13 @@ const Root$7 = styledComponents.styled(Layer)(responsivePaddingStyle, dialogStyl
|
|
|
5095
5106
|
scheme,
|
|
5096
5107
|
shadow: shadowProp,
|
|
5097
5108
|
width: widthProp
|
|
5098
|
-
} = props, portal = usePortal(), portalElement = portalProp ? ((_a = portal.elements) == null ? void 0 : _a[portalProp]) || null : portal.element, boundaryElement = useBoundaryElement().element, radius = useArrayProp(radiusProp), shadow = useArrayProp(shadowProp), width = useArrayProp(widthProp),
|
|
5099
|
-
react.
|
|
5100
|
-
|
|
5101
|
-
|
|
5109
|
+
} = props, portal = usePortal(), portalElement = portalProp ? ((_a = portal.elements) == null ? void 0 : _a[portalProp]) || null : portal.element, boundaryElement = useBoundaryElement().element, radius = useArrayProp(radiusProp), shadow = useArrayProp(shadowProp), width = useArrayProp(widthProp), ref = react.useRef(null), [rootElement, setRootElement] = react.useState(null), contentRef = react.useRef(null), layer = useLayer(), { isTopLayer } = layer, labelId = `${id}_label`, showCloseButton = !!onClose && hideCloseButton === !1, showHeader = !!header || showCloseButton;
|
|
5110
|
+
react.useImperativeHandle(forwardedRef, () => ref.current), react.useImperativeHandle(
|
|
5111
|
+
forwardedContentRef,
|
|
5112
|
+
() => contentRef.current
|
|
5113
|
+
), react.useEffect(() => {
|
|
5114
|
+
autoFocus && ref.current && focusFirstDescendant(ref.current);
|
|
5115
|
+
}, [autoFocus, ref]), useGlobalKeyDown(
|
|
5102
5116
|
react.useCallback(
|
|
5103
5117
|
(event) => {
|
|
5104
5118
|
if (!isTopLayer || !onClose) return;
|
|
@@ -5118,17 +5132,9 @@ const Root$7 = styledComponents.styled(Layer)(responsivePaddingStyle, dialogStyl
|
|
|
5118
5132
|
),
|
|
5119
5133
|
[rootElement]
|
|
5120
5134
|
);
|
|
5121
|
-
const setRef = react.useCallback(
|
|
5122
|
-
(el)
|
|
5123
|
-
|
|
5124
|
-
},
|
|
5125
|
-
[forwardedRef]
|
|
5126
|
-
), setContentRef = react.useCallback(
|
|
5127
|
-
(el) => {
|
|
5128
|
-
localContentRef.current = el, typeof contentRef == "function" ? contentRef(el) : contentRef && (contentRef.current = el);
|
|
5129
|
-
},
|
|
5130
|
-
[contentRef]
|
|
5131
|
-
);
|
|
5135
|
+
const setRef = react.useCallback((el) => {
|
|
5136
|
+
setRootElement(el), ref.current = el;
|
|
5137
|
+
}, []);
|
|
5132
5138
|
return /* @__PURE__ */ jsxRuntime.jsx(DialogContainer, { "data-ui": "DialogCard", width, children: /* @__PURE__ */ jsxRuntime.jsx(DialogCardRoot, { radius, ref: setRef, scheme, shadow, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogLayout, { direction: "column", children: [
|
|
5133
5139
|
showHeader && /* @__PURE__ */ jsxRuntime.jsx(DialogHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(Flex, { align: "center", padding: 3, children: [
|
|
5134
5140
|
/* @__PURE__ */ jsxRuntime.jsx(Box, { flex: 1, padding: 2, children: header && /* @__PURE__ */ jsxRuntime.jsx(Text, { id: labelId, size: 1, weight: "semibold", children: header }) }),
|
|
@@ -5144,7 +5150,7 @@ const Root$7 = styledComponents.styled(Layer)(responsivePaddingStyle, dialogStyl
|
|
|
5144
5150
|
}
|
|
5145
5151
|
) })
|
|
5146
5152
|
] }) }),
|
|
5147
|
-
/* @__PURE__ */ jsxRuntime.jsx(DialogContent, { flex: 1, ref:
|
|
5153
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogContent, { flex: 1, ref: contentRef, tabIndex: -1, children }),
|
|
5148
5154
|
footer && /* @__PURE__ */ jsxRuntime.jsx(DialogFooter, { children: footer })
|
|
5149
5155
|
] }) }) });
|
|
5150
5156
|
}), Dialog = react.forwardRef(function(props, ref) {
|
|
@@ -5420,7 +5426,7 @@ function useMenuController(props) {
|
|
|
5420
5426
|
const Root$5 = styledComponents.styled(Box)`
|
|
5421
5427
|
outline: none;
|
|
5422
5428
|
overflow: auto;
|
|
5423
|
-
`, Menu = react.forwardRef(function(props,
|
|
5429
|
+
`, Menu = react.forwardRef(function(props, forwardedRef) {
|
|
5424
5430
|
const {
|
|
5425
5431
|
children,
|
|
5426
5432
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -5438,7 +5444,9 @@ const Root$5 = styledComponents.styled(Box)`
|
|
|
5438
5444
|
shouldFocus = props.focusFirst && "first" || props.focusLast && "last" || null,
|
|
5439
5445
|
space = 1,
|
|
5440
5446
|
...restProps
|
|
5441
|
-
} = props,
|
|
5447
|
+
} = props, ref = react.useRef(null);
|
|
5448
|
+
react.useImperativeHandle(forwardedRef, () => ref.current);
|
|
5449
|
+
const { isTopLayer } = useLayer(), {
|
|
5442
5450
|
activeElement,
|
|
5443
5451
|
activeIndex,
|
|
5444
5452
|
handleItemMouseEnter,
|
|
@@ -5449,9 +5457,9 @@ const Root$5 = styledComponents.styled(Box)`
|
|
|
5449
5457
|
setRootElement
|
|
5450
5458
|
} = useMenuController({ onKeyDown, originElement, shouldFocus }), handleRefChange = react.useCallback(
|
|
5451
5459
|
(el) => {
|
|
5452
|
-
setRootElement(el),
|
|
5460
|
+
setRootElement(el), ref.current = el;
|
|
5453
5461
|
},
|
|
5454
|
-
[
|
|
5462
|
+
[setRootElement]
|
|
5455
5463
|
);
|
|
5456
5464
|
react.useEffect(() => {
|
|
5457
5465
|
onItemSelect && onItemSelect(activeIndex);
|
|
@@ -5886,9 +5894,9 @@ const MenuItem = react.forwardRef(function(props, forwardedRef) {
|
|
|
5886
5894
|
onItemClick,
|
|
5887
5895
|
onItemMouseEnter = menu.onMouseEnter,
|
|
5888
5896
|
onItemMouseLeave = menu.onMouseLeave
|
|
5889
|
-
} = menu, [rootElement, setRootElement] = react.useState(null), active = !!activeElement && activeElement === rootElement;
|
|
5890
|
-
react.useEffect(() => mount(rootElement, selectedProp), [mount, rootElement, selectedProp]);
|
|
5891
|
-
const
|
|
5897
|
+
} = menu, [rootElement, setRootElement] = react.useState(null), active = !!activeElement && activeElement === rootElement, ref = react.useRef(null);
|
|
5898
|
+
react.useImperativeHandle(forwardedRef, () => ref.current), react.useEffect(() => mount(rootElement, selectedProp), [mount, rootElement, selectedProp]);
|
|
5899
|
+
const handleClick = react.useCallback(
|
|
5892
5900
|
(event) => {
|
|
5893
5901
|
disabled || (onClick && onClick(event), onItemClick && onItemClick());
|
|
5894
5902
|
},
|
|
@@ -5904,12 +5912,9 @@ const MenuItem = react.forwardRef(function(props, forwardedRef) {
|
|
|
5904
5912
|
paddingLeft
|
|
5905
5913
|
}),
|
|
5906
5914
|
[padding, paddingX, paddingY, paddingTop, paddingRight, paddingBottom, paddingLeft]
|
|
5907
|
-
), hotkeysFontSize = useArrayProp(fontSize2).map((s) => s - 1), setRef = react.useCallback(
|
|
5908
|
-
(el)
|
|
5909
|
-
|
|
5910
|
-
},
|
|
5911
|
-
[ref]
|
|
5912
|
-
);
|
|
5915
|
+
), hotkeysFontSize = useArrayProp(fontSize2).map((s) => s - 1), setRef = react.useCallback((el) => {
|
|
5916
|
+
ref.current = el, setRootElement(el);
|
|
5917
|
+
}, []);
|
|
5913
5918
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5914
5919
|
Selectable,
|
|
5915
5920
|
{
|
|
@@ -6048,16 +6053,21 @@ const MenuItem = react.forwardRef(function(props, forwardedRef) {
|
|
|
6048
6053
|
padding = 2,
|
|
6049
6054
|
selected,
|
|
6050
6055
|
...restProps
|
|
6051
|
-
} = props,
|
|
6056
|
+
} = props, ref = react.useRef(null), focusedRef = react.useRef(!1);
|
|
6057
|
+
react.useImperativeHandle(
|
|
6058
|
+
forwardedRef,
|
|
6059
|
+
() => ref.current
|
|
6060
|
+
);
|
|
6061
|
+
const handleBlur = react.useCallback(() => {
|
|
6052
6062
|
focusedRef.current = !1;
|
|
6053
6063
|
}, []), handleFocus = react.useCallback(
|
|
6054
6064
|
(event) => {
|
|
6055
6065
|
focusedRef.current = !0, onFocus && onFocus(event);
|
|
6056
6066
|
},
|
|
6057
6067
|
[onFocus]
|
|
6058
|
-
)
|
|
6068
|
+
);
|
|
6059
6069
|
return react.useEffect(() => {
|
|
6060
|
-
focused && !focusedRef.current && (
|
|
6070
|
+
focused && !focusedRef.current && (ref.current && ref.current.focus(), focusedRef.current = !0);
|
|
6061
6071
|
}, [focused]), /* @__PURE__ */ jsxRuntime.jsx(
|
|
6062
6072
|
CustomButton,
|
|
6063
6073
|
{
|
|
@@ -6072,9 +6082,7 @@ const MenuItem = react.forwardRef(function(props, forwardedRef) {
|
|
|
6072
6082
|
onBlur: handleBlur,
|
|
6073
6083
|
onFocus: handleFocus,
|
|
6074
6084
|
padding,
|
|
6075
|
-
ref
|
|
6076
|
-
elementRef.current = el, ref.current = el;
|
|
6077
|
-
},
|
|
6085
|
+
ref,
|
|
6078
6086
|
role: "tab",
|
|
6079
6087
|
selected,
|
|
6080
6088
|
tabIndex: selected ? 0 : -1,
|
|
@@ -6357,9 +6365,12 @@ function _focusItemElement(el) {
|
|
|
6357
6365
|
}
|
|
6358
6366
|
}
|
|
6359
6367
|
const key = Symbol.for("@sanity/ui/context/tree"), TreeContext = createGlobalScopedContext(key, null), Tree = react.memo(
|
|
6360
|
-
react.forwardRef(function(props,
|
|
6361
|
-
const { children, space = 1, onFocus, ...restProps } = props,
|
|
6362
|
-
react.
|
|
6368
|
+
react.forwardRef(function(props, forwardedRef) {
|
|
6369
|
+
const { children, space = 1, onFocus, ...restProps } = props, ref = react.useRef(null), [focusedElement, setFocusedElement] = react.useState(null), focusedElementRef = react.useRef(focusedElement), path = react.useMemo(() => [], []), [itemElements, setItemElements] = react.useState([]), [state, setState] = react.useState({}), stateRef = react.useRef(state);
|
|
6370
|
+
react.useImperativeHandle(
|
|
6371
|
+
forwardedRef,
|
|
6372
|
+
() => ref.current
|
|
6373
|
+
), react.useEffect(() => {
|
|
6363
6374
|
focusedElementRef.current = focusedElement;
|
|
6364
6375
|
}, [focusedElement]), react.useEffect(() => {
|
|
6365
6376
|
stateRef.current = state;
|
|
@@ -6453,12 +6464,12 @@ const key = Symbol.for("@sanity/ui/context/tree"), TreeContext = createGlobalSco
|
|
|
6453
6464
|
[onFocus]
|
|
6454
6465
|
);
|
|
6455
6466
|
return react.useEffect(() => {
|
|
6456
|
-
if (!
|
|
6467
|
+
if (!ref.current) return;
|
|
6457
6468
|
const _itemElements = Array.from(
|
|
6458
|
-
|
|
6469
|
+
ref.current.querySelectorAll('[data-ui="TreeItem"]')
|
|
6459
6470
|
);
|
|
6460
6471
|
setItemElements(_itemElements);
|
|
6461
|
-
}, [children,
|
|
6472
|
+
}, [children, ref]), /* @__PURE__ */ jsxRuntime.jsx(TreeContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6462
6473
|
Stack,
|
|
6463
6474
|
{
|
|
6464
6475
|
as: "ul",
|
|
@@ -6466,7 +6477,7 @@ const key = Symbol.for("@sanity/ui/context/tree"), TreeContext = createGlobalSco
|
|
|
6466
6477
|
...restProps,
|
|
6467
6478
|
onFocus: handleFocus,
|
|
6468
6479
|
onKeyDown: handleKeyDown,
|
|
6469
|
-
ref
|
|
6480
|
+
ref,
|
|
6470
6481
|
role: "tree",
|
|
6471
6482
|
space,
|
|
6472
6483
|
children
|