@adamjanicki/ui-extended 1.2.0 → 1.2.2

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.
@@ -59,7 +59,7 @@ type Props<T> = {
59
59
  /**
60
60
  * Allow free text input
61
61
  */
62
- freeSolo?: boolean;
62
+ customize?: boolean;
63
63
  /**
64
64
  * Props for the input field
65
65
  */
@@ -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.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"]);
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.customize, customize = _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", "customize", "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 (freeSolo && value.length > 0 && filteredOptions.length === 0) {
57
+ if (customize && 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,11 +84,9 @@ 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 efficient
87
+ // It's terrible, but speedy
88
88
  var child = current.firstChild;
89
- if (child && child.nodeName === "A")
90
- (_b = child.click) === null || _b === void 0 ? void 0 : _b.call(child);
91
- current.click();
89
+ (_b = child === null || child === void 0 ? void 0 : child.click) === null || _b === void 0 ? void 0 : _b.call(child);
92
90
  }
93
91
  else if (onUnselectedEnter) {
94
92
  onUnselectedEnter();
@@ -139,7 +137,7 @@ var Autocomplete = function (props) {
139
137
  ? "aui-autocomplete-on-option"
140
138
  : undefined, listItemProps.className), onClick: function () { return handleChange(option); }, children: _jsx(_Fragment, { children: renderOption(option) }) }))] }, index));
141
139
  })
142
- : !freeSolo &&
140
+ : !customize &&
143
141
  (noOptionsNode || defaultRenderOption("No results found")) }) })), !!footer && (_jsx(Box, { onClick: closeOnFooterClick ? closeMenu : undefined, children: _jsx(_Fragment, { children: footer }) }))] }))] })) }));
144
142
  };
145
143
  export default Autocomplete;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adamjanicki/ui-extended",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
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.6",
25
+ "@adamjanicki/ui": "^1.7.7",
26
26
  "@floating-ui/react": "^0.26.17"
27
27
  },
28
28
  "devDependencies": {