@instructure/ui-radio-input 11.7.3-snapshot-7 → 11.7.3-snapshot-26

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/CHANGELOG.md CHANGED
@@ -3,9 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [11.7.3-snapshot-7](https://github.com/instructure/instructure-ui/compare/v11.7.2...v11.7.3-snapshot-7) (2026-04-29)
6
+ ## [11.7.3-snapshot-26](https://github.com/instructure/instructure-ui/compare/v11.7.2...v11.7.3-snapshot-26) (2026-05-05)
7
7
 
8
- **Note:** Version bump only for package @instructure/ui-radio-input
8
+
9
+ ### Bug Fixes
10
+
11
+ * **many:** update dependencies, remove lots of Babel plugins, remove Webpack 4 support ([f916fca](https://github.com/instructure/instructure-ui/commit/f916fcafdddcb2d7de401f93e8ff92cfdfa47bba))
9
12
 
10
13
 
11
14
 
@@ -1,4 +1,4 @@
1
- var _dec, _dec2, _class, _RadioInput;
1
+ var _dec, _dec2, _class;
2
2
  /*
3
3
  * The MIT License (MIT)
4
4
  *
@@ -36,41 +36,23 @@ category: components
36
36
  ---
37
37
  **/
38
38
  import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
39
- let RadioInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec(_class = _dec2(_class = (_RadioInput = class RadioInput extends Component {
39
+ let RadioInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec(_class = _dec2(_class = class RadioInput extends Component {
40
+ static displayName = "RadioInput";
41
+ static componentId = 'RadioInput';
42
+ static allowedProps = allowedProps;
43
+ static defaultProps = {
44
+ variant: 'simple',
45
+ size: 'medium',
46
+ disabled: false,
47
+ inline: false,
48
+ context: 'success',
49
+ readOnly: false
50
+ };
51
+ ref = null;
52
+ _defaultId;
53
+ _input = null;
40
54
  constructor(props) {
41
55
  super(props);
42
- this.ref = null;
43
- this._defaultId = void 0;
44
- this._input = null;
45
- this.handleInputRef = el => {
46
- this._input = el;
47
- if (typeof this.props.inputRef === 'function') {
48
- this.props.inputRef(el);
49
- }
50
- };
51
- this.handleClick = e => {
52
- if (this.props.disabled || this.props.readOnly) {
53
- e.preventDefault();
54
- return;
55
- }
56
- if (typeof this.props.onClick === 'function') {
57
- this.props.onClick(e);
58
- }
59
- };
60
- this.handleChange = e => {
61
- if (this.props.disabled || this.props.readOnly) {
62
- e.preventDefault();
63
- return;
64
- }
65
- if (typeof this.props.checked === 'undefined') {
66
- this.setState({
67
- checked: !this.state.checked
68
- });
69
- }
70
- if (typeof this.props.onChange === 'function') {
71
- this.props.onChange(e);
72
- }
73
- };
74
56
  if (typeof props.checked === 'undefined') {
75
57
  this.state = {
76
58
  checked: false
@@ -79,16 +61,42 @@ let RadioInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
79
61
  this._defaultId = props.deterministicId();
80
62
  }
81
63
  componentDidMount() {
82
- var _this$props$makeStyle, _this$props;
83
- (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
64
+ this.props.makeStyles?.();
84
65
  }
85
66
  componentDidUpdate() {
86
- var _this$props$makeStyle2, _this$props2;
87
- (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
67
+ this.props.makeStyles?.();
88
68
  }
69
+ handleInputRef = el => {
70
+ this._input = el;
71
+ if (typeof this.props.inputRef === 'function') {
72
+ this.props.inputRef(el);
73
+ }
74
+ };
75
+ handleClick = e => {
76
+ if (this.props.disabled || this.props.readOnly) {
77
+ e.preventDefault();
78
+ return;
79
+ }
80
+ if (typeof this.props.onClick === 'function') {
81
+ this.props.onClick(e);
82
+ }
83
+ };
84
+ handleChange = e => {
85
+ if (this.props.disabled || this.props.readOnly) {
86
+ e.preventDefault();
87
+ return;
88
+ }
89
+ if (typeof this.props.checked === 'undefined') {
90
+ this.setState({
91
+ checked: !this.state.checked
92
+ });
93
+ }
94
+ if (typeof this.props.onChange === 'function') {
95
+ this.props.onChange(e);
96
+ }
97
+ };
89
98
  focus() {
90
- var _this$_input;
91
- (_this$_input = this._input) === null || _this$_input === void 0 ? void 0 : _this$_input.focus();
99
+ this._input?.focus();
92
100
  }
93
101
  get id() {
94
102
  return this.props.id || this._defaultId;
@@ -100,22 +108,23 @@ let RadioInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
100
108
  return typeof this.props.checked === 'undefined' ? this.state.checked : this.props.checked;
101
109
  }
102
110
  render() {
103
- const _this$props3 = this.props,
104
- disabled = _this$props3.disabled,
105
- readOnly = _this$props3.readOnly,
106
- label = _this$props3.label,
107
- value = _this$props3.value,
108
- name = _this$props3.name,
109
- styles = _this$props3.styles;
111
+ const {
112
+ disabled,
113
+ readOnly,
114
+ label,
115
+ value,
116
+ name,
117
+ styles
118
+ } = this.props;
110
119
  const props = omitProps(this.props, RadioInput.allowedProps);
111
120
  return _jsx("div", {
112
- css: styles === null || styles === void 0 ? void 0 : styles.radioInput,
121
+ css: styles?.radioInput,
113
122
  "data-cid": "RadioInput",
114
123
  ref: el => {
115
124
  this.ref = el;
116
125
  },
117
126
  children: _jsxs("div", {
118
- css: styles === null || styles === void 0 ? void 0 : styles.container,
127
+ css: styles?.container,
119
128
  children: [_jsx("input", {
120
129
  ...props,
121
130
  id: this.id,
@@ -124,31 +133,24 @@ let RadioInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
124
133
  name: name,
125
134
  checked: this.checked,
126
135
  type: "radio",
127
- css: styles === null || styles === void 0 ? void 0 : styles.input,
136
+ css: styles?.input,
128
137
  disabled: disabled || readOnly,
129
138
  onChange: this.handleChange,
130
139
  onClick: this.handleClick
131
140
  }), _jsxs("label", {
132
- css: styles === null || styles === void 0 ? void 0 : styles.control,
141
+ css: styles?.control,
133
142
  htmlFor: this.id,
134
143
  children: [_jsx("span", {
135
- css: styles === null || styles === void 0 ? void 0 : styles.facade,
144
+ css: styles?.facade,
136
145
  "aria-hidden": "true"
137
146
  }), _jsx("span", {
138
- css: styles === null || styles === void 0 ? void 0 : styles.label,
147
+ css: styles?.label,
139
148
  children: label
140
149
  })]
141
150
  })]
142
151
  })
143
152
  });
144
153
  }
145
- }, _RadioInput.displayName = "RadioInput", _RadioInput.componentId = 'RadioInput', _RadioInput.allowedProps = allowedProps, _RadioInput.defaultProps = {
146
- variant: 'simple',
147
- size: 'medium',
148
- disabled: false,
149
- inline: false,
150
- context: 'success',
151
- readOnly: false
152
- }, _RadioInput)) || _class) || _class);
154
+ }) || _class) || _class);
153
155
  export default RadioInput;
154
156
  export { RadioInput };
@@ -33,11 +33,13 @@
33
33
  * @return {Object} The final style object, which will be used in the component
34
34
  */
35
35
  const generateStyle = (componentTheme, props) => {
36
- const disabled = props.disabled,
37
- variant = props.variant,
38
- context = props.context,
39
- size = props.size,
40
- inline = props.inline;
36
+ const {
37
+ disabled,
38
+ variant,
39
+ context,
40
+ size,
41
+ inline
42
+ } = props;
41
43
  const getInputStateSelector = state => `[class$=-radioInput__input]:${state} + [class$=-radioInput__control] &`;
42
44
  const toggleFacadeContextVariants = {
43
45
  success: {
@@ -28,14 +28,15 @@
28
28
  * @return {Object} The final theme object with the overrides and component variables
29
29
  */
30
30
  const generateComponentTheme = theme => {
31
- var _colors$contrasts, _colors$contrasts2, _colors$contrasts3, _colors$contrasts4, _colors$contrasts5, _colors$contrasts6, _colors$contrasts7, _colors$contrasts8, _colors$contrasts9, _colors$contrasts0, _colors$contrasts1;
32
- const spacing = theme.spacing,
33
- borders = theme.borders,
34
- colors = theme.colors,
35
- forms = theme.forms,
36
- shadows = theme.shadows,
37
- typography = theme.typography,
38
- themeName = theme.key;
31
+ const {
32
+ spacing,
33
+ borders,
34
+ colors,
35
+ forms,
36
+ shadows,
37
+ typography,
38
+ key: themeName
39
+ } = theme;
39
40
  const themeSpecificStyle = {
40
41
  canvas: {
41
42
  focusBorderColor: theme['ic-brand-primary'],
@@ -43,47 +44,47 @@ const generateComponentTheme = theme => {
43
44
  labelColor: theme['ic-brand-font-color-dark']
44
45
  },
45
46
  'canvas-high-contrast': {
46
- toggleBackgroundOff: colors === null || colors === void 0 ? void 0 : (_colors$contrasts = colors.contrasts) === null || _colors$contrasts === void 0 ? void 0 : _colors$contrasts.grey125125
47
+ toggleBackgroundOff: colors?.contrasts?.grey125125
47
48
  }
48
49
  };
49
50
  const componentVariables = {
50
- labelColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts2 = colors.contrasts) === null || _colors$contrasts2 === void 0 ? void 0 : _colors$contrasts2.grey125125,
51
- labelFontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
52
- labelFontWeight: typography === null || typography === void 0 ? void 0 : typography.fontWeightNormal,
53
- labelLineHeight: typography === null || typography === void 0 ? void 0 : typography.lineHeightCondensed,
54
- background: colors === null || colors === void 0 ? void 0 : (_colors$contrasts3 = colors.contrasts) === null || _colors$contrasts3 === void 0 ? void 0 : _colors$contrasts3.white1010,
55
- borderWidth: borders === null || borders === void 0 ? void 0 : borders.widthSmall,
56
- borderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts4 = colors.contrasts) === null || _colors$contrasts4 === void 0 ? void 0 : _colors$contrasts4.grey3045,
57
- hoverBorderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts5 = colors.contrasts) === null || _colors$contrasts5 === void 0 ? void 0 : _colors$contrasts5.grey125125,
51
+ labelColor: colors?.contrasts?.grey125125,
52
+ labelFontFamily: typography?.fontFamily,
53
+ labelFontWeight: typography?.fontWeightNormal,
54
+ labelLineHeight: typography?.lineHeightCondensed,
55
+ background: colors?.contrasts?.white1010,
56
+ borderWidth: borders?.widthSmall,
57
+ borderColor: colors?.contrasts?.grey3045,
58
+ hoverBorderColor: colors?.contrasts?.grey125125,
58
59
  controlSize: '0.1875rem',
59
- focusBorderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts6 = colors.contrasts) === null || _colors$contrasts6 === void 0 ? void 0 : _colors$contrasts6.blue4570,
60
- focusBorderWidth: borders === null || borders === void 0 ? void 0 : borders.widthMedium,
61
- focusBorderStyle: borders === null || borders === void 0 ? void 0 : borders.style,
60
+ focusBorderColor: colors?.contrasts?.blue4570,
61
+ focusBorderWidth: borders?.widthMedium,
62
+ focusBorderStyle: borders?.style,
62
63
  simpleFacadeSmallSize: '1rem',
63
64
  simpleFacadeMediumSize: '1.25rem',
64
65
  simpleFacadeLargeSize: '1.75rem',
65
66
  simpleCheckedInsetSmall: '0.1875rem',
66
67
  simpleCheckedInsetMedium: '0.25rem',
67
68
  simpleCheckedInsetLarge: '0.375rem',
68
- simpleFontSizeSmall: typography === null || typography === void 0 ? void 0 : typography.fontSizeSmall,
69
- simpleFontSizeMedium: typography === null || typography === void 0 ? void 0 : typography.fontSizeMedium,
70
- simpleFontSizeLarge: typography === null || typography === void 0 ? void 0 : typography.fontSizeLarge,
71
- simpleFacadeMarginEnd: spacing === null || spacing === void 0 ? void 0 : spacing.xSmall,
72
- toggleBorderRadius: borders === null || borders === void 0 ? void 0 : borders.radiusSmall,
73
- toggleBorderWidth: borders === null || borders === void 0 ? void 0 : borders.widthLarge,
74
- toggleBackgroundSuccess: colors === null || colors === void 0 ? void 0 : (_colors$contrasts7 = colors.contrasts) === null || _colors$contrasts7 === void 0 ? void 0 : _colors$contrasts7.green4570,
75
- toggleBackgroundOff: colors === null || colors === void 0 ? void 0 : (_colors$contrasts8 = colors.contrasts) === null || _colors$contrasts8 === void 0 ? void 0 : _colors$contrasts8.green4570,
76
- toggleBackgroundDanger: colors === null || colors === void 0 ? void 0 : (_colors$contrasts9 = colors.contrasts) === null || _colors$contrasts9 === void 0 ? void 0 : _colors$contrasts9.orange4570,
77
- toggleBackgroundWarning: colors === null || colors === void 0 ? void 0 : (_colors$contrasts0 = colors.contrasts) === null || _colors$contrasts0 === void 0 ? void 0 : _colors$contrasts0.orange4570,
78
- toggleHandleText: colors === null || colors === void 0 ? void 0 : (_colors$contrasts1 = colors.contrasts) === null || _colors$contrasts1 === void 0 ? void 0 : _colors$contrasts1.white1010,
79
- toggleSmallHeight: forms === null || forms === void 0 ? void 0 : forms.inputHeightSmall,
80
- toggleMediumHeight: forms === null || forms === void 0 ? void 0 : forms.inputHeightMedium,
81
- toggleLargeHeight: forms === null || forms === void 0 ? void 0 : forms.inputHeightLarge,
82
- toggleShadow: shadows === null || shadows === void 0 ? void 0 : shadows.depth1,
69
+ simpleFontSizeSmall: typography?.fontSizeSmall,
70
+ simpleFontSizeMedium: typography?.fontSizeMedium,
71
+ simpleFontSizeLarge: typography?.fontSizeLarge,
72
+ simpleFacadeMarginEnd: spacing?.xSmall,
73
+ toggleBorderRadius: borders?.radiusSmall,
74
+ toggleBorderWidth: borders?.widthLarge,
75
+ toggleBackgroundSuccess: colors?.contrasts?.green4570,
76
+ toggleBackgroundOff: colors?.contrasts?.green4570,
77
+ toggleBackgroundDanger: colors?.contrasts?.orange4570,
78
+ toggleBackgroundWarning: colors?.contrasts?.orange4570,
79
+ toggleHandleText: colors?.contrasts?.white1010,
80
+ toggleSmallHeight: forms?.inputHeightSmall,
81
+ toggleMediumHeight: forms?.inputHeightMedium,
82
+ toggleLargeHeight: forms?.inputHeightLarge,
83
+ toggleShadow: shadows?.depth1,
83
84
  // toggle font is uppercase, so sizes are smaller below
84
- toggleSmallFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeXSmall,
85
- toggleMediumFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeSmall,
86
- toggleLargeFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeMedium
85
+ toggleSmallFontSize: typography?.fontSizeXSmall,
86
+ toggleMediumFontSize: typography?.fontSizeSmall,
87
+ toggleLargeFontSize: typography?.fontSizeMedium
87
88
  };
88
89
  return {
89
90
  ...componentVariables,
@@ -1,6 +1,3 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- const _excluded = ["variant", "size", "disabled", "inline", "context", "readOnly", "id", "label", "value", "name", "checked", "onClick", "onChange", "inputRef", "themeOverride"];
4
1
  /*
5
2
  * The MIT License (MIT)
6
3
  *
@@ -37,47 +34,34 @@ category: components
37
34
  ---
38
35
  **/
39
36
  const RadioInput = /*#__PURE__*/forwardRef((props, ref) => {
40
- const _props$variant = props.variant,
41
- variant = _props$variant === void 0 ? 'simple' : _props$variant,
42
- _props$size = props.size,
43
- size = _props$size === void 0 ? 'medium' : _props$size,
44
- _props$disabled = props.disabled,
45
- disabled = _props$disabled === void 0 ? false : _props$disabled,
46
- _props$inline = props.inline,
47
- inline = _props$inline === void 0 ? false : _props$inline,
48
- _props$context = props.context,
49
- context = _props$context === void 0 ? 'success' : _props$context,
50
- _props$readOnly = props.readOnly,
51
- readOnly = _props$readOnly === void 0 ? false : _props$readOnly,
52
- idProp = props.id,
53
- label = props.label,
54
- value = props.value,
55
- name = props.name,
56
- checkedProp = props.checked,
57
- onClick = props.onClick,
58
- onChange = props.onChange,
59
- inputRef = props.inputRef,
60
- themeOverride = props.themeOverride,
61
- rest = _objectWithoutProperties(props, _excluded);
62
- const _useState = useState(false),
63
- _useState2 = _slicedToArray(_useState, 2),
64
- hovered = _useState2[0],
65
- setHovered = _useState2[1];
37
+ const {
38
+ variant = 'simple',
39
+ size = 'medium',
40
+ disabled = false,
41
+ inline = false,
42
+ context = 'success',
43
+ readOnly = false,
44
+ id: idProp,
45
+ label,
46
+ value,
47
+ name,
48
+ checked: checkedProp,
49
+ onClick,
50
+ onChange,
51
+ inputRef,
52
+ themeOverride,
53
+ ...rest
54
+ } = props;
55
+ const [hovered, setHovered] = useState(false);
66
56
  // State for uncontrolled mode
67
- const _useState3 = useState(false),
68
- _useState4 = _slicedToArray(_useState3, 2),
69
- internalChecked = _useState4[0],
70
- setInternalChecked = _useState4[1];
57
+ const [internalChecked, setInternalChecked] = useState(false);
71
58
 
72
59
  // Refs
73
60
  const containerRef = useRef(null);
74
61
  const inputElementRef = useRef(null);
75
62
 
76
63
  // Deterministic ID generation
77
- const _useState5 = useState(),
78
- _useState6 = _slicedToArray(_useState5, 2),
79
- deterministicId = _useState6[0],
80
- setDeterministicId = _useState6[1];
64
+ const [deterministicId, setDeterministicId] = useState();
81
65
  const getId = useDeterministicId('RadioInput');
82
66
  useEffect(() => {
83
67
  setDeterministicId(getId());
@@ -136,8 +120,7 @@ const RadioInput = /*#__PURE__*/forwardRef((props, ref) => {
136
120
  // Expose imperative API via ref
137
121
  useImperativeHandle(ref, () => ({
138
122
  focus: () => {
139
- var _inputElementRef$curr;
140
- (_inputElementRef$curr = inputElementRef.current) === null || _inputElementRef$curr === void 0 ? void 0 : _inputElementRef$curr.focus();
123
+ inputElementRef.current?.focus();
141
124
  },
142
125
  get focused() {
143
126
  return isActiveElement(inputElementRef.current);
@@ -158,7 +141,7 @@ const RadioInput = /*#__PURE__*/forwardRef((props, ref) => {
158
141
  };
159
142
  const passedProps = passthroughProps(rest);
160
143
  return _jsxs("div", {
161
- css: styles === null || styles === void 0 ? void 0 : styles.radioInput,
144
+ css: styles?.radioInput,
162
145
  "data-cid": "RadioInput",
163
146
  ref: containerRef
164
147
  /* eslint-disable-next-line jsx-a11y/mouse-events-have-key-events */,
@@ -173,14 +156,14 @@ const RadioInput = /*#__PURE__*/forwardRef((props, ref) => {
173
156
  name: name,
174
157
  checked: checked,
175
158
  type: "radio",
176
- css: styles === null || styles === void 0 ? void 0 : styles.input,
159
+ css: styles?.input,
177
160
  readOnly: readOnly,
178
161
  disabled: disabled,
179
162
  onChange: handleChange,
180
163
  onClick: handleClick
181
164
  }), _jsx("label", {
182
165
  htmlFor: id,
183
- css: styles === null || styles === void 0 ? void 0 : styles.label,
166
+ css: styles?.label,
184
167
  children: label
185
168
  })]
186
169
  });
@@ -35,14 +35,15 @@ import { calcFocusOutlineStyles } from '@instructure/emotion';
35
35
  * @return The final style object, which will be used in the component
36
36
  */
37
37
  const generateStyle = (componentTheme, params, sharedTokens) => {
38
- var _toggleContextBackgro;
39
- const disabled = params.disabled,
40
- inline = params.inline,
41
- hovered = params.hovered,
42
- size = params.size,
43
- readOnly = params.readOnly,
44
- variant = params.variant,
45
- context = params.context;
38
+ const {
39
+ disabled,
40
+ inline,
41
+ hovered,
42
+ size,
43
+ readOnly,
44
+ variant,
45
+ context
46
+ } = params;
46
47
 
47
48
  // 4*2 states: base, hover, disabled, readonly X none/selected
48
49
  const insetSizes = {
@@ -98,7 +99,7 @@ const generateStyle = (componentTheme, params, sharedTokens) => {
98
99
  danger: componentTheme.toggleBackgroundDanger,
99
100
  off: componentTheme.toggleBackgroundOff
100
101
  };
101
- const toggleBackground = (_toggleContextBackgro = toggleContextBackgrounds[context !== null && context !== void 0 ? context : 'success']) !== null && _toggleContextBackgro !== void 0 ? _toggleContextBackgro : toggleContextBackgrounds['success'];
102
+ const toggleBackground = toggleContextBackgrounds[context ?? 'success'] ?? toggleContextBackgrounds['success'];
102
103
  const focusOutline = calcFocusOutlineStyles(sharedTokens.focusOutline);
103
104
  focusOutline.transition += ', box-shadow 0.2s';
104
105
  const inputVariants = {
@@ -1,4 +1,4 @@
1
- var _dec, _dec2, _class, _RadioInputGroup;
1
+ var _dec, _dec2, _class;
2
2
  /*
3
3
  * The MIT License (MIT)
4
4
  *
@@ -38,29 +38,24 @@ import { jsxs as _jsxs, jsx as _jsx } from "@emotion/react/jsx-runtime";
38
38
  category: components
39
39
  ---
40
40
  **/
41
- let RadioInputGroup = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec(_class = _dec2(_class = (_RadioInputGroup = class RadioInputGroup extends Component {
41
+ let RadioInputGroup = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec(_class = _dec2(_class = class RadioInputGroup extends Component {
42
+ static displayName = "RadioInputGroup";
43
+ static componentId = 'RadioInputGroup';
44
+ static allowedProps = allowedProps;
45
+ static defaultProps = {
46
+ disabled: false,
47
+ variant: 'simple',
48
+ size: 'medium',
49
+ layout: 'stacked',
50
+ readOnly: false
51
+ };
52
+ ref = null;
53
+ _messagesId;
54
+ handleRef = el => {
55
+ this.ref = el;
56
+ };
42
57
  constructor(props) {
43
58
  super(props);
44
- this.ref = null;
45
- this._messagesId = void 0;
46
- this.handleRef = el => {
47
- this.ref = el;
48
- };
49
- this.handleChange = e => {
50
- const value = e.target.value;
51
- if (this.props.disabled || this.props.readOnly) {
52
- e.preventDefault();
53
- return;
54
- }
55
- if (typeof this.props.value === 'undefined') {
56
- this.setState({
57
- value
58
- });
59
- }
60
- if (typeof this.props.onChange === 'function') {
61
- this.props.onChange(e, value);
62
- }
63
- };
64
59
  if (typeof props.value === 'undefined') {
65
60
  this.state = {
66
61
  value: props.defaultValue
@@ -72,20 +67,35 @@ let RadioInputGroup = (_dec = withDeterministicId(), _dec2 = withStyle(generateS
72
67
  return !!this.props.messages && this.props.messages.length > 0;
73
68
  }
74
69
  get invalid() {
75
- var _this$props$messages;
76
- return !!((_this$props$messages = this.props.messages) !== null && _this$props$messages !== void 0 && _this$props$messages.find(m => m.type === 'newError' || m.type === 'error'));
70
+ return !!this.props.messages?.find(m => m.type === 'newError' || m.type === 'error');
77
71
  }
72
+ handleChange = e => {
73
+ const value = e.target.value;
74
+ if (this.props.disabled || this.props.readOnly) {
75
+ e.preventDefault();
76
+ return;
77
+ }
78
+ if (typeof this.props.value === 'undefined') {
79
+ this.setState({
80
+ value
81
+ });
82
+ }
83
+ if (typeof this.props.onChange === 'function') {
84
+ this.props.onChange(e, value);
85
+ }
86
+ };
78
87
  get value() {
79
88
  return typeof this.props.value === 'undefined' ? this.state.value : this.props.value;
80
89
  }
81
90
  renderChildren() {
82
- const _this$props = this.props,
83
- children = _this$props.children,
84
- name = _this$props.name,
85
- variant = _this$props.variant,
86
- size = _this$props.size,
87
- disabled = _this$props.disabled,
88
- readOnly = _this$props.readOnly;
91
+ const {
92
+ children,
93
+ name,
94
+ variant,
95
+ size,
96
+ disabled,
97
+ readOnly
98
+ } = this.props;
89
99
 
90
100
  // This adds the passed in name property to each RadioInput component
91
101
  // and checks the input whose value matches the value property
@@ -102,7 +112,7 @@ let RadioInputGroup = (_dec = withDeterministicId(), _dec2 = withStyle(generateS
102
112
  onChange: this.handleChange,
103
113
  readOnly: readOnly || child.props.readOnly,
104
114
  width: child.props.width || 'auto',
105
- 'aria-describedby': this.hasMessages ? this._messagesId : void 0,
115
+ 'aria-describedby': this.hasMessages ? this._messagesId : undefined,
106
116
  // only one radio in a group should be considered tabbable
107
117
  // if a radio is checked, it should be the input to receive focus when tabbed to
108
118
  // if none of the inputs are checked, the first should receive the focus
@@ -115,15 +125,16 @@ let RadioInputGroup = (_dec = withDeterministicId(), _dec2 = withStyle(generateS
115
125
  });
116
126
  }
117
127
  render() {
118
- const _this$props2 = this.props,
119
- variant = _this$props2.variant,
120
- layout = _this$props2.layout,
121
- description = _this$props2.description,
122
- isRequired = _this$props2.isRequired,
123
- styles = _this$props2.styles;
128
+ const {
129
+ variant,
130
+ layout,
131
+ description,
132
+ isRequired,
133
+ styles
134
+ } = this.props;
124
135
  const descriptionWithRequired = hasVisibleChildren(description) ? _jsxs(Fragment, {
125
136
  children: [description, isRequired && description && _jsxs("span", {
126
- css: this.invalid ? styles === null || styles === void 0 ? void 0 : styles.invalidAsterisk : {},
137
+ css: this.invalid ? styles?.invalidAsterisk : {},
127
138
  "aria-hidden": true,
128
139
  children: [' ', "*"]
129
140
  })]
@@ -138,7 +149,7 @@ let RadioInputGroup = (_dec = withDeterministicId(), _dec2 = withStyle(generateS
138
149
  rowSpacing: "small",
139
150
  colSpacing: variant === 'toggle' ? 'none' : 'small' // keep toggles close together
140
151
  ,
141
- startAt: variant === 'toggle' ? 'small' : void 0,
152
+ startAt: variant === 'toggle' ? 'small' : undefined,
142
153
  messagesId: this._messagesId,
143
154
  elementRef: this.handleRef,
144
155
  role: "radiogroup",
@@ -146,12 +157,6 @@ let RadioInputGroup = (_dec = withDeterministicId(), _dec2 = withStyle(generateS
146
157
  children: this.renderChildren()
147
158
  });
148
159
  }
149
- }, _RadioInputGroup.displayName = "RadioInputGroup", _RadioInputGroup.componentId = 'RadioInputGroup', _RadioInputGroup.allowedProps = allowedProps, _RadioInputGroup.defaultProps = {
150
- disabled: false,
151
- variant: 'simple',
152
- size: 'medium',
153
- layout: 'stacked',
154
- readOnly: false
155
- }, _RadioInputGroup)) || _class) || _class);
160
+ }) || _class) || _class);
156
161
  export default RadioInputGroup;
157
162
  export { RadioInputGroup };
@@ -31,7 +31,9 @@
31
31
  * @return {Object} The final style object, which will be used in the component
32
32
  */
33
33
  const generateStyle = componentTheme => {
34
- const invalidAsteriskColor = componentTheme.invalidAsteriskColor;
34
+ const {
35
+ invalidAsteriskColor
36
+ } = componentTheme;
35
37
  return {
36
38
  invalidAsterisk: {
37
39
  color: invalidAsteriskColor
@@ -28,10 +28,11 @@
28
28
  * @return {Object} The final theme object with the overrides and component variables
29
29
  */
30
30
  const generateComponentTheme = theme => {
31
- var _colors$primitives;
32
- const colors = theme.colors;
31
+ const {
32
+ colors
33
+ } = theme;
33
34
  const componentVariables = {
34
- invalidAsteriskColor: colors === null || colors === void 0 ? void 0 : (_colors$primitives = colors.primitives) === null || _colors$primitives === void 0 ? void 0 : _colors$primitives.red57
35
+ invalidAsteriskColor: colors?.primitives?.red57
35
36
  };
36
37
  return {
37
38
  ...componentVariables