@instructure/ui-checkbox 8.8.1-snapshot.3 → 8.9.0
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 +6 -0
- package/es/Checkbox/CheckboxFacade/index.js +5 -20
- package/{src/CheckboxGroup/types.ts → es/Checkbox/CheckboxFacade/props.js} +14 -15
- package/es/Checkbox/ToggleFacade/index.js +9 -21
- package/{src/Checkbox/CheckboxFacade/types.ts → es/Checkbox/ToggleFacade/props.js} +12 -10
- package/es/Checkbox/index.js +7 -72
- package/es/Checkbox/props.js +78 -0
- package/es/CheckboxGroup/index.js +3 -43
- package/es/CheckboxGroup/props.js +65 -0
- package/lib/Checkbox/CheckboxFacade/index.js +6 -21
- package/lib/Checkbox/CheckboxFacade/props.js +49 -0
- package/lib/Checkbox/ToggleFacade/index.js +10 -22
- package/{src/Checkbox/types.ts → lib/Checkbox/ToggleFacade/props.js} +23 -26
- package/lib/Checkbox/index.js +7 -75
- package/lib/Checkbox/props.js +91 -0
- package/lib/CheckboxGroup/index.js +3 -50
- package/lib/CheckboxGroup/props.js +81 -0
- package/package.json +20 -21
- package/src/Checkbox/CheckboxFacade/index.tsx +8 -21
- package/src/Checkbox/CheckboxFacade/props.ts +67 -0
- package/src/Checkbox/CheckboxFacade/styles.ts +1 -1
- package/src/Checkbox/ToggleFacade/index.tsx +12 -23
- package/src/Checkbox/ToggleFacade/{types.ts → props.ts} +36 -3
- package/src/Checkbox/ToggleFacade/styles.ts +1 -1
- package/src/Checkbox/index.tsx +10 -68
- package/src/Checkbox/props.ts +129 -0
- package/src/Checkbox/styles.ts +1 -1
- package/src/CheckboxGroup/index.tsx +6 -43
- package/src/CheckboxGroup/props.ts +106 -0
- package/src/index.ts +4 -4
- package/types/Checkbox/CheckboxFacade/index.d.ts +17 -15
- package/types/Checkbox/CheckboxFacade/index.d.ts.map +1 -1
- package/types/Checkbox/CheckboxFacade/props.d.ts +19 -0
- package/types/Checkbox/CheckboxFacade/props.d.ts.map +1 -0
- package/types/Checkbox/CheckboxFacade/styles.d.ts +1 -1
- package/types/Checkbox/ToggleFacade/index.d.ts +19 -13
- package/types/Checkbox/ToggleFacade/index.d.ts.map +1 -1
- package/types/Checkbox/ToggleFacade/props.d.ts +20 -0
- package/types/Checkbox/ToggleFacade/props.d.ts.map +1 -0
- package/types/Checkbox/ToggleFacade/styles.d.ts +1 -1
- package/types/Checkbox/index.d.ts +43 -60
- package/types/Checkbox/index.d.ts.map +1 -1
- package/types/Checkbox/{types.d.ts → props.d.ts} +11 -4
- package/types/Checkbox/props.d.ts.map +1 -0
- package/types/Checkbox/styles.d.ts +1 -1
- package/types/CheckboxGroup/index.d.ts +28 -44
- package/types/CheckboxGroup/index.d.ts.map +1 -1
- package/types/CheckboxGroup/props.d.ts +24 -0
- package/types/CheckboxGroup/props.d.ts.map +1 -0
- package/types/index.d.ts +4 -4
- package/LICENSE.md +0 -27
- package/es/Checkbox/CheckboxFacade/types.js +0 -1
- package/es/Checkbox/ToggleFacade/types.js +0 -1
- package/es/Checkbox/types.js +0 -1
- package/es/CheckboxGroup/types.js +0 -1
- package/lib/Checkbox/CheckboxFacade/types.js +0 -1
- package/lib/Checkbox/ToggleFacade/types.js +0 -1
- package/lib/Checkbox/types.js +0 -1
- package/lib/CheckboxGroup/types.js +0 -1
- package/types/Checkbox/CheckboxFacade/types.d.ts +0 -10
- package/types/Checkbox/CheckboxFacade/types.d.ts.map +0 -1
- package/types/Checkbox/ToggleFacade/types.d.ts +0 -11
- package/types/Checkbox/ToggleFacade/types.d.ts.map +0 -1
- package/types/Checkbox/types.d.ts.map +0 -1
- package/types/CheckboxGroup/types.d.ts +0 -15
- package/types/CheckboxGroup/types.d.ts.map +0 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
import PropTypes from 'prop-types';
|
|
25
|
+
import { FormPropTypes } from '@instructure/ui-form-field';
|
|
26
|
+
import { controllable, Children as ChildrenPropTypes } from '@instructure/ui-prop-types';
|
|
27
|
+
import { Checkbox } from '../Checkbox';
|
|
28
|
+
const propTypes = {
|
|
29
|
+
name: PropTypes.string.isRequired,
|
|
30
|
+
description: PropTypes.node.isRequired,
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* value to set on initial render
|
|
34
|
+
*/
|
|
35
|
+
defaultValue: PropTypes.array,
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* the selected values (must be accompanied by an `onChange` prop)
|
|
39
|
+
*/
|
|
40
|
+
value: controllable(PropTypes.array),
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* when used with the `value` prop, the component will not control its own state
|
|
44
|
+
*/
|
|
45
|
+
onChange: PropTypes.func,
|
|
46
|
+
disabled: PropTypes.bool,
|
|
47
|
+
readOnly: PropTypes.bool,
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* object with shape: `{
|
|
51
|
+
text: PropTypes.string,
|
|
52
|
+
type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
|
|
53
|
+
}`
|
|
54
|
+
*/
|
|
55
|
+
messages: PropTypes.arrayOf(FormPropTypes.message),
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* children of type `Checkbox`
|
|
59
|
+
*/
|
|
60
|
+
children: ChildrenPropTypes.oneOf([Checkbox]),
|
|
61
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
62
|
+
layout: PropTypes.oneOf(['stacked', 'columns', 'inline'])
|
|
63
|
+
};
|
|
64
|
+
const allowedProps = ['name', 'description', 'defaultValue', 'value', 'onChange', 'disabled', 'readOnly', 'messages', 'children', 'size', 'layout'];
|
|
65
|
+
export { propTypes, allowedProps };
|
|
@@ -9,8 +9,6 @@ exports.CheckboxFacade = exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _react = require("react");
|
|
11
11
|
|
|
12
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
12
|
var _SVGIcon2 = require("@instructure/ui-svg-images/lib/SVGIcon");
|
|
15
13
|
|
|
16
14
|
var _IconCheckMarkSolid2 = require("@instructure/ui-icons/lib/IconCheckMarkSolid.js");
|
|
@@ -21,6 +19,8 @@ var _styles = _interopRequireDefault(require("./styles"));
|
|
|
21
19
|
|
|
22
20
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
23
21
|
|
|
22
|
+
var _props = require("./props");
|
|
23
|
+
|
|
24
24
|
var _dec, _class, _class2, _temp, _SVGIcon, _IconCheckMarkSolid;
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -62,31 +62,16 @@ let CheckboxFacade = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.def
|
|
|
62
62
|
children = _this$props.children,
|
|
63
63
|
styles = _this$props.styles;
|
|
64
64
|
return (0, _emotion.jsx)("span", {
|
|
65
|
-
css: styles.checkboxFacade
|
|
65
|
+
css: styles === null || styles === void 0 ? void 0 : styles.checkboxFacade
|
|
66
66
|
}, (0, _emotion.jsx)("span", {
|
|
67
|
-
css: styles.facade,
|
|
67
|
+
css: styles === null || styles === void 0 ? void 0 : styles.facade,
|
|
68
68
|
"aria-hidden": "true"
|
|
69
69
|
}, this.renderIcon()), (0, _emotion.jsx)("span", {
|
|
70
|
-
css: styles.label
|
|
70
|
+
css: styles === null || styles === void 0 ? void 0 : styles.label
|
|
71
71
|
}, children));
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
}, _class2.displayName = "CheckboxFacade", _class2.componentId = 'CheckboxFacade', _class2.propTypes = {
|
|
75
|
-
// eslint-disable-next-line react/require-default-props
|
|
76
|
-
makeStyles: _propTypes.default.func,
|
|
77
|
-
// eslint-disable-next-line react/require-default-props
|
|
78
|
-
styles: _propTypes.default.object,
|
|
79
|
-
children: _propTypes.default.node.isRequired,
|
|
80
|
-
checked: _propTypes.default.bool,
|
|
81
|
-
focused: _propTypes.default.bool,
|
|
82
|
-
hovered: _propTypes.default.bool,
|
|
83
|
-
size: _propTypes.default.oneOf(['small', 'medium', 'large']),
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Visual state showing that child checkboxes are a combination of checked and unchecked
|
|
87
|
-
*/
|
|
88
|
-
indeterminate: _propTypes.default.bool
|
|
89
|
-
}, _class2.defaultProps = {
|
|
74
|
+
}, _class2.displayName = "CheckboxFacade", _class2.componentId = 'CheckboxFacade', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
|
|
90
75
|
checked: false,
|
|
91
76
|
focused: false,
|
|
92
77
|
hovered: false,
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.allowedProps = exports.propTypes = void 0;
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* The MIT License (MIT)
|
|
14
|
+
*
|
|
15
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
16
|
+
*
|
|
17
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
18
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
19
|
+
* in the Software without restriction, including without limitation the rights
|
|
20
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
21
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
22
|
+
* furnished to do so, subject to the following conditions:
|
|
23
|
+
*
|
|
24
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
25
|
+
* copies or substantial portions of the Software.
|
|
26
|
+
*
|
|
27
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
28
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
29
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
30
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
31
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
32
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
|
+
* SOFTWARE.
|
|
34
|
+
*/
|
|
35
|
+
const propTypes = {
|
|
36
|
+
children: _propTypes.default.node.isRequired,
|
|
37
|
+
checked: _propTypes.default.bool,
|
|
38
|
+
focused: _propTypes.default.bool,
|
|
39
|
+
hovered: _propTypes.default.bool,
|
|
40
|
+
size: _propTypes.default.oneOf(['small', 'medium', 'large']),
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Visual state showing that child checkboxes are a combination of checked and unchecked
|
|
44
|
+
*/
|
|
45
|
+
indeterminate: _propTypes.default.bool
|
|
46
|
+
};
|
|
47
|
+
exports.propTypes = propTypes;
|
|
48
|
+
const allowedProps = ['children', 'checked', 'focused', 'hovered', 'size', 'indeterminate'];
|
|
49
|
+
exports.allowedProps = allowedProps;
|
|
@@ -9,8 +9,6 @@ exports.ToggleFacade = exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _react = require("react");
|
|
11
11
|
|
|
12
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
12
|
var _IconCheckSolid = require("@instructure/ui-icons/lib/IconCheckSolid.js");
|
|
15
13
|
|
|
16
14
|
var _IconXSolid = require("@instructure/ui-icons/lib/IconXSolid.js");
|
|
@@ -21,6 +19,8 @@ var _styles = _interopRequireDefault(require("./styles"));
|
|
|
21
19
|
|
|
22
20
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
23
21
|
|
|
22
|
+
var _props = require("./props");
|
|
23
|
+
|
|
24
24
|
var _dec, _class, _class2, _temp;
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -44,11 +44,11 @@ let ToggleFacade = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defau
|
|
|
44
44
|
|
|
45
45
|
if (checked) {
|
|
46
46
|
return (0, _emotion.jsx)(_IconCheckSolid.IconCheckSolid, {
|
|
47
|
-
css: styles.iconSVG
|
|
47
|
+
css: styles === null || styles === void 0 ? void 0 : styles.iconSVG
|
|
48
48
|
});
|
|
49
49
|
} else {
|
|
50
50
|
return (0, _emotion.jsx)(_IconXSolid.IconXSolid, {
|
|
51
|
-
css: styles.iconSVG
|
|
51
|
+
css: styles === null || styles === void 0 ? void 0 : styles.iconSVG
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -58,7 +58,7 @@ let ToggleFacade = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defau
|
|
|
58
58
|
children = _this$props2.children,
|
|
59
59
|
styles = _this$props2.styles;
|
|
60
60
|
return (0, _emotion.jsx)("span", {
|
|
61
|
-
css: styles.label
|
|
61
|
+
css: styles === null || styles === void 0 ? void 0 : styles.label
|
|
62
62
|
}, children);
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -67,30 +67,18 @@ let ToggleFacade = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defau
|
|
|
67
67
|
labelPlacement = _this$props3.labelPlacement,
|
|
68
68
|
styles = _this$props3.styles;
|
|
69
69
|
return (0, _emotion.jsx)("span", {
|
|
70
|
-
css: styles.toggleFacade
|
|
70
|
+
css: styles === null || styles === void 0 ? void 0 : styles.toggleFacade
|
|
71
71
|
}, (labelPlacement === 'top' || labelPlacement === 'start') && this.renderLabel(), (0, _emotion.jsx)("span", {
|
|
72
|
-
css: styles.facade,
|
|
72
|
+
css: styles === null || styles === void 0 ? void 0 : styles.facade,
|
|
73
73
|
"aria-hidden": "true"
|
|
74
74
|
}, (0, _emotion.jsx)("span", {
|
|
75
|
-
css: styles.icon
|
|
75
|
+
css: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
76
76
|
}, (0, _emotion.jsx)("span", {
|
|
77
|
-
css: styles.iconToggle
|
|
77
|
+
css: styles === null || styles === void 0 ? void 0 : styles.iconToggle
|
|
78
78
|
}, this.renderIcon()))), labelPlacement === 'end' && this.renderLabel());
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
}, _class2.displayName = "ToggleFacade", _class2.componentId = 'ToggleFacade', _class2.propTypes = {
|
|
82
|
-
// eslint-disable-next-line react/require-default-props
|
|
83
|
-
makeStyles: _propTypes.default.func,
|
|
84
|
-
// eslint-disable-next-line react/require-default-props
|
|
85
|
-
styles: _propTypes.default.object,
|
|
86
|
-
children: _propTypes.default.node.isRequired,
|
|
87
|
-
checked: _propTypes.default.bool,
|
|
88
|
-
disabled: _propTypes.default.bool,
|
|
89
|
-
readOnly: _propTypes.default.bool,
|
|
90
|
-
focused: _propTypes.default.bool,
|
|
91
|
-
size: _propTypes.default.oneOf(['small', 'medium', 'large']),
|
|
92
|
-
labelPlacement: _propTypes.default.oneOf(['top', 'start', 'end'])
|
|
93
|
-
}, _class2.defaultProps = {
|
|
81
|
+
}, _class2.displayName = "ToggleFacade", _class2.componentId = 'ToggleFacade', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
|
|
94
82
|
checked: false,
|
|
95
83
|
focused: false,
|
|
96
84
|
size: 'medium',
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.allowedProps = exports.propTypes = void 0;
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
1
12
|
/*
|
|
2
13
|
* The MIT License (MIT)
|
|
3
14
|
*
|
|
@@ -21,29 +32,15 @@
|
|
|
21
32
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
33
|
* SOFTWARE.
|
|
23
34
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
onChange?: (...args: any[]) => any
|
|
37
|
-
onKeyDown?: (...args: any[]) => any
|
|
38
|
-
onFocus?: (...args: any[]) => any
|
|
39
|
-
onBlur?: (...args: any[]) => any
|
|
40
|
-
onMouseOver?: (...args: any[]) => any
|
|
41
|
-
onMouseOut?: (...args: any[]) => any
|
|
42
|
-
disabled?: boolean
|
|
43
|
-
readOnly?: boolean
|
|
44
|
-
indeterminate?: boolean
|
|
45
|
-
size?: 'small' | 'medium' | 'large'
|
|
46
|
-
variant?: 'simple' | 'toggle'
|
|
47
|
-
inline?: boolean
|
|
48
|
-
labelPlacement?: 'top' | 'start' | 'end'
|
|
49
|
-
}
|
|
35
|
+
const propTypes = {
|
|
36
|
+
children: _propTypes.default.node.isRequired,
|
|
37
|
+
checked: _propTypes.default.bool,
|
|
38
|
+
disabled: _propTypes.default.bool,
|
|
39
|
+
readOnly: _propTypes.default.bool,
|
|
40
|
+
focused: _propTypes.default.bool,
|
|
41
|
+
size: _propTypes.default.oneOf(['small', 'medium', 'large']),
|
|
42
|
+
labelPlacement: _propTypes.default.oneOf(['top', 'start', 'end'])
|
|
43
|
+
};
|
|
44
|
+
exports.propTypes = propTypes;
|
|
45
|
+
const allowedProps = ['children', 'checked', 'disabled', 'readOnly', 'focused', 'size', 'labelPlacement'];
|
|
46
|
+
exports.allowedProps = allowedProps;
|
package/lib/Checkbox/index.js
CHANGED
|
@@ -21,14 +21,8 @@ exports.Checkbox = exports.default = void 0;
|
|
|
21
21
|
|
|
22
22
|
var _react = require("react");
|
|
23
23
|
|
|
24
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
25
|
-
|
|
26
24
|
var _keycode = _interopRequireDefault(require("keycode"));
|
|
27
25
|
|
|
28
|
-
var _controllable = require("@instructure/ui-prop-types/lib/controllable.js");
|
|
29
|
-
|
|
30
|
-
var _FormPropTypes = require("@instructure/ui-form-field/lib/FormPropTypes.js");
|
|
31
|
-
|
|
32
26
|
var _FormFieldMessages = require("@instructure/ui-form-field/lib/FormFieldMessages");
|
|
33
27
|
|
|
34
28
|
var _createChainedFunction = require("@instructure/ui-utils/lib/createChainedFunction.js");
|
|
@@ -53,6 +47,8 @@ var _ToggleFacade = require("./ToggleFacade");
|
|
|
53
47
|
|
|
54
48
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
55
49
|
|
|
50
|
+
var _props = require("./props");
|
|
51
|
+
|
|
56
52
|
var _dec, _dec2, _class, _class2, _temp;
|
|
57
53
|
|
|
58
54
|
/**
|
|
@@ -229,7 +225,7 @@ let Checkbox = (_dec = (0, _emotion.withStyle)(_styles.default, null), _dec2 = (
|
|
|
229
225
|
/* eslint-disable jsx-a11y/mouse-events-have-key-events */
|
|
230
226
|
|
|
231
227
|
return (0, _emotion.jsx)("div", {
|
|
232
|
-
css: styles.checkbox,
|
|
228
|
+
css: styles === null || styles === void 0 ? void 0 : styles.checkbox,
|
|
233
229
|
onMouseOver: (0, _createChainedFunction.createChainedFunction)(onMouseOver, this.handleMouseOver),
|
|
234
230
|
onMouseOut: (0, _createChainedFunction.createChainedFunction)(onMouseOut, this.handleMouseOut)
|
|
235
231
|
}, (0, _emotion.jsx)("input", Object.assign({}, props, {
|
|
@@ -240,8 +236,8 @@ let Checkbox = (_dec = (0, _emotion.withStyle)(_styles.default, null), _dec2 = (
|
|
|
240
236
|
this._input = c;
|
|
241
237
|
},
|
|
242
238
|
disabled: disabled || readOnly,
|
|
243
|
-
"aria-checked": indeterminate ? 'mixed' :
|
|
244
|
-
css: styles.input,
|
|
239
|
+
"aria-checked": indeterminate ? 'mixed' : void 0,
|
|
240
|
+
css: styles === null || styles === void 0 ? void 0 : styles.input,
|
|
245
241
|
onChange: this.handleChange,
|
|
246
242
|
onKeyDown: (0, _createChainedFunction.createChainedFunction)(onKeyDown, this.handleKeyDown),
|
|
247
243
|
onFocus: (0, _createChainedFunction.createChainedFunction)(onFocus, this.handleFocus),
|
|
@@ -249,82 +245,18 @@ let Checkbox = (_dec = (0, _emotion.withStyle)(_styles.default, null), _dec2 = (
|
|
|
249
245
|
checked: this.checked
|
|
250
246
|
})), (0, _emotion.jsx)("label", {
|
|
251
247
|
htmlFor: this.id,
|
|
252
|
-
css: styles.control
|
|
248
|
+
css: styles === null || styles === void 0 ? void 0 : styles.control
|
|
253
249
|
}, this.renderFacade(), this.renderMessages()));
|
|
254
250
|
/* eslint-enable jsx-a11y/mouse-events-have-key-events */
|
|
255
251
|
}
|
|
256
252
|
|
|
257
|
-
}, _class2.displayName = "Checkbox", _class2.componentId = 'Checkbox', _class2.propTypes = {
|
|
258
|
-
// eslint-disable-next-line react/require-default-props
|
|
259
|
-
makeStyles: _propTypes.default.func,
|
|
260
|
-
// eslint-disable-next-line react/require-default-props
|
|
261
|
-
styles: _propTypes.default.object,
|
|
262
|
-
label: _propTypes.default.node.isRequired,
|
|
263
|
-
id: _propTypes.default.string,
|
|
264
|
-
value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* object with shape: `{
|
|
268
|
-
* text: PropTypes.string,
|
|
269
|
-
* type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
|
|
270
|
-
* }`
|
|
271
|
-
*/
|
|
272
|
-
messages: _propTypes.default.arrayOf(_FormPropTypes.FormPropTypes.message),
|
|
273
|
-
|
|
274
|
-
/* whether to set the input to checked or not on initial render */
|
|
275
|
-
defaultChecked: _propTypes.default.bool,
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* whether the input is checked or not (must be accompanied by an `onChange` prop)
|
|
279
|
-
*/
|
|
280
|
-
checked: (0, _controllable.controllable)(_propTypes.default.bool, 'onChange', 'defaultChecked'),
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* when used with the `checked` prop, the component will not control its own state
|
|
284
|
-
*/
|
|
285
|
-
onChange: _propTypes.default.func,
|
|
286
|
-
onKeyDown: _propTypes.default.func,
|
|
287
|
-
onFocus: _propTypes.default.func,
|
|
288
|
-
onBlur: _propTypes.default.func,
|
|
289
|
-
onMouseOver: _propTypes.default.func,
|
|
290
|
-
onMouseOut: _propTypes.default.func,
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* Whether or not to disable the checkbox
|
|
294
|
-
*/
|
|
295
|
-
disabled: _propTypes.default.bool,
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* Works just like disabled but keeps the same styles as if it were active
|
|
299
|
-
*/
|
|
300
|
-
readOnly: _propTypes.default.bool,
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* Visual state showing that child checkboxes are a combination of checked and unchecked
|
|
304
|
-
*/
|
|
305
|
-
indeterminate: _propTypes.default.bool,
|
|
306
|
-
size: _propTypes.default.oneOf(['small', 'medium', 'large']),
|
|
307
|
-
variant: _propTypes.default.oneOf(['simple', 'toggle']),
|
|
308
|
-
inline: _propTypes.default.bool,
|
|
309
|
-
labelPlacement: _propTypes.default.oneOf(['top', 'start', 'end'])
|
|
310
|
-
}, _class2.defaultProps = {
|
|
253
|
+
}, _class2.displayName = "Checkbox", _class2.componentId = 'Checkbox', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
|
|
311
254
|
size: 'medium',
|
|
312
255
|
variant: 'simple',
|
|
313
256
|
disabled: false,
|
|
314
257
|
inline: false,
|
|
315
258
|
indeterminate: false,
|
|
316
259
|
readOnly: false,
|
|
317
|
-
onChange: void 0,
|
|
318
|
-
onKeyDown: void 0,
|
|
319
|
-
onFocus: void 0,
|
|
320
|
-
onBlur: void 0,
|
|
321
|
-
onMouseOut: void 0,
|
|
322
|
-
onMouseOver: void 0,
|
|
323
|
-
checked: void 0,
|
|
324
|
-
defaultChecked: void 0,
|
|
325
|
-
messages: void 0,
|
|
326
|
-
id: void 0,
|
|
327
|
-
value: void 0,
|
|
328
260
|
labelPlacement: 'end'
|
|
329
261
|
}, _temp)) || _class) || _class);
|
|
330
262
|
exports.Checkbox = Checkbox;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.allowedProps = exports.propTypes = void 0;
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _FormPropTypes = require("@instructure/ui-form-field/lib/FormPropTypes.js");
|
|
13
|
+
|
|
14
|
+
var _controllable = require("@instructure/ui-prop-types/lib/controllable.js");
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
* The MIT License (MIT)
|
|
18
|
+
*
|
|
19
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
20
|
+
*
|
|
21
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
22
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
23
|
+
* in the Software without restriction, including without limitation the rights
|
|
24
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
25
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
26
|
+
* furnished to do so, subject to the following conditions:
|
|
27
|
+
*
|
|
28
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
29
|
+
* copies or substantial portions of the Software.
|
|
30
|
+
*
|
|
31
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
32
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
33
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
34
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
35
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
36
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
37
|
+
* SOFTWARE.
|
|
38
|
+
*/
|
|
39
|
+
const propTypes = {
|
|
40
|
+
label: _propTypes.default.node.isRequired,
|
|
41
|
+
id: _propTypes.default.string,
|
|
42
|
+
value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* object with shape: `{
|
|
46
|
+
* text: PropTypes.string,
|
|
47
|
+
* type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
|
|
48
|
+
* }`
|
|
49
|
+
*/
|
|
50
|
+
messages: _propTypes.default.arrayOf(_FormPropTypes.FormPropTypes.message),
|
|
51
|
+
|
|
52
|
+
/* whether to set the input to checked or not on initial render */
|
|
53
|
+
defaultChecked: _propTypes.default.bool,
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* whether the input is checked or not (must be accompanied by an `onChange` prop)
|
|
57
|
+
*/
|
|
58
|
+
checked: (0, _controllable.controllable)(_propTypes.default.bool, 'onChange', 'defaultChecked'),
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* when used with the `checked` prop, the component will not control its own state
|
|
62
|
+
*/
|
|
63
|
+
onChange: _propTypes.default.func,
|
|
64
|
+
onKeyDown: _propTypes.default.func,
|
|
65
|
+
onFocus: _propTypes.default.func,
|
|
66
|
+
onBlur: _propTypes.default.func,
|
|
67
|
+
onMouseOver: _propTypes.default.func,
|
|
68
|
+
onMouseOut: _propTypes.default.func,
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Whether or not to disable the checkbox
|
|
72
|
+
*/
|
|
73
|
+
disabled: _propTypes.default.bool,
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Works just like disabled but keeps the same styles as if it were active
|
|
77
|
+
*/
|
|
78
|
+
readOnly: _propTypes.default.bool,
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Visual state showing that child checkboxes are a combination of checked and unchecked
|
|
82
|
+
*/
|
|
83
|
+
indeterminate: _propTypes.default.bool,
|
|
84
|
+
size: _propTypes.default.oneOf(['small', 'medium', 'large']),
|
|
85
|
+
variant: _propTypes.default.oneOf(['simple', 'toggle']),
|
|
86
|
+
inline: _propTypes.default.bool,
|
|
87
|
+
labelPlacement: _propTypes.default.oneOf(['top', 'start', 'end'])
|
|
88
|
+
};
|
|
89
|
+
exports.propTypes = propTypes;
|
|
90
|
+
const allowedProps = ['label', 'id', 'value', 'messages', 'defaultChecked', 'checked', 'onChange', 'onKeyDown', 'onFocus', 'onBlur', 'onMouseOver', 'onMouseOut', 'disabled', 'readOnly', 'indeterminate', 'size', 'variant', 'inline', 'labelPlacement'];
|
|
91
|
+
exports.allowedProps = allowedProps;
|