@sanity/ui 4.0.0-next.0 → 4.0.0-next.2

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,3300 +0,0 @@
1
- import { a as createColorTheme$1, c as multiply$1, d as hexToRgb$1, f as hslToRgb$1, i as getTheme_v2, l as rgba$1, m as rgbToHsl$1, o as buildTheme, p as rgbToHex$1, s as screen$1, t as getScopedTheme, u as parseColor$1 } from "./getScopedTheme.js";
2
- import { c } from "react-compiler-runtime";
3
- import { Children, cloneElement, createContext, forwardRef, isValidElement, useContext, useDebugValue, useEffect, useId, useImperativeHandle, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
4
- import { ThemeProvider, css, keyframes, styled, useTheme } from "styled-components";
5
- import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
6
- import { isValidElementType } from "react-is";
7
- import { SpinnerIcon } from "@sanity/icons/Spinner";
8
- import { arrow, autoPlacement, autoUpdate, detectOverflow, flip, hide, offset, shift, useFloating } from "@floating-ui/react-dom";
9
- import { AnimatePresence, motion } from "motion/react";
10
- import { ResizeObserver } from "@juggle/resize-observer";
11
- import { createPortal } from "react-dom";
12
- import { CloseIcon } from "@sanity/icons/Close";
13
- import { useEffectEvent } from "use-effect-event";
14
- import { ChevronRightIcon } from "@sanity/icons/ChevronRight";
15
- /**
16
- * @public
17
- * @deprecated Use `createColorTheme` from `@sanity/ui/theme` instead.
18
- */
19
- const createColorTheme = createColorTheme$1, hexToRgb = hexToRgb$1, hslToRgb = hslToRgb$1, multiply = multiply$1, parseColor = parseColor$1, rgbToHex = rgbToHex$1, rgbToHsl = rgbToHsl$1, rgba = rgba$1, screen = screen$1, studioTheme = buildTheme(), EMPTY_ARRAY = [], EMPTY_RECORD = {}, POPOVER_MOTION_DURATION = .2, POPOVER_MOTION_PROPS = {
20
- card: {
21
- initial: {
22
- scale: .97,
23
- willChange: "transform"
24
- },
25
- hidden: { opacity: 0 },
26
- visible: {
27
- opacity: 1,
28
- transition: {
29
- when: "beforeChildren",
30
- duration: POPOVER_MOTION_DURATION / 2
31
- }
32
- },
33
- scaleIn: { scale: 1 },
34
- scaleOut: { scale: .97 }
35
- },
36
- children: {
37
- hidden: { opacity: 0 },
38
- visible: { opacity: 1 }
39
- },
40
- transition: {
41
- type: "spring",
42
- visualDuration: POPOVER_MOTION_DURATION,
43
- bounce: .25
44
- }
45
- };
46
- /**
47
- * @internal
48
- */
49
- function _isEnterToClickElement(element) {
50
- return isHTMLAnchorElement(element) || isHTMLButtonElement(element);
51
- }
52
- /**
53
- * @internal
54
- */
55
- function isHTMLElement(node) {
56
- return node instanceof Node && node.nodeType === Node.ELEMENT_NODE;
57
- }
58
- /**
59
- * @internal
60
- */
61
- function isHTMLAnchorElement(element) {
62
- return isHTMLElement(element) && element.nodeName === "A";
63
- }
64
- /**
65
- * @internal
66
- */
67
- function isHTMLInputElement(element) {
68
- return isHTMLElement(element) && element.nodeName === "INPUT";
69
- }
70
- /**
71
- * @internal
72
- */
73
- function isHTMLButtonElement(element) {
74
- return isHTMLElement(element) && element.nodeName === "BUTTON";
75
- }
76
- /**
77
- * @internal
78
- */
79
- function isHTMLSelectElement(element) {
80
- return isHTMLElement(element) && element.nodeName === "SELECT";
81
- }
82
- /**
83
- * @internal
84
- */
85
- function isHTMLTextAreaElement(element) {
86
- return isHTMLElement(element) && element.nodeName === "TEXTAREA";
87
- }
88
- /**
89
- * @internal
90
- */
91
- function containsOrEqualsElement(element, node) {
92
- return element.contains(node) || element === node;
93
- }
94
- /**
95
- * @internal
96
- */
97
- function _fillCSSObject(keys, value) {
98
- return keys.reduce((style, key) => (style[key] = value, style), {});
99
- }
100
- /**
101
- * @public
102
- */
103
- function rem(pixelValue) {
104
- return pixelValue === 0 ? 0 : `${pixelValue / 16}rem`;
105
- }
106
- /**
107
- * @internal
108
- */
109
- function _responsive(media, values, callback) {
110
- return (values?.map(callback) || []).map((statement, mediaIndex) => mediaIndex === 0 ? statement : { [`@media screen and (min-width: ${media[mediaIndex - 1]}px)`]: statement });
111
- }
112
- /**
113
- * @internal
114
- */
115
- function _getArrayProp(val, defaultVal) {
116
- return val === void 0 ? defaultVal || EMPTY_ARRAY : Array.isArray(val) ? val : [val];
117
- }
118
- /**
119
- * @internal
120
- */
121
- function _getResponsiveSpace(theme, props, spaceIndexes = EMPTY_ARRAY) {
122
- if (!Array.isArray(spaceIndexes)) throw Error("the property must be array of numbers");
123
- if (spaceIndexes.length === 0) return null;
124
- let { media, space } = getTheme_v2(theme);
125
- return _responsive(media, spaceIndexes, (spaceIndex) => _fillCSSObject(props, rem(space[spaceIndex])));
126
- }
127
- const BASE_STYLE$3 = { "&[data-as=\"ul\"],&[data-as=\"ol\"]": { listStyle: "none" } }, BOX_SIZING = {
128
- content: "content-box",
129
- border: "border-box"
130
- }, BOX_HEIGHT = {
131
- stretch: "stretch",
132
- fill: "100%"
133
- };
134
- function boxStyle() {
135
- return BASE_STYLE$3;
136
- }
137
- function responsiveBoxStyle() {
138
- return [
139
- responsiveBoxSizingStyle,
140
- responsiveBoxHeightStyle,
141
- responsiveBoxOverflowStyle,
142
- responsiveBoxDisplayStyle
143
- ];
144
- }
145
- function responsiveBoxDisplayStyle(props) {
146
- let { media } = getTheme_v2(props.theme);
147
- return _responsive(media, props.$display, (display) => ({ "&:not([hidden])": { display } }));
148
- }
149
- function responsiveBoxSizingStyle(props) {
150
- let { media } = getTheme_v2(props.theme);
151
- return _responsive(media, props.$sizing, (sizing) => ({ boxSizing: BOX_SIZING[sizing] }));
152
- }
153
- function responsiveBoxHeightStyle(props) {
154
- let { media } = getTheme_v2(props.theme);
155
- return _responsive(media, props.$height, (height) => ({ height: BOX_HEIGHT[height] }));
156
- }
157
- function responsiveBoxOverflowStyle(props) {
158
- let { media } = getTheme_v2(props.theme);
159
- return _responsive(media, props.$overflow, (overflow) => ({ overflow }));
160
- }
161
- const BASE_STYLE$2 = {
162
- minWidth: 0,
163
- minHeight: 0
164
- };
165
- function flexItemStyle() {
166
- return [BASE_STYLE$2, responsiveFlexItemStyle];
167
- }
168
- function responsiveFlexItemStyle(props) {
169
- let { media } = getTheme_v2(props.theme);
170
- return props.$flex ? _responsive(media, props.$flex, (flex) => ({ flex: `${flex}` })) : EMPTY_ARRAY;
171
- }
172
- function responsiveGridItemStyle() {
173
- return [
174
- responsiveGridItemRowStyle,
175
- responsiveGridItemRowStartStyle,
176
- responsiveGridItemRowEndStyle,
177
- responsiveGridItemColumnStyle,
178
- responsiveGridItemColumnStartStyle,
179
- responsiveGridItemColumnEndStyle
180
- ];
181
- }
182
- const GRID_ITEM_ROW = {
183
- auto: "auto",
184
- full: "1 / -1"
185
- }, GRID_ITEM_COLUMN = {
186
- auto: "auto",
187
- full: "1 / -1"
188
- };
189
- function responsiveGridItemRowStyle(props) {
190
- let { media } = getTheme_v2(props.theme);
191
- return _responsive(media, props.$row, (row) => typeof row == "number" ? { gridRow: `span ${row} / span ${row}` } : { gridRow: GRID_ITEM_ROW[row] });
192
- }
193
- function responsiveGridItemRowStartStyle(props) {
194
- let { media } = getTheme_v2(props.theme);
195
- return _responsive(media, props.$rowStart, (rowStart) => ({ gridRowStart: `${rowStart}` }));
196
- }
197
- function responsiveGridItemRowEndStyle(props) {
198
- let { media } = getTheme_v2(props.theme);
199
- return _responsive(media, props.$rowEnd, (rowEnd) => ({ gridRowEnd: `${rowEnd}` }));
200
- }
201
- function responsiveGridItemColumnStyle(props) {
202
- let { media } = getTheme_v2(props.theme);
203
- return _responsive(media, props.$column, (column) => typeof column == "number" ? { gridColumn: `span ${column} / span ${column}` } : { gridColumn: GRID_ITEM_COLUMN[column] });
204
- }
205
- function responsiveGridItemColumnStartStyle(props) {
206
- let { media } = getTheme_v2(props.theme);
207
- return _responsive(media, props.$columnStart, (columnStart) => ({ gridColumnStart: `${columnStart}` }));
208
- }
209
- function responsiveGridItemColumnEndStyle(props) {
210
- let { media } = getTheme_v2(props.theme);
211
- return _responsive(media, props.$columnEnd, (columnEnd) => ({ gridColumnEnd: `${columnEnd}` }));
212
- }
213
- function responsiveMarginStyle(props) {
214
- let { theme } = props;
215
- return [
216
- _getResponsiveSpace(theme, ["margin"], props.$margin),
217
- _getResponsiveSpace(theme, ["marginLeft", "marginRight"], props.$marginX),
218
- _getResponsiveSpace(theme, ["marginTop", "marginBottom"], props.$marginY),
219
- _getResponsiveSpace(theme, ["marginTop"], props.$marginTop),
220
- _getResponsiveSpace(theme, ["marginRight"], props.$marginRight),
221
- _getResponsiveSpace(theme, ["marginBottom"], props.$marginBottom),
222
- _getResponsiveSpace(theme, ["marginLeft"], props.$marginLeft)
223
- ].filter(Boolean);
224
- }
225
- function responsivePaddingStyle(props) {
226
- let { theme } = props;
227
- return [
228
- _getResponsiveSpace(theme, ["padding"], props.$padding),
229
- _getResponsiveSpace(theme, ["paddingLeft", "paddingRight"], props.$paddingX),
230
- _getResponsiveSpace(theme, ["paddingTop", "paddingBottom"], props.$paddingY),
231
- _getResponsiveSpace(theme, ["paddingTop"], props.$paddingTop),
232
- _getResponsiveSpace(theme, ["paddingRight"], props.$paddingRight),
233
- _getResponsiveSpace(theme, ["paddingBottom"], props.$paddingBottom),
234
- _getResponsiveSpace(theme, ["paddingLeft"], props.$paddingLeft)
235
- ].filter(Boolean);
236
- }
237
- const StyledBox = /* @__PURE__ */ styled.div.withConfig({
238
- displayName: "StyledBox",
239
- componentId: "sc-p4sc7t-0"
240
- })(boxStyle, flexItemStyle, responsiveBoxStyle, responsiveGridItemStyle, responsiveMarginStyle, responsivePaddingStyle), Box = forwardRef(function Box(props, ref) {
241
- let $ = c(115), deprecated_column, deprecated_columnEnd, deprecated_columnStart, deprecated_row, deprecated_rowEnd, deprecated_rowStart, flex, gridColumn, gridColumnEnd, gridColumnStart, gridRow, gridRowEnd, gridRowStart, height, marginBottom, marginLeft, marginRight, marginTop, marginX, marginY, overflow, paddingBottom, paddingLeft, paddingRight, paddingTop, paddingX, paddingY, restProps, sizing, t0, t1, t2, t3;
242
- $[0] === props ? (deprecated_column = $[1], deprecated_columnEnd = $[2], deprecated_columnStart = $[3], deprecated_row = $[4], deprecated_rowEnd = $[5], deprecated_rowStart = $[6], flex = $[7], gridColumn = $[8], gridColumnEnd = $[9], gridColumnStart = $[10], gridRow = $[11], gridRowEnd = $[12], gridRowStart = $[13], height = $[14], marginBottom = $[15], marginLeft = $[16], marginRight = $[17], marginTop = $[18], marginX = $[19], marginY = $[20], overflow = $[21], paddingBottom = $[22], paddingLeft = $[23], paddingRight = $[24], paddingTop = $[25], paddingX = $[26], paddingY = $[27], restProps = $[28], sizing = $[29], t0 = $[30], t1 = $[31], t2 = $[32], t3 = $[33]) : ({as: t0, gridColumn, column: deprecated_column, gridColumnStart, columnStart: deprecated_columnStart, gridColumnEnd, columnEnd: deprecated_columnEnd, display: t1, flex, height, margin: t2, marginX, marginY, marginTop, marginRight, marginBottom, marginLeft, overflow, padding: t3, paddingX, paddingY, paddingTop, paddingRight, paddingBottom, paddingLeft, gridRow, row: deprecated_row, gridRowStart, rowStart: deprecated_rowStart, gridRowEnd, rowEnd: deprecated_rowEnd, sizing, ...restProps} = props, $[0] = props, $[1] = deprecated_column, $[2] = deprecated_columnEnd, $[3] = deprecated_columnStart, $[4] = deprecated_row, $[5] = deprecated_rowEnd, $[6] = deprecated_rowStart, $[7] = flex, $[8] = gridColumn, $[9] = gridColumnEnd, $[10] = gridColumnStart, $[11] = gridRow, $[12] = gridRowEnd, $[13] = gridRowStart, $[14] = height, $[15] = marginBottom, $[16] = marginLeft, $[17] = marginRight, $[18] = marginTop, $[19] = marginX, $[20] = marginY, $[21] = overflow, $[22] = paddingBottom, $[23] = paddingLeft, $[24] = paddingRight, $[25] = paddingTop, $[26] = paddingX, $[27] = paddingY, $[28] = restProps, $[29] = sizing, $[30] = t0, $[31] = t1, $[32] = t2, $[33] = t3);
243
- let asProp = t0 === void 0 ? "div" : t0, display = t1 === void 0 ? "block" : t1, margin = t2 === void 0 ? 0 : t2, padding = t3 === void 0 ? 0 : t3, column = gridColumn === void 0 ? deprecated_column : gridColumn, columnStart = gridColumnStart === void 0 ? deprecated_columnStart : gridColumnStart, columnEnd = gridColumnEnd === void 0 ? deprecated_columnEnd : gridColumnEnd, row = gridRow === void 0 ? deprecated_row : gridRow, rowStart = gridRowStart === void 0 ? deprecated_rowStart : gridRowStart, rowEnd = gridRowEnd === void 0 ? deprecated_rowEnd : gridRowEnd, t4 = typeof asProp == "string" ? asProp : void 0, t5;
244
- $[34] === column ? t5 = $[35] : (t5 = _getArrayProp(column), $[34] = column, $[35] = t5);
245
- let t6;
246
- $[36] === columnStart ? t6 = $[37] : (t6 = _getArrayProp(columnStart), $[36] = columnStart, $[37] = t6);
247
- let t7;
248
- $[38] === columnEnd ? t7 = $[39] : (t7 = _getArrayProp(columnEnd), $[38] = columnEnd, $[39] = t7);
249
- let t8;
250
- $[40] === display ? t8 = $[41] : (t8 = _getArrayProp(display), $[40] = display, $[41] = t8);
251
- let t9;
252
- $[42] === flex ? t9 = $[43] : (t9 = _getArrayProp(flex), $[42] = flex, $[43] = t9);
253
- let t10;
254
- $[44] === height ? t10 = $[45] : (t10 = _getArrayProp(height), $[44] = height, $[45] = t10);
255
- let t11;
256
- $[46] === margin ? t11 = $[47] : (t11 = _getArrayProp(margin), $[46] = margin, $[47] = t11);
257
- let t12;
258
- $[48] === marginX ? t12 = $[49] : (t12 = _getArrayProp(marginX), $[48] = marginX, $[49] = t12);
259
- let t13;
260
- $[50] === marginY ? t13 = $[51] : (t13 = _getArrayProp(marginY), $[50] = marginY, $[51] = t13);
261
- let t14;
262
- $[52] === marginTop ? t14 = $[53] : (t14 = _getArrayProp(marginTop), $[52] = marginTop, $[53] = t14);
263
- let t15;
264
- $[54] === marginRight ? t15 = $[55] : (t15 = _getArrayProp(marginRight), $[54] = marginRight, $[55] = t15);
265
- let t16;
266
- $[56] === marginBottom ? t16 = $[57] : (t16 = _getArrayProp(marginBottom), $[56] = marginBottom, $[57] = t16);
267
- let t17;
268
- $[58] === marginLeft ? t17 = $[59] : (t17 = _getArrayProp(marginLeft), $[58] = marginLeft, $[59] = t17);
269
- let t18;
270
- $[60] === overflow ? t18 = $[61] : (t18 = _getArrayProp(overflow), $[60] = overflow, $[61] = t18);
271
- let t19;
272
- $[62] === padding ? t19 = $[63] : (t19 = _getArrayProp(padding), $[62] = padding, $[63] = t19);
273
- let t20;
274
- $[64] === paddingX ? t20 = $[65] : (t20 = _getArrayProp(paddingX), $[64] = paddingX, $[65] = t20);
275
- let t21;
276
- $[66] === paddingY ? t21 = $[67] : (t21 = _getArrayProp(paddingY), $[66] = paddingY, $[67] = t21);
277
- let t22;
278
- $[68] === paddingTop ? t22 = $[69] : (t22 = _getArrayProp(paddingTop), $[68] = paddingTop, $[69] = t22);
279
- let t23;
280
- $[70] === paddingRight ? t23 = $[71] : (t23 = _getArrayProp(paddingRight), $[70] = paddingRight, $[71] = t23);
281
- let t24;
282
- $[72] === paddingBottom ? t24 = $[73] : (t24 = _getArrayProp(paddingBottom), $[72] = paddingBottom, $[73] = t24);
283
- let t25;
284
- $[74] === paddingLeft ? t25 = $[75] : (t25 = _getArrayProp(paddingLeft), $[74] = paddingLeft, $[75] = t25);
285
- let t26;
286
- $[76] === row ? t26 = $[77] : (t26 = _getArrayProp(row), $[76] = row, $[77] = t26);
287
- let t27;
288
- $[78] === rowStart ? t27 = $[79] : (t27 = _getArrayProp(rowStart), $[78] = rowStart, $[79] = t27);
289
- let t28;
290
- $[80] === rowEnd ? t28 = $[81] : (t28 = _getArrayProp(rowEnd), $[80] = rowEnd, $[81] = t28);
291
- let t29;
292
- $[82] === sizing ? t29 = $[83] : (t29 = _getArrayProp(sizing), $[82] = sizing, $[83] = t29);
293
- let t30;
294
- return $[84] !== asProp || $[85] !== props.children || $[86] !== ref || $[87] !== restProps || $[88] !== t10 || $[89] !== t11 || $[90] !== t12 || $[91] !== t13 || $[92] !== t14 || $[93] !== t15 || $[94] !== t16 || $[95] !== t17 || $[96] !== t18 || $[97] !== t19 || $[98] !== t20 || $[99] !== t21 || $[100] !== t22 || $[101] !== t23 || $[102] !== t24 || $[103] !== t25 || $[104] !== t26 || $[105] !== t27 || $[106] !== t28 || $[107] !== t29 || $[108] !== t4 || $[109] !== t5 || $[110] !== t6 || $[111] !== t7 || $[112] !== t8 || $[113] !== t9 ? (t30 = /* @__PURE__ */ jsx(StyledBox, {
295
- "data-as": t4,
296
- "data-ui": "Box",
297
- ...restProps,
298
- $column: t5,
299
- $columnStart: t6,
300
- $columnEnd: t7,
301
- $display: t8,
302
- $flex: t9,
303
- $height: t10,
304
- $margin: t11,
305
- $marginX: t12,
306
- $marginY: t13,
307
- $marginTop: t14,
308
- $marginRight: t15,
309
- $marginBottom: t16,
310
- $marginLeft: t17,
311
- $overflow: t18,
312
- $padding: t19,
313
- $paddingX: t20,
314
- $paddingY: t21,
315
- $paddingTop: t22,
316
- $paddingRight: t23,
317
- $paddingBottom: t24,
318
- $paddingLeft: t25,
319
- $row: t26,
320
- $rowStart: t27,
321
- $rowEnd: t28,
322
- $sizing: t29,
323
- as: asProp,
324
- ref,
325
- children: props.children
326
- }), $[84] = asProp, $[85] = props.children, $[86] = ref, $[87] = restProps, $[88] = t10, $[89] = t11, $[90] = t12, $[91] = t13, $[92] = t14, $[93] = t15, $[94] = t16, $[95] = t17, $[96] = t18, $[97] = t19, $[98] = t20, $[99] = t21, $[100] = t22, $[101] = t23, $[102] = t24, $[103] = t25, $[104] = t26, $[105] = t27, $[106] = t28, $[107] = t29, $[108] = t4, $[109] = t5, $[110] = t6, $[111] = t7, $[112] = t8, $[113] = t9, $[114] = t30) : t30 = $[114], t30;
327
- });
328
- function responsiveRadiusStyle(props) {
329
- let { media, radius } = getTheme_v2(props.theme);
330
- return _responsive(media, props.$radius, (value) => {
331
- let borderRadius = 0;
332
- return typeof value == "number" && (borderRadius = rem(radius[value])), value === "full" && (borderRadius = "9999px"), { borderRadius };
333
- });
334
- }
335
- /**
336
- * @public
337
- */
338
- function useTheme$1() {
339
- return useTheme();
340
- }
341
- /**
342
- * @public
343
- */
344
- function useTheme_v2() {
345
- let $ = c(2), t0 = useTheme(), t1;
346
- return $[0] === t0 ? t1 = $[1] : (t1 = getTheme_v2(t0), $[0] = t0, $[1] = t1), t1;
347
- }
348
- const BASE_STYLE$1 = { "&&:not([hidden])": { display: "flex" } };
349
- function responsiveFlexStyle() {
350
- return [
351
- BASE_STYLE$1,
352
- responsiveFlexAlignStyle,
353
- responsiveFlexGapStyle,
354
- responsiveFlexWrapStyle,
355
- responsiveFlexJustifyStyle,
356
- responsiveFlexDirectionStyle
357
- ];
358
- }
359
- function responsiveFlexAlignStyle(props) {
360
- let { media } = getTheme_v2(props.theme);
361
- return _responsive(media, props.$align, (align) => ({ alignItems: align }));
362
- }
363
- function responsiveFlexGapStyle(props) {
364
- let { media, space } = getTheme_v2(props.theme);
365
- return _responsive(media, props.$gap, (gap) => ({ gap: gap ? rem(space[gap]) : void 0 }));
366
- }
367
- function responsiveFlexWrapStyle(props) {
368
- let { media } = getTheme_v2(props.theme);
369
- return _responsive(media, props.$wrap, (wrap) => ({ flexWrap: wrap }));
370
- }
371
- function responsiveFlexJustifyStyle(props) {
372
- let { media } = getTheme_v2(props.theme);
373
- return _responsive(media, props.$justify, (justify) => ({ justifyContent: justify }));
374
- }
375
- function responsiveFlexDirectionStyle(props) {
376
- let { media } = getTheme_v2(props.theme);
377
- return _responsive(media, props.$direction, (direction) => ({ flexDirection: direction }));
378
- }
379
- const StyledFlex = /* @__PURE__ */ styled(Box).withConfig({
380
- displayName: "StyledFlex",
381
- componentId: "sc-5lzqa2-0"
382
- })(flexItemStyle, responsiveFlexStyle), Flex = forwardRef(function Flex(props, ref) {
383
- let $ = c(27), align, as, gap, justify, restProps, t0, wrap;
384
- $[0] === props ? (align = $[1], as = $[2], gap = $[3], justify = $[4], restProps = $[5], t0 = $[6], wrap = $[7]) : ({align, as, direction: t0, gap, justify, wrap, ...restProps} = props, $[0] = props, $[1] = align, $[2] = as, $[3] = gap, $[4] = justify, $[5] = restProps, $[6] = t0, $[7] = wrap);
385
- let direction = t0 === void 0 ? "row" : t0, t1;
386
- $[8] === align ? t1 = $[9] : (t1 = _getArrayProp(align), $[8] = align, $[9] = t1);
387
- let t2;
388
- $[10] === direction ? t2 = $[11] : (t2 = _getArrayProp(direction), $[10] = direction, $[11] = t2);
389
- let t3;
390
- $[12] === gap ? t3 = $[13] : (t3 = _getArrayProp(gap), $[12] = gap, $[13] = t3);
391
- let t4;
392
- $[14] === justify ? t4 = $[15] : (t4 = _getArrayProp(justify), $[14] = justify, $[15] = t4);
393
- let t5;
394
- $[16] === wrap ? t5 = $[17] : (t5 = _getArrayProp(wrap), $[16] = wrap, $[17] = t5);
395
- let t6;
396
- return $[18] !== as || $[19] !== ref || $[20] !== restProps || $[21] !== t1 || $[22] !== t2 || $[23] !== t3 || $[24] !== t4 || $[25] !== t5 ? (t6 = /* @__PURE__ */ jsx(StyledFlex, {
397
- "data-ui": "Flex",
398
- ...restProps,
399
- $align: t1,
400
- $direction: t2,
401
- $gap: t3,
402
- $justify: t4,
403
- $wrap: t5,
404
- forwardedAs: as,
405
- ref
406
- }), $[18] = as, $[19] = ref, $[20] = restProps, $[21] = t1, $[22] = t2, $[23] = t3, $[24] = t4, $[25] = t5, $[26] = t6) : t6 = $[26], t6;
407
- });
408
- /**
409
- * Get responsive text align styles.
410
- * @internal
411
- */
412
- function responsiveTextAlignStyle(props) {
413
- let { media } = getTheme_v2(props.theme);
414
- return _responsive(media, props.$align, (textAlign) => ({ textAlign }));
415
- }
416
- /**
417
- * A utility function getting responsive font styles.
418
- * @internal
419
- */
420
- function responsiveFont(fontKey, props) {
421
- let { $size, $weight } = props, { font, media } = getTheme_v2(props.theme), { family, sizes, weights } = font[fontKey], fontWeight = $weight && weights[$weight] || weights.regular, defaultSize = sizes[2], base = {
422
- position: "relative",
423
- fontFamily: family,
424
- fontWeight: `${fontWeight}`,
425
- padding: "1px 0",
426
- margin: 0,
427
- "&:before": {
428
- content: "\"\"",
429
- display: "block",
430
- height: 0
431
- },
432
- "&:after": {
433
- content: "\"\"",
434
- display: "block",
435
- height: 0
436
- },
437
- "& > code, & > span": { display: "block" },
438
- "&:not([hidden])": { display: "block" }
439
- };
440
- return $size ? [base, ..._responsive(media, $size, (sizeIndex) => fontSize(sizes[sizeIndex] || defaultSize))] : (responsiveFont.warned ||= (console.warn("No size specified for responsive font", {
441
- fontKey,
442
- $size,
443
- props,
444
- base
445
- }), !0), [base]);
446
- }
447
- function fontSize(size) {
448
- let { ascenderHeight, descenderHeight, fontSize, iconSize, letterSpacing, lineHeight } = size, negHeight = ascenderHeight + descenderHeight, capHeight = lineHeight - negHeight, iconOffset = (capHeight - iconSize) / 2, customIconSize = Math.floor(fontSize * 1.125 / 2) * 2 + 1, customIconOffset = (capHeight - customIconSize) / 2;
449
- return {
450
- fontSize: rem(fontSize),
451
- lineHeight: `calc(${lineHeight} / ${fontSize})`,
452
- letterSpacing: rem(letterSpacing),
453
- transform: `translateY(${rem(descenderHeight)})`,
454
- "&:before": { marginTop: `calc(${rem(0 - negHeight)} - 1px)` },
455
- "&:after": { marginBottom: "-1px" },
456
- "& svg:not([data-sanity-icon])": {
457
- fontSize: `calc(${customIconSize} / 16 * 1rem)`,
458
- margin: rem(customIconOffset)
459
- },
460
- "& [data-sanity-icon]": {
461
- fontSize: `calc(${iconSize} / 16 * 1rem)`,
462
- margin: rem(iconOffset)
463
- }
464
- };
465
- }
466
- /**
467
- * Get responsive CSS for the `text` font style.
468
- * @internal
469
- */
470
- function responsiveTextFont(props) {
471
- return responsiveFont("text", props);
472
- }
473
- /** @internal */
474
- const SpanWithTextOverflow = styled.span.withConfig({
475
- displayName: "SpanWithTextOverflow",
476
- componentId: "sc-xkyu3h-0"
477
- })`display:block;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;overflow:clip;`;
478
- function textBaseStyle(props) {
479
- let { $accent, $muted } = props, { font } = getTheme_v2(props.theme);
480
- return css`color:var(--card-fg-color);${$accent && css`color:var(--card-accent-fg-color);`} ${$muted && css`color:var(--card-muted-fg-color);`} & code{font-family:${font.code.family};border-radius:1px;background-color:var(--card-code-bg-color);color:var(--card-code-fg-color);}& a{text-decoration:none;border-radius:1px;color:var(--card-link-color);outline:none;@media (hover:hover){&:hover{text-decoration:underline;}}&:focus{box-shadow:0 0 0 1px var(--card-bg-color),0 0 0 3px var(--card-focus-ring-color);}&:focus:not(:focus-visible){box-shadow:none;}}& strong{font-weight:${font.text.weights.bold};}& svg{display:inline;}& [data-sanity-icon]{vertical-align:baseline;color:var(--card-icon-color);& path{vector-effect:non-scaling-stroke !important;}}`;
481
- }
482
- const StyledText = /* @__PURE__ */ styled.div.withConfig({
483
- displayName: "StyledText",
484
- componentId: "sc-m7q2yn-0"
485
- })(responsiveTextFont, responsiveTextAlignStyle, textBaseStyle), Text = forwardRef(function Text(props, ref) {
486
- let $ = c(26), align, childrenProp, restProps, t0, t1, t2, textOverflow, weight;
487
- $[0] === props ? (align = $[1], childrenProp = $[2], restProps = $[3], t0 = $[4], t1 = $[5], t2 = $[6], textOverflow = $[7], weight = $[8]) : ({accent: t0, align, children: childrenProp, muted: t1, size: t2, textOverflow, weight, ...restProps} = props, $[0] = props, $[1] = align, $[2] = childrenProp, $[3] = restProps, $[4] = t0, $[5] = t1, $[6] = t2, $[7] = textOverflow, $[8] = weight);
488
- let accent = t0 !== void 0 && t0, muted = t1 !== void 0 && t1, size = t2 === void 0 ? 2 : t2, children = childrenProp;
489
- if (textOverflow === "ellipsis") {
490
- let t3;
491
- $[9] === children ? t3 = $[10] : (t3 = /* @__PURE__ */ jsx(SpanWithTextOverflow, { children }), $[9] = children, $[10] = t3), children = t3;
492
- }
493
- let t3;
494
- $[11] === align ? t3 = $[12] : (t3 = _getArrayProp(align), $[11] = align, $[12] = t3);
495
- let t4;
496
- $[13] === size ? t4 = $[14] : (t4 = _getArrayProp(size), $[13] = size, $[14] = t4);
497
- let t5;
498
- $[15] === children ? t5 = $[16] : (t5 = /* @__PURE__ */ jsx("span", { children }), $[15] = children, $[16] = t5);
499
- let t6;
500
- return $[17] !== accent || $[18] !== muted || $[19] !== ref || $[20] !== restProps || $[21] !== t3 || $[22] !== t4 || $[23] !== t5 || $[24] !== weight ? (t6 = /* @__PURE__ */ jsx(StyledText, {
501
- "data-ui": "Text",
502
- ...restProps,
503
- $accent: accent,
504
- $align: t3,
505
- $muted: muted,
506
- ref,
507
- $size: t4,
508
- $weight: weight,
509
- children: t5
510
- }), $[17] = accent, $[18] = muted, $[19] = ref, $[20] = restProps, $[21] = t3, $[22] = t4, $[23] = t5, $[24] = weight, $[25] = t6) : t6 = $[25], t6;
511
- }), rotate = keyframes`from{transform:rotate(0deg);}to{transform:rotate(360deg);}`, StyledSpinner = styled(Text).withConfig({
512
- displayName: "StyledSpinner",
513
- componentId: "sc-k51eu1-0"
514
- })`& > span > svg{animation:${rotate} 500ms linear infinite;}`, Spinner = forwardRef(function Spinner(props, ref) {
515
- let $ = c(4), t0;
516
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx(SpinnerIcon, {}), $[0] = t0) : t0 = $[0];
517
- let t1;
518
- return $[1] !== props || $[2] !== ref ? (t1 = /* @__PURE__ */ jsx(StyledSpinner, {
519
- "data-ui": "Spinner",
520
- ...props,
521
- ref,
522
- children: t0
523
- }), $[1] = props, $[2] = ref, $[3] = t1) : t1 = $[3], t1;
524
- });
525
- /**
526
- * @internal
527
- */
528
- function _cardColorStyle(base, color, checkered = !1) {
529
- return {
530
- "--card-backdrop-color": base.backdrop,
531
- "--card-focus-ring-color": base.focusRing,
532
- "--card-shadow-outline-color": base.shadow.outline,
533
- "--card-shadow-umbra-color": base.shadow.umbra,
534
- "--card-shadow-penumbra-color": base.shadow.penumbra,
535
- "--card-shadow-ambient-color": base.shadow.ambient,
536
- "--card-accent-fg-color": color.accent.fg,
537
- "--card-avatar-gray-bg-color": color.avatar.gray.bg,
538
- "--card-avatar-gray-fg-color": color.avatar.gray.fg,
539
- "--card-avatar-blue-bg-color": color.avatar.blue.bg,
540
- "--card-avatar-blue-fg-color": color.avatar.blue.fg,
541
- "--card-avatar-purple-bg-color": color.avatar.purple.bg,
542
- "--card-avatar-purple-fg-color": color.avatar.purple.fg,
543
- "--card-avatar-magenta-bg-color": color.avatar.magenta.bg,
544
- "--card-avatar-magenta-fg-color": color.avatar.magenta.fg,
545
- "--card-avatar-red-bg-color": color.avatar.red.bg,
546
- "--card-avatar-red-fg-color": color.avatar.red.fg,
547
- "--card-avatar-orange-bg-color": color.avatar.orange.bg,
548
- "--card-avatar-orange-fg-color": color.avatar.orange.fg,
549
- "--card-avatar-yellow-bg-color": color.avatar.yellow.bg,
550
- "--card-avatar-yellow-fg-color": color.avatar.yellow.fg,
551
- "--card-avatar-green-bg-color": color.avatar.green.bg,
552
- "--card-avatar-green-fg-color": color.avatar.green.fg,
553
- "--card-avatar-cyan-bg-color": color.avatar.cyan.bg,
554
- "--card-avatar-cyan-fg-color": color.avatar.cyan.fg,
555
- "--card-bg-color": color.bg,
556
- "--card-bg-image": checkered ? `repeating-conic-gradient(${color.bg} 0% 25%, ${color.muted.bg} 0% 50%)` : void 0,
557
- "--card-border-color": color.border,
558
- "--card-badge-default-bg-color": color.badge.default.bg,
559
- "--card-badge-default-dot-color": color.badge.default.dot,
560
- "--card-badge-default-fg-color": color.badge.default.fg,
561
- "--card-badge-default-icon-color": color.badge.default.icon,
562
- "--card-badge-neutral-bg-color": color.badge.neutral?.bg,
563
- "--card-badge-neutral-dot-color": color.badge.neutral?.dot,
564
- "--card-badge-neutral-fg-color": color.badge.neutral?.fg,
565
- "--card-badge-neutral-icon-color": color.badge.neutral?.icon,
566
- "--card-badge-primary-bg-color": color.badge.primary.bg,
567
- "--card-badge-primary-dot-color": color.badge.primary.dot,
568
- "--card-badge-primary-fg-color": color.badge.primary.fg,
569
- "--card-badge-primary-icon-color": color.badge.primary.icon,
570
- "--card-badge-suggest-bg-color": color.badge.suggest?.bg,
571
- "--card-badge-suggest-dot-color": color.badge.suggest?.dot,
572
- "--card-badge-suggest-fg-color": color.badge.suggest?.fg,
573
- "--card-badge-suggest-icon-color": color.badge.suggest?.icon,
574
- "--card-badge-positive-bg-color": color.badge.positive.bg,
575
- "--card-badge-positive-dot-color": color.badge.positive.dot,
576
- "--card-badge-positive-fg-color": color.badge.positive.fg,
577
- "--card-badge-positive-icon-color": color.badge.positive.icon,
578
- "--card-badge-caution-bg-color": color.badge.caution.bg,
579
- "--card-badge-caution-dot-color": color.badge.caution.dot,
580
- "--card-badge-caution-fg-color": color.badge.caution.fg,
581
- "--card-badge-caution-icon-color": color.badge.caution.icon,
582
- "--card-badge-critical-bg-color": color.badge.critical.bg,
583
- "--card-badge-critical-dot-color": color.badge.critical.dot,
584
- "--card-badge-critical-fg-color": color.badge.critical.fg,
585
- "--card-badge-critical-icon-color": color.badge.critical.icon,
586
- "--card-code-bg-color": color.code.bg,
587
- "--card-code-fg-color": color.code.fg,
588
- "--card-fg-color": color.fg,
589
- "--card-icon-color": color.icon,
590
- "--card-kbd-bg-color": color.kbd.bg,
591
- "--card-kbd-border-color": color.kbd.border,
592
- "--card-kbd-fg-color": color.kbd.fg,
593
- "--card-link-fg-color": color.link.fg,
594
- "--card-muted-bg-color": color.muted.bg,
595
- "--card-muted-fg-color": color.muted.fg,
596
- "--card-skeleton-color-from": color.skeleton.from,
597
- "--card-skeleton-color-to": color.skeleton.to,
598
- "--card-bg2-color": color.muted.bg,
599
- "--card-link-color": color.link.fg,
600
- "--card-hairline-soft-color": color.border,
601
- "--card-hairline-hard-color": color.border
602
- };
603
- }
604
- function focusRingBorderStyle(border) {
605
- return `inset 0 0 0 ${border.width}px ${border.color}`;
606
- }
607
- function focusRingStyle(opts) {
608
- let { base, border, focusRing } = opts, focusRingOutsetWidth = focusRing.offset + focusRing.width, focusRingInsetWidth = 0 - focusRing.offset, bgColor = base ? base.bg : "var(--card-bg-color)";
609
- return [
610
- focusRingInsetWidth > 0 && `inset 0 0 0 ${focusRingInsetWidth}px var(--card-focus-ring-color)`,
611
- border && focusRingBorderStyle(border),
612
- focusRingInsetWidth < 0 && `0 0 0 ${0 - focusRingInsetWidth}px ${bgColor}`,
613
- focusRingOutsetWidth > 0 && `0 0 0 ${focusRingOutsetWidth}px var(--card-focus-ring-color)`
614
- ].filter(Boolean).join(",");
615
- }
616
- /**
617
- * @internal
618
- */
619
- function buttonBaseStyles(props) {
620
- let { $width } = props, { style } = getTheme_v2(props.theme);
621
- return css`${style?.button};-webkit-font-smoothing:inherit;appearance:none;display:inline-flex;align-items:center;font:inherit;border:0;outline:none;user-select:none;text-decoration:none;border:0;box-sizing:border-box;padding:0;margin:0;white-space:nowrap;text-align:left;position:relative;vertical-align:top;${$width === "fill" && css`width:-moz-available;width:-webkit-fill-available;width:stretch;`} & > span{display:block;flex:1;min-width:0;border-radius:inherit;}&::-moz-focus-inner{border:0;padding:0;}`;
622
- }
623
- function combineBoxShadow(...boxShadows) {
624
- return boxShadows.filter(Boolean).join(",");
625
- }
626
- /**
627
- * @internal
628
- */
629
- function buttonColorStyles(props) {
630
- let { $mode } = props, { button, color: baseColor, style } = getTheme_v2(props.theme);
631
- props.$mode;
632
- let mode = baseColor.button[$mode] || baseColor.button.default, color = mode[props.$tone] || mode.default, border = {
633
- width: button.border.width,
634
- color: "var(--card-border-color)"
635
- };
636
- return [
637
- _cardColorStyle(baseColor, color.enabled),
638
- {
639
- backgroundColor: "var(--card-bg-color)",
640
- color: "var(--card-fg-color)",
641
- boxShadow: focusRingBorderStyle(border),
642
- "&:disabled, &[data-disabled=\"true\"]": _cardColorStyle(baseColor, color.disabled),
643
- "&:not([data-disabled='true'])": {
644
- boxShadow: combineBoxShadow(focusRingBorderStyle(border), void 0),
645
- "&:focus": { boxShadow: focusRingStyle({
646
- base: baseColor,
647
- border: {
648
- width: 2,
649
- color: baseColor.bg
650
- },
651
- focusRing: button.focusRing
652
- }) },
653
- "&:focus:not(:focus-visible)": { boxShadow: combineBoxShadow(focusRingBorderStyle(border), void 0) },
654
- "@media (hover: hover)": {
655
- "&:hover": _cardColorStyle(baseColor, color.hovered),
656
- "&:active": _cardColorStyle(baseColor, color.pressed),
657
- "&[data-hovered]": _cardColorStyle(baseColor, color.hovered)
658
- },
659
- "&[data-selected]": _cardColorStyle(baseColor, color.pressed)
660
- }
661
- },
662
- style?.button?.root
663
- ].filter(Boolean);
664
- }
665
- const StyledButton = /* @__PURE__ */ styled.button.withConfig({
666
- displayName: "StyledButton",
667
- componentId: "sc-5eghxe-0"
668
- })(responsiveRadiusStyle, buttonBaseStyles, buttonColorStyles), LoadingBox = styled.div.withConfig({
669
- displayName: "LoadingBox",
670
- componentId: "sc-5eghxe-1"
671
- })`position:absolute;top:0;left:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center;background-color:var(--card-bg-color);border-radius:inherit;z-index:1;box-shadow:inherit;`, Button = forwardRef(function Button(props, ref) {
672
- let $ = c(87), IconComponent, IconRightComponent, children, disabled, gap, loading, paddingBottomProp, paddingLeftProp, paddingRightProp, paddingTopProp, paddingXProp, paddingYProp, restProps, selected, t0, t1, t2, t3, t4, t5, t6, t7, t8, text, textAlign, textWeight, width;
673
- $[0] === props ? (IconComponent = $[1], IconRightComponent = $[2], children = $[3], disabled = $[4], gap = $[5], loading = $[6], paddingBottomProp = $[7], paddingLeftProp = $[8], paddingRightProp = $[9], paddingTopProp = $[10], paddingXProp = $[11], paddingYProp = $[12], restProps = $[13], selected = $[14], t0 = $[15], t1 = $[16], t2 = $[17], t3 = $[18], t4 = $[19], t5 = $[20], t6 = $[21], t7 = $[22], t8 = $[23], text = $[24], textAlign = $[25], textWeight = $[26], width = $[27]) : ({children, disabled, fontSize: t0, icon: IconComponent, iconRight: IconRightComponent, justify: t1, loading, mode: t2, padding: t3, paddingX: paddingXProp, paddingY: paddingYProp, paddingTop: paddingTopProp, paddingBottom: paddingBottomProp, paddingLeft: paddingLeftProp, paddingRight: paddingRightProp, radius: t4, selected, gap, space: t5, text, textAlign, textWeight, tone: t6, type: t7, muted: t8, width, ...restProps} = props, $[0] = props, $[1] = IconComponent, $[2] = IconRightComponent, $[3] = children, $[4] = disabled, $[5] = gap, $[6] = loading, $[7] = paddingBottomProp, $[8] = paddingLeftProp, $[9] = paddingRightProp, $[10] = paddingTopProp, $[11] = paddingXProp, $[12] = paddingYProp, $[13] = restProps, $[14] = selected, $[15] = t0, $[16] = t1, $[17] = t2, $[18] = t3, $[19] = t4, $[20] = t5, $[21] = t6, $[22] = t7, $[23] = t8, $[24] = text, $[25] = textAlign, $[26] = textWeight, $[27] = width);
674
- let fontSize = t0 === void 0 ? 1 : t0, justifyProp = t1 === void 0 ? "center" : t1, mode = t2 === void 0 ? "default" : t2, paddingProp = t3 === void 0 ? 3 : t3, radiusProp = t4 === void 0 ? 2 : t4, deprecated_space = t5 === void 0 ? 3 : t5, tone = t6 === void 0 ? "default" : t6, type = t7 === void 0 ? "button" : t7, muted = t8 !== void 0 && t8, { button } = useTheme_v2(), t9;
675
- $[28] === justifyProp ? t9 = $[29] : (t9 = _getArrayProp(justifyProp), $[28] = justifyProp, $[29] = t9);
676
- let justify = t9, t10;
677
- $[30] === paddingProp ? t10 = $[31] : (t10 = _getArrayProp(paddingProp), $[30] = paddingProp, $[31] = t10);
678
- let padding = t10, t11;
679
- $[32] === paddingXProp ? t11 = $[33] : (t11 = _getArrayProp(paddingXProp), $[32] = paddingXProp, $[33] = t11);
680
- let paddingX = t11, t12;
681
- $[34] === paddingYProp ? t12 = $[35] : (t12 = _getArrayProp(paddingYProp), $[34] = paddingYProp, $[35] = t12);
682
- let paddingY = t12, t13;
683
- $[36] === paddingTopProp ? t13 = $[37] : (t13 = _getArrayProp(paddingTopProp), $[36] = paddingTopProp, $[37] = t13);
684
- let paddingTop = t13, t14;
685
- $[38] === paddingBottomProp ? t14 = $[39] : (t14 = _getArrayProp(paddingBottomProp), $[38] = paddingBottomProp, $[39] = t14);
686
- let paddingBottom = t14, t15;
687
- $[40] === paddingLeftProp ? t15 = $[41] : (t15 = _getArrayProp(paddingLeftProp), $[40] = paddingLeftProp, $[41] = t15);
688
- let paddingLeft = t15, t16;
689
- $[42] === paddingRightProp ? t16 = $[43] : (t16 = _getArrayProp(paddingRightProp), $[42] = paddingRightProp, $[43] = t16);
690
- let paddingRight = t16, t17;
691
- $[44] === radiusProp ? t17 = $[45] : (t17 = _getArrayProp(radiusProp), $[44] = radiusProp, $[45] = t17);
692
- let radius = t17, t18 = gap === void 0 ? deprecated_space : gap, t19;
693
- $[46] === t18 ? t19 = $[47] : (t19 = _getArrayProp(t18), $[46] = t18, $[47] = t19);
694
- let spacing = t19, t20;
695
- $[48] !== padding || $[49] !== paddingBottom || $[50] !== paddingLeft || $[51] !== paddingRight || $[52] !== paddingTop || $[53] !== paddingX || $[54] !== paddingY ? (t20 = {
696
- padding,
697
- paddingX,
698
- paddingY,
699
- paddingTop,
700
- paddingBottom,
701
- paddingLeft,
702
- paddingRight
703
- }, $[48] = padding, $[49] = paddingBottom, $[50] = paddingLeft, $[51] = paddingRight, $[52] = paddingTop, $[53] = paddingX, $[54] = paddingY, $[55] = t20) : t20 = $[55];
704
- let boxProps = t20, t21 = !!(loading || disabled), t22 = selected ? "" : void 0, t23 = !!(loading || disabled), t24;
705
- $[56] === loading ? t24 = $[57] : (t24 = !!loading && /* @__PURE__ */ jsx(LoadingBox, { children: /* @__PURE__ */ jsx(Spinner, {}) }), $[56] = loading, $[57] = t24);
706
- let t25;
707
- $[58] !== IconComponent || $[59] !== IconRightComponent || $[60] !== boxProps || $[61] !== button || $[62] !== fontSize || $[63] !== justify || $[64] !== muted || $[65] !== spacing || $[66] !== text || $[67] !== textAlign || $[68] !== textWeight ? (t25 = (IconComponent || text || IconRightComponent) && /* @__PURE__ */ jsx(Box, {
708
- as: "span",
709
- ...boxProps,
710
- children: /* @__PURE__ */ jsxs(Flex, {
711
- as: "span",
712
- justify,
713
- gap: spacing,
714
- children: [
715
- IconComponent && /* @__PURE__ */ jsxs(Text, {
716
- size: fontSize,
717
- children: [isValidElement(IconComponent) && IconComponent, isValidElementType(IconComponent) && /* @__PURE__ */ jsx(IconComponent, {})]
718
- }),
719
- text && /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Text, {
720
- muted,
721
- align: textAlign,
722
- size: fontSize,
723
- textOverflow: "ellipsis",
724
- weight: textWeight ?? button.textWeight,
725
- children: text
726
- }) }),
727
- IconRightComponent && /* @__PURE__ */ jsxs(Text, {
728
- size: fontSize,
729
- children: [isValidElement(IconRightComponent) && IconRightComponent, isValidElementType(IconRightComponent) && /* @__PURE__ */ jsx(IconRightComponent, {})]
730
- })
731
- ]
732
- })
733
- }), $[58] = IconComponent, $[59] = IconRightComponent, $[60] = boxProps, $[61] = button, $[62] = fontSize, $[63] = justify, $[64] = muted, $[65] = spacing, $[66] = text, $[67] = textAlign, $[68] = textWeight, $[69] = t25) : t25 = $[69];
734
- let t26;
735
- $[70] !== boxProps || $[71] !== children ? (t26 = children && /* @__PURE__ */ jsx(Box, {
736
- as: "span",
737
- ...boxProps,
738
- children
739
- }), $[70] = boxProps, $[71] = children, $[72] = t26) : t26 = $[72];
740
- let t27;
741
- return $[73] !== mode || $[74] !== radius || $[75] !== ref || $[76] !== restProps || $[77] !== t21 || $[78] !== t22 || $[79] !== t23 || $[80] !== t24 || $[81] !== t25 || $[82] !== t26 || $[83] !== tone || $[84] !== type || $[85] !== width ? (t27 = /* @__PURE__ */ jsxs(StyledButton, {
742
- "data-ui": "Button",
743
- ...restProps,
744
- $mode: mode,
745
- $radius: radius,
746
- $tone: tone,
747
- "data-disabled": t21,
748
- "data-selected": t22,
749
- disabled: t23,
750
- ref,
751
- type,
752
- $width: width,
753
- children: [
754
- t24,
755
- t25,
756
- t26
757
- ]
758
- }), $[73] = mode, $[74] = radius, $[75] = ref, $[76] = restProps, $[77] = t21, $[78] = t22, $[79] = t23, $[80] = t24, $[81] = t25, $[82] = t26, $[83] = tone, $[84] = type, $[85] = width, $[86] = t27) : t27 = $[86], t27;
759
- });
760
- function responsiveBorderStyle() {
761
- return [
762
- border,
763
- borderTop,
764
- borderRight,
765
- borderBottom,
766
- borderLeft
767
- ];
768
- }
769
- function border(props) {
770
- let { card, media } = getTheme_v2(props.theme), borderStyle = `${card.border?.width ?? 1}px solid var(--card-border-color)`;
771
- return _responsive(media, props.$border, (value) => value ? { "&&": { border: borderStyle } } : { "&&": { border: 0 } });
772
- }
773
- function borderTop(props) {
774
- let { card, media } = getTheme_v2(props.theme), borderStyle = `${card.border?.width ?? 1}px solid var(--card-border-color)`;
775
- return _responsive(media, props.$borderTop, (value) => value ? { "&&": { borderTop: borderStyle } } : { "&&": { borderTop: 0 } });
776
- }
777
- function borderRight(props) {
778
- let { card, media } = getTheme_v2(props.theme), borderStyle = `${card.border?.width ?? 1}px solid var(--card-border-color)`;
779
- return _responsive(media, props.$borderRight, (value) => value ? { "&&": { borderRight: borderStyle } } : { "&&": { borderRight: 0 } });
780
- }
781
- function borderBottom(props) {
782
- let { card, media } = getTheme_v2(props.theme), borderStyle = `${card.border?.width ?? 1}px solid var(--card-border-color)`;
783
- return _responsive(media, props.$borderBottom, (value) => value ? { "&&": { borderBottom: borderStyle } } : { "&&": { borderBottom: 0 } });
784
- }
785
- function borderLeft(props) {
786
- let { card, media } = getTheme_v2(props.theme), borderStyle = `${card.border?.width ?? 1}px solid var(--card-border-color)`;
787
- return _responsive(media, props.$borderLeft, (value) => value ? { "&&": { borderLeft: borderStyle } } : { "&&": { borderLeft: 0 } });
788
- }
789
- function toBoxShadow(shadow, color) {
790
- return `${shadow.map(rem).join(" ")} ${color}`;
791
- }
792
- function shadowStyle(shadow, outlineWidth = 1) {
793
- return shadow ? { boxShadow: `${`0 0 0 ${rem(outlineWidth)} var(--card-shadow-outline-color)`}, ${toBoxShadow(shadow.umbra, "var(--card-shadow-umbra-color)")}, ${toBoxShadow(shadow.penumbra, "var(--card-shadow-penumbra-color)")}, ${toBoxShadow(shadow.ambient, "var(--card-shadow-ambient-color)")}` } : EMPTY_RECORD;
794
- }
795
- function responsiveShadowStyle(props) {
796
- let { card, media, shadow } = getTheme_v2(props.theme);
797
- return _responsive(media, props.$shadow, (index) => shadowStyle(shadow[index], card.shadow.outline));
798
- }
799
- /**
800
- * Gets the global scope instance in a given environment.
801
- *
802
- * The strategy is to return the most modern, and if not, the most common:
803
- * - The `globalThis` variable is the modern approach to accessing the global scope
804
- * - The `window` variable is the global scope in a web browser
805
- * - The `self` variable is the global scope in workers and others
806
- * - The `global` variable is the global scope in Node.js
807
- */
808
- function getGlobalScope() {
809
- if (typeof globalThis < "u") return globalThis;
810
- if (typeof window < "u") return window;
811
- if (typeof self < "u") return self;
812
- if (typeof global < "u") return global;
813
- throw Error("@sanity/ui: could not locate global scope");
814
- }
815
- const globalScope = getGlobalScope();
816
- /**
817
- * As `@sanity/ui` is declared as a dependency, and may be duplicated, sometimes across major versions
818
- * it's critical that vital react contexts are shared even when there is a duplicate.
819
- * If we used a model similar to `sanity` itself, or `styled-components`, this would be unnecessary as
820
- * those libraries enforce single instances.
821
- * Since we don't enforce it we have to support a sanity plugin being able to call hooks like `useToast`, and then
822
- * read the context setup by `sanity`, which calls `ToastProvider`, even if the provider and hook are different instances in memory.
823
- * It's also why it's vital that all changes to globally scoped providers remain fully backwards compatible to v1.
824
- */
825
- function createGlobalScopedContext(key, defaultValue) {
826
- let symbol = Symbol.for(key);
827
- /**
828
- * Prevent errors about re-renders on React SSR on Next.js App Router
829
- */
830
- if (typeof document > "u") {
831
- let context = createContext(defaultValue);
832
- return context.displayName = key, context;
833
- }
834
- return globalScope[symbol] = globalScope[symbol] || createContext(defaultValue), globalScope[symbol];
835
- }
836
- /**
837
- * @internal
838
- */
839
- const ThemeContext = createGlobalScopedContext("@sanity/ui/context/theme", null);
840
- /**
841
- * @public
842
- */
843
- function ThemeProvider$1(props) {
844
- let $ = c(15), parentTheme = useContext(ThemeContext), { children } = props, scheme = props.scheme ?? (parentTheme?.scheme || "light"), rootTheme = props.theme ?? (parentTheme?.theme || null), tone = props.tone ?? (parentTheme?.tone || "default"), t0;
845
- bb0: {
846
- if (!rootTheme) {
847
- t0 = null;
848
- break bb0;
849
- }
850
- let t1;
851
- $[0] !== rootTheme || $[1] !== scheme || $[2] !== tone ? (t1 = {
852
- version: 0,
853
- theme: rootTheme,
854
- scheme,
855
- tone
856
- }, $[0] = rootTheme, $[1] = scheme, $[2] = tone, $[3] = t1) : t1 = $[3], t0 = t1;
857
- }
858
- let themeContext = t0, t1;
859
- bb1: {
860
- if (!rootTheme) {
861
- t1 = null;
862
- break bb1;
863
- }
864
- let t2;
865
- $[4] !== rootTheme || $[5] !== scheme || $[6] !== tone ? (t2 = getScopedTheme(rootTheme, scheme, tone), $[4] = rootTheme, $[5] = scheme, $[6] = tone, $[7] = t2) : t2 = $[7], t1 = t2;
866
- }
867
- let theme = t1;
868
- if (!theme) {
869
- let t2;
870
- return $[8] === Symbol.for("react.memo_cache_sentinel") ? (t2 = /* @__PURE__ */ jsx("pre", { children: "ThemeProvider: no \"theme\" property provided" }), $[8] = t2) : t2 = $[8], t2;
871
- }
872
- let t2;
873
- $[9] !== children || $[10] !== theme ? (t2 = /* @__PURE__ */ jsx(ThemeProvider, {
874
- theme,
875
- children
876
- }), $[9] = children, $[10] = theme, $[11] = t2) : t2 = $[11];
877
- let t3;
878
- return $[12] !== t2 || $[13] !== themeContext ? (t3 = /* @__PURE__ */ jsx(ThemeContext.Provider, {
879
- value: themeContext,
880
- children: t2
881
- }), $[12] = t2, $[13] = themeContext, $[14] = t3) : t3 = $[14], t3;
882
- }
883
- /**
884
- * @public
885
- */
886
- function useRootTheme() {
887
- let value = useContext(ThemeContext);
888
- if (!value) throw Error("useRootTheme(): missing context value");
889
- return value;
890
- }
891
- /**
892
- * @public
893
- */
894
- function ThemeColorProvider(props) {
895
- let $ = c(5), { children, scheme, tone } = props, root = useRootTheme(), t0 = scheme || root.scheme, t1;
896
- return $[0] !== children || $[1] !== root.theme || $[2] !== t0 || $[3] !== tone ? (t1 = /* @__PURE__ */ jsx(ThemeProvider$1, {
897
- scheme: t0,
898
- theme: root.theme,
899
- tone,
900
- children
901
- }), $[0] = children, $[1] = root.theme, $[2] = t0, $[3] = tone, $[4] = t1) : t1 = $[4], t1;
902
- }
903
- function cardStyle(props) {
904
- return [cardBaseStyle(props), cardColorStyle(props)];
905
- }
906
- function cardBaseStyle(props) {
907
- let { $checkered } = props, { space } = getTheme_v2(props.theme);
908
- return css`${$checkered && css`background-size:${space[3]}px ${space[3]}px;background-position:50% 50%;background-image:var(--card-bg-image);`} &[data-as='button']{-webkit-font-smoothing:inherit;appearance:none;outline:none;font:inherit;text-align:inherit;border:0;width:-moz-available;width:-webkit-fill-available;width:stretch;}&[data-as='a']{outline:none;text-decoration:none;}&[data-as='pre']{font:inherit;}`;
909
- }
910
- function cardColorStyle(props) {
911
- let { $checkered, $focusRing, $muted } = props, { card, color, style } = getTheme_v2(props.theme), border = {
912
- width: card.border.width,
913
- color: "var(--card-border-color)"
914
- };
915
- return css`color-scheme:${color._dark ? "dark" : "light"};${_cardColorStyle(color, color, $checkered)} background-color:${$muted ? "var(--card-muted-bg-color)" : "var(--card-bg-color)"};color:var(--card-fg-color);&[data-as='button']{--card-focus-ring-box-shadow:none;cursor:default;box-shadow:var(--card-focus-ring-box-shadow);&:disabled{${_cardColorStyle(color, color.selectable.default.disabled, $checkered)}}&:not(:disabled){&[data-pressed]{${_cardColorStyle(color, color.selectable.default.pressed, $checkered)}}&[data-selected]{${_cardColorStyle(color, color.selectable.default.selected, $checkered)}}@media (hover:hover){&:not([data-pressed]):not([data-selected]){&[data-hovered],&:hover{${_cardColorStyle(color, color.selectable.default.hovered, $checkered)}}&:active{${_cardColorStyle(color, color.selectable.default.pressed, $checkered)}}}}&:focus-visible{--card-focus-ring-box-shadow:${$focusRing ? focusRingStyle({
916
- base: color,
917
- border,
918
- focusRing: card.focusRing
919
- }) : void 0};}}}&[data-as='a']{cursor:pointer;box-shadow:var(--card-focus-ring-box-shadow);&[data-disabled]{${_cardColorStyle(color, color.selectable.default.disabled, $checkered)}}&:not([data-disabled]){&[data-pressed]{${_cardColorStyle(color, color.selectable.default.pressed, $checkered)}}&[data-selected]{${_cardColorStyle(color, color.selectable.default.selected, $checkered)}}@media (hover:hover){&:not([data-pressed]):not([data-selected]){&[data-hovered],&:hover{${_cardColorStyle(color, color.selectable.default.hovered, $checkered)}}&:active{${_cardColorStyle(color, color.selectable.default.pressed, $checkered)}}}}&:focus-visible{--card-focus-ring-box-shadow:${$focusRing ? focusRingStyle({
920
- base: color,
921
- border,
922
- focusRing: card.focusRing
923
- }) : void 0};}}}${style?.card?.root}`;
924
- }
925
- const StyledCard = /* @__PURE__ */ styled(Box).withConfig({
926
- displayName: "StyledCard",
927
- componentId: "sc-2ikw89-0"
928
- })(responsiveBorderStyle, responsiveRadiusStyle, responsiveShadowStyle, cardStyle), Card = forwardRef(function Card(props, ref) {
929
- let $ = c(56), asProp, border, borderBottom, borderLeft, borderRight, borderTop, muted, pressed, restProps, scheme, selected, shadow, t0, t1, t2, t3;
930
- $[0] === props ? (asProp = $[1], border = $[2], borderBottom = $[3], borderLeft = $[4], borderRight = $[5], borderTop = $[6], muted = $[7], pressed = $[8], restProps = $[9], scheme = $[10], selected = $[11], shadow = $[12], t0 = $[13], t1 = $[14], t2 = $[15], t3 = $[16]) : ({__unstable_checkered: t0, __unstable_focusRing: t1, as: asProp, border, borderTop, borderRight, borderBottom, borderLeft, muted, pressed, radius: t2, scheme, selected, shadow, tone: t3, ...restProps} = props, $[0] = props, $[1] = asProp, $[2] = border, $[3] = borderBottom, $[4] = borderLeft, $[5] = borderRight, $[6] = borderTop, $[7] = muted, $[8] = pressed, $[9] = restProps, $[10] = scheme, $[11] = selected, $[12] = shadow, $[13] = t0, $[14] = t1, $[15] = t2, $[16] = t3);
931
- let checkered = t0 !== void 0 && t0, focusRing = t1 !== void 0 && t1, radius = t2 === void 0 ? 0 : t2, toneProp = t3 === void 0 ? "default" : t3, as = isValidElementType(asProp) ? asProp : "div", rootTheme = useRootTheme(), tone = toneProp === "inherit" ? rootTheme.tone : toneProp, t4 = typeof as == "string" ? as : void 0, t5 = rootTheme.scheme, t6;
932
- $[17] === border ? t6 = $[18] : (t6 = _getArrayProp(border), $[17] = border, $[18] = t6);
933
- let t7;
934
- $[19] === borderTop ? t7 = $[20] : (t7 = _getArrayProp(borderTop), $[19] = borderTop, $[20] = t7);
935
- let t8;
936
- $[21] === borderRight ? t8 = $[22] : (t8 = _getArrayProp(borderRight), $[21] = borderRight, $[22] = t8);
937
- let t9;
938
- $[23] === borderBottom ? t9 = $[24] : (t9 = _getArrayProp(borderBottom), $[23] = borderBottom, $[24] = t9);
939
- let t10;
940
- $[25] === borderLeft ? t10 = $[26] : (t10 = _getArrayProp(borderLeft), $[25] = borderLeft, $[26] = t10);
941
- let t11;
942
- $[27] === radius ? t11 = $[28] : (t11 = _getArrayProp(radius), $[27] = radius, $[28] = t11);
943
- let t12;
944
- $[29] === shadow ? t12 = $[30] : (t12 = _getArrayProp(shadow), $[29] = shadow, $[30] = t12);
945
- let t13 = checkered ? "" : void 0, t14 = pressed ? "" : void 0, t15 = selected ? "" : void 0, t16;
946
- $[31] !== as || $[32] !== checkered || $[33] !== focusRing || $[34] !== muted || $[35] !== ref || $[36] !== restProps || $[37] !== rootTheme.scheme || $[38] !== selected || $[39] !== t10 || $[40] !== t11 || $[41] !== t12 || $[42] !== t13 || $[43] !== t14 || $[44] !== t15 || $[45] !== t4 || $[46] !== t6 || $[47] !== t7 || $[48] !== t8 || $[49] !== t9 || $[50] !== tone ? (t16 = /* @__PURE__ */ jsx(StyledCard, {
947
- "data-as": t4,
948
- "data-scheme": t5,
949
- "data-ui": "Card",
950
- "data-tone": tone,
951
- ...restProps,
952
- $border: t6,
953
- $borderTop: t7,
954
- $borderRight: t8,
955
- $borderBottom: t9,
956
- $borderLeft: t10,
957
- $checkered: checkered,
958
- $focusRing: focusRing,
959
- $muted: muted,
960
- $radius: t11,
961
- $shadow: t12,
962
- $tone: tone,
963
- "data-checkered": t13,
964
- "data-pressed": t14,
965
- "data-selected": t15,
966
- forwardedAs: as,
967
- ref,
968
- selected
969
- }), $[31] = as, $[32] = checkered, $[33] = focusRing, $[34] = muted, $[35] = ref, $[36] = restProps, $[37] = rootTheme.scheme, $[38] = selected, $[39] = t10, $[40] = t11, $[41] = t12, $[42] = t13, $[43] = t14, $[44] = t15, $[45] = t4, $[46] = t6, $[47] = t7, $[48] = t8, $[49] = t9, $[50] = tone, $[51] = t16) : t16 = $[51];
970
- let t17;
971
- return $[52] !== scheme || $[53] !== t16 || $[54] !== tone ? (t17 = /* @__PURE__ */ jsx(ThemeColorProvider, {
972
- scheme,
973
- tone,
974
- children: t16
975
- }), $[52] = scheme, $[53] = t16, $[54] = tone, $[55] = t17) : t17 = $[55], t17;
976
- }), _ResizeObserver = typeof document < "u" && typeof window < "u" && window.ResizeObserver ? window.ResizeObserver : ResizeObserver, _elementSizeObserver = _createElementSizeObserver();
977
- function _createElementRectValueListener() {
978
- return { subscribe(element, subscriber) {
979
- let resizeObserver = new _ResizeObserver(([entry]) => {
980
- subscriber({
981
- _contentRect: entry.contentRect,
982
- border: {
983
- width: entry.borderBoxSize[0].inlineSize,
984
- height: entry.borderBoxSize[0].blockSize
985
- },
986
- content: {
987
- width: entry.contentRect.width,
988
- height: entry.contentRect.height
989
- }
990
- });
991
- });
992
- return resizeObserver.observe(element), () => {
993
- resizeObserver.unobserve(element), resizeObserver.disconnect();
994
- };
995
- } };
996
- }
997
- function _createElementSizeObserver() {
998
- let disposeCache = /* @__PURE__ */ new WeakMap(), subscribersCache = /* @__PURE__ */ new WeakMap();
999
- return { subscribe(element, subscriber) {
1000
- let subscribers = subscribersCache.get(element) || [], dispose = disposeCache.get(element);
1001
- return subscribersCache.has(element) || (subscribersCache.set(element, subscribers), dispose = _createElementRectValueListener().subscribe(element, (elementRect) => {
1002
- for (let sub of subscribers) sub(elementRect);
1003
- })), subscribers.push(subscriber), () => {
1004
- let idx = subscribers.indexOf(subscriber);
1005
- idx > -1 && subscribers.splice(idx, 1), subscribers.length === 0 && dispose && dispose();
1006
- };
1007
- } };
1008
- }
1009
- /**
1010
- * Subscribe to the size of a DOM element.
1011
- * @beta
1012
- */
1013
- function useElementSize(element) {
1014
- let $ = c(3), [size, setSize] = useState(null), t0, t1;
1015
- return $[0] === element ? (t0 = $[1], t1 = $[2]) : (t0 = () => {
1016
- if (element) return _elementSizeObserver.subscribe(element, setSize);
1017
- }, t1 = [element], $[0] = element, $[1] = t0, $[2] = t1), useEffect(t0, t1), size;
1018
- }
1019
- function _getMediaQuery(media, index) {
1020
- return index === 0 ? `screen and (max-width: ${media[index] - 1}px)` : index === media.length ? `screen and (min-width: ${media[index - 1]}px)` : `screen and (min-width: ${media[index - 1]}px) and (max-width: ${media[index] - 1}px)`;
1021
- }
1022
- function _createMediaStore(media) {
1023
- let mediaLen = media.length, sizes, getSizes = () => {
1024
- if (!sizes) {
1025
- sizes = [];
1026
- for (let index = mediaLen; index > -1; --index) {
1027
- let mediaQuery = _getMediaQuery(media, index);
1028
- sizes.push({
1029
- index,
1030
- mq: window.matchMedia(mediaQuery)
1031
- });
1032
- }
1033
- }
1034
- return sizes;
1035
- }, getSnapshot = () => {
1036
- for (let { index, mq } of getSizes()) if (mq.matches) return index;
1037
- return 0;
1038
- }, subscribe = (onStoreChange) => {
1039
- let disposeFns = [];
1040
- for (let { mq } of getSizes()) {
1041
- let handleChange = () => {
1042
- mq.matches && onStoreChange();
1043
- };
1044
- mq.addEventListener("change", handleChange), disposeFns.push(() => mq.removeEventListener("change", handleChange));
1045
- }
1046
- return () => {
1047
- for (let disposeFn of disposeFns) disposeFn();
1048
- };
1049
- };
1050
- return {
1051
- getSnapshot,
1052
- subscribe
1053
- };
1054
- }
1055
- /**
1056
- * Only called during server-side rendering, and hydration if using hydrateRoot
1057
- * Since the server environment doesn't have access to the DOM, we can't determine the current value of the media query
1058
- * and we assume `(prefers-color-scheme: light)` since it's the most common scheme
1059
- *
1060
- * @link https://beta.reactjs.org/apis/react/useSyncExternalStore#adding-support-for-server-rendering
1061
- */
1062
- function getServerSnapshot() {
1063
- return 0;
1064
- }
1065
- /**
1066
- * This API might change. DO NOT USE IN PRODUCTION.
1067
- * @beta
1068
- */
1069
- function useMediaIndex() {
1070
- let $ = c(2), { media } = useTheme_v2(), t0;
1071
- $[0] === media ? t0 = $[1] : (t0 = _createMediaStore(media), $[0] = media, $[1] = t0);
1072
- let store = t0;
1073
- return useSyncExternalStore(store.subscribe, store.getSnapshot, getServerSnapshot);
1074
- }
1075
- /**
1076
- * Efficiently subscribes to `window.matchMedia` queries
1077
- *
1078
- * @param getServerSnapshot - Only called during server-side rendering, and hydration if using hydrateRoot. Required if the hook is called during SSR (https://react.dev/reference/react/useSyncExternalStore#adding-support-for-server-rendering)
1079
- *
1080
- * @public
1081
- */
1082
- function useMatchMedia(mediaQueryString, getServerSnapshot) {
1083
- let $ = c(4);
1084
- useDebugValue(mediaQueryString);
1085
- let t0;
1086
- $[0] === mediaQueryString ? t0 = $[1] : (t0 = (onStoreChange) => {
1087
- let media = window.matchMedia(mediaQueryString);
1088
- return media.addEventListener("change", onStoreChange), () => media.removeEventListener("change", onStoreChange);
1089
- }, $[0] = mediaQueryString, $[1] = t0);
1090
- let t1;
1091
- return $[2] === mediaQueryString ? t1 = $[3] : (t1 = () => window.matchMedia(mediaQueryString).matches, $[2] = mediaQueryString, $[3] = t1), useSyncExternalStore(t0, t1, getServerSnapshot);
1092
- }
1093
- /**
1094
- * Returns true if motion should be reduced
1095
- *
1096
- * @param getServerSnapshot - Only called during server-side rendering, and hydration if using hydrateRoot. Since the server environment doesn't have access to the DOM, we can't determine the current value of the media query and we assume `(prefers-reduced-motion: no-preference)` since it's the most common scheme (https://react.dev/reference/react/useSyncExternalStore#adding-support-for-server-rendering)
1097
- *
1098
- * If you persist the detected preference in a cookie or a header then you may implement your own server snapshot to read it.
1099
- * Chrome supports reading the `prefers-reduced-motion` media query from a header if the server response: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Sec-CH-Prefers-Reduced-Motion
1100
- * @example https://gist.github.com/stipsan/0c0f839a27842249cada893e9fb7767b
1101
- *
1102
- * @public
1103
- */
1104
- function usePrefersReducedMotion(t0) {
1105
- return useMatchMedia("(prefers-reduced-motion: reduce)", t0 === void 0 ? _temp$8 : t0);
1106
- }
1107
- function _temp$8() {
1108
- return !1;
1109
- }
1110
- /**
1111
- * Custom floating-ui middleware which calculates transform-origin X + Y offsets
1112
- * based on the current floating rect's dimensions and shift offset.
1113
- *
1114
- * Scaling popovers with these transform-origin offsets will give the effect of
1115
- * popvers slightly 'growing' from the origin/reference element.
1116
- *
1117
- * This middleware must be applied after both `@sanity/ui/size` and `shift` middlewares.
1118
- */
1119
- const origin = {
1120
- name: "@sanity/ui/origin",
1121
- fn({ middlewareData, placement, rects }) {
1122
- let [side] = placement.split("-"), floatingWidth = rects.floating.width, floatingHeight = rects.floating.height, shiftX = middlewareData.shift?.x || 0, shiftY = middlewareData.shift?.y || 0;
1123
- if (floatingWidth <= 0 || floatingHeight <= 0) return {};
1124
- let { originX, originY } = ["bottom", "top"].includes(side) ? {
1125
- originX: clamp(.5 - shiftX / floatingWidth, 0, 1),
1126
- originY: side === "bottom" ? 0 : 1
1127
- } : {
1128
- originX: +(side === "left"),
1129
- originY: clamp(.5 - shiftY / floatingHeight, 0, 1)
1130
- };
1131
- return { data: {
1132
- originX,
1133
- originY
1134
- } };
1135
- }
1136
- };
1137
- function clamp(num, min, max) {
1138
- return Math.min(Math.max(num, min), max);
1139
- }
1140
- function isRecord(value) {
1141
- return !!(value && typeof value == "object" && !Array.isArray(value));
1142
- }
1143
- const BoundaryElementContext = createGlobalScopedContext("@sanity/ui/context/boundaryElement", null), DEFAULT_VALUE = {
1144
- version: 0,
1145
- element: null
1146
- };
1147
- /**
1148
- * @public
1149
- */
1150
- function useBoundaryElement() {
1151
- let value = useContext(BoundaryElementContext);
1152
- if (value && (!isRecord(value) || value.version !== 0)) throw Error("useBoundaryElement(): the context value is not compatible");
1153
- return value || DEFAULT_VALUE;
1154
- }
1155
- function getElementRef(element) {
1156
- let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
1157
- 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);
1158
- }
1159
- function getLayerContext(contextValue) {
1160
- if (!isRecord(contextValue) || contextValue.version !== 0) throw Error("the context value is not compatible");
1161
- if (!contextValue) throw Error("components using `useLayer()` should be wrapped in a <LayerProvider>.");
1162
- if (contextValue.version === 0) return contextValue;
1163
- throw Error("could not get layer context");
1164
- }
1165
- const LayerContext = createGlobalScopedContext("@sanity/ui/context/layer", null);
1166
- /**
1167
- * @public
1168
- */
1169
- function LayerProvider(props) {
1170
- let $ = c(21), { children, zOffset: t0 } = props, zOffsetProp = t0 === void 0 ? 0 : t0, parentContextValue = useContext(LayerContext), t1;
1171
- $[0] === parentContextValue ? t1 = $[1] : (t1 = parentContextValue && getLayerContext(parentContextValue), $[0] = parentContextValue, $[1] = t1);
1172
- let parent = t1, parentRegisterChild = parent?.registerChild, level = (parent?.level ?? 0) + 1, t2;
1173
- $[2] === zOffsetProp ? t2 = $[3] : (t2 = _getArrayProp(zOffsetProp), $[2] = zOffsetProp, $[3] = t2);
1174
- let zOffset = t2, maxMediaIndex = zOffset.length - 1, mediaIndex = Math.min(useMediaIndex(), maxMediaIndex), zIndex = parent ? parent.zIndex + zOffset[mediaIndex] : zOffset[mediaIndex], t3;
1175
- $[4] === Symbol.for("react.memo_cache_sentinel") ? (t3 = {}, $[4] = t3) : t3 = $[4];
1176
- let [, setChildLayers] = useState(t3), [size, setSize] = useState(0), isTopLayer = size === 0, t4;
1177
- $[5] !== parentRegisterChild || $[6] !== setChildLayers ? (t4 = (childLevel) => {
1178
- let parentDispose = parentRegisterChild?.(childLevel);
1179
- return childLevel === void 0 ? setSize(_temp$7) : setChildLayers((state) => {
1180
- let prevLen = state[childLevel] ?? 0, nextState = {
1181
- ...state,
1182
- [childLevel]: prevLen + 1
1183
- };
1184
- return setSize(Object.keys(nextState).length), nextState;
1185
- }), () => {
1186
- childLevel === void 0 ? setSize(_temp2$2) : setChildLayers((state_0) => {
1187
- let nextState_0 = { ...state_0 };
1188
- return nextState_0[childLevel] === 1 ? (delete nextState_0[childLevel], setSize(Object.keys(nextState_0).length)) : nextState_0[childLevel] = nextState_0[childLevel] - 1, nextState_0;
1189
- }), parentDispose?.();
1190
- };
1191
- }, $[5] = parentRegisterChild, $[6] = setChildLayers, $[7] = t4) : t4 = $[7];
1192
- let registerChild = t4, t5, t6;
1193
- $[8] !== level || $[9] !== parentRegisterChild ? (t5 = () => parentRegisterChild?.(level), t6 = [level, parentRegisterChild], $[8] = level, $[9] = parentRegisterChild, $[10] = t5, $[11] = t6) : (t5 = $[10], t6 = $[11]), useEffect(t5, t6);
1194
- let t7;
1195
- $[12] !== isTopLayer || $[13] !== level || $[14] !== registerChild || $[15] !== size || $[16] !== zIndex ? (t7 = {
1196
- version: 0,
1197
- isTopLayer,
1198
- level,
1199
- registerChild,
1200
- size,
1201
- zIndex
1202
- }, $[12] = isTopLayer, $[13] = level, $[14] = registerChild, $[15] = size, $[16] = zIndex, $[17] = t7) : t7 = $[17];
1203
- let value = t7, t8;
1204
- return $[18] !== children || $[19] !== value ? (t8 = /* @__PURE__ */ jsx(LayerContext.Provider, {
1205
- value,
1206
- children
1207
- }), $[18] = children, $[19] = value, $[20] = t8) : t8 = $[20], t8;
1208
- }
1209
- function _temp2$2(v_0) {
1210
- return v_0 - 1;
1211
- }
1212
- function _temp$7(v) {
1213
- return v + 1;
1214
- }
1215
- /**
1216
- * @public
1217
- */
1218
- function useLayer() {
1219
- let $ = c(2), value = useContext(LayerContext);
1220
- if (!value) throw Error("useLayer(): missing context value");
1221
- try {
1222
- let t1;
1223
- return $[0] === value ? t1 = $[1] : (t1 = getLayerContext(value), $[0] = value, $[1] = t1), t1;
1224
- } catch (t0) {
1225
- let err = t0;
1226
- throw err instanceof Error ? Error(`useLayer(): ${err.message}`) : Error(`useLayer(): ${err}`);
1227
- }
1228
- }
1229
- const key = "@sanity/ui/context/portal", elementKey = Symbol.for(`${key}/element`);
1230
- globalScope[elementKey] = null;
1231
- const PortalContext = createGlobalScopedContext(key, {
1232
- version: 0,
1233
- boundaryElement: null,
1234
- get element() {
1235
- return typeof document > "u" ? null : globalScope[elementKey] ? globalScope[elementKey] : (globalScope[elementKey] = document.createElement("div"), globalScope[elementKey].setAttribute("data-portal", ""), document.body.appendChild(globalScope[elementKey]), globalScope[elementKey]);
1236
- }
1237
- });
1238
- /**
1239
- * @public
1240
- */
1241
- function usePortal() {
1242
- let value = useContext(PortalContext);
1243
- if (!value) throw Error("usePortal(): missing context value");
1244
- if (!isRecord(value) || value.version !== 0) throw Error("usePortal(): the context value is not compatible");
1245
- return value;
1246
- }
1247
- /**
1248
- * @public
1249
- */
1250
- function Portal(props) {
1251
- let $ = c(3), { children, __unstable_name: name } = props, portal = usePortal(), portalElement = (name ? portal.elements && portal.elements[name] : portal.element) || portal.elements?.default;
1252
- if (!portalElement) return null;
1253
- let t0;
1254
- return $[0] !== children || $[1] !== portalElement ? (t0 = createPortal(children, portalElement), $[0] = children, $[1] = portalElement, $[2] = t0) : t0 = $[2], t0;
1255
- }
1256
- const DEFAULT_POPOVER_MARGINS = [
1257
- 0,
1258
- 0,
1259
- 0,
1260
- 0
1261
- ], DEFAULT_FALLBACK_PLACEMENTS$1 = {
1262
- top: [
1263
- "bottom",
1264
- "left",
1265
- "right"
1266
- ],
1267
- "top-start": [
1268
- "bottom-start",
1269
- "left-start",
1270
- "right-start"
1271
- ],
1272
- "top-end": [
1273
- "bottom-end",
1274
- "left-end",
1275
- "right-end"
1276
- ],
1277
- bottom: [
1278
- "top",
1279
- "left",
1280
- "right"
1281
- ],
1282
- "bottom-start": [
1283
- "top-start",
1284
- "left-start",
1285
- "right-start"
1286
- ],
1287
- "bottom-end": [
1288
- "top-end",
1289
- "left-end",
1290
- "right-end"
1291
- ],
1292
- left: [
1293
- "right",
1294
- "top",
1295
- "bottom"
1296
- ],
1297
- "left-start": [
1298
- "right-start",
1299
- "top-start",
1300
- "bottom-start"
1301
- ],
1302
- "left-end": [
1303
- "right-end",
1304
- "top-end",
1305
- "bottom-end"
1306
- ],
1307
- right: [
1308
- "left",
1309
- "top",
1310
- "bottom"
1311
- ],
1312
- "right-start": [
1313
- "left-start",
1314
- "top-start",
1315
- "bottom-start"
1316
- ],
1317
- "right-end": [
1318
- "left-end",
1319
- "top-end",
1320
- "bottom-end"
1321
- ]
1322
- };
1323
- function size(options) {
1324
- let { constrainSize, margins, matchReferenceWidth, maxWidthRef, padding = 0, referenceWidthRef, setReferenceWidth, widthRef } = options;
1325
- return {
1326
- name: "@sanity/ui/size",
1327
- async fn(args) {
1328
- let { elements, placement, platform, rects } = args, { floating, reference } = rects, overflow = await detectOverflow(args, {
1329
- altBoundary: !0,
1330
- boundary: options.boundaryElement || void 0,
1331
- elementContext: "floating",
1332
- padding,
1333
- rootBoundary: "viewport"
1334
- }), maxWidth = Infinity, maxHeight = Infinity, floatingW = floating.width, floatingH = floating.height;
1335
- 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));
1336
- let availableWidth = maxWidth - margins[1] - margins[3], availableHeight = maxHeight - margins[0] - margins[2], referenceWidth = reference.width - margins[1] - margins[3];
1337
- referenceWidthRef.current = referenceWidth, setReferenceWidth(referenceWidth), matchReferenceWidth ? elements.floating.style.width = `${referenceWidth}px` : widthRef.current !== void 0 && (elements.floating.style.width = `${widthRef.current}px`), constrainSize && (elements.floating.style.maxWidth = `${Math.min(availableWidth, maxWidthRef.current ?? Infinity)}px`, elements.floating.style.maxHeight = `${availableHeight}px`);
1338
- let nextDimensions = await platform.getDimensions(elements.floating), targetH = nextDimensions.height;
1339
- return floatingW !== nextDimensions.width || floatingH !== targetH ? { reset: { rects: !0 } } : {};
1340
- }
1341
- };
1342
- }
1343
- function calcCurrentWidth(params) {
1344
- let { container, mediaIndex, width } = params, w = width[mediaIndex], currentWidth = w === void 0 ? width[width.length - 1] : w;
1345
- return typeof currentWidth == "number" ? container[currentWidth] : void 0;
1346
- }
1347
- function calcMaxWidth(params) {
1348
- let { boundaryWidth, currentWidth } = params;
1349
- if (currentWidth !== void 0 || boundaryWidth !== void 0) return Math.min(currentWidth ?? Infinity, (boundaryWidth || Infinity) - 8);
1350
- }
1351
- function moveTowardsLength(movingPoint, targetPoint, amount) {
1352
- let width = targetPoint.x - movingPoint.x, height = targetPoint.y - movingPoint.y, distance = Math.sqrt(width * width + height * height);
1353
- return moveTowardsFractional(movingPoint, targetPoint, Math.min(1, amount / distance));
1354
- }
1355
- function moveTowardsFractional(movingPoint, targetPoint, fraction) {
1356
- return {
1357
- x: movingPoint.x + (targetPoint.x - movingPoint.x) * fraction,
1358
- y: movingPoint.y + (targetPoint.y - movingPoint.y) * fraction
1359
- };
1360
- }
1361
- function getRoundedCommands(points) {
1362
- let len = points.length, cmds = [];
1363
- for (let i = 0; i < len; i += 1) {
1364
- let point = points[i], prevPoint = points[i - 1], nextPoint = points[i + 1];
1365
- if (prevPoint && point.radius) {
1366
- let curveStart = moveTowardsLength(point, prevPoint, point.radius), curveEnd = moveTowardsLength(point, nextPoint, point.radius), startControl = moveTowardsFractional(curveStart, point, .5), endControl = moveTowardsFractional(point, curveEnd, .5);
1367
- cmds.push({
1368
- type: "point",
1369
- ...curveStart
1370
- }), cmds.push({
1371
- type: "curve",
1372
- curveEnd,
1373
- startControl,
1374
- endControl
1375
- });
1376
- } else cmds.push({
1377
- type: "point",
1378
- ...point
1379
- });
1380
- }
1381
- return cmds;
1382
- }
1383
- function compileCommands(cmds) {
1384
- 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(" ");
1385
- }
1386
- const StyledArrow = /* @__PURE__ */ styled.div.withConfig({
1387
- displayName: "StyledArrow",
1388
- componentId: "sc-ivw6of-0"
1389
- })(({ $w: w }) => css`position:absolute;width:${w}px;height:${w}px;:empty + &{display:none;}& > svg{display:block;line-height:0;transform-origin:${w / 2}px ${w / 2}px;}[data-placement^='top'] > &{bottom:-${w}px;& > svg{transform:rotate(0);}}[data-placement^='right'] > &{left:-${w}px;& > svg{transform:rotate(90deg);}}[data-placement^='left'] > &{right:-${w}px;& > svg{transform:rotate(-90deg);}}[data-placement^='bottom'] > &{top:-${w}px;& > svg{transform:rotate(180deg);}}`), StrokePath = styled.path.withConfig({
1390
- displayName: "StrokePath",
1391
- componentId: "sc-ivw6of-1"
1392
- })`stroke:var(--card-shadow-outline-color);`, ShapePath = styled.path.withConfig({
1393
- displayName: "ShapePath",
1394
- componentId: "sc-ivw6of-2"
1395
- })`fill:var(--card-bg-color);`, Arrow = forwardRef(function Arrow(props, ref) {
1396
- let $ = c(29), h, restProps, t0, w;
1397
- $[0] === props ? (h = $[1], restProps = $[2], t0 = $[3], w = $[4]) : ({width: w, height: h, radius: t0, ...restProps} = props, $[0] = props, $[1] = h, $[2] = restProps, $[3] = t0, $[4] = w);
1398
- let radius = t0 === void 0 ? 0 : t0, { card } = useTheme_v2(), strokeWidth = card.shadow.outline, center = w / 2, t1;
1399
- $[5] !== center || $[6] !== h || $[7] !== radius || $[8] !== w ? (t1 = compileCommands(getRoundedCommands([
1400
- {
1401
- x: 0,
1402
- y: 0
1403
- },
1404
- {
1405
- x: radius,
1406
- y: 0,
1407
- radius
1408
- },
1409
- {
1410
- x: center,
1411
- y: h - 1,
1412
- radius
1413
- },
1414
- {
1415
- x: w - radius,
1416
- y: 0,
1417
- radius
1418
- },
1419
- {
1420
- x: w,
1421
- y: 0
1422
- }
1423
- ])), $[5] = center, $[6] = h, $[7] = radius, $[8] = w, $[9] = t1) : t1 = $[9];
1424
- let path = t1, strokePath = `${path}`, fillPath = `${path} M ${w} -1 M 0 -1 Z`, t2 = `0 0 ${w} ${w}`, t3;
1425
- $[10] !== strokeWidth || $[11] !== w ? (t3 = /* @__PURE__ */ jsx("mask", {
1426
- id: "stroke-mask",
1427
- children: /* @__PURE__ */ jsx("rect", {
1428
- x: 0,
1429
- y: strokeWidth,
1430
- width: w,
1431
- height: w,
1432
- fill: "white"
1433
- })
1434
- }), $[10] = strokeWidth, $[11] = w, $[12] = t3) : t3 = $[12];
1435
- let t4 = strokeWidth * 2, t5;
1436
- $[13] !== strokePath || $[14] !== t4 ? (t5 = /* @__PURE__ */ jsx(StrokePath, {
1437
- d: strokePath,
1438
- mask: "url(#stroke-mask)",
1439
- strokeWidth: t4
1440
- }), $[13] = strokePath, $[14] = t4, $[15] = t5) : t5 = $[15];
1441
- let t6;
1442
- $[16] === fillPath ? t6 = $[17] : (t6 = /* @__PURE__ */ jsx(ShapePath, { d: fillPath }), $[16] = fillPath, $[17] = t6);
1443
- let t7;
1444
- $[18] !== t2 || $[19] !== t3 || $[20] !== t5 || $[21] !== t6 || $[22] !== w ? (t7 = /* @__PURE__ */ jsxs("svg", {
1445
- width: w,
1446
- height: w,
1447
- viewBox: t2,
1448
- children: [
1449
- t3,
1450
- t5,
1451
- t6
1452
- ]
1453
- }), $[18] = t2, $[19] = t3, $[20] = t5, $[21] = t6, $[22] = w, $[23] = t7) : t7 = $[23];
1454
- let t8;
1455
- return $[24] !== ref || $[25] !== restProps || $[26] !== t7 || $[27] !== w ? (t8 = /* @__PURE__ */ jsx(StyledArrow, {
1456
- ...restProps,
1457
- $w: w,
1458
- ref,
1459
- children: t7
1460
- }), $[24] = ref, $[25] = restProps, $[26] = t7, $[27] = w, $[28] = t8) : t8 = $[28], t8;
1461
- }), MotionCard$1 = styled(motion.create(Card)).withConfig({
1462
- displayName: "MotionCard",
1463
- componentId: "sc-tq6s8o-0"
1464
- })`&:not([hidden]){display:flex;}flex-direction:column;width:max-content;min-width:min-content;will-change:transform;`, MotionFlex = styled(motion.create(Flex)).withConfig({
1465
- displayName: "MotionFlex",
1466
- componentId: "sc-tq6s8o-1"
1467
- })`will-change:opacity;`, PopoverCard = forwardRef(function PopoverCard(props, ref) {
1468
- let $ = c(66), animate, arrow, arrowRef, arrowX, arrowY, children, marginsProp, originX, originY, overflow, padding, placement, radius, restProps, scheme, shadow, strategy, style, tone, width, xProp, yProp;
1469
- $[0] === props ? (animate = $[1], arrow = $[2], arrowRef = $[3], arrowX = $[4], arrowY = $[5], children = $[6], marginsProp = $[7], originX = $[8], originY = $[9], overflow = $[10], padding = $[11], placement = $[12], radius = $[13], restProps = $[14], scheme = $[15], shadow = $[16], strategy = $[17], style = $[18], tone = $[19], width = $[20], xProp = $[21], yProp = $[22]) : ({__unstable_margins: marginsProp, animate, arrow, arrowRef, arrowX, arrowY, children, padding, placement, originX, originY, overflow, radius, scheme, shadow, strategy, style, tone, width, x: xProp, y: yProp, ...restProps} = props, $[0] = props, $[1] = animate, $[2] = arrow, $[3] = arrowRef, $[4] = arrowX, $[5] = arrowY, $[6] = children, $[7] = marginsProp, $[8] = originX, $[9] = originY, $[10] = overflow, $[11] = padding, $[12] = placement, $[13] = radius, $[14] = restProps, $[15] = scheme, $[16] = shadow, $[17] = strategy, $[18] = style, $[19] = tone, $[20] = width, $[21] = xProp, $[22] = yProp);
1470
- let { zIndex } = useLayer(), margins = marginsProp || DEFAULT_POPOVER_MARGINS, x = (xProp ?? 0) + margins[3], y = (yProp ?? 0) + margins[0], t0 = animate ? "transform" : void 0, t1;
1471
- $[23] !== originX || $[24] !== originY || $[25] !== strategy || $[26] !== style || $[27] !== t0 || $[28] !== width || $[29] !== x || $[30] !== y || $[31] !== zIndex ? (t1 = {
1472
- left: x,
1473
- originX,
1474
- originY,
1475
- position: strategy,
1476
- top: y,
1477
- width,
1478
- zIndex,
1479
- willChange: t0,
1480
- ...style
1481
- }, $[23] = originX, $[24] = originY, $[25] = strategy, $[26] = style, $[27] = t0, $[28] = width, $[29] = x, $[30] = y, $[31] = zIndex, $[32] = t1) : t1 = $[32];
1482
- let rootStyle = t1, t2 = arrowX === null ? void 0 : arrowX, t3 = arrowY === null ? void 0 : arrowY, t4;
1483
- $[33] !== t2 || $[34] !== t3 ? (t4 = {
1484
- left: t2,
1485
- top: t3,
1486
- right: void 0,
1487
- bottom: void 0
1488
- }, $[33] = t2, $[34] = t3, $[35] = t4) : t4 = $[35];
1489
- let arrowStyle = t4, t5 = restProps, t6;
1490
- $[36] === animate ? t6 = $[37] : (t6 = animate ? ["hidden", "initial"] : void 0, $[36] = animate, $[37] = t6);
1491
- let t7;
1492
- $[38] === animate ? t7 = $[39] : (t7 = animate ? ["visible", "scaleIn"] : void 0, $[38] = animate, $[39] = t7);
1493
- let t8;
1494
- $[40] === animate ? t8 = $[41] : (t8 = animate ? ["hidden", "scaleOut"] : void 0, $[40] = animate, $[41] = t8);
1495
- let t9;
1496
- $[42] !== children || $[43] !== padding ? (t9 = /* @__PURE__ */ jsx(Flex, {
1497
- direction: "column",
1498
- flex: 1,
1499
- padding,
1500
- children
1501
- }), $[42] = children, $[43] = padding, $[44] = t9) : t9 = $[44];
1502
- let t10;
1503
- $[45] !== overflow || $[46] !== t9 ? (t10 = /* @__PURE__ */ jsx(MotionFlex, {
1504
- "data-ui": "Popover__wrapper",
1505
- direction: "column",
1506
- flex: 1,
1507
- overflow,
1508
- variants: POPOVER_MOTION_PROPS.children,
1509
- transition: POPOVER_MOTION_PROPS.transition,
1510
- children: t9
1511
- }), $[45] = overflow, $[46] = t9, $[47] = t10) : t10 = $[47];
1512
- let t11;
1513
- $[48] !== arrow || $[49] !== arrowRef || $[50] !== arrowStyle ? (t11 = arrow && /* @__PURE__ */ jsx(Arrow, {
1514
- ref: arrowRef,
1515
- style: arrowStyle,
1516
- width: 19,
1517
- height: 8,
1518
- radius: 2
1519
- }), $[48] = arrow, $[49] = arrowRef, $[50] = arrowStyle, $[51] = t11) : t11 = $[51];
1520
- let t12;
1521
- return $[52] !== placement || $[53] !== radius || $[54] !== ref || $[55] !== rootStyle || $[56] !== scheme || $[57] !== shadow || $[58] !== t10 || $[59] !== t11 || $[60] !== t5 || $[61] !== t6 || $[62] !== t7 || $[63] !== t8 || $[64] !== tone ? (t12 = /* @__PURE__ */ jsxs(MotionCard$1, {
1522
- "data-ui": "Popover",
1523
- ...t5,
1524
- "data-placement": placement,
1525
- radius,
1526
- ref,
1527
- scheme,
1528
- shadow,
1529
- sizing: "border",
1530
- style: rootStyle,
1531
- tone,
1532
- variants: POPOVER_MOTION_PROPS.card,
1533
- transition: POPOVER_MOTION_PROPS.transition,
1534
- initial: t6,
1535
- animate: t7,
1536
- exit: t8,
1537
- children: [t10, t11]
1538
- }), $[52] = placement, $[53] = radius, $[54] = ref, $[55] = rootStyle, $[56] = scheme, $[57] = shadow, $[58] = t10, $[59] = t11, $[60] = t5, $[61] = t6, $[62] = t7, $[63] = t8, $[64] = tone, $[65] = t12) : t12 = $[65], t12;
1539
- }), ViewportOverlay = () => {
1540
- let $ = c(2), { zIndex } = useLayer(), t0;
1541
- return $[0] === zIndex ? t0 = $[1] : (t0 = /* @__PURE__ */ jsx("div", { style: {
1542
- height: "100vh",
1543
- inset: 0,
1544
- position: "fixed",
1545
- width: "100vw",
1546
- zIndex
1547
- } }), $[0] = zIndex, $[1] = t0), t0;
1548
- }, Popover = forwardRef(function Popover(props, forwardedRef) {
1549
- let $ = c(126), { container, layer } = useTheme_v2(), boundaryElementContext = useBoundaryElement(), _boundaryElement, _fallbackPlacements, _floatingBoundary, _referenceBoundary, _zOffsetProp, childProp, content, disabled, matchReferenceWidth, modal, open, paddingProp, portal, referenceElement, restProps, scheme, t0, t1, t10, t11, t2, t3, t4, t5, t6, t7, t8, t9, updateRef;
1550
- if ($[0] !== props) {
1551
- let { __unstable_margins: t12, animate: t13, arrow: t14, boundaryElement: t15, children: t16, constrainSize: t17, content: t18, disabled: t19, fallbackPlacements: t20, matchReferenceWidth: t21, floatingBoundary: t22, modal: t23, onActivate, open: t24, overflow: t25, padding: t26, placement: t27, placementStrategy: t28, portal: t29, preventOverflow: t30, radius: t31, referenceBoundary: t32, referenceElement: t33, scheme: t34, shadow: t35, tone: t36, width: t37, zOffset: t38, updateRef: t39, ...t40 } = props;
1552
- t0 = t12, t1 = t13, t2 = t14, _boundaryElement = t15, childProp = t16, t3 = t17, content = t18, disabled = t19, _fallbackPlacements = t20, matchReferenceWidth = t21, _floatingBoundary = t22, modal = t23, open = t24, t4 = t25, paddingProp = t26, t5 = t27, t6 = t28, portal = t29, t7 = t30, t8 = t31, _referenceBoundary = t32, referenceElement = t33, scheme = t34, t9 = t35, t10 = t36, t11 = t37, _zOffsetProp = t38, updateRef = t39, restProps = t40, $[0] = props, $[1] = _boundaryElement, $[2] = _fallbackPlacements, $[3] = _floatingBoundary, $[4] = _referenceBoundary, $[5] = _zOffsetProp, $[6] = childProp, $[7] = content, $[8] = disabled, $[9] = matchReferenceWidth, $[10] = modal, $[11] = open, $[12] = paddingProp, $[13] = portal, $[14] = referenceElement, $[15] = restProps, $[16] = scheme, $[17] = t0, $[18] = t1, $[19] = t10, $[20] = t11, $[21] = t2, $[22] = t3, $[23] = t4, $[24] = t5, $[25] = t6, $[26] = t7, $[27] = t8, $[28] = t9, $[29] = updateRef;
1553
- } else _boundaryElement = $[1], _fallbackPlacements = $[2], _floatingBoundary = $[3], _referenceBoundary = $[4], _zOffsetProp = $[5], childProp = $[6], content = $[7], disabled = $[8], matchReferenceWidth = $[9], modal = $[10], open = $[11], paddingProp = $[12], portal = $[13], referenceElement = $[14], restProps = $[15], scheme = $[16], t0 = $[17], t1 = $[18], t10 = $[19], t11 = $[20], t2 = $[21], t3 = $[22], t4 = $[23], t5 = $[24], t6 = $[25], t7 = $[26], t8 = $[27], t9 = $[28], updateRef = $[29];
1554
- let margins = t0 === void 0 ? DEFAULT_POPOVER_MARGINS : t0, _animate = t1 !== void 0 && t1, arrowProp = t2 !== void 0 && t2, constrainSize = t3 !== void 0 && t3, overflow = t4 === void 0 ? "hidden" : t4, placementProp = t5 === void 0 ? "bottom" : t5, placementStrategy = t6 === void 0 ? "flip" : t6, preventOverflow = t7 === void 0 || t7, radiusProp = t8 === void 0 ? 3 : t8, shadowProp = t9 === void 0 ? 3 : t9, tone = t10 === void 0 ? "inherit" : t10, widthProp = t11 === void 0 ? "auto" : t11, boundaryElement = _boundaryElement ?? boundaryElementContext?.element, fallbackPlacements = _fallbackPlacements ?? DEFAULT_FALLBACK_PLACEMENTS$1[props.placement ?? "bottom"], floatingBoundary = _floatingBoundary ?? props.boundaryElement ?? boundaryElementContext.element, referenceBoundary = _referenceBoundary ?? props.boundaryElement ?? boundaryElementContext.element, zOffsetProp = _zOffsetProp ?? layer.popover.zOffset, animate = !usePrefersReducedMotion() && _animate, boundarySize = useElementSize(boundaryElement)?.border, t12;
1555
- $[30] === paddingProp ? t12 = $[31] : (t12 = _getArrayProp(paddingProp), $[30] = paddingProp, $[31] = t12);
1556
- let padding = t12, t13;
1557
- $[32] === radiusProp ? t13 = $[33] : (t13 = _getArrayProp(radiusProp), $[32] = radiusProp, $[33] = t13);
1558
- let radius = t13, t14;
1559
- $[34] === shadowProp ? t14 = $[35] : (t14 = _getArrayProp(shadowProp), $[34] = shadowProp, $[35] = t14);
1560
- let shadow = t14, widthArrayProp = _getArrayProp(widthProp), t15;
1561
- $[36] === zOffsetProp ? t15 = $[37] : (t15 = _getArrayProp(zOffsetProp), $[36] = zOffsetProp, $[37] = t15);
1562
- let zOffset = t15, ref = useRef(null), arrowRef = useRef(null), t16;
1563
- $[38] === Symbol.for("react.memo_cache_sentinel") ? (t16 = () => ref.current, $[38] = t16) : t16 = $[38], useImperativeHandle(forwardedRef, t16);
1564
- let mediaIndex = useMediaIndex(), boundaryWidth = constrainSize || preventOverflow ? boundarySize?.width : void 0, width = calcCurrentWidth({
1565
- container,
1566
- mediaIndex,
1567
- width: widthArrayProp
1568
- }), widthRef = useRef(width), t17, t18;
1569
- $[39] === width ? (t17 = $[40], t18 = $[41]) : (t17 = () => {
1570
- widthRef.current = width;
1571
- }, t18 = [width], $[39] = width, $[40] = t17, $[41] = t18), useEffect(t17, t18);
1572
- let t19;
1573
- $[42] !== boundaryWidth || $[43] !== width ? (t19 = calcMaxWidth({
1574
- boundaryWidth,
1575
- currentWidth: width
1576
- }), $[42] = boundaryWidth, $[43] = width, $[44] = t19) : t19 = $[44];
1577
- let maxWidth = t19, maxWidthRef = useRef(maxWidth), t20, t21;
1578
- $[45] === maxWidth ? (t20 = $[46], t21 = $[47]) : (t20 = () => {
1579
- maxWidthRef.current = maxWidth;
1580
- }, t21 = [maxWidth], $[45] = maxWidth, $[46] = t20, $[47] = t21), useEffect(t20, t21);
1581
- let referenceWidthRef = useRef(void 0), t22, t23;
1582
- $[48] !== matchReferenceWidth || $[49] !== maxWidth || $[50] !== open || $[51] !== width ? (t22 = () => {
1583
- let floatingElement = ref.current;
1584
- if (!open || !floatingElement) return;
1585
- let referenceWidth = referenceWidthRef.current;
1586
- matchReferenceWidth ? referenceWidth !== void 0 && (floatingElement.style.width = `${referenceWidth}px`) : width !== void 0 && (floatingElement.style.width = `${width}px`), typeof maxWidth == "number" && (floatingElement.style.maxWidth = `${maxWidth}px`);
1587
- }, t23 = [
1588
- width,
1589
- matchReferenceWidth,
1590
- maxWidth,
1591
- open
1592
- ], $[48] = matchReferenceWidth, $[49] = maxWidth, $[50] = open, $[51] = width, $[52] = t22, $[53] = t23) : (t22 = $[52], t23 = $[53]), useEffect(t22, t23);
1593
- let [referenceWidth_0, setReferenceWidth] = useState(void 0), t24;
1594
- $[54] !== animate || $[55] !== arrowProp || $[56] !== constrainSize || $[57] !== fallbackPlacements || $[58] !== floatingBoundary || $[59] !== margins || $[60] !== matchReferenceWidth || $[61] !== placementProp || $[62] !== placementStrategy || $[63] !== preventOverflow || $[64] !== referenceBoundary ? (t24 = {
1595
- animate,
1596
- arrowProp,
1597
- arrowRef,
1598
- constrainSize,
1599
- fallbackPlacements,
1600
- floatingBoundary,
1601
- margins,
1602
- matchReferenceWidth,
1603
- maxWidthRef,
1604
- placementProp,
1605
- placementStrategy,
1606
- preventOverflow,
1607
- referenceBoundary,
1608
- referenceWidthRef,
1609
- rootBoundary: "viewport",
1610
- setReferenceWidth,
1611
- widthRef
1612
- }, $[54] = animate, $[55] = arrowProp, $[56] = constrainSize, $[57] = fallbackPlacements, $[58] = floatingBoundary, $[59] = margins, $[60] = matchReferenceWidth, $[61] = placementProp, $[62] = placementStrategy, $[63] = preventOverflow, $[64] = referenceBoundary, $[65] = t24) : t24 = $[65];
1613
- let middleware = useMiddleware$1(t24), t25;
1614
- $[66] === referenceElement ? t25 = $[67] : (t25 = referenceElement ? { reference: referenceElement } : void 0, $[66] = referenceElement, $[67] = t25);
1615
- let t26;
1616
- $[68] !== middleware || $[69] !== placementProp || $[70] !== t25 ? (t26 = {
1617
- middleware,
1618
- placement: placementProp,
1619
- whileElementsMounted: autoUpdate,
1620
- elements: t25
1621
- }, $[68] = middleware, $[69] = placementProp, $[70] = t25, $[71] = t26) : t26 = $[71];
1622
- let { x, y, middlewareData, placement, refs, strategy, update } = useFloating(t26), referenceHidden = middlewareData.hide?.referenceHidden, arrowX = middlewareData.arrow?.x, arrowY = middlewareData.arrow?.y, originX = middlewareData["@sanity/ui/origin"]?.originX, originY = middlewareData["@sanity/ui/origin"]?.originY, t27;
1623
- $[72] === Symbol.for("react.memo_cache_sentinel") ? (t27 = (arrowEl) => {
1624
- arrowRef.current = arrowEl;
1625
- }, $[72] = t27) : t27 = $[72];
1626
- let setArrow = t27, t28;
1627
- $[73] === refs ? t28 = $[74] : (t28 = (node) => {
1628
- ref.current = node, refs.setFloating(node);
1629
- }, $[73] = refs, $[74] = t28);
1630
- let setFloating = t28, t29;
1631
- $[75] === childProp ? t29 = $[76] : (t29 = childProp ? getElementRef(childProp) : null, $[75] = childProp, $[76] = t29);
1632
- let t30;
1633
- $[77] === refs.reference.current ? t30 = $[78] : (t30 = () => refs.reference.current, $[77] = refs.reference.current, $[78] = t30), useImperativeHandle(t29, t30);
1634
- let t31;
1635
- bb0: {
1636
- if (referenceElement) {
1637
- t31 = childProp;
1638
- break bb0;
1639
- }
1640
- if (!childProp) {
1641
- t31 = null;
1642
- break bb0;
1643
- }
1644
- let t32;
1645
- $[79] !== childProp || $[80] !== refs.setReference ? (t32 = cloneElement(childProp, { ref: refs.setReference }), $[79] = childProp, $[80] = refs.setReference, $[81] = t32) : t32 = $[81], t31 = t32;
1646
- }
1647
- let child = t31, t32, t33;
1648
- if ($[82] === update ? (t32 = $[83], t33 = $[84]) : (t32 = () => update, t33 = [update], $[82] = update, $[83] = t32, $[84] = t33), useImperativeHandle(updateRef, t32, t33), disabled) {
1649
- let t34;
1650
- return $[85] === childProp ? t34 = $[86] : (t34 = childProp || /* @__PURE__ */ jsx(Fragment$1, {}), $[85] = childProp, $[86] = t34), t34;
1651
- }
1652
- let t34;
1653
- $[87] === modal ? t34 = $[88] : (t34 = modal && /* @__PURE__ */ jsx(ViewportOverlay, {}), $[87] = modal, $[88] = t34);
1654
- let t35 = matchReferenceWidth ? referenceWidth_0 : width, t36;
1655
- $[89] !== animate || $[90] !== arrowProp || $[91] !== arrowX || $[92] !== arrowY || $[93] !== content || $[94] !== margins || $[95] !== originX || $[96] !== originY || $[97] !== overflow || $[98] !== padding || $[99] !== placement || $[100] !== radius || $[101] !== referenceHidden || $[102] !== restProps || $[103] !== scheme || $[104] !== setFloating || $[105] !== shadow || $[106] !== strategy || $[107] !== t35 || $[108] !== tone || $[109] !== x || $[110] !== y ? (t36 = /* @__PURE__ */ jsx(PopoverCard, {
1656
- ...restProps,
1657
- __unstable_margins: margins,
1658
- animate,
1659
- arrow: arrowProp,
1660
- arrowRef: setArrow,
1661
- arrowX,
1662
- arrowY,
1663
- hidden: referenceHidden,
1664
- overflow,
1665
- padding,
1666
- placement,
1667
- radius,
1668
- ref: setFloating,
1669
- scheme,
1670
- shadow,
1671
- originX,
1672
- originY,
1673
- strategy,
1674
- tone,
1675
- width: t35,
1676
- x,
1677
- y,
1678
- children: content
1679
- }), $[89] = animate, $[90] = arrowProp, $[91] = arrowX, $[92] = arrowY, $[93] = content, $[94] = margins, $[95] = originX, $[96] = originY, $[97] = overflow, $[98] = padding, $[99] = placement, $[100] = radius, $[101] = referenceHidden, $[102] = restProps, $[103] = scheme, $[104] = setFloating, $[105] = shadow, $[106] = strategy, $[107] = t35, $[108] = tone, $[109] = x, $[110] = y, $[111] = t36) : t36 = $[111];
1680
- let t37;
1681
- $[112] !== t34 || $[113] !== t36 || $[114] !== zOffset ? (t37 = /* @__PURE__ */ jsxs(LayerProvider, {
1682
- zOffset,
1683
- children: [t34, t36]
1684
- }), $[112] = t34, $[113] = t36, $[114] = zOffset, $[115] = t37) : t37 = $[115];
1685
- let popover = t37, t38;
1686
- $[116] !== open || $[117] !== popover || $[118] !== portal ? (t38 = open && (portal ? /* @__PURE__ */ jsx(Portal, {
1687
- __unstable_name: typeof portal == "string" ? portal : void 0,
1688
- children: popover
1689
- }) : popover), $[116] = open, $[117] = popover, $[118] = portal, $[119] = t38) : t38 = $[119];
1690
- let children = t38, t39;
1691
- $[120] !== animate || $[121] !== children ? (t39 = animate ? /* @__PURE__ */ jsx(AnimatePresence, { children }) : children, $[120] = animate, $[121] = children, $[122] = t39) : t39 = $[122];
1692
- let t40;
1693
- return $[123] !== child || $[124] !== t39 ? (t40 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t39, child] }), $[123] = child, $[124] = t39, $[125] = t40) : t40 = $[125], t40;
1694
- });
1695
- function useMiddleware$1(t0) {
1696
- let $ = c(42), { animate, arrowProp, arrowRef, constrainSize, fallbackPlacements, floatingBoundary, margins, matchReferenceWidth, maxWidthRef, placementProp, placementStrategy, preventOverflow, referenceBoundary, referenceWidthRef, rootBoundary, setReferenceWidth, widthRef } = t0, ret;
1697
- if ($[0] !== animate || $[1] !== arrowProp || $[2] !== arrowRef || $[3] !== constrainSize || $[4] !== fallbackPlacements || $[5] !== floatingBoundary || $[6] !== margins || $[7] !== matchReferenceWidth || $[8] !== maxWidthRef || $[9] !== placementProp || $[10] !== placementStrategy || $[11] !== preventOverflow || $[12] !== referenceBoundary || $[13] !== referenceWidthRef || $[14] !== rootBoundary || $[15] !== setReferenceWidth || $[16] !== widthRef) {
1698
- if (ret = [], constrainSize || preventOverflow) if (placementStrategy === "autoPlacement") {
1699
- let t1;
1700
- $[18] !== fallbackPlacements || $[19] !== placementProp ? (t1 = autoPlacement({ allowedPlacements: [placementProp].concat(fallbackPlacements) }), $[18] = fallbackPlacements, $[19] = placementProp, $[20] = t1) : t1 = $[20], ret.push(t1);
1701
- } else {
1702
- let t1 = floatingBoundary || void 0, t2;
1703
- $[21] !== fallbackPlacements || $[22] !== rootBoundary || $[23] !== t1 ? (t2 = flip({
1704
- boundary: t1,
1705
- fallbackPlacements,
1706
- padding: 4,
1707
- rootBoundary
1708
- }), $[21] = fallbackPlacements, $[22] = rootBoundary, $[23] = t1, $[24] = t2) : t2 = $[24], ret.push(t2);
1709
- }
1710
- let t1;
1711
- if ($[25] === Symbol.for("react.memo_cache_sentinel") ? (t1 = offset({ mainAxis: 4 }), $[25] = t1) : t1 = $[25], ret.push(t1), constrainSize || matchReferenceWidth) {
1712
- let t2 = floatingBoundary || void 0, t3;
1713
- $[26] !== constrainSize || $[27] !== margins || $[28] !== matchReferenceWidth || $[29] !== maxWidthRef || $[30] !== referenceWidthRef || $[31] !== setReferenceWidth || $[32] !== t2 || $[33] !== widthRef ? (t3 = size({
1714
- boundaryElement: t2,
1715
- constrainSize,
1716
- margins,
1717
- matchReferenceWidth,
1718
- maxWidthRef,
1719
- padding: 4,
1720
- referenceWidthRef,
1721
- setReferenceWidth,
1722
- widthRef
1723
- }), $[26] = constrainSize, $[27] = margins, $[28] = matchReferenceWidth, $[29] = maxWidthRef, $[30] = referenceWidthRef, $[31] = setReferenceWidth, $[32] = t2, $[33] = widthRef, $[34] = t3) : t3 = $[34], ret.push(t3);
1724
- }
1725
- if (preventOverflow) {
1726
- let t2 = floatingBoundary || void 0, t3;
1727
- $[35] !== rootBoundary || $[36] !== t2 ? (t3 = shift({
1728
- boundary: t2,
1729
- rootBoundary,
1730
- padding: 4
1731
- }), $[35] = rootBoundary, $[36] = t2, $[37] = t3) : t3 = $[37], ret.push(t3);
1732
- }
1733
- if (arrowProp) {
1734
- let t2;
1735
- $[38] === arrowRef ? t2 = $[39] : (t2 = arrow({
1736
- element: arrowRef,
1737
- padding: 4
1738
- }), $[38] = arrowRef, $[39] = t2), ret.push(t2);
1739
- }
1740
- animate && ret.push(origin);
1741
- let t2 = referenceBoundary || void 0, t3;
1742
- $[40] === t2 ? t3 = $[41] : (t3 = hide({
1743
- boundary: t2,
1744
- padding: 4,
1745
- strategy: "referenceHidden"
1746
- }), $[40] = t2, $[41] = t3), ret.push(t3), $[0] = animate, $[1] = arrowProp, $[2] = arrowRef, $[3] = constrainSize, $[4] = fallbackPlacements, $[5] = floatingBoundary, $[6] = margins, $[7] = matchReferenceWidth, $[8] = maxWidthRef, $[9] = placementProp, $[10] = placementStrategy, $[11] = preventOverflow, $[12] = referenceBoundary, $[13] = referenceWidthRef, $[14] = rootBoundary, $[15] = setReferenceWidth, $[16] = widthRef, $[17] = ret;
1747
- } else ret = $[17];
1748
- return ret;
1749
- }
1750
- const BASE_STYLE = {
1751
- "&&:not([hidden])": { display: "grid" },
1752
- "&[data-as=\"ul\"],&[data-as=\"ol\"]": { listStyle: "none" },
1753
- gridTemplateColumns: "minmax(0, 1fr)",
1754
- gridAutoRows: "min-content"
1755
- };
1756
- function stackBaseStyle() {
1757
- return BASE_STYLE;
1758
- }
1759
- function responsiveStackSpaceStyle(props) {
1760
- let { media, space } = getTheme_v2(props.theme);
1761
- return _responsive(media, props.$space, (spaceIndex) => ({ gridGap: rem(space[spaceIndex]) }));
1762
- }
1763
- const StyledStack = /* @__PURE__ */ styled(Box).withConfig({
1764
- displayName: "StyledStack",
1765
- componentId: "sc-ux0lrj-0"
1766
- })(stackBaseStyle, responsiveStackSpaceStyle), Stack = forwardRef(function Stack(props, ref) {
1767
- let $ = c(13), as, deprecated_space, gap, restProps;
1768
- $[0] === props ? (as = $[1], deprecated_space = $[2], gap = $[3], restProps = $[4]) : ({as, gap, space: deprecated_space, ...restProps} = props, $[0] = props, $[1] = as, $[2] = deprecated_space, $[3] = gap, $[4] = restProps);
1769
- let spacing = gap === void 0 ? deprecated_space : gap, t0 = typeof as == "string" ? as : void 0, t1;
1770
- $[5] === spacing ? t1 = $[6] : (t1 = _getArrayProp(spacing), $[5] = spacing, $[6] = t1);
1771
- let t2;
1772
- return $[7] !== as || $[8] !== ref || $[9] !== restProps || $[10] !== t0 || $[11] !== t1 ? (t2 = /* @__PURE__ */ jsx(StyledStack, {
1773
- "data-as": t0,
1774
- "data-ui": "Stack",
1775
- ...restProps,
1776
- $space: t1,
1777
- forwardedAs: as,
1778
- ref
1779
- }), $[7] = as, $[8] = ref, $[9] = restProps, $[10] = t0, $[11] = t1, $[12] = t2) : t2 = $[12], t2;
1780
- });
1781
- /**
1782
- * @beta
1783
- */
1784
- function useCustomValidity(ref, customValidity) {
1785
- let $ = c(4), t0, t1;
1786
- $[0] !== customValidity || $[1] !== ref ? (t0 = () => {
1787
- ref.current?.setCustomValidity(customValidity || "");
1788
- }, t1 = [customValidity, ref], $[0] = customValidity, $[1] = ref, $[2] = t0, $[3] = t1) : (t0 = $[2], t1 = $[3]), useEffect(t0, t1);
1789
- }
1790
- function responsiveInputPaddingStyle(props) {
1791
- let { $fontSize, $iconLeft, $iconRight, $padding, $space } = props, { font, media, space } = getTheme_v2(props.theme), len = Math.max($padding.length, $space.length, $fontSize.length), _padding = [], _space = [], _fontSize = [];
1792
- for (let i = 0; i < len; i += 1) _fontSize[i] = $fontSize[i] === void 0 ? _fontSize[i - 1] : $fontSize[i], _padding[i] = $padding[i] === void 0 ? _padding[i - 1] : $padding[i], _space[i] = $space[i] === void 0 ? _space[i - 1] : $space[i];
1793
- return _responsive(media, _padding, (_, i) => {
1794
- let size = font.text.sizes[_fontSize[i]] || font.text.sizes[2], emSize = size.lineHeight - size.ascenderHeight - size.descenderHeight, p = space[_padding[i]], s = space[_space[i]], styles = {
1795
- paddingTop: rem(p - size.ascenderHeight),
1796
- paddingRight: rem(p),
1797
- paddingBottom: rem(p - size.descenderHeight),
1798
- paddingLeft: rem(p)
1799
- };
1800
- return $iconRight && (styles.paddingRight = rem(p + emSize + s)), $iconLeft && (styles.paddingLeft = rem(p + emSize + s)), styles;
1801
- });
1802
- }
1803
- function responsiveInputPaddingIconRightStyle(props) {
1804
- return responsiveInputPaddingStyle({
1805
- ...props,
1806
- $iconRight: !0
1807
- });
1808
- }
1809
- const ROOT_STYLE = css`&:not([hidden]){display:flex;}align-items:center;`;
1810
- function textInputRootStyle() {
1811
- return ROOT_STYLE;
1812
- }
1813
- function textInputBaseStyle(props) {
1814
- let { $scheme, $tone, $weight } = props, { color, font } = getTheme_v2(props.theme);
1815
- return css`appearance:none;background:none;border:0;border-radius:0;outline:none;width:100%;box-sizing:border-box;font-family:${font.text.family};font-weight:${$weight && font.text.weights[$weight] || font.text.weights.regular};margin:0;position:relative;z-index:1;display:block;&:-webkit-autofill,&:-webkit-autofill:hover,&:-webkit-autofill:focus,&:-webkit-autofill:active{-webkit-text-fill-color:var(--input-fg-color) !important;transition:background-color 5000s;transition-delay:86400s;}&[data-as='textarea']{resize:none;}color:var(--input-fg-color);&::placeholder{color:var(--input-placeholder-color);}&[data-scheme='${$scheme}'][data-tone='${$tone}']{--input-fg-color:${color.input.default.enabled.fg};--input-placeholder-color:${color.input.default.enabled.placeholder};&:not(:invalid):not(:disabled):not(:read-only){--input-fg-color:${color.input.default.enabled.fg};--input-placeholder-color:${color.input.default.enabled.placeholder};}&:not(:invalid):disabled{--input-fg-color:${color.input.default.disabled.fg};--input-placeholder-color:${color.input.default.disabled.placeholder};}&:invalid{--input-fg-color:${color.input.invalid.enabled.fg};--input-placeholder-color:${color.input.invalid.enabled.placeholder};}&:read-only{--input-fg-color:${color.input.default.readOnly.fg};--input-placeholder-color:${color.input.default.readOnly.placeholder};}}`;
1816
- }
1817
- function textInputFontSizeStyle(props) {
1818
- let { font, media } = getTheme_v2(props.theme);
1819
- return _responsive(media, props.$fontSize, (sizeIndex) => {
1820
- let size = font.text.sizes[sizeIndex] || font.text.sizes[2];
1821
- return {
1822
- fontSize: rem(size.fontSize),
1823
- lineHeight: `${size.lineHeight / size.fontSize}`
1824
- };
1825
- });
1826
- }
1827
- function textInputRepresentationStyle(props) {
1828
- let { $hasPrefix, $hasSuffix, $scheme, $tone, $unstableDisableFocusRing } = props, { color, input } = getTheme_v2(props.theme);
1829
- return css`--input-box-shadow:none;position:absolute;top:0;left:0;right:0;bottom:0;display:block;pointer-events:none;z-index:0;background-color:var(--card-bg-color);box-shadow:var(--input-box-shadow);border-top-left-radius:${$hasPrefix ? 0 : void 0};border-bottom-left-radius:${$hasPrefix ? 0 : void 0};border-top-right-radius:${$hasSuffix ? 0 : void 0};border-bottom-right-radius:${$hasSuffix ? 0 : void 0};&[data-scheme='${$scheme}'][data-tone='${$tone}']{--card-bg-color:${color.input.default.enabled.bg};--card-fg-color:${color.input.default.enabled.fg};*:not(:disabled) + &[data-border]{--input-box-shadow:${focusRingBorderStyle({
1830
- color: color.input.default.enabled.border,
1831
- width: input.border.width
1832
- })};}*:not(:disabled):invalid + &{--card-bg-color:${color.input.invalid.enabled.bg};--card-fg-color:${color.input.invalid.enabled.fg};&[data-border]{--input-box-shadow:${focusRingBorderStyle({
1833
- color: color.input.invalid.enabled.border,
1834
- width: input.border.width
1835
- })};}}*:not(:disabled):focus + &{&[data-border]{--input-box-shadow:${$unstableDisableFocusRing ? void 0 : focusRingStyle({
1836
- border: {
1837
- color: color.input.default.enabled.border,
1838
- width: input.border.width
1839
- },
1840
- focusRing: input.text.focusRing
1841
- })};}&:not([data-border]){--input-box-shadow:${$unstableDisableFocusRing ? void 0 : focusRingStyle({ focusRing: input.text.focusRing })};}}*:not(:invalid):disabled + &{--card-bg-color:${color.input.default.disabled.bg} !important;--card-fg-color:${color.input.default.disabled.fg} !important;--card-icon-color:${color.input.default.disabled.fg} !important;&[data-border]{--input-box-shadow:${focusRingBorderStyle({
1842
- color: color.input.default.disabled.border,
1843
- width: input.border.width
1844
- })};}}*:invalid:disabled + &{--card-bg-color:${color.input.invalid.disabled.bg} !important;--card-fg-color:${color.input.invalid.disabled.fg} !important;--card-icon-color:${color.input.invalid.disabled.fg} !important;&[data-border]{--input-box-shadow:${focusRingBorderStyle({
1845
- color: color.input.invalid.disabled.border,
1846
- width: input.border.width
1847
- })};}}*:not(:invalid):read-only + &{--card-bg-color:${color.input.default.readOnly.bg} !important;--card-fg-color:${color.input.default.readOnly.fg} !important;}*:invalid:read-only + &{--card-bg-color:${color.input.invalid.readOnly.bg} !important;--card-fg-color:${color.input.invalid.readOnly.fg} !important;}@media (hover:hover){*:not(:disabled):not(:read-only):not(:invalid):hover + &{--card-bg-color:${color.input.default.hovered.bg};--card-fg-color:${color.input.default.hovered.fg};}*:invalid:not(:disabled):not(:read-only):hover + &{--card-bg-color:${color.input.invalid.hovered.bg};--card-fg-color:${color.input.invalid.hovered.fg};}*:not(:disabled):not(:read-only):not(:invalid):not(:focus):hover + &[data-border]{--input-box-shadow:${focusRingBorderStyle({
1848
- color: color.input.default.hovered.border,
1849
- width: input.border.width
1850
- })};}*:invalid:not(:disabled):not(:read-only):not(:focus):hover + &[data-border]{--input-box-shadow:${focusRingBorderStyle({
1851
- color: color.input.invalid.hovered.border,
1852
- width: input.border.width
1853
- })};}}}`;
1854
- }
1855
- const CLEAR_BUTTON_BOX_STYLE = { zIndex: 2 }, StyledTextInput = /* @__PURE__ */ styled(Card).attrs({ forwardedAs: "span" }).withConfig({
1856
- displayName: "StyledTextInput",
1857
- componentId: "sc-7gzsyi-0"
1858
- })(textInputRootStyle), InputRoot = styled.span.withConfig({
1859
- displayName: "InputRoot",
1860
- componentId: "sc-7gzsyi-1"
1861
- })`flex:1;min-width:0;display:block;position:relative;`, Prefix = styled(Card).attrs({ forwardedAs: "span" }).withConfig({
1862
- displayName: "Prefix",
1863
- componentId: "sc-7gzsyi-2"
1864
- })`border-top-right-radius:0;border-bottom-right-radius:0;& > span{display:block;margin:-1px;}`, Suffix = styled(Card).attrs({ forwardedAs: "span" }).withConfig({
1865
- displayName: "Suffix",
1866
- componentId: "sc-7gzsyi-3"
1867
- })`border-top-left-radius:0;border-bottom-left-radius:0;& > span{display:block;margin:-1px;}`, Input = /* @__PURE__ */ styled.input.withConfig({
1868
- displayName: "Input",
1869
- componentId: "sc-7gzsyi-4"
1870
- })(responsiveInputPaddingStyle, textInputBaseStyle, textInputFontSizeStyle), Presentation = /* @__PURE__ */ styled.span.withConfig({
1871
- displayName: "Presentation",
1872
- componentId: "sc-7gzsyi-5"
1873
- })(responsiveRadiusStyle, textInputRepresentationStyle), LeftBox = styled(Box).withConfig({
1874
- displayName: "LeftBox",
1875
- componentId: "sc-7gzsyi-6"
1876
- })`position:absolute;top:0;left:0;`, RightBox = styled(Box).withConfig({
1877
- displayName: "RightBox",
1878
- componentId: "sc-7gzsyi-7"
1879
- })`position:absolute;top:0;right:0;`, RightCard = styled(Card).withConfig({
1880
- displayName: "RightCard",
1881
- componentId: "sc-7gzsyi-8"
1882
- })`background-color:transparent;position:absolute;top:0;right:0;`, TextInputClearButton = /* @__PURE__ */ styled(Button).withConfig({
1883
- displayName: "TextInputClearButton",
1884
- componentId: "sc-7gzsyi-9"
1885
- })({ "&:not([hidden])": { display: "block" } }), TextInput = forwardRef(function TextInput(props, forwardedRef) {
1886
- let $ = c(93), IconComponent, IconRightComponent, __unstable_disableFocusRing, clearButton, customValidity, gap, onClear, prefix, readOnly, restProps, suffix, t0, t1, t2, t3, t4, t5, t6, weight;
1887
- $[0] === props ? (IconComponent = $[1], IconRightComponent = $[2], __unstable_disableFocusRing = $[3], clearButton = $[4], customValidity = $[5], gap = $[6], onClear = $[7], prefix = $[8], readOnly = $[9], restProps = $[10], suffix = $[11], t0 = $[12], t1 = $[13], t2 = $[14], t3 = $[15], t4 = $[16], t5 = $[17], t6 = $[18], weight = $[19]) : ({__unstable_disableFocusRing, border: t0, clearButton, disabled: t1, fontSize: t2, gap, icon: IconComponent, iconRight: IconRightComponent, onClear, padding: t3, prefix, radius: t4, readOnly, space: t5, suffix, customValidity, type: t6, weight, ...restProps} = props, $[0] = props, $[1] = IconComponent, $[2] = IconRightComponent, $[3] = __unstable_disableFocusRing, $[4] = clearButton, $[5] = customValidity, $[6] = gap, $[7] = onClear, $[8] = prefix, $[9] = readOnly, $[10] = restProps, $[11] = suffix, $[12] = t0, $[13] = t1, $[14] = t2, $[15] = t3, $[16] = t4, $[17] = t5, $[18] = t6, $[19] = weight);
1888
- let border = t0 === void 0 || t0, disabled = t1 !== void 0 && t1, fontSizeProp = t2 === void 0 ? 2 : t2, paddingProp = t3 === void 0 ? 3 : t3, radiusProp = t4 === void 0 ? 2 : t4, deprecated_space = t5 === void 0 ? 3 : t5, type = t6 === void 0 ? "text" : t6, ref = useRef(null), rootTheme = useRootTheme(), t7;
1889
- $[20] === fontSizeProp ? t7 = $[21] : (t7 = _getArrayProp(fontSizeProp), $[20] = fontSizeProp, $[21] = t7);
1890
- let fontSize = t7, t8;
1891
- $[22] === paddingProp ? t8 = $[23] : (t8 = _getArrayProp(paddingProp), $[22] = paddingProp, $[23] = t8);
1892
- let padding = t8, t9;
1893
- $[24] === radiusProp ? t9 = $[25] : (t9 = _getArrayProp(radiusProp), $[24] = radiusProp, $[25] = t9);
1894
- let radius = t9, t10 = gap === void 0 ? deprecated_space : gap, t11;
1895
- $[26] === t10 ? t11 = $[27] : (t11 = _getArrayProp(t10), $[26] = t10, $[27] = t11);
1896
- let space = t11, $hasClearButton = !!clearButton, $hasIcon = !!IconComponent, $hasIconRight = !!IconRightComponent, $hasSuffix = !!suffix, $hasPrefix = !!prefix, t12;
1897
- $[28] === Symbol.for("react.memo_cache_sentinel") ? (t12 = () => ref.current, $[28] = t12) : t12 = $[28], useImperativeHandle(forwardedRef, t12), useCustomValidity(ref, customValidity);
1898
- let handleClearMouseDown = _temp$6, t13;
1899
- $[29] === onClear ? t13 = $[30] : (t13 = (event_0) => {
1900
- event_0.preventDefault(), event_0.stopPropagation(), onClear && onClear(), ref.current?.focus();
1901
- }, $[29] = onClear, $[30] = t13);
1902
- let handleClearClick = t13, t14;
1903
- $[31] !== prefix || $[32] !== radius ? (t14 = prefix && /* @__PURE__ */ jsx(Prefix, {
1904
- borderTop: !0,
1905
- borderLeft: !0,
1906
- borderBottom: !0,
1907
- radius,
1908
- sizing: "border",
1909
- tone: "inherit",
1910
- children: /* @__PURE__ */ jsx("span", { children: prefix })
1911
- }), $[31] = prefix, $[32] = radius, $[33] = t14) : t14 = $[33];
1912
- let prefixNode = t14, t15 = border ? "" : void 0, t16;
1913
- $[34] !== IconComponent || $[35] !== fontSize || $[36] !== padding ? (t16 = IconComponent && /* @__PURE__ */ jsx(LeftBox, {
1914
- padding,
1915
- children: /* @__PURE__ */ jsxs(Text, {
1916
- size: fontSize,
1917
- children: [isValidElement(IconComponent) && IconComponent, isValidElementType(IconComponent) && /* @__PURE__ */ jsx(IconComponent, {})]
1918
- })
1919
- }), $[34] = IconComponent, $[35] = fontSize, $[36] = padding, $[37] = t16) : t16 = $[37];
1920
- let t17;
1921
- $[38] !== $hasClearButton || $[39] !== IconRightComponent || $[40] !== fontSize || $[41] !== padding ? (t17 = !$hasClearButton && IconRightComponent && /* @__PURE__ */ jsx(RightBox, {
1922
- padding,
1923
- children: /* @__PURE__ */ jsxs(Text, {
1924
- size: fontSize,
1925
- children: [isValidElement(IconRightComponent) && IconRightComponent, isValidElementType(IconRightComponent) && /* @__PURE__ */ jsx(IconRightComponent, {})]
1926
- })
1927
- }), $[38] = $hasClearButton, $[39] = IconRightComponent, $[40] = fontSize, $[41] = padding, $[42] = t17) : t17 = $[42];
1928
- let t18;
1929
- $[43] !== $hasPrefix || $[44] !== $hasSuffix || $[45] !== __unstable_disableFocusRing || $[46] !== radius || $[47] !== rootTheme.scheme || $[48] !== rootTheme.tone || $[49] !== t15 || $[50] !== t16 || $[51] !== t17 ? (t18 = /* @__PURE__ */ jsxs(Presentation, {
1930
- $hasPrefix,
1931
- $unstableDisableFocusRing: __unstable_disableFocusRing,
1932
- $hasSuffix,
1933
- $radius: radius,
1934
- $scheme: rootTheme.scheme,
1935
- $tone: rootTheme.tone,
1936
- "data-border": t15,
1937
- "data-scheme": rootTheme.scheme,
1938
- "data-tone": rootTheme.tone,
1939
- children: [t16, t17]
1940
- }), $[43] = $hasPrefix, $[44] = $hasSuffix, $[45] = __unstable_disableFocusRing, $[46] = radius, $[47] = rootTheme.scheme, $[48] = rootTheme.tone, $[49] = t15, $[50] = t16, $[51] = t17, $[52] = t18) : t18 = $[52];
1941
- let presentationNode = t18, t19;
1942
- $[53] === padding ? t19 = $[54] : (t19 = padding.map(_temp2$1), $[53] = padding, $[54] = t19);
1943
- let clearButtonBoxPadding = t19, t20;
1944
- $[55] === padding ? t20 = $[56] : (t20 = padding.map(_temp3), $[55] = padding, $[56] = t20);
1945
- let clearButtonPadding = t20, clearButtonProps = typeof clearButton == "object" ? clearButton : EMPTY_RECORD, t21;
1946
- $[57] !== clearButton || $[58] !== clearButtonBoxPadding || $[59] !== clearButtonPadding || $[60] !== clearButtonProps || $[61] !== customValidity || $[62] !== disabled || $[63] !== fontSize || $[64] !== handleClearClick || $[65] !== radius || $[66] !== readOnly ? (t21 = !disabled && !readOnly && clearButton && /* @__PURE__ */ jsx(RightCard, {
1947
- forwardedAs: "span",
1948
- padding: clearButtonBoxPadding,
1949
- style: CLEAR_BUTTON_BOX_STYLE,
1950
- tone: customValidity ? "critical" : "inherit",
1951
- children: /* @__PURE__ */ jsx(TextInputClearButton, {
1952
- "aria-label": "Clear",
1953
- "data-qa": "clear-button",
1954
- fontSize,
1955
- icon: CloseIcon,
1956
- mode: "bleed",
1957
- padding: clearButtonPadding,
1958
- radius,
1959
- ...clearButtonProps,
1960
- onClick: handleClearClick,
1961
- onMouseDown: handleClearMouseDown
1962
- })
1963
- }), $[57] = clearButton, $[58] = clearButtonBoxPadding, $[59] = clearButtonPadding, $[60] = clearButtonProps, $[61] = customValidity, $[62] = disabled, $[63] = fontSize, $[64] = handleClearClick, $[65] = radius, $[66] = readOnly, $[67] = t21) : t21 = $[67];
1964
- let clearButtonNode = t21, t22;
1965
- $[68] !== radius || $[69] !== suffix ? (t22 = suffix && /* @__PURE__ */ jsx(Suffix, {
1966
- borderTop: !0,
1967
- borderRight: !0,
1968
- borderBottom: !0,
1969
- radius,
1970
- sizing: "border",
1971
- tone: "inherit",
1972
- children: /* @__PURE__ */ jsx("span", { children: suffix })
1973
- }), $[68] = radius, $[69] = suffix, $[70] = t22) : t22 = $[70];
1974
- let suffixNode = t22, t23 = $hasIconRight || $hasClearButton, t24;
1975
- $[71] !== $hasIcon || $[72] !== disabled || $[73] !== fontSize || $[74] !== padding || $[75] !== readOnly || $[76] !== restProps || $[77] !== rootTheme.scheme || $[78] !== rootTheme.tone || $[79] !== space || $[80] !== t23 || $[81] !== type || $[82] !== weight ? (t24 = /* @__PURE__ */ jsx(Input, {
1976
- "data-as": "input",
1977
- "data-scheme": rootTheme.scheme,
1978
- "data-tone": rootTheme.tone,
1979
- ...restProps,
1980
- $fontSize: fontSize,
1981
- $iconLeft: $hasIcon,
1982
- $iconRight: t23,
1983
- $padding: padding,
1984
- $scheme: rootTheme.scheme,
1985
- $space: space,
1986
- $tone: rootTheme.tone,
1987
- $weight: weight,
1988
- disabled,
1989
- readOnly,
1990
- ref,
1991
- type
1992
- }), $[71] = $hasIcon, $[72] = disabled, $[73] = fontSize, $[74] = padding, $[75] = readOnly, $[76] = restProps, $[77] = rootTheme.scheme, $[78] = rootTheme.tone, $[79] = space, $[80] = t23, $[81] = type, $[82] = weight, $[83] = t24) : t24 = $[83];
1993
- let t25;
1994
- $[84] !== clearButtonNode || $[85] !== presentationNode || $[86] !== t24 ? (t25 = /* @__PURE__ */ jsxs(InputRoot, { children: [
1995
- t24,
1996
- presentationNode,
1997
- clearButtonNode
1998
- ] }), $[84] = clearButtonNode, $[85] = presentationNode, $[86] = t24, $[87] = t25) : t25 = $[87];
1999
- let t26;
2000
- return $[88] !== prefixNode || $[89] !== rootTheme.tone || $[90] !== suffixNode || $[91] !== t25 ? (t26 = /* @__PURE__ */ jsxs(StyledTextInput, {
2001
- "data-ui": "TextInput",
2002
- tone: rootTheme.tone,
2003
- children: [
2004
- prefixNode,
2005
- t25,
2006
- suffixNode
2007
- ]
2008
- }), $[88] = prefixNode, $[89] = rootTheme.tone, $[90] = suffixNode, $[91] = t25, $[92] = t26) : t26 = $[92], t26;
2009
- });
2010
- function _temp$6(event) {
2011
- event.preventDefault(), event.stopPropagation();
2012
- }
2013
- function _temp2$1(v) {
2014
- return v === 0 ? 0 : v === 1 || v === 2 ? 1 : v - 2;
2015
- }
2016
- function _temp3(v_0) {
2017
- return v_0 === 0 || v_0 === 1 ? 0 : v_0 === 2 ? 1 : v_0 - 1;
2018
- }
2019
- /**
2020
- * @public
2021
- */
2022
- function useClickOutsideEvent(listener, t0, boundaryElement) {
2023
- let $ = c(9), elementsArg = t0 === void 0 ? _temp$5 : t0, t1;
2024
- $[0] !== boundaryElement || $[1] !== elementsArg || $[2] !== listener ? (t1 = (evt) => {
2025
- if (!listener) return;
2026
- let target = evt.target;
2027
- if (!(target instanceof Node)) return;
2028
- let resolvedBoundaryElement = boundaryElement?.();
2029
- if (resolvedBoundaryElement && !resolvedBoundaryElement.contains(target)) return;
2030
- let elements = elementsArg().flat();
2031
- for (let el of elements) if (el && (target === el || el.contains(target))) return;
2032
- listener(evt);
2033
- }, $[0] = boundaryElement, $[1] = elementsArg, $[2] = listener, $[3] = t1) : t1 = $[3];
2034
- let onEvent = useEffectEvent(t1), hasListener = !!listener, t2;
2035
- $[4] !== hasListener || $[5] !== onEvent ? (t2 = () => {
2036
- if (!hasListener) return;
2037
- let handleEvent = (evt_0) => onEvent(evt_0);
2038
- return document.addEventListener("mousedown", handleEvent), () => {
2039
- document.removeEventListener("mousedown", handleEvent);
2040
- };
2041
- }, $[4] = hasListener, $[5] = onEvent, $[6] = t2) : t2 = $[6];
2042
- let t3;
2043
- $[7] === hasListener ? t3 = $[8] : (t3 = [hasListener], $[7] = hasListener, $[8] = t3), useEffect(t2, t3), useDebugValue(listener ? "MouseDown On" : "MouseDown Off");
2044
- }
2045
- function _temp$5() {
2046
- return EMPTY_ARRAY;
2047
- }
2048
- /**
2049
- * Adds global keydown event listener to the window.
2050
- *
2051
- * @param onKeyDown - The function to call when a keydown event is triggered.
2052
- * @param options - The options to pass to the addEventListener function (example, capture: true)
2053
- * @beta
2054
- */
2055
- function useGlobalKeyDown(onKeyDown, options) {
2056
- let $ = c(7), t0;
2057
- $[0] === onKeyDown ? t0 = $[1] : (t0 = (event) => onKeyDown(event), $[0] = onKeyDown, $[1] = t0);
2058
- let handleKeyDown = useEffectEvent(t0), t1;
2059
- $[2] !== handleKeyDown || $[3] !== options ? (t1 = () => {
2060
- let handler = (event_0) => handleKeyDown(event_0);
2061
- return window.addEventListener("keydown", handler, options), () => window.removeEventListener("keydown", handler, options);
2062
- }, $[2] = handleKeyDown, $[3] = options, $[4] = t1) : t1 = $[4];
2063
- let t2;
2064
- $[5] === options ? t2 = $[6] : (t2 = [options], $[5] = options, $[6] = t2), useEffect(t1, t2);
2065
- }
2066
- const StyledLayer = /* @__PURE__ */ styled.div.withConfig({
2067
- displayName: "StyledLayer",
2068
- componentId: "sc-c59p9w-0"
2069
- })({ position: "relative" }), LayerChildren = forwardRef(function LayerChildren(props, forwardedRef) {
2070
- let $ = c(22), children, onActivate, onFocus, restProps, t0;
2071
- $[0] === props ? (children = $[1], onActivate = $[2], onFocus = $[3], restProps = $[4], t0 = $[5]) : ({children, onActivate, onFocus, style: t0, ...restProps} = props, $[0] = props, $[1] = children, $[2] = onActivate, $[3] = onFocus, $[4] = restProps, $[5] = t0);
2072
- let style = t0 === void 0 ? EMPTY_RECORD : t0, { zIndex, isTopLayer } = useLayer(), lastFocusedRef = useRef(null), ref = useRef(null), isTopLayerRef = useRef(isTopLayer), t1;
2073
- $[6] === Symbol.for("react.memo_cache_sentinel") ? (t1 = () => ref.current, $[6] = t1) : t1 = $[6], useImperativeHandle(forwardedRef, t1);
2074
- let t2, t3;
2075
- $[7] !== isTopLayer || $[8] !== onActivate ? (t2 = () => {
2076
- isTopLayerRef.current !== isTopLayer && isTopLayer && onActivate?.({ activeElement: lastFocusedRef.current }), isTopLayerRef.current = isTopLayer;
2077
- }, t3 = [isTopLayer, onActivate], $[7] = isTopLayer, $[8] = onActivate, $[9] = t2, $[10] = t3) : (t2 = $[9], t3 = $[10]), useEffect(t2, t3);
2078
- let t4;
2079
- $[11] !== isTopLayer || $[12] !== onFocus ? (t4 = (event) => {
2080
- onFocus?.(event);
2081
- let rootElement = ref.current, target = document.activeElement;
2082
- !isTopLayer || !rootElement || !target || isHTMLElement(target) && containsOrEqualsElement(rootElement, target) && (lastFocusedRef.current = target);
2083
- }, $[11] = isTopLayer, $[12] = onFocus, $[13] = t4) : t4 = $[13];
2084
- let handleFocus = t4, t5;
2085
- $[14] !== style || $[15] !== zIndex ? (t5 = {
2086
- ...style,
2087
- zIndex
2088
- }, $[14] = style, $[15] = zIndex, $[16] = t5) : t5 = $[16];
2089
- let t6;
2090
- return $[17] !== children || $[18] !== handleFocus || $[19] !== restProps || $[20] !== t5 ? (t6 = /* @__PURE__ */ jsx(StyledLayer, {
2091
- ...restProps,
2092
- "data-ui": "Layer",
2093
- onFocus: handleFocus,
2094
- ref,
2095
- style: t5,
2096
- children
2097
- }), $[17] = children, $[18] = handleFocus, $[19] = restProps, $[20] = t5, $[21] = t6) : t6 = $[21], t6;
2098
- }), Layer = forwardRef(function Layer(props, ref) {
2099
- let $ = c(11), children, restProps, t0;
2100
- $[0] === props ? (children = $[1], restProps = $[2], t0 = $[3]) : ({children, zOffset: t0, ...restProps} = props, $[0] = props, $[1] = children, $[2] = restProps, $[3] = t0);
2101
- let zOffset = t0 === void 0 ? 1 : t0, t1;
2102
- $[4] !== children || $[5] !== ref || $[6] !== restProps ? (t1 = /* @__PURE__ */ jsx(LayerChildren, {
2103
- ...restProps,
2104
- ref,
2105
- children
2106
- }), $[4] = children, $[5] = ref, $[6] = restProps, $[7] = t1) : t1 = $[7];
2107
- let t2;
2108
- return $[8] !== t1 || $[9] !== zOffset ? (t2 = /* @__PURE__ */ jsx(LayerProvider, {
2109
- zOffset,
2110
- children: t1
2111
- }), $[8] = t1, $[9] = zOffset, $[10] = t2) : t2 = $[10], t2;
2112
- });
2113
- function inlineBaseStyle() {
2114
- return {
2115
- lineHeight: "0",
2116
- "&&:not([hidden])": { display: "block" },
2117
- "& > div": {
2118
- display: "inline-block",
2119
- verticalAlign: "middle"
2120
- }
2121
- };
2122
- }
2123
- function inlineSpaceStyle(props) {
2124
- let { media, space } = getTheme_v2(props.theme);
2125
- return _responsive(media, props.$space, (spaceIndex) => {
2126
- let _space = rem(spaceIndex === .5 ? space[1] / 2 : space[spaceIndex]);
2127
- return {
2128
- margin: `-${_space} 0 0 -${_space}`,
2129
- "& > div": { padding: `${_space} 0 0 ${_space}` }
2130
- };
2131
- });
2132
- }
2133
- const StyledInline = /* @__PURE__ */ styled(Box).withConfig({
2134
- displayName: "StyledInline",
2135
- componentId: "sc-zsbqh7-0"
2136
- })(inlineBaseStyle, inlineSpaceStyle), Inline = forwardRef(function Inline(props, ref) {
2137
- let $ = c(16), as, childrenProp, deprecated_space, gap, restProps;
2138
- $[0] === props ? (as = $[1], childrenProp = $[2], deprecated_space = $[3], gap = $[4], restProps = $[5]) : ({as, children: childrenProp, gap, space: deprecated_space, ...restProps} = props, $[0] = props, $[1] = as, $[2] = childrenProp, $[3] = deprecated_space, $[4] = gap, $[5] = restProps);
2139
- let spacing = gap === void 0 ? deprecated_space : gap, t0;
2140
- $[6] === childrenProp ? t0 = $[7] : (t0 = Children.map(childrenProp, _temp$4), $[6] = childrenProp, $[7] = t0);
2141
- let children = t0, t1;
2142
- $[8] === spacing ? t1 = $[9] : (t1 = _getArrayProp(spacing), $[8] = spacing, $[9] = t1);
2143
- let t2 = ref, t3;
2144
- return $[10] !== as || $[11] !== children || $[12] !== restProps || $[13] !== t1 || $[14] !== t2 ? (t3 = /* @__PURE__ */ jsx(StyledInline, {
2145
- "data-ui": "Inline",
2146
- ...restProps,
2147
- $space: t1,
2148
- forwardedAs: as,
2149
- ref: t2,
2150
- children
2151
- }), $[10] = as, $[11] = children, $[12] = restProps, $[13] = t1, $[14] = t2, $[15] = t3) : t3 = $[15], t3;
2152
- });
2153
- function _temp$4(child) {
2154
- return child && /* @__PURE__ */ jsx("div", { children: child });
2155
- }
2156
- function kbdStyle() {
2157
- return css`--card-bg-color:var(--card-kbd-bg-color);--card-border-color:var(--card-kbd-border-color);--card-fg-color:var(--card-kbd-fg-color);box-shadow:inset 0 0 0 1px var(--card-border-color);background:var(--card-bg-color);font:inherit;vertical-align:top;&:not([hidden]){display:inline-block;}`;
2158
- }
2159
- const StyledKBD = /* @__PURE__ */ styled.kbd.withConfig({
2160
- displayName: "StyledKBD",
2161
- componentId: "sc-xzhxcv-0"
2162
- })(responsiveRadiusStyle, kbdStyle), KBD = forwardRef(function KBD(props, ref) {
2163
- let $ = c(19), children, restProps, t0, t1, t2;
2164
- $[0] === props ? (children = $[1], restProps = $[2], t0 = $[3], t1 = $[4], t2 = $[5]) : ({children, fontSize: t0, padding: t1, radius: t2, ...restProps} = props, $[0] = props, $[1] = children, $[2] = restProps, $[3] = t0, $[4] = t1, $[5] = t2);
2165
- let fontSize = t0 === void 0 ? 0 : t0, padding = t1 === void 0 ? 1 : t1, radius = t2 === void 0 ? 2 : t2, t3;
2166
- $[6] === radius ? t3 = $[7] : (t3 = _getArrayProp(radius), $[6] = radius, $[7] = t3);
2167
- let t4;
2168
- $[8] !== children || $[9] !== fontSize ? (t4 = /* @__PURE__ */ jsx(Text, {
2169
- as: "span",
2170
- size: fontSize,
2171
- weight: "semibold",
2172
- children
2173
- }), $[8] = children, $[9] = fontSize, $[10] = t4) : t4 = $[10];
2174
- let t5;
2175
- $[11] !== padding || $[12] !== t4 ? (t5 = /* @__PURE__ */ jsx(Box, {
2176
- as: "span",
2177
- padding,
2178
- children: t4
2179
- }), $[11] = padding, $[12] = t4, $[13] = t5) : t5 = $[13];
2180
- let t6;
2181
- return $[14] !== ref || $[15] !== restProps || $[16] !== t3 || $[17] !== t5 ? (t6 = /* @__PURE__ */ jsx(StyledKBD, {
2182
- "data-ui": "KBD",
2183
- ...restProps,
2184
- $radius: t3,
2185
- ref,
2186
- children: t5
2187
- }), $[14] = ref, $[15] = restProps, $[16] = t3, $[17] = t5, $[18] = t6) : t6 = $[18], t6;
2188
- }), StyledHotkeys = styled.kbd.withConfig({
2189
- displayName: "StyledHotkeys",
2190
- componentId: "sc-1soubc-0"
2191
- })`font:inherit;padding:1px;&:not([hidden]){display:block;}`, Key = styled(KBD).withConfig({
2192
- displayName: "Key",
2193
- componentId: "sc-1soubc-1"
2194
- })`&:not([hidden]){display:block;}`, Hotkeys = forwardRef(function Hotkeys(props, ref) {
2195
- let $ = c(27), fontSize, gap, keys, padding, radius, restProps, t0;
2196
- $[0] === props ? (fontSize = $[1], gap = $[2], keys = $[3], padding = $[4], radius = $[5], restProps = $[6], t0 = $[7]) : ({fontSize, gap, keys, padding, radius, space: t0, ...restProps} = props, $[0] = props, $[1] = fontSize, $[2] = gap, $[3] = keys, $[4] = padding, $[5] = radius, $[6] = restProps, $[7] = t0);
2197
- let t1 = gap === void 0 ? t0 === void 0 ? .5 : t0 : gap, t2;
2198
- $[8] === t1 ? t2 = $[9] : (t2 = _getArrayProp(t1), $[8] = t1, $[9] = t2);
2199
- let spacing = t2;
2200
- if (!keys || keys.length === 0) {
2201
- let t3;
2202
- return $[10] === Symbol.for("react.memo_cache_sentinel") ? (t3 = /* @__PURE__ */ jsx(Fragment$1, {}), $[10] = t3) : t3 = $[10], t3;
2203
- }
2204
- let t3;
2205
- if ($[11] !== fontSize || $[12] !== keys || $[13] !== padding || $[14] !== radius) {
2206
- let t4;
2207
- $[16] !== fontSize || $[17] !== padding || $[18] !== radius ? (t4 = (key, i) => /* @__PURE__ */ jsx(Key, {
2208
- fontSize,
2209
- padding,
2210
- radius,
2211
- children: key
2212
- }, i), $[16] = fontSize, $[17] = padding, $[18] = radius, $[19] = t4) : t4 = $[19], t3 = keys.map(t4), $[11] = fontSize, $[12] = keys, $[13] = padding, $[14] = radius, $[15] = t3;
2213
- } else t3 = $[15];
2214
- let t4;
2215
- $[20] !== spacing || $[21] !== t3 ? (t4 = /* @__PURE__ */ jsx(Inline, {
2216
- as: "span",
2217
- gap: spacing,
2218
- children: t3
2219
- }), $[20] = spacing, $[21] = t3, $[22] = t4) : t4 = $[22];
2220
- let t5;
2221
- return $[23] !== ref || $[24] !== restProps || $[25] !== t4 ? (t5 = /* @__PURE__ */ jsx(StyledHotkeys, {
2222
- "data-ui": "Hotkeys",
2223
- ...restProps,
2224
- ref,
2225
- children: t4
2226
- }), $[23] = ref, $[24] = restProps, $[25] = t4, $[26] = t5) : t5 = $[26], t5;
2227
- }), MenuContext = createGlobalScopedContext("@sanity/ui/context/menu", null);
2228
- /**
2229
- * @internal
2230
- */
2231
- function _isFocusable(element) {
2232
- return isHTMLAnchorElement(element) && element.getAttribute("data-disabled") !== "true" || isHTMLButtonElement(element) && !element.disabled;
2233
- }
2234
- /**
2235
- * @internal
2236
- */
2237
- function _getFocusableElements(elements) {
2238
- return elements.filter(_isFocusable);
2239
- }
2240
- function _getDOMPath(rootElement, el) {
2241
- let path = [], e = el;
2242
- for (; e !== rootElement;) {
2243
- let parentElement = e.parentElement;
2244
- if (!parentElement) return path;
2245
- let index = Array.from(parentElement.childNodes).indexOf(e);
2246
- if (path.unshift(index), parentElement === rootElement) return path;
2247
- e = parentElement;
2248
- }
2249
- return path;
2250
- }
2251
- const EMPTY_PATH = [];
2252
- /**
2253
- * @internal
2254
- */
2255
- function _sortElements(rootElement, elements) {
2256
- if (!rootElement) return;
2257
- let map = /* @__PURE__ */ new WeakMap();
2258
- for (let el of elements) map.set(el, _getDOMPath(rootElement, el));
2259
- let _sort = (a, b) => {
2260
- let _a = map.get(a) || EMPTY_PATH, _b = map.get(b) || EMPTY_PATH, len = Math.max(_a.length, _b.length);
2261
- for (let i = 0; i < len; i += 1) {
2262
- let aIndex = _a[i] || -1, bIndex = _b[i] || -1;
2263
- if (aIndex !== bIndex) return aIndex - bIndex;
2264
- }
2265
- return 0;
2266
- };
2267
- elements.sort(_sort);
2268
- }
2269
- /**
2270
- * This controller is responsible for controlling UI menu state.
2271
- *
2272
- * @internal
2273
- */
2274
- function useMenuController(props) {
2275
- let $ = c(21), { onKeyDown, originElement, shouldFocus, rootElementRef } = props, t0;
2276
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = [], $[0] = t0) : t0 = $[0];
2277
- let elementsRef = useRef(t0), [activeIndex, _setActiveIndex] = useState(-1), activeIndexRef = useRef(activeIndex), [activeElement, setActiveElement] = useState(null), t1;
2278
- $[1] === Symbol.for("react.memo_cache_sentinel") ? (t1 = (nextActiveIndex) => {
2279
- _setActiveIndex(nextActiveIndex), activeIndexRef.current = nextActiveIndex, setActiveElement(elementsRef.current[nextActiveIndex] || null);
2280
- }, $[1] = t1) : t1 = $[1];
2281
- let setActiveIndex = t1, t2;
2282
- $[2] === rootElementRef ? t2 = $[3] : (t2 = (element, selected) => {
2283
- if (!element) return _temp$3;
2284
- if (elementsRef.current.indexOf(element) === -1 && (elementsRef.current.push(element), _sortElements(rootElementRef.current, elementsRef.current)), selected) {
2285
- let selectedIndex = elementsRef.current.indexOf(element);
2286
- setActiveIndex(selectedIndex);
2287
- }
2288
- return () => {
2289
- let idx = elementsRef.current.indexOf(element);
2290
- idx > -1 && elementsRef.current.splice(idx, 1);
2291
- };
2292
- }, $[2] = rootElementRef, $[3] = t2);
2293
- let mount = t2, t3;
2294
- $[4] !== onKeyDown || $[5] !== originElement ? (t3 = (event) => {
2295
- if (event.key === "Tab") {
2296
- originElement && originElement.focus();
2297
- return;
2298
- }
2299
- if (event.key === "Home") {
2300
- event.preventDefault(), event.stopPropagation();
2301
- let el = _getFocusableElements(elementsRef.current)[0];
2302
- if (!el) return;
2303
- let currentIndex = elementsRef.current.indexOf(el);
2304
- setActiveIndex(currentIndex);
2305
- return;
2306
- }
2307
- if (event.key === "End") {
2308
- event.preventDefault(), event.stopPropagation();
2309
- let focusableElements_0 = _getFocusableElements(elementsRef.current), el_0 = focusableElements_0[focusableElements_0.length - 1];
2310
- if (!el_0) return;
2311
- let currentIndex_0 = elementsRef.current.indexOf(el_0);
2312
- setActiveIndex(currentIndex_0);
2313
- return;
2314
- }
2315
- if (event.key === "ArrowUp") {
2316
- event.preventDefault(), event.stopPropagation();
2317
- let focusableElements_1 = _getFocusableElements(elementsRef.current), focusableLen = focusableElements_1.length;
2318
- if (focusableLen === 0) return;
2319
- let focusedElement = elementsRef.current[activeIndexRef.current], focusedIndex = focusableElements_1.indexOf(focusedElement);
2320
- focusedIndex = (focusedIndex - 1 + focusableLen) % focusableLen;
2321
- let el_1 = focusableElements_1[focusedIndex], currentIndex_1 = elementsRef.current.indexOf(el_1);
2322
- setActiveIndex(currentIndex_1);
2323
- return;
2324
- }
2325
- if (event.key === "ArrowDown") {
2326
- event.preventDefault(), event.stopPropagation();
2327
- let focusableElements_2 = _getFocusableElements(elementsRef.current), focusableLen_0 = focusableElements_2.length;
2328
- if (focusableLen_0 === 0) return;
2329
- let focusedElement_0 = elementsRef.current[activeIndexRef.current], focusedIndex_0 = focusableElements_2.indexOf(focusedElement_0);
2330
- focusedIndex_0 = (focusedIndex_0 + 1) % focusableLen_0;
2331
- let el_2 = focusableElements_2[focusedIndex_0], currentIndex_2 = elementsRef.current.indexOf(el_2);
2332
- setActiveIndex(currentIndex_2);
2333
- return;
2334
- }
2335
- onKeyDown && onKeyDown(event);
2336
- }, $[4] = onKeyDown, $[5] = originElement, $[6] = t3) : t3 = $[6];
2337
- let handleKeyDown = t3, t4;
2338
- $[7] === Symbol.for("react.memo_cache_sentinel") ? (t4 = (event_0) => {
2339
- let element_0 = event_0.currentTarget, currentIndex_3 = elementsRef.current.indexOf(element_0);
2340
- setActiveIndex(currentIndex_3);
2341
- }, $[7] = t4) : t4 = $[7];
2342
- let handleItemMouseEnter = t4, t5;
2343
- $[8] === rootElementRef ? t5 = $[9] : (t5 = () => {
2344
- setActiveIndex(-2), rootElementRef.current?.focus();
2345
- }, $[8] = rootElementRef, $[9] = t5);
2346
- let handleItemMouseLeave = t5, t6, t7;
2347
- $[10] !== activeIndex || $[11] !== rootElementRef || $[12] !== shouldFocus ? (t6 = () => {
2348
- if (!rootElementRef.current) return;
2349
- let rafId = requestAnimationFrame(() => {
2350
- if (activeIndex === -1) {
2351
- if (shouldFocus === "first") {
2352
- let el_3 = _getFocusableElements(elementsRef.current)[0];
2353
- if (el_3) {
2354
- let currentIndex_4 = elementsRef.current.indexOf(el_3);
2355
- setActiveIndex(currentIndex_4);
2356
- }
2357
- }
2358
- if (shouldFocus === "last") {
2359
- let focusableElements_4 = _getFocusableElements(elementsRef.current), el_4 = focusableElements_4[focusableElements_4.length - 1];
2360
- if (el_4) {
2361
- let currentIndex_5 = elementsRef.current.indexOf(el_4);
2362
- setActiveIndex(currentIndex_5);
2363
- }
2364
- }
2365
- return;
2366
- }
2367
- (elementsRef.current[activeIndex] || null)?.focus();
2368
- });
2369
- return () => cancelAnimationFrame(rafId);
2370
- }, t7 = [
2371
- activeIndex,
2372
- rootElementRef,
2373
- setActiveIndex,
2374
- shouldFocus
2375
- ], $[10] = activeIndex, $[11] = rootElementRef, $[12] = shouldFocus, $[13] = t6, $[14] = t7) : (t6 = $[13], t7 = $[14]), useEffect(t6, t7);
2376
- let t8;
2377
- return $[15] !== activeElement || $[16] !== activeIndex || $[17] !== handleItemMouseLeave || $[18] !== handleKeyDown || $[19] !== mount ? (t8 = {
2378
- activeElement,
2379
- activeIndex,
2380
- handleItemMouseEnter,
2381
- handleItemMouseLeave,
2382
- handleKeyDown,
2383
- mount
2384
- }, $[15] = activeElement, $[16] = activeIndex, $[17] = handleItemMouseLeave, $[18] = handleKeyDown, $[19] = mount, $[20] = t8) : t8 = $[20], t8;
2385
- }
2386
- function _temp$3() {}
2387
- const StyledMenu = styled(Box).withConfig({
2388
- displayName: "StyledMenu",
2389
- componentId: "sc-xvs9y5-0"
2390
- })`outline:none;overflow:auto;`, Menu = forwardRef(function Menu(props, forwardedRef) {
2391
- let $ = c(50), _shouldFocus, children, gap, onClickOutside, onEscape, onItemClick, onItemSelect, onKeyDown, originElement, registerElement, restProps, t0, t1;
2392
- if ($[0] !== props) {
2393
- let { children: t2, focusFirst, focusLast, onClickOutside: t3, onEscape: t4, onItemClick: t5, onItemSelect: t6, onKeyDown: t7, originElement: t8, padding: t9, registerElement: t10, shouldFocus: t11, gap: t12, space: t13, ...t14 } = props;
2394
- children = t2, onClickOutside = t3, onEscape = t4, onItemClick = t5, onItemSelect = t6, onKeyDown = t7, originElement = t8, t0 = t9, registerElement = t10, _shouldFocus = t11, gap = t12, t1 = t13, restProps = t14, $[0] = props, $[1] = _shouldFocus, $[2] = children, $[3] = gap, $[4] = onClickOutside, $[5] = onEscape, $[6] = onItemClick, $[7] = onItemSelect, $[8] = onKeyDown, $[9] = originElement, $[10] = registerElement, $[11] = restProps, $[12] = t0, $[13] = t1;
2395
- } else _shouldFocus = $[1], children = $[2], gap = $[3], onClickOutside = $[4], onEscape = $[5], onItemClick = $[6], onItemSelect = $[7], onKeyDown = $[8], originElement = $[9], registerElement = $[10], restProps = $[11], t0 = $[12], t1 = $[13];
2396
- let padding = t0 === void 0 ? 1 : t0, spacing = gap === void 0 ? t1 === void 0 ? 1 : t1 : gap, shouldFocus = _shouldFocus ?? (props.focusFirst && "first" || props.focusLast && "last" || null), ref = useRef(null), t2;
2397
- $[14] === Symbol.for("react.memo_cache_sentinel") ? (t2 = () => ref.current, $[14] = t2) : t2 = $[14], useImperativeHandle(forwardedRef, t2);
2398
- let { isTopLayer } = useLayer(), t3;
2399
- $[15] !== onKeyDown || $[16] !== originElement || $[17] !== shouldFocus ? (t3 = {
2400
- onKeyDown,
2401
- originElement,
2402
- shouldFocus,
2403
- rootElementRef: ref
2404
- }, $[15] = onKeyDown, $[16] = originElement, $[17] = shouldFocus, $[18] = t3) : t3 = $[18];
2405
- let { activeElement, activeIndex, handleItemMouseEnter, handleItemMouseLeave, handleKeyDown, mount } = useMenuController(t3), unregisterElementRef = useRef(null), t4;
2406
- $[19] === registerElement ? t4 = $[20] : (t4 = (el) => {
2407
- unregisterElementRef.current &&= (unregisterElementRef.current(), null), ref.current = el, ref.current && registerElement && (unregisterElementRef.current = registerElement(ref.current));
2408
- }, $[19] = registerElement, $[20] = t4);
2409
- let handleRefChange = t4, t5, t6;
2410
- $[21] !== activeIndex || $[22] !== onItemSelect ? (t5 = () => {
2411
- onItemSelect && onItemSelect(activeIndex);
2412
- }, t6 = [activeIndex, onItemSelect], $[21] = activeIndex, $[22] = onItemSelect, $[23] = t5, $[24] = t6) : (t5 = $[23], t6 = $[24]), useEffect(t5, t6);
2413
- let t7;
2414
- $[25] === Symbol.for("react.memo_cache_sentinel") ? (t7 = () => [ref.current], $[25] = t7) : t7 = $[25], useClickOutsideEvent(isTopLayer && onClickOutside, t7);
2415
- let t8;
2416
- $[26] !== isTopLayer || $[27] !== onEscape ? (t8 = (event) => {
2417
- isTopLayer && event.key === "Escape" && (event.stopPropagation(), onEscape && onEscape());
2418
- }, $[26] = isTopLayer, $[27] = onEscape, $[28] = t8) : t8 = $[28], useGlobalKeyDown(t8);
2419
- let t9;
2420
- $[29] !== activeElement || $[30] !== handleItemMouseEnter || $[31] !== handleItemMouseLeave || $[32] !== mount || $[33] !== onClickOutside || $[34] !== onEscape || $[35] !== onItemClick || $[36] !== registerElement ? (t9 = {
2421
- version: 2,
2422
- activeElement,
2423
- mount,
2424
- onClickOutside,
2425
- onEscape,
2426
- onItemClick,
2427
- onItemMouseEnter: handleItemMouseEnter,
2428
- onItemMouseLeave: handleItemMouseLeave,
2429
- registerElement
2430
- }, $[29] = activeElement, $[30] = handleItemMouseEnter, $[31] = handleItemMouseLeave, $[32] = mount, $[33] = onClickOutside, $[34] = onEscape, $[35] = onItemClick, $[36] = registerElement, $[37] = t9) : t9 = $[37];
2431
- let value = t9, t10;
2432
- $[38] !== children || $[39] !== spacing ? (t10 = /* @__PURE__ */ jsx(Stack, {
2433
- gap: spacing,
2434
- children
2435
- }), $[38] = children, $[39] = spacing, $[40] = t10) : t10 = $[40];
2436
- let t11;
2437
- $[41] !== handleKeyDown || $[42] !== handleRefChange || $[43] !== padding || $[44] !== restProps || $[45] !== t10 ? (t11 = /* @__PURE__ */ jsx(StyledMenu, {
2438
- "data-ui": "Menu",
2439
- ...restProps,
2440
- onKeyDown: handleKeyDown,
2441
- padding,
2442
- ref: handleRefChange,
2443
- role: "menu",
2444
- tabIndex: -1,
2445
- children: t10
2446
- }), $[41] = handleKeyDown, $[42] = handleRefChange, $[43] = padding, $[44] = restProps, $[45] = t10, $[46] = t11) : t11 = $[46];
2447
- let t12;
2448
- return $[47] !== t11 || $[48] !== value ? (t12 = /* @__PURE__ */ jsx(MenuContext.Provider, {
2449
- value,
2450
- children: t11
2451
- }), $[47] = t11, $[48] = value, $[49] = t12) : t12 = $[49], t12;
2452
- }), MenuDivider = styled.hr.withConfig({
2453
- displayName: "MenuDivider",
2454
- componentId: "sc-sxuath-0"
2455
- })`height:1px;border:0;background:var(--card-hairline-soft-color);margin:0;`;
2456
- function selectableBaseStyle() {
2457
- return css`background-color:inherit;color:inherit;&[data-as='button']{-webkit-font-smoothing:inherit;appearance:none;outline:none;font:inherit;text-align:inherit;border:0;width:-moz-available;width:-webkit-fill-available;width:stretch;}&[data-as='a']{text-decoration:none;}`;
2458
- }
2459
- function selectableColorStyle(props) {
2460
- let { $tone } = props, { color, style } = getTheme_v2(props.theme), tone = color.selectable[$tone];
2461
- return css`${_cardColorStyle(color, tone.enabled)} background-color:var(--card-bg-color);color:var(--card-fg-color);outline:none;&[data-as='button']{&:disabled{${_cardColorStyle(color, tone.disabled)}}&:not(:disabled){&[aria-pressed='true']{${_cardColorStyle(color, tone.pressed)}}&[data-selected],&[aria-selected='true'] > &{${_cardColorStyle(color, tone.selected)}}@media (hover:hover){&:not([data-selected]){&[data-hovered],&:hover{${_cardColorStyle(color, tone.hovered)}}&:active{${_cardColorStyle(color, tone.pressed)}}}}}}&[data-as='a']{&[data-disabled]{${_cardColorStyle(color, tone.disabled)}}&:not([data-disabled]){&[data-pressed]{${_cardColorStyle(color, tone.pressed)}}&[data-selected]{${_cardColorStyle(color, tone.selected)}}@media (hover:hover){&:not([data-selected]){&[data-hovered],&:hover{${_cardColorStyle(color, tone.hovered)}}&:active{${_cardColorStyle(color, tone.pressed)}}}}}}${style?.card?.root}`;
2462
- }
2463
- /**
2464
- * @internal
2465
- */
2466
- const Selectable = /* @__PURE__ */ styled(Box).withConfig({
2467
- displayName: "Selectable",
2468
- componentId: "sc-njdnrn-0"
2469
- })(responsiveRadiusStyle, selectableBaseStyle, selectableColorStyle);
2470
- function useMenu() {
2471
- let value = useContext(MenuContext);
2472
- if (!value) throw Error("useMenu(): missing context value");
2473
- if (!isRecord(value) || value.version !== 2) throw Error("useMenu(): the context value is not compatible");
2474
- return value;
2475
- }
2476
- /**
2477
- * @public
2478
- */
2479
- const MenuGroup = function MenuGroup(props) {
2480
- let $ = c(82), IconComponent, children, gap, menuProps, onClick, popover, restProps, t0, t1, t2, t3, t4, t5, text;
2481
- $[0] === props ? (IconComponent = $[1], children = $[2], gap = $[3], menuProps = $[4], onClick = $[5], popover = $[6], restProps = $[7], t0 = $[8], t1 = $[9], t2 = $[10], t3 = $[11], t4 = $[12], t5 = $[13], text = $[14]) : ({as: t0, children, fontSize: t1, icon: IconComponent, menu: menuProps, onClick, padding: t2, popover, radius: t3, gap, space: t4, text, tone: t5, ...restProps} = props, $[0] = props, $[1] = IconComponent, $[2] = children, $[3] = gap, $[4] = menuProps, $[5] = onClick, $[6] = popover, $[7] = restProps, $[8] = t0, $[9] = t1, $[10] = t2, $[11] = t3, $[12] = t4, $[13] = t5, $[14] = text);
2482
- let as = t0 === void 0 ? "button" : t0, fontSize = t1 === void 0 ? 1 : t1, padding = t2 === void 0 ? 3 : t2, radius = t3 === void 0 ? 2 : t3, deprecated_space = t4 === void 0 ? 3 : t4, tone = t5 === void 0 ? "default" : t5, spacing = gap === void 0 ? deprecated_space : gap, menu = useMenu(), { scheme } = useRootTheme(), { activeElement, mount, onClickOutside, onEscape, onItemClick, onItemMouseEnter: _onItemMouseEnter, registerElement } = menu, onItemMouseEnter = _onItemMouseEnter ?? menu.onItemMouseEnter, [rootElement, setRootElement] = useState(null), [open, setOpen] = useState(!1), [shouldFocus, setShouldFocus] = useState(null), active = !!activeElement && activeElement === rootElement, [withinMenu, setWithinMenu] = useState(!1), t6;
2483
- $[15] === onItemMouseEnter ? t6 = $[16] : (t6 = (event) => {
2484
- setWithinMenu(!1), onItemMouseEnter(event), setOpen(!0);
2485
- }, $[15] = onItemMouseEnter, $[16] = t6);
2486
- let handleMouseEnter = t6, t7;
2487
- $[17] === rootElement ? t7 = $[18] : (t7 = (event_0) => {
2488
- event_0.key === "ArrowLeft" && (event_0.stopPropagation(), setOpen(!1), requestAnimationFrame(() => {
2489
- rootElement?.focus();
2490
- }));
2491
- }, $[17] = rootElement, $[18] = t7);
2492
- let handleMenuKeyDown = t7, t8;
2493
- $[19] === onClick ? t8 = $[20] : (t8 = (event_1) => {
2494
- onClick?.(event_1), setShouldFocus("first"), setOpen(!0);
2495
- }, $[19] = onClick, $[20] = t8);
2496
- let handleClick = t8, t9;
2497
- $[21] === onItemClick ? t9 = $[22] : (t9 = () => {
2498
- setOpen(!1), onItemClick?.();
2499
- }, $[21] = onItemClick, $[22] = t9);
2500
- let handleChildItemClick = t9, t10;
2501
- $[23] === Symbol.for("react.memo_cache_sentinel") ? (t10 = () => setWithinMenu(!0), $[23] = t10) : t10 = $[23];
2502
- let handleMenuMouseEnter = t10, t11, t12;
2503
- $[24] !== mount || $[25] !== rootElement ? (t11 = () => mount(rootElement), t12 = [mount, rootElement], $[24] = mount, $[25] = rootElement, $[26] = t11, $[27] = t12) : (t11 = $[26], t12 = $[27]), useEffect(t11, t12);
2504
- let t13, t14;
2505
- $[28] === active ? (t13 = $[29], t14 = $[30]) : (t13 = () => {
2506
- active || setOpen(!1);
2507
- }, t14 = [active], $[28] = active, $[29] = t13, $[30] = t14), useEffect(t13, t14);
2508
- let t15, t16;
2509
- $[31] === open ? (t15 = $[32], t16 = $[33]) : (t15 = () => {
2510
- open || setWithinMenu(!1);
2511
- }, t16 = [open], $[31] = open, $[32] = t15, $[33] = t16), useEffect(t15, t16);
2512
- let t17, t18;
2513
- $[34] === shouldFocus ? (t17 = $[35], t18 = $[36]) : (t17 = () => {
2514
- if (!shouldFocus) return;
2515
- let rafId = requestAnimationFrame(() => setShouldFocus(null));
2516
- return () => cancelAnimationFrame(rafId);
2517
- }, t18 = [shouldFocus], $[34] = shouldFocus, $[35] = t17, $[36] = t18), useEffect(t17, t18);
2518
- let t19;
2519
- $[37] !== children || $[38] !== handleChildItemClick || $[39] !== handleMenuKeyDown || $[40] !== menuProps || $[41] !== onClickOutside || $[42] !== onEscape || $[43] !== registerElement || $[44] !== shouldFocus ? (t19 = /* @__PURE__ */ jsx(Menu, {
2520
- ...menuProps,
2521
- onClickOutside,
2522
- onEscape,
2523
- onItemClick: handleChildItemClick,
2524
- onKeyDown: handleMenuKeyDown,
2525
- onMouseEnter: handleMenuMouseEnter,
2526
- registerElement,
2527
- shouldFocus,
2528
- children
2529
- }), $[37] = children, $[38] = handleChildItemClick, $[39] = handleMenuKeyDown, $[40] = menuProps, $[41] = onClickOutside, $[42] = onEscape, $[43] = registerElement, $[44] = shouldFocus, $[45] = t19) : t19 = $[45];
2530
- let childMenu = t19, t20;
2531
- $[46] === Symbol.for("react.memo_cache_sentinel") ? (t20 = (event_2) => {
2532
- let target = event_2.currentTarget;
2533
- if (document.activeElement === target && event_2.key === "ArrowRight") {
2534
- setShouldFocus("first"), setOpen(!0), setWithinMenu(!0);
2535
- return;
2536
- }
2537
- }, $[46] = t20) : t20 = $[46];
2538
- let handleKeyDown = t20, t21 = as === "button" ? withinMenu : void 0, t22 = as === "button" ? void 0 : withinMenu, t23 = !withinMenu && active ? "" : void 0, t24;
2539
- $[47] === radius ? t24 = $[48] : (t24 = _getArrayProp(radius), $[47] = radius, $[48] = t24);
2540
- let t25 = as === "button" ? "button" : void 0, t26;
2541
- $[49] !== IconComponent || $[50] !== fontSize ? (t26 = IconComponent && /* @__PURE__ */ jsxs(Text, {
2542
- size: fontSize,
2543
- children: [isValidElement(IconComponent) && IconComponent, isValidElementType(IconComponent) && /* @__PURE__ */ jsx(IconComponent, {})]
2544
- }), $[49] = IconComponent, $[50] = fontSize, $[51] = t26) : t26 = $[51];
2545
- let t27;
2546
- $[52] !== fontSize || $[53] !== text ? (t27 = /* @__PURE__ */ jsx(Box, {
2547
- flex: 1,
2548
- children: /* @__PURE__ */ jsx(Text, {
2549
- size: fontSize,
2550
- textOverflow: "ellipsis",
2551
- weight: "medium",
2552
- children: text
2553
- })
2554
- }), $[52] = fontSize, $[53] = text, $[54] = t27) : t27 = $[54];
2555
- let t28;
2556
- $[55] === Symbol.for("react.memo_cache_sentinel") ? (t28 = /* @__PURE__ */ jsx(ChevronRightIcon, {}), $[55] = t28) : t28 = $[55];
2557
- let t29;
2558
- $[56] === fontSize ? t29 = $[57] : (t29 = /* @__PURE__ */ jsx(Text, {
2559
- size: fontSize,
2560
- children: t28
2561
- }), $[56] = fontSize, $[57] = t29);
2562
- let t30;
2563
- $[58] !== padding || $[59] !== spacing || $[60] !== t26 || $[61] !== t27 || $[62] !== t29 ? (t30 = /* @__PURE__ */ jsxs(Flex, {
2564
- gap: spacing,
2565
- padding,
2566
- children: [
2567
- t26,
2568
- t27,
2569
- t29
2570
- ]
2571
- }), $[58] = padding, $[59] = spacing, $[60] = t26, $[61] = t27, $[62] = t29, $[63] = t30) : t30 = $[63];
2572
- let t31;
2573
- $[64] !== as || $[65] !== handleClick || $[66] !== handleMouseEnter || $[67] !== restProps || $[68] !== scheme || $[69] !== t21 || $[70] !== t22 || $[71] !== t23 || $[72] !== t24 || $[73] !== t25 || $[74] !== t30 || $[75] !== tone ? (t31 = /* @__PURE__ */ jsx(Selectable, {
2574
- "data-as": as,
2575
- "data-ui": "MenuGroup",
2576
- forwardedAs: as,
2577
- ...restProps,
2578
- "aria-pressed": t21,
2579
- "data-pressed": t22,
2580
- "data-selected": t23,
2581
- $radius: t24,
2582
- $tone: tone,
2583
- $scheme: scheme,
2584
- onClick: handleClick,
2585
- onKeyDown: handleKeyDown,
2586
- onMouseEnter: handleMouseEnter,
2587
- ref: setRootElement,
2588
- tabIndex: -1,
2589
- type: t25,
2590
- children: t30
2591
- }), $[64] = as, $[65] = handleClick, $[66] = handleMouseEnter, $[67] = restProps, $[68] = scheme, $[69] = t21, $[70] = t22, $[71] = t23, $[72] = t24, $[73] = t25, $[74] = t30, $[75] = tone, $[76] = t31) : t31 = $[76];
2592
- let t32;
2593
- return $[77] !== childMenu || $[78] !== open || $[79] !== popover || $[80] !== t31 ? (t32 = /* @__PURE__ */ jsx(Popover, {
2594
- ...popover,
2595
- content: childMenu,
2596
- "data-ui": "MenuGroup__popover",
2597
- open,
2598
- children: t31
2599
- }), $[77] = childMenu, $[78] = open, $[79] = popover, $[80] = t31, $[81] = t32) : t32 = $[81], t32;
2600
- }, MenuItem = forwardRef(function MenuItem(props, forwardedRef) {
2601
- let $ = c(76), IconComponent, IconRightComponent, children, disabled, gap, hotkeys, onClick, paddingBottom, paddingLeft, paddingRight, paddingTop, paddingX, paddingY, pressed, restProps, selectedProp, t0, t1, t2, t3, t4, t5, text;
2602
- $[0] === props ? (IconComponent = $[1], IconRightComponent = $[2], children = $[3], disabled = $[4], gap = $[5], hotkeys = $[6], onClick = $[7], paddingBottom = $[8], paddingLeft = $[9], paddingRight = $[10], paddingTop = $[11], paddingX = $[12], paddingY = $[13], pressed = $[14], restProps = $[15], selectedProp = $[16], t0 = $[17], t1 = $[18], t2 = $[19], t3 = $[20], t4 = $[21], t5 = $[22], text = $[23]) : ({as: t0, children, disabled, fontSize: t1, hotkeys, icon: IconComponent, iconRight: IconRightComponent, onClick, padding: t2, paddingX, paddingY, paddingTop, paddingRight, paddingBottom, paddingLeft, pressed, radius: t3, selected: selectedProp, gap, space: t4, text, tone: t5, ...restProps} = props, $[0] = props, $[1] = IconComponent, $[2] = IconRightComponent, $[3] = children, $[4] = disabled, $[5] = gap, $[6] = hotkeys, $[7] = onClick, $[8] = paddingBottom, $[9] = paddingLeft, $[10] = paddingRight, $[11] = paddingTop, $[12] = paddingX, $[13] = paddingY, $[14] = pressed, $[15] = restProps, $[16] = selectedProp, $[17] = t0, $[18] = t1, $[19] = t2, $[20] = t3, $[21] = t4, $[22] = t5, $[23] = text);
2603
- let as = t0 === void 0 ? "button" : t0, fontSize = t1 === void 0 ? 1 : t1, padding = t2 === void 0 ? 3 : t2, radius = t3 === void 0 ? 2 : t3, deprecated_space = t4 === void 0 ? 3 : t4, tone = t5 === void 0 ? "default" : t5, spacing = gap === void 0 ? deprecated_space : gap, { scheme } = useRootTheme(), menu = useMenu(), { activeElement, mount, onItemClick, onItemMouseEnter: _onItemMouseEnter, onItemMouseLeave: _onItemMouseLeave } = menu, onItemMouseEnter = _onItemMouseEnter ?? menu.onItemMouseEnter, onItemMouseLeave = _onItemMouseLeave ?? menu.onItemMouseLeave, [rootElement, setRootElement] = useState(null), active = !!activeElement && activeElement === rootElement, ref = useRef(null), t6;
2604
- $[24] === Symbol.for("react.memo_cache_sentinel") ? (t6 = () => ref.current, $[24] = t6) : t6 = $[24], useImperativeHandle(forwardedRef, t6);
2605
- let t7, t8;
2606
- $[25] !== mount || $[26] !== rootElement || $[27] !== selectedProp ? (t7 = () => mount(rootElement, selectedProp), t8 = [
2607
- mount,
2608
- rootElement,
2609
- selectedProp
2610
- ], $[25] = mount, $[26] = rootElement, $[27] = selectedProp, $[28] = t7, $[29] = t8) : (t7 = $[28], t8 = $[29]), useEffect(t7, t8);
2611
- let t9;
2612
- $[30] !== disabled || $[31] !== onClick || $[32] !== onItemClick ? (t9 = (event) => {
2613
- disabled || (onClick && onClick(event), onItemClick && onItemClick());
2614
- }, $[30] = disabled, $[31] = onClick, $[32] = onItemClick, $[33] = t9) : t9 = $[33];
2615
- let handleClick = t9, t10;
2616
- $[34] !== padding || $[35] !== paddingBottom || $[36] !== paddingLeft || $[37] !== paddingRight || $[38] !== paddingTop || $[39] !== paddingX || $[40] !== paddingY ? (t10 = {
2617
- padding,
2618
- paddingX,
2619
- paddingY,
2620
- paddingTop,
2621
- paddingRight,
2622
- paddingBottom,
2623
- paddingLeft
2624
- }, $[34] = padding, $[35] = paddingBottom, $[36] = paddingLeft, $[37] = paddingRight, $[38] = paddingTop, $[39] = paddingX, $[40] = paddingY, $[41] = t10) : t10 = $[41];
2625
- let paddingProps = t10, t11;
2626
- $[42] === fontSize ? t11 = $[43] : (t11 = _getArrayProp(fontSize).map(_temp$2), $[42] = fontSize, $[43] = t11);
2627
- let hotkeysFontSize = t11, t12;
2628
- $[44] === Symbol.for("react.memo_cache_sentinel") ? (t12 = (el) => {
2629
- ref.current = el, setRootElement(el);
2630
- }, $[44] = t12) : t12 = $[44];
2631
- let setRef = t12, t13 = as !== "button" && pressed ? "" : void 0, t14 = active ? "" : void 0, t15 = disabled ? "" : void 0, t16;
2632
- $[45] === radius ? t16 = $[46] : (t16 = _getArrayProp(radius), $[45] = radius, $[46] = t16);
2633
- let t17;
2634
- $[47] === Symbol.for("react.memo_cache_sentinel") ? (t17 = _getArrayProp(0), $[47] = t17) : t17 = $[47];
2635
- let t18 = disabled ? "default" : tone, t19 = as === "button" ? "button" : void 0, t20;
2636
- $[48] !== IconComponent || $[49] !== IconRightComponent || $[50] !== fontSize || $[51] !== hotkeys || $[52] !== hotkeysFontSize || $[53] !== paddingProps || $[54] !== spacing || $[55] !== text ? (t20 = (IconComponent || text || IconRightComponent) && /* @__PURE__ */ jsxs(Flex, {
2637
- as: "span",
2638
- gap: spacing,
2639
- align: "center",
2640
- ...paddingProps,
2641
- children: [
2642
- IconComponent && /* @__PURE__ */ jsxs(Text, {
2643
- size: fontSize,
2644
- children: [isValidElement(IconComponent) && IconComponent, isValidElementType(IconComponent) && /* @__PURE__ */ jsx(IconComponent, {})]
2645
- }),
2646
- text && /* @__PURE__ */ jsx(Box, {
2647
- flex: 1,
2648
- children: /* @__PURE__ */ jsx(Text, {
2649
- size: fontSize,
2650
- textOverflow: "ellipsis",
2651
- weight: "medium",
2652
- children: text
2653
- })
2654
- }),
2655
- hotkeys && /* @__PURE__ */ jsx(Hotkeys, {
2656
- fontSize: hotkeysFontSize,
2657
- keys: hotkeys,
2658
- style: {
2659
- marginTop: -4,
2660
- marginBottom: -4
2661
- }
2662
- }),
2663
- IconRightComponent && /* @__PURE__ */ jsxs(Text, {
2664
- size: fontSize,
2665
- children: [isValidElement(IconRightComponent) && IconRightComponent, isValidElementType(IconRightComponent) && /* @__PURE__ */ jsx(IconRightComponent, {})]
2666
- })
2667
- ]
2668
- }), $[48] = IconComponent, $[49] = IconRightComponent, $[50] = fontSize, $[51] = hotkeys, $[52] = hotkeysFontSize, $[53] = paddingProps, $[54] = spacing, $[55] = text, $[56] = t20) : t20 = $[56];
2669
- let t21;
2670
- $[57] !== children || $[58] !== paddingProps ? (t21 = children && /* @__PURE__ */ jsx(Box, {
2671
- as: "span",
2672
- ...paddingProps,
2673
- children
2674
- }), $[57] = children, $[58] = paddingProps, $[59] = t21) : t21 = $[59];
2675
- let t22;
2676
- return $[60] !== as || $[61] !== disabled || $[62] !== handleClick || $[63] !== onItemMouseEnter || $[64] !== onItemMouseLeave || $[65] !== restProps || $[66] !== scheme || $[67] !== t13 || $[68] !== t14 || $[69] !== t15 || $[70] !== t16 || $[71] !== t18 || $[72] !== t19 || $[73] !== t20 || $[74] !== t21 ? (t22 = /* @__PURE__ */ jsxs(Selectable, {
2677
- "data-ui": "MenuItem",
2678
- role: "menuitem",
2679
- ...restProps,
2680
- "data-pressed": t13,
2681
- "data-selected": t14,
2682
- "data-disabled": t15,
2683
- forwardedAs: as,
2684
- $radius: t16,
2685
- $padding: t17,
2686
- $tone: t18,
2687
- $scheme: scheme,
2688
- disabled,
2689
- onClick: handleClick,
2690
- onMouseEnter: onItemMouseEnter,
2691
- onMouseLeave: onItemMouseLeave,
2692
- ref: setRef,
2693
- tabIndex: -1,
2694
- type: t19,
2695
- children: [t20, t21]
2696
- }), $[60] = as, $[61] = disabled, $[62] = handleClick, $[63] = onItemMouseEnter, $[64] = onItemMouseLeave, $[65] = restProps, $[66] = scheme, $[67] = t13, $[68] = t14, $[69] = t15, $[70] = t16, $[71] = t18, $[72] = t19, $[73] = t20, $[74] = t21, $[75] = t22) : t22 = $[75], t22;
2697
- });
2698
- function _temp$2(s) {
2699
- return s - 1;
2700
- }
2701
- const CustomButton = styled(Button).withConfig({
2702
- displayName: "CustomButton",
2703
- componentId: "sc-whlh6p-0"
2704
- })`max-width:100%;`, Tab = forwardRef(function Tab(props, forwardedRef) {
2705
- let $ = c(30), focused, icon, id, label, onClick, onFocus, restProps, selected, t0, t1;
2706
- $[0] === props ? (focused = $[1], icon = $[2], id = $[3], label = $[4], onClick = $[5], onFocus = $[6], restProps = $[7], selected = $[8], t0 = $[9], t1 = $[10]) : ({icon, id, focused, fontSize: t0, label, onClick, onFocus, padding: t1, selected, ...restProps} = props, $[0] = props, $[1] = focused, $[2] = icon, $[3] = id, $[4] = label, $[5] = onClick, $[6] = onFocus, $[7] = restProps, $[8] = selected, $[9] = t0, $[10] = t1);
2707
- let fontSize = t0 === void 0 ? 1 : t0, padding = t1 === void 0 ? 2 : t1, ref = useRef(null), focusedRef = useRef(!1), t2;
2708
- $[11] === Symbol.for("react.memo_cache_sentinel") ? (t2 = () => ref.current, $[11] = t2) : t2 = $[11], useImperativeHandle(forwardedRef, t2);
2709
- let t3;
2710
- $[12] === Symbol.for("react.memo_cache_sentinel") ? (t3 = () => {
2711
- focusedRef.current = !1;
2712
- }, $[12] = t3) : t3 = $[12];
2713
- let handleBlur = t3, t4;
2714
- $[13] === onFocus ? t4 = $[14] : (t4 = (event) => {
2715
- focusedRef.current = !0, onFocus && onFocus(event);
2716
- }, $[13] = onFocus, $[14] = t4);
2717
- let handleFocus = t4, t5, t6;
2718
- $[15] === focused ? (t5 = $[16], t6 = $[17]) : (t5 = () => {
2719
- focused && !focusedRef.current && (ref.current && ref.current.focus(), focusedRef.current = !0);
2720
- }, t6 = [focused], $[15] = focused, $[16] = t5, $[17] = t6), useEffect(t5, t6);
2721
- let t7 = selected ? "true" : "false", t8 = selected ? 0 : -1, t9;
2722
- return $[18] !== fontSize || $[19] !== handleFocus || $[20] !== icon || $[21] !== id || $[22] !== label || $[23] !== onClick || $[24] !== padding || $[25] !== restProps || $[26] !== selected || $[27] !== t7 || $[28] !== t8 ? (t9 = /* @__PURE__ */ jsx(CustomButton, {
2723
- "data-ui": "Tab",
2724
- ...restProps,
2725
- "aria-selected": t7,
2726
- fontSize,
2727
- icon,
2728
- id,
2729
- mode: "bleed",
2730
- onClick,
2731
- onBlur: handleBlur,
2732
- onFocus: handleFocus,
2733
- padding,
2734
- ref,
2735
- role: "tab",
2736
- selected,
2737
- tabIndex: t8,
2738
- text: label,
2739
- type: "button"
2740
- }), $[18] = fontSize, $[19] = handleFocus, $[20] = icon, $[21] = id, $[22] = label, $[23] = onClick, $[24] = padding, $[25] = restProps, $[26] = selected, $[27] = t7, $[28] = t8, $[29] = t9) : t9 = $[29], t9;
2741
- }), CustomInline = styled(Inline).withConfig({
2742
- displayName: "CustomInline",
2743
- componentId: "sc-tlz8f1-0"
2744
- })`& > div{display:inline-block;vertical-align:middle;max-width:100%;box-sizing:border-box;}`, TabList = forwardRef(function TabList(props, ref) {
2745
- let $ = c(15), childrenProp, restProps;
2746
- $[0] === props ? (childrenProp = $[1], restProps = $[2]) : ({children: childrenProp, ...restProps} = props, $[0] = props, $[1] = childrenProp, $[2] = restProps);
2747
- let [focusedIndex, setFocusedIndex] = useState(-1), t0;
2748
- if ($[3] !== childrenProp || $[4] !== focusedIndex) {
2749
- let children = Children.toArray(childrenProp).filter(isValidElement), t1;
2750
- $[6] === focusedIndex ? t1 = $[7] : (t1 = (child, childIndex) => cloneElement(child, {
2751
- focused: focusedIndex === childIndex,
2752
- key: childIndex,
2753
- onFocus: () => setFocusedIndex(childIndex)
2754
- }), $[6] = focusedIndex, $[7] = t1), t0 = children.map(t1), $[3] = childrenProp, $[4] = focusedIndex, $[5] = t0;
2755
- } else t0 = $[5];
2756
- let tabs = t0, numTabs = tabs.length, t1;
2757
- $[8] === numTabs ? t1 = $[9] : (t1 = (event) => {
2758
- event.key === "ArrowLeft" && setFocusedIndex((prevIndex) => (prevIndex + numTabs - 1) % numTabs), event.key === "ArrowRight" && setFocusedIndex((prevIndex_0) => (prevIndex_0 + 1) % numTabs);
2759
- }, $[8] = numTabs, $[9] = t1);
2760
- let handleKeyDown = t1, t2;
2761
- return $[10] !== handleKeyDown || $[11] !== ref || $[12] !== restProps || $[13] !== tabs ? (t2 = /* @__PURE__ */ jsx(CustomInline, {
2762
- "data-ui": "TabList",
2763
- ...restProps,
2764
- onKeyDown: handleKeyDown,
2765
- ref,
2766
- role: "tablist",
2767
- children: tabs
2768
- }), $[10] = handleKeyDown, $[11] = ref, $[12] = restProps, $[13] = tabs, $[14] = t2) : t2 = $[14], t2;
2769
- }), GRID_CSS = {
2770
- "&&:not([hidden])": { display: "grid" },
2771
- "&[data-as=\"ul\"],&[data-as=\"ol\"]": { listStyle: "none" }
2772
- }, GRID_AUTO_COLUMS = {
2773
- auto: "auto",
2774
- min: "min-content",
2775
- max: "max-content",
2776
- fr: "minmax(0, 1fr)"
2777
- }, GRID_AUTO_ROWS = {
2778
- auto: "auto",
2779
- min: "min-content",
2780
- max: "max-content",
2781
- fr: "minmax(0, 1fr)"
2782
- };
2783
- function responsiveGridStyle() {
2784
- return [
2785
- GRID_CSS,
2786
- responsiveGridAutoFlowStyle,
2787
- responsiveGridAutoRowsStyle,
2788
- responsiveGridAutoColsStyle,
2789
- responsiveGridColumnsStyle,
2790
- responsiveGridRowsStyle,
2791
- responsiveGridGapStyle,
2792
- responsiveGridGapXStyle,
2793
- responsiveGridGapYStyle
2794
- ];
2795
- }
2796
- function responsiveGridAutoFlowStyle(props) {
2797
- let { media } = getTheme_v2(props.theme);
2798
- return _responsive(media, props.$autoFlow, (autoFlow) => ({ gridAutoFlow: autoFlow }));
2799
- }
2800
- function responsiveGridAutoRowsStyle(props) {
2801
- let { media } = getTheme_v2(props.theme);
2802
- return _responsive(media, props.$autoRows, (autoRows) => ({ gridAutoRows: autoRows && GRID_AUTO_ROWS[autoRows] }));
2803
- }
2804
- function responsiveGridAutoColsStyle(props) {
2805
- let { media } = getTheme_v2(props.theme);
2806
- return _responsive(media, props.$autoCols, (autoCols) => ({ gridAutoColumns: autoCols && GRID_AUTO_COLUMS[autoCols] }));
2807
- }
2808
- function responsiveGridColumnsStyle(props) {
2809
- let { media } = getTheme_v2(props.theme);
2810
- return _responsive(media, props.$columns, (columns) => ({ gridTemplateColumns: columns && `repeat(${columns},minmax(0,1fr));` }));
2811
- }
2812
- function responsiveGridRowsStyle(props) {
2813
- let { media } = getTheme_v2(props.theme);
2814
- return _responsive(media, props.$rows, (rows) => ({ gridTemplateRows: rows && `repeat(${rows},minmax(0,1fr));` }));
2815
- }
2816
- function responsiveGridGapStyle(props) {
2817
- let { media, space } = getTheme_v2(props.theme);
2818
- return _responsive(media, props.$gap, (gap) => ({ gridGap: gap ? rem(space[gap]) : void 0 }));
2819
- }
2820
- function responsiveGridGapXStyle(props) {
2821
- let { media, space } = getTheme_v2(props.theme);
2822
- return _responsive(media, props.$gapX, (gapX) => ({ columnGap: gapX ? rem(space[gapX]) : void 0 }));
2823
- }
2824
- function responsiveGridGapYStyle(props) {
2825
- let { media, space } = getTheme_v2(props.theme);
2826
- return _responsive(media, props.$gapY, (gapY) => ({ rowGap: gapY ? rem(space[gapY]) : void 0 }));
2827
- }
2828
- const StyledGrid = /* @__PURE__ */ styled(Box).withConfig({
2829
- displayName: "StyledGrid",
2830
- componentId: "sc-osmjhz-0"
2831
- })(responsiveGridStyle), Grid = forwardRef(function Grid(props, ref) {
2832
- let $ = c(44), as, autoCols, autoFlow, autoRows, children, columns, gap, gapX, gapY, gridTemplateColumns, gridTemplateRows, restProps, rows;
2833
- $[0] === props ? (as = $[1], autoCols = $[2], autoFlow = $[3], autoRows = $[4], children = $[5], columns = $[6], gap = $[7], gapX = $[8], gapY = $[9], gridTemplateColumns = $[10], gridTemplateRows = $[11], restProps = $[12], rows = $[13]) : ({as, autoRows, autoCols, autoFlow, columns, gridTemplateColumns, gap, gapX, gapY, rows, gridTemplateRows, children, ...restProps} = props, $[0] = props, $[1] = as, $[2] = autoCols, $[3] = autoFlow, $[4] = autoRows, $[5] = children, $[6] = columns, $[7] = gap, $[8] = gapX, $[9] = gapY, $[10] = gridTemplateColumns, $[11] = gridTemplateRows, $[12] = restProps, $[13] = rows);
2834
- let t0 = typeof as == "string" ? as : void 0, t1;
2835
- $[14] === autoRows ? t1 = $[15] : (t1 = _getArrayProp(autoRows), $[14] = autoRows, $[15] = t1);
2836
- let t2;
2837
- $[16] === autoCols ? t2 = $[17] : (t2 = _getArrayProp(autoCols), $[16] = autoCols, $[17] = t2);
2838
- let t3;
2839
- $[18] === autoFlow ? t3 = $[19] : (t3 = _getArrayProp(autoFlow), $[18] = autoFlow, $[19] = t3);
2840
- let t4 = gridTemplateColumns === void 0 ? columns : gridTemplateColumns, t5;
2841
- $[20] === t4 ? t5 = $[21] : (t5 = _getArrayProp(t4), $[20] = t4, $[21] = t5);
2842
- let t6;
2843
- $[22] === gap ? t6 = $[23] : (t6 = _getArrayProp(gap), $[22] = gap, $[23] = t6);
2844
- let t7;
2845
- $[24] === gapX ? t7 = $[25] : (t7 = _getArrayProp(gapX), $[24] = gapX, $[25] = t7);
2846
- let t8;
2847
- $[26] === gapY ? t8 = $[27] : (t8 = _getArrayProp(gapY), $[26] = gapY, $[27] = t8);
2848
- let t9 = gridTemplateRows === void 0 ? rows : gridTemplateRows, t10;
2849
- $[28] === t9 ? t10 = $[29] : (t10 = _getArrayProp(t9), $[28] = t9, $[29] = t10);
2850
- let t11;
2851
- return $[30] !== as || $[31] !== children || $[32] !== ref || $[33] !== restProps || $[34] !== t0 || $[35] !== t1 || $[36] !== t10 || $[37] !== t2 || $[38] !== t3 || $[39] !== t5 || $[40] !== t6 || $[41] !== t7 || $[42] !== t8 ? (t11 = /* @__PURE__ */ jsx(StyledGrid, {
2852
- "data-as": t0,
2853
- "data-ui": "Grid",
2854
- ...restProps,
2855
- $autoRows: t1,
2856
- $autoCols: t2,
2857
- $autoFlow: t3,
2858
- $columns: t5,
2859
- $gap: t6,
2860
- $gapX: t7,
2861
- $gapY: t8,
2862
- $rows: t10,
2863
- forwardedAs: as,
2864
- ref,
2865
- children
2866
- }), $[30] = as, $[31] = children, $[32] = ref, $[33] = restProps, $[34] = t0, $[35] = t1, $[36] = t10, $[37] = t2, $[38] = t3, $[39] = t5, $[40] = t6, $[41] = t7, $[42] = t8, $[43] = t11) : t11 = $[43], t11;
2867
- });
2868
- /**
2869
- * Returns true if a dark color scheme is preferred, false if a light color scheme is preferred or the preference is not known.
2870
- *
2871
- * @param getServerSnapshot - Only called during server-side rendering, and hydration if using hydrateRoot. Since the server environment doesn't have access to the DOM, we can't determine the current value of the media query and we assume `(prefers-color-scheme: light)` since it's the most common scheme (https://react.dev/reference/react/useSyncExternalStore#adding-support-for-server-rendering)
2872
- *
2873
- * If you persist the detected preference in a cookie or a header then you may implement your own server snapshot to read it.
2874
- * Chrome supports reading the `prefers-color-scheme` media query from a header if the server response: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Sec-CH-Prefers-Color-Scheme
2875
- * @example https://gist.github.com/stipsan/13c0cccf8dfc34f4b44bb1b984baf7df
2876
- *
2877
- * @public
2878
- */
2879
- function usePrefersDark(t0) {
2880
- return useMatchMedia("(prefers-color-scheme: dark)", t0 === void 0 ? _temp$1 : t0);
2881
- }
2882
- function _temp$1() {
2883
- return !1;
2884
- }
2885
- /**
2886
- * @beta
2887
- */
2888
- function useDelayedState(initialState) {
2889
- let $ = c(5), [state, setState] = useState(initialState), delayedAction = useRef(void 0), t0;
2890
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = (nextState, delay) => {
2891
- let action = () => {
2892
- setState(nextState);
2893
- };
2894
- if (delayedAction.current &&= (clearTimeout(delayedAction.current), void 0), !delay) return action();
2895
- delayedAction.current = setTimeout(action, delay);
2896
- }, $[0] = t0) : t0 = $[0];
2897
- let onStateChange = t0, t1, t2;
2898
- $[1] === Symbol.for("react.memo_cache_sentinel") ? (t1 = () => () => {
2899
- delayedAction.current && clearTimeout(delayedAction.current);
2900
- }, t2 = [], $[1] = t1, $[2] = t2) : (t1 = $[1], t2 = $[2]), useEffect(t1, t2);
2901
- let t3;
2902
- return $[3] === state ? t3 = $[4] : (t3 = [state, onStateChange], $[3] = state, $[4] = t3), t3;
2903
- }
2904
- const DEFAULT_FALLBACK_PLACEMENTS = {
2905
- top: [
2906
- "top-end",
2907
- "top-start",
2908
- "bottom",
2909
- "left",
2910
- "right"
2911
- ],
2912
- "top-start": [
2913
- "top",
2914
- "top-end",
2915
- "bottom-start",
2916
- "left-start",
2917
- "right-start"
2918
- ],
2919
- "top-end": [
2920
- "top",
2921
- "top-start",
2922
- "bottom-end",
2923
- "left-end",
2924
- "right-end"
2925
- ],
2926
- bottom: [
2927
- "bottom-end",
2928
- "bottom-start",
2929
- "top",
2930
- "left",
2931
- "right"
2932
- ],
2933
- "bottom-start": [
2934
- "bottom",
2935
- "bottom-end",
2936
- "top-start",
2937
- "left-start",
2938
- "right-start"
2939
- ],
2940
- "bottom-end": [
2941
- "bottom",
2942
- "bottom-start",
2943
- "top-end",
2944
- "left-end",
2945
- "right-end"
2946
- ],
2947
- left: [
2948
- "left-end",
2949
- "left-start",
2950
- "right",
2951
- "top",
2952
- "bottom"
2953
- ],
2954
- "left-start": [
2955
- "left",
2956
- "left-end",
2957
- "right-start",
2958
- "top-start",
2959
- "bottom-start"
2960
- ],
2961
- "left-end": [
2962
- "left",
2963
- "left-start",
2964
- "right-end",
2965
- "top-end",
2966
- "bottom-end"
2967
- ],
2968
- right: [
2969
- "right-end",
2970
- "right-start",
2971
- "left",
2972
- "top",
2973
- "bottom"
2974
- ],
2975
- "right-start": [
2976
- "right",
2977
- "right-end",
2978
- "left-start",
2979
- "top-start",
2980
- "bottom-start"
2981
- ],
2982
- "right-end": [
2983
- "right",
2984
- "right-start",
2985
- "left-end",
2986
- "top-end",
2987
- "bottom-end"
2988
- ]
2989
- }, MotionCard = styled(motion.create(Card)).withConfig({
2990
- displayName: "MotionCard",
2991
- componentId: "sc-k6wgsf-0"
2992
- })`will-change:transform;`, TooltipCard = forwardRef(function TooltipCard(props, ref) {
2993
- let $ = c(48), animate, arrow, arrowRef, arrowX, arrowY, children, originX, originY, padding, placement, radius, restProps, scheme, shadow, style;
2994
- $[0] === props ? (animate = $[1], arrow = $[2], arrowRef = $[3], arrowX = $[4], arrowY = $[5], children = $[6], originX = $[7], originY = $[8], padding = $[9], placement = $[10], radius = $[11], restProps = $[12], scheme = $[13], shadow = $[14], style = $[15]) : ({animate, arrow, arrowRef, arrowX, arrowY, children, originX, originY, padding, placement, radius, scheme, shadow, style, ...restProps} = 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] = restProps, $[13] = scheme, $[14] = shadow, $[15] = style);
2995
- let t0 = animate ? "transform" : void 0, t1;
2996
- $[16] !== originX || $[17] !== originY || $[18] !== style || $[19] !== t0 ? (t1 = {
2997
- originX,
2998
- originY,
2999
- willChange: t0,
3000
- ...style
3001
- }, $[16] = originX, $[17] = originY, $[18] = style, $[19] = t0, $[20] = t1) : t1 = $[20];
3002
- let rootStyle = t1, t2 = arrowX === null ? void 0 : arrowX, t3 = arrowY === null ? void 0 : arrowY, t4;
3003
- $[21] !== t2 || $[22] !== t3 ? (t4 = {
3004
- left: t2,
3005
- top: t3,
3006
- right: void 0,
3007
- bottom: void 0
3008
- }, $[21] = t2, $[22] = t3, $[23] = t4) : t4 = $[23];
3009
- let arrowStyle = t4, t5 = restProps, t6;
3010
- $[24] === animate ? t6 = $[25] : (t6 = animate ? ["hidden", "initial"] : void 0, $[24] = animate, $[25] = t6);
3011
- let t7;
3012
- $[26] === animate ? t7 = $[27] : (t7 = animate ? ["visible", "scaleIn"] : void 0, $[26] = animate, $[27] = t7);
3013
- let t8;
3014
- $[28] === animate ? t8 = $[29] : (t8 = animate ? ["hidden", "scaleOut"] : void 0, $[28] = animate, $[29] = t8);
3015
- let t9;
3016
- $[30] !== arrow || $[31] !== arrowRef || $[32] !== arrowStyle ? (t9 = arrow && /* @__PURE__ */ jsx(Arrow, {
3017
- ref: arrowRef,
3018
- style: arrowStyle,
3019
- width: 15,
3020
- height: 6,
3021
- radius: 2
3022
- }), $[30] = arrow, $[31] = arrowRef, $[32] = arrowStyle, $[33] = t9) : t9 = $[33];
3023
- let t10;
3024
- return $[34] !== children || $[35] !== padding || $[36] !== placement || $[37] !== radius || $[38] !== ref || $[39] !== rootStyle || $[40] !== scheme || $[41] !== shadow || $[42] !== t5 || $[43] !== t6 || $[44] !== t7 || $[45] !== t8 || $[46] !== t9 ? (t10 = /* @__PURE__ */ jsxs(MotionCard, {
3025
- "data-ui": "Tooltip__card",
3026
- ...t5,
3027
- "data-placement": placement,
3028
- padding,
3029
- radius,
3030
- ref,
3031
- scheme,
3032
- shadow,
3033
- style: rootStyle,
3034
- variants: POPOVER_MOTION_PROPS.card,
3035
- transition: POPOVER_MOTION_PROPS.transition,
3036
- initial: t6,
3037
- animate: t7,
3038
- exit: t8,
3039
- children: [children, t9]
3040
- }), $[34] = children, $[35] = padding, $[36] = placement, $[37] = radius, $[38] = ref, $[39] = rootStyle, $[40] = scheme, $[41] = shadow, $[42] = t5, $[43] = t6, $[44] = t7, $[45] = t8, $[46] = t9, $[47] = t10) : t10 = $[47], t10;
3041
- }), TooltipDelayGroupContext = createGlobalScopedContext("@sanity/ui/context/tooltipDelayGroup", null);
3042
- /**
3043
- * @beta
3044
- */
3045
- function useTooltipDelayGroup() {
3046
- return useContext(TooltipDelayGroupContext);
3047
- }
3048
- const StyledTooltip = styled(Layer).withConfig({
3049
- displayName: "StyledTooltip",
3050
- componentId: "sc-4nppkj-0"
3051
- })`pointer-events:none;`, Tooltip = forwardRef(function Tooltip(props, forwardedRef) {
3052
- let $ = c(137), boundaryElementContext = useBoundaryElement(), { layer } = useTheme_v2(), _boundaryElement, _fallbackPlacementsProp, _zOffset, childProp, content, delay, disabled, portalProp, restProps, scheme, t0, t1, t2, t3, t4, t5;
3053
- $[0] === props ? (_boundaryElement = $[1], _fallbackPlacementsProp = $[2], _zOffset = $[3], childProp = $[4], content = $[5], delay = $[6], disabled = $[7], portalProp = $[8], restProps = $[9], scheme = $[10], t0 = $[11], t1 = $[12], t2 = $[13], t3 = $[14], t4 = $[15], t5 = $[16]) : ({animate: t0, arrow: t1, boundaryElement: _boundaryElement, children: childProp, content, disabled, fallbackPlacements: _fallbackPlacementsProp, padding: t2, placement: t3, portal: portalProp, radius: t4, scheme, shadow: t5, zOffset: _zOffset, delay, ...restProps} = props, $[0] = props, $[1] = _boundaryElement, $[2] = _fallbackPlacementsProp, $[3] = _zOffset, $[4] = childProp, $[5] = content, $[6] = delay, $[7] = disabled, $[8] = portalProp, $[9] = restProps, $[10] = scheme, $[11] = t0, $[12] = t1, $[13] = t2, $[14] = t3, $[15] = t4, $[16] = t5);
3054
- let _animate = t0 !== void 0 && t0, arrowProp = t1 !== void 0 && t1, padding = t2 === void 0 ? 2 : t2, placementProp = t3 === void 0 ? "bottom" : t3, radius = t4 === void 0 ? 2 : t4, shadow = t5 === void 0 ? 2 : t5, boundaryElement = _boundaryElement ?? boundaryElementContext?.element, fallbackPlacementsProp = _fallbackPlacementsProp ?? DEFAULT_FALLBACK_PLACEMENTS[props.placement ?? "bottom"], zOffset = _zOffset ?? layer.tooltip.zOffset, animate = !usePrefersReducedMotion() && _animate, t6;
3055
- $[17] === fallbackPlacementsProp ? t6 = $[18] : (t6 = _getArrayProp(fallbackPlacementsProp), $[17] = fallbackPlacementsProp, $[18] = t6);
3056
- let fallbackPlacements = t6, ref = useRef(null), [referenceElement, setReferenceElement] = useState(null), arrowRef = useRef(null), [tooltipMaxWidth, setTooltipMaxWidth] = useState(0), t7;
3057
- $[19] === Symbol.for("react.memo_cache_sentinel") ? (t7 = () => ref.current, $[19] = t7) : t7 = $[19], useImperativeHandle(forwardedRef, t7);
3058
- let portal = usePortal(), portalElement = typeof portalProp == "string" ? portal.elements?.[portalProp] || null : portal.element, t8;
3059
- $[20] !== animate || $[21] !== arrowProp || $[22] !== boundaryElement || $[23] !== fallbackPlacements ? (t8 = {
3060
- animate,
3061
- arrowProp,
3062
- arrowRef,
3063
- boundaryElement,
3064
- fallbackPlacements,
3065
- rootBoundary: "viewport"
3066
- }, $[20] = animate, $[21] = arrowProp, $[22] = boundaryElement, $[23] = fallbackPlacements, $[24] = t8) : t8 = $[24];
3067
- let middleware = useMiddleware(t8), t9;
3068
- $[25] === referenceElement ? t9 = $[26] : (t9 = { reference: referenceElement }, $[25] = referenceElement, $[26] = t9);
3069
- let t10;
3070
- $[27] !== middleware || $[28] !== placementProp || $[29] !== t9 ? (t10 = {
3071
- middleware,
3072
- placement: placementProp,
3073
- whileElementsMounted: autoUpdate,
3074
- elements: t9
3075
- }, $[27] = middleware, $[28] = placementProp, $[29] = t9, $[30] = t10) : t10 = $[30];
3076
- let { floatingStyles, placement, middlewareData, refs, update } = useFloating(t10), arrowX = middlewareData.arrow?.x, arrowY = middlewareData.arrow?.y, originX = middlewareData["@sanity/ui/origin"]?.originX, originY = middlewareData["@sanity/ui/origin"]?.originY, tooltipId = useId(), [isOpen, setIsOpen] = useDelayedState(!1), delayGroupContext = useTooltipDelayGroup(), t11;
3077
- $[31] === delayGroupContext ? t11 = $[32] : (t11 = delayGroupContext || {}, $[31] = delayGroupContext, $[32] = t11);
3078
- let { setIsGroupActive, setOpenTooltipId } = t11, 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, t12;
3079
- $[33] !== closeDelay || $[34] !== isInsideGroup || $[35] !== openDelay || $[36] !== setIsGroupActive || $[37] !== setIsOpen || $[38] !== setOpenTooltipId || $[39] !== tooltipId ? (t12 = (open, immediate) => {
3080
- if (isInsideGroup) if (open) {
3081
- let groupedOpenDelay = immediate ? 0 : openDelay;
3082
- setIsGroupActive?.(open, groupedOpenDelay), setOpenTooltipId?.(tooltipId, groupedOpenDelay);
3083
- } else setIsGroupActive?.(open, closeDelay > 200 ? closeDelay : 200), setOpenTooltipId?.(null, immediate ? 0 : closeDelay);
3084
- else setIsOpen(open, immediate ? 0 : open ? openDelay : closeDelay);
3085
- }, $[33] = closeDelay, $[34] = isInsideGroup, $[35] = openDelay, $[36] = setIsGroupActive, $[37] = setIsOpen, $[38] = setOpenTooltipId, $[39] = tooltipId, $[40] = t12) : t12 = $[40];
3086
- let handleIsOpenChange = t12, t13;
3087
- $[41] !== childProp?.props || $[42] !== handleIsOpenChange ? (t13 = (e) => {
3088
- handleIsOpenChange(!1), childProp?.props?.onBlur?.(e);
3089
- }, $[41] = childProp?.props, $[42] = handleIsOpenChange, $[43] = t13) : t13 = $[43], childProp?.props;
3090
- let handleBlur = t13, t14;
3091
- $[44] !== childProp?.props || $[45] !== handleIsOpenChange ? (t14 = (e_0) => {
3092
- handleIsOpenChange(!1, !0), childProp?.props.onClick?.(e_0);
3093
- }, $[44] = childProp?.props, $[45] = handleIsOpenChange, $[46] = t14) : t14 = $[46], childProp?.props;
3094
- let handleClick = t14, t15;
3095
- $[47] !== childProp?.props || $[48] !== handleIsOpenChange ? (t15 = (e_1) => {
3096
- handleIsOpenChange(!1, !0), childProp?.props.onContextMenu?.(e_1);
3097
- }, $[47] = childProp?.props, $[48] = handleIsOpenChange, $[49] = t15) : t15 = $[49], childProp?.props;
3098
- let handleContextMenu = t15, t16;
3099
- $[50] !== childProp?.props || $[51] !== handleIsOpenChange ? (t16 = (e_2) => {
3100
- handleIsOpenChange(!0), childProp?.props?.onFocus?.(e_2);
3101
- }, $[50] = childProp?.props, $[51] = handleIsOpenChange, $[52] = t16) : t16 = $[52], childProp?.props;
3102
- let handleFocus = t16, t17;
3103
- $[53] !== childProp?.props || $[54] !== handleIsOpenChange ? (t17 = (e_3) => {
3104
- handleIsOpenChange(!0), childProp?.props?.onMouseEnter?.(e_3);
3105
- }, $[53] = childProp?.props, $[54] = handleIsOpenChange, $[55] = t17) : t17 = $[55], childProp?.props;
3106
- let handleMouseEnter = t17, t18;
3107
- $[56] !== childProp?.props || $[57] !== handleIsOpenChange ? (t18 = (e_4) => {
3108
- handleIsOpenChange(!1), childProp?.props?.onMouseLeave?.(e_4);
3109
- }, $[56] = childProp?.props, $[57] = handleIsOpenChange, $[58] = t18) : t18 = $[58], childProp?.props;
3110
- let handleMouseLeave = t18, t19;
3111
- $[59] !== handleIsOpenChange || $[60] !== isInsideGroup || $[61] !== referenceElement || $[62] !== showTooltip ? (t19 = {
3112
- handleIsOpenChange,
3113
- referenceElement,
3114
- showTooltip,
3115
- isInsideGroup
3116
- }, $[59] = handleIsOpenChange, $[60] = isInsideGroup, $[61] = referenceElement, $[62] = showTooltip, $[63] = t19) : t19 = $[63], useCloseOnMouseLeave(t19);
3117
- let t20, t21;
3118
- $[64] !== disabled || $[65] !== handleIsOpenChange || $[66] !== showTooltip ? (t20 = () => {
3119
- disabled && showTooltip && handleIsOpenChange(!1);
3120
- }, t21 = [
3121
- disabled,
3122
- handleIsOpenChange,
3123
- showTooltip
3124
- ], $[64] = disabled, $[65] = handleIsOpenChange, $[66] = showTooltip, $[67] = t20, $[68] = t21) : (t20 = $[67], t21 = $[68]), useEffect(t20, t21);
3125
- let t22, t23;
3126
- $[69] !== content || $[70] !== handleIsOpenChange || $[71] !== showTooltip ? (t22 = () => {
3127
- !content && showTooltip && handleIsOpenChange(!1);
3128
- }, t23 = [
3129
- content,
3130
- handleIsOpenChange,
3131
- showTooltip
3132
- ], $[69] = content, $[70] = handleIsOpenChange, $[71] = showTooltip, $[72] = t22, $[73] = t23) : (t22 = $[72], t23 = $[73]), useEffect(t22, t23);
3133
- let t24, t25;
3134
- $[74] !== handleIsOpenChange || $[75] !== showTooltip ? (t24 = () => {
3135
- if (!showTooltip) return;
3136
- let handleWindowKeyDown = function handleWindowKeyDown(event) {
3137
- event.key === "Escape" && handleIsOpenChange(!1, !0);
3138
- };
3139
- return window.addEventListener("keydown", handleWindowKeyDown), () => {
3140
- window.removeEventListener("keydown", handleWindowKeyDown);
3141
- };
3142
- }, t25 = [handleIsOpenChange, showTooltip], $[74] = handleIsOpenChange, $[75] = showTooltip, $[76] = t24, $[77] = t25) : (t24 = $[76], t25 = $[77]), useEffect(t24, t25);
3143
- let t26;
3144
- $[78] !== boundaryElement || $[79] !== portalElement?.offsetWidth ? (t26 = () => {
3145
- let availableWidths = [...boundaryElement ? [boundaryElement.offsetWidth] : [], portalElement?.offsetWidth || document.body.offsetWidth];
3146
- setTooltipMaxWidth(Math.min(...availableWidths) - 8);
3147
- }, $[78] = boundaryElement, $[79] = portalElement?.offsetWidth, $[80] = t26) : t26 = $[80];
3148
- let t27;
3149
- $[81] !== boundaryElement || $[82] !== portalElement ? (t27 = [boundaryElement, portalElement], $[81] = boundaryElement, $[82] = portalElement, $[83] = t27) : t27 = $[83], useLayoutEffect(t26, t27);
3150
- let t28;
3151
- $[84] === update ? t28 = $[85] : (t28 = (arrowEl) => {
3152
- arrowRef.current = arrowEl, update();
3153
- }, $[84] = update, $[85] = t28);
3154
- let setArrow = t28, t29;
3155
- $[86] === refs ? t29 = $[87] : (t29 = (node) => {
3156
- ref.current = node, refs.setFloating(node);
3157
- }, $[86] = refs, $[87] = t29);
3158
- let setFloating = t29, t30;
3159
- bb0: {
3160
- if (!childProp) {
3161
- t30 = null;
3162
- break bb0;
3163
- }
3164
- let t31;
3165
- $[88] !== childProp || $[89] !== handleBlur || $[90] !== handleClick || $[91] !== handleContextMenu || $[92] !== handleFocus || $[93] !== handleMouseEnter || $[94] !== handleMouseLeave ? (t31 = cloneElement(childProp, {
3166
- onBlur: handleBlur,
3167
- onFocus: handleFocus,
3168
- onMouseEnter: handleMouseEnter,
3169
- onMouseLeave: handleMouseLeave,
3170
- onClick: handleClick,
3171
- onContextMenu: handleContextMenu,
3172
- ref: setReferenceElement
3173
- }), $[88] = childProp, $[89] = handleBlur, $[90] = handleClick, $[91] = handleContextMenu, $[92] = handleFocus, $[93] = handleMouseEnter, $[94] = handleMouseLeave, $[95] = t31) : t31 = $[95], t30 = t31;
3174
- }
3175
- let child = t30, t31;
3176
- $[96] === childProp ? t31 = $[97] : (t31 = childProp ? getElementRef(childProp) : null, $[96] = childProp, $[97] = t31);
3177
- let t32, t33;
3178
- if ($[98] === referenceElement ? (t32 = $[99], t33 = $[100]) : (t32 = () => referenceElement, t33 = [referenceElement], $[98] = referenceElement, $[99] = t32, $[100] = t33), useImperativeHandle(t31, t32, t33), !child) {
3179
- let t34;
3180
- return $[101] === Symbol.for("react.memo_cache_sentinel") ? (t34 = /* @__PURE__ */ jsx(Fragment$1, {}), $[101] = t34) : t34 = $[101], t34;
3181
- }
3182
- if (disabled) return child;
3183
- let t34 = tooltipMaxWidth > 0 ? `${tooltipMaxWidth}px` : void 0, t35;
3184
- $[102] !== floatingStyles || $[103] !== t34 ? (t35 = {
3185
- ...floatingStyles,
3186
- maxWidth: t34
3187
- }, $[102] = floatingStyles, $[103] = t34, $[104] = t35) : t35 = $[104];
3188
- let t36;
3189
- $[105] !== animate || $[106] !== arrowProp || $[107] !== arrowX || $[108] !== arrowY || $[109] !== content || $[110] !== originX || $[111] !== originY || $[112] !== padding || $[113] !== placement || $[114] !== radius || $[115] !== restProps || $[116] !== scheme || $[117] !== setArrow || $[118] !== setFloating || $[119] !== shadow ? (t36 = /* @__PURE__ */ jsx(TooltipCard, {
3190
- ...restProps,
3191
- animate,
3192
- arrow: arrowProp,
3193
- arrowRef: setArrow,
3194
- arrowX,
3195
- arrowY,
3196
- originX,
3197
- originY,
3198
- padding,
3199
- placement,
3200
- radius,
3201
- ref: setFloating,
3202
- scheme,
3203
- shadow,
3204
- children: content
3205
- }), $[105] = animate, $[106] = arrowProp, $[107] = arrowX, $[108] = arrowY, $[109] = content, $[110] = originX, $[111] = originY, $[112] = padding, $[113] = placement, $[114] = radius, $[115] = restProps, $[116] = scheme, $[117] = setArrow, $[118] = setFloating, $[119] = shadow, $[120] = t36) : t36 = $[120];
3206
- let t37;
3207
- $[121] !== restProps || $[122] !== setFloating || $[123] !== t35 || $[124] !== t36 || $[125] !== zOffset ? (t37 = /* @__PURE__ */ jsx(StyledTooltip, {
3208
- "data-ui": "Tooltip",
3209
- ...restProps,
3210
- ref: setFloating,
3211
- style: t35,
3212
- zOffset,
3213
- children: t36
3214
- }), $[121] = restProps, $[122] = setFloating, $[123] = t35, $[124] = t36, $[125] = zOffset, $[126] = t37) : t37 = $[126];
3215
- let tooltip = t37, t38;
3216
- $[127] !== portalProp || $[128] !== showTooltip || $[129] !== tooltip ? (t38 = showTooltip && (portalProp ? /* @__PURE__ */ jsx(Portal, {
3217
- __unstable_name: typeof portalProp == "string" ? portalProp : void 0,
3218
- children: tooltip
3219
- }) : tooltip), $[127] = portalProp, $[128] = showTooltip, $[129] = tooltip, $[130] = t38) : t38 = $[130];
3220
- let children = t38, t39;
3221
- $[131] !== animate || $[132] !== children ? (t39 = animate ? /* @__PURE__ */ jsx(AnimatePresence, { children }) : children, $[131] = animate, $[132] = children, $[133] = t39) : t39 = $[133];
3222
- let t40;
3223
- return $[134] !== child || $[135] !== t39 ? (t40 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t39, child] }), $[134] = child, $[135] = t39, $[136] = t40) : t40 = $[136], t40;
3224
- });
3225
- function useMiddleware(t0) {
3226
- let $ = c(17), { animate, arrowProp, arrowRef, boundaryElement, fallbackPlacements, rootBoundary } = t0, ret;
3227
- if ($[0] !== animate || $[1] !== arrowProp || $[2] !== arrowRef || $[3] !== boundaryElement || $[4] !== fallbackPlacements || $[5] !== rootBoundary) {
3228
- ret = [];
3229
- let t1 = boundaryElement || void 0, t2;
3230
- $[7] !== fallbackPlacements || $[8] !== rootBoundary || $[9] !== t1 ? (t2 = flip({
3231
- boundary: t1,
3232
- fallbackPlacements,
3233
- padding: 4,
3234
- rootBoundary
3235
- }), $[7] = fallbackPlacements, $[8] = rootBoundary, $[9] = t1, $[10] = t2) : t2 = $[10], ret.push(t2);
3236
- let t3;
3237
- $[11] === Symbol.for("react.memo_cache_sentinel") ? (t3 = offset({ mainAxis: 4 }), $[11] = t3) : t3 = $[11], ret.push(t3);
3238
- let t4 = boundaryElement || void 0, t5;
3239
- if ($[12] !== rootBoundary || $[13] !== t4 ? (t5 = shift({
3240
- boundary: t4,
3241
- rootBoundary,
3242
- padding: 4
3243
- }), $[12] = rootBoundary, $[13] = t4, $[14] = t5) : t5 = $[14], ret.push(t5), arrowProp) {
3244
- let t6;
3245
- $[15] === arrowRef ? t6 = $[16] : (t6 = arrow({
3246
- element: arrowRef,
3247
- padding: 4
3248
- }), $[15] = arrowRef, $[16] = t6), ret.push(t6);
3249
- }
3250
- animate && ret.push(origin), $[0] = animate, $[1] = arrowProp, $[2] = arrowRef, $[3] = boundaryElement, $[4] = fallbackPlacements, $[5] = rootBoundary, $[6] = ret;
3251
- } else ret = $[6];
3252
- return ret;
3253
- }
3254
- /**
3255
- * As `useEffectEvent` should never be passed to other components or hooks, this custom hook groups together the `useEffectEvent` and the `useEffect` hook using it.
3256
- * @see https://19.react.dev/learn/separating-events-from-effects#reading-latest-props-and-state-with-effect-events:~:text=Never%20pass%20them%20to%20other%20components%20or%20Hooks
3257
- */
3258
- function useCloseOnMouseLeave(t0) {
3259
- let $ = c(10), { handleIsOpenChange, referenceElement, showTooltip, isInsideGroup } = t0, t1;
3260
- $[0] !== handleIsOpenChange || $[1] !== referenceElement ? (t1 = (target, teardown) => {
3261
- referenceElement && (referenceElement === target || target instanceof Node && referenceElement.contains(target) || (handleIsOpenChange(!1), teardown()));
3262
- }, $[0] = handleIsOpenChange, $[1] = referenceElement, $[2] = t1) : t1 = $[2];
3263
- let onMouseMove = useEffectEvent(t1), t2;
3264
- $[3] !== isInsideGroup || $[4] !== onMouseMove || $[5] !== showTooltip ? (t2 = () => {
3265
- if (!showTooltip || isInsideGroup) return;
3266
- let handleMouseMove = (event) => {
3267
- onMouseMove(event.target, () => window.removeEventListener("mousemove", handleMouseMove));
3268
- };
3269
- return window.addEventListener("mousemove", handleMouseMove), () => window.removeEventListener("mousemove", handleMouseMove);
3270
- }, $[3] = isInsideGroup, $[4] = onMouseMove, $[5] = showTooltip, $[6] = t2) : t2 = $[6];
3271
- let t3;
3272
- $[7] !== isInsideGroup || $[8] !== showTooltip ? (t3 = [isInsideGroup, showTooltip], $[7] = isInsideGroup, $[8] = showTooltip, $[9] = t3) : t3 = $[9], useEffect(t2, t3);
3273
- }
3274
- /**
3275
- * @public
3276
- */
3277
- function PortalProvider(props) {
3278
- let $ = c(7), { boundaryElement, children, element, __unstable_elements: elements } = props, fallbackElement = useSyncExternalStore(emptySubscribe, _temp, _temp2), t0 = boundaryElement || null, t1 = element || fallbackElement, t2;
3279
- $[0] !== elements || $[1] !== t0 || $[2] !== t1 ? (t2 = {
3280
- version: 0,
3281
- boundaryElement: t0,
3282
- element: t1,
3283
- elements
3284
- }, $[0] = elements, $[1] = t0, $[2] = t1, $[3] = t2) : t2 = $[3];
3285
- let value = t2, t3;
3286
- return $[4] !== children || $[5] !== value ? (t3 = /* @__PURE__ */ jsx(PortalContext.Provider, {
3287
- value,
3288
- children
3289
- }), $[4] = children, $[5] = value, $[6] = t3) : t3 = $[6], t3;
3290
- }
3291
- function _temp2() {
3292
- return null;
3293
- }
3294
- function _temp() {
3295
- return document.body;
3296
- }
3297
- const emptySubscribe = () => () => {};
3298
- export { Spinner as $, Arrow as A, parseColor as At, useMediaIndex as B, textInputRepresentationStyle as C, isHTMLTextAreaElement as Ct, useCustomValidity as D, hexToRgb as Dt, responsiveInputPaddingStyle as E, createColorTheme as Et, useBoundaryElement as F, studioTheme as Ft, ThemeColorProvider as G, _elementSizeObserver as H, BoundaryElementContext as I, createGlobalScopedContext as J, useRootTheme as K, isRecord as L, usePortal as M, rgbToHsl as Mt, useLayer as N, rgba as Nt, Stack as O, hslToRgb as Ot, LayerProvider as P, screen as Pt, _cardColorStyle as Q, usePrefersReducedMotion as R, textInputFontSizeStyle as S, isHTMLSelectElement as St, responsiveInputPaddingIconRightStyle as T, EMPTY_RECORD as Tt, _ResizeObserver as U, useElementSize as V, Card as W, focusRingBorderStyle as X, Button as Y, focusRingStyle as Z, Layer as _, containsOrEqualsElement as _t, useDelayedState as a, Flex as at, TextInput as b, isHTMLElement as bt, TabList as c, responsiveRadiusStyle as ct, MenuGroup as d, _fillCSSObject as dt, Text as et, MenuDivider as f, _getArrayProp as ft, Inline as g, _isEnterToClickElement as gt, KBD as h, rem as ht, TooltipDelayGroupContext as i, responsiveTextAlignStyle as it, Portal as j, rgbToHex as jt, Popover as k, multiply as kt, Tab as l, Box as lt, Hotkeys as m, _responsive as mt, Tooltip as n, responsiveTextFont as nt, usePrefersDark as o, useTheme$1 as ot, Menu as p, _getResponsiveSpace as pt, ThemeProvider$1 as q, useTooltipDelayGroup as r, responsiveFont as rt, Grid as s, useTheme_v2 as st, PortalProvider as t, SpanWithTextOverflow as tt, MenuItem as u, responsivePaddingStyle as ut, useGlobalKeyDown as v, isHTMLAnchorElement as vt, textInputRootStyle as w, EMPTY_ARRAY as wt, textInputBaseStyle as x, isHTMLInputElement as xt, useClickOutsideEvent as y, isHTMLButtonElement as yt, useMatchMedia as z };
3299
-
3300
- //# sourceMappingURL=portalProvider.js.map