@seekho/ui 0.1.53 → 0.1.54
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.d.mts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +8 -3
- package/dist/index.mjs +8 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -57,10 +57,20 @@ interface AutoCompleteProps<T> {
|
|
|
57
57
|
isOptionEqualToValue?: (option: T, value: T) => boolean;
|
|
58
58
|
isLoading?: boolean;
|
|
59
59
|
renderOption?: (props: RenderOptionProps, option: T) => React.ReactNode;
|
|
60
|
+
/**
|
|
61
|
+
* Override how `options` are narrowed down for the dropdown. Defaults to a
|
|
62
|
+
* case-insensitive match of the input against `getOptionLabel`.
|
|
63
|
+
* Pass `(options) => options` when `options` already come from a server-side
|
|
64
|
+
* search, so results that don't match the label (e.g. an id or phone lookup)
|
|
65
|
+
* aren't filtered out.
|
|
66
|
+
*/
|
|
67
|
+
filterOptions?: (options: T[], state: {
|
|
68
|
+
inputValue: string;
|
|
69
|
+
}) => T[];
|
|
60
70
|
onChange: (value: T | null) => void;
|
|
61
71
|
onInputChange?: (value: string) => void;
|
|
62
72
|
}
|
|
63
|
-
declare function AutoComplete<T>({ label: _label, value, options, disabled, error, className, getOptionLabel, isOptionEqualToValue, isLoading, renderOption, onChange, onInputChange, }: AutoCompleteProps<T>): react_jsx_runtime.JSX.Element;
|
|
73
|
+
declare function AutoComplete<T>({ label: _label, value, options, disabled, error, className, getOptionLabel, isOptionEqualToValue, isLoading, renderOption, filterOptions, onChange, onInputChange, }: AutoCompleteProps<T>): react_jsx_runtime.JSX.Element;
|
|
64
74
|
|
|
65
75
|
interface BreadcrumbProps {
|
|
66
76
|
/** Current URL pathname — pass location.pathname (React Router) or router.pathname (Next.js) */
|
package/dist/index.d.ts
CHANGED
|
@@ -57,10 +57,20 @@ interface AutoCompleteProps<T> {
|
|
|
57
57
|
isOptionEqualToValue?: (option: T, value: T) => boolean;
|
|
58
58
|
isLoading?: boolean;
|
|
59
59
|
renderOption?: (props: RenderOptionProps, option: T) => React.ReactNode;
|
|
60
|
+
/**
|
|
61
|
+
* Override how `options` are narrowed down for the dropdown. Defaults to a
|
|
62
|
+
* case-insensitive match of the input against `getOptionLabel`.
|
|
63
|
+
* Pass `(options) => options` when `options` already come from a server-side
|
|
64
|
+
* search, so results that don't match the label (e.g. an id or phone lookup)
|
|
65
|
+
* aren't filtered out.
|
|
66
|
+
*/
|
|
67
|
+
filterOptions?: (options: T[], state: {
|
|
68
|
+
inputValue: string;
|
|
69
|
+
}) => T[];
|
|
60
70
|
onChange: (value: T | null) => void;
|
|
61
71
|
onInputChange?: (value: string) => void;
|
|
62
72
|
}
|
|
63
|
-
declare function AutoComplete<T>({ label: _label, value, options, disabled, error, className, getOptionLabel, isOptionEqualToValue, isLoading, renderOption, onChange, onInputChange, }: AutoCompleteProps<T>): react_jsx_runtime.JSX.Element;
|
|
73
|
+
declare function AutoComplete<T>({ label: _label, value, options, disabled, error, className, getOptionLabel, isOptionEqualToValue, isLoading, renderOption, filterOptions, onChange, onInputChange, }: AutoCompleteProps<T>): react_jsx_runtime.JSX.Element;
|
|
64
74
|
|
|
65
75
|
interface BreadcrumbProps {
|
|
66
76
|
/** Current URL pathname — pass location.pathname (React Router) or router.pathname (Next.js) */
|
package/dist/index.js
CHANGED
|
@@ -217,6 +217,12 @@ var Chip = ({
|
|
|
217
217
|
}
|
|
218
218
|
);
|
|
219
219
|
};
|
|
220
|
+
var defaultFilterOptions = (options, {
|
|
221
|
+
inputValue,
|
|
222
|
+
getOptionLabel
|
|
223
|
+
}) => options.filter(
|
|
224
|
+
(option) => getOptionLabel(option).toLowerCase().includes(inputValue.toLowerCase())
|
|
225
|
+
);
|
|
220
226
|
function AutoComplete({
|
|
221
227
|
label: _label,
|
|
222
228
|
value,
|
|
@@ -228,6 +234,7 @@ function AutoComplete({
|
|
|
228
234
|
isOptionEqualToValue,
|
|
229
235
|
isLoading = false,
|
|
230
236
|
renderOption,
|
|
237
|
+
filterOptions,
|
|
231
238
|
onChange,
|
|
232
239
|
onInputChange
|
|
233
240
|
}) {
|
|
@@ -250,9 +257,7 @@ function AutoComplete({
|
|
|
250
257
|
width: rect.width
|
|
251
258
|
});
|
|
252
259
|
};
|
|
253
|
-
const filteredOptions = options
|
|
254
|
-
(option) => getOptionLabel(option).toLowerCase().includes(inputValue.toLowerCase())
|
|
255
|
-
);
|
|
260
|
+
const filteredOptions = filterOptions ? filterOptions(options, { inputValue }) : defaultFilterOptions(options, { inputValue, getOptionLabel });
|
|
256
261
|
const handleOpen = () => {
|
|
257
262
|
const selectedIdx = filteredOptions.findIndex(
|
|
258
263
|
(opt) => value ? isOptionEqualToValue ? isOptionEqualToValue(opt, value) : getOptionLabel(opt) === getOptionLabel(value) : false
|
package/dist/index.mjs
CHANGED
|
@@ -210,6 +210,12 @@ var Chip = ({
|
|
|
210
210
|
}
|
|
211
211
|
);
|
|
212
212
|
};
|
|
213
|
+
var defaultFilterOptions = (options, {
|
|
214
|
+
inputValue,
|
|
215
|
+
getOptionLabel
|
|
216
|
+
}) => options.filter(
|
|
217
|
+
(option) => getOptionLabel(option).toLowerCase().includes(inputValue.toLowerCase())
|
|
218
|
+
);
|
|
213
219
|
function AutoComplete({
|
|
214
220
|
label: _label,
|
|
215
221
|
value,
|
|
@@ -221,6 +227,7 @@ function AutoComplete({
|
|
|
221
227
|
isOptionEqualToValue,
|
|
222
228
|
isLoading = false,
|
|
223
229
|
renderOption,
|
|
230
|
+
filterOptions,
|
|
224
231
|
onChange,
|
|
225
232
|
onInputChange
|
|
226
233
|
}) {
|
|
@@ -243,9 +250,7 @@ function AutoComplete({
|
|
|
243
250
|
width: rect.width
|
|
244
251
|
});
|
|
245
252
|
};
|
|
246
|
-
const filteredOptions = options
|
|
247
|
-
(option) => getOptionLabel(option).toLowerCase().includes(inputValue.toLowerCase())
|
|
248
|
-
);
|
|
253
|
+
const filteredOptions = filterOptions ? filterOptions(options, { inputValue }) : defaultFilterOptions(options, { inputValue, getOptionLabel });
|
|
249
254
|
const handleOpen = () => {
|
|
250
255
|
const selectedIdx = filteredOptions.findIndex(
|
|
251
256
|
(opt) => value ? isOptionEqualToValue ? isOptionEqualToValue(opt, value) : getOptionLabel(opt) === getOptionLabel(value) : false
|