@rufous/ui 0.2.92 → 0.2.93
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 +7 -1
- package/dist/main.js +7 -1
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -1976,6 +1976,7 @@ function AutocompleteInner(props, _ref) {
|
|
|
1976
1976
|
} = props;
|
|
1977
1977
|
const [open, setOpen] = (0, import_react18.useState)(false);
|
|
1978
1978
|
const [inputStr, setInputStr] = (0, import_react18.useState)("");
|
|
1979
|
+
const [filterQuery, setFilterQuery] = (0, import_react18.useState)("");
|
|
1979
1980
|
const [focusedIdx, setFocusedIdx] = (0, import_react18.useState)(-1);
|
|
1980
1981
|
const [popupStyle, setPopupStyle] = (0, import_react18.useState)({});
|
|
1981
1982
|
const containerRef = (0, import_react18.useRef)(null);
|
|
@@ -2023,7 +2024,7 @@ function AutocompleteInner(props, _ref) {
|
|
|
2023
2024
|
(opt) => selectedValues.some((v) => isEqual(opt, v)),
|
|
2024
2025
|
[selectedValues, isEqual]
|
|
2025
2026
|
);
|
|
2026
|
-
const filtered = filterOptions ? filterOptions(options, activeInput) : defaultFilter(options,
|
|
2027
|
+
const filtered = filterOptions ? filterOptions(options, activeInput) : defaultFilter(options, filterQuery, getOptionLabel);
|
|
2027
2028
|
const flatEntries = [];
|
|
2028
2029
|
if (groupBy) {
|
|
2029
2030
|
const groups = {};
|
|
@@ -2051,6 +2052,7 @@ function AutocompleteInner(props, _ref) {
|
|
|
2051
2052
|
calcPopupStyle();
|
|
2052
2053
|
setOpen(true);
|
|
2053
2054
|
setFocusedIdx(-1);
|
|
2055
|
+
setFilterQuery("");
|
|
2054
2056
|
onOpen?.();
|
|
2055
2057
|
}, [disabled, calcPopupStyle, onOpen]);
|
|
2056
2058
|
const closePopup = (0, import_react18.useCallback)((justSelected = false) => {
|
|
@@ -2095,11 +2097,13 @@ function AutocompleteInner(props, _ref) {
|
|
|
2095
2097
|
const next = already ? selectedValues.filter((v) => !isEqual(v, opt)) : [...selectedValues, opt];
|
|
2096
2098
|
onChange?.(event, next, already ? "removeOption" : "selectOption");
|
|
2097
2099
|
setInputStr("");
|
|
2100
|
+
setFilterQuery("");
|
|
2098
2101
|
onInputChange?.("");
|
|
2099
2102
|
inputRef.current?.focus();
|
|
2100
2103
|
} else {
|
|
2101
2104
|
onChange?.(event, opt, "selectOption");
|
|
2102
2105
|
setInputStr(getOptionLabel(opt));
|
|
2106
|
+
setFilterQuery("");
|
|
2103
2107
|
onInputChange?.(getOptionLabel(opt));
|
|
2104
2108
|
closePopup(true);
|
|
2105
2109
|
}
|
|
@@ -2109,6 +2113,7 @@ function AutocompleteInner(props, _ref) {
|
|
|
2109
2113
|
e.stopPropagation();
|
|
2110
2114
|
onChange?.(e, multiple ? [] : null, "clear");
|
|
2111
2115
|
setInputStr("");
|
|
2116
|
+
setFilterQuery("");
|
|
2112
2117
|
onInputChange?.("");
|
|
2113
2118
|
inputRef.current?.focus();
|
|
2114
2119
|
};
|
|
@@ -2120,6 +2125,7 @@ function AutocompleteInner(props, _ref) {
|
|
|
2120
2125
|
const handleInputChange = (e) => {
|
|
2121
2126
|
const v = e.target.value;
|
|
2122
2127
|
setInputStr(v);
|
|
2128
|
+
setFilterQuery(v);
|
|
2123
2129
|
onInputChange?.(v);
|
|
2124
2130
|
if (!open) openPopup();
|
|
2125
2131
|
};
|
package/dist/main.js
CHANGED
|
@@ -1815,6 +1815,7 @@ function AutocompleteInner(props, _ref) {
|
|
|
1815
1815
|
} = props;
|
|
1816
1816
|
const [open, setOpen] = useState4(false);
|
|
1817
1817
|
const [inputStr, setInputStr] = useState4("");
|
|
1818
|
+
const [filterQuery, setFilterQuery] = useState4("");
|
|
1818
1819
|
const [focusedIdx, setFocusedIdx] = useState4(-1);
|
|
1819
1820
|
const [popupStyle, setPopupStyle] = useState4({});
|
|
1820
1821
|
const containerRef = useRef3(null);
|
|
@@ -1862,7 +1863,7 @@ function AutocompleteInner(props, _ref) {
|
|
|
1862
1863
|
(opt) => selectedValues.some((v) => isEqual(opt, v)),
|
|
1863
1864
|
[selectedValues, isEqual]
|
|
1864
1865
|
);
|
|
1865
|
-
const filtered = filterOptions ? filterOptions(options, activeInput) : defaultFilter(options,
|
|
1866
|
+
const filtered = filterOptions ? filterOptions(options, activeInput) : defaultFilter(options, filterQuery, getOptionLabel);
|
|
1866
1867
|
const flatEntries = [];
|
|
1867
1868
|
if (groupBy) {
|
|
1868
1869
|
const groups = {};
|
|
@@ -1890,6 +1891,7 @@ function AutocompleteInner(props, _ref) {
|
|
|
1890
1891
|
calcPopupStyle();
|
|
1891
1892
|
setOpen(true);
|
|
1892
1893
|
setFocusedIdx(-1);
|
|
1894
|
+
setFilterQuery("");
|
|
1893
1895
|
onOpen?.();
|
|
1894
1896
|
}, [disabled, calcPopupStyle, onOpen]);
|
|
1895
1897
|
const closePopup = useCallback((justSelected = false) => {
|
|
@@ -1934,11 +1936,13 @@ function AutocompleteInner(props, _ref) {
|
|
|
1934
1936
|
const next = already ? selectedValues.filter((v) => !isEqual(v, opt)) : [...selectedValues, opt];
|
|
1935
1937
|
onChange?.(event, next, already ? "removeOption" : "selectOption");
|
|
1936
1938
|
setInputStr("");
|
|
1939
|
+
setFilterQuery("");
|
|
1937
1940
|
onInputChange?.("");
|
|
1938
1941
|
inputRef.current?.focus();
|
|
1939
1942
|
} else {
|
|
1940
1943
|
onChange?.(event, opt, "selectOption");
|
|
1941
1944
|
setInputStr(getOptionLabel(opt));
|
|
1945
|
+
setFilterQuery("");
|
|
1942
1946
|
onInputChange?.(getOptionLabel(opt));
|
|
1943
1947
|
closePopup(true);
|
|
1944
1948
|
}
|
|
@@ -1948,6 +1952,7 @@ function AutocompleteInner(props, _ref) {
|
|
|
1948
1952
|
e.stopPropagation();
|
|
1949
1953
|
onChange?.(e, multiple ? [] : null, "clear");
|
|
1950
1954
|
setInputStr("");
|
|
1955
|
+
setFilterQuery("");
|
|
1951
1956
|
onInputChange?.("");
|
|
1952
1957
|
inputRef.current?.focus();
|
|
1953
1958
|
};
|
|
@@ -1959,6 +1964,7 @@ function AutocompleteInner(props, _ref) {
|
|
|
1959
1964
|
const handleInputChange = (e) => {
|
|
1960
1965
|
const v = e.target.value;
|
|
1961
1966
|
setInputStr(v);
|
|
1967
|
+
setFilterQuery(v);
|
|
1962
1968
|
onInputChange?.(v);
|
|
1963
1969
|
if (!open) openPopup();
|
|
1964
1970
|
};
|