@rufous/ui 0.2.101 → 0.2.102
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/main.cjs +48 -34
- package/dist/main.d.cts +25 -5
- package/dist/main.d.ts +25 -5
- package/dist/main.js +48 -34
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -2226,10 +2226,13 @@ function AutocompleteInner(props, _ref) {
|
|
|
2226
2226
|
onInputChange,
|
|
2227
2227
|
getOptionLabel = defaultGetLabel,
|
|
2228
2228
|
isOptionEqualToValue,
|
|
2229
|
+
getOptionSelected,
|
|
2229
2230
|
groupBy,
|
|
2230
2231
|
filterOptions,
|
|
2231
2232
|
renderOption,
|
|
2233
|
+
renderTags,
|
|
2232
2234
|
getOptionDisabled,
|
|
2235
|
+
filterSelectedOptions = false,
|
|
2233
2236
|
multiple = false,
|
|
2234
2237
|
freeSolo = false,
|
|
2235
2238
|
clearable = true,
|
|
@@ -2295,14 +2298,24 @@ function AutocompleteInner(props, _ref) {
|
|
|
2295
2298
|
const activeInput = controlledInput !== void 0 ? controlledInput : inputStr;
|
|
2296
2299
|
const selectedValues = multiple ? Array.isArray(value) ? value : [] : value != null ? [value] : [];
|
|
2297
2300
|
const isEqual = (0, import_react19.useCallback)(
|
|
2298
|
-
(a, b) =>
|
|
2299
|
-
|
|
2301
|
+
(a, b) => {
|
|
2302
|
+
if (isOptionEqualToValue) return isOptionEqualToValue(a, b);
|
|
2303
|
+
if (getOptionSelected) return getOptionSelected(a, b);
|
|
2304
|
+
return defaultIsEqual(a, b);
|
|
2305
|
+
},
|
|
2306
|
+
[isOptionEqualToValue, getOptionSelected]
|
|
2300
2307
|
);
|
|
2301
2308
|
const isSelected = (0, import_react19.useCallback)(
|
|
2302
2309
|
(opt) => selectedValues.some((v) => isEqual(opt, v)),
|
|
2303
2310
|
[selectedValues, isEqual]
|
|
2304
2311
|
);
|
|
2305
|
-
const filtered =
|
|
2312
|
+
const filtered = (() => {
|
|
2313
|
+
let opts = filterOptions ? filterOptions(options, activeInput) : defaultFilter(options, filterQuery, getOptionLabel);
|
|
2314
|
+
if (filterSelectedOptions && multiple) {
|
|
2315
|
+
opts = opts.filter((opt) => !isSelected(opt));
|
|
2316
|
+
}
|
|
2317
|
+
return opts;
|
|
2318
|
+
})();
|
|
2306
2319
|
const flatEntries = [];
|
|
2307
2320
|
if (groupBy) {
|
|
2308
2321
|
const groups = {};
|
|
@@ -2339,7 +2352,7 @@ function AutocompleteInner(props, _ref) {
|
|
|
2339
2352
|
onClose?.();
|
|
2340
2353
|
if (!justSelected && !freeSolo && !multiple && value == null) {
|
|
2341
2354
|
setInputStr("");
|
|
2342
|
-
onInputChange?.("");
|
|
2355
|
+
onInputChange?.(null, "");
|
|
2343
2356
|
}
|
|
2344
2357
|
}, [freeSolo, multiple, value, onInputChange, onClose]);
|
|
2345
2358
|
(0, import_react19.useEffect)(() => {
|
|
@@ -2376,13 +2389,13 @@ function AutocompleteInner(props, _ref) {
|
|
|
2376
2389
|
onChange?.(event, next, already ? "removeOption" : "selectOption");
|
|
2377
2390
|
setInputStr("");
|
|
2378
2391
|
setFilterQuery("");
|
|
2379
|
-
onInputChange?.("");
|
|
2392
|
+
onInputChange?.(event, "");
|
|
2380
2393
|
inputRef.current?.focus();
|
|
2381
2394
|
} else {
|
|
2382
2395
|
onChange?.(event, opt, "selectOption");
|
|
2383
2396
|
setInputStr(getOptionLabel(opt));
|
|
2384
2397
|
setFilterQuery("");
|
|
2385
|
-
onInputChange?.(getOptionLabel(opt));
|
|
2398
|
+
onInputChange?.(event, getOptionLabel(opt));
|
|
2386
2399
|
closePopup(true);
|
|
2387
2400
|
}
|
|
2388
2401
|
setFocusedIdx(-1);
|
|
@@ -2392,7 +2405,7 @@ function AutocompleteInner(props, _ref) {
|
|
|
2392
2405
|
onChange?.(e, multiple ? [] : null, "clear");
|
|
2393
2406
|
setInputStr("");
|
|
2394
2407
|
setFilterQuery("");
|
|
2395
|
-
onInputChange?.("");
|
|
2408
|
+
onInputChange?.(e, "");
|
|
2396
2409
|
inputRef.current?.focus();
|
|
2397
2410
|
};
|
|
2398
2411
|
const removeTag = (opt, e) => {
|
|
@@ -2404,7 +2417,7 @@ function AutocompleteInner(props, _ref) {
|
|
|
2404
2417
|
const v = e.target.value;
|
|
2405
2418
|
setInputStr(v);
|
|
2406
2419
|
setFilterQuery(v);
|
|
2407
|
-
onInputChange?.(v);
|
|
2420
|
+
onInputChange?.(e, v);
|
|
2408
2421
|
if (!open) openPopup();
|
|
2409
2422
|
};
|
|
2410
2423
|
const handleKeyDown = (e) => {
|
|
@@ -2488,7 +2501,10 @@ function AutocompleteInner(props, _ref) {
|
|
|
2488
2501
|
}
|
|
2489
2502
|
}
|
|
2490
2503
|
},
|
|
2491
|
-
multiple &&
|
|
2504
|
+
multiple && (renderTags ? renderTags(selectedValues, ({ index }) => ({
|
|
2505
|
+
key: index,
|
|
2506
|
+
onDelete: (e) => removeTag(selectedValues[index], e)
|
|
2507
|
+
})) : /* @__PURE__ */ import_react19.default.createElement(import_react19.default.Fragment, null, visibleTags.map((opt, i) => /* @__PURE__ */ import_react19.default.createElement("span", { key: i, className: "rf-autocomplete__tag" }, /* @__PURE__ */ import_react19.default.createElement("span", { style: { overflow: "hidden", textOverflow: "ellipsis" } }, getOptionLabel(opt)), /* @__PURE__ */ import_react19.default.createElement(
|
|
2492
2508
|
"button",
|
|
2493
2509
|
{
|
|
2494
2510
|
type: "button",
|
|
@@ -2498,15 +2514,14 @@ function AutocompleteInner(props, _ref) {
|
|
|
2498
2514
|
tabIndex: -1
|
|
2499
2515
|
},
|
|
2500
2516
|
/* @__PURE__ */ import_react19.default.createElement(CloseSmIcon, { size: 12 })
|
|
2501
|
-
))),
|
|
2502
|
-
hiddenCount > 0 && /* @__PURE__ */ import_react19.default.createElement(
|
|
2517
|
+
))), hiddenCount > 0 && /* @__PURE__ */ import_react19.default.createElement(
|
|
2503
2518
|
Tooltip,
|
|
2504
2519
|
{
|
|
2505
2520
|
title: selectedValues.slice(limitTags).map((o) => getOptionLabel(o)).join(", "),
|
|
2506
2521
|
placement: "top"
|
|
2507
2522
|
},
|
|
2508
2523
|
/* @__PURE__ */ import_react19.default.createElement("span", { className: "rf-autocomplete__tag-more" }, "+", hiddenCount, " more")
|
|
2509
|
-
),
|
|
2524
|
+
))),
|
|
2510
2525
|
/* @__PURE__ */ import_react19.default.createElement(
|
|
2511
2526
|
"input",
|
|
2512
2527
|
{
|
|
@@ -2592,28 +2607,27 @@ function AutocompleteInner(props, _ref) {
|
|
|
2592
2607
|
const focused = focusedIdx === flatIdx;
|
|
2593
2608
|
const optDisabled = getOptionDisabled?.(option) ?? false;
|
|
2594
2609
|
const label2 = getOptionLabel(option);
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
"
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
}
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
);
|
|
2610
|
+
const liProps = {
|
|
2611
|
+
key: label2 + flatIdx,
|
|
2612
|
+
"data-idx": flatIdx,
|
|
2613
|
+
role: "option",
|
|
2614
|
+
"aria-selected": selected,
|
|
2615
|
+
"aria-disabled": optDisabled,
|
|
2616
|
+
className: [
|
|
2617
|
+
"rf-autocomplete__option",
|
|
2618
|
+
selected ? "rf-autocomplete__option--selected" : "",
|
|
2619
|
+
focused ? "rf-autocomplete__option--focused" : "",
|
|
2620
|
+
optDisabled ? "rf-autocomplete__option--disabled" : ""
|
|
2621
|
+
].filter(Boolean).join(" "),
|
|
2622
|
+
onMouseEnter: () => setFocusedIdx(flatIdx),
|
|
2623
|
+
onMouseLeave: () => setFocusedIdx(-1),
|
|
2624
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
2625
|
+
onClick: (e) => selectOption(option, e)
|
|
2626
|
+
};
|
|
2627
|
+
if (renderOption) {
|
|
2628
|
+
return renderOption(liProps, option, { selected, index: flatIdx });
|
|
2629
|
+
}
|
|
2630
|
+
return /* @__PURE__ */ import_react19.default.createElement("li", { ...liProps }, /* @__PURE__ */ import_react19.default.createElement("span", { style: { flex: 1, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, label2), /* @__PURE__ */ import_react19.default.createElement("span", { className: "rf-autocomplete__option-check" }, /* @__PURE__ */ import_react19.default.createElement(CheckIcon, null)));
|
|
2617
2631
|
}
|
|
2618
2632
|
}
|
|
2619
2633
|
var Autocomplete = import_react19.default.forwardRef(AutocompleteInner);
|
package/dist/main.d.cts
CHANGED
|
@@ -697,24 +697,44 @@ interface AutocompleteProps<T = string> {
|
|
|
697
697
|
onChange?: (event: React__default.SyntheticEvent, value: T | T[] | null, reason: 'selectOption' | 'removeOption' | 'clear' | 'freeSolo') => void;
|
|
698
698
|
/** Controlled text in the input */
|
|
699
699
|
inputValue?: string;
|
|
700
|
-
/** Called on every keystroke */
|
|
701
|
-
onInputChange?: (value: string) => void;
|
|
700
|
+
/** Called on every keystroke — receives the native event and the new input string */
|
|
701
|
+
onInputChange?: (event: React__default.SyntheticEvent | null, value: string) => void;
|
|
702
702
|
/** Return the string label for an option */
|
|
703
703
|
getOptionLabel?: (option: T) => string;
|
|
704
704
|
/** Decide equality between option and value (useful for objects) */
|
|
705
705
|
isOptionEqualToValue?: (option: T, value: T) => boolean;
|
|
706
|
+
/** MUI v4 alias for isOptionEqualToValue */
|
|
707
|
+
getOptionSelected?: (option: T, value: T) => boolean;
|
|
706
708
|
/** Group options by returning a category string */
|
|
707
709
|
groupBy?: (option: T) => string;
|
|
708
710
|
/** Custom option filter — replaces the default substring match */
|
|
709
711
|
filterOptions?: (options: T[], inputValue: string) => T[];
|
|
710
|
-
/**
|
|
711
|
-
|
|
712
|
+
/**
|
|
713
|
+
* Custom option renderer (MUI v5 style).
|
|
714
|
+
* Receives the li element props as the first argument so you can render your own <li>.
|
|
715
|
+
* `(props, option, state) => ReactNode`
|
|
716
|
+
*/
|
|
717
|
+
renderOption?: (props: React__default.HTMLAttributes<HTMLLIElement> & {
|
|
718
|
+
key: React__default.Key;
|
|
719
|
+
}, option: T, state: {
|
|
712
720
|
selected: boolean;
|
|
713
|
-
focused: boolean;
|
|
714
721
|
index: number;
|
|
715
722
|
}) => ReactNode;
|
|
723
|
+
/**
|
|
724
|
+
* Custom tag renderer in multiple mode.
|
|
725
|
+
* `(value, getTagProps) => ReactNode`
|
|
726
|
+
* getTagProps({ index }) returns { key, onDelete }.
|
|
727
|
+
*/
|
|
728
|
+
renderTags?: (value: T[], getTagProps: (params: {
|
|
729
|
+
index: number;
|
|
730
|
+
}) => {
|
|
731
|
+
key: number;
|
|
732
|
+
onDelete: (e: React__default.MouseEvent) => void;
|
|
733
|
+
}) => ReactNode;
|
|
716
734
|
/** Mark specific options as disabled */
|
|
717
735
|
getOptionDisabled?: (option: T) => boolean;
|
|
736
|
+
/** If true, already-selected options are hidden from the dropdown */
|
|
737
|
+
filterSelectedOptions?: boolean;
|
|
718
738
|
/** Allow multiple selections */
|
|
719
739
|
multiple?: boolean;
|
|
720
740
|
/** Allow values that are not in the options list */
|
package/dist/main.d.ts
CHANGED
|
@@ -697,24 +697,44 @@ interface AutocompleteProps<T = string> {
|
|
|
697
697
|
onChange?: (event: React__default.SyntheticEvent, value: T | T[] | null, reason: 'selectOption' | 'removeOption' | 'clear' | 'freeSolo') => void;
|
|
698
698
|
/** Controlled text in the input */
|
|
699
699
|
inputValue?: string;
|
|
700
|
-
/** Called on every keystroke */
|
|
701
|
-
onInputChange?: (value: string) => void;
|
|
700
|
+
/** Called on every keystroke — receives the native event and the new input string */
|
|
701
|
+
onInputChange?: (event: React__default.SyntheticEvent | null, value: string) => void;
|
|
702
702
|
/** Return the string label for an option */
|
|
703
703
|
getOptionLabel?: (option: T) => string;
|
|
704
704
|
/** Decide equality between option and value (useful for objects) */
|
|
705
705
|
isOptionEqualToValue?: (option: T, value: T) => boolean;
|
|
706
|
+
/** MUI v4 alias for isOptionEqualToValue */
|
|
707
|
+
getOptionSelected?: (option: T, value: T) => boolean;
|
|
706
708
|
/** Group options by returning a category string */
|
|
707
709
|
groupBy?: (option: T) => string;
|
|
708
710
|
/** Custom option filter — replaces the default substring match */
|
|
709
711
|
filterOptions?: (options: T[], inputValue: string) => T[];
|
|
710
|
-
/**
|
|
711
|
-
|
|
712
|
+
/**
|
|
713
|
+
* Custom option renderer (MUI v5 style).
|
|
714
|
+
* Receives the li element props as the first argument so you can render your own <li>.
|
|
715
|
+
* `(props, option, state) => ReactNode`
|
|
716
|
+
*/
|
|
717
|
+
renderOption?: (props: React__default.HTMLAttributes<HTMLLIElement> & {
|
|
718
|
+
key: React__default.Key;
|
|
719
|
+
}, option: T, state: {
|
|
712
720
|
selected: boolean;
|
|
713
|
-
focused: boolean;
|
|
714
721
|
index: number;
|
|
715
722
|
}) => ReactNode;
|
|
723
|
+
/**
|
|
724
|
+
* Custom tag renderer in multiple mode.
|
|
725
|
+
* `(value, getTagProps) => ReactNode`
|
|
726
|
+
* getTagProps({ index }) returns { key, onDelete }.
|
|
727
|
+
*/
|
|
728
|
+
renderTags?: (value: T[], getTagProps: (params: {
|
|
729
|
+
index: number;
|
|
730
|
+
}) => {
|
|
731
|
+
key: number;
|
|
732
|
+
onDelete: (e: React__default.MouseEvent) => void;
|
|
733
|
+
}) => ReactNode;
|
|
716
734
|
/** Mark specific options as disabled */
|
|
717
735
|
getOptionDisabled?: (option: T) => boolean;
|
|
736
|
+
/** If true, already-selected options are hidden from the dropdown */
|
|
737
|
+
filterSelectedOptions?: boolean;
|
|
718
738
|
/** Allow multiple selections */
|
|
719
739
|
multiple?: boolean;
|
|
720
740
|
/** Allow values that are not in the options list */
|
package/dist/main.js
CHANGED
|
@@ -2072,10 +2072,13 @@ function AutocompleteInner(props, _ref) {
|
|
|
2072
2072
|
onInputChange,
|
|
2073
2073
|
getOptionLabel = defaultGetLabel,
|
|
2074
2074
|
isOptionEqualToValue,
|
|
2075
|
+
getOptionSelected,
|
|
2075
2076
|
groupBy,
|
|
2076
2077
|
filterOptions,
|
|
2077
2078
|
renderOption,
|
|
2079
|
+
renderTags,
|
|
2078
2080
|
getOptionDisabled,
|
|
2081
|
+
filterSelectedOptions = false,
|
|
2079
2082
|
multiple = false,
|
|
2080
2083
|
freeSolo = false,
|
|
2081
2084
|
clearable = true,
|
|
@@ -2141,14 +2144,24 @@ function AutocompleteInner(props, _ref) {
|
|
|
2141
2144
|
const activeInput = controlledInput !== void 0 ? controlledInput : inputStr;
|
|
2142
2145
|
const selectedValues = multiple ? Array.isArray(value) ? value : [] : value != null ? [value] : [];
|
|
2143
2146
|
const isEqual = useCallback2(
|
|
2144
|
-
(a, b) =>
|
|
2145
|
-
|
|
2147
|
+
(a, b) => {
|
|
2148
|
+
if (isOptionEqualToValue) return isOptionEqualToValue(a, b);
|
|
2149
|
+
if (getOptionSelected) return getOptionSelected(a, b);
|
|
2150
|
+
return defaultIsEqual(a, b);
|
|
2151
|
+
},
|
|
2152
|
+
[isOptionEqualToValue, getOptionSelected]
|
|
2146
2153
|
);
|
|
2147
2154
|
const isSelected = useCallback2(
|
|
2148
2155
|
(opt) => selectedValues.some((v) => isEqual(opt, v)),
|
|
2149
2156
|
[selectedValues, isEqual]
|
|
2150
2157
|
);
|
|
2151
|
-
const filtered =
|
|
2158
|
+
const filtered = (() => {
|
|
2159
|
+
let opts = filterOptions ? filterOptions(options, activeInput) : defaultFilter(options, filterQuery, getOptionLabel);
|
|
2160
|
+
if (filterSelectedOptions && multiple) {
|
|
2161
|
+
opts = opts.filter((opt) => !isSelected(opt));
|
|
2162
|
+
}
|
|
2163
|
+
return opts;
|
|
2164
|
+
})();
|
|
2152
2165
|
const flatEntries = [];
|
|
2153
2166
|
if (groupBy) {
|
|
2154
2167
|
const groups = {};
|
|
@@ -2185,7 +2198,7 @@ function AutocompleteInner(props, _ref) {
|
|
|
2185
2198
|
onClose?.();
|
|
2186
2199
|
if (!justSelected && !freeSolo && !multiple && value == null) {
|
|
2187
2200
|
setInputStr("");
|
|
2188
|
-
onInputChange?.("");
|
|
2201
|
+
onInputChange?.(null, "");
|
|
2189
2202
|
}
|
|
2190
2203
|
}, [freeSolo, multiple, value, onInputChange, onClose]);
|
|
2191
2204
|
useEffect5(() => {
|
|
@@ -2222,13 +2235,13 @@ function AutocompleteInner(props, _ref) {
|
|
|
2222
2235
|
onChange?.(event, next, already ? "removeOption" : "selectOption");
|
|
2223
2236
|
setInputStr("");
|
|
2224
2237
|
setFilterQuery("");
|
|
2225
|
-
onInputChange?.("");
|
|
2238
|
+
onInputChange?.(event, "");
|
|
2226
2239
|
inputRef.current?.focus();
|
|
2227
2240
|
} else {
|
|
2228
2241
|
onChange?.(event, opt, "selectOption");
|
|
2229
2242
|
setInputStr(getOptionLabel(opt));
|
|
2230
2243
|
setFilterQuery("");
|
|
2231
|
-
onInputChange?.(getOptionLabel(opt));
|
|
2244
|
+
onInputChange?.(event, getOptionLabel(opt));
|
|
2232
2245
|
closePopup(true);
|
|
2233
2246
|
}
|
|
2234
2247
|
setFocusedIdx(-1);
|
|
@@ -2238,7 +2251,7 @@ function AutocompleteInner(props, _ref) {
|
|
|
2238
2251
|
onChange?.(e, multiple ? [] : null, "clear");
|
|
2239
2252
|
setInputStr("");
|
|
2240
2253
|
setFilterQuery("");
|
|
2241
|
-
onInputChange?.("");
|
|
2254
|
+
onInputChange?.(e, "");
|
|
2242
2255
|
inputRef.current?.focus();
|
|
2243
2256
|
};
|
|
2244
2257
|
const removeTag = (opt, e) => {
|
|
@@ -2250,7 +2263,7 @@ function AutocompleteInner(props, _ref) {
|
|
|
2250
2263
|
const v = e.target.value;
|
|
2251
2264
|
setInputStr(v);
|
|
2252
2265
|
setFilterQuery(v);
|
|
2253
|
-
onInputChange?.(v);
|
|
2266
|
+
onInputChange?.(e, v);
|
|
2254
2267
|
if (!open) openPopup();
|
|
2255
2268
|
};
|
|
2256
2269
|
const handleKeyDown = (e) => {
|
|
@@ -2334,7 +2347,10 @@ function AutocompleteInner(props, _ref) {
|
|
|
2334
2347
|
}
|
|
2335
2348
|
}
|
|
2336
2349
|
},
|
|
2337
|
-
multiple &&
|
|
2350
|
+
multiple && (renderTags ? renderTags(selectedValues, ({ index }) => ({
|
|
2351
|
+
key: index,
|
|
2352
|
+
onDelete: (e) => removeTag(selectedValues[index], e)
|
|
2353
|
+
})) : /* @__PURE__ */ React70.createElement(React70.Fragment, null, visibleTags.map((opt, i) => /* @__PURE__ */ React70.createElement("span", { key: i, className: "rf-autocomplete__tag" }, /* @__PURE__ */ React70.createElement("span", { style: { overflow: "hidden", textOverflow: "ellipsis" } }, getOptionLabel(opt)), /* @__PURE__ */ React70.createElement(
|
|
2338
2354
|
"button",
|
|
2339
2355
|
{
|
|
2340
2356
|
type: "button",
|
|
@@ -2344,15 +2360,14 @@ function AutocompleteInner(props, _ref) {
|
|
|
2344
2360
|
tabIndex: -1
|
|
2345
2361
|
},
|
|
2346
2362
|
/* @__PURE__ */ React70.createElement(CloseSmIcon, { size: 12 })
|
|
2347
|
-
))),
|
|
2348
|
-
hiddenCount > 0 && /* @__PURE__ */ React70.createElement(
|
|
2363
|
+
))), hiddenCount > 0 && /* @__PURE__ */ React70.createElement(
|
|
2349
2364
|
Tooltip,
|
|
2350
2365
|
{
|
|
2351
2366
|
title: selectedValues.slice(limitTags).map((o) => getOptionLabel(o)).join(", "),
|
|
2352
2367
|
placement: "top"
|
|
2353
2368
|
},
|
|
2354
2369
|
/* @__PURE__ */ React70.createElement("span", { className: "rf-autocomplete__tag-more" }, "+", hiddenCount, " more")
|
|
2355
|
-
),
|
|
2370
|
+
))),
|
|
2356
2371
|
/* @__PURE__ */ React70.createElement(
|
|
2357
2372
|
"input",
|
|
2358
2373
|
{
|
|
@@ -2438,28 +2453,27 @@ function AutocompleteInner(props, _ref) {
|
|
|
2438
2453
|
const focused = focusedIdx === flatIdx;
|
|
2439
2454
|
const optDisabled = getOptionDisabled?.(option) ?? false;
|
|
2440
2455
|
const label2 = getOptionLabel(option);
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
"
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
}
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
);
|
|
2456
|
+
const liProps = {
|
|
2457
|
+
key: label2 + flatIdx,
|
|
2458
|
+
"data-idx": flatIdx,
|
|
2459
|
+
role: "option",
|
|
2460
|
+
"aria-selected": selected,
|
|
2461
|
+
"aria-disabled": optDisabled,
|
|
2462
|
+
className: [
|
|
2463
|
+
"rf-autocomplete__option",
|
|
2464
|
+
selected ? "rf-autocomplete__option--selected" : "",
|
|
2465
|
+
focused ? "rf-autocomplete__option--focused" : "",
|
|
2466
|
+
optDisabled ? "rf-autocomplete__option--disabled" : ""
|
|
2467
|
+
].filter(Boolean).join(" "),
|
|
2468
|
+
onMouseEnter: () => setFocusedIdx(flatIdx),
|
|
2469
|
+
onMouseLeave: () => setFocusedIdx(-1),
|
|
2470
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
2471
|
+
onClick: (e) => selectOption(option, e)
|
|
2472
|
+
};
|
|
2473
|
+
if (renderOption) {
|
|
2474
|
+
return renderOption(liProps, option, { selected, index: flatIdx });
|
|
2475
|
+
}
|
|
2476
|
+
return /* @__PURE__ */ React70.createElement("li", { ...liProps }, /* @__PURE__ */ React70.createElement("span", { style: { flex: 1, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, label2), /* @__PURE__ */ React70.createElement("span", { className: "rf-autocomplete__option-check" }, /* @__PURE__ */ React70.createElement(CheckIcon, null)));
|
|
2463
2477
|
}
|
|
2464
2478
|
}
|
|
2465
2479
|
var Autocomplete = React70.forwardRef(AutocompleteInner);
|