@sanity/ui 2.11.5 → 2.11.7-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/index.esm.js +63 -120
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +63 -120
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -120
- package/dist/index.mjs.map +1 -1
- package/package.json +57 -71
- package/src/core/primitives/popover/popover.tsx +1 -26
- package/src/core/primitives/tooltip/tooltip.tsx +5 -13
- package/src/core/utils/getElementRef.ts +26 -0
- package/src/core/utils/virtualList/virtualList.tsx +13 -9
package/dist/index.esm.js
CHANGED
|
@@ -166,13 +166,9 @@ function _getElements(element, elementsArg) {
|
|
|
166
166
|
Array.isArray(el) ? ret.push(...el) : ret.push(el);
|
|
167
167
|
return ret.filter(Boolean);
|
|
168
168
|
}
|
|
169
|
-
function useClickOutside(listener,
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
$[0] !== element || $[1] !== elementsArg ? (t1 = () => _getElements(element, elementsArg), $[0] = element, $[1] = elementsArg, $[2] = t1) : t1 = $[2];
|
|
173
|
-
const [elements, setElements] = useState(t1), elementsRef = useRef(elements);
|
|
174
|
-
let t2, t3;
|
|
175
|
-
$[3] !== element || $[4] !== elementsArg ? (t2 = () => {
|
|
169
|
+
function useClickOutside(listener, elementsArg = EMPTY_ARRAY, boundaryElement) {
|
|
170
|
+
const [element, setElement] = useState(null), [elements, setElements] = useState(() => _getElements(element, elementsArg)), elementsRef = useRef(elements);
|
|
171
|
+
return useEffect(() => {
|
|
176
172
|
const prevElements = elementsRef.current, nextElements = _getElements(element, elementsArg);
|
|
177
173
|
if (prevElements.length !== nextElements.length) {
|
|
178
174
|
setElements(nextElements), elementsRef.current = nextElements;
|
|
@@ -188,11 +184,8 @@ function useClickOutside(listener, t0, boundaryElement) {
|
|
|
188
184
|
setElements(nextElements), elementsRef.current = nextElements;
|
|
189
185
|
return;
|
|
190
186
|
}
|
|
191
|
-
},
|
|
192
|
-
|
|
193
|
-
return $[7] !== boundaryElement || $[8] !== elements || $[9] !== listener ? (t4 = () => {
|
|
194
|
-
if (!listener)
|
|
195
|
-
return;
|
|
187
|
+
}, [element, elementsArg]), useEffect(() => {
|
|
188
|
+
if (!listener) return;
|
|
196
189
|
const handleWindowMouseDown = (evt) => {
|
|
197
190
|
const target = evt.target;
|
|
198
191
|
if (target instanceof Node && !(boundaryElement && !boundaryElement.contains(target))) {
|
|
@@ -205,10 +198,10 @@ function useClickOutside(listener, t0, boundaryElement) {
|
|
|
205
198
|
return window.addEventListener("mousedown", handleWindowMouseDown), () => {
|
|
206
199
|
window.removeEventListener("mousedown", handleWindowMouseDown);
|
|
207
200
|
};
|
|
208
|
-
},
|
|
201
|
+
}, [boundaryElement, listener, elements]), setElement;
|
|
209
202
|
}
|
|
210
203
|
function useClickOutsideEvent(listener, t0, boundaryElement) {
|
|
211
|
-
const $ = c(8), elementsArg = t0 === void 0 ? _temp$
|
|
204
|
+
const $ = c(8), elementsArg = t0 === void 0 ? _temp$a : t0;
|
|
212
205
|
let t1;
|
|
213
206
|
$[0] !== boundaryElement || $[1] !== elementsArg || $[2] !== listener ? (t1 = (evt) => {
|
|
214
207
|
if (!listener)
|
|
@@ -236,7 +229,7 @@ function useClickOutsideEvent(listener, t0, boundaryElement) {
|
|
|
236
229
|
};
|
|
237
230
|
}, t3 = [hasListener, onEvent], $[4] = hasListener, $[5] = onEvent, $[6] = t2, $[7] = t3) : (t2 = $[6], t3 = $[7]), useEffect(t2, t3), useDebugValue(listener ? "MouseDown On" : "MouseDown Off");
|
|
238
231
|
}
|
|
239
|
-
function _temp$
|
|
232
|
+
function _temp$a() {
|
|
240
233
|
return EMPTY_ARRAY;
|
|
241
234
|
}
|
|
242
235
|
function useCustomValidity(ref, customValidity) {
|
|
@@ -749,15 +742,15 @@ function useMediaIndex() {
|
|
|
749
742
|
return useSyncExternalStore(store.subscribe, store.getSnapshot, getServerSnapshot);
|
|
750
743
|
}
|
|
751
744
|
function usePrefersDark(t0) {
|
|
752
|
-
return useMatchMedia("(prefers-color-scheme: dark)", t0 === void 0 ? _temp$
|
|
745
|
+
return useMatchMedia("(prefers-color-scheme: dark)", t0 === void 0 ? _temp$9 : t0);
|
|
753
746
|
}
|
|
754
|
-
function _temp$
|
|
747
|
+
function _temp$9() {
|
|
755
748
|
return !1;
|
|
756
749
|
}
|
|
757
750
|
function usePrefersReducedMotion(t0) {
|
|
758
|
-
return useMatchMedia("(prefers-reduced-motion: reduce)", t0 === void 0 ? _temp$
|
|
751
|
+
return useMatchMedia("(prefers-reduced-motion: reduce)", t0 === void 0 ? _temp$8 : t0);
|
|
759
752
|
}
|
|
760
|
-
function _temp$
|
|
753
|
+
function _temp$8() {
|
|
761
754
|
return !1;
|
|
762
755
|
}
|
|
763
756
|
function responsiveBorderStyle() {
|
|
@@ -1702,7 +1695,7 @@ const StyledAvatar = /* @__PURE__ */ styled.div.withConfig({
|
|
|
1702
1695
|
}, $[20] = onImageLoadError, $[21] = t7) : t7 = $[21];
|
|
1703
1696
|
const handleImageError = t7;
|
|
1704
1697
|
let t8, t9;
|
|
1705
|
-
$[22] !== size2 ? (t9 = size2.map(_temp$
|
|
1698
|
+
$[22] !== size2 ? (t9 = size2.map(_temp$7), $[22] = size2, $[23] = t9) : t9 = $[23], t8 = t9;
|
|
1706
1699
|
const initialsSize = t8, t10 = typeof as == "string" ? as : void 0;
|
|
1707
1700
|
let t11;
|
|
1708
1701
|
$[24] !== color ? (t11 = /* @__PURE__ */ jsx(Arrow$1, { children: /* @__PURE__ */ jsx("svg", { width: "11", height: "7", viewBox: "0 0 11 7", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M6.67948 1.50115L11 7L0 7L4.32052 1.50115C4.92109 0.736796 6.07891 0.736795 6.67948 1.50115Z", fill: color }) }) }), $[24] = color, $[25] = t11) : t11 = $[25];
|
|
@@ -1723,7 +1716,7 @@ const StyledAvatar = /* @__PURE__ */ styled.div.withConfig({
|
|
|
1723
1716
|
] }), $[39] = arrowPosition, $[40] = as, $[41] = color, $[42] = ref, $[43] = restProps, $[44] = size2, $[45] = status, $[46] = t10, $[47] = t11, $[48] = t12, $[49] = t13, $[50] = title, $[51] = t14) : t14 = $[51], t14;
|
|
1724
1717
|
});
|
|
1725
1718
|
Avatar.displayName = "ForwardRef(Avatar)";
|
|
1726
|
-
function _temp$
|
|
1719
|
+
function _temp$7(s) {
|
|
1727
1720
|
return s === 1 ? 1 : s === 2 ? 3 : s === 3 ? 5 : 0;
|
|
1728
1721
|
}
|
|
1729
1722
|
function _responsiveAvatarCounterSizeStyle(props) {
|
|
@@ -1771,7 +1764,7 @@ const StyledAvatarCounter = /* @__PURE__ */ styled.div.withConfig({
|
|
|
1771
1764
|
size: t0
|
|
1772
1765
|
} = props, size2 = useArrayProp(t0 === void 0 ? 1 : t0);
|
|
1773
1766
|
let t1, t2;
|
|
1774
|
-
$[0] !== size2 ? (t2 = size2.map(_temp$
|
|
1767
|
+
$[0] !== size2 ? (t2 = size2.map(_temp$6), $[0] = size2, $[1] = t2) : t2 = $[1], t1 = t2;
|
|
1775
1768
|
const fontSize2 = t1;
|
|
1776
1769
|
let t3;
|
|
1777
1770
|
$[2] !== count || $[3] !== fontSize2 ? (t3 = /* @__PURE__ */ jsx(Label, { as: "span", size: fontSize2, weight: "medium", children: count }), $[2] = count, $[3] = fontSize2, $[4] = t3) : t3 = $[4];
|
|
@@ -1779,7 +1772,7 @@ const StyledAvatarCounter = /* @__PURE__ */ styled.div.withConfig({
|
|
|
1779
1772
|
return $[5] !== ref || $[6] !== size2 || $[7] !== t3 ? (t4 = /* @__PURE__ */ jsx(StyledAvatarCounter, { $size: size2, "data-ui": "AvatarCounter", ref, children: t3 }), $[5] = ref, $[6] = size2, $[7] = t3, $[8] = t4) : t4 = $[8], t4;
|
|
1780
1773
|
});
|
|
1781
1774
|
AvatarCounter.displayName = "ForwardRef(AvatarCounter)";
|
|
1782
|
-
function _temp$
|
|
1775
|
+
function _temp$6(s) {
|
|
1783
1776
|
return s === 1 ? 1 : s === 2 ? 3 : s === 3 ? 5 : 0;
|
|
1784
1777
|
}
|
|
1785
1778
|
const BASE_STYLES = css`
|
|
@@ -3013,13 +3006,13 @@ const StyledInline = /* @__PURE__ */ styled(Box).withConfig({
|
|
|
3013
3006
|
...restProps
|
|
3014
3007
|
} = props, $[0] = props, $[1] = as, $[2] = childrenProp, $[3] = restProps, $[4] = space) : (as = $[1], childrenProp = $[2], restProps = $[3], space = $[4]);
|
|
3015
3008
|
let t0, t1;
|
|
3016
|
-
$[5] !== childrenProp ? (t1 = Children.map(childrenProp, _temp$
|
|
3009
|
+
$[5] !== childrenProp ? (t1 = Children.map(childrenProp, _temp$5), $[5] = childrenProp, $[6] = t1) : t1 = $[6], t0 = t1;
|
|
3017
3010
|
const children = t0, t2 = useArrayProp(space);
|
|
3018
3011
|
let t3;
|
|
3019
3012
|
return $[7] !== as || $[8] !== children || $[9] !== restProps || $[10] !== t2 ? (t3 = /* @__PURE__ */ jsx(StyledInline, { "data-ui": "Inline", ...restProps, $space: t2, forwardedAs: as, ref, children }), $[7] = as, $[8] = children, $[9] = restProps, $[10] = t2, $[11] = t3) : t3 = $[11], t3;
|
|
3020
3013
|
});
|
|
3021
3014
|
Inline.displayName = "ForwardRef(Inline)";
|
|
3022
|
-
function _temp$
|
|
3015
|
+
function _temp$5(child) {
|
|
3023
3016
|
return child && /* @__PURE__ */ jsx("div", { children: child });
|
|
3024
3017
|
}
|
|
3025
3018
|
function kbdStyle() {
|
|
@@ -3458,7 +3451,7 @@ function LayerProvider(props) {
|
|
|
3458
3451
|
[childLevel]: prevLen + 1
|
|
3459
3452
|
};
|
|
3460
3453
|
return setSize(Object.keys(nextState).length), nextState;
|
|
3461
|
-
}) : setSize(_temp$
|
|
3454
|
+
}) : setSize(_temp$4), () => {
|
|
3462
3455
|
childLevel !== void 0 ? setChildLayers((state_0) => {
|
|
3463
3456
|
const nextState_0 = {
|
|
3464
3457
|
...state_0
|
|
@@ -3486,7 +3479,7 @@ function LayerProvider(props) {
|
|
|
3486
3479
|
function _temp2$3(v_0) {
|
|
3487
3480
|
return v_0 - 1;
|
|
3488
3481
|
}
|
|
3489
|
-
function _temp$
|
|
3482
|
+
function _temp$4(v) {
|
|
3490
3483
|
return v + 1;
|
|
3491
3484
|
}
|
|
3492
3485
|
LayerProvider.displayName = "LayerProvider";
|
|
@@ -3580,7 +3573,7 @@ function PortalProvider(props) {
|
|
|
3580
3573
|
children,
|
|
3581
3574
|
element,
|
|
3582
3575
|
__unstable_elements: elementsProp
|
|
3583
|
-
} = props, elements = useUnique(elementsProp), fallbackElement = useSyncExternalStore(emptySubscribe, _temp$
|
|
3576
|
+
} = props, elements = useUnique(elementsProp), fallbackElement = useSyncExternalStore(emptySubscribe, _temp$3, _temp2$2);
|
|
3584
3577
|
let t0;
|
|
3585
3578
|
const t1 = boundaryElement || null, t2 = element || fallbackElement;
|
|
3586
3579
|
let t3;
|
|
@@ -3597,7 +3590,7 @@ function PortalProvider(props) {
|
|
|
3597
3590
|
function _temp2$2() {
|
|
3598
3591
|
return null;
|
|
3599
3592
|
}
|
|
3600
|
-
function _temp$
|
|
3593
|
+
function _temp$3() {
|
|
3601
3594
|
return document.body;
|
|
3602
3595
|
}
|
|
3603
3596
|
PortalProvider.displayName = "PortalProvider";
|
|
@@ -3664,11 +3657,8 @@ const StyledVirtualList = styled.div.withConfig({
|
|
|
3664
3657
|
$[14] === Symbol.for("react.memo_cache_sentinel") ? (t7 = () => {
|
|
3665
3658
|
if (!ref.current)
|
|
3666
3659
|
return;
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
_scrollEl = _scrollEl.parentNode;
|
|
3670
|
-
if (_scrollEl) {
|
|
3671
|
-
const scrollEl = _scrollEl;
|
|
3660
|
+
const scrollEl = findScrollable(ref.current.parentNode);
|
|
3661
|
+
if (scrollEl) {
|
|
3672
3662
|
if (!(scrollEl instanceof HTMLElement))
|
|
3673
3663
|
return;
|
|
3674
3664
|
const handleScroll = () => {
|
|
@@ -3746,6 +3736,16 @@ const StyledVirtualList = styled.div.withConfig({
|
|
|
3746
3736
|
return $[52] !== as || $[53] !== restProps || $[54] !== t14 ? (t15 = /* @__PURE__ */ jsx(StyledVirtualList, { as, "data-ui": "VirtualList", ...restProps, ref, children: t14 }), $[52] = as, $[53] = restProps, $[54] = t14, $[55] = t15) : t15 = $[55], t15;
|
|
3747
3737
|
});
|
|
3748
3738
|
VirtualList.displayName = "ForwardRef(VirtualList)";
|
|
3739
|
+
function findScrollable(parentNode) {
|
|
3740
|
+
let _scrollEl = parentNode;
|
|
3741
|
+
for (; _scrollEl && !_isScrollable(_scrollEl); )
|
|
3742
|
+
_scrollEl = _scrollEl.parentNode;
|
|
3743
|
+
return _scrollEl;
|
|
3744
|
+
}
|
|
3745
|
+
function getElementRef(element) {
|
|
3746
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
3747
|
+
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);
|
|
3748
|
+
}
|
|
3749
3749
|
const 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 = {
|
|
3750
3750
|
top: ["bottom", "left", "right"],
|
|
3751
3751
|
"top-start": ["bottom-start", "left-start", "right-start"],
|
|
@@ -4025,10 +4025,6 @@ const Popover = memo(forwardRef(function(props, forwardedRef) {
|
|
|
4025
4025
|
] });
|
|
4026
4026
|
}));
|
|
4027
4027
|
Popover.displayName = "Memo(ForwardRef(Popover))";
|
|
4028
|
-
function getElementRef(element) {
|
|
4029
|
-
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
4030
|
-
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);
|
|
4031
|
-
}
|
|
4032
4028
|
function radioBaseStyle() {
|
|
4033
4029
|
return css`
|
|
4034
4030
|
position: relative;
|
|
@@ -4711,7 +4707,7 @@ const CLEAR_BUTTON_BOX_STYLE = {
|
|
|
4711
4707
|
const border2 = t0 === void 0 ? !0 : t0, disabled = t1 === void 0 ? !1 : t1, fontSizeProp = t2 === void 0 ? 2 : t2, paddingProp = t3 === void 0 ? 3 : t3, radiusProp = t4 === void 0 ? 2 : t4, spaceProp = t5 === void 0 ? 3 : t5, type = t6 === void 0 ? "text" : t6, ref = useRef(null), rootTheme = useRootTheme(), fontSize2 = useArrayProp(fontSizeProp), padding = useArrayProp(paddingProp), radius = useArrayProp(radiusProp), space = useArrayProp(spaceProp), $hasClearButton = !!clearButton, $hasIcon = !!IconComponent, $hasIconRight = !!IconRightComponent, $hasSuffix = !!suffix, $hasPrefix = !!prefix;
|
|
4712
4708
|
let t7;
|
|
4713
4709
|
$[19] === Symbol.for("react.memo_cache_sentinel") ? (t7 = () => ref.current, $[19] = t7) : t7 = $[19], useImperativeHandle(forwardedRef, t7), useCustomValidity(ref, customValidity);
|
|
4714
|
-
const handleClearMouseDown = _temp$
|
|
4710
|
+
const handleClearMouseDown = _temp$2;
|
|
4715
4711
|
let t8;
|
|
4716
4712
|
$[20] !== onClear ? (t8 = (event_0) => {
|
|
4717
4713
|
event_0.preventDefault(), event_0.stopPropagation(), onClear && onClear(), ref.current?.focus();
|
|
@@ -4769,7 +4765,7 @@ const CLEAR_BUTTON_BOX_STYLE = {
|
|
|
4769
4765
|
] }), $[79] = prefixNode, $[80] = rootTheme.tone, $[81] = suffixNode, $[82] = t27, $[83] = t28) : t28 = $[83], t28;
|
|
4770
4766
|
});
|
|
4771
4767
|
TextInput.displayName = "ForwardRef(TextInput)";
|
|
4772
|
-
function _temp$
|
|
4768
|
+
function _temp$2(event) {
|
|
4773
4769
|
event.preventDefault(), event.stopPropagation();
|
|
4774
4770
|
}
|
|
4775
4771
|
function _temp2$1(v) {
|
|
@@ -4988,21 +4984,16 @@ const StyledTooltip = styled(Layer).withConfig({
|
|
|
4988
4984
|
arrowRef.current = arrowEl, update();
|
|
4989
4985
|
}, [update]), setFloating = useCallback((node) => {
|
|
4990
4986
|
ref.current = node, refs.setFloating(node);
|
|
4991
|
-
}, [refs]),
|
|
4992
|
-
useImperativeHandle(childProp?.ref, () => childRef.current);
|
|
4993
|
-
const child = useMemo(() => childProp ? cloneElement(childProp, {
|
|
4987
|
+
}, [refs]), child = useMemo(() => childProp ? cloneElement(childProp, {
|
|
4994
4988
|
onBlur: handleBlur,
|
|
4995
4989
|
onFocus: handleFocus,
|
|
4996
4990
|
onMouseEnter: handleMouseEnter,
|
|
4997
4991
|
onMouseLeave: handleMouseLeave,
|
|
4998
4992
|
onClick: handleClick,
|
|
4999
4993
|
onContextMenu: handleContextMenu,
|
|
5000
|
-
ref:
|
|
4994
|
+
ref: setReferenceElement
|
|
5001
4995
|
}) : null, [childProp, handleBlur, handleClick, handleContextMenu, handleFocus, handleMouseEnter, handleMouseLeave]);
|
|
5002
|
-
if (
|
|
5003
|
-
if (child)
|
|
5004
|
-
return setReferenceElement(childRef.current), () => setReferenceElement(null);
|
|
5005
|
-
}, [child]), !child) return /* @__PURE__ */ jsx(Fragment, {});
|
|
4996
|
+
if (useImperativeHandle(childProp ? getElementRef(childProp) : null, () => referenceElement, [referenceElement]), !child) return /* @__PURE__ */ jsx(Fragment, {});
|
|
5006
4997
|
if (disabled) return child;
|
|
5007
4998
|
const tooltip = /* @__PURE__ */ jsx(StyledTooltip, { "data-ui": "Tooltip", ...restProps, ref: setFloating, style: {
|
|
5008
4999
|
...floatingStyles,
|
|
@@ -5841,8 +5832,8 @@ const StyledMenu = styled(Box).withConfig({
|
|
|
5841
5832
|
});
|
|
5842
5833
|
Menu.displayName = "ForwardRef(Menu)";
|
|
5843
5834
|
const MenuButton = forwardRef(function(props, forwardedRef) {
|
|
5844
|
-
const
|
|
5845
|
-
__unstable_disableRestoreFocusOnClose:
|
|
5835
|
+
const {
|
|
5836
|
+
__unstable_disableRestoreFocusOnClose: disableRestoreFocusOnClose = !1,
|
|
5846
5837
|
boundaryElement: deprecated_boundaryElement,
|
|
5847
5838
|
button: buttonProp,
|
|
5848
5839
|
id,
|
|
@@ -5851,38 +5842,23 @@ const MenuButton = forwardRef(function(props, forwardedRef) {
|
|
|
5851
5842
|
onOpen,
|
|
5852
5843
|
placement: deprecated_placement,
|
|
5853
5844
|
popoverScheme: deprecated_popoverScheme,
|
|
5854
|
-
portal:
|
|
5845
|
+
portal: deprecated_portal = !0,
|
|
5855
5846
|
popover,
|
|
5856
5847
|
popoverRadius: deprecated_popoverRadius,
|
|
5857
5848
|
preventOverflow: deprecated_preventOverflow
|
|
5858
|
-
} = props,
|
|
5859
|
-
|
|
5860
|
-
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t2 = [], $[0] = t2) : t2 = $[0];
|
|
5861
|
-
const [menuElements, setChildMenuElements] = useState(t2), openRef = useRef(open);
|
|
5862
|
-
let t3, t4;
|
|
5863
|
-
$[1] !== onOpen || $[2] !== open ? (t3 = () => {
|
|
5849
|
+
} = props, [open, setOpen] = useState(!1), [shouldFocus, setShouldFocus] = useState(null), [buttonElement, setButtonElement] = useState(null), [menuElements, setChildMenuElements] = useState([]), openRef = useRef(open);
|
|
5850
|
+
useEffect(() => {
|
|
5864
5851
|
onOpen && open && !openRef.current && onOpen();
|
|
5865
|
-
},
|
|
5866
|
-
let t5, t6;
|
|
5867
|
-
$[5] !== onClose || $[6] !== open ? (t5 = () => {
|
|
5852
|
+
}, [onOpen, open]), useEffect(() => {
|
|
5868
5853
|
onClose && !open && openRef.current && onClose();
|
|
5869
|
-
},
|
|
5870
|
-
let t7, t8;
|
|
5871
|
-
$[9] !== open ? (t7 = () => {
|
|
5854
|
+
}, [onClose, open]), useEffect(() => {
|
|
5872
5855
|
openRef.current = open;
|
|
5873
|
-
},
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
}, $[12] = t9) : t9 = $[12];
|
|
5878
|
-
const handleButtonClick = t9;
|
|
5879
|
-
let t10;
|
|
5880
|
-
$[13] !== open ? (t10 = (event) => {
|
|
5856
|
+
}, [open]);
|
|
5857
|
+
const handleButtonClick = useCallback(() => {
|
|
5858
|
+
setOpen((v) => !v), setShouldFocus(null);
|
|
5859
|
+
}, []), handleMouseDown = useCallback((event) => {
|
|
5881
5860
|
open && event.preventDefault();
|
|
5882
|
-
},
|
|
5883
|
-
const handleMouseDown = t10;
|
|
5884
|
-
let t11;
|
|
5885
|
-
$[15] === Symbol.for("react.memo_cache_sentinel") ? (t11 = (event_0) => {
|
|
5861
|
+
}, [open]), handleButtonKeyDown = useCallback((event_0) => {
|
|
5886
5862
|
if (event_0.key === "ArrowDown" || event_0.key === "Enter" || event_0.key === " ") {
|
|
5887
5863
|
event_0.preventDefault(), setOpen(!0), setShouldFocus("first");
|
|
5888
5864
|
return;
|
|
@@ -5891,10 +5867,7 @@ const MenuButton = forwardRef(function(props, forwardedRef) {
|
|
|
5891
5867
|
event_0.preventDefault(), setOpen(!0), setShouldFocus("last");
|
|
5892
5868
|
return;
|
|
5893
5869
|
}
|
|
5894
|
-
},
|
|
5895
|
-
const handleButtonKeyDown = t11;
|
|
5896
|
-
let t12;
|
|
5897
|
-
$[16] !== buttonElement || $[17] !== menuElements ? (t12 = (event_1) => {
|
|
5870
|
+
}, []), handleMenuClickOutside = useCallback((event_1) => {
|
|
5898
5871
|
const target = event_1.target;
|
|
5899
5872
|
if (target instanceof Node && !(buttonElement && (target === buttonElement || buttonElement.contains(target)))) {
|
|
5900
5873
|
for (const el of menuElements)
|
|
@@ -5902,15 +5875,9 @@ const MenuButton = forwardRef(function(props, forwardedRef) {
|
|
|
5902
5875
|
return;
|
|
5903
5876
|
setOpen(!1);
|
|
5904
5877
|
}
|
|
5905
|
-
},
|
|
5906
|
-
const handleMenuClickOutside = t12;
|
|
5907
|
-
let t13;
|
|
5908
|
-
$[19] !== buttonElement || $[20] !== disableRestoreFocusOnClose ? (t13 = () => {
|
|
5878
|
+
}, [buttonElement, menuElements]), handleMenuEscape = useCallback(() => {
|
|
5909
5879
|
setOpen(!1), !disableRestoreFocusOnClose && buttonElement && buttonElement.focus();
|
|
5910
|
-
},
|
|
5911
|
-
const handleMenuEscape = t13;
|
|
5912
|
-
let t14;
|
|
5913
|
-
$[22] !== menuElements ? (t14 = (event_2) => {
|
|
5880
|
+
}, [buttonElement, disableRestoreFocusOnClose]), handleBlur = useCallback((event_2) => {
|
|
5914
5881
|
const target_0 = event_2.relatedTarget;
|
|
5915
5882
|
if (target_0 instanceof Node) {
|
|
5916
5883
|
for (const el_0 of menuElements)
|
|
@@ -5918,18 +5885,9 @@ const MenuButton = forwardRef(function(props, forwardedRef) {
|
|
|
5918
5885
|
return;
|
|
5919
5886
|
setOpen(!1);
|
|
5920
5887
|
}
|
|
5921
|
-
},
|
|
5922
|
-
const handleBlur = t14;
|
|
5923
|
-
let t15;
|
|
5924
|
-
$[24] !== buttonElement || $[25] !== disableRestoreFocusOnClose ? (t15 = () => {
|
|
5888
|
+
}, [menuElements]), handleItemClick = useCallback(() => {
|
|
5925
5889
|
setOpen(!1), !disableRestoreFocusOnClose && buttonElement && buttonElement.focus();
|
|
5926
|
-
},
|
|
5927
|
-
const handleItemClick = t15;
|
|
5928
|
-
let t16;
|
|
5929
|
-
$[27] === Symbol.for("react.memo_cache_sentinel") ? (t16 = (el_1) => (setChildMenuElements((els) => els.concat([el_1])), () => setChildMenuElements((els_0) => els_0.filter((_el) => _el !== el_1))), $[27] = t16) : t16 = $[27];
|
|
5930
|
-
const registerElement = t16;
|
|
5931
|
-
let t17;
|
|
5932
|
-
$[28] !== buttonElement || $[29] !== handleBlur || $[30] !== handleItemClick || $[31] !== handleMenuClickOutside || $[32] !== handleMenuEscape || $[33] !== id || $[34] !== menuProp || $[35] !== shouldFocus ? (t17 = menuProp && cloneElement(menuProp, {
|
|
5890
|
+
}, [buttonElement, disableRestoreFocusOnClose]), registerElement = useCallback((el_1) => (setChildMenuElements((els) => els.concat([el_1])), () => setChildMenuElements((els_0) => els_0.filter((_el) => _el !== el_1))), []), menu = menuProp && cloneElement(menuProp, {
|
|
5933
5891
|
"aria-labelledby": id,
|
|
5934
5892
|
onBlurCapture: handleBlur,
|
|
5935
5893
|
onClickOutside: handleMenuClickOutside,
|
|
@@ -5938,10 +5896,7 @@ const MenuButton = forwardRef(function(props, forwardedRef) {
|
|
|
5938
5896
|
originElement: buttonElement,
|
|
5939
5897
|
registerElement,
|
|
5940
5898
|
shouldFocus
|
|
5941
|
-
}),
|
|
5942
|
-
const menu = t17;
|
|
5943
|
-
let t18, t19;
|
|
5944
|
-
$[37] !== buttonProp || $[38] !== handleMouseDown || $[39] !== id || $[40] !== open ? (t19 = buttonProp && cloneElement(buttonProp, {
|
|
5899
|
+
}), button = useMemo(() => buttonProp && cloneElement(buttonProp, {
|
|
5945
5900
|
"data-ui": "MenuButton",
|
|
5946
5901
|
id,
|
|
5947
5902
|
onClick: handleButtonClick,
|
|
@@ -5951,14 +5906,9 @@ const MenuButton = forwardRef(function(props, forwardedRef) {
|
|
|
5951
5906
|
"aria-expanded": open,
|
|
5952
5907
|
ref: setButtonElement,
|
|
5953
5908
|
selected: buttonProp.props.selected ?? open
|
|
5954
|
-
}),
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
$[42] !== buttonElement ? (t20 = () => buttonElement, t21 = [buttonElement], $[42] = buttonElement, $[43] = t20, $[44] = t21) : (t20 = $[43], t21 = $[44]), useImperativeHandle(forwardedRef, t20, t21);
|
|
5958
|
-
let t22, t23;
|
|
5959
|
-
$[45] !== popover ? (t23 = popover || {}, $[45] = popover, $[46] = t23) : t23 = $[46];
|
|
5960
|
-
let t24;
|
|
5961
|
-
$[47] !== deprecated_boundaryElement || $[48] !== deprecated_placement || $[49] !== deprecated_popoverRadius || $[50] !== deprecated_popoverScheme || $[51] !== deprecated_portal || $[52] !== deprecated_preventOverflow || $[53] !== t23 ? (t24 = {
|
|
5909
|
+
}), [buttonProp, handleButtonClick, handleButtonKeyDown, handleMouseDown, id, open]);
|
|
5910
|
+
useImperativeHandle(forwardedRef, () => buttonElement, [buttonElement]);
|
|
5911
|
+
const popoverProps = useMemo(() => ({
|
|
5962
5912
|
boundaryElement: deprecated_boundaryElement,
|
|
5963
5913
|
overflow: "auto",
|
|
5964
5914
|
placement: deprecated_placement,
|
|
@@ -5966,18 +5916,11 @@ const MenuButton = forwardRef(function(props, forwardedRef) {
|
|
|
5966
5916
|
preventOverflow: deprecated_preventOverflow,
|
|
5967
5917
|
radius: deprecated_popoverRadius,
|
|
5968
5918
|
scheme: deprecated_popoverScheme,
|
|
5969
|
-
...
|
|
5970
|
-
},
|
|
5971
|
-
|
|
5972
|
-
let t25;
|
|
5973
|
-
$[55] !== button ? (t25 = button || /* @__PURE__ */ jsx(Fragment, {}), $[55] = button, $[56] = t25) : t25 = $[56];
|
|
5974
|
-
let t26;
|
|
5975
|
-
return $[57] !== menu || $[58] !== open || $[59] !== popoverProps || $[60] !== t25 ? (t26 = /* @__PURE__ */ jsx(Popover, { "data-ui": "MenuButton__popover", ...popoverProps, content: menu, open, children: t25 }), $[57] = menu, $[58] = open, $[59] = popoverProps, $[60] = t25, $[61] = t26) : t26 = $[61], t26;
|
|
5919
|
+
...popover || {}
|
|
5920
|
+
}), [deprecated_boundaryElement, deprecated_placement, deprecated_popoverRadius, deprecated_popoverScheme, deprecated_portal, deprecated_preventOverflow, popover]);
|
|
5921
|
+
return /* @__PURE__ */ jsx(Popover, { "data-ui": "MenuButton__popover", ...popoverProps, content: menu, open, children: button || /* @__PURE__ */ jsx(Fragment, {}) });
|
|
5976
5922
|
});
|
|
5977
5923
|
MenuButton.displayName = "ForwardRef(MenuButton)";
|
|
5978
|
-
function _temp$2(v) {
|
|
5979
|
-
return !v;
|
|
5980
|
-
}
|
|
5981
5924
|
const MenuDivider = styled.hr.withConfig({
|
|
5982
5925
|
displayName: "MenuDivider",
|
|
5983
5926
|
componentId: "sc-uhoxwu-0"
|