@instructure/ui-radio-input 8.13.1-snapshot.9 → 8.14.1-snapshot.6
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 +4 -0
- package/es/RadioInput/RadioInputLocator.js +2 -1
- package/es/RadioInput/index.js +16 -9
- package/es/RadioInput/props.js +0 -8
- package/es/RadioInput/styles.js +1 -0
- package/es/RadioInputGroup/RadioInputGroupLocator.js +2 -1
- package/es/RadioInputGroup/index.js +24 -23
- package/es/RadioInputGroup/props.js +0 -26
- package/lib/RadioInput/RadioInputLocator.js +1 -0
- package/lib/RadioInput/index.js +18 -9
- package/lib/RadioInput/props.js +0 -8
- package/lib/RadioInput/styles.js +1 -0
- package/lib/RadioInputGroup/RadioInputGroupLocator.js +1 -0
- package/lib/RadioInputGroup/index.js +23 -22
- package/lib/RadioInputGroup/props.js +0 -26
- package/package.json +15 -15
- package/src/RadioInput/index.tsx +23 -31
- package/src/RadioInput/props.ts +16 -10
- package/src/RadioInputGroup/index.tsx +30 -31
- package/src/RadioInputGroup/props.ts +41 -24
- package/tsconfig.build.json +19 -2
- package/tsconfig.build.tsbuildinfo +1 -0
- package/types/RadioInput/RadioInputLocator.d.ts +52 -52
- package/types/RadioInput/index.d.ts +17 -16
- package/types/RadioInput/index.d.ts.map +1 -1
- package/types/RadioInput/props.d.ts +14 -4
- package/types/RadioInput/props.d.ts.map +1 -1
- package/types/RadioInputGroup/RadioInputGroupLocator.d.ts +52 -52
- package/types/RadioInputGroup/index.d.ts +13 -11
- package/types/RadioInputGroup/index.d.ts.map +1 -1
- package/types/RadioInputGroup/props.d.ts +27 -3
- package/types/RadioInputGroup/props.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
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
|
+
# [8.14.0](https://github.com/instructure/instructure-ui/compare/v8.13.0...v8.14.0) (2021-12-16)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-radio-input
|
|
9
|
+
|
|
6
10
|
# [8.13.0](https://github.com/instructure/instructure-ui/compare/v8.12.0...v8.13.0) (2021-12-01)
|
|
7
11
|
|
|
8
12
|
### Features
|
|
@@ -22,5 +22,6 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
import { locator } from '@instructure/ui-test-locator';
|
|
25
|
-
import { RadioInput } from './index';
|
|
25
|
+
import { RadioInput } from './index'; // @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
26
|
+
|
|
26
27
|
export const RadioInputLocator = locator(RadioInput.selector);
|
package/es/RadioInput/index.js
CHANGED
|
@@ -25,7 +25,7 @@ var _dec, _dec2, _class, _class2, _temp;
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
/** @jsx jsx */
|
|
28
|
-
import { Component } from 'react';
|
|
28
|
+
import React, { Component } from 'react';
|
|
29
29
|
import { uid } from '@instructure/uid';
|
|
30
30
|
import { testable } from '@instructure/ui-testable';
|
|
31
31
|
import { omitProps } from '@instructure/ui-react-utils';
|
|
@@ -38,12 +38,15 @@ import { allowedProps, propTypes } from './props';
|
|
|
38
38
|
---
|
|
39
39
|
category: components
|
|
40
40
|
---
|
|
41
|
+
@tsProps
|
|
41
42
|
**/
|
|
42
43
|
|
|
43
44
|
let RadioInput = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_temp = _class2 = class RadioInput extends Component {
|
|
44
45
|
constructor(props) {
|
|
45
46
|
super(props);
|
|
46
47
|
this.ref = null;
|
|
48
|
+
this._defaultId = void 0;
|
|
49
|
+
this._input = null;
|
|
47
50
|
|
|
48
51
|
this.handleClick = e => {
|
|
49
52
|
if (this.props.disabled || this.props.readOnly) {
|
|
@@ -51,7 +54,9 @@ let RadioInput = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2
|
|
|
51
54
|
return;
|
|
52
55
|
}
|
|
53
56
|
|
|
54
|
-
this.props.onClick
|
|
57
|
+
if (typeof this.props.onClick === 'function') {
|
|
58
|
+
this.props.onClick(e);
|
|
59
|
+
}
|
|
55
60
|
};
|
|
56
61
|
|
|
57
62
|
this.handleChange = e => {
|
|
@@ -66,13 +71,15 @@ let RadioInput = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2
|
|
|
66
71
|
});
|
|
67
72
|
}
|
|
68
73
|
|
|
69
|
-
this.props.onChange
|
|
74
|
+
if (typeof this.props.onChange === 'function') {
|
|
75
|
+
this.props.onChange(e);
|
|
76
|
+
}
|
|
70
77
|
};
|
|
71
78
|
|
|
72
|
-
this.state = {};
|
|
73
|
-
|
|
74
79
|
if (typeof props.checked === 'undefined') {
|
|
75
|
-
this.state
|
|
80
|
+
this.state = {
|
|
81
|
+
checked: false
|
|
82
|
+
};
|
|
76
83
|
}
|
|
77
84
|
|
|
78
85
|
this._defaultId = uid('RadioInput');
|
|
@@ -91,7 +98,9 @@ let RadioInput = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2
|
|
|
91
98
|
}
|
|
92
99
|
|
|
93
100
|
focus() {
|
|
94
|
-
|
|
101
|
+
var _this$_input;
|
|
102
|
+
|
|
103
|
+
(_this$_input = this._input) === null || _this$_input === void 0 ? void 0 : _this$_input.focus();
|
|
95
104
|
}
|
|
96
105
|
|
|
97
106
|
get id() {
|
|
@@ -146,8 +155,6 @@ let RadioInput = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2
|
|
|
146
155
|
}
|
|
147
156
|
|
|
148
157
|
}, _class2.displayName = "RadioInput", _class2.componentId = 'RadioInput', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
149
|
-
onClick: function (event) {},
|
|
150
|
-
onChange: function (event) {},
|
|
151
158
|
variant: 'simple',
|
|
152
159
|
size: 'medium',
|
|
153
160
|
disabled: false,
|
package/es/RadioInput/props.js
CHANGED
|
@@ -28,15 +28,7 @@ const propTypes = {
|
|
|
28
28
|
id: PropTypes.string,
|
|
29
29
|
name: PropTypes.string,
|
|
30
30
|
checked: PropTypes.bool,
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Whether or not to disable the input
|
|
34
|
-
*/
|
|
35
31
|
disabled: PropTypes.bool,
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Works just like disabled but keeps the same styles as if it were active
|
|
39
|
-
*/
|
|
40
32
|
readOnly: PropTypes.bool,
|
|
41
33
|
variant: PropTypes.oneOf(['simple', 'toggle']),
|
|
42
34
|
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
package/es/RadioInput/styles.js
CHANGED
|
@@ -22,5 +22,6 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
import { locator } from '@instructure/ui-test-locator';
|
|
25
|
-
import { RadioInputGroup } from './index';
|
|
25
|
+
import { RadioInputGroup } from './index'; // @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
26
|
+
|
|
26
27
|
export const RadioInputGroupLocator = locator(RadioInputGroup.selector);
|
|
@@ -30,16 +30,18 @@ import { testable } from '@instructure/ui-testable';
|
|
|
30
30
|
import { matchComponentTypes, safeCloneElement, omitProps, pickProps } from '@instructure/ui-react-utils';
|
|
31
31
|
import { RadioInput } from '../RadioInput';
|
|
32
32
|
import { allowedProps, propTypes } from './props';
|
|
33
|
+
|
|
33
34
|
/**
|
|
34
35
|
---
|
|
35
36
|
category: components
|
|
36
37
|
---
|
|
38
|
+
@tsProps
|
|
37
39
|
**/
|
|
38
|
-
|
|
39
40
|
let RadioInputGroup = (_dec = testable(), _dec(_class = (_temp = _class2 = class RadioInputGroup extends Component {
|
|
40
41
|
constructor(props) {
|
|
41
|
-
super();
|
|
42
|
+
super(props);
|
|
42
43
|
this.ref = null;
|
|
44
|
+
this._messagesId = void 0;
|
|
43
45
|
|
|
44
46
|
this.handleRef = el => {
|
|
45
47
|
this.ref = el;
|
|
@@ -74,7 +76,7 @@ let RadioInputGroup = (_dec = testable(), _dec(_class = (_temp = _class2 = class
|
|
|
74
76
|
}
|
|
75
77
|
|
|
76
78
|
get hasMessages() {
|
|
77
|
-
return this.props.messages && this.props.messages.length > 0;
|
|
79
|
+
return !!this.props.messages && this.props.messages.length > 0;
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
get value() {
|
|
@@ -104,11 +106,12 @@ let RadioInputGroup = (_dec = testable(), _dec(_class = (_temp = _class2 = class
|
|
|
104
106
|
onChange: this.handleChange,
|
|
105
107
|
readOnly: readOnly || child.props.readOnly,
|
|
106
108
|
width: child.props.width || 'auto',
|
|
107
|
-
'aria-describedby': this.hasMessages
|
|
109
|
+
'aria-describedby': this.hasMessages ? this._messagesId : void 0,
|
|
108
110
|
// only one radio in a group should be considered tabbable
|
|
109
111
|
// if a radio is checked, it should be the input to receive focus when tabbed to
|
|
110
112
|
// if none of the inputs are checked, the first should receive the focus
|
|
111
|
-
tabIndex: isChecked || defaultFocus ?
|
|
113
|
+
tabIndex: isChecked || defaultFocus ? 0 : -1,
|
|
114
|
+
label: child.props.label
|
|
112
115
|
});
|
|
113
116
|
} else {
|
|
114
117
|
return child; // ignore (but preserve) children that aren't RadioInput
|
|
@@ -119,22 +122,21 @@ let RadioInputGroup = (_dec = testable(), _dec(_class = (_temp = _class2 = class
|
|
|
119
122
|
render() {
|
|
120
123
|
const _this$props2 = this.props,
|
|
121
124
|
variant = _this$props2.variant,
|
|
122
|
-
layout = _this$props2.layout
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
);
|
|
125
|
+
layout = _this$props2.layout,
|
|
126
|
+
description = _this$props2.description;
|
|
127
|
+
return /*#__PURE__*/React.createElement(FormFieldGroup, Object.assign({}, omitProps(this.props, RadioInputGroup.allowedProps), pickProps(this.props, FormFieldGroup.allowedProps), {
|
|
128
|
+
description: description // TODO: split out toggle variant into its own component
|
|
129
|
+
,
|
|
130
|
+
layout: layout === 'columns' && variant === 'toggle' ? 'stacked' : layout // toggles already display in cols
|
|
131
|
+
,
|
|
132
|
+
vAlign: variant === 'toggle' ? 'middle' : 'top',
|
|
133
|
+
rowSpacing: "small",
|
|
134
|
+
colSpacing: variant === 'toggle' ? 'none' : 'small' // keep toggles close together
|
|
135
|
+
,
|
|
136
|
+
startAt: variant === 'toggle' ? 'small' : void 0,
|
|
137
|
+
messagesId: this._messagesId,
|
|
138
|
+
elementRef: this.handleRef
|
|
139
|
+
}), this.renderChildren());
|
|
138
140
|
}
|
|
139
141
|
|
|
140
142
|
}, _class2.displayName = "RadioInputGroup", _class2.componentId = 'RadioInputGroup', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
@@ -142,8 +144,7 @@ let RadioInputGroup = (_dec = testable(), _dec(_class = (_temp = _class2 = class
|
|
|
142
144
|
variant: 'simple',
|
|
143
145
|
size: 'medium',
|
|
144
146
|
layout: 'stacked',
|
|
145
|
-
readOnly: false
|
|
146
|
-
children: null
|
|
147
|
+
readOnly: false
|
|
147
148
|
}, _temp)) || _class);
|
|
148
149
|
export default RadioInputGroup;
|
|
149
150
|
export { RadioInputGroup };
|
|
@@ -27,40 +27,14 @@ import { FormPropTypes } from '@instructure/ui-form-field';
|
|
|
27
27
|
const propTypes = {
|
|
28
28
|
name: PropTypes.string.isRequired,
|
|
29
29
|
description: PropTypes.node.isRequired,
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* value to set on initial render
|
|
33
|
-
*/
|
|
34
30
|
defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* the selected value (must be accompanied by an `onChange` prop)
|
|
38
|
-
*/
|
|
39
31
|
value: controllable(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* when used with the `value` prop, the component will not control its own state
|
|
43
|
-
*/
|
|
44
32
|
onChange: PropTypes.func,
|
|
45
33
|
disabled: PropTypes.bool,
|
|
46
|
-
|
|
47
|
-
/** works just like disabled but keeps the same styles as if it were active */
|
|
48
34
|
readOnly: PropTypes.bool,
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* object with shape: `{
|
|
52
|
-
* text: PropTypes.node,
|
|
53
|
-
* type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
|
|
54
|
-
* }`
|
|
55
|
-
*/
|
|
56
35
|
messages: PropTypes.arrayOf(FormPropTypes.message),
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* any children (ones that aren't `RadioInput` are passed through)
|
|
60
|
-
*/
|
|
61
36
|
children: PropTypes.node,
|
|
62
37
|
variant: PropTypes.oneOf(['simple', 'toggle']),
|
|
63
|
-
// TODO: split toggle out to its own component
|
|
64
38
|
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
65
39
|
layout: PropTypes.oneOf(['stacked', 'columns', 'inline'])
|
|
66
40
|
};
|
|
@@ -32,5 +32,6 @@ var _index = require("./index");
|
|
|
32
32
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
33
|
* SOFTWARE.
|
|
34
34
|
*/
|
|
35
|
+
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
35
36
|
const RadioInputLocator = (0, _locator.locator)(_index.RadioInput.selector);
|
|
36
37
|
exports.RadioInputLocator = RadioInputLocator;
|
package/lib/RadioInput/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
|
|
3
5
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
6
|
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -7,7 +9,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
9
|
});
|
|
8
10
|
exports.default = exports.RadioInput = void 0;
|
|
9
11
|
|
|
10
|
-
var _react = require("react");
|
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
13
|
|
|
12
14
|
var _uid = require("@instructure/uid");
|
|
13
15
|
|
|
@@ -31,11 +33,14 @@ var _dec, _dec2, _class, _class2, _temp;
|
|
|
31
33
|
---
|
|
32
34
|
category: components
|
|
33
35
|
---
|
|
36
|
+
@tsProps
|
|
34
37
|
**/
|
|
35
38
|
let RadioInput = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_temp = _class2 = class RadioInput extends _react.Component {
|
|
36
39
|
constructor(props) {
|
|
37
40
|
super(props);
|
|
38
41
|
this.ref = null;
|
|
42
|
+
this._defaultId = void 0;
|
|
43
|
+
this._input = null;
|
|
39
44
|
|
|
40
45
|
this.handleClick = e => {
|
|
41
46
|
if (this.props.disabled || this.props.readOnly) {
|
|
@@ -43,7 +48,9 @@ let RadioInput = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
|
|
|
43
48
|
return;
|
|
44
49
|
}
|
|
45
50
|
|
|
46
|
-
this.props.onClick
|
|
51
|
+
if (typeof this.props.onClick === 'function') {
|
|
52
|
+
this.props.onClick(e);
|
|
53
|
+
}
|
|
47
54
|
};
|
|
48
55
|
|
|
49
56
|
this.handleChange = e => {
|
|
@@ -58,13 +65,15 @@ let RadioInput = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
|
|
|
58
65
|
});
|
|
59
66
|
}
|
|
60
67
|
|
|
61
|
-
this.props.onChange
|
|
68
|
+
if (typeof this.props.onChange === 'function') {
|
|
69
|
+
this.props.onChange(e);
|
|
70
|
+
}
|
|
62
71
|
};
|
|
63
72
|
|
|
64
|
-
this.state = {};
|
|
65
|
-
|
|
66
73
|
if (typeof props.checked === 'undefined') {
|
|
67
|
-
this.state
|
|
74
|
+
this.state = {
|
|
75
|
+
checked: false
|
|
76
|
+
};
|
|
68
77
|
}
|
|
69
78
|
|
|
70
79
|
this._defaultId = (0, _uid.uid)('RadioInput');
|
|
@@ -83,7 +92,9 @@ let RadioInput = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
|
|
|
83
92
|
}
|
|
84
93
|
|
|
85
94
|
focus() {
|
|
86
|
-
|
|
95
|
+
var _this$_input;
|
|
96
|
+
|
|
97
|
+
(_this$_input = this._input) === null || _this$_input === void 0 ? void 0 : _this$_input.focus();
|
|
87
98
|
}
|
|
88
99
|
|
|
89
100
|
get id() {
|
|
@@ -138,8 +149,6 @@ let RadioInput = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
|
|
|
138
149
|
}
|
|
139
150
|
|
|
140
151
|
}, _class2.displayName = "RadioInput", _class2.componentId = 'RadioInput', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
141
|
-
onClick: function (event) {},
|
|
142
|
-
onChange: function (event) {},
|
|
143
152
|
variant: 'simple',
|
|
144
153
|
size: 'medium',
|
|
145
154
|
disabled: false,
|
package/lib/RadioInput/props.js
CHANGED
|
@@ -38,15 +38,7 @@ const propTypes = {
|
|
|
38
38
|
id: _propTypes.default.string,
|
|
39
39
|
name: _propTypes.default.string,
|
|
40
40
|
checked: _propTypes.default.bool,
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Whether or not to disable the input
|
|
44
|
-
*/
|
|
45
41
|
disabled: _propTypes.default.bool,
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Works just like disabled but keeps the same styles as if it were active
|
|
49
|
-
*/
|
|
50
42
|
readOnly: _propTypes.default.bool,
|
|
51
43
|
variant: _propTypes.default.oneOf(['simple', 'toggle']),
|
|
52
44
|
size: _propTypes.default.oneOf(['small', 'medium', 'large']),
|
package/lib/RadioInput/styles.js
CHANGED
|
@@ -32,5 +32,6 @@ var _index = require("./index");
|
|
|
32
32
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
33
|
* SOFTWARE.
|
|
34
34
|
*/
|
|
35
|
+
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
35
36
|
const RadioInputGroupLocator = (0, _locator.locator)(_index.RadioInputGroup.selector);
|
|
36
37
|
exports.RadioInputGroupLocator = RadioInputGroupLocator;
|
|
@@ -33,11 +33,13 @@ var _dec, _class, _class2, _temp;
|
|
|
33
33
|
---
|
|
34
34
|
category: components
|
|
35
35
|
---
|
|
36
|
+
@tsProps
|
|
36
37
|
**/
|
|
37
38
|
let RadioInputGroup = (_dec = (0, _testable.testable)(), _dec(_class = (_temp = _class2 = class RadioInputGroup extends _react.Component {
|
|
38
39
|
constructor(props) {
|
|
39
|
-
super();
|
|
40
|
+
super(props);
|
|
40
41
|
this.ref = null;
|
|
42
|
+
this._messagesId = void 0;
|
|
41
43
|
|
|
42
44
|
this.handleRef = el => {
|
|
43
45
|
this.ref = el;
|
|
@@ -72,7 +74,7 @@ let RadioInputGroup = (_dec = (0, _testable.testable)(), _dec(_class = (_temp =
|
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
get hasMessages() {
|
|
75
|
-
return this.props.messages && this.props.messages.length > 0;
|
|
77
|
+
return !!this.props.messages && this.props.messages.length > 0;
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
get value() {
|
|
@@ -102,11 +104,12 @@ let RadioInputGroup = (_dec = (0, _testable.testable)(), _dec(_class = (_temp =
|
|
|
102
104
|
onChange: this.handleChange,
|
|
103
105
|
readOnly: readOnly || child.props.readOnly,
|
|
104
106
|
width: child.props.width || 'auto',
|
|
105
|
-
'aria-describedby': this.hasMessages
|
|
107
|
+
'aria-describedby': this.hasMessages ? this._messagesId : void 0,
|
|
106
108
|
// only one radio in a group should be considered tabbable
|
|
107
109
|
// if a radio is checked, it should be the input to receive focus when tabbed to
|
|
108
110
|
// if none of the inputs are checked, the first should receive the focus
|
|
109
|
-
tabIndex: isChecked || defaultFocus ?
|
|
111
|
+
tabIndex: isChecked || defaultFocus ? 0 : -1,
|
|
112
|
+
label: child.props.label
|
|
110
113
|
});
|
|
111
114
|
} else {
|
|
112
115
|
return child; // ignore (but preserve) children that aren't RadioInput
|
|
@@ -117,22 +120,21 @@ let RadioInputGroup = (_dec = (0, _testable.testable)(), _dec(_class = (_temp =
|
|
|
117
120
|
render() {
|
|
118
121
|
const _this$props2 = this.props,
|
|
119
122
|
variant = _this$props2.variant,
|
|
120
|
-
layout = _this$props2.layout
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
);
|
|
123
|
+
layout = _this$props2.layout,
|
|
124
|
+
description = _this$props2.description;
|
|
125
|
+
return /*#__PURE__*/_react.default.createElement(_FormFieldGroup.FormFieldGroup, Object.assign({}, (0, _omitProps.omitProps)(this.props, RadioInputGroup.allowedProps), (0, _pickProps.pickProps)(this.props, _FormFieldGroup.FormFieldGroup.allowedProps), {
|
|
126
|
+
description: description // TODO: split out toggle variant into its own component
|
|
127
|
+
,
|
|
128
|
+
layout: layout === 'columns' && variant === 'toggle' ? 'stacked' : layout // toggles already display in cols
|
|
129
|
+
,
|
|
130
|
+
vAlign: variant === 'toggle' ? 'middle' : 'top',
|
|
131
|
+
rowSpacing: "small",
|
|
132
|
+
colSpacing: variant === 'toggle' ? 'none' : 'small' // keep toggles close together
|
|
133
|
+
,
|
|
134
|
+
startAt: variant === 'toggle' ? 'small' : void 0,
|
|
135
|
+
messagesId: this._messagesId,
|
|
136
|
+
elementRef: this.handleRef
|
|
137
|
+
}), this.renderChildren());
|
|
136
138
|
}
|
|
137
139
|
|
|
138
140
|
}, _class2.displayName = "RadioInputGroup", _class2.componentId = 'RadioInputGroup', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
@@ -140,8 +142,7 @@ let RadioInputGroup = (_dec = (0, _testable.testable)(), _dec(_class = (_temp =
|
|
|
140
142
|
variant: 'simple',
|
|
141
143
|
size: 'medium',
|
|
142
144
|
layout: 'stacked',
|
|
143
|
-
readOnly: false
|
|
144
|
-
children: null
|
|
145
|
+
readOnly: false
|
|
145
146
|
}, _temp)) || _class);
|
|
146
147
|
exports.RadioInputGroup = RadioInputGroup;
|
|
147
148
|
var _default = RadioInputGroup;
|
|
@@ -39,40 +39,14 @@ var _FormPropTypes = require("@instructure/ui-form-field/lib/FormPropTypes.js");
|
|
|
39
39
|
const propTypes = {
|
|
40
40
|
name: _propTypes.default.string.isRequired,
|
|
41
41
|
description: _propTypes.default.node.isRequired,
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* value to set on initial render
|
|
45
|
-
*/
|
|
46
42
|
defaultValue: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* the selected value (must be accompanied by an `onChange` prop)
|
|
50
|
-
*/
|
|
51
43
|
value: (0, _controllable.controllable)(_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number])),
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* when used with the `value` prop, the component will not control its own state
|
|
55
|
-
*/
|
|
56
44
|
onChange: _propTypes.default.func,
|
|
57
45
|
disabled: _propTypes.default.bool,
|
|
58
|
-
|
|
59
|
-
/** works just like disabled but keeps the same styles as if it were active */
|
|
60
46
|
readOnly: _propTypes.default.bool,
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* object with shape: `{
|
|
64
|
-
* text: PropTypes.node,
|
|
65
|
-
* type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
|
|
66
|
-
* }`
|
|
67
|
-
*/
|
|
68
47
|
messages: _propTypes.default.arrayOf(_FormPropTypes.FormPropTypes.message),
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* any children (ones that aren't `RadioInput` are passed through)
|
|
72
|
-
*/
|
|
73
48
|
children: _propTypes.default.node,
|
|
74
49
|
variant: _propTypes.default.oneOf(['simple', 'toggle']),
|
|
75
|
-
// TODO: split toggle out to its own component
|
|
76
50
|
size: _propTypes.default.oneOf(['small', 'medium', 'large']),
|
|
77
51
|
layout: _propTypes.default.oneOf(['stacked', 'columns', 'inline'])
|
|
78
52
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-radio-input",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.14.1-snapshot.6+44559fbd7",
|
|
4
4
|
"description": "A styled HTML input type='radio' element",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -25,22 +25,22 @@
|
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@babel/runtime": "^7.13.10",
|
|
28
|
-
"@instructure/emotion": "8.
|
|
29
|
-
"@instructure/shared-types": "8.
|
|
30
|
-
"@instructure/ui-dom-utils": "8.
|
|
31
|
-
"@instructure/ui-form-field": "8.
|
|
32
|
-
"@instructure/ui-prop-types": "8.
|
|
33
|
-
"@instructure/ui-react-utils": "8.
|
|
34
|
-
"@instructure/ui-testable": "8.
|
|
35
|
-
"@instructure/uid": "8.
|
|
28
|
+
"@instructure/emotion": "8.14.1-snapshot.6+44559fbd7",
|
|
29
|
+
"@instructure/shared-types": "8.14.1-snapshot.6+44559fbd7",
|
|
30
|
+
"@instructure/ui-dom-utils": "8.14.1-snapshot.6+44559fbd7",
|
|
31
|
+
"@instructure/ui-form-field": "8.14.1-snapshot.6+44559fbd7",
|
|
32
|
+
"@instructure/ui-prop-types": "8.14.1-snapshot.6+44559fbd7",
|
|
33
|
+
"@instructure/ui-react-utils": "8.14.1-snapshot.6+44559fbd7",
|
|
34
|
+
"@instructure/ui-testable": "8.14.1-snapshot.6+44559fbd7",
|
|
35
|
+
"@instructure/uid": "8.14.1-snapshot.6+44559fbd7",
|
|
36
36
|
"prop-types": "^15"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@instructure/ui-babel-preset": "8.
|
|
40
|
-
"@instructure/ui-color-utils": "8.
|
|
41
|
-
"@instructure/ui-test-locator": "8.
|
|
42
|
-
"@instructure/ui-test-utils": "8.
|
|
43
|
-
"@instructure/ui-themes": "8.
|
|
39
|
+
"@instructure/ui-babel-preset": "8.14.1-snapshot.6+44559fbd7",
|
|
40
|
+
"@instructure/ui-color-utils": "8.14.1-snapshot.6+44559fbd7",
|
|
41
|
+
"@instructure/ui-test-locator": "8.14.1-snapshot.6+44559fbd7",
|
|
42
|
+
"@instructure/ui-test-utils": "8.14.1-snapshot.6+44559fbd7",
|
|
43
|
+
"@instructure/ui-themes": "8.14.1-snapshot.6+44559fbd7"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"react": ">=16.8 <=17"
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
51
|
"sideEffects": false,
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "44559fbd71344c571d339f20cf74491c6fd1dd2f"
|
|
53
53
|
}
|