@sanity/ui 3.0.0-static.41 → 3.0.0-static.43

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.
@@ -1,2261 +0,0 @@
1
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { c } from "react/compiler-runtime";
3
- import { box, text, textOverflow, animatedSpinnerIcon, spinner, button, buttonLoadingBox, _arrow, vars, _arrowSvg, _arrowStrokeMask, _arrowStroke, _arrowShape, card, BREAKPOINTS, popoverCard, popover, _selectable, stack, textInput, textInputPrefix, textInputElement, _inputElement, _inputPresentation, textInputSuffix, kbd, menu, menuDivider, tooltip } from "@sanity/ui/css";
4
- import { useState, isValidElement, useDebugValue, useSyncExternalStore, createContext, useContext, useRef, useImperativeHandle, useEffect, useMemo, useCallback, cloneElement, Children, useId, useLayoutEffect } from "react";
5
- import { useEffectEvent } from "use-effect-event";
6
- import { SpinnerIcon, CloseIcon, ChevronRightIcon } from "@sanity/icons";
7
- import { isValidElementType } from "react-is";
8
- import { detectOverflow, autoPlacement, flip, offset, shift, arrow, hide, useFloating, autoUpdate } from "@floating-ui/react-dom";
9
- import { motion, AnimatePresence } from "framer-motion";
10
- import { createPortal } from "react-dom";
11
- import { assignInlineVars } from "@vanilla-extract/dynamic";
12
- const EMPTY_ARRAY = [], EMPTY_RECORD = {}, POPOVER_MOTION_PROPS = {
13
- card: {
14
- initial: {
15
- scale: 0.97,
16
- willChange: "transform"
17
- },
18
- hidden: {
19
- opacity: 0
20
- },
21
- visible: {
22
- opacity: 1,
23
- transition: {
24
- when: "beforeChildren",
25
- duration: 0.1
26
- }
27
- },
28
- scaleIn: {
29
- scale: 1
30
- },
31
- scaleOut: {
32
- scale: 0.97
33
- }
34
- },
35
- transition: {
36
- type: "spring",
37
- visualDuration: 0.2,
38
- bounce: 0.25
39
- }
40
- }, Z_OFFSETS = {
41
- dialog: 600,
42
- popover: 400,
43
- tooltip: 200
44
- };
45
- function _isEnterToClickElement(element) {
46
- return isHTMLAnchorElement(element) || isHTMLButtonElement(element);
47
- }
48
- function isHTMLElement(node) {
49
- return node instanceof Node && node.nodeType === Node.ELEMENT_NODE;
50
- }
51
- function isHTMLAnchorElement(element) {
52
- return isHTMLElement(element) && element.nodeName === "A";
53
- }
54
- function isHTMLInputElement(element) {
55
- return isHTMLElement(element) && element.nodeName === "INPUT";
56
- }
57
- function isHTMLButtonElement(element) {
58
- return isHTMLElement(element) && element.nodeName === "BUTTON";
59
- }
60
- function isHTMLSelectElement(element) {
61
- return isHTMLElement(element) && element.nodeName === "SELECT";
62
- }
63
- function isHTMLTextAreaElement(element) {
64
- return isHTMLElement(element) && element.nodeName === "TEXTAREA";
65
- }
66
- function containsOrEqualsElement(element, node) {
67
- return element.contains(node) || element === node;
68
- }
69
- function isArray(val) {
70
- return Array.isArray(val);
71
- }
72
- function isRecord(value) {
73
- return !!(value && typeof value == "object" && !Array.isArray(value));
74
- }
75
- function _getArrayProp(val, defaultVal) {
76
- return val === void 0 ? defaultVal || EMPTY_ARRAY : Array.isArray(val) ? val : [val];
77
- }
78
- function _getResponsiveProp(val, defaultVal) {
79
- return val === void 0 ? defaultVal || EMPTY_ARRAY : isArray(val) || isRecord(val) ? val : [val];
80
- }
81
- function useResponsiveProp(val, defaultVal) {
82
- const $ = c(3);
83
- let t0;
84
- $[0] !== defaultVal || $[1] !== val ? (t0 = () => [_getResponsiveProp(val, defaultVal), JSON.stringify(val ?? defaultVal)], $[0] = defaultVal, $[1] = val, $[2] = t0) : t0 = $[2];
85
- const [t1, setCache] = useState(t0), [cachedVal, cachedHash] = t1, hash = JSON.stringify(val ?? defaultVal);
86
- return hash !== cachedHash && setCache([_getResponsiveProp(val, defaultVal), hash]), cachedVal;
87
- }
88
- const DEFAULT_BOX_ELEMENT = "div";
89
- function Box(props) {
90
- const $ = c(132), t0 = props;
91
- let alignItems, borderBottom, borderLeft, borderRight, borderTop, children, className, flex, flexDirection, flexWrap, gap, gapX, gapY, gridAutoColumns, gridAutoFlow, gridAutoRows, gridColumn, gridColumnEnd, gridColumnStart, gridRow, gridRowEnd, gridRowStart, gridTemplateColumns, gridTemplateRows, height, inset, insetBottom, insetLeft, insetRight, insetTop, justifyContent, marginBottom, marginLeft, marginRight, marginTop, marginX, marginY, maxWidth, muted, outline, overflow, overflowX, overflowY, paddingBottom, paddingLeft, paddingRight, paddingTop, paddingX, paddingY, pointerEvents, position, radius, rest, shadow, t1, t2, t3, t4, t5, t6, t7, t8, textAlign, width;
92
- $[0] !== t0 ? ({
93
- alignItems,
94
- as: t1,
95
- border: t2,
96
- borderTop,
97
- borderRight,
98
- borderBottom,
99
- borderLeft,
100
- className,
101
- children,
102
- display: t3,
103
- flex,
104
- flexDirection,
105
- flexWrap,
106
- gap,
107
- gapX,
108
- gapY,
109
- gridAutoColumns,
110
- gridAutoFlow,
111
- gridAutoRows,
112
- gridColumn,
113
- gridColumnEnd,
114
- gridColumnStart,
115
- gridRow,
116
- gridRowEnd,
117
- gridRowStart,
118
- gridTemplateColumns,
119
- gridTemplateRows,
120
- height,
121
- inset,
122
- insetBottom,
123
- insetLeft,
124
- insetRight,
125
- insetTop,
126
- justifyContent,
127
- margin: t4,
128
- marginX,
129
- marginY,
130
- marginTop,
131
- marginRight,
132
- marginBottom,
133
- marginLeft,
134
- maxWidth,
135
- minHeight: t5,
136
- minWidth: t6,
137
- muted,
138
- outline,
139
- overflow,
140
- overflowX,
141
- overflowY,
142
- padding: t7,
143
- paddingX,
144
- paddingY,
145
- paddingTop,
146
- paddingRight,
147
- paddingBottom,
148
- paddingLeft,
149
- pointerEvents,
150
- position,
151
- radius,
152
- shadow,
153
- sizing: t8,
154
- textAlign,
155
- width,
156
- ...rest
157
- } = t0, $[0] = t0, $[1] = alignItems, $[2] = borderBottom, $[3] = borderLeft, $[4] = borderRight, $[5] = borderTop, $[6] = children, $[7] = className, $[8] = flex, $[9] = flexDirection, $[10] = flexWrap, $[11] = gap, $[12] = gapX, $[13] = gapY, $[14] = gridAutoColumns, $[15] = gridAutoFlow, $[16] = gridAutoRows, $[17] = gridColumn, $[18] = gridColumnEnd, $[19] = gridColumnStart, $[20] = gridRow, $[21] = gridRowEnd, $[22] = gridRowStart, $[23] = gridTemplateColumns, $[24] = gridTemplateRows, $[25] = height, $[26] = inset, $[27] = insetBottom, $[28] = insetLeft, $[29] = insetRight, $[30] = insetTop, $[31] = justifyContent, $[32] = marginBottom, $[33] = marginLeft, $[34] = marginRight, $[35] = marginTop, $[36] = marginX, $[37] = marginY, $[38] = maxWidth, $[39] = muted, $[40] = outline, $[41] = overflow, $[42] = overflowX, $[43] = overflowY, $[44] = paddingBottom, $[45] = paddingLeft, $[46] = paddingRight, $[47] = paddingTop, $[48] = paddingX, $[49] = paddingY, $[50] = pointerEvents, $[51] = position, $[52] = radius, $[53] = rest, $[54] = shadow, $[55] = t1, $[56] = t2, $[57] = t3, $[58] = t4, $[59] = t5, $[60] = t6, $[61] = t7, $[62] = t8, $[63] = textAlign, $[64] = width) : (alignItems = $[1], borderBottom = $[2], borderLeft = $[3], borderRight = $[4], borderTop = $[5], children = $[6], className = $[7], flex = $[8], flexDirection = $[9], flexWrap = $[10], gap = $[11], gapX = $[12], gapY = $[13], gridAutoColumns = $[14], gridAutoFlow = $[15], gridAutoRows = $[16], gridColumn = $[17], gridColumnEnd = $[18], gridColumnStart = $[19], gridRow = $[20], gridRowEnd = $[21], gridRowStart = $[22], gridTemplateColumns = $[23], gridTemplateRows = $[24], height = $[25], inset = $[26], insetBottom = $[27], insetLeft = $[28], insetRight = $[29], insetTop = $[30], justifyContent = $[31], marginBottom = $[32], marginLeft = $[33], marginRight = $[34], marginTop = $[35], marginX = $[36], marginY = $[37], maxWidth = $[38], muted = $[39], outline = $[40], overflow = $[41], overflowX = $[42], overflowY = $[43], paddingBottom = $[44], paddingLeft = $[45], paddingRight = $[46], paddingTop = $[47], paddingX = $[48], paddingY = $[49], pointerEvents = $[50], position = $[51], radius = $[52], rest = $[53], shadow = $[54], t1 = $[55], t2 = $[56], t3 = $[57], t4 = $[58], t5 = $[59], t6 = $[60], t7 = $[61], t8 = $[62], textAlign = $[63], width = $[64]);
158
- const Element = t1 === void 0 ? DEFAULT_BOX_ELEMENT : t1, border = t2 === void 0 ? !1 : t2, display = t3 === void 0 ? "block" : t3, margin = t4 === void 0 ? 0 : t4, minHeight = t5 === void 0 ? 0 : t5, minWidth = t6 === void 0 ? 0 : t6, padding = t7 === void 0 ? 0 : t7, sizing = t8 === void 0 ? "border" : t8;
159
- let t9;
160
- $[65] !== alignItems || $[66] !== border || $[67] !== borderBottom || $[68] !== borderLeft || $[69] !== borderRight || $[70] !== borderTop || $[71] !== className || $[72] !== display || $[73] !== flex || $[74] !== flexDirection || $[75] !== flexWrap || $[76] !== gap || $[77] !== gapX || $[78] !== gapY || $[79] !== gridAutoColumns || $[80] !== gridAutoFlow || $[81] !== gridAutoRows || $[82] !== gridColumn || $[83] !== gridColumnEnd || $[84] !== gridColumnStart || $[85] !== gridRow || $[86] !== gridRowEnd || $[87] !== gridRowStart || $[88] !== gridTemplateColumns || $[89] !== gridTemplateRows || $[90] !== height || $[91] !== inset || $[92] !== insetBottom || $[93] !== insetLeft || $[94] !== insetRight || $[95] !== insetTop || $[96] !== justifyContent || $[97] !== margin || $[98] !== marginBottom || $[99] !== marginLeft || $[100] !== marginRight || $[101] !== marginTop || $[102] !== marginX || $[103] !== marginY || $[104] !== maxWidth || $[105] !== minHeight || $[106] !== minWidth || $[107] !== muted || $[108] !== outline || $[109] !== overflow || $[110] !== overflowX || $[111] !== overflowY || $[112] !== padding || $[113] !== paddingBottom || $[114] !== paddingLeft || $[115] !== paddingRight || $[116] !== paddingTop || $[117] !== paddingX || $[118] !== paddingY || $[119] !== pointerEvents || $[120] !== position || $[121] !== radius || $[122] !== shadow || $[123] !== sizing || $[124] !== textAlign || $[125] !== width ? (t9 = box({
161
- className,
162
- alignItems,
163
- border,
164
- borderTop,
165
- borderRight,
166
- borderBottom,
167
- borderLeft,
168
- display,
169
- flex,
170
- flexDirection,
171
- flexWrap,
172
- gap,
173
- gapX,
174
- gapY,
175
- gridAutoColumns,
176
- gridAutoFlow,
177
- gridAutoRows,
178
- gridColumn,
179
- gridColumnEnd,
180
- gridColumnStart,
181
- gridRow,
182
- gridRowEnd,
183
- gridRowStart,
184
- gridTemplateColumns,
185
- gridTemplateRows,
186
- height,
187
- inset,
188
- insetBottom,
189
- insetLeft,
190
- insetRight,
191
- insetTop,
192
- justifyContent,
193
- margin,
194
- marginX,
195
- marginY,
196
- marginTop,
197
- marginRight,
198
- marginBottom,
199
- marginLeft,
200
- maxWidth,
201
- minHeight,
202
- minWidth,
203
- muted,
204
- outline,
205
- overflow,
206
- overflowX,
207
- overflowY,
208
- padding,
209
- paddingX,
210
- paddingY,
211
- paddingTop,
212
- paddingRight,
213
- paddingBottom,
214
- paddingLeft,
215
- pointerEvents,
216
- position,
217
- radius,
218
- shadow,
219
- sizing,
220
- textAlign,
221
- width
222
- }), $[65] = alignItems, $[66] = border, $[67] = borderBottom, $[68] = borderLeft, $[69] = borderRight, $[70] = borderTop, $[71] = className, $[72] = display, $[73] = flex, $[74] = flexDirection, $[75] = flexWrap, $[76] = gap, $[77] = gapX, $[78] = gapY, $[79] = gridAutoColumns, $[80] = gridAutoFlow, $[81] = gridAutoRows, $[82] = gridColumn, $[83] = gridColumnEnd, $[84] = gridColumnStart, $[85] = gridRow, $[86] = gridRowEnd, $[87] = gridRowStart, $[88] = gridTemplateColumns, $[89] = gridTemplateRows, $[90] = height, $[91] = inset, $[92] = insetBottom, $[93] = insetLeft, $[94] = insetRight, $[95] = insetTop, $[96] = justifyContent, $[97] = margin, $[98] = marginBottom, $[99] = marginLeft, $[100] = marginRight, $[101] = marginTop, $[102] = marginX, $[103] = marginY, $[104] = maxWidth, $[105] = minHeight, $[106] = minWidth, $[107] = muted, $[108] = outline, $[109] = overflow, $[110] = overflowX, $[111] = overflowY, $[112] = padding, $[113] = paddingBottom, $[114] = paddingLeft, $[115] = paddingRight, $[116] = paddingTop, $[117] = paddingX, $[118] = paddingY, $[119] = pointerEvents, $[120] = position, $[121] = radius, $[122] = shadow, $[123] = sizing, $[124] = textAlign, $[125] = width, $[126] = t9) : t9 = $[126];
223
- let t10;
224
- return $[127] !== Element || $[128] !== children || $[129] !== rest || $[130] !== t9 ? (t10 = /* @__PURE__ */ jsx(Element, { "data-ui": "Box", ...rest, className: t9, children }), $[127] = Element, $[128] = children, $[129] = rest, $[130] = t9, $[131] = t10) : t10 = $[131], t10;
225
- }
226
- const DEFAULT_TEXT_ELEMENT = "div";
227
- function Text(props) {
228
- const $ = c(30), t0 = props;
229
- let align, children, className, flex, muted, rest, t1, t2, t3, t4, textOverflowProp;
230
- $[0] !== t0 ? ({
231
- align,
232
- as: t1,
233
- children,
234
- className,
235
- flex,
236
- maxWidth: t2,
237
- muted,
238
- size: t3,
239
- textOverflow: textOverflowProp,
240
- weight: t4,
241
- ...rest
242
- } = t0, $[0] = t0, $[1] = align, $[2] = children, $[3] = className, $[4] = flex, $[5] = muted, $[6] = rest, $[7] = t1, $[8] = t2, $[9] = t3, $[10] = t4, $[11] = textOverflowProp) : (align = $[1], children = $[2], className = $[3], flex = $[4], muted = $[5], rest = $[6], t1 = $[7], t2 = $[8], t3 = $[9], t4 = $[10], textOverflowProp = $[11]);
243
- const Element = t1 === void 0 ? DEFAULT_TEXT_ELEMENT : t1, maxWidth = t2 === void 0 ? "fill" : t2, size2 = t3 === void 0 ? 2 : t3, weight = t4 === void 0 ? "regular" : t4;
244
- let t5;
245
- $[12] !== align || $[13] !== className || $[14] !== flex || $[15] !== maxWidth || $[16] !== muted || $[17] !== size2 || $[18] !== weight ? (t5 = text({
246
- className,
247
- align,
248
- flex,
249
- maxWidth,
250
- muted,
251
- size: size2,
252
- weight
253
- }), $[12] = align, $[13] = className, $[14] = flex, $[15] = maxWidth, $[16] = muted, $[17] = size2, $[18] = weight, $[19] = t5) : t5 = $[19];
254
- let t6;
255
- $[20] !== textOverflowProp ? (t6 = textOverflow({
256
- textOverflow: textOverflowProp
257
- }), $[20] = textOverflowProp, $[21] = t6) : t6 = $[21];
258
- let t7;
259
- $[22] !== children || $[23] !== t6 ? (t7 = /* @__PURE__ */ jsx("span", { className: t6, children }), $[22] = children, $[23] = t6, $[24] = t7) : t7 = $[24];
260
- let t8;
261
- return $[25] !== Element || $[26] !== rest || $[27] !== t5 || $[28] !== t7 ? (t8 = /* @__PURE__ */ jsx(Element, { "data-ui": "Text", ...rest, className: t5, children: t7 }), $[25] = Element, $[26] = rest, $[27] = t5, $[28] = t7, $[29] = t8) : t8 = $[29], t8;
262
- }
263
- function AnimatedSpinnerIcon(props) {
264
- const $ = c(5);
265
- let rest;
266
- $[0] !== props ? ({
267
- ...rest
268
- } = props, $[0] = props, $[1] = rest) : rest = $[1];
269
- let t0;
270
- $[2] === Symbol.for("react.memo_cache_sentinel") ? (t0 = animatedSpinnerIcon(), $[2] = t0) : t0 = $[2];
271
- let t1;
272
- return $[3] !== rest ? (t1 = /* @__PURE__ */ jsx(SpinnerIcon, { "data-sanity-icon": "animated-spinner", ...rest, className: t0 }), $[3] = rest, $[4] = t1) : t1 = $[4], t1;
273
- }
274
- const DEFAULT_SPINNER_ELEMENT = "div";
275
- function Spinner(props) {
276
- const $ = c(11), t0 = props;
277
- let className, rest, t1;
278
- $[0] !== t0 ? ({
279
- as: t1,
280
- className,
281
- ...rest
282
- } = t0, $[0] = t0, $[1] = className, $[2] = rest, $[3] = t1) : (className = $[1], rest = $[2], t1 = $[3]);
283
- const as = t1 === void 0 ? DEFAULT_SPINNER_ELEMENT : t1;
284
- let t2;
285
- $[4] !== className ? (t2 = spinner({
286
- className
287
- }), $[4] = className, $[5] = t2) : t2 = $[5];
288
- let t3;
289
- $[6] === Symbol.for("react.memo_cache_sentinel") ? (t3 = /* @__PURE__ */ jsx(AnimatedSpinnerIcon, {}), $[6] = t3) : t3 = $[6];
290
- let t4;
291
- return $[7] !== as || $[8] !== rest || $[9] !== t2 ? (t4 = /* @__PURE__ */ jsx(Text, { as, "data-ui": "Spinner", ...rest, className: t2, children: t3 }), $[7] = as, $[8] = rest, $[9] = t2, $[10] = t4) : t4 = $[10], t4;
292
- }
293
- const DEFAULT_BUTTON_ELEMENT = "button";
294
- function Button(props) {
295
- const {
296
- align = "center",
297
- as: Element = DEFAULT_BUTTON_ELEMENT,
298
- children,
299
- className,
300
- disabled,
301
- flex,
302
- fontSize = 1,
303
- gap = props.padding ?? 3,
304
- gapX,
305
- gapY,
306
- icon: IconComponent,
307
- iconRight: IconRightComponent,
308
- justify = "center",
309
- loading,
310
- mode = "default",
311
- padding = 3,
312
- paddingX,
313
- paddingY,
314
- paddingTop,
315
- paddingBottom,
316
- paddingLeft,
317
- paddingRight,
318
- radius = 2,
319
- selected,
320
- text: text2,
321
- textAlign,
322
- textOverflow: textOverflow2 = "ellipsis",
323
- textWeight = "medium",
324
- tone = "default",
325
- type = "button",
326
- muted = !1,
327
- width,
328
- ...rest
329
- } = props;
330
- let href;
331
- return "href" in rest && (href = typeof rest.href == "string" ? rest.href : href, delete rest.href), /* @__PURE__ */ jsxs(
332
- Element,
333
- {
334
- "data-ui": "Button",
335
- ...rest,
336
- className: button({
337
- className,
338
- flex,
339
- mode,
340
- radius,
341
- tone,
342
- width
343
- }),
344
- "data-disabled": loading || disabled ? "" : void 0,
345
- "data-selected": selected ? "" : void 0,
346
- disabled: !!(loading || disabled),
347
- href: disabled ? void 0 : href,
348
- type,
349
- children: [
350
- !!loading && /* @__PURE__ */ jsx(Box, { alignItems: "center", as: "span", className: buttonLoadingBox(), display: "flex", flex: 1, justifyContent: "center", width: "fill", children: /* @__PURE__ */ jsx(Spinner, { size: fontSize }) }),
351
- (IconComponent || text2 || IconRightComponent) && /* @__PURE__ */ jsxs(Box, { alignItems: align, as: "span", display: "flex", flex: 1, gap, gapX, gapY, justifyContent: justify, padding, paddingX, paddingY, paddingTop, paddingBottom, paddingLeft, paddingRight, children: [
352
- IconComponent && /* @__PURE__ */ jsxs(Text, { as: "span", flex: "none", muted: !0, size: fontSize, children: [
353
- isValidElement(IconComponent) && IconComponent,
354
- isValidElementType(IconComponent) && /* @__PURE__ */ jsx(IconComponent, {})
355
- ] }),
356
- text2 && /* @__PURE__ */ jsx(Box, { as: "span", maxWidth: "auto", children: /* @__PURE__ */ jsx(Text, { align: textAlign, as: "span", muted, size: fontSize, textOverflow: textOverflow2, weight: textWeight, children: text2 }) }),
357
- IconRightComponent && /* @__PURE__ */ jsxs(Text, { as: "span", flex: "none", muted: !0, size: fontSize, children: [
358
- isValidElement(IconRightComponent) && IconRightComponent,
359
- isValidElementType(IconRightComponent) && /* @__PURE__ */ jsx(IconRightComponent, {})
360
- ] })
361
- ] }),
362
- children && /* @__PURE__ */ jsx(Box, { as: "span", flex: 1, padding, paddingX, paddingY, paddingTop, paddingBottom, paddingLeft, paddingRight, children })
363
- ]
364
- }
365
- );
366
- }
367
- function useMatchMedia(mediaQueryString, getServerSnapshot2) {
368
- const $ = c(4);
369
- useDebugValue(mediaQueryString);
370
- let t0;
371
- $[0] !== mediaQueryString ? (t0 = (onStoreChange) => {
372
- const media2 = window.matchMedia(mediaQueryString);
373
- return media2.addEventListener("change", onStoreChange), () => media2.removeEventListener("change", onStoreChange);
374
- }, $[0] = mediaQueryString, $[1] = t0) : t0 = $[1];
375
- let t1;
376
- return $[2] !== mediaQueryString ? (t1 = () => window.matchMedia(mediaQueryString).matches, $[2] = mediaQueryString, $[3] = t1) : t1 = $[3], useSyncExternalStore(t0, t1, getServerSnapshot2);
377
- }
378
- function usePrefersReducedMotion(t0) {
379
- return useMatchMedia("(prefers-reduced-motion: reduce)", t0 === void 0 ? _temp$5 : t0);
380
- }
381
- function _temp$5() {
382
- return !1;
383
- }
384
- const origin = {
385
- name: "@sanity/ui/origin",
386
- fn({
387
- middlewareData,
388
- placement,
389
- rects
390
- }) {
391
- const [side] = placement.split("-"), floatingWidth = rects.floating.width, floatingHeight = rects.floating.height, shiftX = middlewareData.shift?.x || 0, shiftY = middlewareData.shift?.y || 0;
392
- if (floatingWidth <= 0 || floatingHeight <= 0)
393
- return {};
394
- const isVerticalPlacement = ["bottom", "top"].includes(side), {
395
- originX,
396
- originY
397
- } = isVerticalPlacement ? {
398
- originX: clamp(0.5 - shiftX / floatingWidth, 0, 1),
399
- originY: side === "bottom" ? 0 : 1
400
- } : {
401
- originX: side === "left" ? 1 : 0,
402
- originY: clamp(0.5 - shiftY / floatingHeight, 0, 1)
403
- };
404
- return {
405
- data: {
406
- originX,
407
- originY
408
- }
409
- };
410
- }
411
- };
412
- function clamp(num, min, max) {
413
- return Math.min(Math.max(num, min), max);
414
- }
415
- function getGlobalScope() {
416
- if (typeof globalThis < "u") return globalThis;
417
- if (typeof window < "u") return window;
418
- if (typeof self < "u") return self;
419
- if (typeof global < "u") return global;
420
- throw new Error("@sanity/ui: could not locate global scope");
421
- }
422
- const globalScope = getGlobalScope();
423
- function createGlobalScopedContext(key2, defaultValue) {
424
- const symbol = Symbol.for(key2);
425
- if (typeof document > "u")
426
- return createContext(defaultValue);
427
- const symbolMap = globalScope;
428
- return symbolMap[symbol] = symbolMap[symbol] || createContext(defaultValue), symbolMap[symbol];
429
- }
430
- const BoundaryElementContext = createGlobalScopedContext("@sanity/ui/v3/boundaryElement", null), DEFAULT_VALUE = {
431
- version: 0,
432
- element: null
433
- };
434
- function useBoundaryElement() {
435
- const value = useContext(BoundaryElementContext);
436
- if (value && (!isRecord(value) || value.version !== 0))
437
- throw new Error("useBoundaryElement(): the context value is not compatible");
438
- return value || DEFAULT_VALUE;
439
- }
440
- function getElementRef(element) {
441
- let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
442
- 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);
443
- }
444
- const CardContext = createGlobalScopedContext("@sanity/ui/v3/card", null);
445
- function CardProvider(props) {
446
- const $ = c(7), {
447
- children,
448
- tone,
449
- scheme,
450
- unstable_CompatProvider
451
- } = props;
452
- let t0, t1;
453
- $[0] !== scheme || $[1] !== tone || $[2] !== unstable_CompatProvider ? (t1 = {
454
- tone,
455
- scheme,
456
- unstable_CompatProvider
457
- }, $[0] = scheme, $[1] = tone, $[2] = unstable_CompatProvider, $[3] = t1) : t1 = $[3], t0 = t1;
458
- let t2;
459
- return $[4] !== children || $[5] !== t0 ? (t2 = /* @__PURE__ */ jsx(CardContext.Provider, { value: t0, children }), $[4] = children, $[5] = t0, $[6] = t2) : t2 = $[6], t2;
460
- }
461
- function useCard() {
462
- const card2 = useContext(CardContext);
463
- if (!card2)
464
- throw new Error("useCard(): missing context value");
465
- return card2;
466
- }
467
- const key = "@sanity/ui/v3/portal", elementKey = Symbol.for(`${key}/element`), elementMap = globalScope;
468
- elementMap[elementKey] = null;
469
- const defaultContextValue = {
470
- version: 0,
471
- boundaryElement: null,
472
- get element() {
473
- return typeof document > "u" ? null : (elementMap[elementKey] || (elementMap[elementKey] = document.createElement("div"), elementMap[elementKey].setAttribute("data-portal", ""), document.body.appendChild(elementMap[elementKey])), elementMap[elementKey]);
474
- }
475
- }, PortalContext = createGlobalScopedContext(key, defaultContextValue);
476
- function usePortal() {
477
- const value = useContext(PortalContext);
478
- if (!value)
479
- throw new Error("usePortal(): missing context value");
480
- if (!isRecord(value) || value.version !== 0)
481
- throw new Error("usePortal(): the context value is not compatible");
482
- return value;
483
- }
484
- function Portal(props) {
485
- const $ = c(6), {
486
- children,
487
- __unstable_name: name
488
- } = props, card2 = useCard(), portal = usePortal(), portalElement = (name ? portal.elements && portal.elements[name] : portal.element) || portal.elements?.default;
489
- if (!portalElement)
490
- return null;
491
- let t0;
492
- $[0] !== card2.scheme || $[1] !== children ? (t0 = /* @__PURE__ */ jsx(CardProvider, { tone: "transparent", scheme: card2.scheme, children }), $[0] = card2.scheme, $[1] = children, $[2] = t0) : t0 = $[2];
493
- let t1;
494
- return $[3] !== portalElement || $[4] !== t0 ? (t1 = createPortal(t0, portalElement), $[3] = portalElement, $[4] = t0, $[5] = t1) : t1 = $[5], t1;
495
- }
496
- function getLayerContext(contextValue) {
497
- if (!isRecord(contextValue) || contextValue.version !== 0)
498
- throw new Error("the context value is not compatible");
499
- if (!contextValue)
500
- throw new Error("components using `useLayer()` should be wrapped in a <LayerProvider>.");
501
- if (contextValue.version === 0)
502
- return contextValue;
503
- throw new Error("could not get layer context");
504
- }
505
- const LayerContext = createGlobalScopedContext("@sanity/ui/v3/layer", null);
506
- function useLayer() {
507
- const $ = c(2), value = useContext(LayerContext);
508
- if (!value)
509
- throw new Error("useLayer(): missing context value");
510
- try {
511
- let t1;
512
- return $[0] !== value ? (t1 = getLayerContext(value), $[0] = value, $[1] = t1) : t1 = $[1], t1;
513
- } catch (t0) {
514
- const err = t0;
515
- throw err instanceof Error ? new Error(`useLayer(): ${err.message}`) : new Error(`useLayer(): ${err}`);
516
- }
517
- }
518
- 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 = {
519
- top: ["bottom", "left", "right"],
520
- "top-start": ["bottom-start", "left-start", "right-start"],
521
- "top-end": ["bottom-end", "left-end", "right-end"],
522
- bottom: ["top", "left", "right"],
523
- "bottom-start": ["top-start", "left-start", "right-start"],
524
- "bottom-end": ["top-end", "left-end", "right-end"],
525
- left: ["right", "top", "bottom"],
526
- "left-start": ["right-start", "top-start", "bottom-start"],
527
- "left-end": ["right-end", "top-end", "bottom-end"],
528
- right: ["left", "top", "bottom"],
529
- "right-start": ["left-start", "top-start", "bottom-start"],
530
- "right-end": ["left-end", "top-end", "bottom-end"]
531
- };
532
- function size(options) {
533
- const {
534
- apply,
535
- margins,
536
- padding = 0
537
- } = options;
538
- return {
539
- name: "@sanity/ui/size",
540
- async fn(args) {
541
- const {
542
- elements,
543
- placement,
544
- platform,
545
- rects
546
- } = args, {
547
- floating,
548
- reference
549
- } = rects, overflow = await detectOverflow(args, {
550
- altBoundary: !0,
551
- boundary: options.boundaryElement || void 0,
552
- elementContext: "floating",
553
- padding,
554
- rootBoundary: "viewport"
555
- });
556
- let maxWidth = 1 / 0, maxHeight = 1 / 0;
557
- const floatingW = floating.width, floatingH = floating.height;
558
- placement.includes("top") && (maxWidth = floatingW - (overflow.left + overflow.right), maxHeight = floatingH - overflow.top), placement.includes("right") && (maxWidth = floatingW - overflow.right, maxHeight = floatingH - (overflow.top + overflow.bottom)), placement.includes("bottom") && (maxWidth = floatingW - (overflow.left + overflow.right), maxHeight = floatingH - overflow.bottom), placement.includes("left") && (maxWidth = floatingW - overflow.left, maxHeight = floatingH - (overflow.top + overflow.bottom)), apply({
559
- availableWidth: maxWidth - margins[1] - margins[3],
560
- availableHeight: maxHeight - margins[0] - margins[2],
561
- elements,
562
- referenceWidth: reference.width - margins[1] - margins[3]
563
- });
564
- const nextDimensions = await platform.getDimensions(elements.floating), targetH = nextDimensions.height, targetW = nextDimensions.width;
565
- return floatingW !== targetW || floatingH !== targetH ? {
566
- reset: {
567
- rects: !0
568
- }
569
- } : {};
570
- }
571
- };
572
- }
573
- function moveTowardsLength(movingPoint, targetPoint, amount) {
574
- const width = targetPoint.x - movingPoint.x, height = targetPoint.y - movingPoint.y, distance = Math.sqrt(width * width + height * height);
575
- return moveTowardsFractional(movingPoint, targetPoint, Math.min(1, amount / distance));
576
- }
577
- function moveTowardsFractional(movingPoint, targetPoint, fraction) {
578
- return {
579
- x: movingPoint.x + (targetPoint.x - movingPoint.x) * fraction,
580
- y: movingPoint.y + (targetPoint.y - movingPoint.y) * fraction
581
- };
582
- }
583
- function getRoundedCommands(points) {
584
- const len = points.length, cmds = [];
585
- for (let i = 0; i < len; i += 1) {
586
- const point = points[i], prevPoint = points[i - 1], nextPoint = points[i + 1];
587
- if (prevPoint && point.radius) {
588
- const curveStart = moveTowardsLength(point, prevPoint, point.radius), curveEnd = moveTowardsLength(point, nextPoint, point.radius), startControl = moveTowardsFractional(curveStart, point, 0.5), endControl = moveTowardsFractional(point, curveEnd, 0.5);
589
- cmds.push({
590
- type: "point",
591
- ...curveStart
592
- }), cmds.push({
593
- type: "curve",
594
- curveEnd,
595
- startControl,
596
- endControl
597
- });
598
- } else
599
- cmds.push({
600
- type: "point",
601
- ...point
602
- });
603
- }
604
- return cmds;
605
- }
606
- function compileCommands(cmds) {
607
- return cmds.map((n, idx) => n.type === "point" ? `${idx === 0 ? "M" : "L"} ${n.x} ${n.y}` : n.type === "curve" ? `C ${n.startControl.x} ${n.startControl.y} ${n.endControl.x} ${n.endControl.y} ${n.curveEnd.x} ${n.curveEnd.y}` : "").join(" ");
608
- }
609
- const DEFAULT_ARROW_ELEMENT = "div";
610
- function Arrow(props) {
611
- const $ = c(34), t0 = props;
612
- let h, rest, style, t1, t2, w;
613
- $[0] !== t0 ? ({
614
- as: t1,
615
- width: w,
616
- height: h,
617
- radius: t2,
618
- style,
619
- ...rest
620
- } = t0, $[0] = t0, $[1] = h, $[2] = rest, $[3] = style, $[4] = t1, $[5] = t2, $[6] = w) : (h = $[1], rest = $[2], style = $[3], t1 = $[4], t2 = $[5], w = $[6]);
621
- const Element = t1 === void 0 ? DEFAULT_ARROW_ELEMENT : t1, radius = t2 === void 0 ? 0 : t2, center = w / 2;
622
- let t3;
623
- const points = [{
624
- x: 0,
625
- y: 0
626
- }, {
627
- x: radius,
628
- y: 0,
629
- radius
630
- }, {
631
- x: center,
632
- y: h - 1,
633
- radius
634
- }, {
635
- x: w - radius,
636
- y: 0,
637
- radius
638
- }, {
639
- x: w,
640
- y: 0
641
- }], cmds = getRoundedCommands(points);
642
- t3 = compileCommands(cmds);
643
- const path = t3, strokePath = `${path}`, fillPath = `${path} M ${w} -1 M 0 -1 Z`;
644
- let t4;
645
- $[7] === Symbol.for("react.memo_cache_sentinel") ? (t4 = _arrow(), $[7] = t4) : t4 = $[7];
646
- const t5 = `${w}px`;
647
- let t6;
648
- $[8] !== t5 ? (t6 = assignInlineVars({
649
- [vars.arrow.size]: t5
650
- }), $[8] = t5, $[9] = t6) : t6 = $[9];
651
- let t7;
652
- $[10] !== style || $[11] !== t6 ? (t7 = {
653
- ...style,
654
- ...t6
655
- }, $[10] = style, $[11] = t6, $[12] = t7) : t7 = $[12];
656
- let t8;
657
- $[13] === Symbol.for("react.memo_cache_sentinel") ? (t8 = _arrowSvg(), $[13] = t8) : t8 = $[13];
658
- const t9 = `0 0 ${w} ${w}`;
659
- let t10;
660
- $[14] === Symbol.for("react.memo_cache_sentinel") ? (t10 = _arrowStrokeMask(), $[14] = t10) : t10 = $[14];
661
- let t11;
662
- $[15] !== w ? (t11 = /* @__PURE__ */ jsx("mask", { id: "stroke-mask", children: /* @__PURE__ */ jsx("rect", { className: t10, x: 0, width: w, height: w, fill: "white" }) }), $[15] = w, $[16] = t11) : t11 = $[16];
663
- let t12;
664
- $[17] === Symbol.for("react.memo_cache_sentinel") ? (t12 = _arrowStroke(), $[17] = t12) : t12 = $[17];
665
- let t13;
666
- $[18] !== strokePath ? (t13 = /* @__PURE__ */ jsx("path", { className: t12, d: strokePath, mask: "url(#stroke-mask)" }), $[18] = strokePath, $[19] = t13) : t13 = $[19];
667
- let t14;
668
- $[20] === Symbol.for("react.memo_cache_sentinel") ? (t14 = _arrowShape(), $[20] = t14) : t14 = $[20];
669
- let t15;
670
- $[21] !== fillPath ? (t15 = /* @__PURE__ */ jsx("path", { className: t14, d: fillPath }), $[21] = fillPath, $[22] = t15) : t15 = $[22];
671
- let t16;
672
- $[23] !== t11 || $[24] !== t13 || $[25] !== t15 || $[26] !== t9 || $[27] !== w ? (t16 = /* @__PURE__ */ jsxs("svg", { className: t8, width: w, height: w, viewBox: t9, children: [
673
- t11,
674
- t13,
675
- t15
676
- ] }), $[23] = t11, $[24] = t13, $[25] = t15, $[26] = t9, $[27] = w, $[28] = t16) : t16 = $[28];
677
- let t17;
678
- return $[29] !== Element || $[30] !== rest || $[31] !== t16 || $[32] !== t7 ? (t17 = /* @__PURE__ */ jsx(Element, { ...rest, className: t4, style: t7, children: t16 }), $[29] = Element, $[30] = rest, $[31] = t16, $[32] = t7, $[33] = t17) : t17 = $[33], t17;
679
- }
680
- const DEFAULT_FLEX_ELEMENT = "div";
681
- function Flex(props) {
682
- const $ = c(14), t0 = props;
683
- let align, justify, rest, t1, t2, wrap;
684
- $[0] !== t0 ? ({
685
- align,
686
- as: t1,
687
- direction: t2,
688
- justify,
689
- wrap,
690
- ...rest
691
- } = t0, $[0] = t0, $[1] = align, $[2] = justify, $[3] = rest, $[4] = t1, $[5] = t2, $[6] = wrap) : (align = $[1], justify = $[2], rest = $[3], t1 = $[4], t2 = $[5], wrap = $[6]);
692
- const as = t1 === void 0 ? DEFAULT_FLEX_ELEMENT : t1, direction = t2 === void 0 ? "row" : t2;
693
- let t3;
694
- return $[7] !== align || $[8] !== as || $[9] !== direction || $[10] !== justify || $[11] !== rest || $[12] !== wrap ? (t3 = /* @__PURE__ */ jsx(Box, { "data-ui": "Flex", ...rest, alignItems: align, as, display: "flex", flexDirection: direction, flexWrap: wrap, justifyContent: justify }), $[7] = align, $[8] = as, $[9] = direction, $[10] = justify, $[11] = rest, $[12] = wrap, $[13] = t3) : t3 = $[13], t3;
695
- }
696
- const DEFAULT_CARD_ELEMENT = "div";
697
- function Card(props) {
698
- const $ = c(38), t0 = props;
699
- let className, disabled, pressed, rest, schemeProp, selected, style, t1, t2, t3, t4, t5;
700
- $[0] !== t0 ? ({
701
- __unstable_checkered: t1,
702
- __unstable_focusRing: t2,
703
- as: t3,
704
- className,
705
- disabled,
706
- pressed,
707
- radius: t4,
708
- scheme: schemeProp,
709
- selected,
710
- style,
711
- tone: t5,
712
- ...rest
713
- } = t0, $[0] = t0, $[1] = className, $[2] = disabled, $[3] = pressed, $[4] = rest, $[5] = schemeProp, $[6] = selected, $[7] = style, $[8] = t1, $[9] = t2, $[10] = t3, $[11] = t4, $[12] = t5) : (className = $[1], disabled = $[2], pressed = $[3], rest = $[4], schemeProp = $[5], selected = $[6], style = $[7], t1 = $[8], t2 = $[9], t3 = $[10], t4 = $[11], t5 = $[12]);
714
- const checkered = t1 === void 0 ? !1 : t1, focusRing = t2 === void 0 ? !1 : t2, as = t3 === void 0 ? DEFAULT_CARD_ELEMENT : t3, radius = t4 === void 0 ? 0 : t4, toneProp = t5 === void 0 ? "default" : t5, parent = useContext(CardContext), tone = toneProp === "inherit" ? parent?.tone : toneProp, scheme = schemeProp === void 0 ? parent?.scheme : schemeProp, t6 = scheme === parent?.scheme ? void 0 : scheme;
715
- let t7;
716
- $[13] !== className || $[14] !== t6 || $[15] !== tone ? (t7 = card({
717
- className,
718
- scheme: t6,
719
- tone
720
- }), $[13] = className, $[14] = t6, $[15] = tone, $[16] = t7) : t7 = $[16];
721
- const t8 = checkered ? "" : void 0, t9 = disabled ? "" : void 0, t10 = focusRing ? "" : void 0, t11 = pressed ? "" : void 0, t12 = selected ? "" : void 0;
722
- let t13;
723
- $[17] !== as || $[18] !== radius || $[19] !== rest || $[20] !== style || $[21] !== t10 || $[22] !== t11 || $[23] !== t12 || $[24] !== t7 || $[25] !== t8 || $[26] !== t9 ? (t13 = /* @__PURE__ */ jsx(Box, { "data-ui": "Card", ...rest, as, className: t7, "data-checkered": t8, "data-disabled": t9, "data-focus-ring": t10, "data-pressed": t11, "data-selected": t12, radius, style }), $[17] = as, $[18] = radius, $[19] = rest, $[20] = style, $[21] = t10, $[22] = t11, $[23] = t12, $[24] = t7, $[25] = t8, $[26] = t9, $[27] = t13) : t13 = $[27];
724
- let node = t13;
725
- if (scheme === parent?.scheme && tone === parent?.tone)
726
- return node;
727
- const t14 = scheme ?? "light", t15 = tone ?? "default", t16 = parent?.unstable_CompatProvider;
728
- let t17;
729
- if ($[28] !== node || $[29] !== t14 || $[30] !== t15 || $[31] !== t16 ? (t17 = /* @__PURE__ */ jsx(CardProvider, { scheme: t14, tone: t15, unstable_CompatProvider: t16, children: node }), $[28] = node, $[29] = t14, $[30] = t15, $[31] = t16, $[32] = t17) : t17 = $[32], node = t17, parent?.unstable_CompatProvider) {
730
- const CompatProvider = parent.unstable_CompatProvider, t18 = scheme ?? "light", t19 = tone ?? parent.tone;
731
- let t20;
732
- return $[33] !== CompatProvider || $[34] !== node || $[35] !== t18 || $[36] !== t19 ? (t20 = /* @__PURE__ */ jsx(CompatProvider, { scheme: t18, tone: t19, children: node }), $[33] = CompatProvider, $[34] = node, $[35] = t18, $[36] = t19, $[37] = t20) : t20 = $[37], t20;
733
- }
734
- return node;
735
- }
736
- const DEFAULT_LAYER_CARD_ELEMENT = "div";
737
- function LayerCard(props) {
738
- const $ = c(27), t0 = props;
739
- let children, forwardedRef, onActivate, onFocus, rest, t1, t2, t3;
740
- $[0] !== t0 ? ({
741
- as: t1,
742
- children,
743
- onActivate,
744
- onFocus,
745
- position: t2,
746
- ref: forwardedRef,
747
- style: t3,
748
- ...rest
749
- } = t0, $[0] = t0, $[1] = children, $[2] = forwardedRef, $[3] = onActivate, $[4] = onFocus, $[5] = rest, $[6] = t1, $[7] = t2, $[8] = t3) : (children = $[1], forwardedRef = $[2], onActivate = $[3], onFocus = $[4], rest = $[5], t1 = $[6], t2 = $[7], t3 = $[8]);
750
- const as = t1 === void 0 ? DEFAULT_LAYER_CARD_ELEMENT : t1, position = t2 === void 0 ? "relative" : t2, style = t3 === void 0 ? EMPTY_RECORD : t3, {
751
- zIndex,
752
- isTopLayer
753
- } = useLayer(), lastFocusedRef = useRef(null), ref = useRef(null), isTopLayerRef = useRef(isTopLayer);
754
- let t4;
755
- $[9] === Symbol.for("react.memo_cache_sentinel") ? (t4 = () => ref.current, $[9] = t4) : t4 = $[9], useImperativeHandle(forwardedRef, t4);
756
- let t5, t6;
757
- $[10] !== isTopLayer || $[11] !== onActivate ? (t5 = () => {
758
- isTopLayerRef.current !== isTopLayer && isTopLayer && onActivate?.({
759
- activeElement: lastFocusedRef.current
760
- }), isTopLayerRef.current = isTopLayer;
761
- }, t6 = [isTopLayer, onActivate], $[10] = isTopLayer, $[11] = onActivate, $[12] = t5, $[13] = t6) : (t5 = $[12], t6 = $[13]), useEffect(t5, t6);
762
- let t7;
763
- $[14] !== isTopLayer || $[15] !== onFocus ? (t7 = (event) => {
764
- onFocus?.(event);
765
- const rootElement = ref.current, target = document.activeElement;
766
- !isTopLayer || !rootElement || !target || isHTMLElement(target) && containsOrEqualsElement(rootElement, target) && (lastFocusedRef.current = target);
767
- }, $[14] = isTopLayer, $[15] = onFocus, $[16] = t7) : t7 = $[16];
768
- const handleFocus = t7, t8 = as;
769
- let t9;
770
- $[17] !== style || $[18] !== zIndex ? (t9 = {
771
- ...style,
772
- zIndex
773
- }, $[17] = style, $[18] = zIndex, $[19] = t9) : t9 = $[19];
774
- let t10;
775
- return $[20] !== children || $[21] !== handleFocus || $[22] !== position || $[23] !== rest || $[24] !== t8 || $[25] !== t9 ? (t10 = /* @__PURE__ */ jsx(Card, { "data-ui": "Layer", ...rest, as: t8, onFocus: handleFocus, position, ref, style: t9, children }), $[20] = children, $[21] = handleFocus, $[22] = position, $[23] = rest, $[24] = t8, $[25] = t9, $[26] = t10) : t10 = $[26], t10;
776
- }
777
- const media = Object.values(BREAKPOINTS);
778
- function _getMediaQuery(media2, index) {
779
- return index === 0 ? `screen and (max-width: ${media2[index + 1] - 1}px)` : index === media2.length - 1 ? `screen and (min-width: ${media2[index]}px)` : `screen and (min-width: ${media2[index]}px) and (max-width: ${media2[index + 1] - 1}px)`;
780
- }
781
- function _createMediaStore() {
782
- const mediaLen = media.length;
783
- let sizes;
784
- const getSizes = () => {
785
- if (typeof window > "u")
786
- return sizes;
787
- if (!sizes) {
788
- sizes = [];
789
- for (let index = mediaLen; index > -1; index -= 1) {
790
- const mediaQuery = _getMediaQuery(media, index);
791
- sizes.push({
792
- index,
793
- mq: window.matchMedia(mediaQuery)
794
- });
795
- }
796
- }
797
- return sizes;
798
- };
799
- return {
800
- getSnapshot: () => {
801
- for (const {
802
- index,
803
- mq
804
- } of getSizes() ?? [])
805
- if (mq.matches) return index;
806
- return 0;
807
- },
808
- subscribe: (onStoreChange) => {
809
- const disposeFns = [];
810
- for (const {
811
- mq
812
- } of getSizes() ?? []) {
813
- const handleChange = () => {
814
- mq.matches && onStoreChange();
815
- };
816
- mq.addEventListener("change", handleChange), disposeFns.push(() => mq.removeEventListener("change", handleChange));
817
- }
818
- return () => {
819
- for (const disposeFn of disposeFns)
820
- disposeFn();
821
- };
822
- }
823
- };
824
- }
825
- function getServerSnapshot() {
826
- return 0;
827
- }
828
- function useMediaIndex() {
829
- const $ = c(1);
830
- let t0, t1;
831
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = _createMediaStore(), $[0] = t1) : t1 = $[0], t0 = t1;
832
- const store = t0;
833
- return useSyncExternalStore(store.subscribe, store.getSnapshot, getServerSnapshot);
834
- }
835
- function LayerProvider(props) {
836
- const $ = c(19), {
837
- children,
838
- zOffset: t0
839
- } = props, zOffsetProp = t0 === void 0 ? 0 : t0, parentContextValue = useContext(LayerContext);
840
- let t1;
841
- $[0] !== parentContextValue ? (t1 = parentContextValue && getLayerContext(parentContextValue), $[0] = parentContextValue, $[1] = t1) : t1 = $[1];
842
- const parent = t1, parentRegisterChild = parent?.registerChild, level = (parent?.level ?? 0) + 1, zOffset = useResponsiveProp(zOffsetProp), maxMediaIndex = Object.values(zOffset).length - 1, mediaIndex = Math.min(useMediaIndex(), maxMediaIndex), zIndex = parent ? parent.zIndex + (zOffset[mediaIndex] ?? 0) : zOffset[mediaIndex] ?? 0;
843
- let t2;
844
- $[2] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {}, $[2] = t2) : t2 = $[2];
845
- const [, setChildLayers] = useState(t2), [size2, setSize] = useState(0), isTopLayer = size2 === 0;
846
- let t3;
847
- $[3] !== parentRegisterChild || $[4] !== setChildLayers ? (t3 = (childLevel) => {
848
- const parentDispose = parentRegisterChild?.(childLevel);
849
- return childLevel !== void 0 ? setChildLayers((state) => {
850
- const prevLen = state[childLevel] ?? 0, nextState = {
851
- ...state,
852
- [childLevel]: prevLen + 1
853
- };
854
- return setSize(Object.keys(nextState).length), nextState;
855
- }) : setSize(_temp$4), () => {
856
- childLevel !== void 0 ? setChildLayers((state_0) => {
857
- const nextState_0 = {
858
- ...state_0
859
- };
860
- return nextState_0[childLevel] === 1 ? (delete nextState_0[childLevel], setSize(Object.keys(nextState_0).length)) : nextState_0[childLevel] = nextState_0[childLevel] - 1, nextState_0;
861
- }) : setSize(_temp2$1), parentDispose?.();
862
- };
863
- }, $[3] = parentRegisterChild, $[4] = setChildLayers, $[5] = t3) : t3 = $[5];
864
- const registerChild = t3;
865
- let t4, t5;
866
- $[6] !== level || $[7] !== parentRegisterChild ? (t4 = () => parentRegisterChild?.(level), t5 = [level, parentRegisterChild], $[6] = level, $[7] = parentRegisterChild, $[8] = t4, $[9] = t5) : (t4 = $[8], t5 = $[9]), useEffect(t4, t5);
867
- let t6, t7;
868
- $[10] !== isTopLayer || $[11] !== level || $[12] !== registerChild || $[13] !== size2 || $[14] !== zIndex ? (t7 = {
869
- version: 0,
870
- isTopLayer,
871
- level,
872
- registerChild,
873
- size: size2,
874
- zIndex
875
- }, $[10] = isTopLayer, $[11] = level, $[12] = registerChild, $[13] = size2, $[14] = zIndex, $[15] = t7) : t7 = $[15], t6 = t7;
876
- const value = t6;
877
- let t8;
878
- return $[16] !== children || $[17] !== value ? (t8 = /* @__PURE__ */ jsx(LayerContext.Provider, { value, children }), $[16] = children, $[17] = value, $[18] = t8) : t8 = $[18], t8;
879
- }
880
- function _temp2$1(v_0) {
881
- return v_0 - 1;
882
- }
883
- function _temp$4(v) {
884
- return v + 1;
885
- }
886
- const DEFAULT_LAYER_ELEMENT = "div";
887
- function Layer(props) {
888
- const $ = c(12), t0 = props;
889
- let children, rest, t1, t2;
890
- $[0] !== t0 ? ({
891
- as: t1,
892
- children,
893
- zOffset: t2,
894
- ...rest
895
- } = t0, $[0] = t0, $[1] = children, $[2] = rest, $[3] = t1, $[4] = t2) : (children = $[1], rest = $[2], t1 = $[3], t2 = $[4]);
896
- const as = t1 === void 0 ? DEFAULT_LAYER_ELEMENT : t1, zOffset = t2 === void 0 ? 1 : t2;
897
- let t3;
898
- $[5] !== as || $[6] !== children || $[7] !== rest ? (t3 = /* @__PURE__ */ jsx(LayerCard, { ...rest, as, children }), $[5] = as, $[6] = children, $[7] = rest, $[8] = t3) : t3 = $[8];
899
- let t4;
900
- return $[9] !== t3 || $[10] !== zOffset ? (t4 = /* @__PURE__ */ jsx(LayerProvider, { zOffset, children: t3 }), $[9] = t3, $[10] = zOffset, $[11] = t4) : t4 = $[11], t4;
901
- }
902
- function PopoverLayer(props) {
903
- const $ = c(65);
904
- let animate, arrow2, arrowRef, arrowX, arrowY, children, marginsProp, maxWidth, originX, originY, overflow, padding, placement, radius, referenceWidth, rest, shadow, strategy, style, t0, xProp, yProp;
905
- $[0] !== props ? ({
906
- __unstable_margins: marginsProp,
907
- animate,
908
- arrow: arrow2,
909
- arrowRef,
910
- arrowX,
911
- arrowY,
912
- children,
913
- maxWidth,
914
- padding,
915
- placement,
916
- originX,
917
- originY,
918
- overflow,
919
- radius,
920
- referenceWidth,
921
- shadow,
922
- strategy,
923
- style,
924
- tone: t0,
925
- x: xProp,
926
- y: yProp,
927
- ...rest
928
- } = props, $[0] = props, $[1] = animate, $[2] = arrow2, $[3] = arrowRef, $[4] = arrowX, $[5] = arrowY, $[6] = children, $[7] = marginsProp, $[8] = maxWidth, $[9] = originX, $[10] = originY, $[11] = overflow, $[12] = padding, $[13] = placement, $[14] = radius, $[15] = referenceWidth, $[16] = rest, $[17] = shadow, $[18] = strategy, $[19] = style, $[20] = t0, $[21] = xProp, $[22] = yProp) : (animate = $[1], arrow2 = $[2], arrowRef = $[3], arrowX = $[4], arrowY = $[5], children = $[6], marginsProp = $[7], maxWidth = $[8], originX = $[9], originY = $[10], overflow = $[11], padding = $[12], placement = $[13], radius = $[14], referenceWidth = $[15], rest = $[16], shadow = $[17], strategy = $[18], style = $[19], t0 = $[20], xProp = $[21], yProp = $[22]);
929
- const tone = t0 === void 0 ? "inherit" : t0;
930
- let t1;
931
- t1 = marginsProp || DEFAULT_POPOVER_MARGINS;
932
- const margins = t1, x = (xProp ?? 0) + margins[3], y = (yProp ?? 0) + margins[0];
933
- let t2;
934
- const t3 = animate ? "transform" : void 0;
935
- let t4;
936
- $[23] !== originX || $[24] !== originY || $[25] !== referenceWidth || $[26] !== style || $[27] !== t3 || $[28] !== x || $[29] !== y ? (t4 = {
937
- left: x,
938
- originX,
939
- originY,
940
- top: y,
941
- width: referenceWidth,
942
- willChange: t3,
943
- ...style
944
- }, $[23] = originX, $[24] = originY, $[25] = referenceWidth, $[26] = style, $[27] = t3, $[28] = x, $[29] = y, $[30] = t4) : t4 = $[30], t2 = t4;
945
- const rootStyle = t2;
946
- let t5;
947
- const t6 = arrowX !== null ? arrowX : void 0, t7 = arrowY !== null ? arrowY : void 0;
948
- let t8;
949
- $[31] !== t6 || $[32] !== t7 ? (t8 = {
950
- left: t6,
951
- top: t7,
952
- right: void 0,
953
- bottom: void 0
954
- }, $[31] = t6, $[32] = t7, $[33] = t8) : t8 = $[33], t5 = t8;
955
- const arrowStyle = t5;
956
- let t9;
957
- $[34] === Symbol.for("react.memo_cache_sentinel") ? (t9 = popoverCard(), $[34] = t9) : t9 = $[34];
958
- let t10;
959
- $[35] !== animate ? (t10 = animate ? ["hidden", "initial"] : void 0, $[35] = animate, $[36] = t10) : t10 = $[36];
960
- let t11;
961
- $[37] !== animate ? (t11 = animate ? ["visible", "scaleIn"] : void 0, $[37] = animate, $[38] = t11) : t11 = $[38];
962
- let t12;
963
- $[39] !== animate ? (t12 = animate ? ["hidden", "scaleOut"] : void 0, $[39] = animate, $[40] = t12) : t12 = $[40];
964
- let t13;
965
- $[41] !== children || $[42] !== padding ? (t13 = /* @__PURE__ */ jsx(Flex, { direction: "column", flex: 1, padding, children }), $[41] = children, $[42] = padding, $[43] = t13) : t13 = $[43];
966
- let t14;
967
- $[44] !== maxWidth || $[45] !== overflow || $[46] !== t13 ? (t14 = /* @__PURE__ */ jsx(Flex, { "data-ui": "Popover__wrapper", direction: "column", flex: 1, maxWidth, overflow, children: t13 }), $[44] = maxWidth, $[45] = overflow, $[46] = t13, $[47] = t14) : t14 = $[47];
968
- let t15;
969
- $[48] !== arrow2 || $[49] !== arrowRef || $[50] !== arrowStyle ? (t15 = arrow2 && /* @__PURE__ */ jsx(Arrow, { ref: arrowRef, style: arrowStyle, width: DEFAULT_POPOVER_ARROW_WIDTH, height: DEFAULT_POPOVER_ARROW_HEIGHT, radius: DEFAULT_POPOVER_ARROW_RADIUS }), $[48] = arrow2, $[49] = arrowRef, $[50] = arrowStyle, $[51] = t15) : t15 = $[51];
970
- let t16;
971
- return $[52] !== placement || $[53] !== radius || $[54] !== rest || $[55] !== rootStyle || $[56] !== shadow || $[57] !== strategy || $[58] !== t10 || $[59] !== t11 || $[60] !== t12 || $[61] !== t14 || $[62] !== t15 || $[63] !== tone ? (t16 = /* @__PURE__ */ jsxs(Layer, { className: t9, "data-ui": "Popover", ...rest, as: motion.div, "data-context-tone": tone, "data-placement": placement, flexDirection: "column", display: "flex", position: strategy, radius, shadow, sizing: "border", style: rootStyle, tone, variants: POPOVER_MOTION_PROPS.card, transition: POPOVER_MOTION_PROPS.transition, initial: t10, animate: t11, exit: t12, children: [
972
- t14,
973
- t15
974
- ] }), $[52] = placement, $[53] = radius, $[54] = rest, $[55] = rootStyle, $[56] = shadow, $[57] = strategy, $[58] = t10, $[59] = t11, $[60] = t12, $[61] = t14, $[62] = t15, $[63] = tone, $[64] = t16) : t16 = $[64], t16;
975
- }
976
- const DEFAULT_POPOVER_ELEMENT = "div";
977
- function ViewportOverlay() {
978
- const $ = c(2), {
979
- zIndex
980
- } = useLayer();
981
- let t0;
982
- return $[0] !== zIndex ? (t0 = /* @__PURE__ */ jsx("div", { style: {
983
- position: "fixed",
984
- inset: 0,
985
- width: "100vw",
986
- height: "100vh",
987
- zIndex
988
- } }), $[0] = zIndex, $[1] = t0) : t0 = $[1], t0;
989
- }
990
- function Popover(props) {
991
- const boundaryElementContext = useBoundaryElement(), {
992
- __unstable_margins: margins = DEFAULT_POPOVER_MARGINS,
993
- animate: _animate = !1,
994
- arrow: arrowProp = !1,
995
- as = DEFAULT_POPOVER_ELEMENT,
996
- children: childProp,
997
- className,
998
- constrainSize = !1,
999
- content,
1000
- disabled,
1001
- fallbackPlacements = props.fallbackPlacements ?? DEFAULT_FALLBACK_PLACEMENTS$1[props.placement ?? "bottom"],
1002
- matchReferenceWidth,
1003
- floatingBoundary = boundaryElementContext.element,
1004
- modal,
1005
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1006
- onActivate,
1007
- open,
1008
- overflow = "hidden",
1009
- padding,
1010
- placement: placementProp = "bottom",
1011
- placementStrategy = "flip",
1012
- portal,
1013
- preventOverflow = !0,
1014
- radius = 3,
1015
- ref: forwardedRef,
1016
- referenceBoundary = boundaryElementContext.element,
1017
- referenceElement,
1018
- scheme,
1019
- shadow = 3,
1020
- tone = "inherit",
1021
- width: widthProp = "auto",
1022
- zOffset: zOffsetProp = Z_OFFSETS.popover,
1023
- updateRef,
1024
- ...rest
1025
- } = props, card2 = useCard(), animate = usePrefersReducedMotion() ? !1 : _animate, zOffset = useResponsiveProp(zOffsetProp), ref = useRef(null), arrowRef = useRef(null), rootBoundary = "viewport";
1026
- useImperativeHandle(forwardedRef, () => ref.current);
1027
- const referenceWidthRef = useRef(void 0), middleware = useMemo(() => {
1028
- const ret = [];
1029
- return (constrainSize || preventOverflow) && (placementStrategy === "autoPlacement" ? ret.push(autoPlacement({
1030
- allowedPlacements: [placementProp].concat(fallbackPlacements)
1031
- })) : ret.push(flip({
1032
- boundary: floatingBoundary || void 0,
1033
- fallbackPlacements,
1034
- padding: DEFAULT_POPOVER_PADDING,
1035
- rootBoundary
1036
- }))), ret.push(offset({
1037
- mainAxis: DEFAULT_POPOVER_DISTANCE
1038
- })), (constrainSize || matchReferenceWidth) && ret.push(size({
1039
- apply({
1040
- availableWidth,
1041
- availableHeight,
1042
- elements,
1043
- referenceWidth
1044
- }) {
1045
- referenceWidthRef.current = referenceWidth, matchReferenceWidth && (elements.floating.style.width = `${referenceWidth}px`), constrainSize && (elements.floating.style.maxWidth = `${availableWidth}px`, elements.floating.style.maxHeight = `${availableHeight}px`);
1046
- },
1047
- boundaryElement: floatingBoundary || void 0,
1048
- margins,
1049
- padding: DEFAULT_POPOVER_PADDING
1050
- })), preventOverflow && ret.push(shift({
1051
- boundary: floatingBoundary || void 0,
1052
- rootBoundary,
1053
- padding: DEFAULT_POPOVER_PADDING
1054
- })), arrowProp && ret.push(arrow({
1055
- element: arrowRef,
1056
- padding: DEFAULT_POPOVER_PADDING
1057
- })), animate && ret.push(origin), ret.push(hide({
1058
- boundary: referenceBoundary || void 0,
1059
- padding: DEFAULT_POPOVER_PADDING,
1060
- strategy: "referenceHidden"
1061
- })), ret;
1062
- }, [animate, arrowProp, constrainSize, fallbackPlacements, floatingBoundary, placementProp, placementStrategy, margins, matchReferenceWidth, preventOverflow, referenceBoundary]), {
1063
- x,
1064
- y,
1065
- middlewareData,
1066
- placement,
1067
- refs,
1068
- strategy,
1069
- update
1070
- } = useFloating({
1071
- middleware,
1072
- placement: placementProp,
1073
- whileElementsMounted: autoUpdate,
1074
- elements: referenceElement ? {
1075
- reference: referenceElement
1076
- } : void 0
1077
- }), referenceHidden = middlewareData.hide?.referenceHidden, arrowX = middlewareData.arrow?.x, arrowY = middlewareData.arrow?.y, originX = middlewareData["@sanity/ui/origin"]?.originX, originY = middlewareData["@sanity/ui/origin"]?.originY, setArrow = useCallback((arrowEl) => {
1078
- arrowRef.current = arrowEl;
1079
- }, []), setFloating = useCallback((node) => {
1080
- ref.current = node, refs.setFloating(node);
1081
- }, [refs]), setReference = useCallback((node_0) => {
1082
- if (refs.setReference(node_0), !childProp) return;
1083
- const childRef = getElementRef(childProp);
1084
- typeof childRef == "function" ? childRef(node_0) : childRef && (childRef.current = node_0);
1085
- }, [childProp, refs]), child = useMemo(() => referenceElement ? childProp : childProp ? cloneElement(childProp, {
1086
- ref: setReference
1087
- }) : null, [childProp, referenceElement, setReference]);
1088
- if (useEffect(() => {
1089
- updateRef && (typeof updateRef == "function" ? updateRef(update) : updateRef && (updateRef.current = update));
1090
- }, [update, updateRef]), disabled)
1091
- return childProp || /* @__PURE__ */ jsx(Fragment, {});
1092
- const node_1 = /* @__PURE__ */ jsxs(Fragment, { children: [
1093
- modal && /* @__PURE__ */ jsx(ViewportOverlay, {}),
1094
- /* @__PURE__ */ jsx(PopoverLayer, { ...rest, __unstable_margins: margins, animate, arrow: arrowProp, arrowRef: setArrow, arrowX, arrowY, as, className: popover({
1095
- className
1096
- }), hidden: referenceHidden, maxWidth: widthProp, overflow, padding, placement, radius, ref: setFloating, scheme, shadow, originX, originY, strategy, x, y, zOffset, children: content })
1097
- ] }), children = open && (portal ? /* @__PURE__ */ jsx(Portal, { __unstable_name: typeof portal == "string" ? portal : void 0, children: /* @__PURE__ */ jsx(CardProvider, { tone: tone === "inherit" ? card2.tone : tone, scheme: scheme ?? "light", children: node_1 }) }) : node_1);
1098
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1099
- animate ? /* @__PURE__ */ jsx(AnimatePresence, { children }) : children,
1100
- child
1101
- ] });
1102
- }
1103
- const DEFAULT_SELECTABLE_ELEMENT = "button";
1104
- function Selectable(props) {
1105
- const $ = c(16), t0 = props;
1106
- let className, radius, rest, selected, t1, tone;
1107
- $[0] !== t0 ? ({
1108
- as: t1,
1109
- className,
1110
- radius,
1111
- selected,
1112
- tone,
1113
- ...rest
1114
- } = t0, $[0] = t0, $[1] = className, $[2] = radius, $[3] = rest, $[4] = selected, $[5] = t1, $[6] = tone) : (className = $[1], radius = $[2], rest = $[3], selected = $[4], t1 = $[5], tone = $[6]);
1115
- const as = t1 === void 0 ? DEFAULT_SELECTABLE_ELEMENT : t1;
1116
- let t2;
1117
- $[7] !== className || $[8] !== radius || $[9] !== tone ? (t2 = _selectable({
1118
- className,
1119
- radius,
1120
- tone
1121
- }), $[7] = className, $[8] = radius, $[9] = tone, $[10] = t2) : t2 = $[10];
1122
- const t3 = selected ? "" : void 0;
1123
- let t4;
1124
- return $[11] !== as || $[12] !== rest || $[13] !== t2 || $[14] !== t3 ? (t4 = /* @__PURE__ */ jsx(Box, { ...rest, as, className: t2, "data-selected": t3 }), $[11] = as, $[12] = rest, $[13] = t2, $[14] = t3, $[15] = t4) : t4 = $[15], t4;
1125
- }
1126
- const DEFAULT_STACK_ELEMENT = "div";
1127
- function Stack(props) {
1128
- const $ = c(12), t0 = props;
1129
- let className, gap, rest, t1;
1130
- $[0] !== t0 ? ({
1131
- as: t1,
1132
- className,
1133
- gap,
1134
- ...rest
1135
- } = t0, $[0] = t0, $[1] = className, $[2] = gap, $[3] = rest, $[4] = t1) : (className = $[1], gap = $[2], rest = $[3], t1 = $[4]);
1136
- const as = t1 === void 0 ? DEFAULT_STACK_ELEMENT : t1;
1137
- let t2;
1138
- $[5] !== className ? (t2 = stack({
1139
- className
1140
- }), $[5] = className, $[6] = t2) : t2 = $[6];
1141
- let t3;
1142
- return $[7] !== as || $[8] !== gap || $[9] !== rest || $[10] !== t2 ? (t3 = /* @__PURE__ */ jsx(Box, { "data-ui": "Stack", ...rest, as, gridAutoRows: "min", className: t2, display: "grid", gap }), $[7] = as, $[8] = gap, $[9] = rest, $[10] = t2, $[11] = t3) : t3 = $[11], t3;
1143
- }
1144
- function useCustomValidity(ref, customValidity) {
1145
- const $ = c(6);
1146
- let t0;
1147
- $[0] !== customValidity || $[1] !== ref.current ? (t0 = () => {
1148
- ref.current?.setCustomValidity(customValidity || "");
1149
- }, $[0] = customValidity, $[1] = ref.current, $[2] = t0) : t0 = $[2];
1150
- let t1;
1151
- $[3] !== customValidity || $[4] !== ref ? (t1 = [customValidity, ref], $[3] = customValidity, $[4] = ref, $[5] = t1) : t1 = $[5], useEffect(t0, t1);
1152
- }
1153
- const DEFAULT_TEXT_INPUT_ELEMENT = "input";
1154
- function TextInput(props) {
1155
- const $ = c(88), t0 = props;
1156
- let IconComponent, IconRightComponent, __unstable_disableFocusRing, className, clearButton, customValidity, forwardedRef, onClear, prefix, readOnly, rest, suffix, t1, t2, t3, t4, t5, t6, t7, t8, width;
1157
- if ($[0] !== t0) {
1158
- const {
1159
- __unstable_disableFocusRing: t92,
1160
- as: t102,
1161
- border: t112,
1162
- className: t122,
1163
- clearButton: t132,
1164
- disabled: t142,
1165
- fontSize: t152,
1166
- gap: t162,
1167
- icon: t172,
1168
- iconRight: t182,
1169
- onClear: t192,
1170
- padding: t202,
1171
- prefix: t212,
1172
- radius: t222,
1173
- readOnly: t232,
1174
- ref: t242,
1175
- suffix: t252,
1176
- customValidity: t262,
1177
- type: t272,
1178
- weight: _width,
1179
- width: t282,
1180
- ...t292
1181
- } = t0;
1182
- __unstable_disableFocusRing = t92, t1 = t102, t2 = t112, className = t122, clearButton = t132, t3 = t142, t4 = t152, t5 = t162, IconComponent = t172, IconRightComponent = t182, onClear = t192, t6 = t202, prefix = t212, t7 = t222, readOnly = t232, forwardedRef = t242, suffix = t252, customValidity = t262, t8 = t272, width = t282, rest = t292, $[0] = t0, $[1] = IconComponent, $[2] = IconRightComponent, $[3] = __unstable_disableFocusRing, $[4] = className, $[5] = clearButton, $[6] = customValidity, $[7] = forwardedRef, $[8] = onClear, $[9] = prefix, $[10] = readOnly, $[11] = rest, $[12] = suffix, $[13] = t1, $[14] = t2, $[15] = t3, $[16] = t4, $[17] = t5, $[18] = t6, $[19] = t7, $[20] = t8, $[21] = width;
1183
- } else
1184
- IconComponent = $[1], IconRightComponent = $[2], __unstable_disableFocusRing = $[3], className = $[4], clearButton = $[5], customValidity = $[6], forwardedRef = $[7], onClear = $[8], prefix = $[9], readOnly = $[10], rest = $[11], suffix = $[12], t1 = $[13], t2 = $[14], t3 = $[15], t4 = $[16], t5 = $[17], t6 = $[18], t7 = $[19], t8 = $[20], width = $[21];
1185
- const Element = t1 === void 0 ? DEFAULT_TEXT_INPUT_ELEMENT : t1, border = t2 === void 0 ? !0 : t2, disabled = t3 === void 0 ? !1 : t3, fontSize = t4 === void 0 ? 2 : t4, gap = t5 === void 0 ? 3 : t5, padding = t6 === void 0 ? 3 : t6, radius = t7 === void 0 ? 2 : t7, type = t8 === void 0 ? "text" : t8, ref = useRef(null), responsivePadding = useResponsiveProp(padding), withClearButton = !!clearButton;
1186
- let t9;
1187
- $[22] === Symbol.for("react.memo_cache_sentinel") ? (t9 = () => ref.current, $[22] = t9) : t9 = $[22], useImperativeHandle(forwardedRef, t9), useCustomValidity(ref, customValidity);
1188
- const handleClearMouseDown = _temp$3;
1189
- let t10;
1190
- $[23] !== onClear ? (t10 = (event_0) => {
1191
- event_0.preventDefault(), event_0.stopPropagation(), onClear && onClear(), ref.current?.focus();
1192
- }, $[23] = onClear, $[24] = t10) : t10 = $[24];
1193
- const handleClearClick = t10;
1194
- let t11, t12;
1195
- $[25] !== responsivePadding ? (t12 = Object.fromEntries(Object.entries(responsivePadding).map(_temp2)), $[25] = responsivePadding, $[26] = t12) : t12 = $[26], t11 = t12;
1196
- const clearButtonBoxPadding = t11;
1197
- let t13, t14;
1198
- $[27] !== responsivePadding ? (t14 = Object.fromEntries(Object.entries(responsivePadding).map(_temp3)), $[27] = responsivePadding, $[28] = t14) : t14 = $[28], t13 = t14;
1199
- const clearButtonPadding = t13;
1200
- let t15;
1201
- t15 = isRecord(clearButton) ? clearButton : EMPTY_RECORD;
1202
- const clearButtonProps = t15;
1203
- let t16;
1204
- $[29] !== border || $[30] !== className || $[31] !== fontSize || $[32] !== gap || $[33] !== padding || $[34] !== radius || $[35] !== width ? (t16 = textInput({
1205
- className,
1206
- border,
1207
- fontSize,
1208
- padding,
1209
- radius,
1210
- gap,
1211
- width
1212
- }), $[29] = border, $[30] = className, $[31] = fontSize, $[32] = gap, $[33] = padding, $[34] = radius, $[35] = width, $[36] = t16) : t16 = $[36];
1213
- const t17 = IconComponent ? "" : void 0, t18 = IconRightComponent ? "" : void 0, t19 = customValidity ? "" : void 0, t20 = prefix ? "" : void 0, t21 = !disabled && readOnly ? "" : void 0, t22 = suffix ? "" : void 0;
1214
- let t23;
1215
- $[37] !== prefix ? (t23 = prefix && /* @__PURE__ */ jsx(Box, { className: textInputPrefix(), sizing: "border", children: /* @__PURE__ */ jsx("span", { children: prefix }) }), $[37] = prefix, $[38] = t23) : t23 = $[38];
1216
- let t24;
1217
- $[39] === Symbol.for("react.memo_cache_sentinel") ? (t24 = textInputElement(), $[39] = t24) : t24 = $[39];
1218
- let t25;
1219
- $[40] === Symbol.for("react.memo_cache_sentinel") ? (t25 = _inputElement(), $[40] = t25) : t25 = $[40];
1220
- const t26 = __unstable_disableFocusRing ? "" : void 0;
1221
- let t27;
1222
- $[41] !== Element || $[42] !== disabled || $[43] !== readOnly || $[44] !== rest || $[45] !== t26 || $[46] !== type ? (t27 = /* @__PURE__ */ jsx(Element, { ...rest, className: t25, "data-no-focus-ring": t26, disabled, readOnly, ref, type }), $[41] = Element, $[42] = disabled, $[43] = readOnly, $[44] = rest, $[45] = t26, $[46] = type, $[47] = t27) : t27 = $[47];
1223
- let t28;
1224
- $[48] === Symbol.for("react.memo_cache_sentinel") ? (t28 = _inputPresentation(), $[48] = t28) : t28 = $[48];
1225
- let t29;
1226
- $[49] !== IconComponent || $[50] !== fontSize || $[51] !== padding ? (t29 = IconComponent && /* @__PURE__ */ jsx(Box, { padding, position: "absolute", insetTop: 0, insetLeft: 0, children: /* @__PURE__ */ jsxs(Text, { size: fontSize, children: [
1227
- isValidElement(IconComponent) && IconComponent,
1228
- isValidElementType(IconComponent) && /* @__PURE__ */ jsx(IconComponent, {})
1229
- ] }) }), $[49] = IconComponent, $[50] = fontSize, $[51] = padding, $[52] = t29) : t29 = $[52];
1230
- let t30;
1231
- $[53] !== IconRightComponent || $[54] !== fontSize || $[55] !== padding || $[56] !== withClearButton ? (t30 = !withClearButton && IconRightComponent && /* @__PURE__ */ jsx(Box, { padding, position: "absolute", insetTop: 0, insetRight: 0, children: /* @__PURE__ */ jsxs(Text, { size: fontSize, children: [
1232
- isValidElement(IconRightComponent) && IconRightComponent,
1233
- isValidElementType(IconRightComponent) && /* @__PURE__ */ jsx(IconRightComponent, {})
1234
- ] }) }), $[53] = IconRightComponent, $[54] = fontSize, $[55] = padding, $[56] = withClearButton, $[57] = t30) : t30 = $[57];
1235
- let t31;
1236
- $[58] !== t29 || $[59] !== t30 ? (t31 = /* @__PURE__ */ jsxs(Box, { className: t28, position: "absolute", children: [
1237
- t29,
1238
- t30
1239
- ] }), $[58] = t29, $[59] = t30, $[60] = t31) : t31 = $[60];
1240
- let t32;
1241
- $[61] !== clearButton || $[62] !== clearButtonBoxPadding || $[63] !== clearButtonPadding || $[64] !== clearButtonProps || $[65] !== disabled || $[66] !== fontSize || $[67] !== handleClearClick || $[68] !== radius || $[69] !== readOnly ? (t32 = !disabled && !readOnly && clearButton && /* @__PURE__ */ jsx(Box, { insetTop: 0, insetRight: 0, padding: clearButtonBoxPadding, position: "absolute", style: {
1242
- zIndex: 2
1243
- }, children: /* @__PURE__ */ jsx(Button, { "aria-label": "Clear", "data-qa": "clear-button", display: "block", fontSize, icon: CloseIcon, mode: "bleed", padding: clearButtonPadding, radius, ...clearButtonProps, onClick: handleClearClick, onMouseDown: handleClearMouseDown }) }), $[61] = clearButton, $[62] = clearButtonBoxPadding, $[63] = clearButtonPadding, $[64] = clearButtonProps, $[65] = disabled, $[66] = fontSize, $[67] = handleClearClick, $[68] = radius, $[69] = readOnly, $[70] = t32) : t32 = $[70];
1244
- let t33;
1245
- $[71] !== t27 || $[72] !== t31 || $[73] !== t32 ? (t33 = /* @__PURE__ */ jsxs(Box, { className: t24, flex: 1, position: "relative", children: [
1246
- t27,
1247
- t31,
1248
- t32
1249
- ] }), $[71] = t27, $[72] = t31, $[73] = t32, $[74] = t33) : t33 = $[74];
1250
- let t34;
1251
- $[75] !== suffix ? (t34 = suffix && /* @__PURE__ */ jsx(Box, { className: textInputSuffix(), sizing: "border", children: /* @__PURE__ */ jsx("span", { children: suffix }) }), $[75] = suffix, $[76] = t34) : t34 = $[76];
1252
- let t35;
1253
- return $[77] !== t16 || $[78] !== t17 || $[79] !== t18 || $[80] !== t19 || $[81] !== t20 || $[82] !== t21 || $[83] !== t22 || $[84] !== t23 || $[85] !== t33 || $[86] !== t34 ? (t35 = /* @__PURE__ */ jsxs(Box, { alignItems: "center", className: t16, "data-icon-left": t17, "data-icon-right": t18, "data-invalid": t19, "data-prefix": t20, "data-read-only": t21, "data-suffix": t22, "data-ui": "TextInput", display: "flex", children: [
1254
- t23,
1255
- t33,
1256
- t34
1257
- ] }), $[77] = t16, $[78] = t17, $[79] = t18, $[80] = t19, $[81] = t20, $[82] = t21, $[83] = t22, $[84] = t23, $[85] = t33, $[86] = t34, $[87] = t35) : t35 = $[87], t35;
1258
- }
1259
- function _temp3(t0) {
1260
- const [key_0, value_0] = t0;
1261
- return value_0 === 0 ? [key_0, 0] : value_0 === 1 ? [key_0, 0] : value_0 === 2 ? [key_0, 1] : [key_0, typeof value_0 == "number" ? value_0 - 1 : 0];
1262
- }
1263
- function _temp2(t0) {
1264
- const [key2, value] = t0;
1265
- return value === 0 ? [key2, 0] : value === 1 ? [key2, 1] : value === 2 ? [key2, 1] : [key2, typeof value == "number" ? value - 2 : 0];
1266
- }
1267
- function _temp$3(event) {
1268
- event.preventDefault(), event.stopPropagation();
1269
- }
1270
- function useClickOutsideEvent(listener, t0, boundaryElement) {
1271
- const $ = c(9), elementsArg = t0 === void 0 ? _temp$2 : t0;
1272
- let t1;
1273
- $[0] !== boundaryElement || $[1] !== elementsArg || $[2] !== listener ? (t1 = (evt) => {
1274
- if (!listener)
1275
- return;
1276
- const target = evt.target;
1277
- if (!(target instanceof Node))
1278
- return;
1279
- const resolvedBoundaryElement = boundaryElement?.();
1280
- if (resolvedBoundaryElement && !resolvedBoundaryElement.contains(target))
1281
- return;
1282
- const elements = elementsArg().flat();
1283
- for (const el of elements)
1284
- if (el && (target === el || el.contains(target)))
1285
- return;
1286
- listener(evt);
1287
- }, $[0] = boundaryElement, $[1] = elementsArg, $[2] = listener, $[3] = t1) : t1 = $[3];
1288
- const onEvent = useEffectEvent(t1), hasListener = !!listener;
1289
- let t2;
1290
- $[4] !== hasListener || $[5] !== onEvent ? (t2 = () => {
1291
- if (!hasListener)
1292
- return;
1293
- const handleEvent = (evt_0) => onEvent(evt_0);
1294
- return document.addEventListener("mousedown", handleEvent), () => {
1295
- document.removeEventListener("mousedown", handleEvent);
1296
- };
1297
- }, $[4] = hasListener, $[5] = onEvent, $[6] = t2) : t2 = $[6];
1298
- let t3;
1299
- $[7] !== hasListener ? (t3 = [hasListener], $[7] = hasListener, $[8] = t3) : t3 = $[8], useEffect(t2, t3), useDebugValue(listener ? "MouseDown On" : "MouseDown Off");
1300
- }
1301
- function _temp$2() {
1302
- return EMPTY_ARRAY;
1303
- }
1304
- function useGlobalKeyDown(onKeyDown) {
1305
- const $ = c(5);
1306
- let t0;
1307
- $[0] !== onKeyDown ? (t0 = (event) => onKeyDown(event), $[0] = onKeyDown, $[1] = t0) : t0 = $[1];
1308
- const handleKeyDown = useEffectEvent(t0);
1309
- let t1;
1310
- $[2] !== handleKeyDown ? (t1 = () => {
1311
- const handler = (event_0) => handleKeyDown(event_0);
1312
- return window.addEventListener("keydown", handler), () => window.removeEventListener("keydown", handler);
1313
- }, $[2] = handleKeyDown, $[3] = t1) : t1 = $[3];
1314
- let t2;
1315
- $[4] === Symbol.for("react.memo_cache_sentinel") ? (t2 = [], $[4] = t2) : t2 = $[4], useEffect(t1, t2);
1316
- }
1317
- const DEFAULT_KBD_ELEMENT = "kbd";
1318
- function KBD(props) {
1319
- const $ = c(22), t0 = props;
1320
- let children, className, rest, t1, t2, t3, t4, t5;
1321
- $[0] !== t0 ? ({
1322
- as: t1,
1323
- children,
1324
- className,
1325
- display: t2,
1326
- fontSize: t3,
1327
- padding: t4,
1328
- radius: t5,
1329
- ...rest
1330
- } = t0, $[0] = t0, $[1] = children, $[2] = className, $[3] = rest, $[4] = t1, $[5] = t2, $[6] = t3, $[7] = t4, $[8] = t5) : (children = $[1], className = $[2], rest = $[3], t1 = $[4], t2 = $[5], t3 = $[6], t4 = $[7], t5 = $[8]);
1331
- const as = t1 === void 0 ? DEFAULT_KBD_ELEMENT : t1, display = t2 === void 0 ? "inline-block" : t2, fontSize = t3 === void 0 ? 1 : t3, padding = t4 === void 0 ? 1 : t4, radius = t5 === void 0 ? 2 : t5, t6 = as;
1332
- let t7;
1333
- $[9] !== className || $[10] !== radius ? (t7 = kbd({
1334
- className,
1335
- radius
1336
- }), $[9] = className, $[10] = radius, $[11] = t7) : t7 = $[11];
1337
- let t8;
1338
- $[12] !== children || $[13] !== fontSize ? (t8 = /* @__PURE__ */ jsx(Text, { as: "span", muted: !0, size: fontSize, weight: "medium", children }), $[12] = children, $[13] = fontSize, $[14] = t8) : t8 = $[14];
1339
- let t9;
1340
- return $[15] !== display || $[16] !== padding || $[17] !== rest || $[18] !== t6 || $[19] !== t7 || $[20] !== t8 ? (t9 = /* @__PURE__ */ jsx(Box, { "data-ui": "KBD", ...rest, as: t6, className: t7, display, muted: !0, padding, children: t8 }), $[15] = display, $[16] = padding, $[17] = rest, $[18] = t6, $[19] = t7, $[20] = t8, $[21] = t9) : t9 = $[21], t9;
1341
- }
1342
- const DEFAULT_HOTKEYS_ELEMENT = "kbd";
1343
- function Hotkeys(props) {
1344
- const $ = c(26), t0 = props;
1345
- let fontSize, gapX, gapY, keys, padding, radius, rest, t1, t2;
1346
- $[0] !== t0 ? ({
1347
- as: t1,
1348
- fontSize,
1349
- gap: t2,
1350
- gapX,
1351
- gapY,
1352
- keys,
1353
- padding,
1354
- radius,
1355
- ...rest
1356
- } = t0, $[0] = t0, $[1] = fontSize, $[2] = gapX, $[3] = gapY, $[4] = keys, $[5] = padding, $[6] = radius, $[7] = rest, $[8] = t1, $[9] = t2) : (fontSize = $[1], gapX = $[2], gapY = $[3], keys = $[4], padding = $[5], radius = $[6], rest = $[7], t1 = $[8], t2 = $[9]);
1357
- const as = t1 === void 0 ? DEFAULT_HOTKEYS_ELEMENT : t1, gap = t2 === void 0 ? 1 : t2;
1358
- if (!keys || keys.length === 0)
1359
- return;
1360
- let t3;
1361
- if ($[10] !== fontSize || $[11] !== keys || $[12] !== padding || $[13] !== radius) {
1362
- let t42;
1363
- $[15] !== fontSize || $[16] !== padding || $[17] !== radius ? (t42 = (key2, i) => /* @__PURE__ */ jsx(KBD, { fontSize, padding, radius, children: key2 }, i), $[15] = fontSize, $[16] = padding, $[17] = radius, $[18] = t42) : t42 = $[18], t3 = keys.map(t42), $[10] = fontSize, $[11] = keys, $[12] = padding, $[13] = radius, $[14] = t3;
1364
- } else
1365
- t3 = $[14];
1366
- let t4;
1367
- return $[19] !== as || $[20] !== gap || $[21] !== gapX || $[22] !== gapY || $[23] !== rest || $[24] !== t3 ? (t4 = /* @__PURE__ */ jsx(Box, { as, "data-ui": "Hotkeys", ...rest, display: "flex", gap, gapX, gapY, children: t3 }), $[19] = as, $[20] = gap, $[21] = gapX, $[22] = gapY, $[23] = rest, $[24] = t3, $[25] = t4) : t4 = $[25], t4;
1368
- }
1369
- const MenuContext = createGlobalScopedContext("@sanity/ui/v3/menu", null);
1370
- function _isFocusable(element) {
1371
- return isHTMLAnchorElement(element) && element.getAttribute("data-disabled") !== "true" || isHTMLButtonElement(element) && !element.disabled;
1372
- }
1373
- function _getFocusableElements(elements) {
1374
- return elements.filter(_isFocusable);
1375
- }
1376
- function _getDOMPath(rootElement, el) {
1377
- const path = [];
1378
- let e = el;
1379
- for (; e !== rootElement; ) {
1380
- const parentElement = e.parentElement;
1381
- if (!parentElement) return path;
1382
- const index = Array.from(parentElement.childNodes).indexOf(e);
1383
- if (path.unshift(index), parentElement === rootElement)
1384
- return path;
1385
- e = parentElement;
1386
- }
1387
- return path;
1388
- }
1389
- const EMPTY_PATH = [];
1390
- function _sortElements(rootElement, elements) {
1391
- if (!rootElement) return;
1392
- const map = /* @__PURE__ */ new WeakMap();
1393
- for (const el of elements)
1394
- map.set(el, _getDOMPath(rootElement, el));
1395
- const _sort = (a, b) => {
1396
- const _a = map.get(a) || EMPTY_PATH, _b = map.get(b) || EMPTY_PATH, len = Math.max(_a.length, _b.length);
1397
- for (let i = 0; i < len; i += 1) {
1398
- const aIndex = _a[i] || -1, bIndex = _b[i] || -1;
1399
- if (aIndex !== bIndex)
1400
- return aIndex - bIndex;
1401
- }
1402
- return 0;
1403
- };
1404
- elements.sort(_sort);
1405
- }
1406
- function useMenuController(props) {
1407
- const {
1408
- onKeyDown,
1409
- originElement,
1410
- shouldFocus,
1411
- rootElementRef
1412
- } = props, elementsRef = useRef([]), [activeIndex, _setActiveIndex] = useState(-1), activeIndexRef = useRef(activeIndex), activeElement = useMemo(() => elementsRef.current[activeIndex] || null, [activeIndex]), mounted = !!rootElementRef.current, setActiveIndex = useCallback((nextActiveIndex) => {
1413
- _setActiveIndex(nextActiveIndex), activeIndexRef.current = nextActiveIndex;
1414
- }, []), mount = useCallback((element, selected) => {
1415
- if (!element) return () => {
1416
- };
1417
- if (elementsRef.current.indexOf(element) === -1 && (elementsRef.current.push(element), _sortElements(rootElementRef.current, elementsRef.current)), selected) {
1418
- const selectedIndex = elementsRef.current.indexOf(element);
1419
- setActiveIndex(selectedIndex);
1420
- }
1421
- return () => {
1422
- const idx = elementsRef.current.indexOf(element);
1423
- idx > -1 && elementsRef.current.splice(idx, 1);
1424
- };
1425
- }, [rootElementRef, setActiveIndex]), handleKeyDown = useCallback((event) => {
1426
- if (event.key === "Tab") {
1427
- originElement && originElement.focus();
1428
- return;
1429
- }
1430
- if (event.key === "Home") {
1431
- event.preventDefault(), event.stopPropagation();
1432
- const el = _getFocusableElements(elementsRef.current)[0];
1433
- if (!el) return;
1434
- const currentIndex = elementsRef.current.indexOf(el);
1435
- setActiveIndex(currentIndex);
1436
- return;
1437
- }
1438
- if (event.key === "End") {
1439
- event.preventDefault(), event.stopPropagation();
1440
- const focusableElements_0 = _getFocusableElements(elementsRef.current), el_0 = focusableElements_0[focusableElements_0.length - 1];
1441
- if (!el_0) return;
1442
- const currentIndex_0 = elementsRef.current.indexOf(el_0);
1443
- setActiveIndex(currentIndex_0);
1444
- return;
1445
- }
1446
- if (event.key === "ArrowUp") {
1447
- event.preventDefault(), event.stopPropagation();
1448
- const focusableElements_1 = _getFocusableElements(elementsRef.current), focusableLen = focusableElements_1.length;
1449
- if (focusableLen === 0) return;
1450
- const focusedElement = elementsRef.current[activeIndexRef.current];
1451
- let focusedIndex = focusableElements_1.indexOf(focusedElement);
1452
- focusedIndex = (focusedIndex - 1 + focusableLen) % focusableLen;
1453
- const el_1 = focusableElements_1[focusedIndex], currentIndex_1 = elementsRef.current.indexOf(el_1);
1454
- setActiveIndex(currentIndex_1);
1455
- return;
1456
- }
1457
- if (event.key === "ArrowDown") {
1458
- event.preventDefault(), event.stopPropagation();
1459
- const focusableElements_2 = _getFocusableElements(elementsRef.current), focusableLen_0 = focusableElements_2.length;
1460
- if (focusableLen_0 === 0) return;
1461
- const focusedElement_0 = elementsRef.current[activeIndexRef.current];
1462
- let focusedIndex_0 = focusableElements_2.indexOf(focusedElement_0);
1463
- focusedIndex_0 = (focusedIndex_0 + 1) % focusableLen_0;
1464
- const el_2 = focusableElements_2[focusedIndex_0], currentIndex_2 = elementsRef.current.indexOf(el_2);
1465
- setActiveIndex(currentIndex_2);
1466
- return;
1467
- }
1468
- onKeyDown && onKeyDown(event);
1469
- }, [onKeyDown, originElement, setActiveIndex]), handleItemMouseEnter = useCallback((event_0) => {
1470
- const element_0 = event_0.currentTarget, currentIndex_3 = elementsRef.current.indexOf(element_0);
1471
- setActiveIndex(currentIndex_3);
1472
- }, [setActiveIndex]), handleItemMouseLeave = useCallback(() => {
1473
- setActiveIndex(-2), rootElementRef.current?.focus();
1474
- }, [rootElementRef, setActiveIndex]);
1475
- return useEffect(() => {
1476
- if (!mounted) return;
1477
- const rafId = requestAnimationFrame(() => {
1478
- if (activeIndex === -1) {
1479
- if (shouldFocus === "first") {
1480
- const el_3 = _getFocusableElements(elementsRef.current)[0];
1481
- if (el_3) {
1482
- const currentIndex_4 = elementsRef.current.indexOf(el_3);
1483
- setActiveIndex(currentIndex_4);
1484
- }
1485
- }
1486
- if (shouldFocus === "last") {
1487
- const focusableElements_4 = _getFocusableElements(elementsRef.current), el_4 = focusableElements_4[focusableElements_4.length - 1];
1488
- if (el_4) {
1489
- const currentIndex_5 = elementsRef.current.indexOf(el_4);
1490
- setActiveIndex(currentIndex_5);
1491
- }
1492
- }
1493
- return;
1494
- }
1495
- (elementsRef.current[activeIndex] || null)?.focus();
1496
- });
1497
- return () => cancelAnimationFrame(rafId);
1498
- }, [activeIndex, mounted, setActiveIndex, shouldFocus]), {
1499
- activeElement,
1500
- activeIndex,
1501
- handleItemMouseEnter,
1502
- handleItemMouseLeave,
1503
- handleKeyDown,
1504
- mount
1505
- };
1506
- }
1507
- const DEFAULT_MENU_ELEMENT = "div";
1508
- function Menu(props) {
1509
- const $ = c(57), t0 = props;
1510
- let _shouldFocus, children, className, forwardedRef, onClickOutside, onEscape, onItemClick, onItemSelect, onKeyDown, originElement, registerElement, rest, t1, t2, t3;
1511
- $[0] !== t0 ? ({
1512
- as: t1,
1513
- children,
1514
- className,
1515
- gap: t2,
1516
- onClickOutside,
1517
- onEscape,
1518
- onItemClick,
1519
- onItemSelect,
1520
- onKeyDown,
1521
- originElement,
1522
- padding: t3,
1523
- ref: forwardedRef,
1524
- registerElement,
1525
- shouldFocus: _shouldFocus,
1526
- ...rest
1527
- } = t0, $[0] = t0, $[1] = _shouldFocus, $[2] = children, $[3] = className, $[4] = forwardedRef, $[5] = onClickOutside, $[6] = onEscape, $[7] = onItemClick, $[8] = onItemSelect, $[9] = onKeyDown, $[10] = originElement, $[11] = registerElement, $[12] = rest, $[13] = t1, $[14] = t2, $[15] = t3) : (_shouldFocus = $[1], children = $[2], className = $[3], forwardedRef = $[4], onClickOutside = $[5], onEscape = $[6], onItemClick = $[7], onItemSelect = $[8], onKeyDown = $[9], originElement = $[10], registerElement = $[11], rest = $[12], t1 = $[13], t2 = $[14], t3 = $[15]);
1528
- const as = t1 === void 0 ? DEFAULT_MENU_ELEMENT : t1, gap = t2 === void 0 ? 1 : t2, padding = t3 === void 0 ? 1 : t3, shouldFocus = _shouldFocus ?? null, ref = useRef(null);
1529
- let t4;
1530
- $[16] === Symbol.for("react.memo_cache_sentinel") ? (t4 = () => ref.current, $[16] = t4) : t4 = $[16], useImperativeHandle(forwardedRef, t4);
1531
- const {
1532
- isTopLayer
1533
- } = useLayer();
1534
- let t5;
1535
- $[17] !== onKeyDown || $[18] !== originElement || $[19] !== shouldFocus ? (t5 = {
1536
- onKeyDown,
1537
- originElement,
1538
- shouldFocus,
1539
- rootElementRef: ref
1540
- }, $[17] = onKeyDown, $[18] = originElement, $[19] = shouldFocus, $[20] = t5) : t5 = $[20];
1541
- const {
1542
- activeElement,
1543
- activeIndex,
1544
- handleItemMouseEnter,
1545
- handleItemMouseLeave,
1546
- handleKeyDown,
1547
- mount
1548
- } = useMenuController(t5), unregisterElementRef = useRef(null);
1549
- let t6;
1550
- $[21] !== registerElement ? (t6 = (el) => {
1551
- unregisterElementRef.current && (unregisterElementRef.current(), unregisterElementRef.current = null), ref.current = el, ref.current && registerElement && (unregisterElementRef.current = registerElement(ref.current));
1552
- }, $[21] = registerElement, $[22] = t6) : t6 = $[22];
1553
- const handleRefChange = t6;
1554
- let t7, t8;
1555
- $[23] !== activeIndex || $[24] !== onItemSelect ? (t7 = () => {
1556
- onItemSelect && onItemSelect(activeIndex);
1557
- }, t8 = [activeIndex, onItemSelect], $[23] = activeIndex, $[24] = onItemSelect, $[25] = t7, $[26] = t8) : (t7 = $[25], t8 = $[26]), useEffect(t7, t8);
1558
- let t9;
1559
- $[27] === Symbol.for("react.memo_cache_sentinel") ? (t9 = () => [ref.current], $[27] = t9) : t9 = $[27], useClickOutsideEvent(isTopLayer && onClickOutside, t9);
1560
- let t10;
1561
- $[28] !== isTopLayer || $[29] !== onEscape ? (t10 = (event) => {
1562
- isTopLayer && event.key === "Escape" && (event.stopPropagation(), onEscape && onEscape());
1563
- }, $[28] = isTopLayer, $[29] = onEscape, $[30] = t10) : t10 = $[30], useGlobalKeyDown(t10);
1564
- let t11, t12;
1565
- $[31] !== activeElement || $[32] !== activeIndex || $[33] !== handleItemMouseEnter || $[34] !== handleItemMouseLeave || $[35] !== mount || $[36] !== onClickOutside || $[37] !== onEscape || $[38] !== onItemClick || $[39] !== registerElement ? (t12 = {
1566
- version: 0,
1567
- activeElement,
1568
- activeIndex,
1569
- mount,
1570
- onClickOutside,
1571
- onEscape,
1572
- onItemClick,
1573
- onItemMouseEnter: handleItemMouseEnter,
1574
- onItemMouseLeave: handleItemMouseLeave,
1575
- registerElement,
1576
- onMouseEnter: handleItemMouseEnter,
1577
- onMouseLeave: handleItemMouseLeave
1578
- }, $[31] = activeElement, $[32] = activeIndex, $[33] = handleItemMouseEnter, $[34] = handleItemMouseLeave, $[35] = mount, $[36] = onClickOutside, $[37] = onEscape, $[38] = onItemClick, $[39] = registerElement, $[40] = t12) : t12 = $[40], t11 = t12;
1579
- const value = t11;
1580
- let t13;
1581
- $[41] !== className ? (t13 = menu({
1582
- className
1583
- }), $[41] = className, $[42] = t13) : t13 = $[42];
1584
- let t14;
1585
- $[43] !== children || $[44] !== gap ? (t14 = /* @__PURE__ */ jsx(Stack, { gap, children }), $[43] = children, $[44] = gap, $[45] = t14) : t14 = $[45];
1586
- let t15;
1587
- $[46] !== as || $[47] !== handleKeyDown || $[48] !== handleRefChange || $[49] !== padding || $[50] !== rest || $[51] !== t13 || $[52] !== t14 ? (t15 = /* @__PURE__ */ jsx(Box, { "data-ui": "Menu", ...rest, as, className: t13, onKeyDown: handleKeyDown, overflow: "auto", outline: "none", padding, ref: handleRefChange, role: "menu", tabIndex: -1, children: t14 }), $[46] = as, $[47] = handleKeyDown, $[48] = handleRefChange, $[49] = padding, $[50] = rest, $[51] = t13, $[52] = t14, $[53] = t15) : t15 = $[53];
1588
- let t16;
1589
- return $[54] !== t15 || $[55] !== value ? (t16 = /* @__PURE__ */ jsx(MenuContext.Provider, { value, children: t15 }), $[54] = t15, $[55] = value, $[56] = t16) : t16 = $[56], t16;
1590
- }
1591
- const DEFAULT_MENU_DIVIDER_ELEMENT = "hr";
1592
- function MenuDivider(props) {
1593
- const $ = c(10), t0 = props;
1594
- let className, rest, t1;
1595
- $[0] !== t0 ? ({
1596
- as: t1,
1597
- className,
1598
- ...rest
1599
- } = t0, $[0] = t0, $[1] = className, $[2] = rest, $[3] = t1) : (className = $[1], rest = $[2], t1 = $[3]);
1600
- const Element = t1 === void 0 ? DEFAULT_MENU_DIVIDER_ELEMENT : t1;
1601
- let t2;
1602
- $[4] !== className ? (t2 = menuDivider({
1603
- className
1604
- }), $[4] = className, $[5] = t2) : t2 = $[5];
1605
- let t3;
1606
- return $[6] !== Element || $[7] !== rest || $[8] !== t2 ? (t3 = /* @__PURE__ */ jsx(Element, { ...rest, className: t2 }), $[6] = Element, $[7] = rest, $[8] = t2, $[9] = t3) : t3 = $[9], t3;
1607
- }
1608
- function useMenu() {
1609
- const value = useContext(MenuContext);
1610
- if (!value)
1611
- throw new Error("useMenu(): missing context value");
1612
- if (!isRecord(value) || value.version !== 0)
1613
- throw new Error("useMenu(): the context value is not compatible");
1614
- return value;
1615
- }
1616
- const DEFAULT_MENU_GROUP_ELEMENT = "button";
1617
- function MenuGroup(props) {
1618
- const $ = c(77), t0 = props;
1619
- let IconComponent, children, menuProps, onClick, popover2, rest, t1, t2, t3, t4, t5, t6, text2;
1620
- $[0] !== t0 ? ({
1621
- as: t1,
1622
- children,
1623
- fontSize: t2,
1624
- gap: t3,
1625
- icon: IconComponent,
1626
- menu: menuProps,
1627
- onClick,
1628
- padding: t4,
1629
- popover: popover2,
1630
- radius: t5,
1631
- text: text2,
1632
- tone: t6,
1633
- ...rest
1634
- } = t0, $[0] = t0, $[1] = IconComponent, $[2] = children, $[3] = menuProps, $[4] = onClick, $[5] = popover2, $[6] = rest, $[7] = t1, $[8] = t2, $[9] = t3, $[10] = t4, $[11] = t5, $[12] = t6, $[13] = text2) : (IconComponent = $[1], children = $[2], menuProps = $[3], onClick = $[4], popover2 = $[5], rest = $[6], t1 = $[7], t2 = $[8], t3 = $[9], t4 = $[10], t5 = $[11], t6 = $[12], text2 = $[13]);
1635
- const as = t1 === void 0 ? DEFAULT_MENU_GROUP_ELEMENT : t1, fontSize = t2 === void 0 ? 1 : t2, gap = t3 === void 0 ? 3 : t3, padding = t4 === void 0 ? 3 : t4, radius = t5 === void 0 ? 2 : t5, tone = t6 === void 0 ? "default" : t6, {
1636
- activeElement,
1637
- mount,
1638
- onClickOutside,
1639
- onEscape,
1640
- onItemClick,
1641
- onItemMouseEnter,
1642
- registerElement
1643
- } = useMenu(), [rootElement, setRootElement] = useState(null), [open, setOpen] = useState(!1), [shouldFocus, setShouldFocus] = useState(null), active = !!activeElement && activeElement === rootElement, [withinMenu, setWithinMenu] = useState(!1);
1644
- let t7;
1645
- $[14] !== onItemMouseEnter ? (t7 = (event) => {
1646
- setWithinMenu(!1), onItemMouseEnter?.(event), setOpen(!0);
1647
- }, $[14] = onItemMouseEnter, $[15] = t7) : t7 = $[15];
1648
- const handleMouseEnter = t7;
1649
- let t8;
1650
- $[16] !== rootElement ? (t8 = (event_0) => {
1651
- event_0.key === "ArrowLeft" && (event_0.stopPropagation(), setOpen(!1), requestAnimationFrame(() => {
1652
- rootElement?.focus();
1653
- }));
1654
- }, $[16] = rootElement, $[17] = t8) : t8 = $[17];
1655
- const handleMenuKeyDown = t8;
1656
- let t9;
1657
- $[18] !== onClick ? (t9 = (event_1) => {
1658
- onClick?.(event_1), setShouldFocus("first"), setOpen(!0);
1659
- }, $[18] = onClick, $[19] = t9) : t9 = $[19];
1660
- const handleClick = t9;
1661
- let t10;
1662
- $[20] !== onItemClick ? (t10 = () => {
1663
- setOpen(!1), onItemClick?.();
1664
- }, $[20] = onItemClick, $[21] = t10) : t10 = $[21];
1665
- const handleChildItemClick = t10;
1666
- let t11;
1667
- $[22] === Symbol.for("react.memo_cache_sentinel") ? (t11 = () => setWithinMenu(!0), $[22] = t11) : t11 = $[22];
1668
- const handleMenuMouseEnter = t11;
1669
- let t12, t13;
1670
- $[23] !== mount || $[24] !== rootElement ? (t12 = () => mount(rootElement), t13 = [mount, rootElement], $[23] = mount, $[24] = rootElement, $[25] = t12, $[26] = t13) : (t12 = $[25], t13 = $[26]), useEffect(t12, t13);
1671
- let t14, t15;
1672
- $[27] !== active ? (t14 = () => {
1673
- active || setOpen(!1);
1674
- }, t15 = [active], $[27] = active, $[28] = t14, $[29] = t15) : (t14 = $[28], t15 = $[29]), useEffect(t14, t15);
1675
- let t16, t17;
1676
- $[30] !== open ? (t16 = () => {
1677
- open || setWithinMenu(!1);
1678
- }, t17 = [open], $[30] = open, $[31] = t16, $[32] = t17) : (t16 = $[31], t17 = $[32]), useEffect(t16, t17);
1679
- let t18, t19;
1680
- $[33] !== shouldFocus ? (t18 = () => {
1681
- if (!shouldFocus)
1682
- return;
1683
- const rafId = requestAnimationFrame(() => setShouldFocus(null));
1684
- return () => cancelAnimationFrame(rafId);
1685
- }, t19 = [shouldFocus], $[33] = shouldFocus, $[34] = t18, $[35] = t19) : (t18 = $[34], t19 = $[35]), useEffect(t18, t19);
1686
- let t20;
1687
- $[36] !== children || $[37] !== handleChildItemClick || $[38] !== handleMenuKeyDown || $[39] !== menuProps || $[40] !== onClickOutside || $[41] !== onEscape || $[42] !== registerElement || $[43] !== shouldFocus ? (t20 = /* @__PURE__ */ jsx(Menu, { ...menuProps, onClickOutside, onEscape, onItemClick: handleChildItemClick, onKeyDown: handleMenuKeyDown, onMouseEnter: handleMenuMouseEnter, registerElement, shouldFocus, children }), $[36] = children, $[37] = handleChildItemClick, $[38] = handleMenuKeyDown, $[39] = menuProps, $[40] = onClickOutside, $[41] = onEscape, $[42] = registerElement, $[43] = shouldFocus, $[44] = t20) : t20 = $[44];
1688
- const childMenu = t20;
1689
- let t21;
1690
- $[45] === Symbol.for("react.memo_cache_sentinel") ? (t21 = (event_2) => {
1691
- const target = event_2.currentTarget;
1692
- if (document.activeElement === target && event_2.key === "ArrowRight") {
1693
- setShouldFocus("first"), setOpen(!0), setWithinMenu(!0);
1694
- return;
1695
- }
1696
- }, $[45] = t21) : t21 = $[45];
1697
- const handleKeyDown = t21, t22 = as === "button" ? withinMenu : void 0, t23 = as === "button" ? "button" : void 0;
1698
- let t24;
1699
- $[46] !== IconComponent || $[47] !== fontSize ? (t24 = IconComponent && /* @__PURE__ */ jsxs(Text, { size: fontSize, children: [
1700
- isValidElement(IconComponent) && IconComponent,
1701
- isValidElementType(IconComponent) && /* @__PURE__ */ jsx(IconComponent, {})
1702
- ] }), $[46] = IconComponent, $[47] = fontSize, $[48] = t24) : t24 = $[48];
1703
- let t25;
1704
- $[49] !== fontSize || $[50] !== text2 ? (t25 = /* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsx(Text, { size: fontSize, textOverflow: "ellipsis", weight: "medium", children: text2 }) }), $[49] = fontSize, $[50] = text2, $[51] = t25) : t25 = $[51];
1705
- let t26;
1706
- $[52] === Symbol.for("react.memo_cache_sentinel") ? (t26 = /* @__PURE__ */ jsx(ChevronRightIcon, {}), $[52] = t26) : t26 = $[52];
1707
- let t27;
1708
- $[53] !== fontSize ? (t27 = /* @__PURE__ */ jsx(Text, { size: fontSize, children: t26 }), $[53] = fontSize, $[54] = t27) : t27 = $[54];
1709
- let t28;
1710
- $[55] !== gap || $[56] !== padding || $[57] !== t24 || $[58] !== t25 || $[59] !== t27 ? (t28 = /* @__PURE__ */ jsxs(Flex, { gap, padding, children: [
1711
- t24,
1712
- t25,
1713
- t27
1714
- ] }), $[55] = gap, $[56] = padding, $[57] = t24, $[58] = t25, $[59] = t27, $[60] = t28) : t28 = $[60];
1715
- let t29;
1716
- $[61] !== as || $[62] !== handleClick || $[63] !== handleMouseEnter || $[64] !== radius || $[65] !== rest || $[66] !== t22 || $[67] !== t23 || $[68] !== t28 || $[69] !== tone || $[70] !== withinMenu ? (t29 = /* @__PURE__ */ jsx(Selectable, { "data-ui": "MenuGroup", ...rest, "aria-pressed": t22, as, onClick: handleClick, onKeyDown: handleKeyDown, onMouseEnter: handleMouseEnter, radius, ref: setRootElement, selected: withinMenu, tabIndex: -1, tone, type: t23, children: t28 }), $[61] = as, $[62] = handleClick, $[63] = handleMouseEnter, $[64] = radius, $[65] = rest, $[66] = t22, $[67] = t23, $[68] = t28, $[69] = tone, $[70] = withinMenu, $[71] = t29) : t29 = $[71];
1717
- let t30;
1718
- return $[72] !== childMenu || $[73] !== open || $[74] !== popover2 || $[75] !== t29 ? (t30 = /* @__PURE__ */ jsx(Popover, { ...popover2, content: childMenu, "data-ui": "MenuGroup__popover", open, children: t29 }), $[72] = childMenu, $[73] = open, $[74] = popover2, $[75] = t29, $[76] = t30) : t30 = $[76], t30;
1719
- }
1720
- const DEFAULT_MENU_ITEM_ELEMENT = "button";
1721
- function MenuItem(props) {
1722
- const $ = c(73), t0 = props;
1723
- let IconComponent, IconRightComponent, children, disabled, forwardedRef, gapX, gapY, hotkeys, onClick, paddingBottom, paddingLeft, paddingRight, paddingTop, paddingX, paddingY, pressed, rest, selectedProp, t1, t2, t3, t4, t5, t6, text2;
1724
- $[0] !== t0 ? ({
1725
- as: t1,
1726
- children,
1727
- disabled,
1728
- fontSize: t2,
1729
- gap: t3,
1730
- gapX,
1731
- gapY,
1732
- hotkeys,
1733
- icon: IconComponent,
1734
- iconRight: IconRightComponent,
1735
- onClick,
1736
- padding: t4,
1737
- paddingX,
1738
- paddingY,
1739
- paddingTop,
1740
- paddingRight,
1741
- paddingBottom,
1742
- paddingLeft,
1743
- pressed,
1744
- radius: t5,
1745
- ref: forwardedRef,
1746
- selected: selectedProp,
1747
- text: text2,
1748
- tone: t6,
1749
- ...rest
1750
- } = t0, $[0] = t0, $[1] = IconComponent, $[2] = IconRightComponent, $[3] = children, $[4] = disabled, $[5] = forwardedRef, $[6] = gapX, $[7] = gapY, $[8] = hotkeys, $[9] = onClick, $[10] = paddingBottom, $[11] = paddingLeft, $[12] = paddingRight, $[13] = paddingTop, $[14] = paddingX, $[15] = paddingY, $[16] = pressed, $[17] = rest, $[18] = selectedProp, $[19] = t1, $[20] = t2, $[21] = t3, $[22] = t4, $[23] = t5, $[24] = t6, $[25] = text2) : (IconComponent = $[1], IconRightComponent = $[2], children = $[3], disabled = $[4], forwardedRef = $[5], gapX = $[6], gapY = $[7], hotkeys = $[8], onClick = $[9], paddingBottom = $[10], paddingLeft = $[11], paddingRight = $[12], paddingTop = $[13], paddingX = $[14], paddingY = $[15], pressed = $[16], rest = $[17], selectedProp = $[18], t1 = $[19], t2 = $[20], t3 = $[21], t4 = $[22], t5 = $[23], t6 = $[24], text2 = $[25]);
1751
- const as = t1 === void 0 ? DEFAULT_MENU_ITEM_ELEMENT : t1, fontSize = t2 === void 0 ? 1 : t2, gap = t3 === void 0 ? 3 : t3, padding = t4 === void 0 ? 3 : t4, radius = t5 === void 0 ? 2 : t5, tone = t6 === void 0 ? "default" : t6, menu2 = useMenu(), {
1752
- activeElement,
1753
- mount,
1754
- onItemClick,
1755
- onItemMouseEnter,
1756
- onItemMouseLeave
1757
- } = menu2, [rootElement, setRootElement] = useState(null), active = !!activeElement && activeElement === rootElement, ref = useRef(null);
1758
- let t7;
1759
- $[26] === Symbol.for("react.memo_cache_sentinel") ? (t7 = () => ref.current, $[26] = t7) : t7 = $[26], useImperativeHandle(forwardedRef, t7);
1760
- let t8, t9;
1761
- $[27] !== mount || $[28] !== rootElement || $[29] !== selectedProp ? (t8 = () => mount(rootElement, selectedProp), t9 = [mount, rootElement, selectedProp], $[27] = mount, $[28] = rootElement, $[29] = selectedProp, $[30] = t8, $[31] = t9) : (t8 = $[30], t9 = $[31]), useEffect(t8, t9);
1762
- let t10;
1763
- $[32] !== disabled || $[33] !== onClick || $[34] !== onItemClick ? (t10 = (event) => {
1764
- disabled || (onClick && onClick(event), onItemClick && onItemClick());
1765
- }, $[32] = disabled, $[33] = onClick, $[34] = onItemClick, $[35] = t10) : t10 = $[35];
1766
- const handleClick = t10;
1767
- let t11, t12;
1768
- $[36] !== padding || $[37] !== paddingBottom || $[38] !== paddingLeft || $[39] !== paddingRight || $[40] !== paddingTop || $[41] !== paddingX || $[42] !== paddingY ? (t12 = {
1769
- padding,
1770
- paddingX,
1771
- paddingY,
1772
- paddingTop,
1773
- paddingRight,
1774
- paddingBottom,
1775
- paddingLeft
1776
- }, $[36] = padding, $[37] = paddingBottom, $[38] = paddingLeft, $[39] = paddingRight, $[40] = paddingTop, $[41] = paddingX, $[42] = paddingY, $[43] = t12) : t12 = $[43], t11 = t12;
1777
- const paddingProps = t11;
1778
- let t13;
1779
- $[44] === Symbol.for("react.memo_cache_sentinel") ? (t13 = (el) => {
1780
- ref.current = el, setRootElement(el);
1781
- }, $[44] = t13) : t13 = $[44];
1782
- const setRef = t13, t14 = pressed ? "" : void 0, t15 = active ? "" : void 0, t16 = disabled ? "" : void 0, t17 = as === "button" ? "button" : void 0;
1783
- let t18;
1784
- $[45] !== IconComponent || $[46] !== IconRightComponent || $[47] !== fontSize || $[48] !== gap || $[49] !== gapX || $[50] !== gapY || $[51] !== hotkeys || $[52] !== paddingProps || $[53] !== text2 ? (t18 = (IconComponent || text2 || IconRightComponent) && /* @__PURE__ */ jsxs(Flex, { as: "span", gap, gapX, gapY, align: "center", ...paddingProps, children: [
1785
- IconComponent && /* @__PURE__ */ jsxs(Text, { muted: !0, size: fontSize, children: [
1786
- isValidElement(IconComponent) && IconComponent,
1787
- isValidElementType(IconComponent) && /* @__PURE__ */ jsx(IconComponent, {})
1788
- ] }),
1789
- text2 && /* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsx(Text, { size: fontSize, textOverflow: "ellipsis", weight: "medium", children: text2 }) }),
1790
- hotkeys && /* @__PURE__ */ jsx(Hotkeys, { keys: hotkeys, style: {
1791
- marginTop: -4,
1792
- marginBottom: -4
1793
- } }),
1794
- IconRightComponent && /* @__PURE__ */ jsxs(Text, { muted: !0, size: fontSize, children: [
1795
- isValidElement(IconRightComponent) && IconRightComponent,
1796
- isValidElementType(IconRightComponent) && /* @__PURE__ */ jsx(IconRightComponent, {})
1797
- ] })
1798
- ] }), $[45] = IconComponent, $[46] = IconRightComponent, $[47] = fontSize, $[48] = gap, $[49] = gapX, $[50] = gapY, $[51] = hotkeys, $[52] = paddingProps, $[53] = text2, $[54] = t18) : t18 = $[54];
1799
- let t19;
1800
- $[55] !== children || $[56] !== paddingProps ? (t19 = children && /* @__PURE__ */ jsx(Box, { as: "span", ...paddingProps, children }), $[55] = children, $[56] = paddingProps, $[57] = t19) : t19 = $[57];
1801
- let t20;
1802
- return $[58] !== as || $[59] !== disabled || $[60] !== handleClick || $[61] !== onItemMouseEnter || $[62] !== onItemMouseLeave || $[63] !== radius || $[64] !== rest || $[65] !== t14 || $[66] !== t15 || $[67] !== t16 || $[68] !== t17 || $[69] !== t18 || $[70] !== t19 || $[71] !== tone ? (t20 = /* @__PURE__ */ jsxs(Selectable, { "data-ui": "MenuItem", ...rest, as, "data-pressed": t14, "data-selected": t15, "data-disabled": t16, radius, disabled, onClick: handleClick, onMouseEnter: onItemMouseEnter, onMouseLeave: onItemMouseLeave, ref: setRef, role: "menuitem", tabIndex: -1, tone, type: t17, children: [
1803
- t18,
1804
- t19
1805
- ] }), $[58] = as, $[59] = disabled, $[60] = handleClick, $[61] = onItemMouseEnter, $[62] = onItemMouseLeave, $[63] = radius, $[64] = rest, $[65] = t14, $[66] = t15, $[67] = t16, $[68] = t17, $[69] = t18, $[70] = t19, $[71] = tone, $[72] = t20) : t20 = $[72], t20;
1806
- }
1807
- const DEFAULT_TAB_ELEMENT = "button";
1808
- function Tab(props) {
1809
- const $ = c(33), t0 = props;
1810
- let focused, forwardedRef, icon, id, label, onClick, onFocus, rest, selected, t1, t2, t3;
1811
- $[0] !== t0 ? ({
1812
- as: t1,
1813
- icon,
1814
- id,
1815
- focused,
1816
- fontSize: t2,
1817
- label,
1818
- onClick,
1819
- onFocus,
1820
- padding: t3,
1821
- ref: forwardedRef,
1822
- selected,
1823
- ...rest
1824
- } = t0, $[0] = t0, $[1] = focused, $[2] = forwardedRef, $[3] = icon, $[4] = id, $[5] = label, $[6] = onClick, $[7] = onFocus, $[8] = rest, $[9] = selected, $[10] = t1, $[11] = t2, $[12] = t3) : (focused = $[1], forwardedRef = $[2], icon = $[3], id = $[4], label = $[5], onClick = $[6], onFocus = $[7], rest = $[8], selected = $[9], t1 = $[10], t2 = $[11], t3 = $[12]);
1825
- const as = t1 === void 0 ? DEFAULT_TAB_ELEMENT : t1, fontSize = t2 === void 0 ? 1 : t2, padding = t3 === void 0 ? 2 : t3, ref = useRef(null), focusedRef = useRef(!1);
1826
- let t4;
1827
- $[13] === Symbol.for("react.memo_cache_sentinel") ? (t4 = () => ref.current, $[13] = t4) : t4 = $[13], useImperativeHandle(forwardedRef, t4);
1828
- let t5;
1829
- $[14] === Symbol.for("react.memo_cache_sentinel") ? (t5 = () => {
1830
- focusedRef.current = !1;
1831
- }, $[14] = t5) : t5 = $[14];
1832
- const handleBlur = t5;
1833
- let t6;
1834
- $[15] !== onFocus ? (t6 = (event) => {
1835
- focusedRef.current = !0, onFocus && onFocus(event);
1836
- }, $[15] = onFocus, $[16] = t6) : t6 = $[16];
1837
- const handleFocus = t6;
1838
- let t7, t8;
1839
- $[17] !== focused ? (t7 = () => {
1840
- focused && !focusedRef.current && (ref.current && ref.current.focus(), focusedRef.current = !0);
1841
- }, t8 = [focused], $[17] = focused, $[18] = t7, $[19] = t8) : (t7 = $[18], t8 = $[19]), useEffect(t7, t8);
1842
- const t9 = selected ? "true" : "false", t10 = selected ? 0 : -1;
1843
- let t11;
1844
- return $[20] !== as || $[21] !== fontSize || $[22] !== handleFocus || $[23] !== icon || $[24] !== id || $[25] !== label || $[26] !== onClick || $[27] !== padding || $[28] !== rest || $[29] !== selected || $[30] !== t10 || $[31] !== t9 ? (t11 = /* @__PURE__ */ jsx(Button, { "data-ui": "Tab", ...rest, "aria-selected": t9, as, fontSize, icon, id, mode: "bleed", onClick, onBlur: handleBlur, onFocus: handleFocus, padding, ref, role: "tab", selected, tabIndex: t10, text: label, type: "button" }), $[20] = as, $[21] = fontSize, $[22] = handleFocus, $[23] = icon, $[24] = id, $[25] = label, $[26] = onClick, $[27] = padding, $[28] = rest, $[29] = selected, $[30] = t10, $[31] = t9, $[32] = t11) : t11 = $[32], t11;
1845
- }
1846
- const DEFAULT_TAB_LIST_ELEMENT = "div";
1847
- function TabList(props) {
1848
- const $ = c(20), t0 = props;
1849
- let childrenProp, rest, t1, t2, t3;
1850
- $[0] !== t0 ? ({
1851
- as: t1,
1852
- children: childrenProp,
1853
- gap: t2,
1854
- wrap: t3,
1855
- ...rest
1856
- } = t0, $[0] = t0, $[1] = childrenProp, $[2] = rest, $[3] = t1, $[4] = t2, $[5] = t3) : (childrenProp = $[1], rest = $[2], t1 = $[3], t2 = $[4], t3 = $[5]);
1857
- const as = t1 === void 0 ? DEFAULT_TAB_LIST_ELEMENT : t1, gap = t2 === void 0 ? 1 : t2, wrap = t3 === void 0 ? "nowrap" : t3, [focusedIndex, setFocusedIndex] = useState(-1);
1858
- let t4;
1859
- if ($[6] !== childrenProp || $[7] !== focusedIndex) {
1860
- const children = Children.toArray(childrenProp).filter(_isReactElement);
1861
- let t52;
1862
- $[9] !== focusedIndex ? (t52 = (child, childIndex) => cloneElement(child, {
1863
- focused: focusedIndex === childIndex,
1864
- key: childIndex,
1865
- onFocus: () => setFocusedIndex(childIndex)
1866
- }), $[9] = focusedIndex, $[10] = t52) : t52 = $[10], t4 = children.map(t52), $[6] = childrenProp, $[7] = focusedIndex, $[8] = t4;
1867
- } else
1868
- t4 = $[8];
1869
- const tabs = t4, numTabs = tabs.length;
1870
- let t5;
1871
- $[11] !== numTabs ? (t5 = (event) => {
1872
- event.key === "ArrowLeft" && setFocusedIndex((prevIndex) => (prevIndex + numTabs - 1) % numTabs), event.key === "ArrowRight" && setFocusedIndex((prevIndex_0) => (prevIndex_0 + 1) % numTabs);
1873
- }, $[11] = numTabs, $[12] = t5) : t5 = $[12];
1874
- const handleKeyDown = t5;
1875
- let t6;
1876
- return $[13] !== as || $[14] !== gap || $[15] !== handleKeyDown || $[16] !== rest || $[17] !== tabs || $[18] !== wrap ? (t6 = /* @__PURE__ */ jsx(Flex, { "data-ui": "TabList", ...rest, as, gap, onKeyDown: handleKeyDown, role: "tablist", wrap, children: tabs }), $[13] = as, $[14] = gap, $[15] = handleKeyDown, $[16] = rest, $[17] = tabs, $[18] = wrap, $[19] = t6) : t6 = $[19], t6;
1877
- }
1878
- function _isReactElement(node) {
1879
- return !!node;
1880
- }
1881
- const DEFAULT_GRID_ELEMENT = "div";
1882
- function Grid(props) {
1883
- const $ = c(8), t0 = props;
1884
- let children, rest, t1;
1885
- $[0] !== t0 ? ({
1886
- as: t1,
1887
- children,
1888
- ...rest
1889
- } = t0, $[0] = t0, $[1] = children, $[2] = rest, $[3] = t1) : (children = $[1], rest = $[2], t1 = $[3]);
1890
- const as = t1 === void 0 ? DEFAULT_GRID_ELEMENT : t1;
1891
- let t2;
1892
- return $[4] !== as || $[5] !== children || $[6] !== rest ? (t2 = /* @__PURE__ */ jsx(Box, { "data-ui": "Grid", ...rest, as, display: "grid", children }), $[4] = as, $[5] = children, $[6] = rest, $[7] = t2) : t2 = $[7], t2;
1893
- }
1894
- function usePrefersDark(t0) {
1895
- return useMatchMedia("(prefers-color-scheme: dark)", t0 === void 0 ? _temp$1 : t0);
1896
- }
1897
- function _temp$1() {
1898
- return !1;
1899
- }
1900
- function useDelayedState(initialState) {
1901
- const $ = c(3), [state, setState] = useState(initialState), delayedAction = useRef(void 0);
1902
- let t0;
1903
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = (nextState, delay) => {
1904
- const action = () => {
1905
- setState(nextState);
1906
- };
1907
- if (delayedAction.current && (clearTimeout(delayedAction.current), delayedAction.current = void 0), !delay)
1908
- return action();
1909
- delayedAction.current = setTimeout(action, delay);
1910
- }, $[0] = t0) : t0 = $[0];
1911
- const onStateChange = t0;
1912
- let t1;
1913
- return $[1] !== state ? (t1 = [state, onStateChange], $[1] = state, $[2] = t1) : t1 = $[2], t1;
1914
- }
1915
- const DEFAULT_TOOLTIP_ARROW_WIDTH = 15, DEFAULT_TOOLTIP_ARROW_HEIGHT = 6, DEFAULT_TOOLTIP_ARROW_RADIUS = 2, DEFAULT_TOOLTIP_DISTANCE = 4, DEFAULT_TOOLTIP_PADDING = 4, DEFAULT_FALLBACK_PLACEMENTS = {
1916
- top: ["top-end", "top-start", "bottom", "left", "right"],
1917
- "top-start": ["top", "top-end", "bottom-start", "left-start", "right-start"],
1918
- "top-end": ["top", "top-start", "bottom-end", "left-end", "right-end"],
1919
- bottom: ["bottom-end", "bottom-start", "top", "left", "right"],
1920
- "bottom-start": ["bottom", "bottom-end", "top-start", "left-start", "right-start"],
1921
- "bottom-end": ["bottom", "bottom-start", "top-end", "left-end", "right-end"],
1922
- left: ["left-end", "left-start", "right", "top", "bottom"],
1923
- "left-start": ["left", "left-end", "right-start", "top-start", "bottom-start"],
1924
- "left-end": ["left", "left-start", "right-end", "top-end", "bottom-end"],
1925
- right: ["right-end", "right-start", "left", "top", "bottom"],
1926
- "right-start": ["right", "right-end", "left-start", "top-start", "bottom-start"],
1927
- "right-end": ["right", "right-start", "left-end", "top-end", "bottom-end"]
1928
- }, TooltipDelayGroupContext = createGlobalScopedContext("@sanity/ui/v3/tooltipDelayGroup", null);
1929
- function useTooltipDelayGroup() {
1930
- return useContext(TooltipDelayGroupContext);
1931
- }
1932
- function TooltipLayer(props) {
1933
- const $ = c(50);
1934
- let animate, arrow2, arrowRef, arrowX, arrowY, children, originX, originY, padding, placement, radius, rest, scheme, shadow, style, t0;
1935
- $[0] !== props ? ({
1936
- animate,
1937
- arrow: arrow2,
1938
- arrowRef,
1939
- arrowX,
1940
- arrowY,
1941
- children,
1942
- originX,
1943
- originY,
1944
- padding,
1945
- placement,
1946
- radius,
1947
- scheme,
1948
- shadow,
1949
- style,
1950
- tone: t0,
1951
- ...rest
1952
- } = props, $[0] = props, $[1] = animate, $[2] = arrow2, $[3] = arrowRef, $[4] = arrowX, $[5] = arrowY, $[6] = children, $[7] = originX, $[8] = originY, $[9] = padding, $[10] = placement, $[11] = radius, $[12] = rest, $[13] = scheme, $[14] = shadow, $[15] = style, $[16] = t0) : (animate = $[1], arrow2 = $[2], arrowRef = $[3], arrowX = $[4], arrowY = $[5], children = $[6], originX = $[7], originY = $[8], padding = $[9], placement = $[10], radius = $[11], rest = $[12], scheme = $[13], shadow = $[14], style = $[15], t0 = $[16]);
1953
- const tone = t0 === void 0 ? "inherit" : t0;
1954
- let t1;
1955
- const t2 = animate ? "transform" : void 0;
1956
- let t3;
1957
- $[17] !== originX || $[18] !== originY || $[19] !== style || $[20] !== t2 ? (t3 = {
1958
- originX,
1959
- originY,
1960
- willChange: t2,
1961
- ...style
1962
- }, $[17] = originX, $[18] = originY, $[19] = style, $[20] = t2, $[21] = t3) : t3 = $[21], t1 = t3;
1963
- const rootStyle = t1;
1964
- let t4;
1965
- const t5 = arrowX !== null ? arrowX : void 0, t6 = arrowY !== null ? arrowY : void 0;
1966
- let t7;
1967
- $[22] !== t5 || $[23] !== t6 ? (t7 = {
1968
- left: t5,
1969
- top: t6,
1970
- right: void 0,
1971
- bottom: void 0
1972
- }, $[22] = t5, $[23] = t6, $[24] = t7) : t7 = $[24], t4 = t7;
1973
- const arrowStyle = t4, t8 = animate ? "" : void 0;
1974
- let t9;
1975
- $[25] !== animate ? (t9 = animate ? ["hidden", "initial"] : void 0, $[25] = animate, $[26] = t9) : t9 = $[26];
1976
- let t10;
1977
- $[27] !== animate ? (t10 = animate ? ["visible", "scaleIn"] : void 0, $[27] = animate, $[28] = t10) : t10 = $[28];
1978
- let t11;
1979
- $[29] !== animate ? (t11 = animate ? ["hidden", "scaleOut"] : void 0, $[29] = animate, $[30] = t11) : t11 = $[30];
1980
- let t12;
1981
- $[31] !== arrow2 || $[32] !== arrowRef || $[33] !== arrowStyle ? (t12 = arrow2 && /* @__PURE__ */ jsx(Arrow, { ref: arrowRef, style: arrowStyle, width: DEFAULT_TOOLTIP_ARROW_WIDTH, height: DEFAULT_TOOLTIP_ARROW_HEIGHT, radius: DEFAULT_TOOLTIP_ARROW_RADIUS }), $[31] = arrow2, $[32] = arrowRef, $[33] = arrowStyle, $[34] = t12) : t12 = $[34];
1982
- let t13;
1983
- return $[35] !== children || $[36] !== padding || $[37] !== placement || $[38] !== radius || $[39] !== rest || $[40] !== rootStyle || $[41] !== scheme || $[42] !== shadow || $[43] !== t10 || $[44] !== t11 || $[45] !== t12 || $[46] !== t8 || $[47] !== t9 || $[48] !== tone ? (t13 = /* @__PURE__ */ jsxs(Layer, { "data-ui": "Tooltip__layer", ...rest, as: motion.div, "data-animate": t8, "data-placement": placement, padding, radius, scheme, shadow, style: rootStyle, variants: POPOVER_MOTION_PROPS.card, transition: POPOVER_MOTION_PROPS.transition, initial: t9, animate: t10, exit: t11, tone, children: [
1984
- children,
1985
- t12
1986
- ] }), $[35] = children, $[36] = padding, $[37] = placement, $[38] = radius, $[39] = rest, $[40] = rootStyle, $[41] = scheme, $[42] = shadow, $[43] = t10, $[44] = t11, $[45] = t12, $[46] = t8, $[47] = t9, $[48] = tone, $[49] = t13) : t13 = $[49], t13;
1987
- }
1988
- const DEFAULT_TOOLTIP_ELEMENT = "div";
1989
- function Tooltip(props) {
1990
- const boundaryElementContext = useBoundaryElement(), {
1991
- animate: _animate = !1,
1992
- arrow: arrowProp = !1,
1993
- as = DEFAULT_TOOLTIP_ELEMENT,
1994
- boundaryElement = boundaryElementContext?.element,
1995
- children: childProp,
1996
- className,
1997
- content,
1998
- delay,
1999
- disabled,
2000
- fallbackPlacements = props.fallbackPlacements ?? DEFAULT_FALLBACK_PLACEMENTS[props.placement ?? "bottom"],
2001
- padding = 2,
2002
- placement: placementProp = "bottom",
2003
- portal: portalProp,
2004
- radius = 3,
2005
- ref: forwardedRef,
2006
- scheme,
2007
- shadow = 2,
2008
- zOffset = Z_OFFSETS.tooltip,
2009
- tone = "inherit",
2010
- ...rest
2011
- } = props, card2 = useCard(), animate = usePrefersReducedMotion() ? !1 : _animate, ref = useRef(null), [referenceElement, setReferenceElement] = useState(null), arrowRef = useRef(null), rootBoundary = "viewport", [tooltipMaxWidth, setTooltipMaxWidth] = useState(0);
2012
- useImperativeHandle(forwardedRef, () => ref.current);
2013
- const portal = usePortal(), portalElement = typeof portalProp == "string" ? portal.elements?.[portalProp] || null : portal.element, middleware = useMemo(() => {
2014
- const ret = [];
2015
- return ret.push(flip({
2016
- boundary: boundaryElement || void 0,
2017
- fallbackPlacements,
2018
- padding: DEFAULT_TOOLTIP_PADDING,
2019
- rootBoundary
2020
- })), ret.push(offset({
2021
- mainAxis: DEFAULT_TOOLTIP_DISTANCE
2022
- })), ret.push(shift({
2023
- boundary: boundaryElement || void 0,
2024
- rootBoundary,
2025
- padding: DEFAULT_TOOLTIP_PADDING
2026
- })), arrowProp && ret.push(arrow({
2027
- element: arrowRef,
2028
- padding: DEFAULT_TOOLTIP_PADDING
2029
- })), animate && ret.push(origin), ret;
2030
- }, [animate, arrowProp, boundaryElement, fallbackPlacements]), {
2031
- floatingStyles,
2032
- placement,
2033
- middlewareData,
2034
- refs,
2035
- update
2036
- } = useFloating({
2037
- middleware,
2038
- placement: placementProp,
2039
- whileElementsMounted: autoUpdate,
2040
- elements: {
2041
- reference: referenceElement
2042
- },
2043
- transform: !1
2044
- }), arrowX = middlewareData.arrow?.x, arrowY = middlewareData.arrow?.y, originX = middlewareData["@sanity/ui/origin"]?.originX, originY = middlewareData["@sanity/ui/origin"]?.originY, tooltipId = useId(), [isOpen, setIsOpen] = useDelayedState(!1), delayGroupContext = useTooltipDelayGroup(), {
2045
- setIsGroupActive,
2046
- setOpenTooltipId
2047
- } = delayGroupContext || {}, showTooltip = isOpen || delayGroupContext?.openTooltipId === tooltipId, isInsideGroup = delayGroupContext !== null, openDelayProp = typeof delay == "number" ? delay : delay?.open || 0, closeDelayProp = typeof delay == "number" ? delay : delay?.close || 0, openDelay = isInsideGroup ? delayGroupContext.openDelay : openDelayProp, closeDelay = isInsideGroup ? delayGroupContext.closeDelay : closeDelayProp, handleIsOpenChange = useCallback((open, immediate) => {
2048
- if (isInsideGroup)
2049
- if (open) {
2050
- const groupedOpenDelay = immediate ? 0 : openDelay;
2051
- setIsGroupActive?.(open, groupedOpenDelay), setOpenTooltipId?.(tooltipId, groupedOpenDelay);
2052
- } else {
2053
- const groupDeactivateDelay = closeDelay > 200 ? closeDelay : 200;
2054
- setIsGroupActive?.(open, groupDeactivateDelay), setOpenTooltipId?.(null, immediate ? 0 : closeDelay);
2055
- }
2056
- else
2057
- setIsOpen(open, immediate ? 0 : open ? openDelay : closeDelay);
2058
- }, [isInsideGroup, openDelay, setIsGroupActive, setOpenTooltipId, tooltipId, closeDelay, setIsOpen]), handleBlur = useCallback((e) => {
2059
- handleIsOpenChange(!1), childProp?.props?.onBlur?.(e);
2060
- }, [childProp?.props, handleIsOpenChange]), handleClick = useCallback((e_0) => {
2061
- handleIsOpenChange(!1, !0), childProp?.props.onClick?.(e_0);
2062
- }, [childProp?.props, handleIsOpenChange]), handleContextMenu = useCallback((e_1) => {
2063
- handleIsOpenChange(!1, !0), childProp?.props.onContextMenu?.(e_1);
2064
- }, [childProp?.props, handleIsOpenChange]), handleFocus = useCallback((e_2) => {
2065
- handleIsOpenChange(!0), childProp?.props?.onFocus?.(e_2);
2066
- }, [childProp?.props, handleIsOpenChange]), handleMouseEnter = useCallback((e_3) => {
2067
- handleIsOpenChange(!0), childProp?.props?.onMouseEnter?.(e_3);
2068
- }, [childProp?.props, handleIsOpenChange]), handleMouseLeave = useCallback((e_4) => {
2069
- handleIsOpenChange(!1), childProp?.props?.onMouseLeave?.(e_4);
2070
- }, [childProp?.props, handleIsOpenChange]);
2071
- useCloseOnMouseLeave({
2072
- handleIsOpenChange,
2073
- referenceElement,
2074
- showTooltip,
2075
- isInsideGroup
2076
- }), useEffect(() => {
2077
- disabled && showTooltip && handleIsOpenChange(!1);
2078
- }, [disabled, handleIsOpenChange, showTooltip]), useEffect(() => {
2079
- !content && showTooltip && handleIsOpenChange(!1);
2080
- }, [content, handleIsOpenChange, showTooltip]), useEffect(() => {
2081
- if (!showTooltip) return;
2082
- function handleWindowKeyDown(event) {
2083
- event.key === "Escape" && handleIsOpenChange(!1, !0);
2084
- }
2085
- return window.addEventListener("keydown", handleWindowKeyDown), () => {
2086
- window.removeEventListener("keydown", handleWindowKeyDown);
2087
- };
2088
- }, [handleIsOpenChange, showTooltip]), useLayoutEffect(() => {
2089
- const availableWidths = [...boundaryElement ? [boundaryElement.offsetWidth] : [], portalElement?.offsetWidth || document.body.offsetWidth];
2090
- setTooltipMaxWidth(Math.min(...availableWidths) - DEFAULT_TOOLTIP_PADDING * 2);
2091
- }, [boundaryElement, portalElement]);
2092
- const setArrow = useCallback((arrowEl) => {
2093
- arrowRef.current = arrowEl, update();
2094
- }, [update]), setFloating = useCallback((node) => {
2095
- ref.current = node, refs.setFloating(node);
2096
- }, [refs]), child = useMemo(() => childProp ? cloneElement(childProp, {
2097
- onBlur: handleBlur,
2098
- onFocus: handleFocus,
2099
- onMouseEnter: handleMouseEnter,
2100
- onMouseLeave: handleMouseLeave,
2101
- onClick: handleClick,
2102
- onContextMenu: handleContextMenu,
2103
- ref: setReferenceElement
2104
- }) : null, [childProp, handleBlur, handleClick, handleContextMenu, handleFocus, handleMouseEnter, handleMouseLeave]);
2105
- if (useImperativeHandle(childProp ? getElementRef(childProp) : null, () => referenceElement, [referenceElement]), !child) return /* @__PURE__ */ jsx(Fragment, {});
2106
- if (disabled) return child;
2107
- const node_0 = /* @__PURE__ */ jsx(TooltipLayer, { "data-ui": "Tooltip", ...rest, animate, arrow: arrowProp, arrowRef: setArrow, arrowX, arrowY, as, className: tooltip({
2108
- className
2109
- }), originX, originY, padding, placement, radius, ref: setFloating, scheme, shadow, style: {
2110
- ...floatingStyles,
2111
- maxWidth: tooltipMaxWidth > 0 ? `${tooltipMaxWidth}px` : void 0
2112
- }, tone, zOffset, children: content }), children = showTooltip && (portalProp ? /* @__PURE__ */ jsx(Portal, { __unstable_name: typeof portalProp == "string" ? portalProp : void 0, children: /* @__PURE__ */ jsx(CardProvider, { tone: tone === "inherit" ? card2.tone : tone, scheme: scheme ?? "light", children: node_0 }) }) : node_0);
2113
- return /* @__PURE__ */ jsxs(Fragment, { children: [
2114
- animate ? /* @__PURE__ */ jsx(AnimatePresence, { children }) : children,
2115
- child
2116
- ] });
2117
- }
2118
- function useCloseOnMouseLeave(t0) {
2119
- const $ = c(10), {
2120
- handleIsOpenChange,
2121
- referenceElement,
2122
- showTooltip,
2123
- isInsideGroup
2124
- } = t0;
2125
- let t1;
2126
- $[0] !== handleIsOpenChange || $[1] !== referenceElement ? (t1 = (target, teardown) => {
2127
- referenceElement && (referenceElement === target || target instanceof Node && referenceElement.contains(target) || (handleIsOpenChange(!1), teardown()));
2128
- }, $[0] = handleIsOpenChange, $[1] = referenceElement, $[2] = t1) : t1 = $[2];
2129
- const onMouseMove = useEffectEvent(t1);
2130
- let t2;
2131
- $[3] !== isInsideGroup || $[4] !== onMouseMove || $[5] !== showTooltip ? (t2 = () => {
2132
- if (!showTooltip || isInsideGroup)
2133
- return;
2134
- const handleMouseMove = (event) => {
2135
- onMouseMove(event.target, () => window.removeEventListener("mousemove", handleMouseMove));
2136
- };
2137
- return window.addEventListener("mousemove", handleMouseMove), () => window.removeEventListener("mousemove", handleMouseMove);
2138
- }, $[3] = isInsideGroup, $[4] = onMouseMove, $[5] = showTooltip, $[6] = t2) : t2 = $[6];
2139
- let t3;
2140
- $[7] !== isInsideGroup || $[8] !== showTooltip ? (t3 = [isInsideGroup, showTooltip], $[7] = isInsideGroup, $[8] = showTooltip, $[9] = t3) : t3 = $[9], useEffect(t2, t3);
2141
- }
2142
- function PortalProvider(props) {
2143
- const $ = c(9), {
2144
- children,
2145
- element,
2146
- __unstable_elements: elementsProp
2147
- } = props, elements = useUnique(elementsProp), parentPortal = useContext(PortalContext);
2148
- let t0;
2149
- $[0] !== elements || $[1] !== parentPortal ? (t0 = () => elements?.default ?? (parentPortal.element || document.body), $[0] = elements, $[1] = parentPortal, $[2] = t0) : t0 = $[2];
2150
- const fallbackElement = useSyncExternalStore(emptySubscribe, t0, _temp);
2151
- let t1;
2152
- const t2 = element || fallbackElement;
2153
- let t3;
2154
- $[3] !== elements || $[4] !== t2 ? (t3 = {
2155
- version: 0,
2156
- boundaryElement: null,
2157
- element: t2,
2158
- elements
2159
- }, $[3] = elements, $[4] = t2, $[5] = t3) : t3 = $[5], t1 = t3;
2160
- const value = t1;
2161
- let t4;
2162
- return $[6] !== children || $[7] !== value ? (t4 = /* @__PURE__ */ jsx(PortalContext.Provider, { value, children }), $[6] = children, $[7] = value, $[8] = t4) : t4 = $[8], t4;
2163
- }
2164
- function _temp() {
2165
- return null;
2166
- }
2167
- const emptySubscribe = () => () => {
2168
- };
2169
- function useUnique(value) {
2170
- const valueRef = useRef(value);
2171
- return _isEqual(valueRef.current, value) || (valueRef.current = value), valueRef.current;
2172
- }
2173
- function _isEqual(objA, objB) {
2174
- if (!objA || !objB)
2175
- return objA === objB;
2176
- const keysA = Object.keys(objA), keysB = Object.keys(objB);
2177
- return keysA.length !== keysB.length ? !1 : keysA.every((key2) => objA[key2] === objB[key2]);
2178
- }
2179
- export {
2180
- AnimatedSpinnerIcon,
2181
- Arrow,
2182
- BoundaryElementContext,
2183
- Box,
2184
- Button,
2185
- Card,
2186
- CardProvider,
2187
- DEFAULT_ARROW_ELEMENT,
2188
- DEFAULT_BOX_ELEMENT,
2189
- DEFAULT_BUTTON_ELEMENT,
2190
- DEFAULT_CARD_ELEMENT,
2191
- DEFAULT_FLEX_ELEMENT,
2192
- DEFAULT_GRID_ELEMENT,
2193
- DEFAULT_HOTKEYS_ELEMENT,
2194
- DEFAULT_KBD_ELEMENT,
2195
- DEFAULT_LAYER_ELEMENT,
2196
- DEFAULT_MENU_DIVIDER_ELEMENT,
2197
- DEFAULT_MENU_ELEMENT,
2198
- DEFAULT_MENU_GROUP_ELEMENT,
2199
- DEFAULT_MENU_ITEM_ELEMENT,
2200
- DEFAULT_POPOVER_ELEMENT,
2201
- DEFAULT_SELECTABLE_ELEMENT,
2202
- DEFAULT_SPINNER_ELEMENT,
2203
- DEFAULT_STACK_ELEMENT,
2204
- DEFAULT_TAB_ELEMENT,
2205
- DEFAULT_TAB_LIST_ELEMENT,
2206
- DEFAULT_TEXT_ELEMENT,
2207
- DEFAULT_TEXT_INPUT_ELEMENT,
2208
- DEFAULT_TOOLTIP_ELEMENT,
2209
- EMPTY_ARRAY,
2210
- EMPTY_RECORD,
2211
- Flex,
2212
- Grid,
2213
- Hotkeys,
2214
- KBD,
2215
- Layer,
2216
- LayerProvider,
2217
- Menu,
2218
- MenuDivider,
2219
- MenuGroup,
2220
- MenuItem,
2221
- Popover,
2222
- Portal,
2223
- PortalProvider,
2224
- Selectable,
2225
- Spinner,
2226
- Stack,
2227
- Tab,
2228
- TabList,
2229
- Text,
2230
- TextInput,
2231
- Tooltip,
2232
- TooltipDelayGroupContext,
2233
- Z_OFFSETS,
2234
- _getArrayProp,
2235
- _getResponsiveProp,
2236
- _isEnterToClickElement,
2237
- containsOrEqualsElement,
2238
- createGlobalScopedContext,
2239
- isHTMLAnchorElement,
2240
- isHTMLButtonElement,
2241
- isHTMLElement,
2242
- isHTMLInputElement,
2243
- isHTMLSelectElement,
2244
- isHTMLTextAreaElement,
2245
- isRecord,
2246
- useBoundaryElement,
2247
- useCard,
2248
- useClickOutsideEvent,
2249
- useCustomValidity,
2250
- useDelayedState,
2251
- useGlobalKeyDown,
2252
- useLayer,
2253
- useMatchMedia,
2254
- useMediaIndex,
2255
- usePortal,
2256
- usePrefersDark,
2257
- usePrefersReducedMotion,
2258
- useResponsiveProp,
2259
- useTooltipDelayGroup
2260
- };
2261
- //# sourceMappingURL=_visual-editing.js.map