@mackin.com/styleguide 9.5.0 → 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 +5 -1
  2. package/index.js +18 -17
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -628,8 +628,12 @@ interface PickerProps<T extends PickerValue> extends SelectProps {
628
628
  onValueChange: (value: T) => void;
629
629
  readOnly?: boolean;
630
630
  round?: boolean;
631
- /** 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
+ */
632
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;
633
637
  /** This will be applied to the select element. */
634
638
  className?: string;
635
639
  /** Applies to the outer wrapper which contains the select and other elements. */
package/index.js CHANGED
@@ -3017,7 +3017,7 @@ const roundPxPadding = '4px';
3017
3017
  const Picker = (props) => {
3018
3018
  const selectProps = __rest(props
3019
3019
  // if we put numbers in, we expect them out
3020
- , ["value", "options", "onValueChange", "readOnly", "round", "controlAlign", "wrapperClassName", "iconClassName"]);
3020
+ , ["value", "options", "onValueChange", "readOnly", "round", "controlAlign", "wrapperClassName", "iconClassName", "error"]);
3021
3021
  // if we put numbers in, we expect them out
3022
3022
  let isNumber = false;
3023
3023
  if (props.options && props.options.length) {
@@ -3057,6 +3057,11 @@ const Picker = (props) => {
3057
3057
  borderRadius: theme.controls.roundRadius,
3058
3058
  paddingLeft: `calc(${theme.controls.padding} + ${roundPxPadding})`,
3059
3059
  paddingRight: `calc(${theme.controls.padding} + 1rem + ${roundPxPadding})`,
3060
+ }, props.error && {
3061
+ borderColor: theme.colors.required,
3062
+ ':focus': {
3063
+ boxShadow: theme.controls.focusOutlineRequiredShadow
3064
+ }
3060
3065
  }, props.readOnly && {
3061
3066
  backgroundColor: 'transparent !important',
3062
3067
  backgroundImage: 'unset',
@@ -3113,28 +3118,24 @@ const Picker = (props) => {
3113
3118
  }
3114
3119
  return React__namespace.createElement("option", { key: val, value: val }, label);
3115
3120
  })));
3116
- let iconHeight;
3117
- if (props.controlAlign) {
3118
- iconHeight = `calc(100% - ${theme.controls.inputErrorMinHeight})`;
3119
- }
3120
- else {
3121
- iconHeight = '100%';
3122
- }
3123
3121
  return (React__namespace.createElement("span", { className: css.cx(css.css({
3124
3122
  label: 'PickerWrapper',
3125
3123
  position: 'relative',
3126
3124
  display: 'inline-block',
3127
3125
  width: '100%',
3128
- paddingBottom: props.controlAlign ? theme.controls.inputErrorMinHeight : undefined
3129
3126
  }), props.wrapperClassName) },
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: iconHeight,
3135
- pointerEvents: 'none',
3136
- color: theme.colors.font
3137
- }), 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 })));
3138
3139
  };
3139
3140
 
3140
3141
  const Pager = (props) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mackin.com/styleguide",
3
- "version": "9.5.0",
3
+ "version": "9.6.0",
4
4
  "description": "",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",