@mackin.com/styleguide 8.10.0 → 8.11.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.
Files changed (3) hide show
  1. package/index.d.ts +5 -0
  2. package/index.js +17 -8
  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;
@@ -928,9 +930,12 @@ declare const Table: (props: {
928
930
  caption?: string | JSX.Element;
929
931
  children?: any;
930
932
  noCellBorder?: boolean;
933
+ /** Styles applied to the table element. */
931
934
  className?: string;
932
935
  /** Colors alternate rows. */
933
936
  altRows?: boolean;
937
+ /** Styles applied to the table wrapper scroll container. */
938
+ wrapperClassName?: string;
934
939
  }) => JSX.Element;
935
940
  declare const Tr: (props: {
936
941
  className?: string;
package/index.js CHANGED
@@ -891,16 +891,19 @@ const TabLocker = (props) => {
891
891
  const defaultMaxShownValues = 7;
892
892
  const buttonMarkerClass = 'ListItem__button';
893
893
  const Autocomplete = (p) => {
894
- var _a;
894
+ var _a, _b;
895
895
  const theme = useThemeSafely();
896
896
  const element = React__namespace.useRef(null);
897
897
  const input = React__namespace.useRef(null);
898
898
  const list = React__namespace.useRef(null);
899
899
  const [values, setValues] = React__namespace.useState([]);
900
900
  const showValues = React__namespace.useMemo(() => values.length > 0, [values]);
901
+ const maxShowValues = (_a = p.maxShownValues) !== null && _a !== void 0 ? _a : defaultMaxShownValues;
901
902
  const shownValues = React__namespace.useMemo(() => {
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, maxShowValues);
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) {
@@ -914,7 +917,7 @@ const Autocomplete = (p) => {
914
917
  else {
915
918
  setValues([]);
916
919
  }
917
- }, (_a = p.getOptionsDebounceMs) !== null && _a !== void 0 ? _a : 0, { leading: false, trailing: true }));
920
+ }, (_b = p.getOptionsDebounceMs) !== null && _b !== void 0 ? _b : 0, { leading: false, trailing: true }));
918
921
  const getNextTabElement = (fromIndex, direction) => {
919
922
  var _a, _b, _c;
920
923
  if (fromIndex === -1) {
@@ -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 && shownValues.length > maxShowValues && css.css({
1007
+ overflowY: 'scroll',
1008
+ maxHeight: `calc(${theme.controls.height} * ${maxShowValues})`
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) {
@@ -4082,6 +4089,7 @@ const TabHeader = (p) => {
4082
4089
  const Table = (props) => {
4083
4090
  const theme = useThemeSafely();
4084
4091
  const tableStyles = css.css `
4092
+ label: Table;
4085
4093
  width: 100%;
4086
4094
  border-collapse: collapse;
4087
4095
  ${props.noCellBorder && `
@@ -4097,11 +4105,12 @@ const Table = (props) => {
4097
4105
  `}
4098
4106
  `;
4099
4107
  const wrapperStyles = css.css `
4108
+ label: TableScrollWrapper;
4100
4109
  width:100%;
4101
4110
  overflow-y: auto;
4102
4111
  padding:0 1px; //fixes always showing of the table scroller
4103
4112
  `;
4104
- return (React__namespace.createElement("div", { className: wrapperStyles },
4113
+ return (React__namespace.createElement("div", { className: css.cx(wrapperStyles, props.wrapperClassName) },
4105
4114
  React__namespace.createElement("table", { className: css.cx(tableStyles, props.className) },
4106
4115
  props.caption && React__namespace.createElement("caption", { className: css.css({
4107
4116
  fontWeight: 'bold',
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.2",
4
4
  "description": "",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",