@mackin.com/styleguide 7.12.1 → 7.13.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.
- package/index.d.ts +2 -0
- package/index.js +11 -4
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ interface AutocompleteProps {
|
|
|
29
29
|
inputAriaAttributes?: React.AriaAttributes;
|
|
30
30
|
/** Defaults to 0ms. */
|
|
31
31
|
getOptionsDebounceMs?: number;
|
|
32
|
+
/** Will enable scrolling in the results list. */
|
|
33
|
+
allowScroll?: boolean;
|
|
32
34
|
onChange: (value: string) => void;
|
|
33
35
|
getOptions: (value: string) => Promise<AutocompleteValue[]>;
|
|
34
36
|
onPick: (value: AutocompleteValue) => void;
|
package/index.js
CHANGED
|
@@ -891,7 +891,10 @@ const Autocomplete = (p) => {
|
|
|
891
891
|
const showValues = React__namespace.useMemo(() => values.length > 0, [values]);
|
|
892
892
|
const shownValues = React__namespace.useMemo(() => {
|
|
893
893
|
var _a;
|
|
894
|
-
|
|
894
|
+
if (!p.allowScroll) {
|
|
895
|
+
return values.slice(0, (_a = p.maxShownValues) !== null && _a !== void 0 ? _a : DEFAULT_MAX_SHOWN_VALUES);
|
|
896
|
+
}
|
|
897
|
+
return values.slice();
|
|
895
898
|
}, [values]);
|
|
896
899
|
const onChangeForOptions = React__namespace.useRef(lodash.debounce((value) => {
|
|
897
900
|
if (!p.minChars || value.length >= p.minChars) {
|
|
@@ -923,6 +926,7 @@ const Autocomplete = (p) => {
|
|
|
923
926
|
borderRadius: listBorderRadius,
|
|
924
927
|
boxShadow: theme.controls.boxShadow,
|
|
925
928
|
backgroundColor: theme.colors.bg,
|
|
929
|
+
color: theme.colors.font,
|
|
926
930
|
marginTop: `-4px !important`,
|
|
927
931
|
zIndex: theme.zIndexes.backdrop,
|
|
928
932
|
'li:first-child button': {
|
|
@@ -932,7 +936,7 @@ const Autocomplete = (p) => {
|
|
|
932
936
|
'li:last-child button': {
|
|
933
937
|
borderBottomRightRadius: listBorderRadius,
|
|
934
938
|
borderBottomLeftRadius: listBorderRadius,
|
|
935
|
-
}
|
|
939
|
+
},
|
|
936
940
|
});
|
|
937
941
|
const inputClass = css.css `
|
|
938
942
|
${showValues && `
|
|
@@ -985,7 +989,10 @@ const Autocomplete = (p) => {
|
|
|
985
989
|
}
|
|
986
990
|
}
|
|
987
991
|
}, onKeyPress: e => { var _a; return (_a = p.onKeyPress) === null || _a === void 0 ? void 0 : _a.call(p, e); } }),
|
|
988
|
-
showValues && (React__namespace.createElement(List, { ref: list, className: listClass
|
|
992
|
+
showValues && (React__namespace.createElement(List, { ref: list, className: css.cx(listClass, p.allowScroll && css.css({
|
|
993
|
+
overflowY: 'scroll',
|
|
994
|
+
maxHeight: `calc(${theme.controls.height} * ${p.maxShownValues})`
|
|
995
|
+
})) },
|
|
989
996
|
shownValues.map((value, listItemIndex) => {
|
|
990
997
|
return (React__namespace.createElement(ListItem, { key: getAutocompleteValueId(value), variant: "full" },
|
|
991
998
|
React__namespace.createElement(Button, { onKeyDown: e => {
|
|
@@ -1012,7 +1019,7 @@ const Autocomplete = (p) => {
|
|
|
1012
1019
|
} },
|
|
1013
1020
|
React__namespace.createElement(Text, { tag: "div", ellipsis: true, align: "left" }, getAutocompleteValueText(value)))));
|
|
1014
1021
|
}),
|
|
1015
|
-
shownValues.length < values.length && (React__namespace.createElement(ListItem, null,
|
|
1022
|
+
!p.allowScroll && shownValues.length < values.length && (React__namespace.createElement(ListItem, null,
|
|
1016
1023
|
React__namespace.createElement(Text, { tag: "div", italics: true, align: "center" },
|
|
1017
1024
|
"Showing ",
|
|
1018
1025
|
shownValues.length.toLocaleString(),
|