@mackin.com/styleguide 7.11.0 → 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 +20 -4
- package/index.js +32 -16
- 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;
|
|
@@ -289,13 +291,20 @@ interface InfoTipProps {
|
|
|
289
291
|
onClose?: () => void;
|
|
290
292
|
/** Defaults to 'info'. */
|
|
291
293
|
variant?: 'info' | 'modal';
|
|
292
|
-
modalHeader?: string;
|
|
293
294
|
/** Defaults to nav color. */
|
|
294
295
|
bgColor?: string;
|
|
295
296
|
/** Defaults to nav font color. */
|
|
296
297
|
fontColor?: string;
|
|
298
|
+
/** For variant=modal only. */
|
|
299
|
+
modalHeader?: string;
|
|
300
|
+
/** For variant=modal only. */
|
|
297
301
|
modalId?: string;
|
|
302
|
+
/** For variant=modal only. */
|
|
298
303
|
modalDebug?: boolean;
|
|
304
|
+
/** Whether to move the popover on collision with the parent's bounds. Default is false. For variant=info only. */
|
|
305
|
+
reposition?: boolean;
|
|
306
|
+
/** Order of positions as the Popover colides with the window edge. The default order is ['right', 'top', 'left', 'bottom']. For variant=info only. */
|
|
307
|
+
positions?: ("bottom" | "left" | "right" | "top")[] | undefined;
|
|
299
308
|
}
|
|
300
309
|
declare const InfoTip: (props: InfoTipProps) => JSX.Element;
|
|
301
310
|
|
|
@@ -680,7 +689,7 @@ interface PopoverProps {
|
|
|
680
689
|
border?: string;
|
|
681
690
|
/** Popover background. Defaults to theme.colors.bg. */
|
|
682
691
|
backgroundColor?: string;
|
|
683
|
-
/** Order of positions as the Popover colides with the window edge. */
|
|
692
|
+
/** Order of positions as the Popover colides with the window edge. The default order is ['right', 'top', 'left', 'bottom']. */
|
|
684
693
|
positions?: ("bottom" | "left" | "right" | "top")[] | undefined;
|
|
685
694
|
}
|
|
686
695
|
declare const Popover: (p: PopoverProps) => JSX.Element;
|
|
@@ -719,7 +728,14 @@ declare const GlobalStyles: () => null;
|
|
|
719
728
|
|
|
720
729
|
/** @deprecated This will not work correctly with emotion/css. Use 'cx' for adding multiple class names together. */
|
|
721
730
|
declare const mergeClassNames: (...classes: (string | boolean | undefined)[]) => string | undefined;
|
|
722
|
-
declare const getCurrencyDisplay: (value: number, isCents?: boolean | undefined, denomination?: string) => string;
|
|
731
|
+
declare const getCurrencyDisplay: (value: number, isCents?: boolean | undefined, denomination?: string) => string;
|
|
732
|
+
/** Converts an enum to an array of entities with id and name. The enum can be an integer or string enum.*/
|
|
733
|
+
declare const enumToEntities: <T extends {
|
|
734
|
+
[key: string]: string | number;
|
|
735
|
+
}>(enumObj: T) => {
|
|
736
|
+
id: string | number;
|
|
737
|
+
name: string;
|
|
738
|
+
}[];
|
|
723
739
|
|
|
724
740
|
interface MackinTheme {
|
|
725
741
|
colors: {
|
|
@@ -989,4 +1005,4 @@ declare const WaitingIndicator: (p: {
|
|
|
989
1005
|
debug?: boolean;
|
|
990
1006
|
}) => JSX.Element;
|
|
991
1007
|
|
|
992
|
-
export { Alignment, Autocomplete, AutocompleteProps, AutocompleteValue, Backdrop$1 as Backdrop, Backdrop as Backdrop2, BoundMemoryPager, BoundStaticPager, Button, ButtonProps, Calendar, CalendarProps, Checkbox, CheckboxProps, ConfirmModal, ConfirmModalProps, CopyButton, DateInput, DateInputProps, DatePicker, DatePickerProps, Divider, ErrorModal, FileUploader, Form, FormColumnRow, FormFlexRow, FormProps, GlobalStyles, Header, Highlight, ICONS, Icon, Image, InfoPanel, InfoTip, InfoTipProps, Input, InputProps, ItemPager, Label, LabelProps, List, ListItem, ListItemProps, ListProps, MackinTheme, Modal, Nav, NumberInput, NumberInputProps, OmniLink, OmniLinkProps, PagedResult, Pager, PagerProps, Picker, PickerProps, Popover, ProgressBar, ProgressBarProps, SearchBox, SearchBoxProps, Slider, TabHeader, TabHeaderProps, TabLocker, Table, Td, TdCurrency, TdNumber, Text, TextArea, TextAreaProps, TextInput, TextInputProps, TextProps, Th, ThSort, ThemeProvider, ToggleButton, ToggleButtonGroup, ToggleButtonGroupProps, ToggleButtonProps, TogglePasswordInput, Tr, WaitingIndicator, calcDynamicThemeProps, defaultTheme, getCurrencyDisplay, getFileSizeDisplay, mergeClassNames, useMediaQuery, useThemeSafely };
|
|
1008
|
+
export { Alignment, Autocomplete, AutocompleteProps, AutocompleteValue, Backdrop$1 as Backdrop, Backdrop as Backdrop2, BoundMemoryPager, BoundStaticPager, Button, ButtonProps, Calendar, CalendarProps, Checkbox, CheckboxProps, ConfirmModal, ConfirmModalProps, CopyButton, DateInput, DateInputProps, DatePicker, DatePickerProps, Divider, ErrorModal, FileUploader, Form, FormColumnRow, FormFlexRow, FormProps, GlobalStyles, Header, Highlight, ICONS, Icon, Image, InfoPanel, InfoTip, InfoTipProps, Input, InputProps, ItemPager, Label, LabelProps, List, ListItem, ListItemProps, ListProps, MackinTheme, Modal, Nav, NumberInput, NumberInputProps, OmniLink, OmniLinkProps, PagedResult, Pager, PagerProps, Picker, PickerProps, Popover, ProgressBar, ProgressBarProps, SearchBox, SearchBoxProps, Slider, TabHeader, TabHeaderProps, TabLocker, Table, Td, TdCurrency, TdNumber, Text, TextArea, TextAreaProps, TextInput, TextInputProps, TextProps, Th, ThSort, ThemeProvider, ToggleButton, ToggleButtonGroup, ToggleButtonGroupProps, ToggleButtonProps, TogglePasswordInput, Tr, WaitingIndicator, calcDynamicThemeProps, defaultTheme, enumToEntities, getCurrencyDisplay, getFileSizeDisplay, mergeClassNames, useMediaQuery, useThemeSafely };
|
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(),
|
|
@@ -1049,9 +1056,6 @@ const BackdropContextProvider = (p) => {
|
|
|
1049
1056
|
log('un-mounted');
|
|
1050
1057
|
};
|
|
1051
1058
|
}, []);
|
|
1052
|
-
React.useEffect(() => {
|
|
1053
|
-
log('re-rendered');
|
|
1054
|
-
});
|
|
1055
1059
|
React.useEffect(() => {
|
|
1056
1060
|
log('showCount changed', showCount);
|
|
1057
1061
|
}, [showCount]);
|
|
@@ -1105,9 +1109,6 @@ const BackdropOverlay = (p) => {
|
|
|
1105
1109
|
log('unmounted');
|
|
1106
1110
|
};
|
|
1107
1111
|
}, []);
|
|
1108
|
-
React.useEffect(() => {
|
|
1109
|
-
log('re-rendered');
|
|
1110
|
-
});
|
|
1111
1112
|
React.useEffect(() => {
|
|
1112
1113
|
log('context.showing changed', context.showing);
|
|
1113
1114
|
}, [context.showing]);
|
|
@@ -1337,13 +1338,14 @@ const Modal = (p) => {
|
|
|
1337
1338
|
const hasHeader = p.closeButton || p.heading;
|
|
1338
1339
|
const contentRef = React__default['default'].useRef(null);
|
|
1339
1340
|
const log = useLogger(`Modal ${(_a = p.id) !== null && _a !== void 0 ? _a : '?'}`, (_b = p.debug) !== null && _b !== void 0 ? _b : false);
|
|
1341
|
+
const showing = React.useRef(p.show);
|
|
1340
1342
|
React.useEffect(() => {
|
|
1341
1343
|
log('mounted');
|
|
1342
1344
|
return () => {
|
|
1343
1345
|
// handle the use of modals that are rendered only as show=true and then unmounted.
|
|
1344
1346
|
backdrop.setShow(false);
|
|
1345
1347
|
log('backdrop.setShow', false);
|
|
1346
|
-
if (backdrop.showCount <= 1 && htmlBodyStyles) {
|
|
1348
|
+
if (showing.current && backdrop.showCount <= 1 && htmlBodyStyles) {
|
|
1347
1349
|
log('backdrop.showCount', backdrop.showCount, 'removing htmlBodyStyles');
|
|
1348
1350
|
document.body.classList.remove(htmlBodyStyles);
|
|
1349
1351
|
}
|
|
@@ -1353,10 +1355,12 @@ const Modal = (p) => {
|
|
|
1353
1355
|
React.useEffect(() => {
|
|
1354
1356
|
log('show changed', p.show);
|
|
1355
1357
|
backdrop.setShow(p.show);
|
|
1358
|
+
showing.current = p.show;
|
|
1356
1359
|
log('backdrop.setShow', true);
|
|
1357
1360
|
if (!htmlBodyStyles) {
|
|
1358
1361
|
log('creating singleton htmlBodyStyles');
|
|
1359
1362
|
htmlBodyStyles = css.css({
|
|
1363
|
+
label: 'ModalBodyOverrides',
|
|
1360
1364
|
overflow: 'hidden',
|
|
1361
1365
|
paddingRight: `${useScrollbarSize()}px`
|
|
1362
1366
|
});
|
|
@@ -1937,6 +1941,20 @@ const getCurrencyDisplay = (value, isCents, denomination = '$') => {
|
|
|
1937
1941
|
};
|
|
1938
1942
|
const noop = () => {
|
|
1939
1943
|
// lil' noop would be a great rap name. (thanks linter)
|
|
1944
|
+
};
|
|
1945
|
+
//TB: this will need to be exposed in v8 on the helpers page.
|
|
1946
|
+
/** Converts an enum to an array of entities with id and name. The enum can be an integer or string enum.*/
|
|
1947
|
+
const enumToEntities = (enumObj) => {
|
|
1948
|
+
const entities = [];
|
|
1949
|
+
for (const key in enumObj) {
|
|
1950
|
+
if (isNaN(parseInt(key, 10))) {
|
|
1951
|
+
entities.push({
|
|
1952
|
+
id: enumObj[key],
|
|
1953
|
+
name: key
|
|
1954
|
+
});
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
return entities;
|
|
1940
1958
|
};
|
|
1941
1959
|
|
|
1942
1960
|
const Header = (props) => {
|
|
@@ -2061,7 +2079,7 @@ const Image = (props) => {
|
|
|
2061
2079
|
};
|
|
2062
2080
|
|
|
2063
2081
|
const InfoTip = (props) => {
|
|
2064
|
-
var _a, _b;
|
|
2082
|
+
var _a, _b, _c;
|
|
2065
2083
|
const [showTip, setShowTip] = React__namespace.useState(false);
|
|
2066
2084
|
const theme = useThemeSafely();
|
|
2067
2085
|
const bgColor = (_a = props.bgColor) !== null && _a !== void 0 ? _a : theme.colors.nav;
|
|
@@ -2129,7 +2147,7 @@ const InfoTip = (props) => {
|
|
|
2129
2147
|
React__namespace.createElement("div", { className: css.css({ padding: '1rem' }) }, props.content))));
|
|
2130
2148
|
}
|
|
2131
2149
|
else {
|
|
2132
|
-
return (React__namespace.createElement(Popover, { reposition: false, isOpen: showTip, onClickOutside: closeTip, arrorColor: bgColor, border: '', backgroundColor: bgColor, parent: button, content: (React__namespace.createElement("div", { className: css.css({
|
|
2150
|
+
return (React__namespace.createElement(Popover, { positions: props.positions, reposition: (_c = props.reposition) !== null && _c !== void 0 ? _c : false, isOpen: showTip, onClickOutside: closeTip, arrorColor: bgColor, border: '', backgroundColor: bgColor, parent: button, content: (React__namespace.createElement("div", { className: css.css({
|
|
2133
2151
|
padding: '0.5rem',
|
|
2134
2152
|
fontSize: '0.75rem',
|
|
2135
2153
|
maxWidth: '22rem'
|
|
@@ -3773,9 +3791,6 @@ const WaitingIndicator = (p) => {
|
|
|
3773
3791
|
log('unmounted');
|
|
3774
3792
|
};
|
|
3775
3793
|
}, []);
|
|
3776
|
-
React.useEffect(() => {
|
|
3777
|
-
log('re-rendered');
|
|
3778
|
-
});
|
|
3779
3794
|
}
|
|
3780
3795
|
React.useEffect(() => {
|
|
3781
3796
|
log('show changed', p.show);
|
|
@@ -3885,6 +3900,7 @@ exports.Tr = Tr;
|
|
|
3885
3900
|
exports.WaitingIndicator = WaitingIndicator;
|
|
3886
3901
|
exports.calcDynamicThemeProps = calcDynamicThemeProps;
|
|
3887
3902
|
exports.defaultTheme = defaultTheme;
|
|
3903
|
+
exports.enumToEntities = enumToEntities;
|
|
3888
3904
|
exports.getCurrencyDisplay = getCurrencyDisplay;
|
|
3889
3905
|
exports.getFileSizeDisplay = getFileSizeDisplay;
|
|
3890
3906
|
exports.mergeClassNames = mergeClassNames;
|