@mackin.com/styleguide 7.10.0 → 7.12.1

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 +22 -4
  2. package/index.js +27 -12
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -289,13 +289,20 @@ interface InfoTipProps {
289
289
  onClose?: () => void;
290
290
  /** Defaults to 'info'. */
291
291
  variant?: 'info' | 'modal';
292
- modalHeader?: string;
293
292
  /** Defaults to nav color. */
294
293
  bgColor?: string;
295
294
  /** Defaults to nav font color. */
296
295
  fontColor?: string;
296
+ /** For variant=modal only. */
297
+ modalHeader?: string;
298
+ /** For variant=modal only. */
297
299
  modalId?: string;
300
+ /** For variant=modal only. */
298
301
  modalDebug?: boolean;
302
+ /** Whether to move the popover on collision with the parent's bounds. Default is false. For variant=info only. */
303
+ reposition?: boolean;
304
+ /** Order of positions as the Popover colides with the window edge. The default order is ['right', 'top', 'left', 'bottom']. For variant=info only. */
305
+ positions?: ("bottom" | "left" | "right" | "top")[] | undefined;
299
306
  }
300
307
  declare const InfoTip: (props: InfoTipProps) => JSX.Element;
301
308
 
@@ -680,7 +687,7 @@ interface PopoverProps {
680
687
  border?: string;
681
688
  /** Popover background. Defaults to theme.colors.bg. */
682
689
  backgroundColor?: string;
683
- /** Order of positions as the Popover colides with the window edge. */
690
+ /** Order of positions as the Popover colides with the window edge. The default order is ['right', 'top', 'left', 'bottom']. */
684
691
  positions?: ("bottom" | "left" | "right" | "top")[] | undefined;
685
692
  }
686
693
  declare const Popover: (p: PopoverProps) => JSX.Element;
@@ -719,7 +726,14 @@ declare const GlobalStyles: () => null;
719
726
 
720
727
  /** @deprecated This will not work correctly with emotion/css. Use 'cx' for adding multiple class names together. */
721
728
  declare const mergeClassNames: (...classes: (string | boolean | undefined)[]) => string | undefined;
722
- declare const getCurrencyDisplay: (value: number, isCents?: boolean | undefined, denomination?: string) => string;
729
+ declare const getCurrencyDisplay: (value: number, isCents?: boolean | undefined, denomination?: string) => string;
730
+ /** Converts an enum to an array of entities with id and name. The enum can be an integer or string enum.*/
731
+ declare const enumToEntities: <T extends {
732
+ [key: string]: string | number;
733
+ }>(enumObj: T) => {
734
+ id: string | number;
735
+ name: string;
736
+ }[];
723
737
 
724
738
  interface MackinTheme {
725
739
  colors: {
@@ -810,6 +824,10 @@ interface MackinTheme {
810
824
  desktop: string;
811
825
  tablet: string;
812
826
  };
827
+ mediaQueries: {
828
+ desktop: string;
829
+ tablet: string;
830
+ };
813
831
  }
814
832
  /** Call this on your theme after messing with the props. It will re-build things that depend on sizes and colors. */
815
833
  declare const calcDynamicThemeProps: <T extends MackinTheme>(theme: T) => void;
@@ -985,4 +1003,4 @@ declare const WaitingIndicator: (p: {
985
1003
  debug?: boolean;
986
1004
  }) => JSX.Element;
987
1005
 
988
- 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 };
1006
+ 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
@@ -47,6 +47,8 @@ const calcDynamicThemeProps = (theme) => {
47
47
  theme.controls.focusOutlineShadow = `0px 0px 4px 2px ${theme.colors.focusOutline}`;
48
48
  theme.controls.focusOutlineRequiredShadow = `0px 0px 4px 2px ${theme.colors.focusOutlineRequired}`;
49
49
  theme.controls.dividerBorder = `2px solid ${theme.colors.divider}`;
50
+ theme.mediaQueries.desktop = `@media(min-width:${theme.breakpoints.desktop})`;
51
+ theme.mediaQueries.tablet = `@media(min-width:${theme.breakpoints.tablet})`;
50
52
  };
51
53
  const defaultTheme = {
52
54
  colors: {
@@ -135,6 +137,10 @@ const defaultTheme = {
135
137
  breakpoints: {
136
138
  desktop: '800px',
137
139
  tablet: '768px'
140
+ },
141
+ mediaQueries: {
142
+ desktop: '',
143
+ tablet: ''
138
144
  }
139
145
  };
140
146
  calcDynamicThemeProps(defaultTheme);
@@ -1043,9 +1049,6 @@ const BackdropContextProvider = (p) => {
1043
1049
  log('un-mounted');
1044
1050
  };
1045
1051
  }, []);
1046
- React.useEffect(() => {
1047
- log('re-rendered');
1048
- });
1049
1052
  React.useEffect(() => {
1050
1053
  log('showCount changed', showCount);
1051
1054
  }, [showCount]);
@@ -1099,9 +1102,6 @@ const BackdropOverlay = (p) => {
1099
1102
  log('unmounted');
1100
1103
  };
1101
1104
  }, []);
1102
- React.useEffect(() => {
1103
- log('re-rendered');
1104
- });
1105
1105
  React.useEffect(() => {
1106
1106
  log('context.showing changed', context.showing);
1107
1107
  }, [context.showing]);
@@ -1331,13 +1331,14 @@ const Modal = (p) => {
1331
1331
  const hasHeader = p.closeButton || p.heading;
1332
1332
  const contentRef = React__default['default'].useRef(null);
1333
1333
  const log = useLogger(`Modal ${(_a = p.id) !== null && _a !== void 0 ? _a : '?'}`, (_b = p.debug) !== null && _b !== void 0 ? _b : false);
1334
+ const showing = React.useRef(p.show);
1334
1335
  React.useEffect(() => {
1335
1336
  log('mounted');
1336
1337
  return () => {
1337
1338
  // handle the use of modals that are rendered only as show=true and then unmounted.
1338
1339
  backdrop.setShow(false);
1339
1340
  log('backdrop.setShow', false);
1340
- if (backdrop.showCount <= 1 && htmlBodyStyles) {
1341
+ if (showing.current && backdrop.showCount <= 1 && htmlBodyStyles) {
1341
1342
  log('backdrop.showCount', backdrop.showCount, 'removing htmlBodyStyles');
1342
1343
  document.body.classList.remove(htmlBodyStyles);
1343
1344
  }
@@ -1347,10 +1348,12 @@ const Modal = (p) => {
1347
1348
  React.useEffect(() => {
1348
1349
  log('show changed', p.show);
1349
1350
  backdrop.setShow(p.show);
1351
+ showing.current = p.show;
1350
1352
  log('backdrop.setShow', true);
1351
1353
  if (!htmlBodyStyles) {
1352
1354
  log('creating singleton htmlBodyStyles');
1353
1355
  htmlBodyStyles = css.css({
1356
+ label: 'ModalBodyOverrides',
1354
1357
  overflow: 'hidden',
1355
1358
  paddingRight: `${useScrollbarSize()}px`
1356
1359
  });
@@ -1931,6 +1934,20 @@ const getCurrencyDisplay = (value, isCents, denomination = '$') => {
1931
1934
  };
1932
1935
  const noop = () => {
1933
1936
  // lil' noop would be a great rap name. (thanks linter)
1937
+ };
1938
+ //TB: this will need to be exposed in v8 on the helpers page.
1939
+ /** Converts an enum to an array of entities with id and name. The enum can be an integer or string enum.*/
1940
+ const enumToEntities = (enumObj) => {
1941
+ const entities = [];
1942
+ for (const key in enumObj) {
1943
+ if (isNaN(parseInt(key, 10))) {
1944
+ entities.push({
1945
+ id: enumObj[key],
1946
+ name: key
1947
+ });
1948
+ }
1949
+ }
1950
+ return entities;
1934
1951
  };
1935
1952
 
1936
1953
  const Header = (props) => {
@@ -2055,7 +2072,7 @@ const Image = (props) => {
2055
2072
  };
2056
2073
 
2057
2074
  const InfoTip = (props) => {
2058
- var _a, _b;
2075
+ var _a, _b, _c;
2059
2076
  const [showTip, setShowTip] = React__namespace.useState(false);
2060
2077
  const theme = useThemeSafely();
2061
2078
  const bgColor = (_a = props.bgColor) !== null && _a !== void 0 ? _a : theme.colors.nav;
@@ -2123,7 +2140,7 @@ const InfoTip = (props) => {
2123
2140
  React__namespace.createElement("div", { className: css.css({ padding: '1rem' }) }, props.content))));
2124
2141
  }
2125
2142
  else {
2126
- 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({
2143
+ 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({
2127
2144
  padding: '0.5rem',
2128
2145
  fontSize: '0.75rem',
2129
2146
  maxWidth: '22rem'
@@ -3767,9 +3784,6 @@ const WaitingIndicator = (p) => {
3767
3784
  log('unmounted');
3768
3785
  };
3769
3786
  }, []);
3770
- React.useEffect(() => {
3771
- log('re-rendered');
3772
- });
3773
3787
  }
3774
3788
  React.useEffect(() => {
3775
3789
  log('show changed', p.show);
@@ -3879,6 +3893,7 @@ exports.Tr = Tr;
3879
3893
  exports.WaitingIndicator = WaitingIndicator;
3880
3894
  exports.calcDynamicThemeProps = calcDynamicThemeProps;
3881
3895
  exports.defaultTheme = defaultTheme;
3896
+ exports.enumToEntities = enumToEntities;
3882
3897
  exports.getCurrencyDisplay = getCurrencyDisplay;
3883
3898
  exports.getFileSizeDisplay = getFileSizeDisplay;
3884
3899
  exports.mergeClassNames = mergeClassNames;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mackin.com/styleguide",
3
- "version": "7.10.0",
3
+ "version": "7.12.1",
4
4
  "description": "",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",