@instructure/ui-checkbox 8.8.1-snapshot.8 → 8.9.1
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 +10 -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 +6 -71
- 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 +6 -74
- 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 +9 -66
- 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
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
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.9.1](https://github.com/instructure/instructure-ui/compare/v8.9.0...v8.9.1) (2021-09-16)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-checkbox
|
|
9
|
+
|
|
10
|
+
# [8.9.0](https://github.com/instructure/instructure-ui/compare/v8.8.0...v8.9.0) (2021-09-15)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- fix shared-types TS errors ([7b83164](https://github.com/instructure/instructure-ui/commit/7b83164f4c5872f3a217e010563f59bf584ae4fc))
|
|
15
|
+
|
|
6
16
|
# [8.8.0](https://github.com/instructure/instructure-ui/compare/v8.7.0...v8.8.0) (2021-08-27)
|
|
7
17
|
|
|
8
18
|
### Features
|
|
@@ -26,12 +26,12 @@ var _dec, _class, _class2, _temp, _SVGIcon, _IconCheckMarkSolid;
|
|
|
26
26
|
|
|
27
27
|
/** @jsx jsx */
|
|
28
28
|
import { Component } from 'react';
|
|
29
|
-
import PropTypes from 'prop-types';
|
|
30
29
|
import { SVGIcon } from '@instructure/ui-svg-images';
|
|
31
30
|
import { IconCheckMarkSolid } from '@instructure/ui-icons';
|
|
32
31
|
import { withStyle, jsx } from '@instructure/emotion';
|
|
33
32
|
import generateStyle from './styles';
|
|
34
33
|
import generateComponentTheme from './theme';
|
|
34
|
+
import { propTypes, allowedProps } from './props';
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
---
|
|
@@ -72,31 +72,16 @@ let CheckboxFacade = (_dec = withStyle(generateStyle, generateComponentTheme), _
|
|
|
72
72
|
children = _this$props.children,
|
|
73
73
|
styles = _this$props.styles;
|
|
74
74
|
return jsx("span", {
|
|
75
|
-
css: styles.checkboxFacade
|
|
75
|
+
css: styles === null || styles === void 0 ? void 0 : styles.checkboxFacade
|
|
76
76
|
}, jsx("span", {
|
|
77
|
-
css: styles.facade,
|
|
77
|
+
css: styles === null || styles === void 0 ? void 0 : styles.facade,
|
|
78
78
|
"aria-hidden": "true"
|
|
79
79
|
}, this.renderIcon()), jsx("span", {
|
|
80
|
-
css: styles.label
|
|
80
|
+
css: styles === null || styles === void 0 ? void 0 : styles.label
|
|
81
81
|
}, children));
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
}, _class2.displayName = "CheckboxFacade", _class2.componentId = 'CheckboxFacade', _class2.propTypes = {
|
|
85
|
-
// eslint-disable-next-line react/require-default-props
|
|
86
|
-
makeStyles: PropTypes.func,
|
|
87
|
-
// eslint-disable-next-line react/require-default-props
|
|
88
|
-
styles: PropTypes.object,
|
|
89
|
-
children: PropTypes.node.isRequired,
|
|
90
|
-
checked: PropTypes.bool,
|
|
91
|
-
focused: PropTypes.bool,
|
|
92
|
-
hovered: PropTypes.bool,
|
|
93
|
-
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Visual state showing that child checkboxes are a combination of checked and unchecked
|
|
97
|
-
*/
|
|
98
|
-
indeterminate: PropTypes.bool
|
|
99
|
-
}, _class2.defaultProps = {
|
|
84
|
+
}, _class2.displayName = "CheckboxFacade", _class2.componentId = 'CheckboxFacade', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
100
85
|
checked: false,
|
|
101
86
|
focused: false,
|
|
102
87
|
hovered: false,
|
|
@@ -21,19 +21,18 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
import PropTypes from 'prop-types';
|
|
25
|
+
const propTypes = {
|
|
26
|
+
children: PropTypes.node.isRequired,
|
|
27
|
+
checked: PropTypes.bool,
|
|
28
|
+
focused: PropTypes.bool,
|
|
29
|
+
hovered: PropTypes.bool,
|
|
30
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
24
31
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
value?: any // TODO: controllable(PropTypes.array)
|
|
33
|
-
onChange?: (...args: any[]) => any
|
|
34
|
-
disabled?: boolean
|
|
35
|
-
readOnly?: boolean
|
|
36
|
-
messages?: FormMessage[]
|
|
37
|
-
size?: 'small' | 'medium' | 'large'
|
|
38
|
-
layout?: 'stacked' | 'columns' | 'inline'
|
|
39
|
-
}
|
|
32
|
+
/**
|
|
33
|
+
* Visual state showing that child checkboxes are a combination of checked and unchecked
|
|
34
|
+
*/
|
|
35
|
+
indeterminate: PropTypes.bool
|
|
36
|
+
};
|
|
37
|
+
const allowedProps = ['children', 'checked', 'focused', 'hovered', 'size', 'indeterminate'];
|
|
38
|
+
export { propTypes, allowedProps };
|
|
@@ -26,11 +26,11 @@ var _dec, _class, _class2, _temp;
|
|
|
26
26
|
|
|
27
27
|
/** @jsx jsx */
|
|
28
28
|
import { Component } from 'react';
|
|
29
|
-
import PropTypes from 'prop-types';
|
|
30
29
|
import { IconCheckSolid, IconXSolid } from '@instructure/ui-icons';
|
|
31
30
|
import { withStyle, jsx } from '@instructure/emotion';
|
|
32
31
|
import generateStyle from './styles';
|
|
33
32
|
import generateComponentTheme from './theme';
|
|
33
|
+
import { propTypes, allowedProps } from './props';
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
---
|
|
@@ -53,11 +53,11 @@ let ToggleFacade = (_dec = withStyle(generateStyle, generateComponentTheme), _de
|
|
|
53
53
|
|
|
54
54
|
if (checked) {
|
|
55
55
|
return jsx(IconCheckSolid, {
|
|
56
|
-
css: styles.iconSVG
|
|
56
|
+
css: styles === null || styles === void 0 ? void 0 : styles.iconSVG
|
|
57
57
|
});
|
|
58
58
|
} else {
|
|
59
59
|
return jsx(IconXSolid, {
|
|
60
|
-
css: styles.iconSVG
|
|
60
|
+
css: styles === null || styles === void 0 ? void 0 : styles.iconSVG
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -67,7 +67,7 @@ let ToggleFacade = (_dec = withStyle(generateStyle, generateComponentTheme), _de
|
|
|
67
67
|
children = _this$props2.children,
|
|
68
68
|
styles = _this$props2.styles;
|
|
69
69
|
return jsx("span", {
|
|
70
|
-
css: styles.label
|
|
70
|
+
css: styles === null || styles === void 0 ? void 0 : styles.label
|
|
71
71
|
}, children);
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -76,30 +76,18 @@ let ToggleFacade = (_dec = withStyle(generateStyle, generateComponentTheme), _de
|
|
|
76
76
|
labelPlacement = _this$props3.labelPlacement,
|
|
77
77
|
styles = _this$props3.styles;
|
|
78
78
|
return jsx("span", {
|
|
79
|
-
css: styles.toggleFacade
|
|
79
|
+
css: styles === null || styles === void 0 ? void 0 : styles.toggleFacade
|
|
80
80
|
}, (labelPlacement === 'top' || labelPlacement === 'start') && this.renderLabel(), jsx("span", {
|
|
81
|
-
css: styles.facade,
|
|
81
|
+
css: styles === null || styles === void 0 ? void 0 : styles.facade,
|
|
82
82
|
"aria-hidden": "true"
|
|
83
83
|
}, jsx("span", {
|
|
84
|
-
css: styles.icon
|
|
84
|
+
css: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
85
85
|
}, jsx("span", {
|
|
86
|
-
css: styles.iconToggle
|
|
86
|
+
css: styles === null || styles === void 0 ? void 0 : styles.iconToggle
|
|
87
87
|
}, this.renderIcon()))), labelPlacement === 'end' && this.renderLabel());
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
}, _class2.displayName = "ToggleFacade", _class2.componentId = 'ToggleFacade', _class2.propTypes = {
|
|
91
|
-
// eslint-disable-next-line react/require-default-props
|
|
92
|
-
makeStyles: PropTypes.func,
|
|
93
|
-
// eslint-disable-next-line react/require-default-props
|
|
94
|
-
styles: PropTypes.object,
|
|
95
|
-
children: PropTypes.node.isRequired,
|
|
96
|
-
checked: PropTypes.bool,
|
|
97
|
-
disabled: PropTypes.bool,
|
|
98
|
-
readOnly: PropTypes.bool,
|
|
99
|
-
focused: PropTypes.bool,
|
|
100
|
-
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
101
|
-
labelPlacement: PropTypes.oneOf(['top', 'start', 'end'])
|
|
102
|
-
}, _class2.defaultProps = {
|
|
90
|
+
}, _class2.displayName = "ToggleFacade", _class2.componentId = 'ToggleFacade', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
103
91
|
checked: false,
|
|
104
92
|
focused: false,
|
|
105
93
|
size: 'medium',
|
|
@@ -21,13 +21,15 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
size
|
|
32
|
-
|
|
33
|
-
}
|
|
24
|
+
import PropTypes from 'prop-types';
|
|
25
|
+
const propTypes = {
|
|
26
|
+
children: PropTypes.node.isRequired,
|
|
27
|
+
checked: PropTypes.bool,
|
|
28
|
+
disabled: PropTypes.bool,
|
|
29
|
+
readOnly: PropTypes.bool,
|
|
30
|
+
focused: PropTypes.bool,
|
|
31
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
32
|
+
labelPlacement: PropTypes.oneOf(['top', 'start', 'end'])
|
|
33
|
+
};
|
|
34
|
+
const allowedProps = ['children', 'checked', 'disabled', 'readOnly', 'focused', 'size', 'labelPlacement'];
|
|
35
|
+
export { propTypes, allowedProps };
|
package/es/Checkbox/index.js
CHANGED
|
@@ -26,10 +26,8 @@ var _dec, _dec2, _class, _class2, _temp;
|
|
|
26
26
|
|
|
27
27
|
/** @jsx jsx */
|
|
28
28
|
import { Component } from 'react';
|
|
29
|
-
import PropTypes from 'prop-types';
|
|
30
29
|
import keycode from 'keycode';
|
|
31
|
-
import {
|
|
32
|
-
import { FormPropTypes, FormFieldMessages } from '@instructure/ui-form-field';
|
|
30
|
+
import { FormFieldMessages } from '@instructure/ui-form-field';
|
|
33
31
|
import { createChainedFunction } from '@instructure/ui-utils';
|
|
34
32
|
import { logError as error } from '@instructure/console';
|
|
35
33
|
import { uid } from '@instructure/uid';
|
|
@@ -41,6 +39,7 @@ import { withStyle, jsx } from '@instructure/emotion';
|
|
|
41
39
|
import { CheckboxFacade } from './CheckboxFacade';
|
|
42
40
|
import { ToggleFacade } from './ToggleFacade';
|
|
43
41
|
import generateStyle from './styles';
|
|
42
|
+
import { propTypes, allowedProps } from './props';
|
|
44
43
|
|
|
45
44
|
/**
|
|
46
45
|
---
|
|
@@ -216,7 +215,7 @@ let Checkbox = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _dec(
|
|
|
216
215
|
/* eslint-disable jsx-a11y/mouse-events-have-key-events */
|
|
217
216
|
|
|
218
217
|
return jsx("div", {
|
|
219
|
-
css: styles.checkbox,
|
|
218
|
+
css: styles === null || styles === void 0 ? void 0 : styles.checkbox,
|
|
220
219
|
onMouseOver: createChainedFunction(onMouseOver, this.handleMouseOver),
|
|
221
220
|
onMouseOut: createChainedFunction(onMouseOut, this.handleMouseOut)
|
|
222
221
|
}, jsx("input", Object.assign({}, props, {
|
|
@@ -228,7 +227,7 @@ let Checkbox = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _dec(
|
|
|
228
227
|
},
|
|
229
228
|
disabled: disabled || readOnly,
|
|
230
229
|
"aria-checked": indeterminate ? 'mixed' : void 0,
|
|
231
|
-
css: styles.input,
|
|
230
|
+
css: styles === null || styles === void 0 ? void 0 : styles.input,
|
|
232
231
|
onChange: this.handleChange,
|
|
233
232
|
onKeyDown: createChainedFunction(onKeyDown, this.handleKeyDown),
|
|
234
233
|
onFocus: createChainedFunction(onFocus, this.handleFocus),
|
|
@@ -236,82 +235,18 @@ let Checkbox = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _dec(
|
|
|
236
235
|
checked: this.checked
|
|
237
236
|
})), jsx("label", {
|
|
238
237
|
htmlFor: this.id,
|
|
239
|
-
css: styles.control
|
|
238
|
+
css: styles === null || styles === void 0 ? void 0 : styles.control
|
|
240
239
|
}, this.renderFacade(), this.renderMessages()));
|
|
241
240
|
/* eslint-enable jsx-a11y/mouse-events-have-key-events */
|
|
242
241
|
}
|
|
243
242
|
|
|
244
|
-
}, _class2.displayName = "Checkbox", _class2.componentId = 'Checkbox', _class2.propTypes = {
|
|
245
|
-
// eslint-disable-next-line react/require-default-props
|
|
246
|
-
makeStyles: PropTypes.func,
|
|
247
|
-
// eslint-disable-next-line react/require-default-props
|
|
248
|
-
styles: PropTypes.object,
|
|
249
|
-
label: PropTypes.node.isRequired,
|
|
250
|
-
id: PropTypes.string,
|
|
251
|
-
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* object with shape: `{
|
|
255
|
-
* text: PropTypes.string,
|
|
256
|
-
* type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
|
|
257
|
-
* }`
|
|
258
|
-
*/
|
|
259
|
-
messages: PropTypes.arrayOf(FormPropTypes.message),
|
|
260
|
-
|
|
261
|
-
/* whether to set the input to checked or not on initial render */
|
|
262
|
-
defaultChecked: PropTypes.bool,
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* whether the input is checked or not (must be accompanied by an `onChange` prop)
|
|
266
|
-
*/
|
|
267
|
-
checked: controllable(PropTypes.bool, 'onChange', 'defaultChecked'),
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* when used with the `checked` prop, the component will not control its own state
|
|
271
|
-
*/
|
|
272
|
-
onChange: PropTypes.func,
|
|
273
|
-
onKeyDown: PropTypes.func,
|
|
274
|
-
onFocus: PropTypes.func,
|
|
275
|
-
onBlur: PropTypes.func,
|
|
276
|
-
onMouseOver: PropTypes.func,
|
|
277
|
-
onMouseOut: PropTypes.func,
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* Whether or not to disable the checkbox
|
|
281
|
-
*/
|
|
282
|
-
disabled: PropTypes.bool,
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Works just like disabled but keeps the same styles as if it were active
|
|
286
|
-
*/
|
|
287
|
-
readOnly: PropTypes.bool,
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* Visual state showing that child checkboxes are a combination of checked and unchecked
|
|
291
|
-
*/
|
|
292
|
-
indeterminate: PropTypes.bool,
|
|
293
|
-
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
294
|
-
variant: PropTypes.oneOf(['simple', 'toggle']),
|
|
295
|
-
inline: PropTypes.bool,
|
|
296
|
-
labelPlacement: PropTypes.oneOf(['top', 'start', 'end'])
|
|
297
|
-
}, _class2.defaultProps = {
|
|
243
|
+
}, _class2.displayName = "Checkbox", _class2.componentId = 'Checkbox', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
298
244
|
size: 'medium',
|
|
299
245
|
variant: 'simple',
|
|
300
246
|
disabled: false,
|
|
301
247
|
inline: false,
|
|
302
248
|
indeterminate: false,
|
|
303
249
|
readOnly: false,
|
|
304
|
-
onChange: void 0,
|
|
305
|
-
onKeyDown: void 0,
|
|
306
|
-
onFocus: void 0,
|
|
307
|
-
onBlur: void 0,
|
|
308
|
-
onMouseOut: void 0,
|
|
309
|
-
onMouseOver: void 0,
|
|
310
|
-
checked: void 0,
|
|
311
|
-
defaultChecked: void 0,
|
|
312
|
-
messages: void 0,
|
|
313
|
-
id: void 0,
|
|
314
|
-
value: void 0,
|
|
315
250
|
labelPlacement: 'end'
|
|
316
251
|
}, _temp)) || _class) || _class);
|
|
317
252
|
export default Checkbox;
|
|
@@ -0,0 +1,78 @@
|
|
|
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 } from '@instructure/ui-prop-types';
|
|
27
|
+
const propTypes = {
|
|
28
|
+
label: PropTypes.node.isRequired,
|
|
29
|
+
id: PropTypes.string,
|
|
30
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* object with shape: `{
|
|
34
|
+
* text: PropTypes.string,
|
|
35
|
+
* type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
|
|
36
|
+
* }`
|
|
37
|
+
*/
|
|
38
|
+
messages: PropTypes.arrayOf(FormPropTypes.message),
|
|
39
|
+
|
|
40
|
+
/* whether to set the input to checked or not on initial render */
|
|
41
|
+
defaultChecked: PropTypes.bool,
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* whether the input is checked or not (must be accompanied by an `onChange` prop)
|
|
45
|
+
*/
|
|
46
|
+
checked: controllable(PropTypes.bool, 'onChange', 'defaultChecked'),
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* when used with the `checked` prop, the component will not control its own state
|
|
50
|
+
*/
|
|
51
|
+
onChange: PropTypes.func,
|
|
52
|
+
onKeyDown: PropTypes.func,
|
|
53
|
+
onFocus: PropTypes.func,
|
|
54
|
+
onBlur: PropTypes.func,
|
|
55
|
+
onMouseOver: PropTypes.func,
|
|
56
|
+
onMouseOut: PropTypes.func,
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Whether or not to disable the checkbox
|
|
60
|
+
*/
|
|
61
|
+
disabled: PropTypes.bool,
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Works just like disabled but keeps the same styles as if it were active
|
|
65
|
+
*/
|
|
66
|
+
readOnly: PropTypes.bool,
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Visual state showing that child checkboxes are a combination of checked and unchecked
|
|
70
|
+
*/
|
|
71
|
+
indeterminate: PropTypes.bool,
|
|
72
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
73
|
+
variant: PropTypes.oneOf(['simple', 'toggle']),
|
|
74
|
+
inline: PropTypes.bool,
|
|
75
|
+
labelPlacement: PropTypes.oneOf(['top', 'start', 'end'])
|
|
76
|
+
};
|
|
77
|
+
const allowedProps = ['label', 'id', 'value', 'messages', 'defaultChecked', 'checked', 'onChange', 'onKeyDown', 'onFocus', 'onBlur', 'onMouseOver', 'onMouseOut', 'disabled', 'readOnly', 'indeterminate', 'size', 'variant', 'inline', 'labelPlacement'];
|
|
78
|
+
export { propTypes, allowedProps };
|
|
@@ -24,13 +24,12 @@ var _dec, _class, _class2, _temp;
|
|
|
24
24
|
* SOFTWARE.
|
|
25
25
|
*/
|
|
26
26
|
import React, { Children, Component } from 'react';
|
|
27
|
-
import
|
|
28
|
-
import { controllable, Children as ChildrenPropTypes } from '@instructure/ui-prop-types';
|
|
29
|
-
import { FormPropTypes, FormFieldGroup } from '@instructure/ui-form-field';
|
|
27
|
+
import { FormFieldGroup } from '@instructure/ui-form-field';
|
|
30
28
|
import { uid } from '@instructure/uid';
|
|
31
29
|
import { matchComponentTypes, safeCloneElement, pickProps, omitProps } from '@instructure/ui-react-utils';
|
|
32
30
|
import { testable } from '@instructure/ui-testable';
|
|
33
31
|
import { Checkbox } from '../Checkbox';
|
|
32
|
+
import { propTypes, allowedProps } from './props';
|
|
34
33
|
|
|
35
34
|
/**
|
|
36
35
|
---
|
|
@@ -124,50 +123,11 @@ let CheckboxGroup = (_dec = testable(), _dec(_class = (_temp = _class2 = class C
|
|
|
124
123
|
);
|
|
125
124
|
}
|
|
126
125
|
|
|
127
|
-
}, _class2.displayName = "CheckboxGroup", _class2.componentId = 'CheckboxGroup', _class2.propTypes = {
|
|
128
|
-
name: PropTypes.string.isRequired,
|
|
129
|
-
description: PropTypes.node.isRequired,
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* value to set on initial render
|
|
133
|
-
*/
|
|
134
|
-
defaultValue: PropTypes.array,
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* the selected values (must be accompanied by an `onChange` prop)
|
|
138
|
-
*/
|
|
139
|
-
value: controllable(PropTypes.array),
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* when used with the `value` prop, the component will not control its own state
|
|
143
|
-
*/
|
|
144
|
-
onChange: PropTypes.func,
|
|
145
|
-
disabled: PropTypes.bool,
|
|
146
|
-
readOnly: PropTypes.bool,
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* object with shape: `{
|
|
150
|
-
text: PropTypes.string,
|
|
151
|
-
type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
|
|
152
|
-
}`
|
|
153
|
-
*/
|
|
154
|
-
messages: PropTypes.arrayOf(FormPropTypes.message),
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* children of type `Checkbox`
|
|
158
|
-
*/
|
|
159
|
-
children: ChildrenPropTypes.oneOf([Checkbox]),
|
|
160
|
-
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
161
|
-
layout: PropTypes.oneOf(['stacked', 'columns', 'inline'])
|
|
162
|
-
}, _class2.defaultProps = {
|
|
126
|
+
}, _class2.displayName = "CheckboxGroup", _class2.componentId = 'CheckboxGroup', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
163
127
|
disabled: false,
|
|
164
128
|
readOnly: false,
|
|
165
129
|
size: 'medium',
|
|
166
130
|
layout: 'stacked',
|
|
167
|
-
defaultValue: void 0,
|
|
168
|
-
messages: void 0,
|
|
169
|
-
value: void 0,
|
|
170
|
-
onChange: void 0,
|
|
171
131
|
children: null
|
|
172
132
|
}, _temp)) || _class);
|
|
173
133
|
export default CheckboxGroup;
|