@mackin.com/styleguide 8.10.0 → 8.11.0

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.
Files changed (3) hide show
  1. package/index.d.ts +2 -0
  2. package/index.js +11 -4
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -54,6 +54,8 @@ interface AutocompleteProps<T extends AutocompleteValue> {
54
54
  /** Defaults to 0ms. */
55
55
  getOptionsDebounceMs?: number;
56
56
  autoFocus?: boolean;
57
+ /** Will enable scrolling in the results list. */
58
+ allowScroll?: boolean;
57
59
  onChange: (value: string) => void;
58
60
  getOptions: (value: string) => Promise<T[]>;
59
61
  onPick: (value: T) => void;
package/index.js CHANGED
@@ -900,7 +900,10 @@ const Autocomplete = (p) => {
900
900
  const showValues = React__namespace.useMemo(() => values.length > 0, [values]);
901
901
  const shownValues = React__namespace.useMemo(() => {
902
902
  var _a;
903
- return values.slice(0, (_a = p.maxShownValues) !== null && _a !== void 0 ? _a : defaultMaxShownValues);
903
+ if (!p.allowScroll) {
904
+ return values.slice(0, (_a = p.maxShownValues) !== null && _a !== void 0 ? _a : defaultMaxShownValues);
905
+ }
906
+ return values.slice();
904
907
  }, [values]);
905
908
  const onChangeForOptions = React__namespace.useRef(lodash.debounce((value) => {
906
909
  if (!p.minChars || value.length >= p.minChars) {
@@ -983,7 +986,7 @@ const Autocomplete = (p) => {
983
986
  }
984
987
  (_c = p.onKeyDown) === null || _c === void 0 ? void 0 : _c.call(p, e);
985
988
  }, onKeyPress: e => { var _a; return (_a = p.onKeyPress) === null || _a === void 0 ? void 0 : _a.call(p, e); } }),
986
- showValues && (React__namespace.createElement(List, { ref: list, className: css.css({
989
+ showValues && (React__namespace.createElement(List, { ref: list, className: css.cx(css.css({
987
990
  position: 'absolute',
988
991
  width: '100%',
989
992
  border: theme.controls.border,
@@ -1000,7 +1003,10 @@ const Autocomplete = (p) => {
1000
1003
  borderBottomRightRadius: listBorderRadius,
1001
1004
  borderBottomLeftRadius: listBorderRadius,
1002
1005
  }
1003
- }) },
1006
+ }), p.allowScroll && css.css({
1007
+ overflowY: 'scroll',
1008
+ maxHeight: `calc(${theme.controls.height} * ${p.maxShownValues})`
1009
+ })) },
1004
1010
  shownValues.map((value, listItemIndex) => {
1005
1011
  return (React__namespace.createElement(ListItem, { key: getAutocompleteValueId(value), variant: "full" },
1006
1012
  React__namespace.createElement(Button, { onKeyDown: e => {
@@ -1029,7 +1035,7 @@ const Autocomplete = (p) => {
1029
1035
  } },
1030
1036
  React__namespace.createElement(Text, { tag: "div", ellipsis: true, align: "left" }, getAutocompleteValueText(value)))));
1031
1037
  }),
1032
- shownValues.length < values.length && (React__namespace.createElement(ListItem, null,
1038
+ !p.allowScroll && shownValues.length < values.length && (React__namespace.createElement(ListItem, null,
1033
1039
  React__namespace.createElement(Text, { tag: "div", italics: true, align: "center" },
1034
1040
  "Showing ",
1035
1041
  shownValues.length.toLocaleString(),
@@ -3844,6 +3850,7 @@ const SearchBox = (props) => {
3844
3850
  }), props.buttonClassName), variant: "icon", small: true },
3845
3851
  React__namespace.createElement(Icon, { id: waiting ? 'waiting' : 'search', spin: waiting })));
3846
3852
  //TB: FUTURE replace with new inputs
3853
+ //TB: change the search icon to x when value is present
3847
3854
  const input = (React__namespace.createElement(Input, { inputClassName: props.inputClassName, autoFocus: props.autoFocus, id: props.id, debounceMs: props.debounceMs, disabled: waiting, type: "text", value: props.value, placeholder: props.placeholder, round: props.round, onChange: props.onChange, rightControl: submitButton }));
3848
3855
  const wrapperClassName = css.cx('searchBox', props.className);
3849
3856
  if (!props.noForm) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mackin.com/styleguide",
3
- "version": "8.10.0",
3
+ "version": "8.11.0",
4
4
  "description": "",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",