@adamjanicki/ui-extended 1.1.9 → 1.2.1
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.
|
@@ -28,7 +28,7 @@ import { classNames } from "@adamjanicki/ui/functions";
|
|
|
28
28
|
var defaultRenderOption = function (option) { return (_jsx(Box, { vfx: { padding: "s" }, children: "".concat(option) })); };
|
|
29
29
|
var Autocomplete = function (props) {
|
|
30
30
|
var _a, _b;
|
|
31
|
-
var options = props.options, _c = props.renderOption, renderOption = _c === void 0 ? defaultRenderOption : _c, _d = props.filterOption, filterOption = _d === void 0 ? function () { return true; } : _d, groupBy = props.groupBy, renderGroup = props.renderGroup, noOptionsNode = props.noOptionsNode, _e = props.InputProps, InputProps = _e === void 0 ? {} : _e, _f = props.
|
|
31
|
+
var options = props.options, _c = props.renderOption, renderOption = _c === void 0 ? defaultRenderOption : _c, _d = props.filterOption, filterOption = _d === void 0 ? function () { return true; } : _d, groupBy = props.groupBy, renderGroup = props.renderGroup, noOptionsNode = props.noOptionsNode, _e = props.InputProps, InputProps = _e === void 0 ? {} : _e, _f = props.freeSolo, freeSolo = _f === void 0 ? false : _f, value = props.value, onInputChange = props.onInputChange, onSelect = props.onSelect, popoverProps = props.popoverProps, footer = props.footer, _g = props.listItemProps, listItemProps = _g === void 0 ? {} : _g, _h = props.listProps, listProps = _h === void 0 ? {} : _h, onUnselectedEnter = props.onUnselectedEnter, _j = props.closeOnFooterClick, closeOnFooterClick = _j === void 0 ? true : _j, _k = props.remainOpenOnSelectOrEnter, remainOpenOnSelectOrEnter = _k === void 0 ? false : _k, rest = __rest(props, ["options", "renderOption", "filterOption", "groupBy", "renderGroup", "noOptionsNode", "InputProps", "freeSolo", "value", "onInputChange", "onSelect", "popoverProps", "footer", "listItemProps", "listProps", "onUnselectedEnter", "closeOnFooterClick", "remainOpenOnSelectOrEnter"]);
|
|
32
32
|
var inputContainerRef = React.useRef(null);
|
|
33
33
|
var inputRef = React.useRef(null);
|
|
34
34
|
var onRef = React.useRef(null);
|
|
@@ -54,7 +54,7 @@ var Autocomplete = function (props) {
|
|
|
54
54
|
})
|
|
55
55
|
.flat();
|
|
56
56
|
}
|
|
57
|
-
if (
|
|
57
|
+
if (freeSolo && value.length > 0 && filteredOptions.length === 0) {
|
|
58
58
|
filteredOptions.push(value);
|
|
59
59
|
}
|
|
60
60
|
var focusInput = function () { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
@@ -84,9 +84,11 @@ var Autocomplete = function (props) {
|
|
|
84
84
|
var current = onRef.current;
|
|
85
85
|
if (current) {
|
|
86
86
|
// Horrible heuristic to handle links
|
|
87
|
-
// It's terrible, but
|
|
87
|
+
// It's terrible, but efficient
|
|
88
88
|
var child = current.firstChild;
|
|
89
|
-
(
|
|
89
|
+
if (child && child.nodeName === "A")
|
|
90
|
+
(_b = child.click) === null || _b === void 0 ? void 0 : _b.call(child);
|
|
91
|
+
current.click();
|
|
90
92
|
}
|
|
91
93
|
else if (onUnselectedEnter) {
|
|
92
94
|
onUnselectedEnter();
|
|
@@ -137,7 +139,7 @@ var Autocomplete = function (props) {
|
|
|
137
139
|
? "aui-autocomplete-on-option"
|
|
138
140
|
: undefined, listItemProps.className), onClick: function () { return handleChange(option); }, children: _jsx(_Fragment, { children: renderOption(option) }) }))] }, index));
|
|
139
141
|
})
|
|
140
|
-
: !
|
|
142
|
+
: !freeSolo &&
|
|
141
143
|
(noOptionsNode || defaultRenderOption("No results found")) }) })), !!footer && (_jsx(Box, { onClick: closeOnFooterClick ? closeMenu : undefined, children: _jsx(_Fragment, { children: footer }) }))] }))] })) }));
|
|
142
144
|
};
|
|
143
145
|
export default Autocomplete;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adamjanicki/ui-extended",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "More advanced UI components and hooks for React in TypeScript",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"react-dom": ">=18"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@adamjanicki/ui": "^1.7.
|
|
25
|
+
"@adamjanicki/ui": "^1.7.7",
|
|
26
26
|
"@floating-ui/react": "^0.26.17"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|