@instructure/ui-checkbox 8.33.2-snapshot-0 → 8.33.2
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 +1 -5
- package/es/Checkbox/CheckboxFacade/index.js +2 -12
- package/es/Checkbox/CheckboxFacade/props.js +1 -0
- package/es/Checkbox/CheckboxFacade/styles.js +4 -5
- package/es/Checkbox/CheckboxFacade/theme.js +6 -6
- package/es/Checkbox/CheckboxLocator.js +3 -1
- package/es/Checkbox/ToggleFacade/index.js +6 -18
- package/es/Checkbox/ToggleFacade/props.js +1 -0
- package/es/Checkbox/ToggleFacade/styles.js +3 -4
- package/es/Checkbox/ToggleFacade/theme.js +8 -8
- package/es/Checkbox/index.js +27 -55
- package/es/Checkbox/locator.js +1 -0
- package/es/Checkbox/props.js +1 -0
- package/es/Checkbox/styles.js +3 -5
- package/es/CheckboxGroup/CheckboxGroupLocator.js +3 -1
- package/es/CheckboxGroup/index.js +6 -20
- package/es/CheckboxGroup/locator.js +1 -0
- package/es/CheckboxGroup/props.js +1 -5
- package/lib/Checkbox/CheckboxFacade/index.js +2 -20
- package/lib/Checkbox/CheckboxFacade/props.js +1 -3
- package/lib/Checkbox/CheckboxFacade/styles.js +4 -6
- package/lib/Checkbox/CheckboxFacade/theme.js +6 -7
- package/lib/Checkbox/CheckboxLocator.js +1 -3
- package/lib/Checkbox/ToggleFacade/index.js +6 -26
- package/lib/Checkbox/ToggleFacade/props.js +1 -3
- package/lib/Checkbox/ToggleFacade/styles.js +3 -5
- package/lib/Checkbox/ToggleFacade/theme.js +8 -9
- package/lib/Checkbox/index.js +27 -72
- package/lib/Checkbox/locator.js +0 -2
- package/lib/Checkbox/props.js +1 -5
- package/lib/Checkbox/styles.js +3 -6
- package/lib/CheckboxGroup/CheckboxGroupLocator.js +1 -3
- package/lib/CheckboxGroup/index.js +5 -31
- package/lib/CheckboxGroup/locator.js +0 -2
- package/lib/CheckboxGroup/props.js +1 -12
- package/lib/index.js +0 -2
- package/package.json +19 -19
- package/tsconfig.build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,14 +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.33.2
|
|
6
|
+
## [8.33.2](https://github.com/instructure/instructure-ui/compare/v8.33.1...v8.33.2) (2023-01-25)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-checkbox
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
10
|
## [8.33.1](https://github.com/instructure/instructure-ui/compare/v8.33.0...v8.33.1) (2023-01-06)
|
|
15
11
|
|
|
16
12
|
**Note:** Version bump only for package @instructure/ui-checkbox
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var _dec, _class, _class2, _SVGIcon, _IconCheckMarkSolid;
|
|
2
|
-
|
|
3
2
|
/*
|
|
4
3
|
* The MIT License (MIT)
|
|
5
4
|
*
|
|
@@ -32,7 +31,6 @@ import { withStyle, jsx } from '@instructure/emotion';
|
|
|
32
31
|
import generateStyle from './styles';
|
|
33
32
|
import generateComponentTheme from './theme';
|
|
34
33
|
import { propTypes, allowedProps } from './props';
|
|
35
|
-
|
|
36
34
|
/**
|
|
37
35
|
---
|
|
38
36
|
parent: Checkbox
|
|
@@ -43,24 +41,18 @@ let CheckboxFacade = (_dec = withStyle(generateStyle, generateComponentTheme), _
|
|
|
43
41
|
constructor() {
|
|
44
42
|
super(...arguments);
|
|
45
43
|
this.ref = null;
|
|
46
|
-
|
|
47
44
|
this.handleRef = el => {
|
|
48
45
|
this.ref = el;
|
|
49
46
|
};
|
|
50
47
|
}
|
|
51
|
-
|
|
52
48
|
componentDidMount() {
|
|
53
49
|
var _this$props$makeStyle, _this$props;
|
|
54
|
-
|
|
55
50
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
56
51
|
}
|
|
57
|
-
|
|
58
52
|
componentDidUpdate() {
|
|
59
53
|
var _this$props$makeStyle2, _this$props2;
|
|
60
|
-
|
|
61
54
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
62
55
|
}
|
|
63
|
-
|
|
64
56
|
renderIcon() {
|
|
65
57
|
if (this.props.indeterminate) {
|
|
66
58
|
return _SVGIcon || (_SVGIcon = jsx(SVGIcon, {
|
|
@@ -80,11 +72,10 @@ let CheckboxFacade = (_dec = withStyle(generateStyle, generateComponentTheme), _
|
|
|
80
72
|
return null;
|
|
81
73
|
}
|
|
82
74
|
}
|
|
83
|
-
|
|
84
75
|
render() {
|
|
85
76
|
const _this$props3 = this.props,
|
|
86
|
-
|
|
87
|
-
|
|
77
|
+
children = _this$props3.children,
|
|
78
|
+
styles = _this$props3.styles;
|
|
88
79
|
return jsx("span", {
|
|
89
80
|
css: styles === null || styles === void 0 ? void 0 : styles.checkboxFacade,
|
|
90
81
|
ref: this.handleRef
|
|
@@ -95,7 +86,6 @@ let CheckboxFacade = (_dec = withStyle(generateStyle, generateComponentTheme), _
|
|
|
95
86
|
css: styles === null || styles === void 0 ? void 0 : styles.label
|
|
96
87
|
}, children));
|
|
97
88
|
}
|
|
98
|
-
|
|
99
89
|
}, _class2.displayName = "CheckboxFacade", _class2.componentId = 'CheckboxFacade', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
100
90
|
checked: false,
|
|
101
91
|
focused: false,
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
*/
|
|
35
35
|
const generateStyle = (componentTheme, props) => {
|
|
36
36
|
const size = props.size,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
checked = props.checked,
|
|
38
|
+
focused = props.focused,
|
|
39
|
+
hovered = props.hovered,
|
|
40
|
+
indeterminate = props.indeterminate;
|
|
41
41
|
const isChecked = checked || indeterminate;
|
|
42
42
|
const sizeVariants = {
|
|
43
43
|
small: {
|
|
@@ -136,5 +136,4 @@ const generateStyle = (componentTheme, props) => {
|
|
|
136
136
|
}
|
|
137
137
|
};
|
|
138
138
|
};
|
|
139
|
-
|
|
140
139
|
export default generateStyle;
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
*/
|
|
30
30
|
const generateComponentTheme = theme => {
|
|
31
31
|
const colors = theme.colors,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
borders = theme.borders,
|
|
33
|
+
spacing = theme.spacing,
|
|
34
|
+
typography = theme.typography,
|
|
35
|
+
themeName = theme.key;
|
|
36
36
|
const themeSpecificStyle = {
|
|
37
37
|
canvas: {
|
|
38
38
|
focusBorderColor: theme['ic-brand-primary'],
|
|
@@ -72,9 +72,9 @@ const generateComponentTheme = theme => {
|
|
|
72
72
|
iconSizeMedium: '0.75rem',
|
|
73
73
|
iconSizeLarge: '1rem'
|
|
74
74
|
};
|
|
75
|
-
return {
|
|
75
|
+
return {
|
|
76
|
+
...componentVariables,
|
|
76
77
|
...themeSpecificStyle[themeName]
|
|
77
78
|
};
|
|
78
79
|
};
|
|
79
|
-
|
|
80
80
|
export default generateComponentTheme;
|
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
|
|
24
25
|
import { locator } from '@instructure/ui-test-locator';
|
|
25
|
-
import { Checkbox } from './index';
|
|
26
|
+
import { Checkbox } from './index';
|
|
26
27
|
|
|
28
|
+
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
27
29
|
export const CheckboxLocator = locator(Checkbox.selector);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var _dec, _class, _class2;
|
|
2
|
-
|
|
3
2
|
/*
|
|
4
3
|
* The MIT License (MIT)
|
|
5
4
|
*
|
|
@@ -31,7 +30,6 @@ import { withStyle, jsx } from '@instructure/emotion';
|
|
|
31
30
|
import generateStyle from './styles';
|
|
32
31
|
import generateComponentTheme from './theme';
|
|
33
32
|
import { propTypes, allowedProps } from './props';
|
|
34
|
-
|
|
35
33
|
/**
|
|
36
34
|
---
|
|
37
35
|
parent: Checkbox
|
|
@@ -42,29 +40,22 @@ let ToggleFacade = (_dec = withStyle(generateStyle, generateComponentTheme), _de
|
|
|
42
40
|
constructor() {
|
|
43
41
|
super(...arguments);
|
|
44
42
|
this.ref = null;
|
|
45
|
-
|
|
46
43
|
this.handleRef = el => {
|
|
47
44
|
this.ref = el;
|
|
48
45
|
};
|
|
49
46
|
}
|
|
50
|
-
|
|
51
47
|
componentDidMount() {
|
|
52
48
|
var _this$props$makeStyle, _this$props;
|
|
53
|
-
|
|
54
49
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
55
50
|
}
|
|
56
|
-
|
|
57
51
|
componentDidUpdate() {
|
|
58
52
|
var _this$props$makeStyle2, _this$props2;
|
|
59
|
-
|
|
60
53
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
61
54
|
}
|
|
62
|
-
|
|
63
55
|
renderIcon() {
|
|
64
56
|
const _this$props3 = this.props,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
57
|
+
styles = _this$props3.styles,
|
|
58
|
+
checked = _this$props3.checked;
|
|
68
59
|
if (checked) {
|
|
69
60
|
return jsx(IconCheckSolid, {
|
|
70
61
|
css: styles === null || styles === void 0 ? void 0 : styles.iconSVG
|
|
@@ -75,20 +66,18 @@ let ToggleFacade = (_dec = withStyle(generateStyle, generateComponentTheme), _de
|
|
|
75
66
|
});
|
|
76
67
|
}
|
|
77
68
|
}
|
|
78
|
-
|
|
79
69
|
renderLabel() {
|
|
80
70
|
const _this$props4 = this.props,
|
|
81
|
-
|
|
82
|
-
|
|
71
|
+
children = _this$props4.children,
|
|
72
|
+
styles = _this$props4.styles;
|
|
83
73
|
return jsx("span", {
|
|
84
74
|
css: styles === null || styles === void 0 ? void 0 : styles.label
|
|
85
75
|
}, children);
|
|
86
76
|
}
|
|
87
|
-
|
|
88
77
|
render() {
|
|
89
78
|
const _this$props5 = this.props,
|
|
90
|
-
|
|
91
|
-
|
|
79
|
+
labelPlacement = _this$props5.labelPlacement,
|
|
80
|
+
styles = _this$props5.styles;
|
|
92
81
|
return jsx("span", {
|
|
93
82
|
css: styles === null || styles === void 0 ? void 0 : styles.toggleFacade,
|
|
94
83
|
ref: this.handleRef
|
|
@@ -101,7 +90,6 @@ let ToggleFacade = (_dec = withStyle(generateStyle, generateComponentTheme), _de
|
|
|
101
90
|
css: styles === null || styles === void 0 ? void 0 : styles.iconToggle
|
|
102
91
|
}, this.renderIcon()))), labelPlacement === 'end' && this.renderLabel());
|
|
103
92
|
}
|
|
104
|
-
|
|
105
93
|
}, _class2.displayName = "ToggleFacade", _class2.componentId = 'ToggleFacade', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
106
94
|
checked: false,
|
|
107
95
|
focused: false,
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
*/
|
|
35
35
|
const generateStyle = (componentTheme, props) => {
|
|
36
36
|
const size = props.size,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
checked = props.checked,
|
|
38
|
+
focused = props.focused,
|
|
39
|
+
labelPlacement = props.labelPlacement;
|
|
40
40
|
const labelPlacementVariants = {
|
|
41
41
|
start: {
|
|
42
42
|
facade: {
|
|
@@ -184,5 +184,4 @@ const generateStyle = (componentTheme, props) => {
|
|
|
184
184
|
}
|
|
185
185
|
};
|
|
186
186
|
};
|
|
187
|
-
|
|
188
187
|
export default generateStyle;
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
*/
|
|
30
30
|
const generateComponentTheme = theme => {
|
|
31
31
|
const colors = theme.colors,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
borders = theme.borders,
|
|
33
|
+
forms = theme.forms,
|
|
34
|
+
shadows = theme.shadows,
|
|
35
|
+
spacing = theme.spacing,
|
|
36
|
+
typography = theme.typography,
|
|
37
|
+
themeName = theme.key;
|
|
38
38
|
const themeSpecificStyle = {
|
|
39
39
|
canvas: {
|
|
40
40
|
focusOutlineColor: theme['ic-brand-primary'],
|
|
@@ -71,9 +71,9 @@ const generateComponentTheme = theme => {
|
|
|
71
71
|
labelFontSizeMedium: typography === null || typography === void 0 ? void 0 : typography.fontSizeMedium,
|
|
72
72
|
labelFontSizeLarge: typography === null || typography === void 0 ? void 0 : typography.fontSizeLarge
|
|
73
73
|
};
|
|
74
|
-
return {
|
|
74
|
+
return {
|
|
75
|
+
...componentVariables,
|
|
75
76
|
...themeSpecificStyle[themeName]
|
|
76
77
|
};
|
|
77
78
|
};
|
|
78
|
-
|
|
79
79
|
export default generateComponentTheme;
|
package/es/Checkbox/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var _dec, _dec2, _dec3, _class, _class2;
|
|
2
|
-
|
|
3
2
|
/*
|
|
4
3
|
* The MIT License (MIT)
|
|
5
4
|
*
|
|
@@ -39,7 +38,6 @@ import { CheckboxFacade } from './CheckboxFacade';
|
|
|
39
38
|
import { ToggleFacade } from './ToggleFacade';
|
|
40
39
|
import generateStyle from './styles';
|
|
41
40
|
import { propTypes, allowedProps } from './props';
|
|
42
|
-
|
|
43
41
|
/**
|
|
44
42
|
---
|
|
45
43
|
category: components
|
|
@@ -53,130 +51,105 @@ let Checkbox = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, n
|
|
|
53
51
|
this._defaultId = void 0;
|
|
54
52
|
this._input = null;
|
|
55
53
|
this.ref = null;
|
|
56
|
-
|
|
57
54
|
this.handleRef = el => {
|
|
58
55
|
this.ref = el;
|
|
59
56
|
};
|
|
60
|
-
|
|
61
57
|
this.handleChange = e => {
|
|
62
58
|
const _this$props = this.props,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
59
|
+
onChange = _this$props.onChange,
|
|
60
|
+
disabled = _this$props.disabled,
|
|
61
|
+
checked = _this$props.checked,
|
|
62
|
+
readOnly = _this$props.readOnly;
|
|
68
63
|
if (disabled || readOnly) {
|
|
69
64
|
e.preventDefault();
|
|
70
65
|
return;
|
|
71
66
|
}
|
|
72
|
-
|
|
73
67
|
if (typeof checked === 'undefined') {
|
|
74
68
|
this.setState({
|
|
75
69
|
checked: !this.state.checked
|
|
76
70
|
});
|
|
77
71
|
}
|
|
78
|
-
|
|
79
72
|
if (typeof onChange === 'function') {
|
|
80
73
|
onChange(e);
|
|
81
74
|
}
|
|
82
75
|
};
|
|
83
|
-
|
|
84
76
|
this.handleKeyDown = e => {
|
|
85
77
|
if (this.props.variant === 'toggle' && e.keyCode === keycode.codes.enter) {
|
|
86
78
|
this._input && this._input.click();
|
|
87
79
|
e.preventDefault();
|
|
88
80
|
}
|
|
89
81
|
};
|
|
90
|
-
|
|
91
82
|
this.handleFocus = () => {
|
|
92
83
|
this.setState({
|
|
93
84
|
focused: true
|
|
94
85
|
});
|
|
95
86
|
};
|
|
96
|
-
|
|
97
87
|
this.handleBlur = () => {
|
|
98
88
|
this.setState({
|
|
99
89
|
focused: false
|
|
100
90
|
});
|
|
101
91
|
};
|
|
102
|
-
|
|
103
92
|
this.handleMouseOver = () => {
|
|
104
93
|
this.setState({
|
|
105
94
|
hovered: true
|
|
106
95
|
});
|
|
107
96
|
};
|
|
108
|
-
|
|
109
97
|
this.handleMouseOut = () => {
|
|
110
98
|
this.setState({
|
|
111
99
|
hovered: false
|
|
112
100
|
});
|
|
113
101
|
};
|
|
114
|
-
|
|
115
102
|
this.state = {
|
|
116
103
|
focused: false,
|
|
117
104
|
hovered: false,
|
|
118
105
|
checked: typeof props.checked === 'undefined' ? !!props.defaultChecked : void 0
|
|
119
106
|
};
|
|
120
|
-
|
|
121
107
|
if (typeof props.checked === 'undefined') {
|
|
122
108
|
// @ts-expect-error ts-migrate(2339) FIXME: Property 'checked' does not exist on type 'Readonl... Remove this comment to see the full error message
|
|
123
109
|
this.state.checked = !!props.defaultChecked;
|
|
124
110
|
}
|
|
125
|
-
|
|
126
111
|
this._defaultId = props.deterministicId();
|
|
127
112
|
}
|
|
128
|
-
|
|
129
113
|
componentDidMount() {
|
|
130
114
|
var _this$props$makeStyle, _this$props2;
|
|
131
|
-
|
|
132
115
|
if (this._input) {
|
|
133
116
|
this._input.indeterminate = this.props.indeterminate;
|
|
134
117
|
}
|
|
135
|
-
|
|
136
118
|
(_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
|
|
137
119
|
}
|
|
138
|
-
|
|
139
120
|
componentDidUpdate(prevProps) {
|
|
140
121
|
var _this$props$makeStyle2, _this$props3;
|
|
141
|
-
|
|
142
122
|
if (prevProps.indeterminate !== this.props.indeterminate && this._input) {
|
|
143
123
|
this._input.indeterminate = this.props.indeterminate || false;
|
|
144
124
|
}
|
|
145
|
-
|
|
146
125
|
(_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
|
|
147
126
|
}
|
|
148
|
-
|
|
149
127
|
get id() {
|
|
150
128
|
return this.props.id || this._defaultId;
|
|
151
129
|
}
|
|
152
|
-
|
|
153
130
|
get checked() {
|
|
154
131
|
return typeof this.props.checked === 'undefined' ? this.state.checked : this.props.checked;
|
|
155
132
|
}
|
|
156
|
-
|
|
157
133
|
get focused() {
|
|
158
134
|
return isActiveElement(this._input);
|
|
159
135
|
}
|
|
160
|
-
|
|
161
136
|
focus() {
|
|
162
137
|
this._input && this._input.focus();
|
|
163
138
|
}
|
|
164
|
-
|
|
165
139
|
renderFacade() {
|
|
166
140
|
const _this$props4 = this.props,
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
141
|
+
size = _this$props4.size,
|
|
142
|
+
disabled = _this$props4.disabled,
|
|
143
|
+
variant = _this$props4.variant,
|
|
144
|
+
label = _this$props4.label,
|
|
145
|
+
readOnly = _this$props4.readOnly,
|
|
146
|
+
indeterminate = _this$props4.indeterminate,
|
|
147
|
+
labelPlacement = _this$props4.labelPlacement,
|
|
148
|
+
themeOverride = _this$props4.themeOverride;
|
|
175
149
|
const _this$state = this.state,
|
|
176
|
-
|
|
177
|
-
|
|
150
|
+
hovered = _this$state.hovered,
|
|
151
|
+
focused = _this$state.focused;
|
|
178
152
|
error(!(variant === 'simple' && labelPlacement !== 'end'), `[Checkbox] The \`simple\` variant does not support the \`labelPlacement\` property. Use the \`toggle\` variant instead.`);
|
|
179
|
-
|
|
180
153
|
if (variant === 'toggle') {
|
|
181
154
|
return jsx(ToggleFacade, {
|
|
182
155
|
disabled: disabled,
|
|
@@ -198,7 +171,6 @@ let Checkbox = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, n
|
|
|
198
171
|
}, label);
|
|
199
172
|
}
|
|
200
173
|
}
|
|
201
|
-
|
|
202
174
|
renderMessages() {
|
|
203
175
|
const messages = this.props.messages;
|
|
204
176
|
return messages && messages.length > 0 ? jsx(View, {
|
|
@@ -208,22 +180,22 @@ let Checkbox = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, n
|
|
|
208
180
|
messages: messages
|
|
209
181
|
})) : null;
|
|
210
182
|
}
|
|
211
|
-
|
|
212
183
|
render() {
|
|
213
184
|
const _this$props5 = this.props,
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
185
|
+
disabled = _this$props5.disabled,
|
|
186
|
+
readOnly = _this$props5.readOnly,
|
|
187
|
+
value = _this$props5.value,
|
|
188
|
+
onKeyDown = _this$props5.onKeyDown,
|
|
189
|
+
onFocus = _this$props5.onFocus,
|
|
190
|
+
onBlur = _this$props5.onBlur,
|
|
191
|
+
onMouseOver = _this$props5.onMouseOver,
|
|
192
|
+
onMouseOut = _this$props5.onMouseOut,
|
|
193
|
+
indeterminate = _this$props5.indeterminate,
|
|
194
|
+
variant = _this$props5.variant,
|
|
195
|
+
styles = _this$props5.styles;
|
|
225
196
|
const props = omitProps(this.props, Checkbox.allowedProps);
|
|
226
197
|
error(!(variant === 'toggle' && indeterminate), `[Checkbox] The \`toggle\` variant does not support the \`indeterminate\` property. Use the \`simple\` variant instead.`);
|
|
198
|
+
|
|
227
199
|
/* eslint-disable jsx-a11y/mouse-events-have-key-events */
|
|
228
200
|
|
|
229
201
|
return jsx("div", {
|
|
@@ -250,9 +222,9 @@ let Checkbox = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, n
|
|
|
250
222
|
htmlFor: this.id,
|
|
251
223
|
css: styles === null || styles === void 0 ? void 0 : styles.control
|
|
252
224
|
}, this.renderFacade(), this.renderMessages()));
|
|
225
|
+
|
|
253
226
|
/* eslint-enable jsx-a11y/mouse-events-have-key-events */
|
|
254
227
|
}
|
|
255
|
-
|
|
256
228
|
}, _class2.displayName = "Checkbox", _class2.componentId = 'Checkbox', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
257
229
|
size: 'medium',
|
|
258
230
|
variant: 'simple',
|
package/es/Checkbox/locator.js
CHANGED
package/es/Checkbox/props.js
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
|
|
24
25
|
import PropTypes from 'prop-types';
|
|
25
26
|
import { FormPropTypes } from '@instructure/ui-form-field';
|
|
26
27
|
import { controllable } from '@instructure/ui-prop-types';
|
package/es/Checkbox/styles.js
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
*/
|
|
35
35
|
const generateStyle = (_componentTheme, props) => {
|
|
36
36
|
const inline = props.inline,
|
|
37
|
-
|
|
37
|
+
disabled = props.disabled;
|
|
38
38
|
return {
|
|
39
39
|
checkbox: {
|
|
40
40
|
label: 'checkbox',
|
|
@@ -62,10 +62,9 @@ const generateStyle = (_componentTheme, props) => {
|
|
|
62
62
|
top: 0,
|
|
63
63
|
insetInlineStart: 0,
|
|
64
64
|
insetInlineEnd: 'auto',
|
|
65
|
-
opacity: 0.0001
|
|
66
|
-
/* selenium cannot find fully transparent elements */
|
|
67
|
-
|
|
65
|
+
opacity: 0.0001 /* selenium cannot find fully transparent elements */
|
|
68
66
|
},
|
|
67
|
+
|
|
69
68
|
control: {
|
|
70
69
|
label: 'checkbox__control',
|
|
71
70
|
all: 'initial',
|
|
@@ -75,5 +74,4 @@ const generateStyle = (_componentTheme, props) => {
|
|
|
75
74
|
}
|
|
76
75
|
};
|
|
77
76
|
};
|
|
78
|
-
|
|
79
77
|
export default generateStyle;
|
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
|
|
24
25
|
import { locator } from '@instructure/ui-test-locator';
|
|
25
|
-
import { CheckboxGroup } from './index';
|
|
26
|
+
import { CheckboxGroup } from './index';
|
|
26
27
|
|
|
28
|
+
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
27
29
|
export const CheckboxGroupLocator = locator(CheckboxGroup.selector);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var _dec, _dec2, _class, _class2;
|
|
2
|
-
|
|
3
2
|
/*
|
|
4
3
|
* The MIT License (MIT)
|
|
5
4
|
*
|
|
@@ -23,13 +22,13 @@ var _dec, _dec2, _class, _class2;
|
|
|
23
22
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
23
|
* SOFTWARE.
|
|
25
24
|
*/
|
|
25
|
+
|
|
26
26
|
import React, { Children, Component } from 'react';
|
|
27
27
|
import { FormFieldGroup } from '@instructure/ui-form-field';
|
|
28
28
|
import { matchComponentTypes, safeCloneElement, pickProps, omitProps, withDeterministicId } from '@instructure/ui-react-utils';
|
|
29
29
|
import { testable } from '@instructure/ui-testable';
|
|
30
30
|
import { Checkbox } from '../Checkbox';
|
|
31
31
|
import { propTypes, allowedProps } from './props';
|
|
32
|
-
|
|
33
32
|
/**
|
|
34
33
|
---
|
|
35
34
|
category: components
|
|
@@ -41,60 +40,49 @@ let CheckboxGroup = (_dec = withDeterministicId(), _dec2 = testable(), _dec(_cla
|
|
|
41
40
|
super(props);
|
|
42
41
|
this._messagesId = void 0;
|
|
43
42
|
this.ref = null;
|
|
44
|
-
|
|
45
43
|
this.handleRef = el => {
|
|
46
44
|
this.ref = el;
|
|
47
45
|
};
|
|
48
|
-
|
|
49
46
|
this.handleChange = e => {
|
|
50
47
|
const newValue = this.value;
|
|
51
|
-
|
|
52
48
|
if (this.props.disabled || this.props.readOnly) {
|
|
53
49
|
e.preventDefault();
|
|
54
50
|
return;
|
|
55
51
|
}
|
|
56
|
-
|
|
57
52
|
if (e.target.checked) {
|
|
58
53
|
newValue.push(e.target.value);
|
|
59
54
|
} else {
|
|
60
55
|
newValue.splice(newValue.indexOf(e.target.value), 1);
|
|
61
56
|
}
|
|
62
|
-
|
|
63
57
|
if (typeof this.props.value === 'undefined') {
|
|
64
58
|
this.setState({
|
|
65
59
|
value: newValue
|
|
66
60
|
});
|
|
67
61
|
}
|
|
68
|
-
|
|
69
62
|
if (typeof this.props.onChange === 'function') {
|
|
70
63
|
this.props.onChange(newValue);
|
|
71
64
|
}
|
|
72
65
|
};
|
|
73
|
-
|
|
74
66
|
if (typeof props.value === 'undefined') {
|
|
75
67
|
this.state = {
|
|
76
68
|
value: props.defaultValue || []
|
|
77
69
|
};
|
|
78
70
|
}
|
|
79
|
-
|
|
80
71
|
this._messagesId = props.deterministicId();
|
|
81
72
|
}
|
|
82
|
-
|
|
83
73
|
get hasMessages() {
|
|
84
74
|
return this.props.messages && this.props.messages.length > 0;
|
|
85
75
|
}
|
|
86
|
-
|
|
87
76
|
get value() {
|
|
88
77
|
return typeof this.props.value === 'undefined' ? [...this.state.value] : [...this.props.value];
|
|
89
78
|
}
|
|
90
|
-
|
|
91
79
|
renderChildren() {
|
|
92
80
|
const _this$props = this.props,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
81
|
+
children = _this$props.children,
|
|
82
|
+
name = _this$props.name,
|
|
83
|
+
size = _this$props.size,
|
|
84
|
+
disabled = _this$props.disabled,
|
|
85
|
+
readOnly = _this$props.readOnly;
|
|
98
86
|
return Children.map(children, child => {
|
|
99
87
|
if (matchComponentTypes(child, [Checkbox])) {
|
|
100
88
|
return safeCloneElement(child, {
|
|
@@ -114,7 +102,6 @@ let CheckboxGroup = (_dec = withDeterministicId(), _dec2 = testable(), _dec(_cla
|
|
|
114
102
|
}
|
|
115
103
|
});
|
|
116
104
|
}
|
|
117
|
-
|
|
118
105
|
render() {
|
|
119
106
|
return /*#__PURE__*/React.createElement(FormFieldGroup, Object.assign({}, omitProps(this.props, CheckboxGroup.allowedProps), pickProps(this.props, FormFieldGroup.allowedProps), {
|
|
120
107
|
description: this.props.description,
|
|
@@ -124,7 +111,6 @@ let CheckboxGroup = (_dec = withDeterministicId(), _dec2 = testable(), _dec(_cla
|
|
|
124
111
|
elementRef: this.handleRef
|
|
125
112
|
}), this.renderChildren());
|
|
126
113
|
}
|
|
127
|
-
|
|
128
114
|
}, _class2.displayName = "CheckboxGroup", _class2.componentId = 'CheckboxGroup', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
129
115
|
disabled: false,
|
|
130
116
|
readOnly: false,
|