@instructure/ui-radio-input 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.
Files changed (35) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/es/RadioInput/index.js +23 -49
  3. package/{src/RadioInputGroup/types.ts → es/RadioInput/props.js} +24 -15
  4. package/es/RadioInputGroup/index.js +5 -49
  5. package/es/RadioInputGroup/props.js +68 -0
  6. package/lib/RadioInput/index.js +23 -49
  7. package/lib/RadioInput/props.js +60 -0
  8. package/lib/RadioInputGroup/index.js +4 -53
  9. package/lib/RadioInputGroup/props.js +81 -0
  10. package/package.json +15 -16
  11. package/src/RadioInput/index.tsx +13 -43
  12. package/src/RadioInput/{types.ts → props.ts} +52 -3
  13. package/src/RadioInput/styles.ts +1 -1
  14. package/src/RadioInputGroup/index.tsx +6 -44
  15. package/src/RadioInputGroup/props.ts +107 -0
  16. package/src/index.ts +2 -2
  17. package/types/RadioInput/index.d.ts +32 -30
  18. package/types/RadioInput/index.d.ts.map +1 -1
  19. package/types/RadioInput/props.d.ts +26 -0
  20. package/types/RadioInput/props.d.ts.map +1 -0
  21. package/types/RadioInput/styles.d.ts +1 -1
  22. package/types/RadioInputGroup/index.d.ts +30 -43
  23. package/types/RadioInputGroup/index.d.ts.map +1 -1
  24. package/types/RadioInputGroup/props.d.ts +25 -0
  25. package/types/RadioInputGroup/props.d.ts.map +1 -0
  26. package/types/index.d.ts +2 -2
  27. package/LICENSE.md +0 -27
  28. package/es/RadioInput/types.js +0 -1
  29. package/es/RadioInputGroup/types.js +0 -1
  30. package/lib/RadioInput/types.js +0 -1
  31. package/lib/RadioInputGroup/types.js +0 -1
  32. package/types/RadioInput/types.d.ts +0 -19
  33. package/types/RadioInput/types.d.ts.map +0 -1
  34. package/types/RadioInputGroup/types.d.ts +0 -16
  35. package/types/RadioInputGroup/types.d.ts.map +0 -1
@@ -0,0 +1,60 @@
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
+ label: _propTypes.default.node.isRequired,
37
+ value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
38
+ id: _propTypes.default.string,
39
+ name: _propTypes.default.string,
40
+ checked: _propTypes.default.bool,
41
+
42
+ /**
43
+ * Whether or not to disable the input
44
+ */
45
+ disabled: _propTypes.default.bool,
46
+
47
+ /**
48
+ * Works just like disabled but keeps the same styles as if it were active
49
+ */
50
+ readOnly: _propTypes.default.bool,
51
+ variant: _propTypes.default.oneOf(['simple', 'toggle']),
52
+ size: _propTypes.default.oneOf(['small', 'medium', 'large']),
53
+ context: _propTypes.default.oneOf(['success', 'warning', 'danger', 'off']),
54
+ inline: _propTypes.default.bool,
55
+ onClick: _propTypes.default.func,
56
+ onChange: _propTypes.default.func
57
+ };
58
+ exports.propTypes = propTypes;
59
+ const allowedProps = ['label', 'value', 'id', 'name', 'checked', 'disabled', 'readOnly', 'variant', 'size', 'context', 'inline', 'onClick', 'onChange'];
60
+ exports.allowedProps = allowedProps;
@@ -2,8 +2,6 @@
2
2
 
3
3
  var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
4
 
5
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
@@ -11,12 +9,6 @@ exports.RadioInputGroup = exports.default = void 0;
11
9
 
12
10
  var _react = _interopRequireWildcard(require("react"));
13
11
 
14
- var _propTypes = _interopRequireDefault(require("prop-types"));
15
-
16
- var _controllable = require("@instructure/ui-prop-types/lib/controllable.js");
17
-
18
- var _FormPropTypes = require("@instructure/ui-form-field/lib/FormPropTypes.js");
19
-
20
12
  var _FormFieldGroup = require("@instructure/ui-form-field/lib/FormFieldGroup");
21
13
 
22
14
  var _uid = require("@instructure/uid");
@@ -33,6 +25,8 @@ var _pickProps = require("@instructure/ui-react-utils/lib/pickProps.js");
33
25
 
34
26
  var _RadioInput = require("../RadioInput");
35
27
 
28
+ var _props = require("./props");
29
+
36
30
  var _dec, _class, _class2, _temp;
37
31
 
38
32
  /**
@@ -135,56 +129,13 @@ let RadioInputGroup = (_dec = (0, _testable.testable)(), _dec(_class = (_temp =
135
129
  );
136
130
  }
137
131
 
138
- }, _class2.displayName = "RadioInputGroup", _class2.componentId = 'RadioInputGroup', _class2.propTypes = {
139
- name: _propTypes.default.string.isRequired,
140
- description: _propTypes.default.node.isRequired,
141
-
142
- /**
143
- * value to set on initial render
144
- */
145
- defaultValue: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
146
-
147
- /**
148
- * the selected value (must be accompanied by an `onChange` prop)
149
- */
150
- value: (0, _controllable.controllable)(_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number])),
151
-
152
- /**
153
- * when used with the `value` prop, the component will not control its own state
154
- */
155
- onChange: _propTypes.default.func,
156
- disabled: _propTypes.default.bool,
157
-
158
- /** works just like disabled but keeps the same styles as if it were active */
159
- readOnly: _propTypes.default.bool,
160
-
161
- /**
162
- * object with shape: `{
163
- * text: PropTypes.string,
164
- * type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
165
- * }`
166
- */
167
- messages: _propTypes.default.arrayOf(_FormPropTypes.FormPropTypes.message),
168
-
169
- /**
170
- * any children (ones that aren't `RadioInput` are passed through)
171
- */
172
- children: _propTypes.default.node,
173
- variant: _propTypes.default.oneOf(['simple', 'toggle']),
174
- // TODO: split toggle out to its own component
175
- size: _propTypes.default.oneOf(['small', 'medium', 'large']),
176
- layout: _propTypes.default.oneOf(['stacked', 'columns', 'inline'])
177
- }, _class2.defaultProps = {
132
+ }, _class2.displayName = "RadioInputGroup", _class2.componentId = 'RadioInputGroup', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
178
133
  disabled: false,
179
134
  variant: 'simple',
180
135
  size: 'medium',
181
136
  layout: 'stacked',
182
137
  readOnly: false,
183
- defaultValue: void 0,
184
- value: void 0,
185
- children: null,
186
- messages: void 0,
187
- onChange: void 0
138
+ children: null
188
139
  }, _temp)) || _class);
189
140
  exports.RadioInputGroup = RadioInputGroup;
190
141
  var _default = RadioInputGroup;
@@ -0,0 +1,81 @@
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 _controllable = require("@instructure/ui-prop-types/lib/controllable.js");
13
+
14
+ var _FormPropTypes = require("@instructure/ui-form-field/lib/FormPropTypes.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
+ name: _propTypes.default.string.isRequired,
41
+ description: _propTypes.default.node.isRequired,
42
+
43
+ /**
44
+ * value to set on initial render
45
+ */
46
+ defaultValue: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
47
+
48
+ /**
49
+ * the selected value (must be accompanied by an `onChange` prop)
50
+ */
51
+ value: (0, _controllable.controllable)(_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number])),
52
+
53
+ /**
54
+ * when used with the `value` prop, the component will not control its own state
55
+ */
56
+ onChange: _propTypes.default.func,
57
+ disabled: _propTypes.default.bool,
58
+
59
+ /** works just like disabled but keeps the same styles as if it were active */
60
+ readOnly: _propTypes.default.bool,
61
+
62
+ /**
63
+ * object with shape: `{
64
+ * text: PropTypes.string,
65
+ * type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
66
+ * }`
67
+ */
68
+ messages: _propTypes.default.arrayOf(_FormPropTypes.FormPropTypes.message),
69
+
70
+ /**
71
+ * any children (ones that aren't `RadioInput` are passed through)
72
+ */
73
+ children: _propTypes.default.node,
74
+ variant: _propTypes.default.oneOf(['simple', 'toggle']),
75
+ // TODO: split toggle out to its own component
76
+ size: _propTypes.default.oneOf(['small', 'medium', 'large']),
77
+ layout: _propTypes.default.oneOf(['stacked', 'columns', 'inline'])
78
+ };
79
+ exports.propTypes = propTypes;
80
+ const allowedProps = ['name', 'description', 'defaultValue', 'value', 'onChange', 'disabled', 'readOnly', 'messages', 'children', 'variant', 'size', 'layout'];
81
+ exports.allowedProps = allowedProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-radio-input",
3
- "version": "8.8.1-snapshot.8+7b83164f4",
3
+ "version": "8.9.1",
4
4
  "description": "A styled HTML input type='radio' element",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "type": "commonjs",
@@ -25,22 +25,22 @@
25
25
  "license": "MIT",
26
26
  "dependencies": {
27
27
  "@babel/runtime": "^7.13.10",
28
- "@instructure/emotion": "8.8.1-snapshot.8+7b83164f4",
29
- "@instructure/shared-types": "8.8.1-snapshot.8+7b83164f4",
30
- "@instructure/ui-dom-utils": "8.8.1-snapshot.8+7b83164f4",
31
- "@instructure/ui-form-field": "8.8.1-snapshot.8+7b83164f4",
32
- "@instructure/ui-prop-types": "8.8.1-snapshot.8+7b83164f4",
33
- "@instructure/ui-react-utils": "8.8.1-snapshot.8+7b83164f4",
34
- "@instructure/ui-testable": "8.8.1-snapshot.8+7b83164f4",
35
- "@instructure/uid": "8.8.1-snapshot.8+7b83164f4",
28
+ "@instructure/emotion": "8.9.1",
29
+ "@instructure/shared-types": "8.9.1",
30
+ "@instructure/ui-dom-utils": "8.9.1",
31
+ "@instructure/ui-form-field": "8.9.1",
32
+ "@instructure/ui-prop-types": "8.9.1",
33
+ "@instructure/ui-react-utils": "8.9.1",
34
+ "@instructure/ui-testable": "8.9.1",
35
+ "@instructure/uid": "8.9.1",
36
36
  "prop-types": "^15"
37
37
  },
38
38
  "devDependencies": {
39
- "@instructure/ui-babel-preset": "8.8.1-snapshot.8+7b83164f4",
40
- "@instructure/ui-color-utils": "8.8.1-snapshot.8+7b83164f4",
41
- "@instructure/ui-test-locator": "8.8.1-snapshot.8+7b83164f4",
42
- "@instructure/ui-test-utils": "8.8.1-snapshot.8+7b83164f4",
43
- "@instructure/ui-themes": "8.8.1-snapshot.8+7b83164f4"
39
+ "@instructure/ui-babel-preset": "8.9.1",
40
+ "@instructure/ui-color-utils": "8.9.1",
41
+ "@instructure/ui-test-locator": "8.9.1",
42
+ "@instructure/ui-test-utils": "8.9.1",
43
+ "@instructure/ui-themes": "8.9.1"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "react": ">=16.8 <=17"
@@ -48,6 +48,5 @@
48
48
  "publishConfig": {
49
49
  "access": "public"
50
50
  },
51
- "sideEffects": false,
52
- "gitHead": "7b83164f4c5872f3a217e010563f59bf584ae4fc"
51
+ "sideEffects": false
53
52
  }
@@ -24,7 +24,6 @@
24
24
 
25
25
  /** @jsx jsx */
26
26
  import { Component } from 'react'
27
- import PropTypes from 'prop-types'
28
27
 
29
28
  import { uid } from '@instructure/uid'
30
29
  import { testable } from '@instructure/ui-testable'
@@ -35,7 +34,8 @@ import { withStyle, jsx } from '@instructure/emotion'
35
34
 
36
35
  import generateStyle from './styles'
37
36
  import generateComponentTheme from './theme'
38
- import { RadioInputProps } from './types'
37
+ import type { RadioInputProps } from './props'
38
+ import { allowedProps, propTypes } from './props'
39
39
 
40
40
  /**
41
41
  ---
@@ -47,31 +47,8 @@ category: components
47
47
  class RadioInput extends Component<RadioInputProps> {
48
48
  static readonly componentId = 'RadioInput'
49
49
 
50
- static propTypes = {
51
- // eslint-disable-next-line react/require-default-props
52
- makeStyles: PropTypes.func,
53
- // eslint-disable-next-line react/require-default-props
54
- styles: PropTypes.object,
55
- label: PropTypes.node.isRequired,
56
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
57
- id: PropTypes.string,
58
- name: PropTypes.string,
59
- checked: PropTypes.bool,
60
- /**
61
- * Whether or not to disable the input
62
- */
63
- disabled: PropTypes.bool,
64
- /**
65
- * Works just like disabled but keeps the same styles as if it were active
66
- */
67
- readOnly: PropTypes.bool,
68
- variant: PropTypes.oneOf(['simple', 'toggle']),
69
- size: PropTypes.oneOf(['small', 'medium', 'large']),
70
- context: PropTypes.oneOf(['success', 'warning', 'danger', 'off']),
71
- inline: PropTypes.bool,
72
- onClick: PropTypes.func,
73
- onChange: PropTypes.func
74
- }
50
+ static allowedProps = allowedProps
51
+ static propTypes = propTypes
75
52
 
76
53
  static defaultProps = {
77
54
  // @ts-expect-error ts-migrate(6133) FIXME: 'event' is declared but its value is never read.
@@ -83,11 +60,7 @@ class RadioInput extends Component<RadioInputProps> {
83
60
  disabled: false,
84
61
  inline: false,
85
62
  context: 'success',
86
- readOnly: false,
87
- checked: undefined,
88
- id: undefined,
89
- name: undefined,
90
- value: undefined
63
+ readOnly: false
91
64
  }
92
65
 
93
66
  // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'props' implicitly has an 'any' type.
@@ -106,14 +79,11 @@ class RadioInput extends Component<RadioInputProps> {
106
79
  }
107
80
 
108
81
  componentDidMount() {
109
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
110
- this.props.makeStyles()
82
+ this.props.makeStyles?.()
111
83
  }
112
84
 
113
- // @ts-expect-error ts-migrate(6133) FIXME: 'prevProps' is declared but its value is never rea... Remove this comment to see the full error message
114
- componentDidUpdate(prevProps, prevState, snapshot) {
115
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
116
- this.props.makeStyles()
85
+ componentDidUpdate() {
86
+ this.props.makeStyles?.()
117
87
  }
118
88
 
119
89
  // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'e' implicitly has an 'any' type.
@@ -171,7 +141,7 @@ class RadioInput extends Component<RadioInputProps> {
171
141
  const props = omitProps(this.props, RadioInput.propTypes)
172
142
 
173
143
  return (
174
- <div css={styles.radioInput}>
144
+ <div css={styles?.radioInput}>
175
145
  <input
176
146
  {...props}
177
147
  id={this.id}
@@ -183,16 +153,16 @@ class RadioInput extends Component<RadioInputProps> {
183
153
  name={name}
184
154
  checked={this.checked}
185
155
  type="radio"
186
- css={styles.input}
156
+ css={styles?.input}
187
157
  disabled={disabled || readOnly}
188
158
  // @ts-expect-error ts-migrate(2322) FIXME: Type '"true" | null' is not assignable to type 'bo... Remove this comment to see the full error message
189
159
  aria-disabled={disabled || readOnly ? 'true' : null}
190
160
  onChange={this.handleChange}
191
161
  onClick={this.handleClick}
192
162
  />
193
- <label css={styles.control} htmlFor={this.id}>
194
- <span css={styles.facade} aria-hidden="true" />
195
- <span css={styles.label}>{label}</span>
163
+ <label css={styles?.control} htmlFor={this.id}>
164
+ <span css={styles?.facade} aria-hidden="true" />
165
+ <span css={styles?.label}>{label}</span>
196
166
  </label>
197
167
  </div>
198
168
  )
@@ -21,10 +21,12 @@
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'
24
25
 
25
- export type RadioInputProps = {
26
- makeStyles?: (...args: any[]) => any
27
- styles?: any
26
+ import type { PropValidators } from '@instructure/shared-types'
27
+ import type { WithStyleProps } from '@instructure/emotion'
28
+
29
+ type RadioInputOwnProps = {
28
30
  label: React.ReactNode
29
31
  value?: string | number
30
32
  id?: string
@@ -39,3 +41,50 @@ export type RadioInputProps = {
39
41
  onClick?: (...args: any[]) => any
40
42
  onChange?: (...args: any[]) => any
41
43
  }
44
+
45
+ type PropKeys = keyof RadioInputOwnProps
46
+
47
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
48
+
49
+ type RadioInputProps = RadioInputOwnProps & WithStyleProps
50
+
51
+ const propTypes: PropValidators<PropKeys> = {
52
+ label: PropTypes.node.isRequired,
53
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
54
+ id: PropTypes.string,
55
+ name: PropTypes.string,
56
+ checked: PropTypes.bool,
57
+ /**
58
+ * Whether or not to disable the input
59
+ */
60
+ disabled: PropTypes.bool,
61
+ /**
62
+ * Works just like disabled but keeps the same styles as if it were active
63
+ */
64
+ readOnly: PropTypes.bool,
65
+ variant: PropTypes.oneOf(['simple', 'toggle']),
66
+ size: PropTypes.oneOf(['small', 'medium', 'large']),
67
+ context: PropTypes.oneOf(['success', 'warning', 'danger', 'off']),
68
+ inline: PropTypes.bool,
69
+ onClick: PropTypes.func,
70
+ onChange: PropTypes.func
71
+ }
72
+
73
+ const allowedProps: AllowedPropKeys = [
74
+ 'label',
75
+ 'value',
76
+ 'id',
77
+ 'name',
78
+ 'checked',
79
+ 'disabled',
80
+ 'readOnly',
81
+ 'variant',
82
+ 'size',
83
+ 'context',
84
+ 'inline',
85
+ 'onClick',
86
+ 'onChange'
87
+ ]
88
+
89
+ export type { RadioInputProps }
90
+ export { propTypes, allowedProps }