@mackin.com/styleguide 9.4.1 → 9.6.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 +9 -1
  2. package/index.js +25 -23
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -420,10 +420,14 @@ declare const Nav: (props: {
420
420
  toggle: (show: boolean) => void;
421
421
  id?: string | undefined;
422
422
  children?: React.ReactNode;
423
+ /** @deprecated Going foward, implement the nav visibility based on screen size in the consuming application.
424
+ * If true, the nav and backdrop will hide when the screen is larger. Defaults to `theme.breakpoints.desktop`. */
423
425
  responsive?: boolean | undefined;
424
426
  className?: string | undefined;
425
427
  /** Duration of the slide animation in ms. Defaults to `theme.timings.nav.slideMs`. */
426
428
  slideMs?: number | undefined;
429
+ /** Defaults to `theme.layout.navWidth`. */
430
+ navWidth?: string | undefined;
427
431
  __debug?: boolean | undefined;
428
432
  }) => JSX.Element;
429
433
 
@@ -624,8 +628,12 @@ interface PickerProps<T extends PickerValue> extends SelectProps {
624
628
  onValueChange: (value: T) => void;
625
629
  readOnly?: boolean;
626
630
  round?: boolean;
627
- /** If true, bottom padding will be added to account for other inputs having space for error messages. */
631
+ /** If true, bottom spacing will be added to account for other inputs having space for error messages.
632
+ * If you plan on using 'error', make sure this is also set to true so the spacing is not added and removed when the error message is toggled.
633
+ */
628
634
  controlAlign?: boolean;
635
+ /** An error message to display below the input. If set, 'controlAlign' will be ignored and default to 'true'. */
636
+ error?: string;
629
637
  /** This will be applied to the select element. */
630
638
  className?: string;
631
639
  /** Applies to the outer wrapper which contains the select and other elements. */
package/index.js CHANGED
@@ -2697,14 +2697,15 @@ const useMediaQuery = (query) => {
2697
2697
  };
2698
2698
 
2699
2699
  const Nav = (props) => {
2700
- var _a, _b, _c;
2700
+ var _a, _b, _c, _d;
2701
2701
  const nav = React__namespace.useRef(null);
2702
2702
  const theme = useThemeSafely();
2703
- const totalNavOffset = `calc(${theme.layout.navWidth} + 20px)`;
2703
+ const navWidth = (_a = props.navWidth) !== null && _a !== void 0 ? _a : theme.layout.navWidth;
2704
+ const totalNavOffset = `calc(${navWidth} + 20px)`;
2704
2705
  const backdrop = React__namespace.useContext(BackdropContext);
2705
2706
  const isLargeScreen = useMediaQuery(`(min-width:${theme.breakpoints.desktop})`);
2706
- const log = useLogger(`Nav ${(_a = props.id) !== null && _a !== void 0 ? _a : '?'}`, (_b = props.__debug) !== null && _b !== void 0 ? _b : false);
2707
- const slideMs = (_c = props.slideMs) !== null && _c !== void 0 ? _c : theme.timings.nav.slideMs;
2707
+ const log = useLogger(`Nav ${(_b = props.id) !== null && _b !== void 0 ? _b : '?'}`, (_c = props.__debug) !== null && _c !== void 0 ? _c : false);
2708
+ const slideMs = (_d = props.slideMs) !== null && _d !== void 0 ? _d : theme.timings.nav.slideMs;
2708
2709
  const slideRight = css.keyframes `
2709
2710
  0% {
2710
2711
  transform: translateX(0);
@@ -2738,8 +2739,8 @@ const Nav = (props) => {
2738
2739
  bottom: 0;
2739
2740
  background-color: ${theme.colors.nav};
2740
2741
  color: ${theme.colors.navFont};
2741
- width: ${theme.layout.navWidth};
2742
- min-width: ${theme.layout.navWidth};
2742
+ width: ${navWidth};
2743
+ min-width: ${navWidth};
2743
2744
  box-shadow: 4px 2px 12px 6px rgba(0, 0, 0, 0.2);
2744
2745
  z-index: ${theme.zIndexes.nav};
2745
2746
  overflow-y: auto;
@@ -3016,7 +3017,7 @@ const roundPxPadding = '4px';
3016
3017
  const Picker = (props) => {
3017
3018
  const selectProps = __rest(props
3018
3019
  // if we put numbers in, we expect them out
3019
- , ["value", "options", "onValueChange", "readOnly", "round", "controlAlign", "wrapperClassName", "iconClassName"]);
3020
+ , ["value", "options", "onValueChange", "readOnly", "round", "controlAlign", "wrapperClassName", "iconClassName", "error"]);
3020
3021
  // if we put numbers in, we expect them out
3021
3022
  let isNumber = false;
3022
3023
  if (props.options && props.options.length) {
@@ -3056,6 +3057,11 @@ const Picker = (props) => {
3056
3057
  borderRadius: theme.controls.roundRadius,
3057
3058
  paddingLeft: `calc(${theme.controls.padding} + ${roundPxPadding})`,
3058
3059
  paddingRight: `calc(${theme.controls.padding} + 1rem + ${roundPxPadding})`,
3060
+ }, props.error && {
3061
+ borderColor: theme.colors.required,
3062
+ ':focus': {
3063
+ boxShadow: theme.controls.focusOutlineRequiredShadow
3064
+ }
3059
3065
  }, props.readOnly && {
3060
3066
  backgroundColor: 'transparent !important',
3061
3067
  backgroundImage: 'unset',
@@ -3112,28 +3118,24 @@ const Picker = (props) => {
3112
3118
  }
3113
3119
  return React__namespace.createElement("option", { key: val, value: val }, label);
3114
3120
  })));
3115
- let iconHeight;
3116
- if (props.controlAlign) {
3117
- iconHeight = `calc(100% - ${theme.controls.inputErrorMinHeight})`;
3118
- }
3119
- else {
3120
- iconHeight = '100%';
3121
- }
3122
3121
  return (React__namespace.createElement("span", { className: css.cx(css.css({
3123
3122
  label: 'PickerWrapper',
3124
3123
  position: 'relative',
3125
3124
  display: 'inline-block',
3126
3125
  width: '100%',
3127
- paddingBottom: props.controlAlign ? theme.controls.inputErrorMinHeight : undefined
3128
3126
  }), props.wrapperClassName) },
3129
- select,
3130
- !props.readOnly && (React__namespace.createElement(Icon, { id: "sortDesc", className: css.cx(css.css({
3131
- position: 'absolute',
3132
- right: `calc(${theme.controls.padding} + ${props.round ? roundPxPadding : '0px'})`,
3133
- height: iconHeight,
3134
- pointerEvents: 'none',
3135
- color: theme.colors.font
3136
- }), props.iconClassName) }))));
3127
+ React__namespace.createElement("div", { className: css.css({
3128
+ position: 'relative'
3129
+ }) },
3130
+ select,
3131
+ !props.readOnly && (React__namespace.createElement(Icon, { id: "sortDesc", className: css.cx(css.css({
3132
+ position: 'absolute',
3133
+ right: `calc(${theme.controls.padding} + ${props.round ? roundPxPadding : '0px'})`,
3134
+ height: '100%',
3135
+ pointerEvents: 'none',
3136
+ color: theme.colors.font
3137
+ }), props.iconClassName) }))),
3138
+ (props.error || props.controlAlign) && React__namespace.createElement(InputErrorDisplay, { error: props.error })));
3137
3139
  };
3138
3140
 
3139
3141
  const Pager = (props) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mackin.com/styleguide",
3
- "version": "9.4.1",
3
+ "version": "9.6.0",
4
4
  "description": "",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",