@sanity/ui 3.0.9 → 3.0.11-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks-cjs/_visual-editing.js +82 -64
- package/dist/_chunks-cjs/_visual-editing.js.map +1 -1
- package/dist/_chunks-es/_visual-editing.mjs +82 -64
- package/dist/_chunks-es/_visual-editing.mjs.map +1 -1
- package/dist/index.js +308 -98
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +310 -100
- package/dist/index.mjs.map +1 -1
- package/package.json +31 -45
- package/src/core/components/autocomplete/autocomplete.tsx +79 -47
- package/src/core/components/menu/menu.test.tsx +11 -14
- package/src/core/components/menu/menu.tsx +13 -18
- package/src/core/components/menu/menuContext.ts +3 -14
- package/src/core/components/menu/menuGroup.tsx +1 -1
- package/src/core/components/menu/menuItem.tsx +2 -2
- package/src/core/components/menu/useMenu.ts +2 -2
- package/src/core/components/menu/useMenuController.ts +5 -5
- package/src/core/components/tree/treeItem.tsx +17 -15
- package/src/core/hooks/useClickOutside.test.tsx +1 -1
- package/src/core/lib/createGlobalScopedContext.ts +3 -1
- package/src/core/primitives/avatar/avatar.tsx +1 -0
- package/src/core/primitives/card/card.tsx +1 -0
- package/src/core/primitives/popover/types.ts +2 -1
- package/src/core/styles/font/responsiveFont.ts +2 -0
- package/src/core/theme/__workshop__/canvas.tsx +1 -0
- package/src/core/utils/portal/portalProvider.tsx +2 -34
|
@@ -197,7 +197,7 @@ function useArrayProp(val, defaultVal) {
|
|
|
197
197
|
return hash !== cachedHash && setCache([_getArrayProp(val, defaultVal), hash]), cachedVal;
|
|
198
198
|
}
|
|
199
199
|
function useClickOutsideEvent(listener, t0, boundaryElement) {
|
|
200
|
-
const $ = reactCompilerRuntime.c(9), elementsArg = t0 === void 0 ? _temp$
|
|
200
|
+
const $ = reactCompilerRuntime.c(9), elementsArg = t0 === void 0 ? _temp$a : t0;
|
|
201
201
|
let t1;
|
|
202
202
|
$[0] !== boundaryElement || $[1] !== elementsArg || $[2] !== listener ? (t1 = (evt) => {
|
|
203
203
|
if (!listener)
|
|
@@ -227,7 +227,7 @@ function useClickOutsideEvent(listener, t0, boundaryElement) {
|
|
|
227
227
|
let t3;
|
|
228
228
|
$[7] !== hasListener ? (t3 = [hasListener], $[7] = hasListener, $[8] = t3) : t3 = $[8], react.useEffect(t2, t3), react.useDebugValue(listener ? "MouseDown On" : "MouseDown Off");
|
|
229
229
|
}
|
|
230
|
-
function _temp$
|
|
230
|
+
function _temp$a() {
|
|
231
231
|
return EMPTY_ARRAY;
|
|
232
232
|
}
|
|
233
233
|
function useCustomValidity(ref, customValidity) {
|
|
@@ -318,7 +318,11 @@ function getGlobalScope() {
|
|
|
318
318
|
const globalScope = getGlobalScope();
|
|
319
319
|
function createGlobalScopedContext(key2, defaultValue) {
|
|
320
320
|
const symbol = Symbol.for(key2);
|
|
321
|
-
|
|
321
|
+
if (typeof document > "u") {
|
|
322
|
+
const context = react.createContext(defaultValue);
|
|
323
|
+
return context.displayName = key2, context;
|
|
324
|
+
}
|
|
325
|
+
return globalScope[symbol] = globalScope[symbol] || react.createContext(defaultValue), globalScope[symbol];
|
|
322
326
|
}
|
|
323
327
|
const ThemeContext = createGlobalScopedContext("@sanity/ui/context/theme", null);
|
|
324
328
|
function ThemeProvider(props) {
|
|
@@ -442,15 +446,15 @@ function useMediaIndex() {
|
|
|
442
446
|
return react.useSyncExternalStore(store.subscribe, store.getSnapshot, getServerSnapshot);
|
|
443
447
|
}
|
|
444
448
|
function usePrefersDark(t0) {
|
|
445
|
-
return useMatchMedia("(prefers-color-scheme: dark)", t0 === void 0 ? _temp$
|
|
449
|
+
return useMatchMedia("(prefers-color-scheme: dark)", t0 === void 0 ? _temp$9 : t0);
|
|
446
450
|
}
|
|
447
|
-
function _temp$
|
|
451
|
+
function _temp$9() {
|
|
448
452
|
return !1;
|
|
449
453
|
}
|
|
450
454
|
function usePrefersReducedMotion(t0) {
|
|
451
|
-
return useMatchMedia("(prefers-reduced-motion: reduce)", t0 === void 0 ? _temp$
|
|
455
|
+
return useMatchMedia("(prefers-reduced-motion: reduce)", t0 === void 0 ? _temp$8 : t0);
|
|
452
456
|
}
|
|
453
|
-
function _temp$
|
|
457
|
+
function _temp$8() {
|
|
454
458
|
return !1;
|
|
455
459
|
}
|
|
456
460
|
function responsiveBorderStyle() {
|
|
@@ -1395,7 +1399,7 @@ const StyledAvatar = /* @__PURE__ */ styledComponents.styled.div.withConfig({
|
|
|
1395
1399
|
}, $[20] = onImageLoadError, $[21] = t7) : t7 = $[21];
|
|
1396
1400
|
const handleImageError = t7;
|
|
1397
1401
|
let t8;
|
|
1398
|
-
$[22] !== size2 ? (t8 = size2.map(_temp$
|
|
1402
|
+
$[22] !== size2 ? (t8 = size2.map(_temp$7), $[22] = size2, $[23] = t8) : t8 = $[23];
|
|
1399
1403
|
const initialsSize = t8, t9 = typeof as == "string" ? as : void 0;
|
|
1400
1404
|
let t10;
|
|
1401
1405
|
$[24] !== color ? (t10 = /* @__PURE__ */ jsxRuntime.jsx(Arrow$1, { children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "11", height: "7", viewBox: "0 0 11 7", fill: "none", children: /* @__PURE__ */ jsxRuntime.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] = t10) : t10 = $[25];
|
|
@@ -1416,7 +1420,7 @@ const StyledAvatar = /* @__PURE__ */ styledComponents.styled.div.withConfig({
|
|
|
1416
1420
|
] }), $[39] = arrowPosition, $[40] = as, $[41] = color, $[42] = ref, $[43] = restProps, $[44] = size2, $[45] = status, $[46] = t10, $[47] = t11, $[48] = t12, $[49] = t9, $[50] = title, $[51] = t13) : t13 = $[51], t13;
|
|
1417
1421
|
});
|
|
1418
1422
|
Avatar.displayName = "ForwardRef(Avatar)";
|
|
1419
|
-
function _temp$
|
|
1423
|
+
function _temp$7(s) {
|
|
1420
1424
|
return s === 1 ? 1 : s === 2 ? 3 : s === 3 ? 5 : 0;
|
|
1421
1425
|
}
|
|
1422
1426
|
function _responsiveAvatarCounterSizeStyle(props) {
|
|
@@ -1464,7 +1468,7 @@ const StyledAvatarCounter = /* @__PURE__ */ styledComponents.styled.div.withConf
|
|
|
1464
1468
|
size: t0
|
|
1465
1469
|
} = props, size2 = useArrayProp(t0 === void 0 ? 1 : t0);
|
|
1466
1470
|
let t1;
|
|
1467
|
-
$[0] !== size2 ? (t1 = size2.map(_temp$
|
|
1471
|
+
$[0] !== size2 ? (t1 = size2.map(_temp$6), $[0] = size2, $[1] = t1) : t1 = $[1];
|
|
1468
1472
|
const fontSize2 = t1;
|
|
1469
1473
|
let t2;
|
|
1470
1474
|
$[2] !== count || $[3] !== fontSize2 ? (t2 = /* @__PURE__ */ jsxRuntime.jsx(Label, { as: "span", size: fontSize2, weight: "medium", children: count }), $[2] = count, $[3] = fontSize2, $[4] = t2) : t2 = $[4];
|
|
@@ -1472,7 +1476,7 @@ const StyledAvatarCounter = /* @__PURE__ */ styledComponents.styled.div.withConf
|
|
|
1472
1476
|
return $[5] !== ref || $[6] !== size2 || $[7] !== t2 ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(StyledAvatarCounter, { $size: size2, "data-ui": "AvatarCounter", ref, children: t2 }), $[5] = ref, $[6] = size2, $[7] = t2, $[8] = t3) : t3 = $[8], t3;
|
|
1473
1477
|
});
|
|
1474
1478
|
AvatarCounter.displayName = "ForwardRef(AvatarCounter)";
|
|
1475
|
-
function _temp$
|
|
1479
|
+
function _temp$6(s) {
|
|
1476
1480
|
return s === 1 ? 1 : s === 2 ? 3 : s === 3 ? 5 : 0;
|
|
1477
1481
|
}
|
|
1478
1482
|
const BASE_STYLES = styledComponents.css`
|
|
@@ -2709,13 +2713,13 @@ const StyledInline = /* @__PURE__ */ styledComponents.styled(Box).withConfig({
|
|
|
2709
2713
|
...restProps
|
|
2710
2714
|
} = props, $[0] = props, $[1] = as, $[2] = childrenProp, $[3] = restProps, $[4] = space) : (as = $[1], childrenProp = $[2], restProps = $[3], space = $[4]);
|
|
2711
2715
|
let t0;
|
|
2712
|
-
$[5] !== childrenProp ? (t0 = react.Children.map(childrenProp, _temp$
|
|
2716
|
+
$[5] !== childrenProp ? (t0 = react.Children.map(childrenProp, _temp$5), $[5] = childrenProp, $[6] = t0) : t0 = $[6];
|
|
2713
2717
|
const children = t0, t1 = useArrayProp(space), t2 = ref;
|
|
2714
2718
|
let t3;
|
|
2715
2719
|
return $[7] !== as || $[8] !== children || $[9] !== restProps || $[10] !== t1 || $[11] !== t2 ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(StyledInline, { "data-ui": "Inline", ...restProps, $space: t1, forwardedAs: as, ref: t2, children }), $[7] = as, $[8] = children, $[9] = restProps, $[10] = t1, $[11] = t2, $[12] = t3) : t3 = $[12], t3;
|
|
2716
2720
|
});
|
|
2717
2721
|
Inline.displayName = "ForwardRef(Inline)";
|
|
2718
|
-
function _temp$
|
|
2722
|
+
function _temp$5(child) {
|
|
2719
2723
|
return child && /* @__PURE__ */ jsxRuntime.jsx("div", { children: child });
|
|
2720
2724
|
}
|
|
2721
2725
|
function kbdStyle() {
|
|
@@ -3036,7 +3040,7 @@ function LayerProvider(props) {
|
|
|
3036
3040
|
[childLevel]: prevLen + 1
|
|
3037
3041
|
};
|
|
3038
3042
|
return setSize(Object.keys(nextState).length), nextState;
|
|
3039
|
-
}) : setSize(_temp$
|
|
3043
|
+
}) : setSize(_temp$4), () => {
|
|
3040
3044
|
childLevel !== void 0 ? setChildLayers((state_0) => {
|
|
3041
3045
|
const nextState_0 = {
|
|
3042
3046
|
...state_0
|
|
@@ -3064,7 +3068,7 @@ function LayerProvider(props) {
|
|
|
3064
3068
|
function _temp2$2(v_0) {
|
|
3065
3069
|
return v_0 - 1;
|
|
3066
3070
|
}
|
|
3067
|
-
function _temp$
|
|
3071
|
+
function _temp$4(v) {
|
|
3068
3072
|
return v + 1;
|
|
3069
3073
|
}
|
|
3070
3074
|
LayerProvider.displayName = "LayerProvider";
|
|
@@ -3169,8 +3173,8 @@ function PortalProvider(props) {
|
|
|
3169
3173
|
boundaryElement,
|
|
3170
3174
|
children,
|
|
3171
3175
|
element,
|
|
3172
|
-
__unstable_elements:
|
|
3173
|
-
} = props,
|
|
3176
|
+
__unstable_elements: elements
|
|
3177
|
+
} = props, fallbackElement = react.useSyncExternalStore(emptySubscribe, _temp$3, _temp2$1), t0 = boundaryElement || null, t1 = element || fallbackElement;
|
|
3174
3178
|
let t2;
|
|
3175
3179
|
$[0] !== elements || $[1] !== t0 || $[2] !== t1 ? (t2 = {
|
|
3176
3180
|
version: 0,
|
|
@@ -3185,23 +3189,12 @@ function PortalProvider(props) {
|
|
|
3185
3189
|
function _temp2$1() {
|
|
3186
3190
|
return null;
|
|
3187
3191
|
}
|
|
3188
|
-
function _temp$
|
|
3192
|
+
function _temp$3() {
|
|
3189
3193
|
return document.body;
|
|
3190
3194
|
}
|
|
3191
3195
|
PortalProvider.displayName = "PortalProvider";
|
|
3192
3196
|
const emptySubscribe = () => () => {
|
|
3193
|
-
}
|
|
3194
|
-
function useUnique(value) {
|
|
3195
|
-
const valueRef = react.useRef(value);
|
|
3196
|
-
return _isEqual(valueRef.current, value) || (valueRef.current = value), valueRef.current;
|
|
3197
|
-
}
|
|
3198
|
-
function _isEqual(objA, objB) {
|
|
3199
|
-
if (!objA || !objB)
|
|
3200
|
-
return objA === objB;
|
|
3201
|
-
const keysA = Object.keys(objA), keysB = Object.keys(objB);
|
|
3202
|
-
return keysA.length !== keysB.length ? !1 : keysA.every((key2) => objA[key2] === objB[key2]);
|
|
3203
|
-
}
|
|
3204
|
-
const StyledSrOnly = styledComponents.styled.div.withConfig({
|
|
3197
|
+
}, StyledSrOnly = styledComponents.styled.div.withConfig({
|
|
3205
3198
|
displayName: "StyledSrOnly",
|
|
3206
3199
|
componentId: "sc-mubr0c-0"
|
|
3207
3200
|
})`display:block;width:0;height:0;position:absolute;overflow:hidden;overflow:clip;`, SrOnly = react.forwardRef(function(props, ref) {
|
|
@@ -4274,7 +4267,7 @@ const CLEAR_BUTTON_BOX_STYLE = {
|
|
|
4274
4267
|
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 = react.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;
|
|
4275
4268
|
let t7;
|
|
4276
4269
|
$[19] === Symbol.for("react.memo_cache_sentinel") ? (t7 = () => ref.current, $[19] = t7) : t7 = $[19], react.useImperativeHandle(forwardedRef, t7), useCustomValidity(ref, customValidity);
|
|
4277
|
-
const handleClearMouseDown = _temp$
|
|
4270
|
+
const handleClearMouseDown = _temp$2;
|
|
4278
4271
|
let t8;
|
|
4279
4272
|
$[20] !== onClear ? (t8 = (event_0) => {
|
|
4280
4273
|
event_0.preventDefault(), event_0.stopPropagation(), onClear && onClear(), ref.current?.focus();
|
|
@@ -4327,7 +4320,7 @@ const CLEAR_BUTTON_BOX_STYLE = {
|
|
|
4327
4320
|
] }), $[79] = prefixNode, $[80] = rootTheme.tone, $[81] = suffixNode, $[82] = t20, $[83] = t21) : t21 = $[83], t21;
|
|
4328
4321
|
});
|
|
4329
4322
|
TextInput.displayName = "ForwardRef(TextInput)";
|
|
4330
|
-
function _temp$
|
|
4323
|
+
function _temp$2(event) {
|
|
4331
4324
|
event.preventDefault(), event.stopPropagation();
|
|
4332
4325
|
}
|
|
4333
4326
|
function _temp2(v) {
|
|
@@ -4665,16 +4658,24 @@ function _sortElements(rootElement, elements) {
|
|
|
4665
4658
|
elements.sort(_sort);
|
|
4666
4659
|
}
|
|
4667
4660
|
function useMenuController(props) {
|
|
4668
|
-
const {
|
|
4661
|
+
const $ = reactCompilerRuntime.c(21), {
|
|
4669
4662
|
onKeyDown,
|
|
4670
4663
|
originElement,
|
|
4671
4664
|
shouldFocus,
|
|
4672
4665
|
rootElementRef
|
|
4673
|
-
} = props
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4666
|
+
} = props;
|
|
4667
|
+
let t0;
|
|
4668
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = [], $[0] = t0) : t0 = $[0];
|
|
4669
|
+
const elementsRef = react.useRef(t0), [activeIndex, _setActiveIndex] = react.useState(-1), activeIndexRef = react.useRef(activeIndex), [activeElement, setActiveElement] = react.useState(null);
|
|
4670
|
+
let t1;
|
|
4671
|
+
$[1] === Symbol.for("react.memo_cache_sentinel") ? (t1 = (nextActiveIndex) => {
|
|
4672
|
+
_setActiveIndex(nextActiveIndex), activeIndexRef.current = nextActiveIndex, setActiveElement(elementsRef.current[nextActiveIndex] || null);
|
|
4673
|
+
}, $[1] = t1) : t1 = $[1];
|
|
4674
|
+
const setActiveIndex = t1;
|
|
4675
|
+
let t2;
|
|
4676
|
+
$[2] !== rootElementRef ? (t2 = (element, selected) => {
|
|
4677
|
+
if (!element)
|
|
4678
|
+
return _temp$1;
|
|
4678
4679
|
if (elementsRef.current.indexOf(element) === -1 && (elementsRef.current.push(element), _sortElements(rootElementRef.current, elementsRef.current)), selected) {
|
|
4679
4680
|
const selectedIndex = elementsRef.current.indexOf(element);
|
|
4680
4681
|
setActiveIndex(selectedIndex);
|
|
@@ -4683,7 +4684,10 @@ function useMenuController(props) {
|
|
|
4683
4684
|
const idx = elementsRef.current.indexOf(element);
|
|
4684
4685
|
idx > -1 && elementsRef.current.splice(idx, 1);
|
|
4685
4686
|
};
|
|
4686
|
-
}, [rootElementRef,
|
|
4687
|
+
}, $[2] = rootElementRef, $[3] = t2) : t2 = $[3];
|
|
4688
|
+
const mount = t2;
|
|
4689
|
+
let t3;
|
|
4690
|
+
$[4] !== onKeyDown || $[5] !== originElement ? (t3 = (event) => {
|
|
4687
4691
|
if (event.key === "Tab") {
|
|
4688
4692
|
originElement && originElement.focus();
|
|
4689
4693
|
return;
|
|
@@ -4691,7 +4695,8 @@ function useMenuController(props) {
|
|
|
4691
4695
|
if (event.key === "Home") {
|
|
4692
4696
|
event.preventDefault(), event.stopPropagation();
|
|
4693
4697
|
const el = _getFocusableElements(elementsRef.current)[0];
|
|
4694
|
-
if (!el)
|
|
4698
|
+
if (!el)
|
|
4699
|
+
return;
|
|
4695
4700
|
const currentIndex = elementsRef.current.indexOf(el);
|
|
4696
4701
|
setActiveIndex(currentIndex);
|
|
4697
4702
|
return;
|
|
@@ -4699,7 +4704,8 @@ function useMenuController(props) {
|
|
|
4699
4704
|
if (event.key === "End") {
|
|
4700
4705
|
event.preventDefault(), event.stopPropagation();
|
|
4701
4706
|
const focusableElements_0 = _getFocusableElements(elementsRef.current), el_0 = focusableElements_0[focusableElements_0.length - 1];
|
|
4702
|
-
if (!el_0)
|
|
4707
|
+
if (!el_0)
|
|
4708
|
+
return;
|
|
4703
4709
|
const currentIndex_0 = elementsRef.current.indexOf(el_0);
|
|
4704
4710
|
setActiveIndex(currentIndex_0);
|
|
4705
4711
|
return;
|
|
@@ -4707,7 +4713,8 @@ function useMenuController(props) {
|
|
|
4707
4713
|
if (event.key === "ArrowUp") {
|
|
4708
4714
|
event.preventDefault(), event.stopPropagation();
|
|
4709
4715
|
const focusableElements_1 = _getFocusableElements(elementsRef.current), focusableLen = focusableElements_1.length;
|
|
4710
|
-
if (focusableLen === 0)
|
|
4716
|
+
if (focusableLen === 0)
|
|
4717
|
+
return;
|
|
4711
4718
|
const focusedElement = elementsRef.current[activeIndexRef.current];
|
|
4712
4719
|
let focusedIndex = focusableElements_1.indexOf(focusedElement);
|
|
4713
4720
|
focusedIndex = (focusedIndex - 1 + focusableLen) % focusableLen;
|
|
@@ -4718,7 +4725,8 @@ function useMenuController(props) {
|
|
|
4718
4725
|
if (event.key === "ArrowDown") {
|
|
4719
4726
|
event.preventDefault(), event.stopPropagation();
|
|
4720
4727
|
const focusableElements_2 = _getFocusableElements(elementsRef.current), focusableLen_0 = focusableElements_2.length;
|
|
4721
|
-
if (focusableLen_0 === 0)
|
|
4728
|
+
if (focusableLen_0 === 0)
|
|
4729
|
+
return;
|
|
4722
4730
|
const focusedElement_0 = elementsRef.current[activeIndexRef.current];
|
|
4723
4731
|
let focusedIndex_0 = focusableElements_2.indexOf(focusedElement_0);
|
|
4724
4732
|
focusedIndex_0 = (focusedIndex_0 + 1) % focusableLen_0;
|
|
@@ -4727,14 +4735,23 @@ function useMenuController(props) {
|
|
|
4727
4735
|
return;
|
|
4728
4736
|
}
|
|
4729
4737
|
onKeyDown && onKeyDown(event);
|
|
4730
|
-
}, [onKeyDown, originElement,
|
|
4738
|
+
}, $[4] = onKeyDown, $[5] = originElement, $[6] = t3) : t3 = $[6];
|
|
4739
|
+
const handleKeyDown = t3;
|
|
4740
|
+
let t4;
|
|
4741
|
+
$[7] === Symbol.for("react.memo_cache_sentinel") ? (t4 = (event_0) => {
|
|
4731
4742
|
const element_0 = event_0.currentTarget, currentIndex_3 = elementsRef.current.indexOf(element_0);
|
|
4732
4743
|
setActiveIndex(currentIndex_3);
|
|
4733
|
-
}, [
|
|
4744
|
+
}, $[7] = t4) : t4 = $[7];
|
|
4745
|
+
const handleItemMouseEnter = t4;
|
|
4746
|
+
let t5;
|
|
4747
|
+
$[8] !== rootElementRef ? (t5 = () => {
|
|
4734
4748
|
setActiveIndex(-2), rootElementRef.current?.focus();
|
|
4735
|
-
}, [rootElementRef,
|
|
4736
|
-
|
|
4737
|
-
|
|
4749
|
+
}, $[8] = rootElementRef, $[9] = t5) : t5 = $[9];
|
|
4750
|
+
const handleItemMouseLeave = t5;
|
|
4751
|
+
let t6, t7;
|
|
4752
|
+
$[10] !== activeIndex || $[11] !== rootElementRef || $[12] !== shouldFocus ? (t6 = () => {
|
|
4753
|
+
if (!rootElementRef.current)
|
|
4754
|
+
return;
|
|
4738
4755
|
const rafId = requestAnimationFrame(() => {
|
|
4739
4756
|
if (activeIndex === -1) {
|
|
4740
4757
|
if (shouldFocus === "first") {
|
|
@@ -4756,20 +4773,24 @@ function useMenuController(props) {
|
|
|
4756
4773
|
(elementsRef.current[activeIndex] || null)?.focus();
|
|
4757
4774
|
});
|
|
4758
4775
|
return () => cancelAnimationFrame(rafId);
|
|
4759
|
-
}, [activeIndex,
|
|
4776
|
+
}, t7 = [activeIndex, rootElementRef, setActiveIndex, shouldFocus], $[10] = activeIndex, $[11] = rootElementRef, $[12] = shouldFocus, $[13] = t6, $[14] = t7) : (t6 = $[13], t7 = $[14]), react.useEffect(t6, t7);
|
|
4777
|
+
let t8;
|
|
4778
|
+
return $[15] !== activeElement || $[16] !== activeIndex || $[17] !== handleItemMouseLeave || $[18] !== handleKeyDown || $[19] !== mount ? (t8 = {
|
|
4760
4779
|
activeElement,
|
|
4761
4780
|
activeIndex,
|
|
4762
4781
|
handleItemMouseEnter,
|
|
4763
4782
|
handleItemMouseLeave,
|
|
4764
4783
|
handleKeyDown,
|
|
4765
4784
|
mount
|
|
4766
|
-
};
|
|
4785
|
+
}, $[15] = activeElement, $[16] = activeIndex, $[17] = handleItemMouseLeave, $[18] = handleKeyDown, $[19] = mount, $[20] = t8) : t8 = $[20], t8;
|
|
4786
|
+
}
|
|
4787
|
+
function _temp$1() {
|
|
4767
4788
|
}
|
|
4768
4789
|
const StyledMenu = styledComponents.styled(Box).withConfig({
|
|
4769
4790
|
displayName: "StyledMenu",
|
|
4770
4791
|
componentId: "sc-xt0tnv-0"
|
|
4771
4792
|
})`outline:none;overflow:auto;`, Menu = react.forwardRef(function(props, forwardedRef) {
|
|
4772
|
-
const $ = reactCompilerRuntime.c(
|
|
4793
|
+
const $ = reactCompilerRuntime.c(49);
|
|
4773
4794
|
let _shouldFocus, children, onClickOutside, onEscape, onItemClick, onItemSelect, onKeyDown, originElement, registerElement, restProps, t0, t1;
|
|
4774
4795
|
if ($[0] !== props) {
|
|
4775
4796
|
const {
|
|
@@ -4828,27 +4849,24 @@ const StyledMenu = styledComponents.styled(Box).withConfig({
|
|
|
4828
4849
|
isTopLayer && event.key === "Escape" && (event.stopPropagation(), onEscape && onEscape());
|
|
4829
4850
|
}, $[25] = isTopLayer, $[26] = onEscape, $[27] = t8) : t8 = $[27], useGlobalKeyDown(t8);
|
|
4830
4851
|
let t9;
|
|
4831
|
-
$[28] !== activeElement || $[29] !==
|
|
4832
|
-
version:
|
|
4852
|
+
$[28] !== activeElement || $[29] !== handleItemMouseEnter || $[30] !== handleItemMouseLeave || $[31] !== mount || $[32] !== onClickOutside || $[33] !== onEscape || $[34] !== onItemClick || $[35] !== registerElement ? (t9 = {
|
|
4853
|
+
version: 2,
|
|
4833
4854
|
activeElement,
|
|
4834
|
-
activeIndex,
|
|
4835
4855
|
mount,
|
|
4836
4856
|
onClickOutside,
|
|
4837
4857
|
onEscape,
|
|
4838
4858
|
onItemClick,
|
|
4839
4859
|
onItemMouseEnter: handleItemMouseEnter,
|
|
4840
4860
|
onItemMouseLeave: handleItemMouseLeave,
|
|
4841
|
-
registerElement
|
|
4842
|
-
|
|
4843
|
-
onMouseLeave: handleItemMouseLeave
|
|
4844
|
-
}, $[28] = activeElement, $[29] = activeIndex, $[30] = handleItemMouseEnter, $[31] = handleItemMouseLeave, $[32] = mount, $[33] = onClickOutside, $[34] = onEscape, $[35] = onItemClick, $[36] = registerElement, $[37] = t9) : t9 = $[37];
|
|
4861
|
+
registerElement
|
|
4862
|
+
}, $[28] = activeElement, $[29] = handleItemMouseEnter, $[30] = handleItemMouseLeave, $[31] = mount, $[32] = onClickOutside, $[33] = onEscape, $[34] = onItemClick, $[35] = registerElement, $[36] = t9) : t9 = $[36];
|
|
4845
4863
|
const value = t9;
|
|
4846
4864
|
let t10;
|
|
4847
|
-
$[
|
|
4865
|
+
$[37] !== children || $[38] !== space ? (t10 = /* @__PURE__ */ jsxRuntime.jsx(Stack, { space, children }), $[37] = children, $[38] = space, $[39] = t10) : t10 = $[39];
|
|
4848
4866
|
let t11;
|
|
4849
|
-
$[
|
|
4867
|
+
$[40] !== handleKeyDown || $[41] !== handleRefChange || $[42] !== padding || $[43] !== restProps || $[44] !== t10 ? (t11 = /* @__PURE__ */ jsxRuntime.jsx(StyledMenu, { "data-ui": "Menu", ...restProps, onKeyDown: handleKeyDown, padding, ref: handleRefChange, role: "menu", tabIndex: -1, children: t10 }), $[40] = handleKeyDown, $[41] = handleRefChange, $[42] = padding, $[43] = restProps, $[44] = t10, $[45] = t11) : t11 = $[45];
|
|
4850
4868
|
let t12;
|
|
4851
|
-
return $[
|
|
4869
|
+
return $[46] !== t11 || $[47] !== value ? (t12 = /* @__PURE__ */ jsxRuntime.jsx(MenuContext.Provider, { value, children: t11 }), $[46] = t11, $[47] = value, $[48] = t12) : t12 = $[48], t12;
|
|
4852
4870
|
});
|
|
4853
4871
|
Menu.displayName = "ForwardRef(Menu)";
|
|
4854
4872
|
const MenuDivider = styledComponents.styled.hr.withConfig({
|
|
@@ -4965,7 +4983,7 @@ function useMenu() {
|
|
|
4965
4983
|
const value = react.useContext(MenuContext);
|
|
4966
4984
|
if (!value)
|
|
4967
4985
|
throw new Error("useMenu(): missing context value");
|
|
4968
|
-
if (!isRecord(value) || value.version !==
|
|
4986
|
+
if (!isRecord(value) || value.version !== 2)
|
|
4969
4987
|
throw new Error("useMenu(): the context value is not compatible");
|
|
4970
4988
|
return value;
|
|
4971
4989
|
}
|
|
@@ -4997,7 +5015,7 @@ function MenuGroup(props) {
|
|
|
4997
5015
|
onItemClick,
|
|
4998
5016
|
onItemMouseEnter: _onItemMouseEnter,
|
|
4999
5017
|
registerElement
|
|
5000
|
-
} = menu, onItemMouseEnter = _onItemMouseEnter ?? menu.
|
|
5018
|
+
} = menu, onItemMouseEnter = _onItemMouseEnter ?? menu.onItemMouseEnter, [rootElement, setRootElement] = react.useState(null), [open, setOpen] = react.useState(!1), [shouldFocus, setShouldFocus] = react.useState(null), active = !!activeElement && activeElement === rootElement, [withinMenu, setWithinMenu] = react.useState(!1);
|
|
5001
5019
|
let t6;
|
|
5002
5020
|
$[14] !== onItemMouseEnter ? (t6 = (event) => {
|
|
5003
5021
|
setWithinMenu(!1), onItemMouseEnter(event), setOpen(!0);
|
|
@@ -5110,7 +5128,7 @@ const MenuItem = react.forwardRef(function(props, forwardedRef) {
|
|
|
5110
5128
|
onItemClick,
|
|
5111
5129
|
onItemMouseEnter: _onItemMouseEnter,
|
|
5112
5130
|
onItemMouseLeave: _onItemMouseLeave
|
|
5113
|
-
} = menu, onItemMouseEnter = _onItemMouseEnter ?? menu.
|
|
5131
|
+
} = menu, onItemMouseEnter = _onItemMouseEnter ?? menu.onItemMouseEnter, onItemMouseLeave = _onItemMouseLeave ?? menu.onItemMouseLeave, [rootElement, setRootElement] = react.useState(null), active = !!activeElement && activeElement === rootElement, ref = react.useRef(null);
|
|
5114
5132
|
let t6;
|
|
5115
5133
|
$[23] === Symbol.for("react.memo_cache_sentinel") ? (t6 = () => ref.current, $[23] = t6) : t6 = $[23], react.useImperativeHandle(forwardedRef, t6);
|
|
5116
5134
|
let t7, t8;
|