@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 +5 -2
- package/es/RadioInput/v1/index.js +63 -61
- package/es/RadioInput/v1/styles.js +7 -5
- package/es/RadioInput/v1/theme.js +39 -38
- package/es/RadioInput/v2/index.js +25 -42
- package/es/RadioInput/v2/styles.js +10 -9
- package/es/RadioInputGroup/v1/index.js +52 -47
- package/es/RadioInputGroup/v1/styles.js +3 -1
- package/es/RadioInputGroup/v1/theme.js +4 -3
- package/es/RadioInputGroup/v2/index.js +50 -45
- package/lib/RadioInput/v1/index.js +63 -61
- package/lib/RadioInput/v1/styles.js +7 -5
- package/lib/RadioInput/v1/theme.js +39 -38
- package/lib/RadioInput/v2/index.js +26 -42
- package/lib/RadioInput/v2/styles.js +10 -9
- package/lib/RadioInputGroup/v1/index.js +52 -47
- package/lib/RadioInputGroup/v1/styles.js +3 -1
- package/lib/RadioInputGroup/v1/theme.js +4 -3
- package/lib/RadioInputGroup/v2/index.js +50 -45
- package/package.json +12 -12
- package/tsconfig.build.tsbuildinfo +1 -1
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-
|
|
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
|
-
|
|
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
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
104
|
-
disabled
|
|
105
|
-
readOnly
|
|
106
|
-
label
|
|
107
|
-
value
|
|
108
|
-
name
|
|
109
|
-
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
|
|
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
|
|
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
|
|
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
|
|
141
|
+
css: styles?.control,
|
|
133
142
|
htmlFor: this.id,
|
|
134
143
|
children: [_jsx("span", {
|
|
135
|
-
css: styles
|
|
144
|
+
css: styles?.facade,
|
|
136
145
|
"aria-hidden": "true"
|
|
137
146
|
}), _jsx("span", {
|
|
138
|
-
css: styles
|
|
147
|
+
css: styles?.label,
|
|
139
148
|
children: label
|
|
140
149
|
})]
|
|
141
150
|
})]
|
|
142
151
|
})
|
|
143
152
|
});
|
|
144
153
|
}
|
|
145
|
-
}
|
|
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
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
borders
|
|
34
|
-
colors
|
|
35
|
-
forms
|
|
36
|
-
shadows
|
|
37
|
-
typography
|
|
38
|
-
themeName
|
|
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
|
|
47
|
+
toggleBackgroundOff: colors?.contrasts?.grey125125
|
|
47
48
|
}
|
|
48
49
|
};
|
|
49
50
|
const componentVariables = {
|
|
50
|
-
labelColor: colors
|
|
51
|
-
labelFontFamily: typography
|
|
52
|
-
labelFontWeight: typography
|
|
53
|
-
labelLineHeight: typography
|
|
54
|
-
background: colors
|
|
55
|
-
borderWidth: borders
|
|
56
|
-
borderColor: colors
|
|
57
|
-
hoverBorderColor: colors
|
|
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
|
|
60
|
-
focusBorderWidth: borders
|
|
61
|
-
focusBorderStyle: borders
|
|
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
|
|
69
|
-
simpleFontSizeMedium: typography
|
|
70
|
-
simpleFontSizeLarge: typography
|
|
71
|
-
simpleFacadeMarginEnd: spacing
|
|
72
|
-
toggleBorderRadius: borders
|
|
73
|
-
toggleBorderWidth: borders
|
|
74
|
-
toggleBackgroundSuccess: colors
|
|
75
|
-
toggleBackgroundOff: colors
|
|
76
|
-
toggleBackgroundDanger: colors
|
|
77
|
-
toggleBackgroundWarning: colors
|
|
78
|
-
toggleHandleText: colors
|
|
79
|
-
toggleSmallHeight: forms
|
|
80
|
-
toggleMediumHeight: forms
|
|
81
|
-
toggleLargeHeight: forms
|
|
82
|
-
toggleShadow: shadows
|
|
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
|
|
85
|
-
toggleMediumFontSize: typography
|
|
86
|
-
toggleLargeFontSize: typography
|
|
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
|
|
41
|
-
variant =
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
inline
|
|
41
|
-
hovered
|
|
42
|
-
size
|
|
43
|
-
readOnly
|
|
44
|
-
variant
|
|
45
|
-
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 =
|
|
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
|
|
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 =
|
|
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
|
-
|
|
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
|
|
83
|
-
children
|
|
84
|
-
name
|
|
85
|
-
variant
|
|
86
|
-
size
|
|
87
|
-
disabled
|
|
88
|
-
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 :
|
|
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
|
|
119
|
-
variant
|
|
120
|
-
layout
|
|
121
|
-
description
|
|
122
|
-
isRequired
|
|
123
|
-
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
|
|
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' :
|
|
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
|
-
}
|
|
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
|
|
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
|
-
|
|
32
|
-
|
|
31
|
+
const {
|
|
32
|
+
colors
|
|
33
|
+
} = theme;
|
|
33
34
|
const componentVariables = {
|
|
34
|
-
invalidAsteriskColor: colors
|
|
35
|
+
invalidAsteriskColor: colors?.primitives?.red57
|
|
35
36
|
};
|
|
36
37
|
return {
|
|
37
38
|
...componentVariables
|