@sanity/ui 3.0.14 → 3.0.15-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks-cjs/_visual-editing.js +758 -1819
- package/dist/_chunks-cjs/_visual-editing.js.map +1 -1
- package/dist/_chunks-cjs/refractor.js +7 -15
- package/dist/_chunks-cjs/refractor.js.map +1 -1
- package/dist/_chunks-es/_visual-editing.mjs +760 -1822
- package/dist/_chunks-es/_visual-editing.mjs.map +1 -1
- package/dist/_chunks-es/refractor.mjs +6 -15
- package/dist/_chunks-es/refractor.mjs.map +1 -1
- package/dist/index.js +346 -847
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +347 -849
- package/dist/index.mjs.map +1 -1
- package/package.json +27 -41
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
-
var _visualEditing = require("./_chunks-cjs/_visual-editing.js"), jsxRuntime = require("react/jsx-runtime"),
|
|
3
|
+
var _visualEditing = require("./_chunks-cjs/_visual-editing.js"), jsxRuntime = require("react/jsx-runtime"), icons = require("@sanity/icons"), react = require("react"), styledComponents = require("styled-components"), theme = require("@sanity/ui/theme"), framerMotion = require("framer-motion");
|
|
4
4
|
function _raf(fn) {
|
|
5
5
|
const frameId = requestAnimationFrame(fn);
|
|
6
6
|
return () => {
|
|
@@ -48,9 +48,7 @@ function focusLastDescendant(element) {
|
|
|
48
48
|
return !1;
|
|
49
49
|
}
|
|
50
50
|
function useArrayProp(val, defaultVal) {
|
|
51
|
-
|
|
52
|
-
let t0;
|
|
53
|
-
return $[0] !== defaultVal || $[1] !== val ? (t0 = _visualEditing._getArrayProp(val, defaultVal), $[0] = defaultVal, $[1] = val, $[2] = t0) : t0 = $[2], t0;
|
|
51
|
+
return react.useMemo(() => _visualEditing._getArrayProp(val, defaultVal), [val, defaultVal]);
|
|
54
52
|
}
|
|
55
53
|
function _getElements(element, elementsArg) {
|
|
56
54
|
const ret = [element];
|
|
@@ -58,13 +56,9 @@ function _getElements(element, elementsArg) {
|
|
|
58
56
|
Array.isArray(el) ? ret.push(...el) : ret.push(el);
|
|
59
57
|
return ret.filter(Boolean);
|
|
60
58
|
}
|
|
61
|
-
function useClickOutside(listener,
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
$[0] !== element || $[1] !== elementsArg ? (t1 = () => _getElements(element, elementsArg), $[0] = element, $[1] = elementsArg, $[2] = t1) : t1 = $[2];
|
|
65
|
-
const [elements, setElements] = react.useState(t1), elementsRef = react.useRef(elements);
|
|
66
|
-
let t2, t3;
|
|
67
|
-
$[3] !== element || $[4] !== elementsArg ? (t2 = () => {
|
|
59
|
+
function useClickOutside(listener, elementsArg = _visualEditing.EMPTY_ARRAY, boundaryElement) {
|
|
60
|
+
const [element, setElement] = react.useState(null), [elements, setElements] = react.useState(() => _getElements(element, elementsArg)), elementsRef = react.useRef(elements);
|
|
61
|
+
return react.useEffect(() => {
|
|
68
62
|
const prevElements = elementsRef.current, nextElements = _getElements(element, elementsArg);
|
|
69
63
|
if (prevElements.length !== nextElements.length) {
|
|
70
64
|
setElements(nextElements), elementsRef.current = nextElements;
|
|
@@ -75,21 +69,18 @@ function useClickOutside(listener, t0, boundaryElement) {
|
|
|
75
69
|
setElements(nextElements), elementsRef.current = nextElements;
|
|
76
70
|
return;
|
|
77
71
|
}
|
|
78
|
-
for (const
|
|
79
|
-
if (!prevElements.includes(
|
|
72
|
+
for (const el of nextElements)
|
|
73
|
+
if (!prevElements.includes(el)) {
|
|
80
74
|
setElements(nextElements), elementsRef.current = nextElements;
|
|
81
75
|
return;
|
|
82
76
|
}
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
return $[7] !== boundaryElement || $[8] !== elements || $[9] !== listener ? (t4 = () => {
|
|
86
|
-
if (!listener)
|
|
87
|
-
return;
|
|
77
|
+
}, [element, elementsArg]), react.useEffect(() => {
|
|
78
|
+
if (!listener) return;
|
|
88
79
|
const handleWindowMouseDown = (evt) => {
|
|
89
80
|
const target = evt.target;
|
|
90
81
|
if (target instanceof Node && !(boundaryElement && !boundaryElement.contains(target))) {
|
|
91
|
-
for (const
|
|
92
|
-
if (target ===
|
|
82
|
+
for (const el of elements)
|
|
83
|
+
if (target === el || el.contains(target))
|
|
93
84
|
return;
|
|
94
85
|
listener(evt);
|
|
95
86
|
}
|
|
@@ -97,15 +88,14 @@ function useClickOutside(listener, t0, boundaryElement) {
|
|
|
97
88
|
return window.addEventListener("mousedown", handleWindowMouseDown), () => {
|
|
98
89
|
window.removeEventListener("mousedown", handleWindowMouseDown);
|
|
99
90
|
};
|
|
100
|
-
},
|
|
91
|
+
}, [boundaryElement, listener, elements]), setElement;
|
|
101
92
|
}
|
|
102
93
|
function useElementRect(element) {
|
|
103
94
|
return _visualEditing.useElementSize(element)?._contentRect || null;
|
|
104
95
|
}
|
|
105
96
|
function useForwardedRef(ref) {
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => innerRef.current, $[0] = t0) : t0 = $[0], react.useImperativeHandle(ref, t0), innerRef;
|
|
97
|
+
const innerRef = react.useRef(null);
|
|
98
|
+
return react.useImperativeHandle(ref, () => innerRef.current), innerRef;
|
|
109
99
|
}
|
|
110
100
|
class ErrorBoundary extends react.Component {
|
|
111
101
|
state = {
|
|
@@ -152,27 +142,20 @@ const StyledAutocomplete = styledComponents.styled.div.withConfig({
|
|
|
152
142
|
componentId: "sc-1igauft-2"
|
|
153
143
|
})`animation:${rotate} 500ms linear infinite;`;
|
|
154
144
|
function AutocompleteOption(props) {
|
|
155
|
-
const
|
|
145
|
+
const {
|
|
156
146
|
children,
|
|
157
147
|
id,
|
|
158
148
|
onSelect,
|
|
159
149
|
selected,
|
|
160
150
|
value
|
|
161
|
-
} = props
|
|
162
|
-
let t0;
|
|
163
|
-
$[0] !== onSelect || $[1] !== value ? (t0 = () => {
|
|
151
|
+
} = props, handleClick = react.useCallback(() => {
|
|
164
152
|
setTimeout(() => {
|
|
165
153
|
onSelect(value);
|
|
166
154
|
}, 0);
|
|
167
|
-
},
|
|
168
|
-
const handleClick = t0;
|
|
169
|
-
let t1;
|
|
170
|
-
$[3] !== handleClick ? (t1 = (event) => {
|
|
155
|
+
}, [onSelect, value]), handleKeyDown = react.useCallback((event) => {
|
|
171
156
|
event.key === "Enter" && !_visualEditing._isEnterToClickElement(event.currentTarget) && handleClick();
|
|
172
|
-
},
|
|
173
|
-
|
|
174
|
-
let t2;
|
|
175
|
-
return $[5] !== children || $[6] !== handleClick || $[7] !== handleKeyDown || $[8] !== id || $[9] !== selected ? (t2 = /* @__PURE__ */ jsxRuntime.jsx("li", { "aria-selected": selected, "data-ui": "AutocompleteOption", id, role: "option", onClick: handleClick, onKeyDown: handleKeyDown, children }), $[5] = children, $[6] = handleClick, $[7] = handleKeyDown, $[8] = id, $[9] = selected, $[10] = t2) : t2 = $[10], t2;
|
|
157
|
+
}, [handleClick]);
|
|
158
|
+
return /* @__PURE__ */ jsxRuntime.jsx("li", { "aria-selected": selected, "data-ui": "AutocompleteOption", id, role: "option", onClick: handleClick, onKeyDown: handleKeyDown, children });
|
|
176
159
|
}
|
|
177
160
|
function autocompleteReducer(state, msg) {
|
|
178
161
|
return msg.type === "input/change" ? {
|
|
@@ -214,17 +197,15 @@ function autocompleteReducer(state, msg) {
|
|
|
214
197
|
} : state;
|
|
215
198
|
}
|
|
216
199
|
const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = ["Control", "Shift", "Alt", "Enter", "Home", "End", "PageUp", "PageDown", "Meta", "Tab", "CapsLock"], AUTOCOMPLETE_POPOVER_PLACEMENT = "bottom-start", AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS = ["bottom-start", "top-start"], DEFAULT_RENDER_VALUE = (value, option) => option ? option.value : value, DEFAULT_FILTER_OPTION = (query, option) => option.value.toLowerCase().indexOf(query.toLowerCase()) > -1, InnerAutocomplete = react.forwardRef(function(props, forwardedRef) {
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
$[0] !== props ? ({
|
|
220
|
-
border: t0,
|
|
200
|
+
const {
|
|
201
|
+
border = !0,
|
|
221
202
|
customValidity,
|
|
222
203
|
disabled,
|
|
223
204
|
filterOption: filterOptionProp,
|
|
224
|
-
fontSize
|
|
205
|
+
fontSize = 2,
|
|
225
206
|
icon,
|
|
226
207
|
id,
|
|
227
|
-
listBox
|
|
208
|
+
listBox = _visualEditing.EMPTY_RECORD,
|
|
228
209
|
loading,
|
|
229
210
|
onBlur,
|
|
230
211
|
onChange,
|
|
@@ -234,60 +215,35 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = ["Control", "Shift", "Alt", "Enter", "H
|
|
|
234
215
|
openButton,
|
|
235
216
|
openOnFocus,
|
|
236
217
|
options: optionsProp,
|
|
237
|
-
padding:
|
|
238
|
-
popover
|
|
218
|
+
padding: paddingProp = 3,
|
|
219
|
+
popover = _visualEditing.EMPTY_RECORD,
|
|
239
220
|
prefix,
|
|
240
|
-
radius
|
|
221
|
+
radius = 2,
|
|
241
222
|
readOnly,
|
|
242
223
|
relatedElements,
|
|
243
224
|
renderOption: renderOptionProp,
|
|
244
225
|
renderPopover,
|
|
245
|
-
renderValue
|
|
226
|
+
renderValue = DEFAULT_RENDER_VALUE,
|
|
246
227
|
suffix,
|
|
247
228
|
value: valueProp,
|
|
248
229
|
...restProps
|
|
249
|
-
} = props,
|
|
250
|
-
|
|
251
|
-
let t9;
|
|
252
|
-
$[30] !== t7 || $[31] !== t8 ? (t9 = {
|
|
253
|
-
activeValue: t7,
|
|
230
|
+
} = props, [state, dispatch] = react.useReducer(autocompleteReducer, {
|
|
231
|
+
activeValue: valueProp || null,
|
|
254
232
|
focused: !1,
|
|
255
233
|
listFocused: !1,
|
|
256
234
|
query: null,
|
|
257
|
-
value:
|
|
258
|
-
},
|
|
259
|
-
const [state, dispatch] = react.useReducer(autocompleteReducer, t9), {
|
|
235
|
+
value: valueProp || null
|
|
236
|
+
}), {
|
|
260
237
|
activeValue,
|
|
261
238
|
focused,
|
|
262
239
|
listFocused,
|
|
263
240
|
query,
|
|
264
241
|
value
|
|
265
|
-
} = state
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
} = t112;
|
|
271
|
-
return /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Card, { "data-as": "button", padding: paddingProp, radius: 2, tone: "inherit", children: /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Text, { size: fontSize, textOverflow: "ellipsis", children: value_0 }) });
|
|
272
|
-
}, $[33] = fontSize, $[34] = paddingProp, $[35] = t10) : t10 = $[35];
|
|
273
|
-
const renderOption = typeof renderOptionProp == "function" ? renderOptionProp : t10, filterOption = typeof filterOptionProp == "function" ? filterOptionProp : DEFAULT_FILTER_OPTION, rootElementRef = react.useRef(null), resultsPopoverElementRef = react.useRef(null), inputElementRef = react.useRef(null), listBoxElementRef = react.useRef(null), [inputElement, setInputElement] = react.useState(null), listFocusedRef = react.useRef(!1), valueRef = react.useRef(value), valuePropRef = react.useRef(valueProp), popoverMouseWithinRef = react.useRef(!1);
|
|
274
|
-
let t11, t12;
|
|
275
|
-
$[36] !== inputElement ? (t11 = () => inputElement, t12 = [inputElement], $[36] = inputElement, $[37] = t11, $[38] = t12) : (t11 = $[37], t12 = $[38]), react.useImperativeHandle(inputElementRef, t11, t12);
|
|
276
|
-
let t13, t14;
|
|
277
|
-
$[39] !== inputElement ? (t13 = () => inputElement, t14 = [inputElement], $[39] = inputElement, $[40] = t13, $[41] = t14) : (t13 = $[40], t14 = $[41]), react.useImperativeHandle(forwardedRef, t13, t14);
|
|
278
|
-
const listBoxId = `${id}-listbox`, options = Array.isArray(optionsProp) ? optionsProp : _visualEditing.EMPTY_ARRAY, padding = _visualEditing._getArrayProp(paddingProp);
|
|
279
|
-
let t15;
|
|
280
|
-
$[42] !== options || $[43] !== value ? (t15 = value !== null ? options.find((o) => o.value === value) : void 0, $[42] = options, $[43] = value, $[44] = t15) : t15 = $[44];
|
|
281
|
-
const currentOption = t15;
|
|
282
|
-
let t16;
|
|
283
|
-
if ($[45] !== filterOption || $[46] !== options || $[47] !== query) {
|
|
284
|
-
let t172;
|
|
285
|
-
$[49] !== filterOption || $[50] !== query ? (t172 = (option) => query ? filterOption(query, option) : !0, $[49] = filterOption, $[50] = query, $[51] = t172) : t172 = $[51], t16 = options.filter(t172), $[45] = filterOption, $[46] = options, $[47] = query, $[48] = t16;
|
|
286
|
-
} else
|
|
287
|
-
t16 = $[48];
|
|
288
|
-
const filteredOptions = t16, filteredOptionsLen = filteredOptions.length, activeItemId = activeValue ? `${id}-option-${activeValue}` : void 0, expanded = query !== null && loading || focused && query !== null;
|
|
289
|
-
let t17;
|
|
290
|
-
$[52] !== onBlur || $[53] !== onQueryChange || $[54] !== relatedElements ? (t17 = (event) => {
|
|
242
|
+
} = state, defaultRenderOption = react.useCallback(({
|
|
243
|
+
value: value2
|
|
244
|
+
}) => /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Card, { "data-as": "button", padding: paddingProp, radius: 2, tone: "inherit", children: /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Text, { size: fontSize, textOverflow: "ellipsis", children: value2 }) }), [fontSize, paddingProp]), renderOption = typeof renderOptionProp == "function" ? renderOptionProp : defaultRenderOption, filterOption = typeof filterOptionProp == "function" ? filterOptionProp : DEFAULT_FILTER_OPTION, rootElementRef = react.useRef(null), resultsPopoverElementRef = react.useRef(null), inputElementRef = react.useRef(null), listBoxElementRef = react.useRef(null), [inputElement, setInputElement] = react.useState(null), listFocusedRef = react.useRef(!1), valueRef = react.useRef(value), valuePropRef = react.useRef(valueProp), popoverMouseWithinRef = react.useRef(!1);
|
|
245
|
+
react.useImperativeHandle(inputElementRef, () => inputElement, [inputElement]), react.useImperativeHandle(forwardedRef, () => inputElement, [inputElement]);
|
|
246
|
+
const listBoxId = `${id}-listbox`, options = Array.isArray(optionsProp) ? optionsProp : _visualEditing.EMPTY_ARRAY, padding = _visualEditing._getArrayProp(paddingProp), currentOption = react.useMemo(() => value !== null ? options.find((o) => o.value === value) : void 0, [options, value]), filteredOptions = react.useMemo(() => options.filter((option) => query ? filterOption(query, option) : !0), [filterOption, options, query]), filteredOptionsLen = filteredOptions.length, activeItemId = activeValue ? `${id}-option-${activeValue}` : void 0, expanded = query !== null && loading || focused && query !== null, handleRootBlur = react.useCallback((event) => {
|
|
291
247
|
setTimeout(() => {
|
|
292
248
|
if (popoverMouseWithinRef.current)
|
|
293
249
|
return;
|
|
@@ -304,31 +260,21 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = ["Control", "Shift", "Alt", "Enter", "H
|
|
|
304
260
|
type: "root/blur"
|
|
305
261
|
}), popoverMouseWithinRef.current = !1, onQueryChange && onQueryChange(null), onBlur && onBlur(event));
|
|
306
262
|
}, 0);
|
|
307
|
-
},
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
$[56] === Symbol.for("react.memo_cache_sentinel") ? (t18 = (event_0) => {
|
|
311
|
-
const listBoxElement = listBoxElementRef.current, focusedElement = event_0.target instanceof HTMLElement ? event_0.target : null, listFocused_0 = listBoxElement?.contains(focusedElement) || !1;
|
|
312
|
-
listFocused_0 !== listFocusedRef.current && (listFocusedRef.current = listFocused_0, dispatch({
|
|
263
|
+
}, [onBlur, onQueryChange, relatedElements]), handleRootFocus = react.useCallback((event) => {
|
|
264
|
+
const listBoxElement = listBoxElementRef.current, focusedElement = event.target instanceof HTMLElement ? event.target : null, listFocused2 = listBoxElement?.contains(focusedElement) || !1;
|
|
265
|
+
listFocused2 !== listFocusedRef.current && (listFocusedRef.current = listFocused2, dispatch({
|
|
313
266
|
type: "root/setListFocused",
|
|
314
|
-
listFocused:
|
|
267
|
+
listFocused: listFocused2
|
|
315
268
|
}));
|
|
316
|
-
},
|
|
317
|
-
const handleRootFocus = t18;
|
|
318
|
-
let t19;
|
|
319
|
-
$[57] !== onChange || $[58] !== onQueryChange || $[59] !== onSelect ? (t19 = (v) => {
|
|
269
|
+
}, []), handleOptionSelect = react.useCallback((v) => {
|
|
320
270
|
dispatch({
|
|
321
271
|
type: "value/change",
|
|
322
272
|
value: v
|
|
323
273
|
}), popoverMouseWithinRef.current = !1, onSelect && onSelect(v), valueRef.current = v, onChange && onChange(v), onQueryChange && onQueryChange(null), inputElementRef.current?.focus();
|
|
324
|
-
},
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
if (event_1.key === "ArrowDown") {
|
|
329
|
-
if (event_1.preventDefault(), !filteredOptionsLen)
|
|
330
|
-
return;
|
|
331
|
-
const activeOption = filteredOptions.find((o_0) => o_0.value === activeValue), activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1, nextActiveOption = filteredOptions[(activeIndex + 1) % filteredOptionsLen];
|
|
274
|
+
}, [onChange, onSelect, onQueryChange]), handleRootKeyDown = react.useCallback((event) => {
|
|
275
|
+
if (event.key === "ArrowDown") {
|
|
276
|
+
if (event.preventDefault(), !filteredOptionsLen) return;
|
|
277
|
+
const activeOption = filteredOptions.find((o) => o.value === activeValue), activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1, nextActiveOption = filteredOptions[(activeIndex + 1) % filteredOptionsLen];
|
|
332
278
|
nextActiveOption && dispatch({
|
|
333
279
|
type: "root/setActiveValue",
|
|
334
280
|
value: nextActiveOption.value,
|
|
@@ -336,80 +282,56 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = ["Control", "Shift", "Alt", "Enter", "H
|
|
|
336
282
|
});
|
|
337
283
|
return;
|
|
338
284
|
}
|
|
339
|
-
if (
|
|
340
|
-
if (
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
nextActiveOption_0 && dispatch({
|
|
285
|
+
if (event.key === "ArrowUp") {
|
|
286
|
+
if (event.preventDefault(), !filteredOptionsLen) return;
|
|
287
|
+
const activeOption = filteredOptions.find((o) => o.value === activeValue), activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1, nextActiveOption = filteredOptions[activeIndex === -1 ? filteredOptionsLen - 1 : (filteredOptionsLen + activeIndex - 1) % filteredOptionsLen];
|
|
288
|
+
nextActiveOption && dispatch({
|
|
344
289
|
type: "root/setActiveValue",
|
|
345
|
-
value:
|
|
290
|
+
value: nextActiveOption.value,
|
|
346
291
|
listFocused: !0
|
|
347
292
|
});
|
|
348
293
|
return;
|
|
349
294
|
}
|
|
350
|
-
if (
|
|
295
|
+
if (event.key === "Escape") {
|
|
351
296
|
dispatch({
|
|
352
297
|
type: "root/escape"
|
|
353
298
|
}), popoverMouseWithinRef.current = !1, onQueryChange && onQueryChange(null), inputElementRef.current?.focus();
|
|
354
299
|
return;
|
|
355
300
|
}
|
|
356
|
-
const target =
|
|
357
|
-
if ((listEl === target || listEl?.contains(target)) && !AUTOCOMPLETE_LISTBOX_IGNORE_KEYS.includes(
|
|
301
|
+
const target = event.target, listEl = listBoxElementRef.current;
|
|
302
|
+
if ((listEl === target || listEl?.contains(target)) && !AUTOCOMPLETE_LISTBOX_IGNORE_KEYS.includes(event.key)) {
|
|
358
303
|
inputElementRef.current?.focus();
|
|
359
304
|
return;
|
|
360
305
|
}
|
|
361
|
-
},
|
|
362
|
-
|
|
363
|
-
let t21;
|
|
364
|
-
$[66] !== onQueryChange ? (t21 = (event_2) => {
|
|
365
|
-
const nextQuery = event_2.currentTarget.value;
|
|
306
|
+
}, [activeValue, filteredOptions, filteredOptionsLen, onQueryChange]), handleInputChange = react.useCallback((event) => {
|
|
307
|
+
const nextQuery = event.currentTarget.value;
|
|
366
308
|
dispatch({
|
|
367
309
|
type: "input/change",
|
|
368
310
|
query: nextQuery
|
|
369
311
|
}), onQueryChange && onQueryChange(nextQuery);
|
|
370
|
-
},
|
|
371
|
-
const handleInputChange = t21;
|
|
372
|
-
let t22;
|
|
373
|
-
$[68] !== currentOption || $[69] !== renderValue || $[70] !== value ? (t22 = () => {
|
|
312
|
+
}, [onQueryChange]), dispatchOpen = react.useCallback(() => {
|
|
374
313
|
dispatch({
|
|
375
314
|
type: "root/open",
|
|
376
315
|
query: value ? renderValue(value, currentOption) : ""
|
|
377
316
|
});
|
|
378
|
-
},
|
|
379
|
-
const dispatchOpen = t22;
|
|
380
|
-
let t23;
|
|
381
|
-
$[72] !== dispatchOpen || $[73] !== focused || $[74] !== onFocus || $[75] !== openOnFocus ? (t23 = (event_3) => {
|
|
317
|
+
}, [currentOption, renderValue, value]), handleInputFocus = react.useCallback((event) => {
|
|
382
318
|
focused || (dispatch({
|
|
383
319
|
type: "input/focus"
|
|
384
|
-
}), onFocus && onFocus(
|
|
385
|
-
},
|
|
386
|
-
const handleInputFocus = t23;
|
|
387
|
-
let t24;
|
|
388
|
-
$[77] === Symbol.for("react.memo_cache_sentinel") ? (t24 = () => {
|
|
320
|
+
}), onFocus && onFocus(event), openOnFocus && dispatchOpen());
|
|
321
|
+
}, [focused, onFocus, openOnFocus, dispatchOpen]), handlePopoverMouseEnter = react.useCallback(() => {
|
|
389
322
|
popoverMouseWithinRef.current = !0;
|
|
390
|
-
},
|
|
391
|
-
const handlePopoverMouseEnter = t24;
|
|
392
|
-
let t25;
|
|
393
|
-
$[78] === Symbol.for("react.memo_cache_sentinel") ? (t25 = () => {
|
|
323
|
+
}, []), handlePopoverMouseLeave = react.useCallback(() => {
|
|
394
324
|
popoverMouseWithinRef.current = !1;
|
|
395
|
-
},
|
|
396
|
-
const handlePopoverMouseLeave = t25;
|
|
397
|
-
let t26;
|
|
398
|
-
$[79] !== onChange || $[80] !== onQueryChange ? (t26 = () => {
|
|
325
|
+
}, []), handleClearButtonClick = react.useCallback(() => {
|
|
399
326
|
dispatch({
|
|
400
327
|
type: "root/clear"
|
|
401
328
|
}), valueRef.current = "", onChange && onChange(""), onQueryChange && onQueryChange(null), inputElementRef.current?.focus();
|
|
402
|
-
},
|
|
403
|
-
const handleClearButtonClick = t26;
|
|
404
|
-
let t27;
|
|
405
|
-
$[82] === Symbol.for("react.memo_cache_sentinel") ? (t27 = () => {
|
|
329
|
+
}, [onChange, onQueryChange]), handleClearButtonFocus = react.useCallback(() => {
|
|
406
330
|
dispatch({
|
|
407
331
|
type: "input/focus"
|
|
408
332
|
});
|
|
409
|
-
},
|
|
410
|
-
|
|
411
|
-
let t28, t29;
|
|
412
|
-
$[83] !== valueProp ? (t28 = () => {
|
|
333
|
+
}, []);
|
|
334
|
+
react.useEffect(() => {
|
|
413
335
|
if (valueProp !== valuePropRef.current) {
|
|
414
336
|
valuePropRef.current = valueProp, valueProp !== void 0 && (dispatch({
|
|
415
337
|
type: "value/change",
|
|
@@ -421,117 +343,46 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = ["Control", "Shift", "Alt", "Enter", "H
|
|
|
421
343
|
type: "value/change",
|
|
422
344
|
value: valueProp || null
|
|
423
345
|
}));
|
|
424
|
-
},
|
|
425
|
-
let t30, t31;
|
|
426
|
-
$[86] !== focused ? (t30 = () => {
|
|
346
|
+
}, [valueProp]), react.useEffect(() => {
|
|
427
347
|
!focused && valueRef.current && dispatch({
|
|
428
348
|
type: "root/setActiveValue",
|
|
429
349
|
value: valueRef.current
|
|
430
350
|
});
|
|
431
|
-
},
|
|
432
|
-
let t32, t33;
|
|
433
|
-
$[89] !== activeValue || $[90] !== filteredOptions ? (t32 = () => {
|
|
351
|
+
}, [focused]), react.useEffect(() => {
|
|
434
352
|
const listElement = listBoxElementRef.current;
|
|
435
|
-
if (!listElement)
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
const activeIndex_1 = filteredOptions.indexOf(activeOption_1), activeItemElement = listElement.childNodes[activeIndex_1];
|
|
353
|
+
if (!listElement) return;
|
|
354
|
+
const activeOption = filteredOptions.find((o) => o.value === activeValue);
|
|
355
|
+
if (activeOption) {
|
|
356
|
+
const activeIndex = filteredOptions.indexOf(activeOption), activeItemElement = listElement.childNodes[activeIndex];
|
|
440
357
|
if (activeItemElement) {
|
|
441
358
|
if (_hasFocus(activeItemElement))
|
|
442
359
|
return;
|
|
443
360
|
focusFirstDescendant(activeItemElement);
|
|
444
361
|
}
|
|
445
362
|
}
|
|
446
|
-
},
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
let t352;
|
|
451
|
-
$[93] === Symbol.for("react.memo_cache_sentinel") ? (t352 = {
|
|
363
|
+
}, [activeValue, filteredOptions]);
|
|
364
|
+
const clearButton = react.useMemo(() => {
|
|
365
|
+
if (!loading && !disabled && value)
|
|
366
|
+
return {
|
|
452
367
|
"aria-label": "Clear",
|
|
453
368
|
onFocus: handleClearButtonFocus
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
bb1: {
|
|
470
|
-
if (query === null) {
|
|
471
|
-
if (value !== null) {
|
|
472
|
-
let t382;
|
|
473
|
-
$[107] !== currentOption || $[108] !== renderValue || $[109] !== value ? (t382 = renderValue(value, currentOption), $[107] = currentOption, $[108] = renderValue, $[109] = value, $[110] = t382) : t382 = $[110], t37 = t382;
|
|
474
|
-
break bb1;
|
|
475
|
-
}
|
|
476
|
-
t37 = "";
|
|
477
|
-
break bb1;
|
|
478
|
-
}
|
|
479
|
-
t37 = query;
|
|
480
|
-
}
|
|
481
|
-
const inputValue = t37;
|
|
482
|
-
let t38;
|
|
483
|
-
$[111] !== listFocused ? (t38 = (event_5) => {
|
|
484
|
-
event_5.key === "Tab" && listFocused && inputElementRef.current?.focus();
|
|
485
|
-
}, $[111] = listFocused, $[112] = t38) : t38 = $[112];
|
|
486
|
-
const handleListBoxKeyDown = t38;
|
|
487
|
-
let t39;
|
|
488
|
-
bb2: {
|
|
489
|
-
if (filteredOptions.length === 0) {
|
|
490
|
-
t39 = null;
|
|
491
|
-
break bb2;
|
|
492
|
-
}
|
|
493
|
-
let t402;
|
|
494
|
-
if ($[113] !== activeValue || $[114] !== currentOption || $[115] !== filteredOptions || $[116] !== handleOptionSelect || $[117] !== id || $[118] !== listFocused || $[119] !== loading || $[120] !== renderOption) {
|
|
495
|
-
let t413;
|
|
496
|
-
$[122] !== activeValue || $[123] !== currentOption || $[124] !== handleOptionSelect || $[125] !== id || $[126] !== listFocused || $[127] !== loading || $[128] !== renderOption ? (t413 = (option_0) => {
|
|
497
|
-
const active = activeValue !== null ? option_0.value === activeValue : currentOption === option_0;
|
|
498
|
-
return /* @__PURE__ */ jsxRuntime.jsx(AutocompleteOption, { id: `${id}-option-${option_0.value}`, onSelect: handleOptionSelect, selected: active, value: option_0.value, children: react.cloneElement(renderOption(option_0), {
|
|
499
|
-
disabled: loading,
|
|
500
|
-
selected: active,
|
|
501
|
-
tabIndex: listFocused && active ? 0 : -1
|
|
502
|
-
}) }, option_0.value);
|
|
503
|
-
}, $[122] = activeValue, $[123] = currentOption, $[124] = handleOptionSelect, $[125] = id, $[126] = listFocused, $[127] = loading, $[128] = renderOption, $[129] = t413) : t413 = $[129], t402 = filteredOptions.map(t413), $[113] = activeValue, $[114] = currentOption, $[115] = filteredOptions, $[116] = handleOptionSelect, $[117] = id, $[118] = listFocused, $[119] = loading, $[120] = renderOption, $[121] = t402;
|
|
504
|
-
} else
|
|
505
|
-
t402 = $[121];
|
|
506
|
-
let t412;
|
|
507
|
-
$[130] !== listBoxId || $[131] !== t402 ? (t412 = /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Stack, { as: "ul", "aria-multiselectable": !1, "data-ui": "AutoComplete__resultsList", id: listBoxId, ref: listBoxElementRef, role: "listbox", space: 1, children: t402 }), $[130] = listBoxId, $[131] = t402, $[132] = t412) : t412 = $[132];
|
|
508
|
-
let t422;
|
|
509
|
-
$[133] !== handleListBoxKeyDown || $[134] !== listBox || $[135] !== t412 ? (t422 = /* @__PURE__ */ jsxRuntime.jsx(ListBox, { "data-ui": "AutoComplete__results", onKeyDown: handleListBoxKeyDown, padding: 1, ...listBox, tabIndex: -1, children: t412 }), $[133] = handleListBoxKeyDown, $[134] = listBox, $[135] = t412, $[136] = t422) : t422 = $[136], t39 = t422;
|
|
510
|
-
}
|
|
511
|
-
const content2 = t39;
|
|
512
|
-
let t40;
|
|
513
|
-
bb3: {
|
|
514
|
-
if (renderPopover) {
|
|
515
|
-
const t413 = !expanded;
|
|
516
|
-
let t422;
|
|
517
|
-
$[137] !== content2 || $[138] !== handlePopoverMouseEnter || $[139] !== handlePopoverMouseLeave || $[140] !== inputElement || $[141] !== renderPopover || $[142] !== t413 ? (t422 = /* @__PURE__ */ jsxRuntime.jsx(RenderPopover, { content: content2, hidden: t413, inputElement, onMouseEnter: handlePopoverMouseEnter, onMouseLeave: handlePopoverMouseLeave, resultsPopoverElementRef, renderPopover }), $[137] = content2, $[138] = handlePopoverMouseEnter, $[139] = handlePopoverMouseLeave, $[140] = inputElement, $[141] = renderPopover, $[142] = t413, $[143] = t422) : t422 = $[143], t40 = t422;
|
|
518
|
-
break bb3;
|
|
519
|
-
}
|
|
520
|
-
if (filteredOptionsLen === 0) {
|
|
521
|
-
t40 = null;
|
|
522
|
-
break bb3;
|
|
523
|
-
}
|
|
524
|
-
let t412;
|
|
525
|
-
$[144] !== content2 || $[145] !== expanded || $[146] !== handlePopoverMouseEnter || $[147] !== handlePopoverMouseLeave || $[148] !== inputElement || $[149] !== popover || $[150] !== radius ? (t412 = /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Popover, { arrow: !1, constrainSize: !0, content: content2, fallbackPlacements: AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS, matchReferenceWidth: !0, onMouseEnter: handlePopoverMouseEnter, onMouseLeave: handlePopoverMouseLeave, open: expanded, overflow: "auto", placement: AUTOCOMPLETE_POPOVER_PLACEMENT, portal: !0, radius, ref: resultsPopoverElementRef, referenceElement: inputElement, ...popover }), $[144] = content2, $[145] = expanded, $[146] = handlePopoverMouseEnter, $[147] = handlePopoverMouseLeave, $[148] = inputElement, $[149] = popover, $[150] = radius, $[151] = t412) : t412 = $[151], t40 = t412;
|
|
526
|
-
}
|
|
527
|
-
const results = t40, t41 = loading && AnimatedSpinnerIcon, t42 = suffix || openButtonNode;
|
|
528
|
-
let t43;
|
|
529
|
-
$[152] !== activeItemId || $[153] !== border || $[154] !== clearButton || $[155] !== customValidity || $[156] !== disabled || $[157] !== expanded || $[158] !== fontSize || $[159] !== handleClearButtonClick || $[160] !== handleInputChange || $[161] !== handleInputFocus || $[162] !== icon || $[163] !== id || $[164] !== inputValue || $[165] !== listBoxId || $[166] !== padding || $[167] !== prefix || $[168] !== radius || $[169] !== readOnly || $[170] !== restProps || $[171] !== t41 || $[172] !== t42 ? (t43 = /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.TextInput, { ...restProps, "aria-activedescendant": activeItemId, "aria-autocomplete": "list", "aria-expanded": expanded, "aria-owns": listBoxId, autoCapitalize: "off", autoComplete: "off", autoCorrect: "off", border, clearButton, customValidity, disabled, fontSize, icon, iconRight: t41, id, inputMode: "search", onChange: handleInputChange, onClear: handleClearButtonClick, onFocus: handleInputFocus, padding, prefix, radius, readOnly, ref: setInputElement, role: "combobox", spellCheck: !1, suffix: t42, value: inputValue }), $[152] = activeItemId, $[153] = border, $[154] = clearButton, $[155] = customValidity, $[156] = disabled, $[157] = expanded, $[158] = fontSize, $[159] = handleClearButtonClick, $[160] = handleInputChange, $[161] = handleInputFocus, $[162] = icon, $[163] = id, $[164] = inputValue, $[165] = listBoxId, $[166] = padding, $[167] = prefix, $[168] = radius, $[169] = readOnly, $[170] = restProps, $[171] = t41, $[172] = t42, $[173] = t43) : t43 = $[173];
|
|
530
|
-
let t44;
|
|
531
|
-
return $[174] !== handleRootBlur || $[175] !== handleRootFocus || $[176] !== handleRootKeyDown || $[177] !== results || $[178] !== t43 ? (t44 = /* @__PURE__ */ jsxRuntime.jsxs(StyledAutocomplete, { "data-ui": "Autocomplete", onBlur: handleRootBlur, onFocus: handleRootFocus, onKeyDown: handleRootKeyDown, ref: rootElementRef, children: [
|
|
532
|
-
t43,
|
|
369
|
+
};
|
|
370
|
+
}, [disabled, handleClearButtonFocus, loading, value]), openButtonBoxPadding = padding.map((v) => v === 0 ? 0 : v === 1 || v === 2 ? 1 : v - 2), openButtonPadding = padding.map((v) => Math.max(v - 1, 0)), openButtonProps = react.useMemo(() => typeof openButton == "object" ? openButton : _visualEditing.EMPTY_RECORD, [openButton]), handleOpenClick = react.useCallback((event) => {
|
|
371
|
+
dispatchOpen(), openButtonProps.onClick && openButtonProps.onClick(event), _raf(() => inputElementRef.current?.focus());
|
|
372
|
+
}, [openButtonProps, dispatchOpen]), openButtonNode = react.useMemo(() => !disabled && !readOnly && openButton ? /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { "aria-hidden": expanded, padding: openButtonBoxPadding, children: /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Button, { "aria-label": "Open", disabled: expanded, fontSize, icon: icons.ChevronDownIcon, mode: "bleed", padding: openButtonPadding, ...openButtonProps, onClick: handleOpenClick }) }) : void 0, [disabled, expanded, fontSize, handleOpenClick, openButton, openButtonBoxPadding, openButtonPadding, openButtonProps, readOnly]), inputValue = react.useMemo(() => query === null ? value !== null ? renderValue(value, currentOption) : "" : query, [currentOption, query, renderValue, value]), handleListBoxKeyDown = react.useCallback((event) => {
|
|
373
|
+
event.key === "Tab" && listFocused && inputElementRef.current?.focus();
|
|
374
|
+
}, [listFocused]), content2 = react.useMemo(() => filteredOptions.length === 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(ListBox, { "data-ui": "AutoComplete__results", onKeyDown: handleListBoxKeyDown, padding: 1, ...listBox, tabIndex: -1, children: /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Stack, { as: "ul", "aria-multiselectable": !1, "data-ui": "AutoComplete__resultsList", id: listBoxId, ref: listBoxElementRef, role: "listbox", space: 1, children: filteredOptions.map((option) => {
|
|
375
|
+
const active = activeValue !== null ? option.value === activeValue : currentOption === option;
|
|
376
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AutocompleteOption, { id: `${id}-option-${option.value}`, onSelect: handleOptionSelect, selected: active, value: option.value, children: react.cloneElement(renderOption(option), {
|
|
377
|
+
disabled: loading,
|
|
378
|
+
selected: active,
|
|
379
|
+
tabIndex: listFocused && active ? 0 : -1
|
|
380
|
+
}) }, option.value);
|
|
381
|
+
}) }) }), [activeValue, currentOption, filteredOptions, handleOptionSelect, handleListBoxKeyDown, id, listBox, listBoxId, listFocused, loading, renderOption]), results = react.useMemo(() => renderPopover ? /* @__PURE__ */ jsxRuntime.jsx(RenderPopover, { content: content2, hidden: !expanded, inputElement, onMouseEnter: handlePopoverMouseEnter, onMouseLeave: handlePopoverMouseLeave, resultsPopoverElementRef, renderPopover }) : filteredOptionsLen === 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Popover, { arrow: !1, constrainSize: !0, content: content2, fallbackPlacements: AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS, matchReferenceWidth: !0, onMouseEnter: handlePopoverMouseEnter, onMouseLeave: handlePopoverMouseLeave, open: expanded, overflow: "auto", placement: AUTOCOMPLETE_POPOVER_PLACEMENT, portal: !0, radius, ref: resultsPopoverElementRef, referenceElement: inputElement, ...popover }), [content2, expanded, filteredOptionsLen, handlePopoverMouseEnter, handlePopoverMouseLeave, inputElement, popover, radius, renderPopover]);
|
|
382
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(StyledAutocomplete, { "data-ui": "Autocomplete", onBlur: handleRootBlur, onFocus: handleRootFocus, onKeyDown: handleRootKeyDown, ref: rootElementRef, children: [
|
|
383
|
+
/* @__PURE__ */ jsxRuntime.jsx(_visualEditing.TextInput, { ...restProps, "aria-activedescendant": activeItemId, "aria-autocomplete": "list", "aria-expanded": expanded, "aria-owns": listBoxId, autoCapitalize: "off", autoComplete: "off", autoCorrect: "off", border, clearButton, customValidity, disabled, fontSize, icon, iconRight: loading && AnimatedSpinnerIcon, id, inputMode: "search", onChange: handleInputChange, onClear: handleClearButtonClick, onFocus: handleInputFocus, padding, prefix, radius, readOnly, ref: setInputElement, role: "combobox", spellCheck: !1, suffix: suffix || openButtonNode, value: inputValue }),
|
|
533
384
|
results
|
|
534
|
-
] })
|
|
385
|
+
] });
|
|
535
386
|
});
|
|
536
387
|
function RenderPopover({
|
|
537
388
|
renderPopover,
|
|
@@ -551,46 +402,22 @@ function RenderPopover({
|
|
|
551
402
|
}, resultsPopoverElementRef);
|
|
552
403
|
}
|
|
553
404
|
InnerAutocomplete.displayName = "ForwardRef(Autocomplete)";
|
|
554
|
-
const Autocomplete = InnerAutocomplete
|
|
555
|
-
function _temp$3(v_0) {
|
|
556
|
-
return v_0 === 0 ? 0 : v_0 === 1 || v_0 === 2 ? 1 : v_0 - 2;
|
|
557
|
-
}
|
|
558
|
-
function _temp2$1(v_1) {
|
|
559
|
-
return Math.max(v_1 - 1, 0);
|
|
560
|
-
}
|
|
561
|
-
const StyledBreadcrumbs = styledComponents.styled.ol.withConfig({
|
|
405
|
+
const Autocomplete = InnerAutocomplete, StyledBreadcrumbs = styledComponents.styled.ol.withConfig({
|
|
562
406
|
displayName: "StyledBreadcrumbs",
|
|
563
407
|
componentId: "sc-1es8h8q-0"
|
|
564
408
|
})`margin:0;padding:0;display:flex;list-style:none;align-items:center;white-space:nowrap;line-height:0;`, ExpandButton = styledComponents.styled(_visualEditing.Button).withConfig({
|
|
565
409
|
displayName: "ExpandButton",
|
|
566
410
|
componentId: "sc-1es8h8q-1"
|
|
567
411
|
})`appearance:none;margin:-4px;`, Breadcrumbs = react.forwardRef(function(props, ref) {
|
|
568
|
-
const
|
|
569
|
-
let children, maxLength, restProps, separator, t0;
|
|
570
|
-
$[0] !== props ? ({
|
|
412
|
+
const {
|
|
571
413
|
children,
|
|
572
414
|
maxLength,
|
|
573
415
|
separator,
|
|
574
|
-
space:
|
|
416
|
+
space: spaceRaw = 2,
|
|
575
417
|
...restProps
|
|
576
|
-
} = props,
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
$[6] !== spaceRaw ? (t1 = _visualEditing._getArrayProp(spaceRaw), $[6] = spaceRaw, $[7] = t1) : t1 = $[7];
|
|
580
|
-
const space = t1, [open, setOpen] = react.useState(!1), expandElementRef = react.useRef(null), popoverElementRef = react.useRef(null);
|
|
581
|
-
let t2;
|
|
582
|
-
$[8] === Symbol.for("react.memo_cache_sentinel") ? (t2 = () => setOpen(!1), $[8] = t2) : t2 = $[8];
|
|
583
|
-
const collapse = t2;
|
|
584
|
-
let t3;
|
|
585
|
-
$[9] === Symbol.for("react.memo_cache_sentinel") ? (t3 = () => setOpen(!0), $[9] = t3) : t3 = $[9];
|
|
586
|
-
const expand = t3;
|
|
587
|
-
let t4;
|
|
588
|
-
$[10] === Symbol.for("react.memo_cache_sentinel") ? (t4 = () => [expandElementRef.current, popoverElementRef.current], $[10] = t4) : t4 = $[10], _visualEditing.useClickOutsideEvent(collapse, t4);
|
|
589
|
-
let t5;
|
|
590
|
-
$[11] !== children ? (t5 = react.Children.toArray(children).filter(react.isValidElement), $[11] = children, $[12] = t5) : t5 = $[12];
|
|
591
|
-
const rawItems = t5;
|
|
592
|
-
let t6;
|
|
593
|
-
$[13] !== maxLength || $[14] !== open || $[15] !== rawItems || $[16] !== space ? (t6 = {
|
|
418
|
+
} = props, space = _visualEditing._getArrayProp(spaceRaw), [open, setOpen] = react.useState(!1), expandElementRef = react.useRef(null), popoverElementRef = react.useRef(null), collapse = react.useCallback(() => setOpen(!1), []), expand = react.useCallback(() => setOpen(!0), []);
|
|
419
|
+
_visualEditing.useClickOutsideEvent(collapse, () => [expandElementRef.current, popoverElementRef.current]);
|
|
420
|
+
const rawItems = react.useMemo(() => react.Children.toArray(children).filter(react.isValidElement), [children]), items = useItems({
|
|
594
421
|
collapse,
|
|
595
422
|
expand,
|
|
596
423
|
expandElementRef,
|
|
@@ -599,49 +426,27 @@ const StyledBreadcrumbs = styledComponents.styled.ol.withConfig({
|
|
|
599
426
|
popoverElementRef,
|
|
600
427
|
rawItems,
|
|
601
428
|
space
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
$[22] !== separator || $[23] !== space ? (t82 = (item, itemIndex) => /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
|
|
608
|
-
itemIndex > 0 && /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { "aria-hidden": !0, as: "li", paddingX: space, children: separator || /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Text, { muted: !0, children: "/" }) }),
|
|
609
|
-
/* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { as: "li", children: item })
|
|
610
|
-
] }, itemIndex), $[22] = separator, $[23] = space, $[24] = t82) : t82 = $[24], t7 = items.map(t82), $[18] = items, $[19] = separator, $[20] = space, $[21] = t7;
|
|
611
|
-
} else
|
|
612
|
-
t7 = $[21];
|
|
613
|
-
let t8;
|
|
614
|
-
return $[25] !== ref || $[26] !== restProps || $[27] !== t7 ? (t8 = /* @__PURE__ */ jsxRuntime.jsx(StyledBreadcrumbs, { "data-ui": "Breadcrumbs", ...restProps, ref, children: t7 }), $[25] = ref, $[26] = restProps, $[27] = t7, $[28] = t8) : t8 = $[28], t8;
|
|
429
|
+
});
|
|
430
|
+
return /* @__PURE__ */ jsxRuntime.jsx(StyledBreadcrumbs, { "data-ui": "Breadcrumbs", ...restProps, ref, children: items.map((item, itemIndex) => /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
|
|
431
|
+
itemIndex > 0 && /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { "aria-hidden": !0, as: "li", paddingX: space, children: separator || /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Text, { muted: !0, children: "/" }) }),
|
|
432
|
+
/* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { as: "li", children: item })
|
|
433
|
+
] }, itemIndex)) });
|
|
615
434
|
});
|
|
616
435
|
Breadcrumbs.displayName = "ForwardRef(Breadcrumbs)";
|
|
617
|
-
function useItems(
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
436
|
+
function useItems({
|
|
437
|
+
collapse,
|
|
438
|
+
expand,
|
|
439
|
+
expandElementRef,
|
|
440
|
+
maxLength,
|
|
441
|
+
open,
|
|
442
|
+
popoverElementRef,
|
|
443
|
+
rawItems,
|
|
444
|
+
space
|
|
445
|
+
}) {
|
|
446
|
+
const len = rawItems.length;
|
|
628
447
|
if (maxLength && len > maxLength) {
|
|
629
448
|
const beforeLength = Math.ceil(maxLength / 2), afterLength = Math.floor(maxLength / 2);
|
|
630
|
-
|
|
631
|
-
if ($[0] !== afterLength || $[1] !== beforeLength || $[2] !== collapse || $[3] !== expand || $[4] !== expandElementRef || $[5] !== len || $[6] !== open || $[7] !== popoverElementRef || $[8] !== rawItems || $[9] !== space) {
|
|
632
|
-
const t2 = rawItems.slice(0, beforeLength - 1);
|
|
633
|
-
let t3;
|
|
634
|
-
$[11] !== afterLength || $[12] !== beforeLength || $[13] !== len || $[14] !== rawItems ? (t3 = rawItems.slice(beforeLength - 1, len - afterLength), $[11] = afterLength, $[12] = beforeLength, $[13] = len, $[14] = rawItems, $[15] = t3) : t3 = $[15];
|
|
635
|
-
let t4;
|
|
636
|
-
$[16] !== space || $[17] !== t3 ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Stack, { as: "ol", overflow: "auto", padding: space, space, children: t3 }), $[16] = space, $[17] = t3, $[18] = t4) : t4 = $[18];
|
|
637
|
-
const t5 = open ? collapse : expand;
|
|
638
|
-
let t6;
|
|
639
|
-
$[19] !== expandElementRef || $[20] !== open || $[21] !== t5 ? (t6 = /* @__PURE__ */ jsxRuntime.jsx(ExpandButton, { fontSize: 1, mode: "bleed", onClick: t5, padding: 1, ref: expandElementRef, selected: open, text: "\u2026" }), $[19] = expandElementRef, $[20] = open, $[21] = t5, $[22] = t6) : t6 = $[22];
|
|
640
|
-
let t7;
|
|
641
|
-
$[23] !== open || $[24] !== popoverElementRef || $[25] !== t4 || $[26] !== t6 ? (t7 = /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Popover, { constrainSize: !0, content: t4, open, placement: "top", portal: !0, ref: popoverElementRef, children: t6 }, "button"), $[23] = open, $[24] = popoverElementRef, $[25] = t4, $[26] = t6, $[27] = t7) : t7 = $[27], t1 = [...t2, t7, ...rawItems.slice(len - afterLength)], $[0] = afterLength, $[1] = beforeLength, $[2] = collapse, $[3] = expand, $[4] = expandElementRef, $[5] = len, $[6] = open, $[7] = popoverElementRef, $[8] = rawItems, $[9] = space, $[10] = t1;
|
|
642
|
-
} else
|
|
643
|
-
t1 = $[10];
|
|
644
|
-
return t1;
|
|
449
|
+
return [...rawItems.slice(0, beforeLength - 1), /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Popover, { constrainSize: !0, content: /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Stack, { as: "ol", overflow: "auto", padding: space, space, children: rawItems.slice(beforeLength - 1, len - afterLength) }), open, placement: "top", portal: !0, ref: popoverElementRef, children: /* @__PURE__ */ jsxRuntime.jsx(ExpandButton, { fontSize: 1, mode: "bleed", onClick: open ? collapse : expand, padding: 1, ref: expandElementRef, selected: open, text: "\u2026" }) }, "button"), ...rawItems.slice(len - afterLength)];
|
|
645
450
|
}
|
|
646
451
|
return rawItems;
|
|
647
452
|
}
|
|
@@ -734,7 +539,7 @@ const StyledDialog = /* @__PURE__ */ styledComponents.styled(_visualEditing.Laye
|
|
|
734
539
|
displayName: "DialogFooter",
|
|
735
540
|
componentId: "sc-4n4xb3-6"
|
|
736
541
|
})`position:relative;z-index:3;`, DialogCard = react.forwardRef(function(props, forwardedRef) {
|
|
737
|
-
const
|
|
542
|
+
const {
|
|
738
543
|
__unstable_autoFocus: autoFocus,
|
|
739
544
|
__unstable_hideCloseButton: hideCloseButton,
|
|
740
545
|
children,
|
|
@@ -749,71 +554,36 @@ const StyledDialog = /* @__PURE__ */ styledComponents.styled(_visualEditing.Laye
|
|
|
749
554
|
scheme,
|
|
750
555
|
shadow: shadowProp,
|
|
751
556
|
width: widthProp
|
|
752
|
-
} = props, portal = _visualEditing.usePortal(), portalElement = portalProp ? portal.elements?.[portalProp] || null : portal.element, boundaryElement = _visualEditing.useBoundaryElement().element
|
|
753
|
-
let t0;
|
|
754
|
-
$[0] !== radiusProp ? (t0 = _visualEditing._getArrayProp(radiusProp), $[0] = radiusProp, $[1] = t0) : t0 = $[1];
|
|
755
|
-
const radius = t0;
|
|
756
|
-
let t1;
|
|
757
|
-
$[2] !== shadowProp ? (t1 = _visualEditing._getArrayProp(shadowProp), $[2] = shadowProp, $[3] = t1) : t1 = $[3];
|
|
758
|
-
const shadow = t1;
|
|
759
|
-
let t2;
|
|
760
|
-
$[4] !== widthProp ? (t2 = _visualEditing._getArrayProp(widthProp), $[4] = widthProp, $[5] = t2) : t2 = $[5];
|
|
761
|
-
const width = t2, ref = react.useRef(null), contentRef = react.useRef(null), layer = _visualEditing.useLayer(), {
|
|
557
|
+
} = props, portal = _visualEditing.usePortal(), portalElement = portalProp ? portal.elements?.[portalProp] || null : portal.element, boundaryElement = _visualEditing.useBoundaryElement().element, radius = _visualEditing._getArrayProp(radiusProp), shadow = _visualEditing._getArrayProp(shadowProp), width = _visualEditing._getArrayProp(widthProp), ref = react.useRef(null), contentRef = react.useRef(null), layer = _visualEditing.useLayer(), {
|
|
762
558
|
isTopLayer
|
|
763
559
|
} = layer, labelId = `${id}_label`, showCloseButton = !!onClose && hideCloseButton === !1, showHeader = !!header || showCloseButton;
|
|
764
|
-
|
|
765
|
-
$[6] === Symbol.for("react.memo_cache_sentinel") ? (t3 = () => ref.current, $[6] = t3) : t3 = $[6], react.useImperativeHandle(forwardedRef, t3);
|
|
766
|
-
let t4;
|
|
767
|
-
$[7] === Symbol.for("react.memo_cache_sentinel") ? (t4 = () => contentRef.current, $[7] = t4) : t4 = $[7], react.useImperativeHandle(forwardedContentRef, t4);
|
|
768
|
-
let t5, t6;
|
|
769
|
-
$[8] !== autoFocus ? (t5 = () => {
|
|
560
|
+
return react.useImperativeHandle(forwardedRef, () => ref.current), react.useImperativeHandle(forwardedContentRef, () => contentRef.current), react.useEffect(() => {
|
|
770
561
|
autoFocus && ref.current && focusFirstDescendant(ref.current);
|
|
771
|
-
},
|
|
772
|
-
|
|
773
|
-
$[11] !== boundaryElement || $[12] !== isTopLayer || $[13] !== onClose || $[14] !== portalElement ? (t7 = (event) => {
|
|
774
|
-
if (!isTopLayer || !onClose)
|
|
775
|
-
return;
|
|
562
|
+
}, [autoFocus, ref]), _visualEditing.useGlobalKeyDown(react.useCallback((event) => {
|
|
563
|
+
if (!isTopLayer || !onClose) return;
|
|
776
564
|
const target = document.activeElement;
|
|
777
565
|
target && !isTargetWithinScope(boundaryElement, portalElement, target) || event.key === "Escape" && (event.preventDefault(), event.stopPropagation(), onClose());
|
|
778
|
-
},
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
showCloseButton && /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { flex: "none", children: /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Button, { "aria-label": "Close dialog", disabled: !onClose, icon: icons.CloseIcon, mode: "bleed", onClick: onClose, padding: 2 }) })
|
|
790
|
-
] }) }), $[22] = header, $[23] = labelId, $[24] = onClose, $[25] = showCloseButton, $[26] = showHeader, $[27] = t10) : t10 = $[27];
|
|
791
|
-
let t11;
|
|
792
|
-
$[28] !== children ? (t11 = /* @__PURE__ */ jsxRuntime.jsx(DialogContent, { flex: 1, ref: contentRef, tabIndex: -1, children }), $[28] = children, $[29] = t11) : t11 = $[29];
|
|
793
|
-
let t12;
|
|
794
|
-
$[30] !== footer ? (t12 = footer && /* @__PURE__ */ jsxRuntime.jsx(DialogFooter, { children: footer }), $[30] = footer, $[31] = t12) : t12 = $[31];
|
|
795
|
-
let t13;
|
|
796
|
-
$[32] !== t10 || $[33] !== t11 || $[34] !== t12 ? (t13 = /* @__PURE__ */ jsxRuntime.jsxs(DialogLayout, { direction: "column", children: [
|
|
797
|
-
t10,
|
|
798
|
-
t11,
|
|
799
|
-
t12
|
|
800
|
-
] }), $[32] = t10, $[33] = t11, $[34] = t12, $[35] = t13) : t13 = $[35];
|
|
801
|
-
let t14;
|
|
802
|
-
$[36] !== radius || $[37] !== scheme || $[38] !== shadow || $[39] !== t13 ? (t14 = /* @__PURE__ */ jsxRuntime.jsx(DialogCardRoot, { radius, ref, scheme, shadow, children: t13 }), $[36] = radius, $[37] = scheme, $[38] = shadow, $[39] = t13, $[40] = t14) : t14 = $[40];
|
|
803
|
-
let t15;
|
|
804
|
-
return $[41] !== t14 || $[42] !== width ? (t15 = /* @__PURE__ */ jsxRuntime.jsx(DialogContainer, { "data-ui": "DialogCard", width, children: t14 }), $[41] = t14, $[42] = width, $[43] = t15) : t15 = $[43], t15;
|
|
566
|
+
}, [boundaryElement, isTopLayer, onClose, portalElement])), _visualEditing.useClickOutsideEvent(isTopLayer && onClickOutside && ((event) => {
|
|
567
|
+
const target = event.target;
|
|
568
|
+
target && !isTargetWithinScope(boundaryElement, portalElement, target) || onClickOutside();
|
|
569
|
+
}), () => [ref.current]), /* @__PURE__ */ jsxRuntime.jsx(DialogContainer, { "data-ui": "DialogCard", width, children: /* @__PURE__ */ jsxRuntime.jsx(DialogCardRoot, { radius, ref, scheme, shadow, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogLayout, { direction: "column", children: [
|
|
570
|
+
showHeader && /* @__PURE__ */ jsxRuntime.jsx(DialogHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(_visualEditing.Flex, { align: "flex-start", padding: 3, children: [
|
|
571
|
+
/* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { flex: 1, padding: 2, children: header && /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Text, { id: labelId, size: 1, weight: "semibold", children: header }) }),
|
|
572
|
+
showCloseButton && /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { flex: "none", children: /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Button, { "aria-label": "Close dialog", disabled: !onClose, icon: icons.CloseIcon, mode: "bleed", onClick: onClose, padding: 2 }) })
|
|
573
|
+
] }) }),
|
|
574
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogContent, { flex: 1, ref: contentRef, tabIndex: -1, children }),
|
|
575
|
+
footer && /* @__PURE__ */ jsxRuntime.jsx(DialogFooter, { children: footer })
|
|
576
|
+
] }) }) });
|
|
805
577
|
});
|
|
806
578
|
DialogCard.displayName = "ForwardRef(DialogCard)";
|
|
807
579
|
const Dialog = react.forwardRef(function(props, ref) {
|
|
808
|
-
const
|
|
580
|
+
const dialog = useDialog(), {
|
|
809
581
|
layer
|
|
810
|
-
} = _visualEditing.useTheme_v2()
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
cardRadius: t2,
|
|
816
|
-
cardShadow: t3,
|
|
582
|
+
} = _visualEditing.useTheme_v2(), {
|
|
583
|
+
__unstable_autoFocus: autoFocus = !0,
|
|
584
|
+
__unstable_hideCloseButton: hideCloseButton = !1,
|
|
585
|
+
cardRadius: cardRadiusProp = 4,
|
|
586
|
+
cardShadow = 3,
|
|
817
587
|
children,
|
|
818
588
|
contentRef,
|
|
819
589
|
footer,
|
|
@@ -823,33 +593,15 @@ const Dialog = react.forwardRef(function(props, ref) {
|
|
|
823
593
|
onClickOutside,
|
|
824
594
|
onClose,
|
|
825
595
|
onFocus,
|
|
826
|
-
padding:
|
|
596
|
+
padding: paddingProp = 3,
|
|
827
597
|
portal: portalProp,
|
|
828
598
|
position: _positionProp,
|
|
829
599
|
scheme,
|
|
830
|
-
width:
|
|
600
|
+
width: widthProp = 0,
|
|
831
601
|
zOffset: _zOffsetProp,
|
|
832
|
-
animate:
|
|
602
|
+
animate: _animate = !1,
|
|
833
603
|
...restProps
|
|
834
|
-
} = props,
|
|
835
|
-
const autoFocus = t0 === void 0 ? !0 : t0, hideCloseButton = t1 === void 0 ? !1 : t1, cardRadiusProp = t2 === void 0 ? 4 : t2, cardShadow = t3 === void 0 ? 3 : t3, paddingProp = t4 === void 0 ? 3 : t4, widthProp = t5 === void 0 ? 0 : t5, _animate = t6 === void 0 ? !1 : t6, positionProp = _positionProp ?? (dialog.position || "fixed"), zOffsetProp = _zOffsetProp ?? (dialog.zOffset || layer.dialog.zOffset), animate = _visualEditing.usePrefersReducedMotion() ? !1 : _animate, portal = _visualEditing.usePortal(), portalElement = portalProp ? portal.elements?.[portalProp] || null : portal.element, boundaryElement = _visualEditing.useBoundaryElement().element;
|
|
836
|
-
let t7;
|
|
837
|
-
$[22] !== cardRadiusProp ? (t7 = _visualEditing._getArrayProp(cardRadiusProp), $[22] = cardRadiusProp, $[23] = t7) : t7 = $[23];
|
|
838
|
-
const cardRadius = t7;
|
|
839
|
-
let t8;
|
|
840
|
-
$[24] !== paddingProp ? (t8 = _visualEditing._getArrayProp(paddingProp), $[24] = paddingProp, $[25] = t8) : t8 = $[25];
|
|
841
|
-
const padding = t8;
|
|
842
|
-
let t9;
|
|
843
|
-
$[26] !== positionProp ? (t9 = _visualEditing._getArrayProp(positionProp), $[26] = positionProp, $[27] = t9) : t9 = $[27];
|
|
844
|
-
const position = t9;
|
|
845
|
-
let t10;
|
|
846
|
-
$[28] !== widthProp ? (t10 = _visualEditing._getArrayProp(widthProp), $[28] = widthProp, $[29] = t10) : t10 = $[29];
|
|
847
|
-
const width = t10;
|
|
848
|
-
let t11;
|
|
849
|
-
$[30] !== zOffsetProp ? (t11 = _visualEditing._getArrayProp(zOffsetProp), $[30] = zOffsetProp, $[31] = t11) : t11 = $[31];
|
|
850
|
-
const zOffset = t11, preDivRef = react.useRef(null), postDivRef = react.useRef(null), cardRef = react.useRef(null), focusedElementRef = react.useRef(null);
|
|
851
|
-
let t12;
|
|
852
|
-
$[32] !== onFocus ? (t12 = (event) => {
|
|
604
|
+
} = props, positionProp = _positionProp ?? (dialog.position || "fixed"), zOffsetProp = _zOffsetProp ?? (dialog.zOffset || layer.dialog.zOffset), animate = _visualEditing.usePrefersReducedMotion() ? !1 : _animate, portal = _visualEditing.usePortal(), portalElement = portalProp ? portal.elements?.[portalProp] || null : portal.element, boundaryElement = _visualEditing.useBoundaryElement().element, cardRadius = _visualEditing._getArrayProp(cardRadiusProp), padding = _visualEditing._getArrayProp(paddingProp), position = _visualEditing._getArrayProp(positionProp), width = _visualEditing._getArrayProp(widthProp), zOffset = _visualEditing._getArrayProp(zOffsetProp), preDivRef = react.useRef(null), postDivRef = react.useRef(null), cardRef = react.useRef(null), focusedElementRef = react.useRef(null), handleFocus = react.useCallback((event) => {
|
|
853
605
|
onFocus?.(event);
|
|
854
606
|
const target = event.target, cardElement = cardRef.current;
|
|
855
607
|
if (cardElement && target === preDivRef.current) {
|
|
@@ -861,60 +613,43 @@ const Dialog = react.forwardRef(function(props, ref) {
|
|
|
861
613
|
return;
|
|
862
614
|
}
|
|
863
615
|
_visualEditing.isHTMLElement(event.target) && (focusedElementRef.current = event.target);
|
|
864
|
-
},
|
|
865
|
-
const handleFocus = t12, labelId = `${id}_label`, rootClickTimeoutRef = react.useRef(void 0);
|
|
866
|
-
let t13;
|
|
867
|
-
$[34] !== boundaryElement || $[35] !== portalElement ? (t13 = () => {
|
|
616
|
+
}, [onFocus]), labelId = `${id}_label`, rootClickTimeoutRef = react.useRef(void 0), handleRootClick = react.useCallback(() => {
|
|
868
617
|
rootClickTimeoutRef.current && clearTimeout(rootClickTimeoutRef.current), rootClickTimeoutRef.current = setTimeout(() => {
|
|
869
618
|
const activeElement = document.activeElement;
|
|
870
619
|
if (activeElement && !isTargetWithinScope(boundaryElement, portalElement, activeElement)) {
|
|
871
|
-
const
|
|
872
|
-
if (!
|
|
873
|
-
const
|
|
874
|
-
|
|
620
|
+
const target = focusedElementRef.current;
|
|
621
|
+
if (!target || !document.body.contains(target)) {
|
|
622
|
+
const cardElement = cardRef.current;
|
|
623
|
+
cardElement && focusFirstDescendant(cardElement);
|
|
875
624
|
return;
|
|
876
625
|
}
|
|
877
|
-
|
|
626
|
+
target.focus();
|
|
878
627
|
}
|
|
879
628
|
}, 0);
|
|
880
|
-
},
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
let t16;
|
|
887
|
-
$[53] === Symbol.for("react.memo_cache_sentinel") ? (t16 = /* @__PURE__ */ jsxRuntime.jsx("div", { ref: postDivRef, tabIndex: 0 }), $[53] = t16) : t16 = $[53];
|
|
888
|
-
let t17;
|
|
889
|
-
$[54] !== animate || $[55] !== handleFocus || $[56] !== handleRootClick || $[57] !== id || $[58] !== labelId || $[59] !== onActivate || $[60] !== padding || $[61] !== position || $[62] !== ref || $[63] !== restProps || $[64] !== t15 || $[65] !== zOffset ? (t17 = /* @__PURE__ */ jsxRuntime.jsxs(StyledDialog, { ...restProps, $animate: animate, $padding: padding, $position: position, "aria-labelledby": labelId, "aria-modal": !0, "data-ui": "Dialog", id, onActivate, onClick: handleRootClick, onFocus: handleFocus, ref, role: "dialog", zOffset, children: [
|
|
890
|
-
t14,
|
|
891
|
-
t15,
|
|
892
|
-
t16
|
|
893
|
-
] }), $[54] = animate, $[55] = handleFocus, $[56] = handleRootClick, $[57] = id, $[58] = labelId, $[59] = onActivate, $[60] = padding, $[61] = position, $[62] = ref, $[63] = restProps, $[64] = t15, $[65] = zOffset, $[66] = t17) : t17 = $[66];
|
|
894
|
-
let t18;
|
|
895
|
-
return $[67] !== portalProp || $[68] !== t17 ? (t18 = /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Portal, { __unstable_name: portalProp, children: t17 }), $[67] = portalProp, $[68] = t17, $[69] = t18) : t18 = $[69], t18;
|
|
629
|
+
}, [boundaryElement, portalElement]);
|
|
630
|
+
return /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Portal, { __unstable_name: portalProp, children: /* @__PURE__ */ jsxRuntime.jsxs(StyledDialog, { ...restProps, $animate: animate, $padding: padding, $position: position, "aria-labelledby": labelId, "aria-modal": !0, "data-ui": "Dialog", id, onActivate, onClick: handleRootClick, onFocus: handleFocus, ref, role: "dialog", zOffset, children: [
|
|
631
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: preDivRef, tabIndex: 0 }),
|
|
632
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogCard, { __unstable_autoFocus: autoFocus, __unstable_hideCloseButton: hideCloseButton, contentRef, footer, header, id, onClickOutside, onClose, portal: portalProp, radius: cardRadius, ref: cardRef, scheme, shadow: cardShadow, width, children }),
|
|
633
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: postDivRef, tabIndex: 0 })
|
|
634
|
+
] }) });
|
|
896
635
|
});
|
|
897
636
|
Dialog.displayName = "ForwardRef(Dialog)";
|
|
898
637
|
function DialogProvider(props) {
|
|
899
|
-
const
|
|
638
|
+
const {
|
|
900
639
|
children,
|
|
901
640
|
position,
|
|
902
641
|
zOffset
|
|
903
|
-
} = props
|
|
904
|
-
let t0;
|
|
905
|
-
$[0] !== position || $[1] !== zOffset ? (t0 = {
|
|
642
|
+
} = props, contextValue = react.useMemo(() => ({
|
|
906
643
|
version: 0,
|
|
907
644
|
position,
|
|
908
645
|
zOffset
|
|
909
|
-
},
|
|
910
|
-
|
|
911
|
-
let t1;
|
|
912
|
-
return $[3] !== children || $[4] !== contextValue ? (t1 = /* @__PURE__ */ jsxRuntime.jsx(DialogContext.Provider, { value: contextValue, children }), $[3] = children, $[4] = contextValue, $[5] = t1) : t1 = $[5], t1;
|
|
646
|
+
}), [position, zOffset]);
|
|
647
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DialogContext.Provider, { value: contextValue, children });
|
|
913
648
|
}
|
|
914
649
|
DialogProvider.displayName = "DialogProvider";
|
|
915
650
|
const MenuButton = react.forwardRef(function(props, forwardedRef) {
|
|
916
|
-
const
|
|
917
|
-
__unstable_disableRestoreFocusOnClose:
|
|
651
|
+
const {
|
|
652
|
+
__unstable_disableRestoreFocusOnClose: disableRestoreFocusOnClose = !1,
|
|
918
653
|
boundaryElement: deprecated_boundaryElement,
|
|
919
654
|
button: buttonProp,
|
|
920
655
|
id,
|
|
@@ -923,85 +658,52 @@ const MenuButton = react.forwardRef(function(props, forwardedRef) {
|
|
|
923
658
|
onOpen,
|
|
924
659
|
placement: deprecated_placement,
|
|
925
660
|
popoverScheme: deprecated_popoverScheme,
|
|
926
|
-
portal:
|
|
661
|
+
portal: deprecated_portal = !0,
|
|
927
662
|
popover,
|
|
928
663
|
popoverRadius: deprecated_popoverRadius,
|
|
929
664
|
preventOverflow: deprecated_preventOverflow
|
|
930
|
-
} = props,
|
|
931
|
-
|
|
932
|
-
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t2 = [], $[0] = t2) : t2 = $[0];
|
|
933
|
-
const [menuElements, setChildMenuElements] = react.useState(t2), openRef = react.useRef(open);
|
|
934
|
-
let t3, t4;
|
|
935
|
-
$[1] !== onOpen || $[2] !== open ? (t3 = () => {
|
|
665
|
+
} = props, [open, setOpen] = react.useState(!1), [shouldFocus, setShouldFocus] = react.useState(null), [buttonElement, setButtonElement] = react.useState(null), [menuElements, setChildMenuElements] = react.useState([]), openRef = react.useRef(open);
|
|
666
|
+
react.useEffect(() => {
|
|
936
667
|
onOpen && open && !openRef.current && onOpen();
|
|
937
|
-
},
|
|
938
|
-
let t5, t6;
|
|
939
|
-
$[5] !== onClose || $[6] !== open ? (t5 = () => {
|
|
668
|
+
}, [onOpen, open]), react.useEffect(() => {
|
|
940
669
|
onClose && !open && openRef.current && onClose();
|
|
941
|
-
},
|
|
942
|
-
let t7, t8;
|
|
943
|
-
$[9] !== open ? (t7 = () => {
|
|
670
|
+
}, [onClose, open]), react.useEffect(() => {
|
|
944
671
|
openRef.current = open;
|
|
945
|
-
},
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
}, $[12] = t9) : t9 = $[12];
|
|
950
|
-
const handleButtonClick = t9;
|
|
951
|
-
let t10;
|
|
952
|
-
$[13] !== open ? (t10 = (event) => {
|
|
672
|
+
}, [open]);
|
|
673
|
+
const handleButtonClick = react.useCallback(() => {
|
|
674
|
+
setOpen((v) => !v), setShouldFocus(null);
|
|
675
|
+
}, []), handleMouseDown = react.useCallback((event) => {
|
|
953
676
|
open && event.preventDefault();
|
|
954
|
-
},
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
$[15] === Symbol.for("react.memo_cache_sentinel") ? (t11 = (event_0) => {
|
|
958
|
-
if (event_0.key === "ArrowDown" || event_0.key === "Enter" || event_0.key === " ") {
|
|
959
|
-
event_0.preventDefault(), setOpen(!0), setShouldFocus("first");
|
|
677
|
+
}, [open]), handleButtonKeyDown = react.useCallback((event) => {
|
|
678
|
+
if (event.key === "ArrowDown" || event.key === "Enter" || event.key === " ") {
|
|
679
|
+
event.preventDefault(), setOpen(!0), setShouldFocus("first");
|
|
960
680
|
return;
|
|
961
681
|
}
|
|
962
|
-
if (
|
|
963
|
-
|
|
682
|
+
if (event.key === "ArrowUp") {
|
|
683
|
+
event.preventDefault(), setOpen(!0), setShouldFocus("last");
|
|
964
684
|
return;
|
|
965
685
|
}
|
|
966
|
-
},
|
|
967
|
-
|
|
968
|
-
let t12;
|
|
969
|
-
$[16] !== buttonElement || $[17] !== menuElements ? (t12 = (event_1) => {
|
|
970
|
-
const target = event_1.target;
|
|
686
|
+
}, []), handleMenuClickOutside = react.useCallback((event) => {
|
|
687
|
+
const target = event.target;
|
|
971
688
|
if (target instanceof Node && !(buttonElement && (target === buttonElement || buttonElement.contains(target)))) {
|
|
972
689
|
for (const el of menuElements)
|
|
973
690
|
if (target === el || el.contains(target))
|
|
974
691
|
return;
|
|
975
692
|
setOpen(!1);
|
|
976
693
|
}
|
|
977
|
-
},
|
|
978
|
-
const handleMenuClickOutside = t12;
|
|
979
|
-
let t13;
|
|
980
|
-
$[19] !== buttonElement || $[20] !== disableRestoreFocusOnClose ? (t13 = () => {
|
|
694
|
+
}, [buttonElement, menuElements]), handleMenuEscape = react.useCallback(() => {
|
|
981
695
|
setOpen(!1), !disableRestoreFocusOnClose && buttonElement && buttonElement.focus();
|
|
982
|
-
},
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
if (target_0 instanceof Node) {
|
|
988
|
-
for (const el_0 of menuElements)
|
|
989
|
-
if (el_0 === target_0 || el_0.contains(target_0))
|
|
696
|
+
}, [buttonElement, disableRestoreFocusOnClose]), handleBlur = react.useCallback((event) => {
|
|
697
|
+
const target = event.relatedTarget;
|
|
698
|
+
if (target instanceof Node) {
|
|
699
|
+
for (const el of menuElements)
|
|
700
|
+
if (el === target || el.contains(target))
|
|
990
701
|
return;
|
|
991
702
|
setOpen(!1);
|
|
992
703
|
}
|
|
993
|
-
},
|
|
994
|
-
const handleBlur = t14;
|
|
995
|
-
let t15;
|
|
996
|
-
$[24] !== buttonElement || $[25] !== disableRestoreFocusOnClose ? (t15 = () => {
|
|
704
|
+
}, [menuElements]), handleItemClick = react.useCallback(() => {
|
|
997
705
|
setOpen(!1), !disableRestoreFocusOnClose && buttonElement && buttonElement.focus();
|
|
998
|
-
},
|
|
999
|
-
const handleItemClick = t15;
|
|
1000
|
-
let t16;
|
|
1001
|
-
$[27] === Symbol.for("react.memo_cache_sentinel") ? (t16 = (el_1) => (setChildMenuElements((els) => els.concat([el_1])), () => setChildMenuElements((els_0) => els_0.filter((_el) => _el !== el_1))), $[27] = t16) : t16 = $[27];
|
|
1002
|
-
const registerElement = t16;
|
|
1003
|
-
let t17;
|
|
1004
|
-
$[28] !== buttonElement || $[29] !== handleBlur || $[30] !== handleItemClick || $[31] !== handleMenuClickOutside || $[32] !== handleMenuEscape || $[33] !== id || $[34] !== menuProp || $[35] !== shouldFocus ? (t17 = menuProp && react.cloneElement(menuProp, {
|
|
706
|
+
}, [buttonElement, disableRestoreFocusOnClose]), registerElement = react.useCallback((el) => (setChildMenuElements((els) => els.concat([el])), () => setChildMenuElements((els) => els.filter((_el) => _el !== el))), []), menu = menuProp && react.cloneElement(menuProp, {
|
|
1005
707
|
"aria-labelledby": id,
|
|
1006
708
|
onBlurCapture: handleBlur,
|
|
1007
709
|
onClickOutside: handleMenuClickOutside,
|
|
@@ -1010,10 +712,7 @@ const MenuButton = react.forwardRef(function(props, forwardedRef) {
|
|
|
1010
712
|
originElement: buttonElement,
|
|
1011
713
|
registerElement,
|
|
1012
714
|
shouldFocus
|
|
1013
|
-
}),
|
|
1014
|
-
const menu = t17;
|
|
1015
|
-
let t18;
|
|
1016
|
-
$[37] !== buttonProp || $[38] !== handleMouseDown || $[39] !== id || $[40] !== open ? (t18 = buttonProp && react.cloneElement(buttonProp, {
|
|
715
|
+
}), button = react.useMemo(() => buttonProp && react.cloneElement(buttonProp, {
|
|
1017
716
|
"data-ui": "MenuButton",
|
|
1018
717
|
id,
|
|
1019
718
|
onClick: handleButtonClick,
|
|
@@ -1023,14 +722,9 @@ const MenuButton = react.forwardRef(function(props, forwardedRef) {
|
|
|
1023
722
|
"aria-expanded": open,
|
|
1024
723
|
ref: setButtonElement,
|
|
1025
724
|
selected: buttonProp.props.selected ?? open
|
|
1026
|
-
}),
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
$[42] !== buttonElement ? (t19 = () => buttonElement, t20 = [buttonElement], $[42] = buttonElement, $[43] = t19, $[44] = t20) : (t19 = $[43], t20 = $[44]), react.useImperativeHandle(forwardedRef, t19, t20);
|
|
1030
|
-
let t21;
|
|
1031
|
-
$[45] !== popover ? (t21 = popover || {}, $[45] = popover, $[46] = t21) : t21 = $[46];
|
|
1032
|
-
let t22;
|
|
1033
|
-
$[47] !== deprecated_boundaryElement || $[48] !== deprecated_placement || $[49] !== deprecated_popoverRadius || $[50] !== deprecated_popoverScheme || $[51] !== deprecated_portal || $[52] !== deprecated_preventOverflow || $[53] !== t21 ? (t22 = {
|
|
725
|
+
}), [buttonProp, handleButtonClick, handleButtonKeyDown, handleMouseDown, id, open]);
|
|
726
|
+
react.useImperativeHandle(forwardedRef, () => buttonElement, [buttonElement]);
|
|
727
|
+
const popoverProps = react.useMemo(() => ({
|
|
1034
728
|
boundaryElement: deprecated_boundaryElement,
|
|
1035
729
|
overflow: "auto",
|
|
1036
730
|
placement: deprecated_placement,
|
|
@@ -1038,18 +732,11 @@ const MenuButton = react.forwardRef(function(props, forwardedRef) {
|
|
|
1038
732
|
preventOverflow: deprecated_preventOverflow,
|
|
1039
733
|
radius: deprecated_popoverRadius,
|
|
1040
734
|
scheme: deprecated_popoverScheme,
|
|
1041
|
-
...
|
|
1042
|
-
},
|
|
1043
|
-
|
|
1044
|
-
let t23;
|
|
1045
|
-
$[55] !== button ? (t23 = button || /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {}), $[55] = button, $[56] = t23) : t23 = $[56];
|
|
1046
|
-
let t24;
|
|
1047
|
-
return $[57] !== menu || $[58] !== open || $[59] !== popoverProps || $[60] !== t23 ? (t24 = /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Popover, { "data-ui": "MenuButton__popover", ...popoverProps, content: menu, open, children: t23 }), $[57] = menu, $[58] = open, $[59] = popoverProps, $[60] = t23, $[61] = t24) : t24 = $[61], t24;
|
|
735
|
+
...popover || {}
|
|
736
|
+
}), [deprecated_boundaryElement, deprecated_placement, deprecated_popoverRadius, deprecated_popoverScheme, deprecated_portal, deprecated_preventOverflow, popover]);
|
|
737
|
+
return /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Popover, { "data-ui": "MenuButton__popover", ...popoverProps, content: menu, open, children: button || /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {}) });
|
|
1048
738
|
});
|
|
1049
739
|
MenuButton.displayName = "ForwardRef(MenuButton)";
|
|
1050
|
-
function _temp$2(v) {
|
|
1051
|
-
return !v;
|
|
1052
|
-
}
|
|
1053
740
|
const keyframe = styledComponents.keyframes`
|
|
1054
741
|
0% {
|
|
1055
742
|
background-position: 100%;
|
|
@@ -1094,17 +781,13 @@ const keyframe = styledComponents.keyframes`
|
|
|
1094
781
|
displayName: "StyledSkeleton",
|
|
1095
782
|
componentId: "sc-ebtpni-0"
|
|
1096
783
|
})(_visualEditing.responsiveRadiusStyle, skeletonStyle), Skeleton = react.forwardRef(function(props, ref) {
|
|
1097
|
-
const
|
|
1098
|
-
|
|
1099
|
-
$[0] !== props ? ({
|
|
1100
|
-
animated: t0,
|
|
784
|
+
const {
|
|
785
|
+
animated = !1,
|
|
1101
786
|
delay,
|
|
1102
787
|
radius,
|
|
1103
788
|
...restProps
|
|
1104
|
-
} = props,
|
|
1105
|
-
|
|
1106
|
-
let t1, t2;
|
|
1107
|
-
$[5] !== delay ? (t1 = () => {
|
|
789
|
+
} = props, [visible, setVisible] = react.useState(!delay);
|
|
790
|
+
return react.useEffect(() => {
|
|
1108
791
|
if (!delay)
|
|
1109
792
|
return;
|
|
1110
793
|
const timeout = setTimeout(() => {
|
|
@@ -1113,12 +796,7 @@ const keyframe = styledComponents.keyframes`
|
|
|
1113
796
|
return () => {
|
|
1114
797
|
clearTimeout(timeout);
|
|
1115
798
|
};
|
|
1116
|
-
},
|
|
1117
|
-
let t3;
|
|
1118
|
-
$[8] !== radius ? (t3 = _visualEditing._getArrayProp(radius), $[8] = radius, $[9] = t3) : t3 = $[9];
|
|
1119
|
-
const t4 = delay ? visible : !0;
|
|
1120
|
-
let t5;
|
|
1121
|
-
return $[10] !== animated || $[11] !== ref || $[12] !== restProps || $[13] !== t3 || $[14] !== t4 ? (t5 = /* @__PURE__ */ jsxRuntime.jsx(StyledSkeleton$1, { ...restProps, $animated: animated, $radius: t3, $visible: t4, ref }), $[10] = animated, $[11] = ref, $[12] = restProps, $[13] = t3, $[14] = t4, $[15] = t5) : t5 = $[15], t5;
|
|
799
|
+
}, [delay]), /* @__PURE__ */ jsxRuntime.jsx(StyledSkeleton$1, { ...restProps, $animated: animated, $radius: _visualEditing._getArrayProp(radius), $visible: delay ? visible : !0, ref });
|
|
1122
800
|
});
|
|
1123
801
|
Skeleton.displayName = "ForwardRef(Skeleton)";
|
|
1124
802
|
const StyledSkeleton = /* @__PURE__ */ styledComponents.styled(Skeleton).withConfig({
|
|
@@ -1139,75 +817,43 @@ const StyledSkeleton = /* @__PURE__ */ styledComponents.styled(Skeleton).withCon
|
|
|
1139
817
|
};
|
|
1140
818
|
});
|
|
1141
819
|
}), TextSkeleton = react.forwardRef(function(props, ref) {
|
|
1142
|
-
const
|
|
1143
|
-
|
|
1144
|
-
$[0] !== props ? ({
|
|
1145
|
-
size: t0,
|
|
820
|
+
const {
|
|
821
|
+
size = 2,
|
|
1146
822
|
...restProps
|
|
1147
|
-
} = props, $
|
|
1148
|
-
|
|
1149
|
-
let t1;
|
|
1150
|
-
$[3] !== size ? (t1 = _visualEditing._getArrayProp(size), $[3] = size, $[4] = t1) : t1 = $[4];
|
|
1151
|
-
const $size = t1;
|
|
1152
|
-
let t2;
|
|
1153
|
-
return $[5] !== $size || $[6] !== ref || $[7] !== restProps ? (t2 = /* @__PURE__ */ jsxRuntime.jsx(StyledSkeleton, { ...restProps, $size, ref, $style: "text" }), $[5] = $size, $[6] = ref, $[7] = restProps, $[8] = t2) : t2 = $[8], t2;
|
|
823
|
+
} = props, $size = _visualEditing._getArrayProp(size);
|
|
824
|
+
return /* @__PURE__ */ jsxRuntime.jsx(StyledSkeleton, { ...restProps, $size, ref, $style: "text" });
|
|
1154
825
|
});
|
|
1155
826
|
TextSkeleton.displayName = "ForwardRef(TextSkeleton)";
|
|
1156
827
|
const LabelSkeleton = react.forwardRef(function(props, ref) {
|
|
1157
|
-
const
|
|
1158
|
-
|
|
1159
|
-
$[0] !== props ? ({
|
|
1160
|
-
size: t0,
|
|
828
|
+
const {
|
|
829
|
+
size = 2,
|
|
1161
830
|
...restProps
|
|
1162
|
-
} = props, $
|
|
1163
|
-
|
|
1164
|
-
let t1;
|
|
1165
|
-
$[3] !== size ? (t1 = _visualEditing._getArrayProp(size), $[3] = size, $[4] = t1) : t1 = $[4];
|
|
1166
|
-
const $size = t1;
|
|
1167
|
-
let t2;
|
|
1168
|
-
return $[5] !== $size || $[6] !== ref || $[7] !== restProps ? (t2 = /* @__PURE__ */ jsxRuntime.jsx(StyledSkeleton, { ...restProps, $size, ref, $style: "label" }), $[5] = $size, $[6] = ref, $[7] = restProps, $[8] = t2) : t2 = $[8], t2;
|
|
831
|
+
} = props, $size = _visualEditing._getArrayProp(size);
|
|
832
|
+
return /* @__PURE__ */ jsxRuntime.jsx(StyledSkeleton, { ...restProps, $size, ref, $style: "label" });
|
|
1169
833
|
});
|
|
1170
834
|
LabelSkeleton.displayName = "ForwardRef(LabelSkeleton)";
|
|
1171
835
|
const HeadingSkeleton = react.forwardRef(function(props, ref) {
|
|
1172
|
-
const
|
|
1173
|
-
|
|
1174
|
-
$[0] !== props ? ({
|
|
1175
|
-
size: t0,
|
|
836
|
+
const {
|
|
837
|
+
size = 2,
|
|
1176
838
|
...restProps
|
|
1177
|
-
} = props, $
|
|
1178
|
-
|
|
1179
|
-
let t1;
|
|
1180
|
-
$[3] !== size ? (t1 = _visualEditing._getArrayProp(size), $[3] = size, $[4] = t1) : t1 = $[4];
|
|
1181
|
-
const $size = t1;
|
|
1182
|
-
let t2;
|
|
1183
|
-
return $[5] !== $size || $[6] !== ref || $[7] !== restProps ? (t2 = /* @__PURE__ */ jsxRuntime.jsx(StyledSkeleton, { ...restProps, $size, ref, $style: "heading" }), $[5] = $size, $[6] = ref, $[7] = restProps, $[8] = t2) : t2 = $[8], t2;
|
|
839
|
+
} = props, $size = _visualEditing._getArrayProp(size);
|
|
840
|
+
return /* @__PURE__ */ jsxRuntime.jsx(StyledSkeleton, { ...restProps, $size, ref, $style: "heading" });
|
|
1184
841
|
});
|
|
1185
842
|
HeadingSkeleton.displayName = "ForwardRef(HeadingSkeleton)";
|
|
1186
843
|
const CodeSkeleton = react.forwardRef(function(props, ref) {
|
|
1187
|
-
const
|
|
1188
|
-
|
|
1189
|
-
$[0] !== props ? ({
|
|
1190
|
-
size: t0,
|
|
844
|
+
const {
|
|
845
|
+
size = 2,
|
|
1191
846
|
...restProps
|
|
1192
|
-
} = props, $
|
|
1193
|
-
|
|
1194
|
-
let t1;
|
|
1195
|
-
$[3] !== size ? (t1 = _visualEditing._getArrayProp(size), $[3] = size, $[4] = t1) : t1 = $[4];
|
|
1196
|
-
const $size = t1;
|
|
1197
|
-
let t2;
|
|
1198
|
-
return $[5] !== $size || $[6] !== ref || $[7] !== restProps ? (t2 = /* @__PURE__ */ jsxRuntime.jsx(StyledSkeleton, { ...restProps, $size, ref, $style: "code" }), $[5] = $size, $[6] = ref, $[7] = restProps, $[8] = t2) : t2 = $[8], t2;
|
|
847
|
+
} = props, $size = _visualEditing._getArrayProp(size);
|
|
848
|
+
return /* @__PURE__ */ jsxRuntime.jsx(StyledSkeleton, { ...restProps, $size, ref, $style: "code" });
|
|
1199
849
|
});
|
|
1200
850
|
CodeSkeleton.displayName = "ForwardRef(CodeSkeleton)";
|
|
1201
851
|
const TabPanel = react.forwardRef(function(props, ref) {
|
|
1202
|
-
const
|
|
1203
|
-
let flex, restProps;
|
|
1204
|
-
$[0] !== props ? ({
|
|
852
|
+
const {
|
|
1205
853
|
flex,
|
|
1206
854
|
...restProps
|
|
1207
|
-
} = props
|
|
1208
|
-
|
|
1209
|
-
let t1;
|
|
1210
|
-
return $[3] !== flex || $[4] !== props.children || $[5] !== ref || $[6] !== restProps || $[7] !== t0 ? (t1 = /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { "data-ui": "TabPanel", ...restProps, flex, ref, role: "tabpanel", tabIndex: t0, children: props.children }), $[3] = flex, $[4] = props.children, $[5] = ref, $[6] = restProps, $[7] = t0, $[8] = t1) : t1 = $[8], t1;
|
|
855
|
+
} = props;
|
|
856
|
+
return /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { "data-ui": "TabPanel", ...restProps, flex, ref, role: "tabpanel", tabIndex: props.tabIndex === void 0 ? 0 : props.tabIndex, children: props.children });
|
|
1211
857
|
});
|
|
1212
858
|
TabPanel.displayName = "ForwardRef(TabPanel)";
|
|
1213
859
|
const LOADING_BAR_HEIGHT = 2, STATUS_CARD_TONE = {
|
|
@@ -1247,74 +893,46 @@ const LOADING_BAR_HEIGHT = 2, STATUS_CARD_TONE = {
|
|
|
1247
893
|
info: "alert"
|
|
1248
894
|
}, LONG_ENOUGH_BUT_NOT_TOO_LONG = 1e3 * 60 * 60 * 24 * 24;
|
|
1249
895
|
function Toast(props) {
|
|
1250
|
-
const
|
|
1251
|
-
let closable, description, duration, onClose, restProps, status, t0, title, updatedAt;
|
|
1252
|
-
$[0] !== props ? ({
|
|
896
|
+
const {
|
|
1253
897
|
closable,
|
|
1254
898
|
description,
|
|
1255
899
|
duration,
|
|
1256
900
|
onClose,
|
|
1257
|
-
radius
|
|
901
|
+
radius = 3,
|
|
1258
902
|
title,
|
|
1259
903
|
status,
|
|
1260
904
|
updatedAt,
|
|
1261
905
|
...restProps
|
|
1262
|
-
} = props,
|
|
1263
|
-
const radius = t0 === void 0 ? 3 : t0, cardTone = status ? STATUS_CARD_TONE[status] : "default", buttonTone = status ? BUTTON_TONE[status] : "default", role = status ? ROLES[status] : "status", visualDuration = _visualEditing.usePrefersReducedMotion() ? 0 : 0.26;
|
|
1264
|
-
let t1;
|
|
1265
|
-
$[10] !== visualDuration ? (t1 = visualDuration ? {
|
|
906
|
+
} = props, cardTone = status ? STATUS_CARD_TONE[status] : "default", buttonTone = status ? BUTTON_TONE[status] : "default", role = status ? ROLES[status] : "status", visualDuration = _visualEditing.usePrefersReducedMotion() ? 0 : 0.26, transition = visualDuration ? {
|
|
1266
907
|
type: "spring",
|
|
1267
908
|
visualDuration,
|
|
1268
909
|
bounce: 0.25
|
|
1269
910
|
} : {
|
|
1270
911
|
duration: 0
|
|
1271
|
-
},
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
let t10;
|
|
1296
|
-
$[27] !== t8 || $[28] !== t9 || $[29] !== transition ? (t10 = /* @__PURE__ */ jsxRuntime.jsxs(MotionFlex, { align: "flex-start", variants: content, transition, children: [
|
|
1297
|
-
t8,
|
|
1298
|
-
t9
|
|
1299
|
-
] }), $[27] = t8, $[28] = t9, $[29] = transition, $[30] = t10) : t10 = $[30];
|
|
1300
|
-
let t11;
|
|
1301
|
-
$[31] !== cardTone || $[32] !== duration || $[33] !== hasDuration || $[34] !== onClose || $[35] !== radius || $[36] !== transition || $[37] !== updatedAt || $[38] !== visualDuration ? (t11 = hasDuration && /* @__PURE__ */ jsxRuntime.jsxs(MotionLoadingBar, { variants: content, transition, children: [
|
|
1302
|
-
/* @__PURE__ */ jsxRuntime.jsx(LoadingBarMask, { tone: cardTone, radius }),
|
|
1303
|
-
/* @__PURE__ */ jsxRuntime.jsx(MotionLoadingBarProgress, { tone: cardTone, initial: {
|
|
1304
|
-
scaleX: 0
|
|
1305
|
-
}, animate: {
|
|
1306
|
-
scaleX: 1
|
|
1307
|
-
}, transition: {
|
|
1308
|
-
delay: visualDuration,
|
|
1309
|
-
duration: duration / 1e3,
|
|
1310
|
-
ease: "linear"
|
|
1311
|
-
}, onAnimationComplete: onClose }, `progress-${updatedAt}`)
|
|
1312
|
-
] }), $[31] = cardTone, $[32] = duration, $[33] = hasDuration, $[34] = onClose, $[35] = radius, $[36] = transition, $[37] = updatedAt, $[38] = visualDuration, $[39] = t11) : t11 = $[39];
|
|
1313
|
-
let t12;
|
|
1314
|
-
return $[40] !== cardTone || $[41] !== radius || $[42] !== restProps || $[43] !== role || $[44] !== t10 || $[45] !== t11 || $[46] !== t5 || $[47] !== transition || $[48] !== visualDuration ? (t12 = /* @__PURE__ */ jsxRuntime.jsxs(MotionToast, { "data-ui": "Toast", role, ...restProps, "data-has-duration": t5, custom: visualDuration, radius, shadow: 2, tone: cardTone, forwardedAs: "li", layout: "position", variants: container, initial, animate, exit, transition, children: [
|
|
1315
|
-
t10,
|
|
1316
|
-
t11
|
|
1317
|
-
] }), $[40] = cardTone, $[41] = radius, $[42] = restProps, $[43] = role, $[44] = t10, $[45] = t11, $[46] = t5, $[47] = transition, $[48] = visualDuration, $[49] = t12) : t12 = $[49], t12;
|
|
912
|
+
}, hasDuration = duration && isFinite(duration) && duration < LONG_ENOUGH_BUT_NOT_TOO_LONG;
|
|
913
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(MotionToast, { "data-ui": "Toast", role, ...restProps, "data-has-duration": hasDuration ? "" : void 0, custom: visualDuration, radius, shadow: 2, tone: cardTone, forwardedAs: "li", layout: "position", variants: container, initial: ["hidden", "initial"], animate: ["visible", "slideIn"], exit: ["hidden", "slideOut"], transition, children: [
|
|
914
|
+
/* @__PURE__ */ jsxRuntime.jsxs(MotionFlex, { align: "flex-start", variants: content, transition, children: [
|
|
915
|
+
/* @__PURE__ */ jsxRuntime.jsx(TextBox, { flex: 1, padding: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(_visualEditing.Stack, { space: 3, children: [
|
|
916
|
+
title && /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Text, { size: 1, weight: "medium", children: title }),
|
|
917
|
+
description && /* @__PURE__ */ jsxRuntime.jsx(MotionText, { muted: !0, size: 1, variants: content, transition, children: description })
|
|
918
|
+
] }) }),
|
|
919
|
+
closable && /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { padding: 1, children: /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Button, { as: "button", icon: icons.CloseIcon, mode: "bleed", padding: 2, tone: buttonTone, onClick: onClose, style: {
|
|
920
|
+
verticalAlign: "top"
|
|
921
|
+
} }) })
|
|
922
|
+
] }),
|
|
923
|
+
hasDuration && /* @__PURE__ */ jsxRuntime.jsxs(MotionLoadingBar, { variants: content, transition, children: [
|
|
924
|
+
/* @__PURE__ */ jsxRuntime.jsx(LoadingBarMask, { tone: cardTone, radius }),
|
|
925
|
+
/* @__PURE__ */ jsxRuntime.jsx(MotionLoadingBarProgress, { tone: cardTone, initial: {
|
|
926
|
+
scaleX: 0
|
|
927
|
+
}, animate: {
|
|
928
|
+
scaleX: 1
|
|
929
|
+
}, transition: {
|
|
930
|
+
delay: visualDuration,
|
|
931
|
+
duration: duration / 1e3,
|
|
932
|
+
ease: "linear"
|
|
933
|
+
}, onAnimationComplete: onClose }, `progress-${updatedAt}`)
|
|
934
|
+
] })
|
|
935
|
+
] });
|
|
1318
936
|
}
|
|
1319
937
|
Toast.displayName = "Toast";
|
|
1320
938
|
const container = {
|
|
@@ -1356,32 +974,23 @@ const container = {
|
|
|
1356
974
|
}
|
|
1357
975
|
}, MotionToast = framerMotion.motion.create(StyledToast), MotionFlex = framerMotion.motion.create(_visualEditing.Flex), MotionText = framerMotion.motion.create(_visualEditing.Text), MotionLoadingBar = framerMotion.motion.create(LoadingBar), MotionLoadingBarProgress = framerMotion.motion.create(LoadingBarProgress);
|
|
1358
976
|
function useMounted() {
|
|
1359
|
-
return react.useSyncExternalStore(subscribe,
|
|
1360
|
-
}
|
|
1361
|
-
function _temp2() {
|
|
1362
|
-
return !1;
|
|
1363
|
-
}
|
|
1364
|
-
function _temp$1() {
|
|
1365
|
-
return !0;
|
|
977
|
+
return react.useSyncExternalStore(subscribe, () => !0, () => !1);
|
|
1366
978
|
}
|
|
1367
979
|
const subscribe = () => () => {
|
|
1368
980
|
}, ToastContext = _visualEditing.createGlobalScopedContext("@sanity/ui/context/toast", null);
|
|
1369
981
|
function ToastLayer(props) {
|
|
1370
|
-
const
|
|
982
|
+
const {
|
|
1371
983
|
children,
|
|
1372
|
-
padding
|
|
984
|
+
padding = 4,
|
|
1373
985
|
paddingX,
|
|
1374
986
|
paddingY,
|
|
1375
|
-
gap
|
|
1376
|
-
} = props,
|
|
987
|
+
gap = 3
|
|
988
|
+
} = props, {
|
|
1377
989
|
zIndex
|
|
1378
990
|
} = _visualEditing.useLayer();
|
|
1379
|
-
|
|
1380
|
-
$[0] !== zIndex ? (t2 = {
|
|
991
|
+
return /* @__PURE__ */ jsxRuntime.jsx(StyledLayer, { forwardedAs: "ul", "data-ui": "ToastProvider", padding, paddingX, paddingY, gap, columns: 1, style: {
|
|
1381
992
|
zIndex
|
|
1382
|
-
},
|
|
1383
|
-
let t3;
|
|
1384
|
-
return $[2] !== children || $[3] !== gap || $[4] !== padding || $[5] !== paddingX || $[6] !== paddingY || $[7] !== t2 ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(StyledLayer, { forwardedAs: "ul", "data-ui": "ToastProvider", padding, paddingX, paddingY, gap, columns: 1, style: t2, children }), $[2] = children, $[3] = gap, $[4] = padding, $[5] = paddingX, $[6] = paddingY, $[7] = t2, $[8] = t3) : t3 = $[8], t3;
|
|
993
|
+
}, children });
|
|
1385
994
|
}
|
|
1386
995
|
ToastLayer.displayName = "ToastLayer";
|
|
1387
996
|
const StyledLayer = styledComponents.styled(_visualEditing.Grid).withConfig({
|
|
@@ -1393,19 +1002,14 @@ function generateToastId() {
|
|
|
1393
1002
|
return String(toastId++);
|
|
1394
1003
|
}
|
|
1395
1004
|
function ToastProvider(props) {
|
|
1396
|
-
const
|
|
1005
|
+
const {
|
|
1397
1006
|
children,
|
|
1398
1007
|
padding,
|
|
1399
1008
|
paddingX,
|
|
1400
1009
|
paddingY,
|
|
1401
1010
|
gap,
|
|
1402
|
-
zOffset
|
|
1403
|
-
} = props,
|
|
1404
|
-
let t1;
|
|
1405
|
-
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = [], $[0] = t1) : t1 = $[0];
|
|
1406
|
-
const [state, setState] = react.useState(t1), mounted = useMounted();
|
|
1407
|
-
let t2;
|
|
1408
|
-
$[1] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {
|
|
1011
|
+
zOffset = 1
|
|
1012
|
+
} = props, [state, setState] = react.useState([]), mounted = useMounted(), value = react.useMemo(() => ({
|
|
1409
1013
|
version: 0,
|
|
1410
1014
|
push: (params) => {
|
|
1411
1015
|
const id = params.id || generateToastId(), duration = params.duration || 5e3;
|
|
@@ -1413,8 +1017,8 @@ function ToastProvider(props) {
|
|
|
1413
1017
|
setState((prevState) => {
|
|
1414
1018
|
if (duration === 0.01)
|
|
1415
1019
|
return prevState.filter((toast) => toast.id !== id);
|
|
1416
|
-
const dismiss = () => react.startTransition(() => setState((currentState) => currentState.filter((
|
|
1417
|
-
return [...prevState.filter((
|
|
1020
|
+
const dismiss = () => react.startTransition(() => setState((currentState) => currentState.filter((toast) => toast.id !== id)));
|
|
1021
|
+
return [...prevState.filter((toast) => toast.id !== id), {
|
|
1418
1022
|
dismiss,
|
|
1419
1023
|
id,
|
|
1420
1024
|
updatedAt: Date.now(),
|
|
@@ -1426,24 +1030,16 @@ function ToastProvider(props) {
|
|
|
1426
1030
|
});
|
|
1427
1031
|
}), id;
|
|
1428
1032
|
}
|
|
1429
|
-
},
|
|
1430
|
-
|
|
1431
|
-
let t3;
|
|
1432
|
-
$[2] !== gap || $[3] !== mounted || $[4] !== padding || $[5] !== paddingX || $[6] !== paddingY || $[7] !== state || $[8] !== zOffset ? (t3 = mounted && /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.LayerProvider, { zOffset, children: /* @__PURE__ */ jsxRuntime.jsx(ToastLayer, { padding, paddingX, paddingY, gap, children: /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { initial: !1, mode: "popLayout", children: state.map(_temp) }) }) }), $[2] = gap, $[3] = mounted, $[4] = padding, $[5] = paddingX, $[6] = paddingY, $[7] = state, $[8] = zOffset, $[9] = t3) : t3 = $[9];
|
|
1433
|
-
let t4;
|
|
1434
|
-
return $[10] !== children || $[11] !== t3 ? (t4 = /* @__PURE__ */ jsxRuntime.jsxs(ToastContext.Provider, { value, children: [
|
|
1033
|
+
}), []);
|
|
1034
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ToastContext.Provider, { value, children: [
|
|
1435
1035
|
children,
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
dismiss:
|
|
1442
|
-
|
|
1443
|
-
params: params_0,
|
|
1444
|
-
updatedAt
|
|
1445
|
-
} = t0;
|
|
1446
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Toast, { closable: params_0.closable, description: params_0.description, onClose: dismiss_0, status: params_0.status, title: params_0.title, duration: params_0.duration, updatedAt }, id_0);
|
|
1036
|
+
mounted && /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.LayerProvider, { zOffset, children: /* @__PURE__ */ jsxRuntime.jsx(ToastLayer, { padding, paddingX, paddingY, gap, children: /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { initial: !1, mode: "popLayout", children: state.map(({
|
|
1037
|
+
dismiss,
|
|
1038
|
+
id,
|
|
1039
|
+
params,
|
|
1040
|
+
updatedAt
|
|
1041
|
+
}) => /* @__PURE__ */ jsxRuntime.jsx(Toast, { closable: params.closable, description: params.description, onClose: dismiss, status: params.status, title: params.title, duration: params.duration, updatedAt }, id)) }) }) })
|
|
1042
|
+
] });
|
|
1447
1043
|
}
|
|
1448
1044
|
ToastProvider.displayName = "ToastProvider";
|
|
1449
1045
|
function useToast() {
|
|
@@ -1509,68 +1105,44 @@ function _focusItemElement(el) {
|
|
|
1509
1105
|
}
|
|
1510
1106
|
}
|
|
1511
1107
|
const TreeContext = _visualEditing.createGlobalScopedContext("@sanity/ui/context/tree", null), Tree = react.forwardRef(function(props, forwardedRef) {
|
|
1512
|
-
const
|
|
1513
|
-
let children, onFocus, restProps, t0;
|
|
1514
|
-
$[0] !== props ? ({
|
|
1108
|
+
const {
|
|
1515
1109
|
children,
|
|
1516
|
-
space
|
|
1110
|
+
space = 1,
|
|
1517
1111
|
onFocus,
|
|
1518
1112
|
...restProps
|
|
1519
|
-
} = props,
|
|
1520
|
-
|
|
1521
|
-
let t1;
|
|
1522
|
-
$[5] === Symbol.for("react.memo_cache_sentinel") ? (t1 = [], $[5] = t1) : t1 = $[5];
|
|
1523
|
-
const path = t1;
|
|
1524
|
-
let t2;
|
|
1525
|
-
$[6] === Symbol.for("react.memo_cache_sentinel") ? (t2 = [], $[6] = t2) : t2 = $[6];
|
|
1526
|
-
const [itemElements, setItemElements] = react.useState(t2);
|
|
1527
|
-
let t3;
|
|
1528
|
-
$[7] === Symbol.for("react.memo_cache_sentinel") ? (t3 = {}, $[7] = t3) : t3 = $[7];
|
|
1529
|
-
const [state, setState] = react.useState(t3), stateRef = react.useRef(state);
|
|
1530
|
-
let t4;
|
|
1531
|
-
$[8] === Symbol.for("react.memo_cache_sentinel") ? (t4 = () => ref.current, $[8] = t4) : t4 = $[8], react.useImperativeHandle(forwardedRef, t4);
|
|
1532
|
-
let t5, t6;
|
|
1533
|
-
$[9] !== focusedElement ? (t5 = () => {
|
|
1113
|
+
} = props, ref = react.useRef(null), [focusedElement, setFocusedElement] = react.useState(null), focusedElementRef = react.useRef(focusedElement), path = react.useMemo(() => [], []), [itemElements, setItemElements] = react.useState([]), [state, setState] = react.useState({}), stateRef = react.useRef(state);
|
|
1114
|
+
react.useImperativeHandle(forwardedRef, () => ref.current), react.useEffect(() => {
|
|
1534
1115
|
focusedElementRef.current = focusedElement;
|
|
1535
|
-
},
|
|
1536
|
-
let t7, t8;
|
|
1537
|
-
$[12] !== state ? (t7 = () => {
|
|
1116
|
+
}, [focusedElement]), react.useEffect(() => {
|
|
1538
1117
|
stateRef.current = state;
|
|
1539
|
-
},
|
|
1540
|
-
|
|
1541
|
-
$[15] === Symbol.for("react.memo_cache_sentinel") ? (t9 = (element, path_0, expanded, selected) => (setState((s) => ({
|
|
1118
|
+
}, [state]);
|
|
1119
|
+
const registerItem = react.useCallback((element, path2, expanded, selected) => (setState((s) => ({
|
|
1542
1120
|
...s,
|
|
1543
|
-
[
|
|
1121
|
+
[path2]: {
|
|
1544
1122
|
element,
|
|
1545
1123
|
expanded
|
|
1546
1124
|
}
|
|
1547
1125
|
})), selected && setFocusedElement(element), () => {
|
|
1548
|
-
setState((
|
|
1126
|
+
setState((s) => {
|
|
1549
1127
|
const newState = {
|
|
1550
|
-
...
|
|
1128
|
+
...s
|
|
1551
1129
|
};
|
|
1552
|
-
return delete newState[
|
|
1130
|
+
return delete newState[path2], newState;
|
|
1553
1131
|
});
|
|
1554
|
-
}),
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
$[16] === Symbol.for("react.memo_cache_sentinel") ? (t10 = (path_1, expanded_0) => {
|
|
1558
|
-
setState((s_1) => {
|
|
1559
|
-
const itemState = s_1[path_1];
|
|
1132
|
+
}), []), setExpanded = react.useCallback((path2, expanded) => {
|
|
1133
|
+
setState((s) => {
|
|
1134
|
+
const itemState = s[path2];
|
|
1560
1135
|
return itemState ? {
|
|
1561
|
-
...
|
|
1562
|
-
[
|
|
1136
|
+
...s,
|
|
1137
|
+
[path2]: {
|
|
1563
1138
|
...itemState,
|
|
1564
|
-
expanded
|
|
1139
|
+
expanded
|
|
1565
1140
|
}
|
|
1566
|
-
} :
|
|
1141
|
+
} : s;
|
|
1567
1142
|
});
|
|
1568
|
-
},
|
|
1569
|
-
const setExpanded = t10, t11 = focusedElement || itemElements[0] || null;
|
|
1570
|
-
let t12;
|
|
1571
|
-
$[17] !== space || $[18] !== state || $[19] !== t11 ? (t12 = {
|
|
1143
|
+
}, []), contextValue = react.useMemo(() => ({
|
|
1572
1144
|
version: 0,
|
|
1573
|
-
focusedElement:
|
|
1145
|
+
focusedElement: focusedElement || itemElements[0] || null,
|
|
1574
1146
|
level: 0,
|
|
1575
1147
|
path,
|
|
1576
1148
|
registerItem,
|
|
@@ -1578,10 +1150,7 @@ const TreeContext = _visualEditing.createGlobalScopedContext("@sanity/ui/context
|
|
|
1578
1150
|
setFocusedElement,
|
|
1579
1151
|
space,
|
|
1580
1152
|
state
|
|
1581
|
-
},
|
|
1582
|
-
const contextValue = t12;
|
|
1583
|
-
let t13;
|
|
1584
|
-
$[21] !== itemElements ? (t13 = (event) => {
|
|
1153
|
+
}), [focusedElement, itemElements, path, registerItem, setExpanded, space, state]), handleKeyDown = react.useCallback((event) => {
|
|
1585
1154
|
if (focusedElementRef.current) {
|
|
1586
1155
|
if (event.key === "ArrowDown") {
|
|
1587
1156
|
event.preventDefault();
|
|
@@ -1598,21 +1167,19 @@ const TreeContext = _visualEditing.createGlobalScopedContext("@sanity/ui/context
|
|
|
1598
1167
|
if (event.key === "ArrowLeft") {
|
|
1599
1168
|
event.preventDefault();
|
|
1600
1169
|
const itemKey = focusedElementRef.current.getAttribute("data-tree-key");
|
|
1601
|
-
if (!itemKey)
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
if (
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
return itemState_1 ? {
|
|
1610
|
-
...s_2,
|
|
1170
|
+
if (!itemKey) return;
|
|
1171
|
+
const itemState = stateRef.current[itemKey];
|
|
1172
|
+
if (!itemState) return;
|
|
1173
|
+
if (itemState.expanded)
|
|
1174
|
+
setState((s) => {
|
|
1175
|
+
const itemState2 = s[itemKey];
|
|
1176
|
+
return itemState2 ? {
|
|
1177
|
+
...s,
|
|
1611
1178
|
[itemKey]: {
|
|
1612
|
-
...
|
|
1179
|
+
...itemState2,
|
|
1613
1180
|
expanded: !1
|
|
1614
1181
|
}
|
|
1615
|
-
} :
|
|
1182
|
+
} : s;
|
|
1616
1183
|
});
|
|
1617
1184
|
else {
|
|
1618
1185
|
const itemPath = itemKey.split("/");
|
|
@@ -1625,41 +1192,28 @@ const TreeContext = _visualEditing.createGlobalScopedContext("@sanity/ui/context
|
|
|
1625
1192
|
if (event.key === "ArrowRight") {
|
|
1626
1193
|
event.preventDefault();
|
|
1627
1194
|
const focusedKey = focusedElementRef.current.getAttribute("data-tree-key");
|
|
1628
|
-
if (!focusedKey)
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
...s_3,
|
|
1195
|
+
if (!focusedKey) return;
|
|
1196
|
+
stateRef.current[focusedKey]?.expanded || setState((s) => {
|
|
1197
|
+
const itemState = s[focusedKey];
|
|
1198
|
+
return itemState ? {
|
|
1199
|
+
...s,
|
|
1634
1200
|
[focusedKey]: {
|
|
1635
|
-
...
|
|
1201
|
+
...itemState,
|
|
1636
1202
|
expanded: !0
|
|
1637
1203
|
}
|
|
1638
|
-
} :
|
|
1204
|
+
} : s;
|
|
1639
1205
|
});
|
|
1640
1206
|
return;
|
|
1641
1207
|
}
|
|
1642
1208
|
}
|
|
1643
|
-
},
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
}, $[23] = onFocus, $[24] = t14) : t14 = $[24];
|
|
1649
|
-
const handleFocus = t14;
|
|
1650
|
-
let t15;
|
|
1651
|
-
$[25] === Symbol.for("react.memo_cache_sentinel") ? (t15 = () => {
|
|
1652
|
-
if (!ref.current)
|
|
1653
|
-
return;
|
|
1209
|
+
}, [itemElements]), handleFocus = react.useCallback((event) => {
|
|
1210
|
+
setFocusedElement(event.target), onFocus?.(event);
|
|
1211
|
+
}, [onFocus]);
|
|
1212
|
+
return react.useEffect(() => {
|
|
1213
|
+
if (!ref.current) return;
|
|
1654
1214
|
const _itemElements = Array.from(ref.current.querySelectorAll('[data-ui="TreeItem"]'));
|
|
1655
1215
|
setItemElements(_itemElements);
|
|
1656
|
-
},
|
|
1657
|
-
let t16;
|
|
1658
|
-
$[26] !== children ? (t16 = [children], $[26] = children, $[27] = t16) : t16 = $[27], react.useEffect(t15, t16);
|
|
1659
|
-
let t17;
|
|
1660
|
-
$[28] !== children || $[29] !== handleFocus || $[30] !== handleKeyDown || $[31] !== restProps || $[32] !== space ? (t17 = /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Stack, { as: "ul", "data-ui": "Tree", ...restProps, onFocus: handleFocus, onKeyDown: handleKeyDown, ref, role: "tree", space, children }), $[28] = children, $[29] = handleFocus, $[30] = handleKeyDown, $[31] = restProps, $[32] = space, $[33] = t17) : t17 = $[33];
|
|
1661
|
-
let t18;
|
|
1662
|
-
return $[34] !== contextValue || $[35] !== t17 ? (t18 = /* @__PURE__ */ jsxRuntime.jsx(TreeContext.Provider, { value: contextValue, children: t17 }), $[34] = contextValue, $[35] = t17, $[36] = t18) : t18 = $[36], t18;
|
|
1216
|
+
}, [children]), /* @__PURE__ */ jsxRuntime.jsx(TreeContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Stack, { as: "ul", "data-ui": "Tree", ...restProps, onFocus: handleFocus, onKeyDown: handleKeyDown, ref, role: "tree", space, children }) });
|
|
1663
1217
|
});
|
|
1664
1218
|
Tree.displayName = "ForwardRef(Tree)";
|
|
1665
1219
|
function treeItemRootStyle() {
|
|
@@ -1761,16 +1315,12 @@ function useTree() {
|
|
|
1761
1315
|
return tree;
|
|
1762
1316
|
}
|
|
1763
1317
|
function TreeGroup(props) {
|
|
1764
|
-
const
|
|
1765
|
-
let children, restProps, t0;
|
|
1766
|
-
$[0] !== props ? ({
|
|
1318
|
+
const {
|
|
1767
1319
|
children,
|
|
1768
|
-
expanded
|
|
1320
|
+
expanded = !1,
|
|
1769
1321
|
...restProps
|
|
1770
|
-
} = props,
|
|
1771
|
-
|
|
1772
|
-
let t2;
|
|
1773
|
-
return $[4] !== children || $[5] !== restProps || $[6] !== t1 || $[7] !== tree.space ? (t2 = /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Stack, { as: "ul", "data-ui": "TreeGroup", ...restProps, hidden: t1, marginTop: tree.space, role: "group", space: tree.space, children }), $[4] = children, $[5] = restProps, $[6] = t1, $[7] = tree.space, $[8] = t2) : t2 = $[8], t2;
|
|
1322
|
+
} = props, tree = useTree();
|
|
1323
|
+
return /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Stack, { as: "ul", "data-ui": "TreeGroup", ...restProps, hidden: !expanded, marginTop: tree.space, role: "group", space: tree.space, children });
|
|
1774
1324
|
}
|
|
1775
1325
|
const StyledTreeItem = /* @__PURE__ */ styledComponents.styled.li.withConfig({
|
|
1776
1326
|
displayName: "StyledTreeItem",
|
|
@@ -1785,115 +1335,64 @@ const StyledTreeItem = /* @__PURE__ */ styledComponents.styled.li.withConfig({
|
|
|
1785
1335
|
componentId: "sc-iiskig-2"
|
|
1786
1336
|
})`& > svg{transition:transform 100ms;}`;
|
|
1787
1337
|
function TreeItem(props) {
|
|
1788
|
-
const
|
|
1789
|
-
let IconComponent, children, href, idProp, linkAs, muted, onClick, restProps, t0, t1, t2, t3, t4, text, weight;
|
|
1790
|
-
$[0] !== props ? ({
|
|
1338
|
+
const {
|
|
1791
1339
|
children,
|
|
1792
|
-
expanded:
|
|
1793
|
-
fontSize
|
|
1340
|
+
expanded: expandedProp = !1,
|
|
1341
|
+
fontSize = 1,
|
|
1794
1342
|
href,
|
|
1795
1343
|
icon: IconComponent,
|
|
1796
1344
|
id: idProp,
|
|
1797
1345
|
linkAs,
|
|
1798
1346
|
muted,
|
|
1799
1347
|
onClick,
|
|
1800
|
-
padding
|
|
1801
|
-
selected
|
|
1802
|
-
space
|
|
1348
|
+
padding = 2,
|
|
1349
|
+
selected = !1,
|
|
1350
|
+
space = 2,
|
|
1803
1351
|
text,
|
|
1804
1352
|
weight,
|
|
1805
1353
|
...restProps
|
|
1806
|
-
} = props,
|
|
1807
|
-
const expandedProp = t0 === void 0 ? !1 : t0, fontSize = t1 === void 0 ? 1 : t1, padding = t2 === void 0 ? 2 : t2, selected = t3 === void 0 ? !1 : t3, space = t4 === void 0 ? 2 : t4, [rootElement, setRootElement] = react.useState(null), treeitemRef = react.useRef(null), tree = useTree(), {
|
|
1354
|
+
} = props, [rootElement, setRootElement] = react.useState(null), treeitemRef = react.useRef(null), tree = useTree(), {
|
|
1808
1355
|
path,
|
|
1809
1356
|
registerItem,
|
|
1810
1357
|
setExpanded,
|
|
1811
1358
|
setFocusedElement
|
|
1812
|
-
} = tree, _id = react.useId(), id = idProp || _id
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
t5 = itemPath, t6 = itemPath.join("/"), $[16] = id, $[17] = path, $[18] = t5, $[19] = t6;
|
|
1817
|
-
} else
|
|
1818
|
-
t5 = $[18], t6 = $[19];
|
|
1819
|
-
let t7;
|
|
1820
|
-
$[20] !== t5 || $[21] !== t6 ? (t7 = [t5, t6], $[20] = t5, $[21] = t6, $[22] = t7) : t7 = $[22];
|
|
1821
|
-
const [itemPath_0, itemKey] = t7, itemState = tree.state[itemKey], focused = tree.focusedElement === rootElement, expanded = itemState?.expanded === void 0 ? expandedProp : itemState?.expanded || !1, tabIndex = tree.focusedElement && tree.focusedElement === rootElement ? 0 : -1, t8 = tree.level + 1;
|
|
1822
|
-
let t9;
|
|
1823
|
-
$[23] !== itemPath_0 || $[24] !== t8 || $[25] !== tree ? (t9 = {
|
|
1359
|
+
} = tree, _id = react.useId(), id = idProp || _id, [itemPath, itemKey] = react.useMemo(() => {
|
|
1360
|
+
const itemPath2 = path.concat([id || ""]);
|
|
1361
|
+
return [itemPath2, itemPath2.join("/")];
|
|
1362
|
+
}, [id, path]), itemState = tree.state[itemKey], focused = tree.focusedElement === rootElement, expanded = itemState?.expanded === void 0 ? expandedProp : itemState?.expanded || !1, tabIndex = tree.focusedElement && tree.focusedElement === rootElement ? 0 : -1, contextValue = react.useMemo(() => ({
|
|
1824
1363
|
...tree,
|
|
1825
|
-
level:
|
|
1826
|
-
path:
|
|
1827
|
-
},
|
|
1828
|
-
const contextValue = t9;
|
|
1829
|
-
let t10;
|
|
1830
|
-
$[27] !== expanded || $[28] !== itemKey || $[29] !== onClick || $[30] !== rootElement || $[31] !== setExpanded || $[32] !== setFocusedElement ? (t10 = (event) => {
|
|
1364
|
+
level: tree.level + 1,
|
|
1365
|
+
path: itemPath
|
|
1366
|
+
}), [itemPath, tree]), handleClick = react.useCallback((event) => {
|
|
1831
1367
|
onClick && onClick(event);
|
|
1832
1368
|
const target = event.target;
|
|
1833
1369
|
target instanceof HTMLElement && (target.getAttribute("data-ui") === "TreeItem" || target.closest('[data-ui="TreeItem__box"]')) && (event.stopPropagation(), setExpanded(itemKey, !expanded), setFocusedElement(rootElement));
|
|
1834
|
-
},
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
focused && event_0.key === "Enter" && (treeitemRef.current || rootElement)?.click();
|
|
1839
|
-
}, $[34] = focused, $[35] = rootElement, $[36] = t11) : t11 = $[36];
|
|
1840
|
-
const handleKeyDown = t11;
|
|
1841
|
-
let t12, t13;
|
|
1842
|
-
$[37] !== expanded || $[38] !== itemKey || $[39] !== registerItem || $[40] !== rootElement || $[41] !== selected ? (t12 = () => {
|
|
1370
|
+
}, [expanded, itemKey, onClick, rootElement, setExpanded, setFocusedElement]), handleKeyDown = react.useCallback((event) => {
|
|
1371
|
+
focused && event.key === "Enter" && (treeitemRef.current || rootElement)?.click();
|
|
1372
|
+
}, [focused, rootElement]);
|
|
1373
|
+
react.useEffect(() => {
|
|
1843
1374
|
if (rootElement)
|
|
1844
1375
|
return registerItem(rootElement, itemKey, expanded, selected);
|
|
1845
|
-
},
|
|
1846
|
-
const
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
let t20;
|
|
1866
|
-
$[67] !== padding || $[68] !== t18 || $[69] !== t19 ? (t20 = /* @__PURE__ */ jsxRuntime.jsxs(_visualEditing.Flex, { padding, children: [
|
|
1867
|
-
t18,
|
|
1868
|
-
t19
|
|
1869
|
-
] }), $[67] = padding, $[68] = t18, $[69] = t19, $[70] = t20) : t20 = $[70];
|
|
1870
|
-
const content2 = t20;
|
|
1871
|
-
if (href) {
|
|
1872
|
-
const t212 = selected ? "" : void 0;
|
|
1873
|
-
let t222;
|
|
1874
|
-
$[71] !== content2 || $[72] !== expanded || $[73] !== href || $[74] !== linkAs || $[75] !== tabIndex || $[76] !== tree.level ? (t222 = /* @__PURE__ */ jsxRuntime.jsx(TreeItemBox, { $level: tree.level, "aria-expanded": expanded, as: linkAs, "data-ui": "TreeItem__box", href, ref: treeitemRef, role: "treeitem", tabIndex, children: content2 }), $[71] = content2, $[72] = expanded, $[73] = href, $[74] = linkAs, $[75] = tabIndex, $[76] = tree.level, $[77] = t222) : t222 = $[77];
|
|
1875
|
-
let t232;
|
|
1876
|
-
$[78] !== children || $[79] !== expanded ? (t232 = children && /* @__PURE__ */ jsxRuntime.jsx(TreeGroup, { hidden: !expanded, children }), $[78] = children, $[79] = expanded, $[80] = t232) : t232 = $[80];
|
|
1877
|
-
let t242;
|
|
1878
|
-
$[81] !== contextValue || $[82] !== t232 ? (t242 = /* @__PURE__ */ jsxRuntime.jsx(TreeContext.Provider, { value: contextValue, children: t232 }), $[81] = contextValue, $[82] = t232, $[83] = t242) : t242 = $[83];
|
|
1879
|
-
let t252;
|
|
1880
|
-
return $[84] !== handleClick || $[85] !== id || $[86] !== itemKey || $[87] !== restProps || $[88] !== t212 || $[89] !== t222 || $[90] !== t242 ? (t252 = /* @__PURE__ */ jsxRuntime.jsxs(StyledTreeItem, { "data-selected": t212, "data-tree-id": id, "data-tree-key": itemKey, "data-ui": "TreeItem", ...restProps, onClick: handleClick, ref: setRootElement, role: "none", children: [
|
|
1881
|
-
t222,
|
|
1882
|
-
t242
|
|
1883
|
-
] }), $[84] = handleClick, $[85] = id, $[86] = itemKey, $[87] = restProps, $[88] = t212, $[89] = t222, $[90] = t242, $[91] = t252) : t252 = $[91], t252;
|
|
1884
|
-
}
|
|
1885
|
-
const t21 = selected ? "" : void 0;
|
|
1886
|
-
let t22;
|
|
1887
|
-
$[92] !== content2 || $[93] !== tree.level ? (t22 = /* @__PURE__ */ jsxRuntime.jsx(TreeItemBox, { $level: tree.level, as: "div", "data-ui": "TreeItem__box", children: content2 }), $[92] = content2, $[93] = tree.level, $[94] = t22) : t22 = $[94];
|
|
1888
|
-
let t23;
|
|
1889
|
-
$[95] !== children || $[96] !== expanded ? (t23 = children && /* @__PURE__ */ jsxRuntime.jsx(TreeGroup, { expanded, children }), $[95] = children, $[96] = expanded, $[97] = t23) : t23 = $[97];
|
|
1890
|
-
let t24;
|
|
1891
|
-
$[98] !== contextValue || $[99] !== t23 ? (t24 = /* @__PURE__ */ jsxRuntime.jsx(TreeContext.Provider, { value: contextValue, children: t23 }), $[98] = contextValue, $[99] = t23, $[100] = t24) : t24 = $[100];
|
|
1892
|
-
let t25;
|
|
1893
|
-
return $[101] !== expanded || $[102] !== handleClick || $[103] !== handleKeyDown || $[104] !== id || $[105] !== itemKey || $[106] !== restProps || $[107] !== t21 || $[108] !== t22 || $[109] !== t24 || $[110] !== tabIndex ? (t25 = /* @__PURE__ */ jsxRuntime.jsxs(StyledTreeItem, { "data-selected": t21, "data-ui": "TreeItem", "data-tree-id": id, "data-tree-key": itemKey, ...restProps, "aria-expanded": expanded, onClick: handleClick, onKeyDown: handleKeyDown, ref: setRootElement, role: "treeitem", tabIndex, children: [
|
|
1894
|
-
t22,
|
|
1895
|
-
t24
|
|
1896
|
-
] }), $[101] = expanded, $[102] = handleClick, $[103] = handleKeyDown, $[104] = id, $[105] = itemKey, $[106] = restProps, $[107] = t21, $[108] = t22, $[109] = t24, $[110] = tabIndex, $[111] = t25) : t25 = $[111], t25;
|
|
1376
|
+
}, [expanded, itemKey, registerItem, rootElement, selected]);
|
|
1377
|
+
const content2 = /* @__PURE__ */ jsxRuntime.jsxs(_visualEditing.Flex, { padding, children: [
|
|
1378
|
+
/* @__PURE__ */ jsxRuntime.jsxs(_visualEditing.Box, { marginRight: space, style: {
|
|
1379
|
+
visibility: IconComponent || children ? "visible" : "hidden",
|
|
1380
|
+
pointerEvents: "none"
|
|
1381
|
+
}, children: [
|
|
1382
|
+
IconComponent && /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Text, { muted, size: fontSize, weight, children: /* @__PURE__ */ jsxRuntime.jsx(IconComponent, {}) }),
|
|
1383
|
+
!IconComponent && /* @__PURE__ */ jsxRuntime.jsx(ToggleArrowText, { muted, size: fontSize, weight, children: /* @__PURE__ */ jsxRuntime.jsx(icons.ToggleArrowRightIcon, { style: {
|
|
1384
|
+
transform: expanded ? "rotate(90deg)" : void 0
|
|
1385
|
+
} }) })
|
|
1386
|
+
] }),
|
|
1387
|
+
/* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Text, { muted, size: fontSize, textOverflow: "ellipsis", weight, children: text }) })
|
|
1388
|
+
] });
|
|
1389
|
+
return href ? /* @__PURE__ */ jsxRuntime.jsxs(StyledTreeItem, { "data-selected": selected ? "" : void 0, "data-tree-id": id, "data-tree-key": itemKey, "data-ui": "TreeItem", ...restProps, onClick: handleClick, ref: setRootElement, role: "none", children: [
|
|
1390
|
+
/* @__PURE__ */ jsxRuntime.jsx(TreeItemBox, { $level: tree.level, "aria-expanded": expanded, as: linkAs, "data-ui": "TreeItem__box", href, ref: treeitemRef, role: "treeitem", tabIndex, children: content2 }),
|
|
1391
|
+
/* @__PURE__ */ jsxRuntime.jsx(TreeContext.Provider, { value: contextValue, children: children && /* @__PURE__ */ jsxRuntime.jsx(TreeGroup, { hidden: !expanded, children }) })
|
|
1392
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(StyledTreeItem, { "data-selected": selected ? "" : void 0, "data-ui": "TreeItem", "data-tree-id": id, "data-tree-key": itemKey, ...restProps, "aria-expanded": expanded, onClick: handleClick, onKeyDown: handleKeyDown, ref: setRootElement, role: "treeitem", tabIndex, children: [
|
|
1393
|
+
/* @__PURE__ */ jsxRuntime.jsx(TreeItemBox, { $level: tree.level, as: "div", "data-ui": "TreeItem__box", children: content2 }),
|
|
1394
|
+
/* @__PURE__ */ jsxRuntime.jsx(TreeContext.Provider, { value: contextValue, children: children && /* @__PURE__ */ jsxRuntime.jsx(TreeGroup, { expanded, children }) })
|
|
1395
|
+
] });
|
|
1897
1396
|
}
|
|
1898
1397
|
TreeItem.displayName = "TreeItem";
|
|
1899
1398
|
exports.Arrow = _visualEditing.Arrow;
|