@adamjanicki/ui-extended 1.0.5 → 1.0.6
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/components/Autocomplete.d.ts +5 -0
- package/components/Autocomplete.js +4 -4
- package/package.json +1 -1
- package/style.css +1 -1
- package/utils/types.d.ts +0 -8
- package/utils/types.js +0 -1
|
@@ -84,6 +84,11 @@ interface Props<T> {
|
|
|
84
84
|
* Footer node to render at the bottom of the popover
|
|
85
85
|
*/
|
|
86
86
|
footer?: React.ReactNode;
|
|
87
|
+
/**
|
|
88
|
+
* Close the popover when the footer is clicked
|
|
89
|
+
* @default true
|
|
90
|
+
*/
|
|
91
|
+
closeOnFooterClick?: boolean;
|
|
87
92
|
/**
|
|
88
93
|
* A callback to be called when the user hits the enter key while no option is selected
|
|
89
94
|
*/
|
|
@@ -29,14 +29,14 @@ import { classNames } from "@adamjanicki/ui/utils/util";
|
|
|
29
29
|
var defaultRenderOption = function (option) { return (_jsx("div", { className: "ajui-autocomplete-default-rendering", children: "".concat(option) })); };
|
|
30
30
|
var Autocomplete = function (props) {
|
|
31
31
|
var _a, _b;
|
|
32
|
-
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, _g = props.focusOnSelect, focusOnSelect = _g === void 0 ? true : _g, value = props.value, onInputChange = props.onInputChange, onSelect = props.onSelect, popoverProps = props.popoverProps, footer = props.footer, _h = props.listItemProps, listItemProps = _h === void 0 ? {} : _h, _j = props.listProps, listProps = _j === void 0 ? {} : _j, onUnselectedEnter = props.onUnselectedEnter, rest = __rest(props, ["options", "renderOption", "filterOption", "groupBy", "renderGroup", "noOptionsNode", "InputProps", "freeSolo", "focusOnSelect", "value", "onInputChange", "onSelect", "popoverProps", "footer", "listItemProps", "listProps", "onUnselectedEnter"]);
|
|
32
|
+
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, _g = props.focusOnSelect, focusOnSelect = _g === void 0 ? true : _g, value = props.value, onInputChange = props.onInputChange, onSelect = props.onSelect, popoverProps = props.popoverProps, footer = props.footer, _h = props.listItemProps, listItemProps = _h === void 0 ? {} : _h, _j = props.listProps, listProps = _j === void 0 ? {} : _j, onUnselectedEnter = props.onUnselectedEnter, _k = props.closeOnFooterClick, closeOnFooterClick = _k === void 0 ? true : _k, rest = __rest(props, ["options", "renderOption", "filterOption", "groupBy", "renderGroup", "noOptionsNode", "InputProps", "freeSolo", "focusOnSelect", "value", "onInputChange", "onSelect", "popoverProps", "footer", "listItemProps", "listProps", "onUnselectedEnter", "closeOnFooterClick"]);
|
|
33
33
|
var inputContainerRef = React.useRef(null);
|
|
34
34
|
var inputRef = React.useRef(null);
|
|
35
35
|
var onRef = React.useRef(null);
|
|
36
36
|
var nextRef = React.useRef(null);
|
|
37
37
|
var prevRef = React.useRef(null);
|
|
38
|
-
var
|
|
39
|
-
var
|
|
38
|
+
var _l = React.useState(), on = _l[0], setOn = _l[1];
|
|
39
|
+
var _m = React.useState(false), open = _m[0], setOpen = _m[1];
|
|
40
40
|
var filteredOptions = options.filter(filterOption);
|
|
41
41
|
var groupMap = new Map();
|
|
42
42
|
if (groupBy) {
|
|
@@ -152,6 +152,6 @@ var Autocomplete = function (props) {
|
|
|
152
152
|
: undefined, listItemProps.className), onClick: function () { return handleChange(option); }, children: renderOption(option) }))] }, index));
|
|
153
153
|
})
|
|
154
154
|
: !freeSolo &&
|
|
155
|
-
(noOptionsNode || defaultRenderOption("No results found")) })), footer] }))] })) }));
|
|
155
|
+
(noOptionsNode || defaultRenderOption("No results found")) })), footer && (_jsx("div", { onClick: closeOnFooterClick ? closeMenu : undefined, children: footer }))] }))] })) }));
|
|
156
156
|
};
|
|
157
157
|
export default Autocomplete;
|
package/package.json
CHANGED
package/style.css
CHANGED
package/utils/types.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The type of corner to display, controlling the border radius property.
|
|
3
|
-
*/
|
|
4
|
-
export type CornerType = "pill" | "rounded" | "sharp";
|
|
5
|
-
/**
|
|
6
|
-
* The type of message associated with a piece of content.
|
|
7
|
-
*/
|
|
8
|
-
export type ContentType = "success" | "warning" | "error" | "info" | "static";
|
package/utils/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|