@sanity/ui 2.3.6-canary.3 → 2.3.6-canary.5
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.compiled.mjs +84 -41
- package/dist/index.compiled.mjs.map +1 -1
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +29 -31
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +29 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -31
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/core/components/menu/menu.tsx +2 -0
- package/src/core/components/menu/menuButton.tsx +17 -32
- package/src/core/theme/themeProvider.tsx +2 -2
package/dist/index.compiled.mjs
CHANGED
|
@@ -164,10 +164,10 @@ function createGlobalScopedContext(key2, defaultValue) {
|
|
|
164
164
|
}
|
|
165
165
|
const key$8 = Symbol.for("@sanity/ui/context/theme"), ThemeContext = createGlobalScopedContext(key$8, null);
|
|
166
166
|
function ThemeProvider(props) {
|
|
167
|
-
var _a;
|
|
167
|
+
var _a, _b, _c2;
|
|
168
168
|
const $ = c(15), {
|
|
169
169
|
children
|
|
170
|
-
} = props, parentTheme = useContext(ThemeContext), scheme = (_a = props.scheme) != null ? _a : (parentTheme == null ? void 0 : parentTheme.scheme) || "light", rootTheme = (parentTheme == null ? void 0 : parentTheme.theme) || null, tone = (parentTheme == null ? void 0 : parentTheme.tone) || "default";
|
|
170
|
+
} = props, parentTheme = useContext(ThemeContext), scheme = (_a = props.scheme) != null ? _a : (parentTheme == null ? void 0 : parentTheme.scheme) || "light", rootTheme = (_b = props.theme) != null ? _b : (parentTheme == null ? void 0 : parentTheme.theme) || null, tone = (_c2 = props.tone) != null ? _c2 : (parentTheme == null ? void 0 : parentTheme.tone) || "default";
|
|
171
171
|
let t0;
|
|
172
172
|
bb0: {
|
|
173
173
|
if (!rootTheme) {
|
|
@@ -6056,8 +6056,9 @@ const Root$5 = styled(Box)`
|
|
|
6056
6056
|
let t16;
|
|
6057
6057
|
return $[55] !== value || $[56] !== t15 ? (t16 = /* @__PURE__ */ jsx(MenuContext.Provider, { value, children: t15 }), $[55] = value, $[56] = t15, $[57] = t16) : t16 = $[57], t16;
|
|
6058
6058
|
}), MenuButton = forwardRef(function(props, forwardedRef) {
|
|
6059
|
-
|
|
6060
|
-
|
|
6059
|
+
var _a;
|
|
6060
|
+
const $ = c(63), {
|
|
6061
|
+
__unstable_disableRestoreFocusOnClose: t0,
|
|
6061
6062
|
boundaryElement: deprecated_boundaryElement,
|
|
6062
6063
|
button: buttonProp,
|
|
6063
6064
|
id,
|
|
@@ -6066,23 +6067,38 @@ const Root$5 = styled(Box)`
|
|
|
6066
6067
|
onOpen,
|
|
6067
6068
|
placement: deprecated_placement,
|
|
6068
6069
|
popoverScheme: deprecated_popoverScheme,
|
|
6069
|
-
portal:
|
|
6070
|
+
portal: t1,
|
|
6070
6071
|
popover,
|
|
6071
6072
|
popoverRadius: deprecated_popoverRadius,
|
|
6072
6073
|
preventOverflow: deprecated_preventOverflow
|
|
6073
|
-
} = props, [open, setOpen] = useState(!1), [shouldFocus, setShouldFocus] = useState(null), [buttonElement, setButtonElement] = useState(null)
|
|
6074
|
-
|
|
6074
|
+
} = props, disableRestoreFocusOnClose = t0 === void 0 ? !1 : t0, deprecated_portal = t1 === void 0 ? !0 : t1, [open, setOpen] = useState(!1), [shouldFocus, setShouldFocus] = useState(null), [buttonElement, setButtonElement] = useState(null);
|
|
6075
|
+
let t2;
|
|
6076
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t2 = [], $[0] = t2) : t2 = $[0];
|
|
6077
|
+
const [menuElements, setChildMenuElements] = useState(t2), openRef = useRef(open);
|
|
6078
|
+
let t3, t4;
|
|
6079
|
+
$[1] !== onOpen || $[2] !== open ? (t3 = () => {
|
|
6075
6080
|
onOpen && open && !openRef.current && onOpen();
|
|
6076
|
-
}, [onOpen, open]), useEffect(
|
|
6081
|
+
}, t4 = [onOpen, open], $[1] = onOpen, $[2] = open, $[3] = t3, $[4] = t4) : (t3 = $[3], t4 = $[4]), useEffect(t3, t4);
|
|
6082
|
+
let t5, t6;
|
|
6083
|
+
$[5] !== onClose || $[6] !== open ? (t5 = () => {
|
|
6077
6084
|
onClose && !open && openRef.current && onClose();
|
|
6078
|
-
}, [onClose, open]), useEffect(
|
|
6085
|
+
}, t6 = [onClose, open], $[5] = onClose, $[6] = open, $[7] = t5, $[8] = t6) : (t5 = $[7], t6 = $[8]), useEffect(t5, t6);
|
|
6086
|
+
let t7, t8;
|
|
6087
|
+
$[9] !== open ? (t7 = () => {
|
|
6079
6088
|
openRef.current = open;
|
|
6080
|
-
}, [open]);
|
|
6081
|
-
|
|
6089
|
+
}, t8 = [open], $[9] = open, $[10] = t7, $[11] = t8) : (t7 = $[10], t8 = $[11]), useEffect(t7, t8);
|
|
6090
|
+
let t9;
|
|
6091
|
+
$[12] === Symbol.for("react.memo_cache_sentinel") ? (t9 = () => {
|
|
6082
6092
|
setOpen((v) => !v), setShouldFocus(null);
|
|
6083
|
-
}, []
|
|
6093
|
+
}, $[12] = t9) : t9 = $[12];
|
|
6094
|
+
const handleButtonClick = t9;
|
|
6095
|
+
let t10;
|
|
6096
|
+
$[13] !== open ? (t10 = (event) => {
|
|
6084
6097
|
open && event.preventDefault();
|
|
6085
|
-
}, [open
|
|
6098
|
+
}, $[13] = open, $[14] = t10) : t10 = $[14];
|
|
6099
|
+
const handleMouseDown = t10;
|
|
6100
|
+
let t11;
|
|
6101
|
+
$[15] === Symbol.for("react.memo_cache_sentinel") ? (t11 = (event_0) => {
|
|
6086
6102
|
if (event_0.key === "ArrowDown" || event_0.key === "Enter" || event_0.key === " ") {
|
|
6087
6103
|
event_0.preventDefault(), setOpen(!0), setShouldFocus("first");
|
|
6088
6104
|
return;
|
|
@@ -6091,7 +6107,10 @@ const Root$5 = styled(Box)`
|
|
|
6091
6107
|
event_0.preventDefault(), setOpen(!0), setShouldFocus("last");
|
|
6092
6108
|
return;
|
|
6093
6109
|
}
|
|
6094
|
-
}, []
|
|
6110
|
+
}, $[15] = t11) : t11 = $[15];
|
|
6111
|
+
const handleButtonKeyDown = t11;
|
|
6112
|
+
let t12;
|
|
6113
|
+
$[16] !== buttonElement || $[17] !== menuElements ? (t12 = (event_1) => {
|
|
6095
6114
|
const target = event_1.target;
|
|
6096
6115
|
if (target instanceof Node && !(buttonElement && (target === buttonElement || buttonElement.contains(target)))) {
|
|
6097
6116
|
for (const el of menuElements)
|
|
@@ -6099,9 +6118,15 @@ const Root$5 = styled(Box)`
|
|
|
6099
6118
|
return;
|
|
6100
6119
|
setOpen(!1);
|
|
6101
6120
|
}
|
|
6102
|
-
}, [buttonElement, menuElements
|
|
6121
|
+
}, $[16] = buttonElement, $[17] = menuElements, $[18] = t12) : t12 = $[18];
|
|
6122
|
+
const handleMenuClickOutside = t12;
|
|
6123
|
+
let t13;
|
|
6124
|
+
$[19] !== disableRestoreFocusOnClose || $[20] !== buttonElement ? (t13 = () => {
|
|
6103
6125
|
setOpen(!1), !disableRestoreFocusOnClose && buttonElement && buttonElement.focus();
|
|
6104
|
-
}, [
|
|
6126
|
+
}, $[19] = disableRestoreFocusOnClose, $[20] = buttonElement, $[21] = t13) : t13 = $[21];
|
|
6127
|
+
const handleMenuEscape = t13;
|
|
6128
|
+
let t14;
|
|
6129
|
+
$[22] !== menuElements ? (t14 = (event_2) => {
|
|
6105
6130
|
const target_0 = event_2.relatedTarget;
|
|
6106
6131
|
if (target_0 instanceof Node) {
|
|
6107
6132
|
for (const el_0 of menuElements)
|
|
@@ -6109,11 +6134,20 @@ const Root$5 = styled(Box)`
|
|
|
6109
6134
|
return;
|
|
6110
6135
|
setOpen(!1);
|
|
6111
6136
|
}
|
|
6112
|
-
}, [menuElements
|
|
6137
|
+
}, $[22] = menuElements, $[23] = t14) : t14 = $[23];
|
|
6138
|
+
const handleBlur = t14;
|
|
6139
|
+
let t15;
|
|
6140
|
+
$[24] !== disableRestoreFocusOnClose || $[25] !== buttonElement ? (t15 = () => {
|
|
6113
6141
|
setOpen(!1), !disableRestoreFocusOnClose && buttonElement && buttonElement.focus();
|
|
6114
|
-
}, [
|
|
6142
|
+
}, $[24] = disableRestoreFocusOnClose, $[25] = buttonElement, $[26] = t15) : t15 = $[26];
|
|
6143
|
+
const handleItemClick = t15;
|
|
6144
|
+
let t16;
|
|
6145
|
+
$[27] === Symbol.for("react.memo_cache_sentinel") ? (t16 = (el_1) => (setChildMenuElements((els) => els.concat([el_1])), () => {
|
|
6115
6146
|
setChildMenuElements((els_0) => els_0.filter((_el) => _el !== el_1));
|
|
6116
|
-
}), []
|
|
6147
|
+
}), $[27] = t16) : t16 = $[27];
|
|
6148
|
+
const registerElement = t16;
|
|
6149
|
+
let t17;
|
|
6150
|
+
$[28] !== menuProp || $[29] !== id || $[30] !== handleBlur || $[31] !== handleMenuClickOutside || $[32] !== handleMenuEscape || $[33] !== handleItemClick || $[34] !== buttonElement || $[35] !== shouldFocus ? (t17 = menuProp && cloneElement(menuProp, {
|
|
6117
6151
|
"aria-labelledby": id,
|
|
6118
6152
|
onBlurCapture: handleBlur,
|
|
6119
6153
|
onClickOutside: handleMenuClickOutside,
|
|
@@ -6122,25 +6156,27 @@ const Root$5 = styled(Box)`
|
|
|
6122
6156
|
originElement: buttonElement,
|
|
6123
6157
|
registerElement,
|
|
6124
6158
|
shouldFocus
|
|
6125
|
-
}), [
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
|
|
6138
|
-
}, [buttonProp,
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6159
|
+
}), $[28] = menuProp, $[29] = id, $[30] = handleBlur, $[31] = handleMenuClickOutside, $[32] = handleMenuEscape, $[33] = handleItemClick, $[34] = buttonElement, $[35] = shouldFocus, $[36] = t17) : t17 = $[36];
|
|
6160
|
+
const menu = t17;
|
|
6161
|
+
let t18, t19;
|
|
6162
|
+
$[37] !== buttonProp || $[38] !== open || $[39] !== id || $[40] !== handleMouseDown ? (t19 = buttonProp && cloneElement(buttonProp, {
|
|
6163
|
+
"data-ui": "MenuButton",
|
|
6164
|
+
id,
|
|
6165
|
+
onClick: handleButtonClick,
|
|
6166
|
+
onKeyDown: handleButtonKeyDown,
|
|
6167
|
+
onMouseDown: handleMouseDown,
|
|
6168
|
+
"aria-haspopup": !0,
|
|
6169
|
+
"aria-expanded": open,
|
|
6170
|
+
ref: setButtonElement,
|
|
6171
|
+
selected: (_a = buttonProp.props.selected) != null ? _a : open
|
|
6172
|
+
}), $[37] = buttonProp, $[38] = open, $[39] = id, $[40] = handleMouseDown, $[41] = t19) : t19 = $[41], t18 = t19;
|
|
6173
|
+
const button = t18;
|
|
6174
|
+
let t20, t21;
|
|
6175
|
+
$[42] !== buttonElement ? (t20 = () => buttonElement, t21 = [buttonElement], $[42] = buttonElement, $[43] = t20, $[44] = t21) : (t20 = $[43], t21 = $[44]), useImperativeHandle(forwardedRef, t20, t21);
|
|
6176
|
+
let t22, t23;
|
|
6177
|
+
$[45] !== popover ? (t23 = popover || {}, $[45] = popover, $[46] = t23) : t23 = $[46];
|
|
6178
|
+
let t24;
|
|
6179
|
+
$[47] !== deprecated_boundaryElement || $[48] !== deprecated_placement || $[49] !== deprecated_portal || $[50] !== deprecated_preventOverflow || $[51] !== deprecated_popoverRadius || $[52] !== deprecated_popoverScheme || $[53] !== t23 ? (t24 = {
|
|
6144
6180
|
boundaryElement: deprecated_boundaryElement,
|
|
6145
6181
|
overflow: "auto",
|
|
6146
6182
|
placement: deprecated_placement,
|
|
@@ -6148,9 +6184,16 @@ const Root$5 = styled(Box)`
|
|
|
6148
6184
|
preventOverflow: deprecated_preventOverflow,
|
|
6149
6185
|
radius: deprecated_popoverRadius,
|
|
6150
6186
|
scheme: deprecated_popoverScheme,
|
|
6151
|
-
...
|
|
6152
|
-
}
|
|
6153
|
-
|
|
6187
|
+
...t23
|
|
6188
|
+
}, $[47] = deprecated_boundaryElement, $[48] = deprecated_placement, $[49] = deprecated_portal, $[50] = deprecated_preventOverflow, $[51] = deprecated_popoverRadius, $[52] = deprecated_popoverScheme, $[53] = t23, $[54] = t24) : t24 = $[54], t22 = t24;
|
|
6189
|
+
const popoverProps = t22;
|
|
6190
|
+
let t25;
|
|
6191
|
+
$[55] !== buttonElement || $[56] !== popoverProps || $[57] !== menu || $[58] !== open ? (t25 = /* @__PURE__ */ jsx(Popover, { "data-ui": "MenuButton__popover", referenceElement: buttonElement, ...popoverProps, content: menu, open }), $[55] = buttonElement, $[56] = popoverProps, $[57] = menu, $[58] = open, $[59] = t25) : t25 = $[59];
|
|
6192
|
+
let t26;
|
|
6193
|
+
return $[60] !== t25 || $[61] !== button ? (t26 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6194
|
+
t25,
|
|
6195
|
+
button
|
|
6196
|
+
] }), $[60] = t25, $[61] = button, $[62] = t26) : t26 = $[62], t26;
|
|
6154
6197
|
}), MenuDivider = styled.hr`
|
|
6155
6198
|
height: 1px;
|
|
6156
6199
|
border: 0;
|