@sanity/ui 2.8.21 → 2.8.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +68 -221
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +68 -221
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -221
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/core/components/autocomplete/autocomplete.tsx +31 -42
package/dist/index.mjs
CHANGED
|
@@ -5025,17 +5025,15 @@ function autocompleteReducer(state, msg2) {
|
|
|
5025
5025
|
} : state;
|
|
5026
5026
|
}
|
|
5027
5027
|
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 = forwardRef(function(props, forwardedRef) {
|
|
5028
|
-
const
|
|
5029
|
-
|
|
5030
|
-
$[0] !== props ? ({
|
|
5031
|
-
border: t0,
|
|
5028
|
+
const {
|
|
5029
|
+
border: border2 = !0,
|
|
5032
5030
|
customValidity,
|
|
5033
5031
|
disabled,
|
|
5034
5032
|
filterOption: filterOptionProp,
|
|
5035
|
-
fontSize:
|
|
5033
|
+
fontSize: fontSize2 = 2,
|
|
5036
5034
|
icon,
|
|
5037
5035
|
id,
|
|
5038
|
-
listBox
|
|
5036
|
+
listBox = EMPTY_RECORD,
|
|
5039
5037
|
loading,
|
|
5040
5038
|
onBlur,
|
|
5041
5039
|
onChange,
|
|
@@ -5045,63 +5043,39 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = ["Control", "Shift", "Alt", "Enter", "H
|
|
|
5045
5043
|
openButton,
|
|
5046
5044
|
openOnFocus,
|
|
5047
5045
|
options: optionsProp,
|
|
5048
|
-
padding:
|
|
5049
|
-
popover
|
|
5046
|
+
padding: paddingProp = 3,
|
|
5047
|
+
popover = EMPTY_RECORD,
|
|
5050
5048
|
prefix,
|
|
5051
|
-
radius
|
|
5049
|
+
radius = 2,
|
|
5052
5050
|
readOnly,
|
|
5053
5051
|
relatedElements,
|
|
5054
5052
|
renderOption: renderOptionProp,
|
|
5055
5053
|
renderPopover,
|
|
5056
|
-
renderValue
|
|
5054
|
+
renderValue = DEFAULT_RENDER_VALUE,
|
|
5057
5055
|
suffix,
|
|
5058
5056
|
value: valueProp,
|
|
5059
5057
|
...restProps
|
|
5060
|
-
} = props,
|
|
5061
|
-
|
|
5062
|
-
let t9;
|
|
5063
|
-
$[30] !== t7 || $[31] !== t8 ? (t9 = {
|
|
5064
|
-
activeValue: t7,
|
|
5058
|
+
} = props, [state, dispatch] = useReducer(autocompleteReducer, {
|
|
5059
|
+
activeValue: valueProp || null,
|
|
5065
5060
|
focused: !1,
|
|
5066
5061
|
listFocused: !1,
|
|
5067
5062
|
query: null,
|
|
5068
|
-
value:
|
|
5069
|
-
},
|
|
5070
|
-
const [state, dispatch] = useReducer(autocompleteReducer, t9), {
|
|
5063
|
+
value: valueProp || null
|
|
5064
|
+
}), {
|
|
5071
5065
|
activeValue,
|
|
5072
5066
|
focused,
|
|
5073
5067
|
listFocused,
|
|
5074
5068
|
query,
|
|
5075
5069
|
value
|
|
5076
|
-
} = state
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
} = t112;
|
|
5082
|
-
return /* @__PURE__ */ jsx(Card, { "data-as": "button", padding: paddingProp, radius: 2, tone: "inherit", children: /* @__PURE__ */ jsx(Text, { size: fontSize2, textOverflow: "ellipsis", children: value_0 }) });
|
|
5083
|
-
}, $[33] = paddingProp, $[34] = fontSize2, $[35] = t10) : t10 = $[35];
|
|
5084
|
-
const renderOption = typeof renderOptionProp == "function" ? renderOptionProp : t10, filterOption = typeof filterOptionProp == "function" ? filterOptionProp : DEFAULT_FILTER_OPTION, [rootElement, setRootElement] = useState(null), [resultsPopoverElement, setResultsPopoverElement] = useState(null), [inputElement, setInputElement] = useState(null), listBoxElementRef = useRef(null), listFocusedRef = useRef(!1), valueRef = useRef(value), valuePropRef = useRef(valueProp), [popoverMouseWithin, setPopoverMouseWithin] = useState(!1);
|
|
5085
|
-
let t11, t12;
|
|
5086
|
-
$[36] !== inputElement ? (t11 = () => inputElement, t12 = [inputElement], $[36] = inputElement, $[37] = t11, $[38] = t12) : (t11 = $[37], t12 = $[38]), useImperativeHandle(forwardedRef, t11, t12);
|
|
5087
|
-
const listBoxId = `${id}-listbox`, options = Array.isArray(optionsProp) ? optionsProp : EMPTY_ARRAY, padding = useArrayProp(paddingProp);
|
|
5088
|
-
let t13, t14;
|
|
5089
|
-
$[39] !== value || $[40] !== options ? (t14 = value !== null ? options.find((o) => o.value === value) : void 0, $[39] = value, $[40] = options, $[41] = t14) : t14 = $[41], t13 = t14;
|
|
5090
|
-
const currentOption = t13;
|
|
5091
|
-
let t15, t16;
|
|
5092
|
-
if ($[42] !== query || $[43] !== filterOption || $[44] !== options) {
|
|
5093
|
-
let t172;
|
|
5094
|
-
$[46] !== query || $[47] !== filterOption ? (t172 = (option) => query ? filterOption(query, option) : !0, $[46] = query, $[47] = filterOption, $[48] = t172) : t172 = $[48], t16 = options.filter(t172), $[42] = query, $[43] = filterOption, $[44] = options, $[45] = t16;
|
|
5095
|
-
} else
|
|
5096
|
-
t16 = $[45];
|
|
5097
|
-
t15 = t16;
|
|
5098
|
-
const filteredOptions = t15, filteredOptionsLen = filteredOptions.length, activeItemId = activeValue ? `${id}-option-${activeValue}` : void 0, expanded = query !== null && loading || focused && query !== null;
|
|
5099
|
-
let t17;
|
|
5100
|
-
$[49] !== popoverMouseWithin || $[50] !== relatedElements || $[51] !== rootElement || $[52] !== resultsPopoverElement || $[53] !== onQueryChange || $[54] !== onBlur ? (t17 = (event) => {
|
|
5070
|
+
} = state, defaultRenderOption = useCallback(({
|
|
5071
|
+
value: value_0
|
|
5072
|
+
}) => /* @__PURE__ */ jsx(Card, { "data-as": "button", padding: paddingProp, radius: 2, tone: "inherit", children: /* @__PURE__ */ jsx(Text, { size: fontSize2, textOverflow: "ellipsis", children: value_0 }) }), [fontSize2, paddingProp]), renderOption = typeof renderOptionProp == "function" ? renderOptionProp : defaultRenderOption, filterOption = typeof filterOptionProp == "function" ? filterOptionProp : DEFAULT_FILTER_OPTION, rootElementRef = useRef(null), resultsPopoverElementRef = useRef(null), inputElementRef = useRef(null), listBoxElementRef = useRef(null), listFocusedRef = useRef(!1), valueRef = useRef(value), valuePropRef = useRef(valueProp), popoverMouseWithinRef = useRef(!1);
|
|
5073
|
+
useImperativeHandle(forwardedRef, () => inputElementRef.current);
|
|
5074
|
+
const listBoxId = `${id}-listbox`, options = Array.isArray(optionsProp) ? optionsProp : EMPTY_ARRAY, padding = useArrayProp(paddingProp), currentOption = useMemo(() => value !== null ? options.find((o) => o.value === value) : void 0, [options, value]), filteredOptions = 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 = useCallback((event) => {
|
|
5101
5075
|
setTimeout(() => {
|
|
5102
|
-
if (
|
|
5076
|
+
if (popoverMouseWithinRef.current)
|
|
5103
5077
|
return;
|
|
5104
|
-
const elements = (relatedElements || []).concat(
|
|
5078
|
+
const elements = (relatedElements || []).concat(rootElementRef.current ? [rootElementRef.current] : [], resultsPopoverElementRef.current ? [resultsPopoverElementRef.current] : []);
|
|
5105
5079
|
let focusInside = !1;
|
|
5106
5080
|
if (document.activeElement) {
|
|
5107
5081
|
for (const e of elements)
|
|
@@ -5112,32 +5086,22 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = ["Control", "Shift", "Alt", "Enter", "H
|
|
|
5112
5086
|
}
|
|
5113
5087
|
focusInside === !1 && (dispatch({
|
|
5114
5088
|
type: "root/blur"
|
|
5115
|
-
}),
|
|
5089
|
+
}), popoverMouseWithinRef.current = !1, onQueryChange && onQueryChange(null), onBlur && onBlur(event));
|
|
5116
5090
|
}, 0);
|
|
5117
|
-
},
|
|
5118
|
-
const handleRootBlur = t17;
|
|
5119
|
-
let t18;
|
|
5120
|
-
$[56] === Symbol.for("react.memo_cache_sentinel") ? (t18 = (event_0) => {
|
|
5091
|
+
}, [onBlur, onQueryChange, relatedElements]), handleRootFocus = useCallback((event_0) => {
|
|
5121
5092
|
const listBoxElement = listBoxElementRef.current, focusedElement = event_0.target instanceof HTMLElement ? event_0.target : null, listFocused_0 = listBoxElement?.contains(focusedElement) || !1;
|
|
5122
5093
|
listFocused_0 !== listFocusedRef.current && (listFocusedRef.current = listFocused_0, dispatch({
|
|
5123
5094
|
type: "root/setListFocused",
|
|
5124
5095
|
listFocused: listFocused_0
|
|
5125
5096
|
}));
|
|
5126
|
-
},
|
|
5127
|
-
const handleRootFocus = t18;
|
|
5128
|
-
let t19;
|
|
5129
|
-
$[57] !== onSelect || $[58] !== onChange || $[59] !== onQueryChange || $[60] !== inputElement ? (t19 = (v) => {
|
|
5097
|
+
}, []), handleOptionSelect = useCallback((v) => {
|
|
5130
5098
|
dispatch({
|
|
5131
5099
|
type: "value/change",
|
|
5132
5100
|
value: v
|
|
5133
|
-
}),
|
|
5134
|
-
},
|
|
5135
|
-
const handleOptionSelect = t19;
|
|
5136
|
-
let t20;
|
|
5137
|
-
$[62] !== filteredOptionsLen || $[63] !== filteredOptions || $[64] !== activeValue || $[65] !== onQueryChange || $[66] !== inputElement ? (t20 = (event_1) => {
|
|
5101
|
+
}), popoverMouseWithinRef.current = !1, onSelect && onSelect(v), valueRef.current = v, onChange && onChange(v), onQueryChange && onQueryChange(null), inputElementRef.current?.focus();
|
|
5102
|
+
}, [onChange, onSelect, onQueryChange]), handleRootKeyDown = useCallback((event_1) => {
|
|
5138
5103
|
if (event_1.key === "ArrowDown") {
|
|
5139
|
-
if (event_1.preventDefault(), !filteredOptionsLen)
|
|
5140
|
-
return;
|
|
5104
|
+
if (event_1.preventDefault(), !filteredOptionsLen) return;
|
|
5141
5105
|
const activeOption = filteredOptions.find((o_0) => o_0.value === activeValue), activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1, nextActiveOption = filteredOptions[(activeIndex + 1) % filteredOptionsLen];
|
|
5142
5106
|
nextActiveOption && dispatch({
|
|
5143
5107
|
type: "root/setActiveValue",
|
|
@@ -5147,8 +5111,7 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = ["Control", "Shift", "Alt", "Enter", "H
|
|
|
5147
5111
|
return;
|
|
5148
5112
|
}
|
|
5149
5113
|
if (event_1.key === "ArrowUp") {
|
|
5150
|
-
if (event_1.preventDefault(), !filteredOptionsLen)
|
|
5151
|
-
return;
|
|
5114
|
+
if (event_1.preventDefault(), !filteredOptionsLen) return;
|
|
5152
5115
|
const activeOption_0 = filteredOptions.find((o_1) => o_1.value === activeValue), activeIndex_0 = activeOption_0 ? filteredOptions.indexOf(activeOption_0) : -1, nextActiveOption_0 = filteredOptions[activeIndex_0 === -1 ? filteredOptionsLen - 1 : (filteredOptionsLen + activeIndex_0 - 1) % filteredOptionsLen];
|
|
5153
5116
|
nextActiveOption_0 && dispatch({
|
|
5154
5117
|
type: "root/setActiveValue",
|
|
@@ -5160,66 +5123,43 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = ["Control", "Shift", "Alt", "Enter", "H
|
|
|
5160
5123
|
if (event_1.key === "Escape") {
|
|
5161
5124
|
dispatch({
|
|
5162
5125
|
type: "root/escape"
|
|
5163
|
-
}),
|
|
5126
|
+
}), popoverMouseWithinRef.current = !1, onQueryChange && onQueryChange(null), inputElementRef.current?.focus();
|
|
5164
5127
|
return;
|
|
5165
5128
|
}
|
|
5166
5129
|
const target = event_1.target, listEl = listBoxElementRef.current;
|
|
5167
5130
|
if ((listEl === target || listEl?.contains(target)) && !AUTOCOMPLETE_LISTBOX_IGNORE_KEYS.includes(event_1.key)) {
|
|
5168
|
-
|
|
5131
|
+
inputElementRef.current?.focus();
|
|
5169
5132
|
return;
|
|
5170
5133
|
}
|
|
5171
|
-
},
|
|
5172
|
-
const handleRootKeyDown = t20;
|
|
5173
|
-
let t21;
|
|
5174
|
-
$[68] !== onQueryChange ? (t21 = (event_2) => {
|
|
5134
|
+
}, [activeValue, filteredOptions, filteredOptionsLen, onQueryChange]), handleInputChange = useCallback((event_2) => {
|
|
5175
5135
|
const nextQuery = event_2.currentTarget.value;
|
|
5176
5136
|
dispatch({
|
|
5177
5137
|
type: "input/change",
|
|
5178
5138
|
query: nextQuery
|
|
5179
5139
|
}), onQueryChange && onQueryChange(nextQuery);
|
|
5180
|
-
},
|
|
5181
|
-
const handleInputChange = t21;
|
|
5182
|
-
let t22;
|
|
5183
|
-
$[70] !== value || $[71] !== renderValue || $[72] !== currentOption ? (t22 = () => {
|
|
5140
|
+
}, [onQueryChange]), dispatchOpen = useCallback(() => {
|
|
5184
5141
|
dispatch({
|
|
5185
5142
|
type: "root/open",
|
|
5186
5143
|
query: value ? renderValue(value, currentOption) : ""
|
|
5187
5144
|
});
|
|
5188
|
-
},
|
|
5189
|
-
const dispatchOpen = t22;
|
|
5190
|
-
let t23;
|
|
5191
|
-
$[74] !== focused || $[75] !== onFocus || $[76] !== openOnFocus || $[77] !== dispatchOpen ? (t23 = (event_3) => {
|
|
5145
|
+
}, [currentOption, renderValue, value]), handleInputFocus = useCallback((event_3) => {
|
|
5192
5146
|
focused || (dispatch({
|
|
5193
5147
|
type: "input/focus"
|
|
5194
5148
|
}), onFocus && onFocus(event_3), openOnFocus && dispatchOpen());
|
|
5195
|
-
},
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
}, $[79] = t24) : t24 = $[79];
|
|
5201
|
-
const handlePopoverMouseEnter = t24;
|
|
5202
|
-
let t25;
|
|
5203
|
-
$[80] === Symbol.for("react.memo_cache_sentinel") ? (t25 = () => {
|
|
5204
|
-
setPopoverMouseWithin(!1);
|
|
5205
|
-
}, $[80] = t25) : t25 = $[80];
|
|
5206
|
-
const handlePopoverMouseLeave = t25;
|
|
5207
|
-
let t26;
|
|
5208
|
-
$[81] !== onChange || $[82] !== onQueryChange || $[83] !== inputElement ? (t26 = () => {
|
|
5149
|
+
}, [focused, onFocus, openOnFocus, dispatchOpen]), handlePopoverMouseEnter = useCallback(() => {
|
|
5150
|
+
popoverMouseWithinRef.current = !0;
|
|
5151
|
+
}, []), handlePopoverMouseLeave = useCallback(() => {
|
|
5152
|
+
popoverMouseWithinRef.current = !1;
|
|
5153
|
+
}, []), handleClearButtonClick = useCallback(() => {
|
|
5209
5154
|
dispatch({
|
|
5210
5155
|
type: "root/clear"
|
|
5211
|
-
}), valueRef.current = "", onChange && onChange(""), onQueryChange && onQueryChange(null),
|
|
5212
|
-
},
|
|
5213
|
-
const handleClearButtonClick = t26;
|
|
5214
|
-
let t27;
|
|
5215
|
-
$[85] === Symbol.for("react.memo_cache_sentinel") ? (t27 = () => {
|
|
5156
|
+
}), valueRef.current = "", onChange && onChange(""), onQueryChange && onQueryChange(null), inputElementRef.current?.focus();
|
|
5157
|
+
}, [onChange, onQueryChange]), handleClearButtonFocus = useCallback(() => {
|
|
5216
5158
|
dispatch({
|
|
5217
5159
|
type: "input/focus"
|
|
5218
5160
|
});
|
|
5219
|
-
},
|
|
5220
|
-
|
|
5221
|
-
let t28, t29;
|
|
5222
|
-
$[86] !== valueProp ? (t28 = () => {
|
|
5161
|
+
}, []);
|
|
5162
|
+
useEffect(() => {
|
|
5223
5163
|
if (valueProp !== valuePropRef.current) {
|
|
5224
5164
|
valuePropRef.current = valueProp, valueProp !== void 0 && (dispatch({
|
|
5225
5165
|
type: "value/change",
|
|
@@ -5231,19 +5171,14 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = ["Control", "Shift", "Alt", "Enter", "H
|
|
|
5231
5171
|
type: "value/change",
|
|
5232
5172
|
value: valueProp || null
|
|
5233
5173
|
}));
|
|
5234
|
-
},
|
|
5235
|
-
let t30, t31;
|
|
5236
|
-
$[89] !== focused ? (t30 = () => {
|
|
5174
|
+
}, [valueProp]), useEffect(() => {
|
|
5237
5175
|
!focused && valueRef.current && dispatch({
|
|
5238
5176
|
type: "root/setActiveValue",
|
|
5239
5177
|
value: valueRef.current
|
|
5240
5178
|
});
|
|
5241
|
-
},
|
|
5242
|
-
let t32, t33;
|
|
5243
|
-
$[92] !== filteredOptions || $[93] !== activeValue ? (t32 = () => {
|
|
5179
|
+
}, [focused]), useEffect(() => {
|
|
5244
5180
|
const listElement = listBoxElementRef.current;
|
|
5245
|
-
if (!listElement)
|
|
5246
|
-
return;
|
|
5181
|
+
if (!listElement) return;
|
|
5247
5182
|
const activeOption_1 = filteredOptions.find((o_2) => o_2.value === activeValue);
|
|
5248
5183
|
if (activeOption_1) {
|
|
5249
5184
|
const activeIndex_1 = filteredOptions.indexOf(activeOption_1), activeItemElement = listElement.childNodes[activeIndex_1];
|
|
@@ -5253,123 +5188,35 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = ["Control", "Shift", "Alt", "Enter", "H
|
|
|
5253
5188
|
focusFirstDescendant(activeItemElement);
|
|
5254
5189
|
}
|
|
5255
5190
|
}
|
|
5256
|
-
},
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
let t352;
|
|
5261
|
-
$[96] === Symbol.for("react.memo_cache_sentinel") ? (t352 = {
|
|
5191
|
+
}, [activeValue, filteredOptions]);
|
|
5192
|
+
const clearButton = useMemo(() => {
|
|
5193
|
+
if (!loading && !disabled && value)
|
|
5194
|
+
return {
|
|
5262
5195
|
"aria-label": "Clear",
|
|
5263
5196
|
onFocus: handleClearButtonFocus
|
|
5264
|
-
}
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
}
|
|
5283
|
-
|
|
5284
|
-
t37 = t38;
|
|
5285
|
-
const openButtonPadding = t37;
|
|
5286
|
-
let t39;
|
|
5287
|
-
t39 = typeof openButton == "object" ? openButton : EMPTY_RECORD;
|
|
5288
|
-
const openButtonProps = t39;
|
|
5289
|
-
let t40;
|
|
5290
|
-
$[103] !== dispatchOpen || $[104] !== openButtonProps || $[105] !== inputElement ? (t40 = (event_4) => {
|
|
5291
|
-
dispatchOpen(), openButtonProps.onClick && openButtonProps.onClick(event_4), _raf(() => inputElement?.focus());
|
|
5292
|
-
}, $[103] = dispatchOpen, $[104] = openButtonProps, $[105] = inputElement, $[106] = t40) : t40 = $[106];
|
|
5293
|
-
const handleOpenClick = t40;
|
|
5294
|
-
let t41, t42;
|
|
5295
|
-
$[107] !== disabled || $[108] !== readOnly || $[109] !== openButton || $[110] !== expanded || $[111] !== fontSize2 || $[112] !== openButtonPadding || $[113] !== openButtonProps || $[114] !== handleOpenClick || $[115] !== openButtonBoxPadding ? (t42 = !disabled && !readOnly && openButton ? /* @__PURE__ */ jsx(Box, { "aria-hidden": expanded, padding: openButtonBoxPadding, children: /* @__PURE__ */ jsx(Button, { "aria-label": "Open", disabled: expanded, fontSize: fontSize2, icon: ChevronDownIcon, mode: "bleed", padding: openButtonPadding, ...openButtonProps, onClick: handleOpenClick }) }) : void 0, $[107] = disabled, $[108] = readOnly, $[109] = openButton, $[110] = expanded, $[111] = fontSize2, $[112] = openButtonPadding, $[113] = openButtonProps, $[114] = handleOpenClick, $[115] = openButtonBoxPadding, $[116] = t42) : t42 = $[116], t41 = t42;
|
|
5296
|
-
const openButtonNode = t41;
|
|
5297
|
-
let t43;
|
|
5298
|
-
bb1: {
|
|
5299
|
-
if (query === null) {
|
|
5300
|
-
if (value !== null) {
|
|
5301
|
-
let t442;
|
|
5302
|
-
$[117] !== renderValue || $[118] !== value || $[119] !== currentOption ? (t442 = renderValue(value, currentOption), $[117] = renderValue, $[118] = value, $[119] = currentOption, $[120] = t442) : t442 = $[120], t43 = t442;
|
|
5303
|
-
break bb1;
|
|
5304
|
-
}
|
|
5305
|
-
t43 = "";
|
|
5306
|
-
break bb1;
|
|
5307
|
-
}
|
|
5308
|
-
t43 = query;
|
|
5309
|
-
}
|
|
5310
|
-
const inputValue = t43, t44 = loading && AnimatedSpinnerIcon, t45 = suffix || openButtonNode;
|
|
5311
|
-
let t46;
|
|
5312
|
-
$[121] !== restProps || $[122] !== activeItemId || $[123] !== expanded || $[124] !== listBoxId || $[125] !== border2 || $[126] !== clearButton || $[127] !== customValidity || $[128] !== disabled || $[129] !== fontSize2 || $[130] !== icon || $[131] !== t44 || $[132] !== id || $[133] !== handleInputChange || $[134] !== handleClearButtonClick || $[135] !== handleInputFocus || $[136] !== padding || $[137] !== prefix || $[138] !== radius || $[139] !== readOnly || $[140] !== t45 || $[141] !== inputValue ? (t46 = /* @__PURE__ */ jsx(TextInput, { ...restProps, "aria-activedescendant": activeItemId, "aria-autocomplete": "list", "aria-expanded": expanded, "aria-owns": listBoxId, autoCapitalize: "off", autoComplete: "off", autoCorrect: "off", border: border2, clearButton, customValidity, disabled, fontSize: fontSize2, icon, iconRight: t44, id, inputMode: "search", onChange: handleInputChange, onClear: handleClearButtonClick, onFocus: handleInputFocus, padding, prefix, radius, readOnly, ref: setInputElement, role: "combobox", spellCheck: !1, suffix: t45, value: inputValue }), $[121] = restProps, $[122] = activeItemId, $[123] = expanded, $[124] = listBoxId, $[125] = border2, $[126] = clearButton, $[127] = customValidity, $[128] = disabled, $[129] = fontSize2, $[130] = icon, $[131] = t44, $[132] = id, $[133] = handleInputChange, $[134] = handleClearButtonClick, $[135] = handleInputFocus, $[136] = padding, $[137] = prefix, $[138] = radius, $[139] = readOnly, $[140] = t45, $[141] = inputValue, $[142] = t46) : t46 = $[142];
|
|
5313
|
-
const input = t46;
|
|
5314
|
-
let t47;
|
|
5315
|
-
$[143] !== listFocused || $[144] !== inputElement ? (t47 = (event_5) => {
|
|
5316
|
-
event_5.key === "Tab" && listFocused && inputElement?.focus();
|
|
5317
|
-
}, $[143] = listFocused, $[144] = inputElement, $[145] = t47) : t47 = $[145];
|
|
5318
|
-
const handleListBoxKeyDown = t47;
|
|
5319
|
-
let t48;
|
|
5320
|
-
bb2: {
|
|
5321
|
-
if (filteredOptions.length === 0) {
|
|
5322
|
-
t48 = null;
|
|
5323
|
-
break bb2;
|
|
5324
|
-
}
|
|
5325
|
-
let t492;
|
|
5326
|
-
if ($[146] !== activeValue || $[147] !== currentOption || $[148] !== id || $[149] !== handleOptionSelect || $[150] !== renderOption || $[151] !== loading || $[152] !== listFocused || $[153] !== filteredOptions) {
|
|
5327
|
-
let t503;
|
|
5328
|
-
$[155] !== activeValue || $[156] !== currentOption || $[157] !== id || $[158] !== handleOptionSelect || $[159] !== renderOption || $[160] !== loading || $[161] !== listFocused ? (t503 = (option_0) => {
|
|
5329
|
-
const active = activeValue !== null ? option_0.value === activeValue : currentOption === option_0;
|
|
5330
|
-
return /* @__PURE__ */ jsx(AutocompleteOption, { id: `${id}-option-${option_0.value}`, onSelect: handleOptionSelect, selected: active, value: option_0.value, children: cloneElement(renderOption(option_0), {
|
|
5331
|
-
disabled: loading,
|
|
5332
|
-
selected: active,
|
|
5333
|
-
tabIndex: listFocused && active ? 0 : -1
|
|
5334
|
-
}) }, option_0.value);
|
|
5335
|
-
}, $[155] = activeValue, $[156] = currentOption, $[157] = id, $[158] = handleOptionSelect, $[159] = renderOption, $[160] = loading, $[161] = listFocused, $[162] = t503) : t503 = $[162], t492 = filteredOptions.map(t503), $[146] = activeValue, $[147] = currentOption, $[148] = id, $[149] = handleOptionSelect, $[150] = renderOption, $[151] = loading, $[152] = listFocused, $[153] = filteredOptions, $[154] = t492;
|
|
5336
|
-
} else
|
|
5337
|
-
t492 = $[154];
|
|
5338
|
-
let t502;
|
|
5339
|
-
$[163] !== listBoxId || $[164] !== t492 ? (t502 = /* @__PURE__ */ jsx(Stack, { as: "ul", "aria-multiselectable": !1, "data-ui": "AutoComplete__resultsList", id: listBoxId, ref: listBoxElementRef, role: "listbox", space: 1, children: t492 }), $[163] = listBoxId, $[164] = t492, $[165] = t502) : t502 = $[165];
|
|
5340
|
-
let t51;
|
|
5341
|
-
$[166] !== handleListBoxKeyDown || $[167] !== listBox || $[168] !== t502 ? (t51 = /* @__PURE__ */ jsx(ListBox, { "data-ui": "AutoComplete__results", onKeyDown: handleListBoxKeyDown, padding: 1, ...listBox, tabIndex: -1, children: t502 }), $[166] = handleListBoxKeyDown, $[167] = listBox, $[168] = t502, $[169] = t51) : t51 = $[169], t48 = t51;
|
|
5342
|
-
}
|
|
5343
|
-
const content = t48;
|
|
5344
|
-
let t49;
|
|
5345
|
-
bb3: {
|
|
5346
|
-
if (renderPopover) {
|
|
5347
|
-
const t503 = !expanded;
|
|
5348
|
-
let t51;
|
|
5349
|
-
$[170] !== content || $[171] !== t503 || $[172] !== inputElement || $[173] !== resultsPopoverElement || $[174] !== renderPopover ? (t51 = renderPopover({
|
|
5350
|
-
content,
|
|
5351
|
-
hidden: t503,
|
|
5352
|
-
inputElement,
|
|
5353
|
-
onMouseEnter: handlePopoverMouseEnter,
|
|
5354
|
-
onMouseLeave: handlePopoverMouseLeave
|
|
5355
|
-
}, {
|
|
5356
|
-
current: resultsPopoverElement
|
|
5357
|
-
}), $[170] = content, $[171] = t503, $[172] = inputElement, $[173] = resultsPopoverElement, $[174] = renderPopover, $[175] = t51) : t51 = $[175], t49 = t51;
|
|
5358
|
-
break bb3;
|
|
5359
|
-
}
|
|
5360
|
-
if (filteredOptionsLen === 0) {
|
|
5361
|
-
t49 = null;
|
|
5362
|
-
break bb3;
|
|
5363
|
-
}
|
|
5364
|
-
let t502;
|
|
5365
|
-
$[176] !== content || $[177] !== expanded || $[178] !== radius || $[179] !== inputElement || $[180] !== popover ? (t502 = /* @__PURE__ */ jsx(Popover, { arrow: !1, constrainSize: !0, content, fallbackPlacements: AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS, matchReferenceWidth: !0, onMouseEnter: handlePopoverMouseEnter, onMouseLeave: handlePopoverMouseLeave, open: expanded, overflow: "auto", placement: AUTOCOMPLETE_POPOVER_PLACEMENT, portal: !0, radius, ref: setResultsPopoverElement, referenceElement: inputElement, ...popover }), $[176] = content, $[177] = expanded, $[178] = radius, $[179] = inputElement, $[180] = popover, $[181] = t502) : t502 = $[181], t49 = t502;
|
|
5366
|
-
}
|
|
5367
|
-
const results = t49;
|
|
5368
|
-
let t50;
|
|
5369
|
-
return $[182] !== handleRootBlur || $[183] !== handleRootKeyDown || $[184] !== input || $[185] !== results ? (t50 = /* @__PURE__ */ jsxs(Root$9, { "data-ui": "Autocomplete", onBlur: handleRootBlur, onFocus: handleRootFocus, onKeyDown: handleRootKeyDown, ref: setRootElement, children: [
|
|
5197
|
+
};
|
|
5198
|
+
}, [disabled, handleClearButtonFocus, loading, value]), openButtonBoxPadding = useMemo(() => padding.map((v_0) => v_0 === 0 ? 0 : v_0 === 1 || v_0 === 2 ? 1 : v_0 - 2), [padding]), openButtonPadding = useMemo(() => padding.map((v_1) => Math.max(v_1 - 1, 0)), [padding]), openButtonProps = useMemo(() => typeof openButton == "object" ? openButton : EMPTY_RECORD, [openButton]), handleOpenClick = useCallback((event_4) => {
|
|
5199
|
+
dispatchOpen(), openButtonProps.onClick && openButtonProps.onClick(event_4), _raf(() => inputElementRef.current?.focus());
|
|
5200
|
+
}, [openButtonProps, dispatchOpen]), openButtonNode = useMemo(() => !disabled && !readOnly && openButton ? /* @__PURE__ */ jsx(Box, { "aria-hidden": expanded, padding: openButtonBoxPadding, children: /* @__PURE__ */ jsx(Button, { "aria-label": "Open", disabled: expanded, fontSize: fontSize2, icon: ChevronDownIcon, mode: "bleed", padding: openButtonPadding, ...openButtonProps, onClick: handleOpenClick }) }) : void 0, [disabled, expanded, fontSize2, handleOpenClick, openButton, openButtonBoxPadding, openButtonPadding, openButtonProps, readOnly]), inputValue = useMemo(() => query === null ? value !== null ? renderValue(value, currentOption) : "" : query, [currentOption, query, renderValue, value]), input = /* @__PURE__ */ jsx(TextInput, { ...restProps, "aria-activedescendant": activeItemId, "aria-autocomplete": "list", "aria-expanded": expanded, "aria-owns": listBoxId, autoCapitalize: "off", autoComplete: "off", autoCorrect: "off", border: border2, clearButton, customValidity, disabled, fontSize: fontSize2, icon, iconRight: loading && AnimatedSpinnerIcon, id, inputMode: "search", onChange: handleInputChange, onClear: handleClearButtonClick, onFocus: handleInputFocus, padding, prefix, radius, readOnly, ref: inputElementRef, role: "combobox", spellCheck: !1, suffix: suffix || openButtonNode, value: inputValue }), handleListBoxKeyDown = useCallback((event_5) => {
|
|
5201
|
+
event_5.key === "Tab" && listFocused && inputElementRef.current?.focus();
|
|
5202
|
+
}, [listFocused]), content = useMemo(() => filteredOptions.length === 0 ? null : /* @__PURE__ */ jsx(ListBox, { "data-ui": "AutoComplete__results", onKeyDown: handleListBoxKeyDown, padding: 1, ...listBox, tabIndex: -1, children: /* @__PURE__ */ jsx(Stack, { as: "ul", "aria-multiselectable": !1, "data-ui": "AutoComplete__resultsList", id: listBoxId, ref: listBoxElementRef, role: "listbox", space: 1, children: filteredOptions.map((option_0) => {
|
|
5203
|
+
const active = activeValue !== null ? option_0.value === activeValue : currentOption === option_0;
|
|
5204
|
+
return /* @__PURE__ */ jsx(AutocompleteOption, { id: `${id}-option-${option_0.value}`, onSelect: handleOptionSelect, selected: active, value: option_0.value, children: cloneElement(renderOption(option_0), {
|
|
5205
|
+
disabled: loading,
|
|
5206
|
+
selected: active,
|
|
5207
|
+
tabIndex: listFocused && active ? 0 : -1
|
|
5208
|
+
}) }, option_0.value);
|
|
5209
|
+
}) }) }), [activeValue, currentOption, filteredOptions, handleOptionSelect, handleListBoxKeyDown, id, listBox, listBoxId, listFocused, loading, renderOption]), results = useMemo(() => renderPopover ? renderPopover({
|
|
5210
|
+
content,
|
|
5211
|
+
hidden: !expanded,
|
|
5212
|
+
inputElement: inputElementRef.current,
|
|
5213
|
+
onMouseEnter: handlePopoverMouseEnter,
|
|
5214
|
+
onMouseLeave: handlePopoverMouseLeave
|
|
5215
|
+
}, resultsPopoverElementRef) : filteredOptionsLen === 0 ? null : /* @__PURE__ */ jsx(Popover, { arrow: !1, constrainSize: !0, content, 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: inputElementRef.current, ...popover }), [content, expanded, filteredOptionsLen, handlePopoverMouseEnter, handlePopoverMouseLeave, popover, radius, renderPopover]);
|
|
5216
|
+
return /* @__PURE__ */ jsxs(Root$9, { "data-ui": "Autocomplete", onBlur: handleRootBlur, onFocus: handleRootFocus, onKeyDown: handleRootKeyDown, ref: rootElementRef, children: [
|
|
5370
5217
|
input,
|
|
5371
5218
|
results
|
|
5372
|
-
] })
|
|
5219
|
+
] });
|
|
5373
5220
|
});
|
|
5374
5221
|
InnerAutocomplete.displayName = "ForwardRef(Autocomplete)";
|
|
5375
5222
|
const Autocomplete = InnerAutocomplete, Root$8 = styled.ol`
|