@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
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-radio-input
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,7 +26,6 @@ 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 { uid } from '@instructure/uid';
31
30
  import { testable } from '@instructure/ui-testable';
32
31
  import { omitProps } from '@instructure/ui-react-utils';
@@ -34,12 +33,13 @@ import { isActiveElement } from '@instructure/ui-dom-utils';
34
33
  import { withStyle, jsx } from '@instructure/emotion';
35
34
  import generateStyle from './styles';
36
35
  import generateComponentTheme from './theme';
37
-
36
+ import { allowedProps, propTypes } from './props';
38
37
  /**
39
38
  ---
40
39
  category: components
41
40
  ---
42
41
  **/
42
+
43
43
  let RadioInput = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_temp = _class2 = class RadioInput extends Component {
44
44
  constructor(props) {
45
45
  super(props);
@@ -78,11 +78,15 @@ let RadioInput = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2
78
78
  }
79
79
 
80
80
  componentDidMount() {
81
- this.props.makeStyles();
81
+ var _this$props$makeStyle, _this$props;
82
+
83
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
82
84
  }
83
85
 
84
- componentDidUpdate(prevProps, prevState, snapshot) {
85
- this.props.makeStyles();
86
+ componentDidUpdate() {
87
+ var _this$props$makeStyle2, _this$props2;
88
+
89
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
86
90
  }
87
91
 
88
92
  focus() {
@@ -102,16 +106,16 @@ let RadioInput = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2
102
106
  }
103
107
 
104
108
  render() {
105
- const _this$props = this.props,
106
- disabled = _this$props.disabled,
107
- readOnly = _this$props.readOnly,
108
- label = _this$props.label,
109
- value = _this$props.value,
110
- name = _this$props.name,
111
- styles = _this$props.styles;
109
+ const _this$props3 = this.props,
110
+ disabled = _this$props3.disabled,
111
+ readOnly = _this$props3.readOnly,
112
+ label = _this$props3.label,
113
+ value = _this$props3.value,
114
+ name = _this$props3.name,
115
+ styles = _this$props3.styles;
112
116
  const props = omitProps(this.props, RadioInput.propTypes);
113
117
  return jsx("div", {
114
- css: styles.radioInput
118
+ css: styles === null || styles === void 0 ? void 0 : styles.radioInput
115
119
  }, jsx("input", Object.assign({}, props, {
116
120
  id: this.id,
117
121
  ref: c => {
@@ -121,49 +125,23 @@ let RadioInput = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2
121
125
  name: name,
122
126
  checked: this.checked,
123
127
  type: "radio",
124
- css: styles.input,
128
+ css: styles === null || styles === void 0 ? void 0 : styles.input,
125
129
  disabled: disabled || readOnly,
126
130
  "aria-disabled": disabled || readOnly ? 'true' : null,
127
131
  onChange: this.handleChange,
128
132
  onClick: this.handleClick
129
133
  })), jsx("label", {
130
- css: styles.control,
134
+ css: styles === null || styles === void 0 ? void 0 : styles.control,
131
135
  htmlFor: this.id
132
136
  }, jsx("span", {
133
- css: styles.facade,
137
+ css: styles === null || styles === void 0 ? void 0 : styles.facade,
134
138
  "aria-hidden": "true"
135
139
  }), jsx("span", {
136
- css: styles.label
140
+ css: styles === null || styles === void 0 ? void 0 : styles.label
137
141
  }, label)));
138
142
  }
139
143
 
140
- }, _class2.displayName = "RadioInput", _class2.componentId = 'RadioInput', _class2.propTypes = {
141
- // eslint-disable-next-line react/require-default-props
142
- makeStyles: PropTypes.func,
143
- // eslint-disable-next-line react/require-default-props
144
- styles: PropTypes.object,
145
- label: PropTypes.node.isRequired,
146
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
147
- id: PropTypes.string,
148
- name: PropTypes.string,
149
- checked: PropTypes.bool,
150
-
151
- /**
152
- * Whether or not to disable the input
153
- */
154
- disabled: PropTypes.bool,
155
-
156
- /**
157
- * Works just like disabled but keeps the same styles as if it were active
158
- */
159
- readOnly: PropTypes.bool,
160
- variant: PropTypes.oneOf(['simple', 'toggle']),
161
- size: PropTypes.oneOf(['small', 'medium', 'large']),
162
- context: PropTypes.oneOf(['success', 'warning', 'danger', 'off']),
163
- inline: PropTypes.bool,
164
- onClick: PropTypes.func,
165
- onChange: PropTypes.func
166
- }, _class2.defaultProps = {
144
+ }, _class2.displayName = "RadioInput", _class2.componentId = 'RadioInput', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
167
145
  onClick: function (event) {},
168
146
  onChange: function (event) {},
169
147
  variant: 'simple',
@@ -171,11 +149,7 @@ let RadioInput = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2
171
149
  disabled: false,
172
150
  inline: false,
173
151
  context: 'success',
174
- readOnly: false,
175
- checked: void 0,
176
- id: void 0,
177
- name: void 0,
178
- value: void 0
152
+ readOnly: false
179
153
  }, _temp)) || _class) || _class);
180
154
  export default RadioInput;
181
155
  export { RadioInput };
@@ -21,20 +21,29 @@
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
+ label: PropTypes.node.isRequired,
27
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
28
+ id: PropTypes.string,
29
+ name: PropTypes.string,
30
+ checked: PropTypes.bool,
24
31
 
25
- import React from 'react'
26
- import type { FormMessage } from '@instructure/ui-form-field'
32
+ /**
33
+ * Whether or not to disable the input
34
+ */
35
+ disabled: PropTypes.bool,
27
36
 
28
- export type RadioInputGroupProps = {
29
- name: string
30
- description: React.ReactNode
31
- defaultValue?: string | number
32
- value?: any // TODO: controllable( PropTypes.oneOfType([PropTypes.string, PropTypes.number]) )
33
- onChange?: (...args: any[]) => any
34
- disabled?: boolean
35
- readOnly?: boolean
36
- messages?: FormMessage[]
37
- variant?: 'simple' | 'toggle'
38
- size?: 'small' | 'medium' | 'large'
39
- layout?: 'stacked' | 'columns' | 'inline'
40
- }
37
+ /**
38
+ * Works just like disabled but keeps the same styles as if it were active
39
+ */
40
+ readOnly: PropTypes.bool,
41
+ variant: PropTypes.oneOf(['simple', 'toggle']),
42
+ size: PropTypes.oneOf(['small', 'medium', 'large']),
43
+ context: PropTypes.oneOf(['success', 'warning', 'danger', 'off']),
44
+ inline: PropTypes.bool,
45
+ onClick: PropTypes.func,
46
+ onChange: PropTypes.func
47
+ };
48
+ const allowedProps = ['label', 'value', 'id', 'name', 'checked', 'disabled', 'readOnly', 'variant', 'size', 'context', 'inline', 'onClick', 'onChange'];
49
+ export { propTypes, allowedProps };
@@ -24,19 +24,18 @@ var _dec, _class, _class2, _temp;
24
24
  * SOFTWARE.
25
25
  */
26
26
  import React, { Children, Component } from 'react';
27
- import PropTypes from 'prop-types';
28
- import { controllable } 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 { testable } from '@instructure/ui-testable';
32
30
  import { matchComponentTypes, safeCloneElement, omitProps, pickProps } from '@instructure/ui-react-utils';
33
31
  import { RadioInput } from '../RadioInput';
34
-
32
+ import { allowedProps, propTypes } from './props';
35
33
  /**
36
34
  ---
37
35
  category: components
38
36
  ---
39
37
  **/
38
+
40
39
  let RadioInputGroup = (_dec = testable(), _dec(_class = (_temp = _class2 = class RadioInputGroup extends Component {
41
40
  constructor(props) {
42
41
  super();
@@ -132,56 +131,13 @@ let RadioInputGroup = (_dec = testable(), _dec(_class = (_temp = _class2 = class
132
131
  );
133
132
  }
134
133
 
135
- }, _class2.displayName = "RadioInputGroup", _class2.componentId = 'RadioInputGroup', _class2.propTypes = {
136
- name: PropTypes.string.isRequired,
137
- description: PropTypes.node.isRequired,
138
-
139
- /**
140
- * value to set on initial render
141
- */
142
- defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
143
-
144
- /**
145
- * the selected value (must be accompanied by an `onChange` prop)
146
- */
147
- value: controllable(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),
148
-
149
- /**
150
- * when used with the `value` prop, the component will not control its own state
151
- */
152
- onChange: PropTypes.func,
153
- disabled: PropTypes.bool,
154
-
155
- /** works just like disabled but keeps the same styles as if it were active */
156
- readOnly: PropTypes.bool,
157
-
158
- /**
159
- * object with shape: `{
160
- * text: PropTypes.string,
161
- * type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
162
- * }`
163
- */
164
- messages: PropTypes.arrayOf(FormPropTypes.message),
165
-
166
- /**
167
- * any children (ones that aren't `RadioInput` are passed through)
168
- */
169
- children: PropTypes.node,
170
- variant: PropTypes.oneOf(['simple', 'toggle']),
171
- // TODO: split toggle out to its own component
172
- size: PropTypes.oneOf(['small', 'medium', 'large']),
173
- layout: PropTypes.oneOf(['stacked', 'columns', 'inline'])
174
- }, _class2.defaultProps = {
134
+ }, _class2.displayName = "RadioInputGroup", _class2.componentId = 'RadioInputGroup', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
175
135
  disabled: false,
176
136
  variant: 'simple',
177
137
  size: 'medium',
178
138
  layout: 'stacked',
179
139
  readOnly: false,
180
- defaultValue: void 0,
181
- value: void 0,
182
- children: null,
183
- messages: void 0,
184
- onChange: void 0
140
+ children: null
185
141
  }, _temp)) || _class);
186
142
  export default RadioInputGroup;
187
143
  export { RadioInputGroup };
@@ -0,0 +1,68 @@
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 { controllable } from '@instructure/ui-prop-types';
26
+ import { FormPropTypes } from '@instructure/ui-form-field';
27
+ const propTypes = {
28
+ name: PropTypes.string.isRequired,
29
+ description: PropTypes.node.isRequired,
30
+
31
+ /**
32
+ * value to set on initial render
33
+ */
34
+ defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
35
+
36
+ /**
37
+ * the selected value (must be accompanied by an `onChange` prop)
38
+ */
39
+ value: controllable(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),
40
+
41
+ /**
42
+ * when used with the `value` prop, the component will not control its own state
43
+ */
44
+ onChange: PropTypes.func,
45
+ disabled: PropTypes.bool,
46
+
47
+ /** works just like disabled but keeps the same styles as if it were active */
48
+ readOnly: PropTypes.bool,
49
+
50
+ /**
51
+ * object with shape: `{
52
+ * text: PropTypes.string,
53
+ * type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
54
+ * }`
55
+ */
56
+ messages: PropTypes.arrayOf(FormPropTypes.message),
57
+
58
+ /**
59
+ * any children (ones that aren't `RadioInput` are passed through)
60
+ */
61
+ children: PropTypes.node,
62
+ variant: PropTypes.oneOf(['simple', 'toggle']),
63
+ // TODO: split toggle out to its own component
64
+ size: PropTypes.oneOf(['small', 'medium', 'large']),
65
+ layout: PropTypes.oneOf(['stacked', 'columns', 'inline'])
66
+ };
67
+ const allowedProps = ['name', 'description', 'defaultValue', 'value', 'onChange', 'disabled', 'readOnly', 'messages', 'children', 'variant', 'size', 'layout'];
68
+ export { propTypes, allowedProps };
@@ -9,8 +9,6 @@ exports.RadioInput = 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 _uid = require("@instructure/uid");
15
13
 
16
14
  var _testable = require("@instructure/ui-testable/lib/testable.js");
@@ -25,6 +23,8 @@ var _styles = _interopRequireDefault(require("./styles"));
25
23
 
26
24
  var _theme = _interopRequireDefault(require("./theme"));
27
25
 
26
+ var _props = require("./props");
27
+
28
28
  var _dec, _dec2, _class, _class2, _temp;
29
29
 
30
30
  /**
@@ -70,11 +70,15 @@ let RadioInput = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
70
70
  }
71
71
 
72
72
  componentDidMount() {
73
- this.props.makeStyles();
73
+ var _this$props$makeStyle, _this$props;
74
+
75
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
74
76
  }
75
77
 
76
- componentDidUpdate(prevProps, prevState, snapshot) {
77
- this.props.makeStyles();
78
+ componentDidUpdate() {
79
+ var _this$props$makeStyle2, _this$props2;
80
+
81
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
78
82
  }
79
83
 
80
84
  focus() {
@@ -94,16 +98,16 @@ let RadioInput = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
94
98
  }
95
99
 
96
100
  render() {
97
- const _this$props = this.props,
98
- disabled = _this$props.disabled,
99
- readOnly = _this$props.readOnly,
100
- label = _this$props.label,
101
- value = _this$props.value,
102
- name = _this$props.name,
103
- styles = _this$props.styles;
101
+ const _this$props3 = this.props,
102
+ disabled = _this$props3.disabled,
103
+ readOnly = _this$props3.readOnly,
104
+ label = _this$props3.label,
105
+ value = _this$props3.value,
106
+ name = _this$props3.name,
107
+ styles = _this$props3.styles;
104
108
  const props = (0, _omitProps.omitProps)(this.props, RadioInput.propTypes);
105
109
  return (0, _emotion.jsx)("div", {
106
- css: styles.radioInput
110
+ css: styles === null || styles === void 0 ? void 0 : styles.radioInput
107
111
  }, (0, _emotion.jsx)("input", Object.assign({}, props, {
108
112
  id: this.id,
109
113
  ref: c => {
@@ -113,49 +117,23 @@ let RadioInput = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
113
117
  name: name,
114
118
  checked: this.checked,
115
119
  type: "radio",
116
- css: styles.input,
120
+ css: styles === null || styles === void 0 ? void 0 : styles.input,
117
121
  disabled: disabled || readOnly,
118
122
  "aria-disabled": disabled || readOnly ? 'true' : null,
119
123
  onChange: this.handleChange,
120
124
  onClick: this.handleClick
121
125
  })), (0, _emotion.jsx)("label", {
122
- css: styles.control,
126
+ css: styles === null || styles === void 0 ? void 0 : styles.control,
123
127
  htmlFor: this.id
124
128
  }, (0, _emotion.jsx)("span", {
125
- css: styles.facade,
129
+ css: styles === null || styles === void 0 ? void 0 : styles.facade,
126
130
  "aria-hidden": "true"
127
131
  }), (0, _emotion.jsx)("span", {
128
- css: styles.label
132
+ css: styles === null || styles === void 0 ? void 0 : styles.label
129
133
  }, label)));
130
134
  }
131
135
 
132
- }, _class2.displayName = "RadioInput", _class2.componentId = 'RadioInput', _class2.propTypes = {
133
- // eslint-disable-next-line react/require-default-props
134
- makeStyles: _propTypes.default.func,
135
- // eslint-disable-next-line react/require-default-props
136
- styles: _propTypes.default.object,
137
- label: _propTypes.default.node.isRequired,
138
- value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
139
- id: _propTypes.default.string,
140
- name: _propTypes.default.string,
141
- checked: _propTypes.default.bool,
142
-
143
- /**
144
- * Whether or not to disable the input
145
- */
146
- disabled: _propTypes.default.bool,
147
-
148
- /**
149
- * Works just like disabled but keeps the same styles as if it were active
150
- */
151
- readOnly: _propTypes.default.bool,
152
- variant: _propTypes.default.oneOf(['simple', 'toggle']),
153
- size: _propTypes.default.oneOf(['small', 'medium', 'large']),
154
- context: _propTypes.default.oneOf(['success', 'warning', 'danger', 'off']),
155
- inline: _propTypes.default.bool,
156
- onClick: _propTypes.default.func,
157
- onChange: _propTypes.default.func
158
- }, _class2.defaultProps = {
136
+ }, _class2.displayName = "RadioInput", _class2.componentId = 'RadioInput', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
159
137
  onClick: function (event) {},
160
138
  onChange: function (event) {},
161
139
  variant: 'simple',
@@ -163,11 +141,7 @@ let RadioInput = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
163
141
  disabled: false,
164
142
  inline: false,
165
143
  context: 'success',
166
- readOnly: false,
167
- checked: void 0,
168
- id: void 0,
169
- name: void 0,
170
- value: void 0
144
+ readOnly: false
171
145
  }, _temp)) || _class) || _class);
172
146
  exports.RadioInput = RadioInput;
173
147
  var _default = RadioInput;