@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
|
@@ -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, Children as ChildrenPropTypes } from '@instructure/ui-prop-types';
|
|
@@ -28,24 +29,20 @@ import { Checkbox } from '../Checkbox';
|
|
|
28
29
|
const propTypes = {
|
|
29
30
|
name: PropTypes.string.isRequired,
|
|
30
31
|
description: PropTypes.node.isRequired,
|
|
31
|
-
|
|
32
32
|
/**
|
|
33
33
|
* value to set on initial render
|
|
34
34
|
*/
|
|
35
35
|
defaultValue: PropTypes.array,
|
|
36
|
-
|
|
37
36
|
/**
|
|
38
37
|
* the selected values (must be accompanied by an `onChange` prop)
|
|
39
38
|
*/
|
|
40
39
|
value: controllable(PropTypes.array),
|
|
41
|
-
|
|
42
40
|
/**
|
|
43
41
|
* when used with the `value` prop, the component will not control its own state
|
|
44
42
|
*/
|
|
45
43
|
onChange: PropTypes.func,
|
|
46
44
|
disabled: PropTypes.bool,
|
|
47
45
|
readOnly: PropTypes.bool,
|
|
48
|
-
|
|
49
46
|
/**
|
|
50
47
|
* object with shape: `{
|
|
51
48
|
text: PropTypes.node,
|
|
@@ -53,7 +50,6 @@ const propTypes = {
|
|
|
53
50
|
}`
|
|
54
51
|
*/
|
|
55
52
|
messages: PropTypes.arrayOf(FormPropTypes.message),
|
|
56
|
-
|
|
57
53
|
/**
|
|
58
54
|
* children of type `Checkbox`
|
|
59
55
|
*/
|
|
@@ -1,28 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = exports.CheckboxFacade = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = require("react");
|
|
11
|
-
|
|
12
9
|
var _SVGIcon2 = require("@instructure/ui-svg-images/lib/SVGIcon");
|
|
13
|
-
|
|
14
10
|
var _IconCheckMarkSolid2 = require("@instructure/ui-icons/lib/IconCheckMarkSolid.js");
|
|
15
|
-
|
|
16
11
|
var _emotion = require("@instructure/emotion");
|
|
17
|
-
|
|
18
12
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
19
|
-
|
|
20
13
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
21
|
-
|
|
22
14
|
var _props = require("./props");
|
|
23
|
-
|
|
24
15
|
var _dec, _class, _class2, _SVGIcon, _IconCheckMarkSolid;
|
|
25
|
-
|
|
26
16
|
/**
|
|
27
17
|
---
|
|
28
18
|
parent: Checkbox
|
|
@@ -33,24 +23,18 @@ let CheckboxFacade = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.def
|
|
|
33
23
|
constructor() {
|
|
34
24
|
super(...arguments);
|
|
35
25
|
this.ref = null;
|
|
36
|
-
|
|
37
26
|
this.handleRef = el => {
|
|
38
27
|
this.ref = el;
|
|
39
28
|
};
|
|
40
29
|
}
|
|
41
|
-
|
|
42
30
|
componentDidMount() {
|
|
43
31
|
var _this$props$makeStyle, _this$props;
|
|
44
|
-
|
|
45
32
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
46
33
|
}
|
|
47
|
-
|
|
48
34
|
componentDidUpdate() {
|
|
49
35
|
var _this$props$makeStyle2, _this$props2;
|
|
50
|
-
|
|
51
36
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
52
37
|
}
|
|
53
|
-
|
|
54
38
|
renderIcon() {
|
|
55
39
|
if (this.props.indeterminate) {
|
|
56
40
|
return _SVGIcon || (_SVGIcon = (0, _emotion.jsx)(_SVGIcon2.SVGIcon, {
|
|
@@ -70,11 +54,10 @@ let CheckboxFacade = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.def
|
|
|
70
54
|
return null;
|
|
71
55
|
}
|
|
72
56
|
}
|
|
73
|
-
|
|
74
57
|
render() {
|
|
75
58
|
const _this$props3 = this.props,
|
|
76
|
-
|
|
77
|
-
|
|
59
|
+
children = _this$props3.children,
|
|
60
|
+
styles = _this$props3.styles;
|
|
78
61
|
return (0, _emotion.jsx)("span", {
|
|
79
62
|
css: styles === null || styles === void 0 ? void 0 : styles.checkboxFacade,
|
|
80
63
|
ref: this.handleRef
|
|
@@ -85,7 +68,6 @@ let CheckboxFacade = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.def
|
|
|
85
68
|
css: styles === null || styles === void 0 ? void 0 : styles.label
|
|
86
69
|
}, children));
|
|
87
70
|
}
|
|
88
|
-
|
|
89
71
|
}, _class2.displayName = "CheckboxFacade", _class2.componentId = 'CheckboxFacade', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
|
|
90
72
|
checked: false,
|
|
91
73
|
focused: false,
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.propTypes = exports.allowedProps = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
/*
|
|
13
10
|
* The MIT License (MIT)
|
|
14
11
|
*
|
|
@@ -32,6 +29,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
32
29
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
30
|
* SOFTWARE.
|
|
34
31
|
*/
|
|
32
|
+
|
|
35
33
|
const propTypes = {
|
|
36
34
|
children: _propTypes.default.node.isRequired,
|
|
37
35
|
checked: _propTypes.default.bool,
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -41,10 +40,10 @@ exports.default = void 0;
|
|
|
41
40
|
*/
|
|
42
41
|
const generateStyle = (componentTheme, props) => {
|
|
43
42
|
const size = props.size,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
checked = props.checked,
|
|
44
|
+
focused = props.focused,
|
|
45
|
+
hovered = props.hovered,
|
|
46
|
+
indeterminate = props.indeterminate;
|
|
48
47
|
const isChecked = checked || indeterminate;
|
|
49
48
|
const sizeVariants = {
|
|
50
49
|
small: {
|
|
@@ -143,6 +142,5 @@ const generateStyle = (componentTheme, props) => {
|
|
|
143
142
|
}
|
|
144
143
|
};
|
|
145
144
|
};
|
|
146
|
-
|
|
147
145
|
var _default = generateStyle;
|
|
148
146
|
exports.default = _default;
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -36,10 +35,10 @@ exports.default = void 0;
|
|
|
36
35
|
*/
|
|
37
36
|
const generateComponentTheme = theme => {
|
|
38
37
|
const colors = theme.colors,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
borders = theme.borders,
|
|
39
|
+
spacing = theme.spacing,
|
|
40
|
+
typography = theme.typography,
|
|
41
|
+
themeName = theme.key;
|
|
43
42
|
const themeSpecificStyle = {
|
|
44
43
|
canvas: {
|
|
45
44
|
focusBorderColor: theme['ic-brand-primary'],
|
|
@@ -79,10 +78,10 @@ const generateComponentTheme = theme => {
|
|
|
79
78
|
iconSizeMedium: '0.75rem',
|
|
80
79
|
iconSizeLarge: '1rem'
|
|
81
80
|
};
|
|
82
|
-
return {
|
|
81
|
+
return {
|
|
82
|
+
...componentVariables,
|
|
83
83
|
...themeSpecificStyle[themeName]
|
|
84
84
|
};
|
|
85
85
|
};
|
|
86
|
-
|
|
87
86
|
var _default = generateComponentTheme;
|
|
88
87
|
exports.default = _default;
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.CheckboxLocator = void 0;
|
|
7
|
-
|
|
8
7
|
var _locator = require("@instructure/ui-test-locator/lib/utils/locator.js");
|
|
9
|
-
|
|
10
8
|
var _index = require("./index");
|
|
11
|
-
|
|
12
9
|
/*
|
|
13
10
|
* The MIT License (MIT)
|
|
14
11
|
*
|
|
@@ -32,6 +29,7 @@ var _index = require("./index");
|
|
|
32
29
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
30
|
* SOFTWARE.
|
|
34
31
|
*/
|
|
32
|
+
|
|
35
33
|
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
36
34
|
const CheckboxLocator = (0, _locator.locator)(_index.Checkbox.selector);
|
|
37
35
|
exports.CheckboxLocator = CheckboxLocator;
|
|
@@ -1,28 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = exports.ToggleFacade = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = require("react");
|
|
11
|
-
|
|
12
9
|
var _IconCheckSolid = require("@instructure/ui-icons/lib/IconCheckSolid.js");
|
|
13
|
-
|
|
14
10
|
var _IconXSolid = require("@instructure/ui-icons/lib/IconXSolid.js");
|
|
15
|
-
|
|
16
11
|
var _emotion = require("@instructure/emotion");
|
|
17
|
-
|
|
18
12
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
19
|
-
|
|
20
13
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
21
|
-
|
|
22
14
|
var _props = require("./props");
|
|
23
|
-
|
|
24
15
|
var _dec, _class, _class2;
|
|
25
|
-
|
|
26
16
|
/**
|
|
27
17
|
---
|
|
28
18
|
parent: Checkbox
|
|
@@ -33,29 +23,22 @@ let ToggleFacade = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defau
|
|
|
33
23
|
constructor() {
|
|
34
24
|
super(...arguments);
|
|
35
25
|
this.ref = null;
|
|
36
|
-
|
|
37
26
|
this.handleRef = el => {
|
|
38
27
|
this.ref = el;
|
|
39
28
|
};
|
|
40
29
|
}
|
|
41
|
-
|
|
42
30
|
componentDidMount() {
|
|
43
31
|
var _this$props$makeStyle, _this$props;
|
|
44
|
-
|
|
45
32
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
46
33
|
}
|
|
47
|
-
|
|
48
34
|
componentDidUpdate() {
|
|
49
35
|
var _this$props$makeStyle2, _this$props2;
|
|
50
|
-
|
|
51
36
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
52
37
|
}
|
|
53
|
-
|
|
54
38
|
renderIcon() {
|
|
55
39
|
const _this$props3 = this.props,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
40
|
+
styles = _this$props3.styles,
|
|
41
|
+
checked = _this$props3.checked;
|
|
59
42
|
if (checked) {
|
|
60
43
|
return (0, _emotion.jsx)(_IconCheckSolid.IconCheckSolid, {
|
|
61
44
|
css: styles === null || styles === void 0 ? void 0 : styles.iconSVG
|
|
@@ -66,20 +49,18 @@ let ToggleFacade = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defau
|
|
|
66
49
|
});
|
|
67
50
|
}
|
|
68
51
|
}
|
|
69
|
-
|
|
70
52
|
renderLabel() {
|
|
71
53
|
const _this$props4 = this.props,
|
|
72
|
-
|
|
73
|
-
|
|
54
|
+
children = _this$props4.children,
|
|
55
|
+
styles = _this$props4.styles;
|
|
74
56
|
return (0, _emotion.jsx)("span", {
|
|
75
57
|
css: styles === null || styles === void 0 ? void 0 : styles.label
|
|
76
58
|
}, children);
|
|
77
59
|
}
|
|
78
|
-
|
|
79
60
|
render() {
|
|
80
61
|
const _this$props5 = this.props,
|
|
81
|
-
|
|
82
|
-
|
|
62
|
+
labelPlacement = _this$props5.labelPlacement,
|
|
63
|
+
styles = _this$props5.styles;
|
|
83
64
|
return (0, _emotion.jsx)("span", {
|
|
84
65
|
css: styles === null || styles === void 0 ? void 0 : styles.toggleFacade,
|
|
85
66
|
ref: this.handleRef
|
|
@@ -92,7 +73,6 @@ let ToggleFacade = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defau
|
|
|
92
73
|
css: styles === null || styles === void 0 ? void 0 : styles.iconToggle
|
|
93
74
|
}, this.renderIcon()))), labelPlacement === 'end' && this.renderLabel());
|
|
94
75
|
}
|
|
95
|
-
|
|
96
76
|
}, _class2.displayName = "ToggleFacade", _class2.componentId = 'ToggleFacade', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
|
|
97
77
|
checked: false,
|
|
98
78
|
focused: false,
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.propTypes = exports.allowedProps = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
/*
|
|
13
10
|
* The MIT License (MIT)
|
|
14
11
|
*
|
|
@@ -32,6 +29,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
32
29
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
30
|
* SOFTWARE.
|
|
34
31
|
*/
|
|
32
|
+
|
|
35
33
|
const propTypes = {
|
|
36
34
|
children: _propTypes.default.node.isRequired,
|
|
37
35
|
checked: _propTypes.default.bool,
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -41,9 +40,9 @@ exports.default = void 0;
|
|
|
41
40
|
*/
|
|
42
41
|
const generateStyle = (componentTheme, props) => {
|
|
43
42
|
const size = props.size,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
checked = props.checked,
|
|
44
|
+
focused = props.focused,
|
|
45
|
+
labelPlacement = props.labelPlacement;
|
|
47
46
|
const labelPlacementVariants = {
|
|
48
47
|
start: {
|
|
49
48
|
facade: {
|
|
@@ -191,6 +190,5 @@ const generateStyle = (componentTheme, props) => {
|
|
|
191
190
|
}
|
|
192
191
|
};
|
|
193
192
|
};
|
|
194
|
-
|
|
195
193
|
var _default = generateStyle;
|
|
196
194
|
exports.default = _default;
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -36,12 +35,12 @@ exports.default = void 0;
|
|
|
36
35
|
*/
|
|
37
36
|
const generateComponentTheme = theme => {
|
|
38
37
|
const colors = theme.colors,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
borders = theme.borders,
|
|
39
|
+
forms = theme.forms,
|
|
40
|
+
shadows = theme.shadows,
|
|
41
|
+
spacing = theme.spacing,
|
|
42
|
+
typography = theme.typography,
|
|
43
|
+
themeName = theme.key;
|
|
45
44
|
const themeSpecificStyle = {
|
|
46
45
|
canvas: {
|
|
47
46
|
focusOutlineColor: theme['ic-brand-primary'],
|
|
@@ -78,10 +77,10 @@ const generateComponentTheme = theme => {
|
|
|
78
77
|
labelFontSizeMedium: typography === null || typography === void 0 ? void 0 : typography.fontSizeMedium,
|
|
79
78
|
labelFontSizeLarge: typography === null || typography === void 0 ? void 0 : typography.fontSizeLarge
|
|
80
79
|
};
|
|
81
|
-
return {
|
|
80
|
+
return {
|
|
81
|
+
...componentVariables,
|
|
82
82
|
...themeSpecificStyle[themeName]
|
|
83
83
|
};
|
|
84
84
|
};
|
|
85
|
-
|
|
86
85
|
var _default = generateComponentTheme;
|
|
87
86
|
exports.default = _default;
|
package/lib/Checkbox/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
-
|
|
5
4
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
@@ -21,39 +19,22 @@ Object.defineProperty(exports, "ToggleFacade", {
|
|
|
21
19
|
}
|
|
22
20
|
});
|
|
23
21
|
exports.default = void 0;
|
|
24
|
-
|
|
25
22
|
var _react = _interopRequireWildcard(require("react"));
|
|
26
|
-
|
|
27
23
|
var _keycode = _interopRequireDefault(require("keycode"));
|
|
28
|
-
|
|
29
24
|
var _FormFieldMessages = require("@instructure/ui-form-field/lib/FormFieldMessages");
|
|
30
|
-
|
|
31
25
|
var _createChainedFunction = require("@instructure/ui-utils/lib/createChainedFunction.js");
|
|
32
|
-
|
|
33
26
|
var _console = require("@instructure/console");
|
|
34
|
-
|
|
35
27
|
var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js");
|
|
36
|
-
|
|
37
28
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
38
|
-
|
|
39
29
|
var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
|
|
40
|
-
|
|
41
30
|
var _View = require("@instructure/ui-view/lib/View");
|
|
42
|
-
|
|
43
31
|
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
44
|
-
|
|
45
32
|
var _emotion = require("@instructure/emotion");
|
|
46
|
-
|
|
47
33
|
var _CheckboxFacade = require("./CheckboxFacade");
|
|
48
|
-
|
|
49
34
|
var _ToggleFacade = require("./ToggleFacade");
|
|
50
|
-
|
|
51
35
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
52
|
-
|
|
53
36
|
var _props = require("./props");
|
|
54
|
-
|
|
55
37
|
var _dec, _dec2, _dec3, _class, _class2;
|
|
56
|
-
|
|
57
38
|
/**
|
|
58
39
|
---
|
|
59
40
|
category: components
|
|
@@ -67,130 +48,105 @@ let Checkbox = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
67
48
|
this._defaultId = void 0;
|
|
68
49
|
this._input = null;
|
|
69
50
|
this.ref = null;
|
|
70
|
-
|
|
71
51
|
this.handleRef = el => {
|
|
72
52
|
this.ref = el;
|
|
73
53
|
};
|
|
74
|
-
|
|
75
54
|
this.handleChange = e => {
|
|
76
55
|
const _this$props = this.props,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
56
|
+
onChange = _this$props.onChange,
|
|
57
|
+
disabled = _this$props.disabled,
|
|
58
|
+
checked = _this$props.checked,
|
|
59
|
+
readOnly = _this$props.readOnly;
|
|
82
60
|
if (disabled || readOnly) {
|
|
83
61
|
e.preventDefault();
|
|
84
62
|
return;
|
|
85
63
|
}
|
|
86
|
-
|
|
87
64
|
if (typeof checked === 'undefined') {
|
|
88
65
|
this.setState({
|
|
89
66
|
checked: !this.state.checked
|
|
90
67
|
});
|
|
91
68
|
}
|
|
92
|
-
|
|
93
69
|
if (typeof onChange === 'function') {
|
|
94
70
|
onChange(e);
|
|
95
71
|
}
|
|
96
72
|
};
|
|
97
|
-
|
|
98
73
|
this.handleKeyDown = e => {
|
|
99
74
|
if (this.props.variant === 'toggle' && e.keyCode === _keycode.default.codes.enter) {
|
|
100
75
|
this._input && this._input.click();
|
|
101
76
|
e.preventDefault();
|
|
102
77
|
}
|
|
103
78
|
};
|
|
104
|
-
|
|
105
79
|
this.handleFocus = () => {
|
|
106
80
|
this.setState({
|
|
107
81
|
focused: true
|
|
108
82
|
});
|
|
109
83
|
};
|
|
110
|
-
|
|
111
84
|
this.handleBlur = () => {
|
|
112
85
|
this.setState({
|
|
113
86
|
focused: false
|
|
114
87
|
});
|
|
115
88
|
};
|
|
116
|
-
|
|
117
89
|
this.handleMouseOver = () => {
|
|
118
90
|
this.setState({
|
|
119
91
|
hovered: true
|
|
120
92
|
});
|
|
121
93
|
};
|
|
122
|
-
|
|
123
94
|
this.handleMouseOut = () => {
|
|
124
95
|
this.setState({
|
|
125
96
|
hovered: false
|
|
126
97
|
});
|
|
127
98
|
};
|
|
128
|
-
|
|
129
99
|
this.state = {
|
|
130
100
|
focused: false,
|
|
131
101
|
hovered: false,
|
|
132
102
|
checked: typeof props.checked === 'undefined' ? !!props.defaultChecked : void 0
|
|
133
103
|
};
|
|
134
|
-
|
|
135
104
|
if (typeof props.checked === 'undefined') {
|
|
136
105
|
// @ts-expect-error ts-migrate(2339) FIXME: Property 'checked' does not exist on type 'Readonl... Remove this comment to see the full error message
|
|
137
106
|
this.state.checked = !!props.defaultChecked;
|
|
138
107
|
}
|
|
139
|
-
|
|
140
108
|
this._defaultId = props.deterministicId();
|
|
141
109
|
}
|
|
142
|
-
|
|
143
110
|
componentDidMount() {
|
|
144
111
|
var _this$props$makeStyle, _this$props2;
|
|
145
|
-
|
|
146
112
|
if (this._input) {
|
|
147
113
|
this._input.indeterminate = this.props.indeterminate;
|
|
148
114
|
}
|
|
149
|
-
|
|
150
115
|
(_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
|
|
151
116
|
}
|
|
152
|
-
|
|
153
117
|
componentDidUpdate(prevProps) {
|
|
154
118
|
var _this$props$makeStyle2, _this$props3;
|
|
155
|
-
|
|
156
119
|
if (prevProps.indeterminate !== this.props.indeterminate && this._input) {
|
|
157
120
|
this._input.indeterminate = this.props.indeterminate || false;
|
|
158
121
|
}
|
|
159
|
-
|
|
160
122
|
(_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
|
|
161
123
|
}
|
|
162
|
-
|
|
163
124
|
get id() {
|
|
164
125
|
return this.props.id || this._defaultId;
|
|
165
126
|
}
|
|
166
|
-
|
|
167
127
|
get checked() {
|
|
168
128
|
return typeof this.props.checked === 'undefined' ? this.state.checked : this.props.checked;
|
|
169
129
|
}
|
|
170
|
-
|
|
171
130
|
get focused() {
|
|
172
131
|
return (0, _isActiveElement.isActiveElement)(this._input);
|
|
173
132
|
}
|
|
174
|
-
|
|
175
133
|
focus() {
|
|
176
134
|
this._input && this._input.focus();
|
|
177
135
|
}
|
|
178
|
-
|
|
179
136
|
renderFacade() {
|
|
180
137
|
const _this$props4 = this.props,
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
138
|
+
size = _this$props4.size,
|
|
139
|
+
disabled = _this$props4.disabled,
|
|
140
|
+
variant = _this$props4.variant,
|
|
141
|
+
label = _this$props4.label,
|
|
142
|
+
readOnly = _this$props4.readOnly,
|
|
143
|
+
indeterminate = _this$props4.indeterminate,
|
|
144
|
+
labelPlacement = _this$props4.labelPlacement,
|
|
145
|
+
themeOverride = _this$props4.themeOverride;
|
|
189
146
|
const _this$state = this.state,
|
|
190
|
-
|
|
191
|
-
|
|
147
|
+
hovered = _this$state.hovered,
|
|
148
|
+
focused = _this$state.focused;
|
|
192
149
|
(0, _console.logError)(!(variant === 'simple' && labelPlacement !== 'end'), `[Checkbox] The \`simple\` variant does not support the \`labelPlacement\` property. Use the \`toggle\` variant instead.`);
|
|
193
|
-
|
|
194
150
|
if (variant === 'toggle') {
|
|
195
151
|
return (0, _emotion.jsx)(_ToggleFacade.ToggleFacade, {
|
|
196
152
|
disabled: disabled,
|
|
@@ -212,7 +168,6 @@ let Checkbox = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
212
168
|
}, label);
|
|
213
169
|
}
|
|
214
170
|
}
|
|
215
|
-
|
|
216
171
|
renderMessages() {
|
|
217
172
|
const messages = this.props.messages;
|
|
218
173
|
return messages && messages.length > 0 ? (0, _emotion.jsx)(_View.View, {
|
|
@@ -222,22 +177,22 @@ let Checkbox = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
222
177
|
messages: messages
|
|
223
178
|
})) : null;
|
|
224
179
|
}
|
|
225
|
-
|
|
226
180
|
render() {
|
|
227
181
|
const _this$props5 = this.props,
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
182
|
+
disabled = _this$props5.disabled,
|
|
183
|
+
readOnly = _this$props5.readOnly,
|
|
184
|
+
value = _this$props5.value,
|
|
185
|
+
onKeyDown = _this$props5.onKeyDown,
|
|
186
|
+
onFocus = _this$props5.onFocus,
|
|
187
|
+
onBlur = _this$props5.onBlur,
|
|
188
|
+
onMouseOver = _this$props5.onMouseOver,
|
|
189
|
+
onMouseOut = _this$props5.onMouseOut,
|
|
190
|
+
indeterminate = _this$props5.indeterminate,
|
|
191
|
+
variant = _this$props5.variant,
|
|
192
|
+
styles = _this$props5.styles;
|
|
239
193
|
const props = (0, _omitProps.omitProps)(this.props, Checkbox.allowedProps);
|
|
240
194
|
(0, _console.logError)(!(variant === 'toggle' && indeterminate), `[Checkbox] The \`toggle\` variant does not support the \`indeterminate\` property. Use the \`simple\` variant instead.`);
|
|
195
|
+
|
|
241
196
|
/* eslint-disable jsx-a11y/mouse-events-have-key-events */
|
|
242
197
|
|
|
243
198
|
return (0, _emotion.jsx)("div", {
|
|
@@ -264,9 +219,9 @@ let Checkbox = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
264
219
|
htmlFor: this.id,
|
|
265
220
|
css: styles === null || styles === void 0 ? void 0 : styles.control
|
|
266
221
|
}, this.renderFacade(), this.renderMessages()));
|
|
222
|
+
|
|
267
223
|
/* eslint-enable jsx-a11y/mouse-events-have-key-events */
|
|
268
224
|
}
|
|
269
|
-
|
|
270
225
|
}, _class2.displayName = "Checkbox", _class2.componentId = 'Checkbox', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
|
|
271
226
|
size: 'medium',
|
|
272
227
|
variant: 'simple',
|