@sanity/ui 3.0.0-static.42 → 3.0.0-static.44

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