@underverse-ui/underverse 2.0.30 → 2.0.31
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/api-reference.json +1 -1
- package/dist/index.cjs +71 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +71 -31
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1871,6 +1871,8 @@ interface ComboboxProps {
|
|
|
1871
1871
|
estimatedItemHeight?: number;
|
|
1872
1872
|
/** Number of extra rows rendered above and below the visible range. Default: 8 */
|
|
1873
1873
|
overscan?: number;
|
|
1874
|
+
/** Control whether the dropdown renders search UI and runs search logic. Defaults to automatic detection. */
|
|
1875
|
+
enableSearch?: boolean;
|
|
1874
1876
|
/** Use "manual" to let callers provide server-filtered options via onSearchChange. Default: "auto" */
|
|
1875
1877
|
searchMode?: "auto" | "manual";
|
|
1876
1878
|
/** Called whenever the search query changes. Required for manual/server search. */
|
|
@@ -1940,6 +1942,8 @@ interface MultiComboboxProps {
|
|
|
1940
1942
|
estimatedItemHeight?: number;
|
|
1941
1943
|
/** Number of extra rows rendered above and below the visible range. Default: 8 */
|
|
1942
1944
|
overscan?: number;
|
|
1945
|
+
/** Control whether the dropdown renders search UI and runs search logic. Defaults to automatic detection. */
|
|
1946
|
+
enableSearch?: boolean;
|
|
1943
1947
|
/** Use "manual" to let callers provide server-filtered options via onSearchChange. Default: "auto" */
|
|
1944
1948
|
searchMode?: "auto" | "manual";
|
|
1945
1949
|
/** Called whenever the search query changes. Required for manual/server search. */
|
|
@@ -2193,8 +2197,8 @@ interface CategoryTreeSelectBaseProps {
|
|
|
2193
2197
|
/** Called whenever expand/collapse changes the expanded branch ids. */
|
|
2194
2198
|
onExpandedChange?: (expandedIds: number[]) => void;
|
|
2195
2199
|
/**
|
|
2196
|
-
*
|
|
2197
|
-
*
|
|
2200
|
+
* Control whether search UI and search logic are enabled.
|
|
2201
|
+
* Defaults to automatic detection from category count and search-related props.
|
|
2198
2202
|
*/
|
|
2199
2203
|
enableSearch?: boolean;
|
|
2200
2204
|
/** Replace built-in labels for localization or custom wording. */
|
package/dist/index.d.ts
CHANGED
|
@@ -1871,6 +1871,8 @@ interface ComboboxProps {
|
|
|
1871
1871
|
estimatedItemHeight?: number;
|
|
1872
1872
|
/** Number of extra rows rendered above and below the visible range. Default: 8 */
|
|
1873
1873
|
overscan?: number;
|
|
1874
|
+
/** Control whether the dropdown renders search UI and runs search logic. Defaults to automatic detection. */
|
|
1875
|
+
enableSearch?: boolean;
|
|
1874
1876
|
/** Use "manual" to let callers provide server-filtered options via onSearchChange. Default: "auto" */
|
|
1875
1877
|
searchMode?: "auto" | "manual";
|
|
1876
1878
|
/** Called whenever the search query changes. Required for manual/server search. */
|
|
@@ -1940,6 +1942,8 @@ interface MultiComboboxProps {
|
|
|
1940
1942
|
estimatedItemHeight?: number;
|
|
1941
1943
|
/** Number of extra rows rendered above and below the visible range. Default: 8 */
|
|
1942
1944
|
overscan?: number;
|
|
1945
|
+
/** Control whether the dropdown renders search UI and runs search logic. Defaults to automatic detection. */
|
|
1946
|
+
enableSearch?: boolean;
|
|
1943
1947
|
/** Use "manual" to let callers provide server-filtered options via onSearchChange. Default: "auto" */
|
|
1944
1948
|
searchMode?: "auto" | "manual";
|
|
1945
1949
|
/** Called whenever the search query changes. Required for manual/server search. */
|
|
@@ -2193,8 +2197,8 @@ interface CategoryTreeSelectBaseProps {
|
|
|
2193
2197
|
/** Called whenever expand/collapse changes the expanded branch ids. */
|
|
2194
2198
|
onExpandedChange?: (expandedIds: number[]) => void;
|
|
2195
2199
|
/**
|
|
2196
|
-
*
|
|
2197
|
-
*
|
|
2200
|
+
* Control whether search UI and search logic are enabled.
|
|
2201
|
+
* Defaults to automatic detection from category count and search-related props.
|
|
2198
2202
|
*/
|
|
2199
2203
|
enableSearch?: boolean;
|
|
2200
2204
|
/** Replace built-in labels for localization or custom wording. */
|
package/dist/index.js
CHANGED
|
@@ -4702,6 +4702,7 @@ var Combobox = ({
|
|
|
4702
4702
|
virtualized = false,
|
|
4703
4703
|
estimatedItemHeight = 44,
|
|
4704
4704
|
overscan = 8,
|
|
4705
|
+
enableSearch: enableSearchProp,
|
|
4705
4706
|
searchMode = "auto",
|
|
4706
4707
|
onSearchChange,
|
|
4707
4708
|
searchDebounceMs = 0,
|
|
@@ -4730,28 +4731,28 @@ var Combobox = ({
|
|
|
4730
4731
|
const autoId = useId4();
|
|
4731
4732
|
const resolvedId = id ? String(id) : `combobox-${autoId}`;
|
|
4732
4733
|
const labelId = label ? `${resolvedId}-label` : void 0;
|
|
4733
|
-
const
|
|
4734
|
+
const isSearchEnabled = enableSearchProp ?? (options.length > 10 || searchMode === "manual" || minSearchLength > 0 || !!onSearchChange);
|
|
4734
4735
|
const trimmedQuery = query.trim();
|
|
4735
4736
|
const queryMeetsMinimum = trimmedQuery.length >= minSearchLength;
|
|
4736
|
-
const shouldPromptForSearch = minSearchLength > 0 && !queryMeetsMinimum && (searchMode === "manual" || showSearchPromptWhenEmptyQuery);
|
|
4737
|
+
const shouldPromptForSearch = isSearchEnabled && minSearchLength > 0 && !queryMeetsMinimum && (searchMode === "manual" || showSearchPromptWhenEmptyQuery);
|
|
4737
4738
|
const filteredOptions = React19.useMemo(
|
|
4738
4739
|
() => {
|
|
4739
4740
|
if (shouldPromptForSearch) return [];
|
|
4740
|
-
if (!
|
|
4741
|
+
if (!isSearchEnabled || searchMode === "manual") return options;
|
|
4741
4742
|
const normalizedQuery = trimmedQuery.toLowerCase();
|
|
4742
4743
|
if (!normalizedQuery) return options;
|
|
4743
4744
|
return options.filter((o) => getOptionLabel(o).toLowerCase().includes(normalizedQuery));
|
|
4744
4745
|
},
|
|
4745
|
-
[
|
|
4746
|
+
[isSearchEnabled, options, searchMode, shouldPromptForSearch, trimmedQuery]
|
|
4746
4747
|
);
|
|
4747
4748
|
const renderLimitedOptions = React19.useMemo(
|
|
4748
4749
|
() => {
|
|
4749
|
-
if (trimmedQuery || maxInitialOptions === void 0 || maxInitialOptions < 1) {
|
|
4750
|
+
if (!isSearchEnabled || trimmedQuery || maxInitialOptions === void 0 || maxInitialOptions < 1) {
|
|
4750
4751
|
return filteredOptions;
|
|
4751
4752
|
}
|
|
4752
4753
|
return filteredOptions.slice(0, maxInitialOptions);
|
|
4753
4754
|
},
|
|
4754
|
-
[filteredOptions, maxInitialOptions, trimmedQuery]
|
|
4755
|
+
[filteredOptions, isSearchEnabled, maxInitialOptions, trimmedQuery]
|
|
4755
4756
|
);
|
|
4756
4757
|
const canVirtualize = virtualized && !groupBy;
|
|
4757
4758
|
const optionVirtualizer = useVirtualizer({
|
|
@@ -4812,7 +4813,7 @@ var Combobox = ({
|
|
|
4812
4813
|
setQuery("");
|
|
4813
4814
|
setActiveIndex(null);
|
|
4814
4815
|
scrollVirtualListToStart();
|
|
4815
|
-
} else if (
|
|
4816
|
+
} else if (isSearchEnabled) {
|
|
4816
4817
|
const triggerWindow = triggerRef.current?.ownerDocument.defaultView;
|
|
4817
4818
|
if (!triggerWindow) return void 0;
|
|
4818
4819
|
const timeoutId = triggerWindow.setTimeout(() => {
|
|
@@ -4821,14 +4822,14 @@ var Combobox = ({
|
|
|
4821
4822
|
return () => triggerWindow.clearTimeout(timeoutId);
|
|
4822
4823
|
}
|
|
4823
4824
|
return void 0;
|
|
4824
|
-
}, [
|
|
4825
|
+
}, [isSearchEnabled, open, scrollVirtualListToStart]);
|
|
4825
4826
|
React19.useEffect(() => {
|
|
4826
|
-
if (!onSearchChange) return void 0;
|
|
4827
|
+
if (!isSearchEnabled || !onSearchChange) return void 0;
|
|
4827
4828
|
const triggerWindow = triggerRef.current?.ownerDocument.defaultView;
|
|
4828
4829
|
if (!triggerWindow) return void 0;
|
|
4829
4830
|
const timeoutId = triggerWindow.setTimeout(() => onSearchChange(query), searchDebounceMs);
|
|
4830
4831
|
return () => triggerWindow.clearTimeout(timeoutId);
|
|
4831
|
-
}, [onSearchChange, query, searchDebounceMs]);
|
|
4832
|
+
}, [isSearchEnabled, onSearchChange, query, searchDebounceMs]);
|
|
4832
4833
|
React19.useEffect(() => {
|
|
4833
4834
|
if (process.env.NODE_ENV !== "production" && options.length > 300 && !virtualized && searchMode !== "manual" && maxInitialOptions === void 0) {
|
|
4834
4835
|
console.warn(
|
|
@@ -4964,7 +4965,7 @@ var Combobox = ({
|
|
|
4964
4965
|
style: usePortal ? { maxHeight: "var(--underverse-popover-available-height)" } : void 0,
|
|
4965
4966
|
className: cn("w-full overflow-hidden", usePortal && "flex min-h-0 flex-col", getPanelBorderRadiusClass(resolvedBorderMode)),
|
|
4966
4967
|
children: [
|
|
4967
|
-
|
|
4968
|
+
isSearchEnabled && /* @__PURE__ */ jsx22("div", { className: cn("relative shrink-0 border-b border-border/30", size === "xs" ? "p-1.5" : size === "sm" ? "p-2" : size === "lg" ? "p-3" : size === "xl" ? "p-3.5" : "p-2.5"), children: /* @__PURE__ */ jsxs18("div", { className: "relative", children: [
|
|
4968
4969
|
/* @__PURE__ */ jsx22(
|
|
4969
4970
|
Search4,
|
|
4970
4971
|
{
|
|
@@ -5120,11 +5121,24 @@ var Combobox = ({
|
|
|
5120
5121
|
"aria-invalid": !!effectiveError,
|
|
5121
5122
|
id: resolvedId,
|
|
5122
5123
|
"aria-labelledby": labelId,
|
|
5124
|
+
"aria-activedescendant": activeIndex !== null ? `${resolvedId}-item-${activeIndex}` : void 0,
|
|
5123
5125
|
onKeyDown: (e) => {
|
|
5124
5126
|
if (disabled) return;
|
|
5125
|
-
if (e.key === "ArrowDown" || e.key === "Enter" || e.key === " ") {
|
|
5127
|
+
if (!open && (e.key === "ArrowDown" || e.key === "Enter" || e.key === " ")) {
|
|
5126
5128
|
e.preventDefault();
|
|
5127
5129
|
setOpen(true);
|
|
5130
|
+
if (!isSearchEnabled && e.key === "ArrowDown") moveActiveIndex(1);
|
|
5131
|
+
} else if (open && !isSearchEnabled && e.key === "ArrowDown") {
|
|
5132
|
+
e.preventDefault();
|
|
5133
|
+
moveActiveIndex(1);
|
|
5134
|
+
} else if (open && !isSearchEnabled && e.key === "ArrowUp") {
|
|
5135
|
+
e.preventDefault();
|
|
5136
|
+
moveActiveIndex(-1);
|
|
5137
|
+
} else if (open && !isSearchEnabled && e.key === "Enter") {
|
|
5138
|
+
e.preventDefault();
|
|
5139
|
+
if (activeIndex !== null && renderLimitedOptions[activeIndex] && !getOptionDisabled(renderLimitedOptions[activeIndex])) {
|
|
5140
|
+
handleSelect(renderLimitedOptions[activeIndex]);
|
|
5141
|
+
}
|
|
5128
5142
|
} else if (e.key === "Escape") {
|
|
5129
5143
|
e.preventDefault();
|
|
5130
5144
|
setOpen(false);
|
|
@@ -15054,6 +15068,7 @@ var MultiCombobox = ({
|
|
|
15054
15068
|
virtualized = false,
|
|
15055
15069
|
estimatedItemHeight = 44,
|
|
15056
15070
|
overscan = 8,
|
|
15071
|
+
enableSearch: enableSearchProp,
|
|
15057
15072
|
searchMode = "auto",
|
|
15058
15073
|
onSearchChange,
|
|
15059
15074
|
searchDebounceMs = 0,
|
|
@@ -15086,25 +15101,25 @@ var MultiCombobox = ({
|
|
|
15086
15101
|
),
|
|
15087
15102
|
[options]
|
|
15088
15103
|
);
|
|
15089
|
-
const
|
|
15104
|
+
const isSearchEnabled = enableSearchProp ?? (normalizedOptions.length > 10 || searchMode === "manual" || minSearchLength > 0 || !!onSearchChange);
|
|
15090
15105
|
const trimmedQuery = query.trim();
|
|
15091
15106
|
const queryMeetsMinimum = trimmedQuery.length >= minSearchLength;
|
|
15092
|
-
const shouldPromptForSearch = minSearchLength > 0 && !queryMeetsMinimum && (searchMode === "manual" || showSearchPromptWhenEmptyQuery);
|
|
15107
|
+
const shouldPromptForSearch = isSearchEnabled && minSearchLength > 0 && !queryMeetsMinimum && (searchMode === "manual" || showSearchPromptWhenEmptyQuery);
|
|
15093
15108
|
const filtered = React35.useMemo(() => {
|
|
15094
15109
|
if (shouldPromptForSearch) return [];
|
|
15095
|
-
if (!
|
|
15110
|
+
if (!isSearchEnabled || searchMode === "manual") return normalizedOptions;
|
|
15096
15111
|
const normalizedQuery = trimmedQuery.toLowerCase();
|
|
15097
15112
|
if (!normalizedQuery) return normalizedOptions;
|
|
15098
15113
|
return normalizedOptions.filter(
|
|
15099
15114
|
(opt) => opt.label.toLowerCase().includes(normalizedQuery) || opt.description?.toLowerCase().includes(normalizedQuery)
|
|
15100
15115
|
);
|
|
15101
|
-
}, [
|
|
15116
|
+
}, [isSearchEnabled, normalizedOptions, searchMode, shouldPromptForSearch, trimmedQuery]);
|
|
15102
15117
|
const renderLimitedOptions = React35.useMemo(() => {
|
|
15103
|
-
if (trimmedQuery || maxInitialOptions === void 0 || maxInitialOptions < 1) {
|
|
15118
|
+
if (!isSearchEnabled || trimmedQuery || maxInitialOptions === void 0 || maxInitialOptions < 1) {
|
|
15104
15119
|
return filtered;
|
|
15105
15120
|
}
|
|
15106
15121
|
return filtered.slice(0, maxInitialOptions);
|
|
15107
|
-
}, [filtered, maxInitialOptions, trimmedQuery]);
|
|
15122
|
+
}, [filtered, isSearchEnabled, maxInitialOptions, trimmedQuery]);
|
|
15108
15123
|
const canVirtualize = virtualized && !groupBy;
|
|
15109
15124
|
const optionVirtualizer = useVirtualizer2({
|
|
15110
15125
|
count: canVirtualize ? renderLimitedOptions.length : 0,
|
|
@@ -15148,24 +15163,32 @@ var MultiCombobox = ({
|
|
|
15148
15163
|
onChange(value.filter((v) => v !== val));
|
|
15149
15164
|
};
|
|
15150
15165
|
const handleKeyDown = (e) => {
|
|
15151
|
-
if (!open) setOpen(true);
|
|
15152
15166
|
if (e.key === "ArrowDown") {
|
|
15153
15167
|
e.preventDefault();
|
|
15168
|
+
if (!open) setOpen(true);
|
|
15154
15169
|
if (renderLimitedOptions.length === 0) return;
|
|
15155
15170
|
const next = activeIndex === null ? 0 : (activeIndex + 1) % renderLimitedOptions.length;
|
|
15156
15171
|
setActiveIndex(next);
|
|
15157
15172
|
scrollVirtualListToIndex(next);
|
|
15158
15173
|
} else if (e.key === "ArrowUp") {
|
|
15159
15174
|
e.preventDefault();
|
|
15175
|
+
if (!open) setOpen(true);
|
|
15160
15176
|
if (renderLimitedOptions.length === 0) return;
|
|
15161
15177
|
const next = activeIndex === null ? renderLimitedOptions.length - 1 : (activeIndex - 1 + renderLimitedOptions.length) % renderLimitedOptions.length;
|
|
15162
15178
|
setActiveIndex(next);
|
|
15163
15179
|
scrollVirtualListToIndex(next);
|
|
15164
15180
|
} else if (e.key === "Enter") {
|
|
15165
15181
|
e.preventDefault();
|
|
15182
|
+
if (!open) {
|
|
15183
|
+
setOpen(true);
|
|
15184
|
+
return;
|
|
15185
|
+
}
|
|
15166
15186
|
if (activeIndex !== null && renderLimitedOptions[activeIndex]) {
|
|
15167
15187
|
toggleSelect(renderLimitedOptions[activeIndex].value);
|
|
15168
15188
|
}
|
|
15189
|
+
} else if (e.key === " " && !open) {
|
|
15190
|
+
e.preventDefault();
|
|
15191
|
+
setOpen(true);
|
|
15169
15192
|
} else if (e.key === "Escape") {
|
|
15170
15193
|
e.preventDefault();
|
|
15171
15194
|
setOpen(false);
|
|
@@ -15181,7 +15204,7 @@ var MultiCombobox = ({
|
|
|
15181
15204
|
}
|
|
15182
15205
|
}, [disabled, required, value.length]);
|
|
15183
15206
|
React35.useEffect(() => {
|
|
15184
|
-
if (open &&
|
|
15207
|
+
if (open && isSearchEnabled) {
|
|
15185
15208
|
setTimeout(() => {
|
|
15186
15209
|
inputRef.current?.focus();
|
|
15187
15210
|
}, 100);
|
|
@@ -15190,12 +15213,12 @@ var MultiCombobox = ({
|
|
|
15190
15213
|
setActiveIndex(null);
|
|
15191
15214
|
scrollVirtualListToStart();
|
|
15192
15215
|
}
|
|
15193
|
-
}, [
|
|
15216
|
+
}, [isSearchEnabled, open, scrollVirtualListToStart]);
|
|
15194
15217
|
React35.useEffect(() => {
|
|
15195
|
-
if (!onSearchChange) return void 0;
|
|
15218
|
+
if (!isSearchEnabled || !onSearchChange) return void 0;
|
|
15196
15219
|
const timeoutId = window.setTimeout(() => onSearchChange(query), searchDebounceMs);
|
|
15197
15220
|
return () => window.clearTimeout(timeoutId);
|
|
15198
|
-
}, [onSearchChange, query, searchDebounceMs]);
|
|
15221
|
+
}, [isSearchEnabled, onSearchChange, query, searchDebounceMs]);
|
|
15199
15222
|
React35.useEffect(() => {
|
|
15200
15223
|
if (process.env.NODE_ENV !== "production" && normalizedOptions.length > 300 && !virtualized && searchMode !== "manual" && maxInitialOptions === void 0) {
|
|
15201
15224
|
console.warn(
|
|
@@ -15270,6 +15293,10 @@ var MultiCombobox = ({
|
|
|
15270
15293
|
return /* @__PURE__ */ jsx39(
|
|
15271
15294
|
"li",
|
|
15272
15295
|
{
|
|
15296
|
+
id: `${resolvedId}-option-${index}`,
|
|
15297
|
+
role: "option",
|
|
15298
|
+
"aria-selected": isSelected,
|
|
15299
|
+
"aria-disabled": isDisabled,
|
|
15273
15300
|
ref: (node) => {
|
|
15274
15301
|
measureRef?.(node);
|
|
15275
15302
|
listRef.current[index] = node;
|
|
@@ -15281,7 +15308,7 @@ var MultiCombobox = ({
|
|
|
15281
15308
|
e.preventDefault();
|
|
15282
15309
|
e.stopPropagation();
|
|
15283
15310
|
if (!isDisabled) toggleSelect(item.value);
|
|
15284
|
-
inputRef.current?.focus();
|
|
15311
|
+
(isSearchEnabled ? inputRef.current : triggerRef.current)?.focus();
|
|
15285
15312
|
},
|
|
15286
15313
|
children: /* @__PURE__ */ jsx39("div", { className: cn("dropdown-item", isDisabled && "opacity-50 cursor-not-allowed pointer-events-none"), children: renderOption(item, isSelected) })
|
|
15287
15314
|
},
|
|
@@ -15291,6 +15318,10 @@ var MultiCombobox = ({
|
|
|
15291
15318
|
return /* @__PURE__ */ jsx39(
|
|
15292
15319
|
"li",
|
|
15293
15320
|
{
|
|
15321
|
+
id: `${resolvedId}-option-${index}`,
|
|
15322
|
+
role: "option",
|
|
15323
|
+
"aria-selected": isSelected,
|
|
15324
|
+
"aria-disabled": isDisabled,
|
|
15294
15325
|
ref: (node) => {
|
|
15295
15326
|
measureRef?.(node);
|
|
15296
15327
|
listRef.current[index] = node;
|
|
@@ -15302,7 +15333,7 @@ var MultiCombobox = ({
|
|
|
15302
15333
|
e.preventDefault();
|
|
15303
15334
|
e.stopPropagation();
|
|
15304
15335
|
if (!isDisabled) toggleSelect(item.value);
|
|
15305
|
-
inputRef.current?.focus();
|
|
15336
|
+
(isSearchEnabled ? inputRef.current : triggerRef.current)?.focus();
|
|
15306
15337
|
},
|
|
15307
15338
|
children: /* @__PURE__ */ jsxs32(
|
|
15308
15339
|
"div",
|
|
@@ -15358,7 +15389,7 @@ var MultiCombobox = ({
|
|
|
15358
15389
|
}
|
|
15359
15390
|
)
|
|
15360
15391
|
] }),
|
|
15361
|
-
|
|
15392
|
+
isSearchEnabled && /* @__PURE__ */ jsxs32("div", { className: "relative border-b border-border/40", children: [
|
|
15362
15393
|
/* @__PURE__ */ jsx39(Search5, { className: cn("absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground", sizeStyles7[size].icon) }),
|
|
15363
15394
|
/* @__PURE__ */ jsx39(
|
|
15364
15395
|
"input",
|
|
@@ -15470,6 +15501,8 @@ var MultiCombobox = ({
|
|
|
15470
15501
|
"aria-controls": listboxId,
|
|
15471
15502
|
"aria-required": required,
|
|
15472
15503
|
"aria-invalid": !!effectiveError,
|
|
15504
|
+
"aria-activedescendant": activeIndex !== null ? `${resolvedId}-option-${activeIndex}` : void 0,
|
|
15505
|
+
onKeyDown: !isSearchEnabled ? handleKeyDown : void 0,
|
|
15473
15506
|
className: cn(
|
|
15474
15507
|
"group flex w-full items-center gap-2 transition-all duration-200",
|
|
15475
15508
|
formControlFixedClass,
|
|
@@ -15539,7 +15572,13 @@ var MultiCombobox = ({
|
|
|
15539
15572
|
e.stopPropagation();
|
|
15540
15573
|
handleClearAll();
|
|
15541
15574
|
},
|
|
15542
|
-
onKeyDown: (e) =>
|
|
15575
|
+
onKeyDown: (e) => {
|
|
15576
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
15577
|
+
e.preventDefault();
|
|
15578
|
+
e.stopPropagation();
|
|
15579
|
+
handleClearAll();
|
|
15580
|
+
}
|
|
15581
|
+
},
|
|
15543
15582
|
className: "opacity-0 group-hover:opacity-100 transition-all duration-200 p-1 rounded-lg hover:bg-destructive/10 text-muted-foreground hover:text-destructive",
|
|
15544
15583
|
children: /* @__PURE__ */ jsx39(X12, { className: "h-3.5 w-3.5" })
|
|
15545
15584
|
}
|
|
@@ -17170,7 +17209,7 @@ function CategoryTreeSelect(props) {
|
|
|
17170
17209
|
const trimmedQuery = useMemo18(() => query.trim(), [query]);
|
|
17171
17210
|
const normalizedQuery = useMemo18(() => trimmedQuery.toLowerCase(), [trimmedQuery]);
|
|
17172
17211
|
const queryMeetsMinimum = trimmedQuery.length >= minSearchLength;
|
|
17173
|
-
const shouldPromptForSearch = minSearchLength > 0 && !queryMeetsMinimum && (searchMode === "manual" || showSearchPromptWhenEmptyQuery);
|
|
17212
|
+
const shouldPromptForSearch = isSearchEnabled && minSearchLength > 0 && !queryMeetsMinimum && (searchMode === "manual" || showSearchPromptWhenEmptyQuery);
|
|
17174
17213
|
const isSearchMode = isSearchEnabled && normalizedQuery.length > 0;
|
|
17175
17214
|
const shouldAutoExpandSearchResults = searchMode === "auto" && isSearchMode;
|
|
17176
17215
|
const effectiveExpandedNodes = useMemo18(() => getExpandedNodesState(expandedIds, expandedNodes), [expandedIds, expandedNodes]);
|
|
@@ -17214,12 +17253,12 @@ function CategoryTreeSelect(props) {
|
|
|
17214
17253
|
return visible;
|
|
17215
17254
|
}, [byId, categories, childrenMap, isSearchMode, normalizedQuery, searchMode, shouldPromptForSearch]);
|
|
17216
17255
|
useEffect20(() => {
|
|
17217
|
-
if (!onSearchChange) return;
|
|
17256
|
+
if (!isSearchEnabled || !onSearchChange) return;
|
|
17218
17257
|
const timeoutId = window.setTimeout(() => {
|
|
17219
17258
|
onSearchChange(trimmedQuery);
|
|
17220
17259
|
}, Math.max(0, searchDebounceMs));
|
|
17221
17260
|
return () => window.clearTimeout(timeoutId);
|
|
17222
|
-
}, [onSearchChange, searchDebounceMs, trimmedQuery]);
|
|
17261
|
+
}, [isSearchEnabled, onSearchChange, searchDebounceMs, trimmedQuery]);
|
|
17223
17262
|
useEffect20(() => {
|
|
17224
17263
|
if (!isOpen) return;
|
|
17225
17264
|
if (!isSearchEnabled) return;
|
|
@@ -17302,7 +17341,7 @@ function CategoryTreeSelect(props) {
|
|
|
17302
17341
|
const flattenedRows = useMemo18(() => {
|
|
17303
17342
|
if (shouldPromptForSearch) return [];
|
|
17304
17343
|
const rows = flattenVisibleCategories(effectiveParentCategories, effectiveChildrenMap, effectiveExpandedNodes, shouldAutoExpandSearchResults);
|
|
17305
|
-
if (trimmedQuery || maxInitialOptions === void 0 || maxInitialOptions < 1) {
|
|
17344
|
+
if (!isSearchEnabled || trimmedQuery || maxInitialOptions === void 0 || maxInitialOptions < 1) {
|
|
17306
17345
|
return rows;
|
|
17307
17346
|
}
|
|
17308
17347
|
const limitedRows = rows.slice(0, maxInitialOptions);
|
|
@@ -17330,6 +17369,7 @@ function CategoryTreeSelect(props) {
|
|
|
17330
17369
|
effectiveExpandedNodes,
|
|
17331
17370
|
effectiveParentCategories,
|
|
17332
17371
|
expandToId,
|
|
17372
|
+
isSearchEnabled,
|
|
17333
17373
|
maxInitialOptions,
|
|
17334
17374
|
selectedIds,
|
|
17335
17375
|
shouldAutoExpandSearchResults,
|