@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.js CHANGED
@@ -5019,17 +5019,15 @@ function autocompleteReducer(state, msg2) {
5019
5019
  } : state;
5020
5020
  }
5021
5021
  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) {
5022
- const $ = reactCompilerRuntime.c(187);
5023
- let t0, t1, t2, t3, t4, t5, t6, valueProp, renderOptionProp, filterOptionProp, id, optionsProp, loading, onBlur, onQueryChange, relatedElements, onSelect, onChange, onFocus, openOnFocus, disabled, openButton, readOnly, suffix, restProps, customValidity, icon, prefix, renderPopover;
5024
- $[0] !== props ? ({
5025
- border: t0,
5022
+ const {
5023
+ border: border2 = !0,
5026
5024
  customValidity,
5027
5025
  disabled,
5028
5026
  filterOption: filterOptionProp,
5029
- fontSize: t1,
5027
+ fontSize: fontSize2 = 2,
5030
5028
  icon,
5031
5029
  id,
5032
- listBox: t2,
5030
+ listBox = EMPTY_RECORD,
5033
5031
  loading,
5034
5032
  onBlur,
5035
5033
  onChange,
@@ -5039,63 +5037,39 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = ["Control", "Shift", "Alt", "Enter", "H
5039
5037
  openButton,
5040
5038
  openOnFocus,
5041
5039
  options: optionsProp,
5042
- padding: t3,
5043
- popover: t4,
5040
+ padding: paddingProp = 3,
5041
+ popover = EMPTY_RECORD,
5044
5042
  prefix,
5045
- radius: t5,
5043
+ radius = 2,
5046
5044
  readOnly,
5047
5045
  relatedElements,
5048
5046
  renderOption: renderOptionProp,
5049
5047
  renderPopover,
5050
- renderValue: t6,
5048
+ renderValue = DEFAULT_RENDER_VALUE,
5051
5049
  suffix,
5052
5050
  value: valueProp,
5053
5051
  ...restProps
5054
- } = props, $[0] = props, $[1] = t0, $[2] = t1, $[3] = t2, $[4] = t3, $[5] = t4, $[6] = t5, $[7] = t6, $[8] = valueProp, $[9] = renderOptionProp, $[10] = filterOptionProp, $[11] = id, $[12] = optionsProp, $[13] = loading, $[14] = onBlur, $[15] = onQueryChange, $[16] = relatedElements, $[17] = onSelect, $[18] = onChange, $[19] = onFocus, $[20] = openOnFocus, $[21] = disabled, $[22] = openButton, $[23] = readOnly, $[24] = suffix, $[25] = restProps, $[26] = customValidity, $[27] = icon, $[28] = prefix, $[29] = renderPopover) : (t0 = $[1], t1 = $[2], t2 = $[3], t3 = $[4], t4 = $[5], t5 = $[6], t6 = $[7], valueProp = $[8], renderOptionProp = $[9], filterOptionProp = $[10], id = $[11], optionsProp = $[12], loading = $[13], onBlur = $[14], onQueryChange = $[15], relatedElements = $[16], onSelect = $[17], onChange = $[18], onFocus = $[19], openOnFocus = $[20], disabled = $[21], openButton = $[22], readOnly = $[23], suffix = $[24], restProps = $[25], customValidity = $[26], icon = $[27], prefix = $[28], renderPopover = $[29]);
5055
- const border2 = t0 === void 0 ? !0 : t0, fontSize2 = t1 === void 0 ? 2 : t1, listBox = t2 === void 0 ? EMPTY_RECORD : t2, paddingProp = t3 === void 0 ? 3 : t3, popover = t4 === void 0 ? EMPTY_RECORD : t4, radius = t5 === void 0 ? 2 : t5, renderValue = t6 === void 0 ? DEFAULT_RENDER_VALUE : t6, t7 = valueProp || null, t8 = valueProp || null;
5056
- let t9;
5057
- $[30] !== t7 || $[31] !== t8 ? (t9 = {
5058
- activeValue: t7,
5052
+ } = props, [state, dispatch] = react.useReducer(autocompleteReducer, {
5053
+ activeValue: valueProp || null,
5059
5054
  focused: !1,
5060
5055
  listFocused: !1,
5061
5056
  query: null,
5062
- value: t8
5063
- }, $[30] = t7, $[31] = t8, $[32] = t9) : t9 = $[32];
5064
- const [state, dispatch] = react.useReducer(autocompleteReducer, t9), {
5057
+ value: valueProp || null
5058
+ }), {
5065
5059
  activeValue,
5066
5060
  focused,
5067
5061
  listFocused,
5068
5062
  query,
5069
5063
  value
5070
- } = state;
5071
- let t10;
5072
- $[33] !== paddingProp || $[34] !== fontSize2 ? (t10 = (t112) => {
5073
- const {
5074
- value: value_0
5075
- } = t112;
5076
- return /* @__PURE__ */ jsxRuntime.jsx(Card, { "data-as": "button", padding: paddingProp, radius: 2, tone: "inherit", children: /* @__PURE__ */ jsxRuntime.jsx(Text, { size: fontSize2, textOverflow: "ellipsis", children: value_0 }) });
5077
- }, $[33] = paddingProp, $[34] = fontSize2, $[35] = t10) : t10 = $[35];
5078
- const renderOption = typeof renderOptionProp == "function" ? renderOptionProp : t10, filterOption = typeof filterOptionProp == "function" ? filterOptionProp : DEFAULT_FILTER_OPTION, [rootElement, setRootElement] = react.useState(null), [resultsPopoverElement, setResultsPopoverElement] = react.useState(null), [inputElement, setInputElement] = react.useState(null), listBoxElementRef = react.useRef(null), listFocusedRef = react.useRef(!1), valueRef = react.useRef(value), valuePropRef = react.useRef(valueProp), [popoverMouseWithin, setPopoverMouseWithin] = react.useState(!1);
5079
- let t11, t12;
5080
- $[36] !== inputElement ? (t11 = () => inputElement, t12 = [inputElement], $[36] = inputElement, $[37] = t11, $[38] = t12) : (t11 = $[37], t12 = $[38]), react.useImperativeHandle(forwardedRef, t11, t12);
5081
- const listBoxId = `${id}-listbox`, options = Array.isArray(optionsProp) ? optionsProp : EMPTY_ARRAY, padding = useArrayProp(paddingProp);
5082
- let t13, t14;
5083
- $[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;
5084
- const currentOption = t13;
5085
- let t15, t16;
5086
- if ($[42] !== query || $[43] !== filterOption || $[44] !== options) {
5087
- let t172;
5088
- $[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;
5089
- } else
5090
- t16 = $[45];
5091
- t15 = t16;
5092
- const filteredOptions = t15, filteredOptionsLen = filteredOptions.length, activeItemId = activeValue ? `${id}-option-${activeValue}` : void 0, expanded = query !== null && loading || focused && query !== null;
5093
- let t17;
5094
- $[49] !== popoverMouseWithin || $[50] !== relatedElements || $[51] !== rootElement || $[52] !== resultsPopoverElement || $[53] !== onQueryChange || $[54] !== onBlur ? (t17 = (event) => {
5064
+ } = state, defaultRenderOption = react.useCallback(({
5065
+ value: value_0
5066
+ }) => /* @__PURE__ */ jsxRuntime.jsx(Card, { "data-as": "button", padding: paddingProp, radius: 2, tone: "inherit", children: /* @__PURE__ */ jsxRuntime.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 = react.useRef(null), resultsPopoverElementRef = react.useRef(null), inputElementRef = react.useRef(null), listBoxElementRef = react.useRef(null), listFocusedRef = react.useRef(!1), valueRef = react.useRef(value), valuePropRef = react.useRef(valueProp), popoverMouseWithinRef = react.useRef(!1);
5067
+ react.useImperativeHandle(forwardedRef, () => inputElementRef.current);
5068
+ const listBoxId = `${id}-listbox`, options = Array.isArray(optionsProp) ? optionsProp : EMPTY_ARRAY, padding = useArrayProp(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) => {
5095
5069
  setTimeout(() => {
5096
- if (popoverMouseWithin)
5070
+ if (popoverMouseWithinRef.current)
5097
5071
  return;
5098
- const elements = (relatedElements || []).concat(rootElement ? [rootElement] : [], resultsPopoverElement ? [resultsPopoverElement] : []);
5072
+ const elements = (relatedElements || []).concat(rootElementRef.current ? [rootElementRef.current] : [], resultsPopoverElementRef.current ? [resultsPopoverElementRef.current] : []);
5099
5073
  let focusInside = !1;
5100
5074
  if (document.activeElement) {
5101
5075
  for (const e of elements)
@@ -5106,32 +5080,22 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = ["Control", "Shift", "Alt", "Enter", "H
5106
5080
  }
5107
5081
  focusInside === !1 && (dispatch({
5108
5082
  type: "root/blur"
5109
- }), setPopoverMouseWithin(!1), onQueryChange && onQueryChange(null), onBlur && onBlur(event));
5083
+ }), popoverMouseWithinRef.current = !1, onQueryChange && onQueryChange(null), onBlur && onBlur(event));
5110
5084
  }, 0);
5111
- }, $[49] = popoverMouseWithin, $[50] = relatedElements, $[51] = rootElement, $[52] = resultsPopoverElement, $[53] = onQueryChange, $[54] = onBlur, $[55] = t17) : t17 = $[55];
5112
- const handleRootBlur = t17;
5113
- let t18;
5114
- $[56] === Symbol.for("react.memo_cache_sentinel") ? (t18 = (event_0) => {
5085
+ }, [onBlur, onQueryChange, relatedElements]), handleRootFocus = react.useCallback((event_0) => {
5115
5086
  const listBoxElement = listBoxElementRef.current, focusedElement = event_0.target instanceof HTMLElement ? event_0.target : null, listFocused_0 = listBoxElement?.contains(focusedElement) || !1;
5116
5087
  listFocused_0 !== listFocusedRef.current && (listFocusedRef.current = listFocused_0, dispatch({
5117
5088
  type: "root/setListFocused",
5118
5089
  listFocused: listFocused_0
5119
5090
  }));
5120
- }, $[56] = t18) : t18 = $[56];
5121
- const handleRootFocus = t18;
5122
- let t19;
5123
- $[57] !== onSelect || $[58] !== onChange || $[59] !== onQueryChange || $[60] !== inputElement ? (t19 = (v) => {
5091
+ }, []), handleOptionSelect = react.useCallback((v) => {
5124
5092
  dispatch({
5125
5093
  type: "value/change",
5126
5094
  value: v
5127
- }), setPopoverMouseWithin(!1), onSelect && onSelect(v), valueRef.current = v, onChange && onChange(v), onQueryChange && onQueryChange(null), inputElement?.focus();
5128
- }, $[57] = onSelect, $[58] = onChange, $[59] = onQueryChange, $[60] = inputElement, $[61] = t19) : t19 = $[61];
5129
- const handleOptionSelect = t19;
5130
- let t20;
5131
- $[62] !== filteredOptionsLen || $[63] !== filteredOptions || $[64] !== activeValue || $[65] !== onQueryChange || $[66] !== inputElement ? (t20 = (event_1) => {
5095
+ }), popoverMouseWithinRef.current = !1, onSelect && onSelect(v), valueRef.current = v, onChange && onChange(v), onQueryChange && onQueryChange(null), inputElementRef.current?.focus();
5096
+ }, [onChange, onSelect, onQueryChange]), handleRootKeyDown = react.useCallback((event_1) => {
5132
5097
  if (event_1.key === "ArrowDown") {
5133
- if (event_1.preventDefault(), !filteredOptionsLen)
5134
- return;
5098
+ if (event_1.preventDefault(), !filteredOptionsLen) return;
5135
5099
  const activeOption = filteredOptions.find((o_0) => o_0.value === activeValue), activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1, nextActiveOption = filteredOptions[(activeIndex + 1) % filteredOptionsLen];
5136
5100
  nextActiveOption && dispatch({
5137
5101
  type: "root/setActiveValue",
@@ -5141,8 +5105,7 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = ["Control", "Shift", "Alt", "Enter", "H
5141
5105
  return;
5142
5106
  }
5143
5107
  if (event_1.key === "ArrowUp") {
5144
- if (event_1.preventDefault(), !filteredOptionsLen)
5145
- return;
5108
+ if (event_1.preventDefault(), !filteredOptionsLen) return;
5146
5109
  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];
5147
5110
  nextActiveOption_0 && dispatch({
5148
5111
  type: "root/setActiveValue",
@@ -5154,66 +5117,43 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = ["Control", "Shift", "Alt", "Enter", "H
5154
5117
  if (event_1.key === "Escape") {
5155
5118
  dispatch({
5156
5119
  type: "root/escape"
5157
- }), setPopoverMouseWithin(!1), onQueryChange && onQueryChange(null), inputElement?.focus();
5120
+ }), popoverMouseWithinRef.current = !1, onQueryChange && onQueryChange(null), inputElementRef.current?.focus();
5158
5121
  return;
5159
5122
  }
5160
5123
  const target = event_1.target, listEl = listBoxElementRef.current;
5161
5124
  if ((listEl === target || listEl?.contains(target)) && !AUTOCOMPLETE_LISTBOX_IGNORE_KEYS.includes(event_1.key)) {
5162
- inputElement?.focus();
5125
+ inputElementRef.current?.focus();
5163
5126
  return;
5164
5127
  }
5165
- }, $[62] = filteredOptionsLen, $[63] = filteredOptions, $[64] = activeValue, $[65] = onQueryChange, $[66] = inputElement, $[67] = t20) : t20 = $[67];
5166
- const handleRootKeyDown = t20;
5167
- let t21;
5168
- $[68] !== onQueryChange ? (t21 = (event_2) => {
5128
+ }, [activeValue, filteredOptions, filteredOptionsLen, onQueryChange]), handleInputChange = react.useCallback((event_2) => {
5169
5129
  const nextQuery = event_2.currentTarget.value;
5170
5130
  dispatch({
5171
5131
  type: "input/change",
5172
5132
  query: nextQuery
5173
5133
  }), onQueryChange && onQueryChange(nextQuery);
5174
- }, $[68] = onQueryChange, $[69] = t21) : t21 = $[69];
5175
- const handleInputChange = t21;
5176
- let t22;
5177
- $[70] !== value || $[71] !== renderValue || $[72] !== currentOption ? (t22 = () => {
5134
+ }, [onQueryChange]), dispatchOpen = react.useCallback(() => {
5178
5135
  dispatch({
5179
5136
  type: "root/open",
5180
5137
  query: value ? renderValue(value, currentOption) : ""
5181
5138
  });
5182
- }, $[70] = value, $[71] = renderValue, $[72] = currentOption, $[73] = t22) : t22 = $[73];
5183
- const dispatchOpen = t22;
5184
- let t23;
5185
- $[74] !== focused || $[75] !== onFocus || $[76] !== openOnFocus || $[77] !== dispatchOpen ? (t23 = (event_3) => {
5139
+ }, [currentOption, renderValue, value]), handleInputFocus = react.useCallback((event_3) => {
5186
5140
  focused || (dispatch({
5187
5141
  type: "input/focus"
5188
5142
  }), onFocus && onFocus(event_3), openOnFocus && dispatchOpen());
5189
- }, $[74] = focused, $[75] = onFocus, $[76] = openOnFocus, $[77] = dispatchOpen, $[78] = t23) : t23 = $[78];
5190
- const handleInputFocus = t23;
5191
- let t24;
5192
- $[79] === Symbol.for("react.memo_cache_sentinel") ? (t24 = () => {
5193
- setPopoverMouseWithin(!0);
5194
- }, $[79] = t24) : t24 = $[79];
5195
- const handlePopoverMouseEnter = t24;
5196
- let t25;
5197
- $[80] === Symbol.for("react.memo_cache_sentinel") ? (t25 = () => {
5198
- setPopoverMouseWithin(!1);
5199
- }, $[80] = t25) : t25 = $[80];
5200
- const handlePopoverMouseLeave = t25;
5201
- let t26;
5202
- $[81] !== onChange || $[82] !== onQueryChange || $[83] !== inputElement ? (t26 = () => {
5143
+ }, [focused, onFocus, openOnFocus, dispatchOpen]), handlePopoverMouseEnter = react.useCallback(() => {
5144
+ popoverMouseWithinRef.current = !0;
5145
+ }, []), handlePopoverMouseLeave = react.useCallback(() => {
5146
+ popoverMouseWithinRef.current = !1;
5147
+ }, []), handleClearButtonClick = react.useCallback(() => {
5203
5148
  dispatch({
5204
5149
  type: "root/clear"
5205
- }), valueRef.current = "", onChange && onChange(""), onQueryChange && onQueryChange(null), inputElement?.focus();
5206
- }, $[81] = onChange, $[82] = onQueryChange, $[83] = inputElement, $[84] = t26) : t26 = $[84];
5207
- const handleClearButtonClick = t26;
5208
- let t27;
5209
- $[85] === Symbol.for("react.memo_cache_sentinel") ? (t27 = () => {
5150
+ }), valueRef.current = "", onChange && onChange(""), onQueryChange && onQueryChange(null), inputElementRef.current?.focus();
5151
+ }, [onChange, onQueryChange]), handleClearButtonFocus = react.useCallback(() => {
5210
5152
  dispatch({
5211
5153
  type: "input/focus"
5212
5154
  });
5213
- }, $[85] = t27) : t27 = $[85];
5214
- const handleClearButtonFocus = t27;
5215
- let t28, t29;
5216
- $[86] !== valueProp ? (t28 = () => {
5155
+ }, []);
5156
+ react.useEffect(() => {
5217
5157
  if (valueProp !== valuePropRef.current) {
5218
5158
  valuePropRef.current = valueProp, valueProp !== void 0 && (dispatch({
5219
5159
  type: "value/change",
@@ -5225,19 +5165,14 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = ["Control", "Shift", "Alt", "Enter", "H
5225
5165
  type: "value/change",
5226
5166
  value: valueProp || null
5227
5167
  }));
5228
- }, t29 = [valueProp], $[86] = valueProp, $[87] = t28, $[88] = t29) : (t28 = $[87], t29 = $[88]), react.useEffect(t28, t29);
5229
- let t30, t31;
5230
- $[89] !== focused ? (t30 = () => {
5168
+ }, [valueProp]), react.useEffect(() => {
5231
5169
  !focused && valueRef.current && dispatch({
5232
5170
  type: "root/setActiveValue",
5233
5171
  value: valueRef.current
5234
5172
  });
5235
- }, t31 = [focused], $[89] = focused, $[90] = t30, $[91] = t31) : (t30 = $[90], t31 = $[91]), react.useEffect(t30, t31);
5236
- let t32, t33;
5237
- $[92] !== filteredOptions || $[93] !== activeValue ? (t32 = () => {
5173
+ }, [focused]), react.useEffect(() => {
5238
5174
  const listElement = listBoxElementRef.current;
5239
- if (!listElement)
5240
- return;
5175
+ if (!listElement) return;
5241
5176
  const activeOption_1 = filteredOptions.find((o_2) => o_2.value === activeValue);
5242
5177
  if (activeOption_1) {
5243
5178
  const activeIndex_1 = filteredOptions.indexOf(activeOption_1), activeItemElement = listElement.childNodes[activeIndex_1];
@@ -5247,123 +5182,35 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = ["Control", "Shift", "Alt", "Enter", "H
5247
5182
  focusFirstDescendant(activeItemElement);
5248
5183
  }
5249
5184
  }
5250
- }, t33 = [activeValue, filteredOptions], $[92] = filteredOptions, $[93] = activeValue, $[94] = t32, $[95] = t33) : (t32 = $[94], t33 = $[95]), react.useEffect(t32, t33);
5251
- let t34;
5252
- bb0: {
5253
- if (!loading && !disabled && value) {
5254
- let t352;
5255
- $[96] === Symbol.for("react.memo_cache_sentinel") ? (t352 = {
5185
+ }, [activeValue, filteredOptions]);
5186
+ const clearButton = react.useMemo(() => {
5187
+ if (!loading && !disabled && value)
5188
+ return {
5256
5189
  "aria-label": "Clear",
5257
5190
  onFocus: handleClearButtonFocus
5258
- }, $[96] = t352) : t352 = $[96], t34 = t352;
5259
- break bb0;
5260
- }
5261
- t34 = void 0;
5262
- }
5263
- const clearButton = t34;
5264
- let t35, t36;
5265
- if ($[97] !== padding) {
5266
- let t372;
5267
- $[99] === Symbol.for("react.memo_cache_sentinel") ? (t372 = (v_0) => v_0 === 0 ? 0 : v_0 === 1 || v_0 === 2 ? 1 : v_0 - 2, $[99] = t372) : t372 = $[99], t36 = padding.map(t372), $[97] = padding, $[98] = t36;
5268
- } else
5269
- t36 = $[98];
5270
- t35 = t36;
5271
- const openButtonBoxPadding = t35;
5272
- let t37, t38;
5273
- if ($[100] !== padding) {
5274
- let t392;
5275
- $[102] === Symbol.for("react.memo_cache_sentinel") ? (t392 = (v_1) => Math.max(v_1 - 1, 0), $[102] = t392) : t392 = $[102], t38 = padding.map(t392), $[100] = padding, $[101] = t38;
5276
- } else
5277
- t38 = $[101];
5278
- t37 = t38;
5279
- const openButtonPadding = t37;
5280
- let t39;
5281
- t39 = typeof openButton == "object" ? openButton : EMPTY_RECORD;
5282
- const openButtonProps = t39;
5283
- let t40;
5284
- $[103] !== dispatchOpen || $[104] !== openButtonProps || $[105] !== inputElement ? (t40 = (event_4) => {
5285
- dispatchOpen(), openButtonProps.onClick && openButtonProps.onClick(event_4), _raf(() => inputElement?.focus());
5286
- }, $[103] = dispatchOpen, $[104] = openButtonProps, $[105] = inputElement, $[106] = t40) : t40 = $[106];
5287
- const handleOpenClick = t40;
5288
- let t41, t42;
5289
- $[107] !== disabled || $[108] !== readOnly || $[109] !== openButton || $[110] !== expanded || $[111] !== fontSize2 || $[112] !== openButtonPadding || $[113] !== openButtonProps || $[114] !== handleOpenClick || $[115] !== openButtonBoxPadding ? (t42 = !disabled && !readOnly && openButton ? /* @__PURE__ */ jsxRuntime.jsx(Box, { "aria-hidden": expanded, padding: openButtonBoxPadding, children: /* @__PURE__ */ jsxRuntime.jsx(Button, { "aria-label": "Open", disabled: expanded, fontSize: fontSize2, icon: icons.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;
5290
- const openButtonNode = t41;
5291
- let t43;
5292
- bb1: {
5293
- if (query === null) {
5294
- if (value !== null) {
5295
- let t442;
5296
- $[117] !== renderValue || $[118] !== value || $[119] !== currentOption ? (t442 = renderValue(value, currentOption), $[117] = renderValue, $[118] = value, $[119] = currentOption, $[120] = t442) : t442 = $[120], t43 = t442;
5297
- break bb1;
5298
- }
5299
- t43 = "";
5300
- break bb1;
5301
- }
5302
- t43 = query;
5303
- }
5304
- const inputValue = t43, t44 = loading && AnimatedSpinnerIcon, t45 = suffix || openButtonNode;
5305
- let t46;
5306
- $[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__ */ jsxRuntime.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];
5307
- const input = t46;
5308
- let t47;
5309
- $[143] !== listFocused || $[144] !== inputElement ? (t47 = (event_5) => {
5310
- event_5.key === "Tab" && listFocused && inputElement?.focus();
5311
- }, $[143] = listFocused, $[144] = inputElement, $[145] = t47) : t47 = $[145];
5312
- const handleListBoxKeyDown = t47;
5313
- let t48;
5314
- bb2: {
5315
- if (filteredOptions.length === 0) {
5316
- t48 = null;
5317
- break bb2;
5318
- }
5319
- let t492;
5320
- if ($[146] !== activeValue || $[147] !== currentOption || $[148] !== id || $[149] !== handleOptionSelect || $[150] !== renderOption || $[151] !== loading || $[152] !== listFocused || $[153] !== filteredOptions) {
5321
- let t503;
5322
- $[155] !== activeValue || $[156] !== currentOption || $[157] !== id || $[158] !== handleOptionSelect || $[159] !== renderOption || $[160] !== loading || $[161] !== listFocused ? (t503 = (option_0) => {
5323
- const active = activeValue !== null ? option_0.value === activeValue : currentOption === option_0;
5324
- 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), {
5325
- disabled: loading,
5326
- selected: active,
5327
- tabIndex: listFocused && active ? 0 : -1
5328
- }) }, option_0.value);
5329
- }, $[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;
5330
- } else
5331
- t492 = $[154];
5332
- let t502;
5333
- $[163] !== listBoxId || $[164] !== t492 ? (t502 = /* @__PURE__ */ jsxRuntime.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];
5334
- let t51;
5335
- $[166] !== handleListBoxKeyDown || $[167] !== listBox || $[168] !== t502 ? (t51 = /* @__PURE__ */ jsxRuntime.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;
5336
- }
5337
- const content = t48;
5338
- let t49;
5339
- bb3: {
5340
- if (renderPopover) {
5341
- const t503 = !expanded;
5342
- let t51;
5343
- $[170] !== content || $[171] !== t503 || $[172] !== inputElement || $[173] !== resultsPopoverElement || $[174] !== renderPopover ? (t51 = renderPopover({
5344
- content,
5345
- hidden: t503,
5346
- inputElement,
5347
- onMouseEnter: handlePopoverMouseEnter,
5348
- onMouseLeave: handlePopoverMouseLeave
5349
- }, {
5350
- current: resultsPopoverElement
5351
- }), $[170] = content, $[171] = t503, $[172] = inputElement, $[173] = resultsPopoverElement, $[174] = renderPopover, $[175] = t51) : t51 = $[175], t49 = t51;
5352
- break bb3;
5353
- }
5354
- if (filteredOptionsLen === 0) {
5355
- t49 = null;
5356
- break bb3;
5357
- }
5358
- let t502;
5359
- $[176] !== content || $[177] !== expanded || $[178] !== radius || $[179] !== inputElement || $[180] !== popover ? (t502 = /* @__PURE__ */ jsxRuntime.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;
5360
- }
5361
- const results = t49;
5362
- let t50;
5363
- return $[182] !== handleRootBlur || $[183] !== handleRootKeyDown || $[184] !== input || $[185] !== results ? (t50 = /* @__PURE__ */ jsxRuntime.jsxs(Root$9, { "data-ui": "Autocomplete", onBlur: handleRootBlur, onFocus: handleRootFocus, onKeyDown: handleRootKeyDown, ref: setRootElement, children: [
5191
+ };
5192
+ }, [disabled, handleClearButtonFocus, loading, value]), openButtonBoxPadding = react.useMemo(() => padding.map((v_0) => v_0 === 0 ? 0 : v_0 === 1 || v_0 === 2 ? 1 : v_0 - 2), [padding]), openButtonPadding = react.useMemo(() => padding.map((v_1) => Math.max(v_1 - 1, 0)), [padding]), openButtonProps = react.useMemo(() => typeof openButton == "object" ? openButton : EMPTY_RECORD, [openButton]), handleOpenClick = react.useCallback((event_4) => {
5193
+ dispatchOpen(), openButtonProps.onClick && openButtonProps.onClick(event_4), _raf(() => inputElementRef.current?.focus());
5194
+ }, [openButtonProps, dispatchOpen]), openButtonNode = react.useMemo(() => !disabled && !readOnly && openButton ? /* @__PURE__ */ jsxRuntime.jsx(Box, { "aria-hidden": expanded, padding: openButtonBoxPadding, children: /* @__PURE__ */ jsxRuntime.jsx(Button, { "aria-label": "Open", disabled: expanded, fontSize: fontSize2, icon: icons.ChevronDownIcon, mode: "bleed", padding: openButtonPadding, ...openButtonProps, onClick: handleOpenClick }) }) : void 0, [disabled, expanded, fontSize2, handleOpenClick, openButton, openButtonBoxPadding, openButtonPadding, openButtonProps, readOnly]), inputValue = react.useMemo(() => query === null ? value !== null ? renderValue(value, currentOption) : "" : query, [currentOption, query, renderValue, value]), input = /* @__PURE__ */ jsxRuntime.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 = react.useCallback((event_5) => {
5195
+ event_5.key === "Tab" && listFocused && inputElementRef.current?.focus();
5196
+ }, [listFocused]), content = 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(Stack, { as: "ul", "aria-multiselectable": !1, "data-ui": "AutoComplete__resultsList", id: listBoxId, ref: listBoxElementRef, role: "listbox", space: 1, children: filteredOptions.map((option_0) => {
5197
+ const active = activeValue !== null ? option_0.value === activeValue : currentOption === option_0;
5198
+ 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), {
5199
+ disabled: loading,
5200
+ selected: active,
5201
+ tabIndex: listFocused && active ? 0 : -1
5202
+ }) }, option_0.value);
5203
+ }) }) }), [activeValue, currentOption, filteredOptions, handleOptionSelect, handleListBoxKeyDown, id, listBox, listBoxId, listFocused, loading, renderOption]), results = react.useMemo(() => renderPopover ? renderPopover({
5204
+ content,
5205
+ hidden: !expanded,
5206
+ inputElement: inputElementRef.current,
5207
+ onMouseEnter: handlePopoverMouseEnter,
5208
+ onMouseLeave: handlePopoverMouseLeave
5209
+ }, resultsPopoverElementRef) : filteredOptionsLen === 0 ? null : /* @__PURE__ */ jsxRuntime.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]);
5210
+ return /* @__PURE__ */ jsxRuntime.jsxs(Root$9, { "data-ui": "Autocomplete", onBlur: handleRootBlur, onFocus: handleRootFocus, onKeyDown: handleRootKeyDown, ref: rootElementRef, children: [
5364
5211
  input,
5365
5212
  results
5366
- ] }), $[182] = handleRootBlur, $[183] = handleRootKeyDown, $[184] = input, $[185] = results, $[186] = t50) : t50 = $[186], t50;
5213
+ ] });
5367
5214
  });
5368
5215
  InnerAutocomplete.displayName = "ForwardRef(Autocomplete)";
5369
5216
  const Autocomplete = InnerAutocomplete, Root$8 = styledComponents.styled.ol`