@instructure/ui-radio-input 11.6.0 → 11.6.1-snapshot-129
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 +45 -299
- package/es/RadioInput/{index.js → v1/index.js} +1 -1
- package/es/RadioInput/v2/index.js +189 -0
- package/{src/index.ts → es/RadioInput/v2/props.js} +2 -4
- package/es/RadioInput/v2/styles.js +268 -0
- package/es/RadioInputGroup/{index.js → v1/index.js} +3 -3
- package/es/RadioInputGroup/v2/index.js +146 -0
- package/es/RadioInputGroup/v2/props.js +26 -0
- package/es/{index.js → exports/a.js} +2 -2
- package/es/exports/b.js +25 -0
- package/lib/RadioInput/{index.js → v1/index.js} +1 -1
- package/lib/RadioInput/v2/index.js +195 -0
- package/lib/RadioInput/v2/props.js +31 -0
- package/lib/RadioInput/v2/styles.js +274 -0
- package/lib/RadioInputGroup/{index.js → v1/index.js} +6 -6
- package/lib/RadioInputGroup/v2/index.js +154 -0
- package/lib/RadioInputGroup/v2/props.js +31 -0
- package/lib/{index.js → exports/a.js} +4 -4
- package/lib/exports/b.js +19 -0
- package/package.json +40 -18
- package/src/RadioInput/{index.tsx → v1/index.tsx} +1 -1
- package/src/RadioInput/v2/README.md +110 -0
- package/src/RadioInput/v2/index.tsx +223 -0
- package/src/RadioInput/v2/props.ts +126 -0
- package/src/RadioInput/v2/styles.ts +304 -0
- package/src/RadioInputGroup/{index.tsx → v1/index.tsx} +4 -4
- package/src/RadioInputGroup/{props.ts → v1/props.ts} +1 -1
- package/src/RadioInputGroup/{styles.ts → v1/styles.ts} +3 -1
- package/src/RadioInputGroup/v2/README.md +241 -0
- package/src/RadioInputGroup/v2/index.tsx +178 -0
- package/src/RadioInputGroup/v2/props.ts +122 -0
- package/src/exports/a.ts +28 -0
- package/src/exports/b.ts +28 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/RadioInput/v1/index.d.ts.map +1 -0
- package/types/RadioInput/v1/props.d.ts.map +1 -0
- package/types/RadioInput/v1/styles.d.ts.map +1 -0
- package/types/RadioInput/v1/theme.d.ts.map +1 -0
- package/types/RadioInput/v2/index.d.ts +64 -0
- package/types/RadioInput/v2/index.d.ts.map +1 -0
- package/types/RadioInput/v2/props.d.ts +77 -0
- package/types/RadioInput/v2/props.d.ts.map +1 -0
- package/types/RadioInput/v2/styles.d.ts +24 -0
- package/types/RadioInput/v2/styles.d.ts.map +1 -0
- package/types/RadioInputGroup/{index.d.ts → v1/index.d.ts} +3 -3
- package/types/RadioInputGroup/v1/index.d.ts.map +1 -0
- package/types/RadioInputGroup/{props.d.ts → v1/props.d.ts} +1 -1
- package/types/RadioInputGroup/v1/props.d.ts.map +1 -0
- package/types/RadioInputGroup/v1/styles.d.ts.map +1 -0
- package/types/RadioInputGroup/v1/theme.d.ts.map +1 -0
- package/types/RadioInputGroup/v2/index.d.ts +47 -0
- package/types/RadioInputGroup/v2/index.d.ts.map +1 -0
- package/types/RadioInputGroup/v2/props.d.ts +63 -0
- package/types/RadioInputGroup/v2/props.d.ts.map +1 -0
- package/types/exports/a.d.ts +5 -0
- package/types/exports/a.d.ts.map +1 -0
- package/types/exports/b.d.ts +5 -0
- package/types/exports/b.d.ts.map +1 -0
- package/types/RadioInput/index.d.ts.map +0 -1
- package/types/RadioInput/props.d.ts.map +0 -1
- package/types/RadioInput/styles.d.ts.map +0 -1
- package/types/RadioInput/theme.d.ts.map +0 -1
- package/types/RadioInputGroup/index.d.ts.map +0 -1
- package/types/RadioInputGroup/props.d.ts.map +0 -1
- package/types/RadioInputGroup/styles.d.ts.map +0 -1
- package/types/RadioInputGroup/theme.d.ts.map +0 -1
- package/types/index.d.ts +0 -5
- package/types/index.d.ts.map +0 -1
- /package/es/RadioInput/{props.js → v1/props.js} +0 -0
- /package/es/RadioInput/{styles.js → v1/styles.js} +0 -0
- /package/es/RadioInput/{theme.js → v1/theme.js} +0 -0
- /package/es/RadioInputGroup/{props.js → v1/props.js} +0 -0
- /package/es/RadioInputGroup/{styles.js → v1/styles.js} +0 -0
- /package/es/RadioInputGroup/{theme.js → v1/theme.js} +0 -0
- /package/lib/RadioInput/{props.js → v1/props.js} +0 -0
- /package/lib/RadioInput/{styles.js → v1/styles.js} +0 -0
- /package/lib/RadioInput/{theme.js → v1/theme.js} +0 -0
- /package/lib/RadioInputGroup/{props.js → v1/props.js} +0 -0
- /package/lib/RadioInputGroup/{styles.js → v1/styles.js} +0 -0
- /package/lib/RadioInputGroup/{theme.js → v1/theme.js} +0 -0
- /package/src/RadioInput/{README.md → v1/README.md} +0 -0
- /package/src/RadioInput/{props.ts → v1/props.ts} +0 -0
- /package/src/RadioInput/{styles.ts → v1/styles.ts} +0 -0
- /package/src/RadioInput/{theme.ts → v1/theme.ts} +0 -0
- /package/src/RadioInputGroup/{README.md → v1/README.md} +0 -0
- /package/src/RadioInputGroup/{theme.ts → v1/theme.ts} +0 -0
- /package/types/RadioInput/{index.d.ts → v1/index.d.ts} +0 -0
- /package/types/RadioInput/{props.d.ts → v1/props.d.ts} +0 -0
- /package/types/RadioInput/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/RadioInput/{theme.d.ts → v1/theme.d.ts} +0 -0
- /package/types/RadioInputGroup/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/RadioInputGroup/{theme.d.ts → v1/theme.d.ts} +0 -0
|
@@ -43,7 +43,7 @@ var _dec, _dec2, _class, _RadioInput;
|
|
|
43
43
|
category: components
|
|
44
44
|
---
|
|
45
45
|
**/
|
|
46
|
-
let RadioInput = exports.RadioInput = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.
|
|
46
|
+
let RadioInput = exports.RadioInput = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = _dec2(_class = (_RadioInput = class RadioInput extends _react.Component {
|
|
47
47
|
constructor(props) {
|
|
48
48
|
super(props);
|
|
49
49
|
this.ref = null;
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = exports.RadioInput = void 0;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
|
|
12
|
+
var _useDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/useDeterministicId.js");
|
|
13
|
+
var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js");
|
|
14
|
+
var _emotion = require("@instructure/emotion");
|
|
15
|
+
var _styles = _interopRequireDefault(require("./styles"));
|
|
16
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
17
|
+
const _excluded = ["variant", "size", "disabled", "inline", "context", "readOnly", "id", "label", "value", "name", "checked", "onClick", "onChange", "inputRef", "themeOverride"];
|
|
18
|
+
/*
|
|
19
|
+
* The MIT License (MIT)
|
|
20
|
+
*
|
|
21
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
22
|
+
*
|
|
23
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
24
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
25
|
+
* in the Software without restriction, including without limitation the rights
|
|
26
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
27
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
28
|
+
* furnished to do so, subject to the following conditions:
|
|
29
|
+
*
|
|
30
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
31
|
+
* copies or substantial portions of the Software.
|
|
32
|
+
*
|
|
33
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
34
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
35
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
36
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
37
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
38
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
39
|
+
* SOFTWARE.
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
---
|
|
43
|
+
category: components
|
|
44
|
+
---
|
|
45
|
+
**/
|
|
46
|
+
const RadioInput = exports.RadioInput = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
47
|
+
const _props$variant = props.variant,
|
|
48
|
+
variant = _props$variant === void 0 ? 'simple' : _props$variant,
|
|
49
|
+
_props$size = props.size,
|
|
50
|
+
size = _props$size === void 0 ? 'medium' : _props$size,
|
|
51
|
+
_props$disabled = props.disabled,
|
|
52
|
+
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
|
53
|
+
_props$inline = props.inline,
|
|
54
|
+
inline = _props$inline === void 0 ? false : _props$inline,
|
|
55
|
+
_props$context = props.context,
|
|
56
|
+
context = _props$context === void 0 ? 'success' : _props$context,
|
|
57
|
+
_props$readOnly = props.readOnly,
|
|
58
|
+
readOnly = _props$readOnly === void 0 ? false : _props$readOnly,
|
|
59
|
+
idProp = props.id,
|
|
60
|
+
label = props.label,
|
|
61
|
+
value = props.value,
|
|
62
|
+
name = props.name,
|
|
63
|
+
checkedProp = props.checked,
|
|
64
|
+
onClick = props.onClick,
|
|
65
|
+
onChange = props.onChange,
|
|
66
|
+
inputRef = props.inputRef,
|
|
67
|
+
themeOverride = props.themeOverride,
|
|
68
|
+
rest = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
69
|
+
const _useState = (0, _react.useState)(false),
|
|
70
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
71
|
+
hovered = _useState2[0],
|
|
72
|
+
setHovered = _useState2[1];
|
|
73
|
+
// State for uncontrolled mode
|
|
74
|
+
const _useState3 = (0, _react.useState)(false),
|
|
75
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
76
|
+
internalChecked = _useState4[0],
|
|
77
|
+
setInternalChecked = _useState4[1];
|
|
78
|
+
|
|
79
|
+
// Refs
|
|
80
|
+
const containerRef = (0, _react.useRef)(null);
|
|
81
|
+
const inputElementRef = (0, _react.useRef)(null);
|
|
82
|
+
|
|
83
|
+
// Deterministic ID generation
|
|
84
|
+
const _useState5 = (0, _react.useState)(),
|
|
85
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
86
|
+
deterministicId = _useState6[0],
|
|
87
|
+
setDeterministicId = _useState6[1];
|
|
88
|
+
const getId = (0, _useDeterministicId.useDeterministicId)('RadioInput');
|
|
89
|
+
(0, _react.useEffect)(() => {
|
|
90
|
+
setDeterministicId(getId());
|
|
91
|
+
}, []);
|
|
92
|
+
const id = idProp || deterministicId;
|
|
93
|
+
|
|
94
|
+
// Computed checked value
|
|
95
|
+
const checked = typeof checkedProp === 'undefined' ? internalChecked : checkedProp;
|
|
96
|
+
|
|
97
|
+
// Styles - pass props with defaults applied for generateStyle
|
|
98
|
+
const styles = (0, _emotion.useStyle)({
|
|
99
|
+
generateStyle: _styles.default,
|
|
100
|
+
themeOverride,
|
|
101
|
+
params: {
|
|
102
|
+
disabled,
|
|
103
|
+
context,
|
|
104
|
+
inline,
|
|
105
|
+
hovered,
|
|
106
|
+
readOnly,
|
|
107
|
+
size,
|
|
108
|
+
variant
|
|
109
|
+
},
|
|
110
|
+
componentId: 'RadioInput',
|
|
111
|
+
displayName: 'RadioInput'
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// Event handlers
|
|
115
|
+
const handleInputRef = (0, _react.useCallback)(el => {
|
|
116
|
+
inputElementRef.current = el;
|
|
117
|
+
if (typeof inputRef === 'function') {
|
|
118
|
+
inputRef(el);
|
|
119
|
+
}
|
|
120
|
+
}, [inputRef]);
|
|
121
|
+
const handleClick = (0, _react.useCallback)(e => {
|
|
122
|
+
if (disabled || readOnly) {
|
|
123
|
+
e.preventDefault();
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (typeof onClick === 'function') {
|
|
127
|
+
onClick(e);
|
|
128
|
+
}
|
|
129
|
+
}, [disabled, readOnly, onClick]);
|
|
130
|
+
const handleChange = (0, _react.useCallback)(e => {
|
|
131
|
+
if (disabled || readOnly) {
|
|
132
|
+
e.preventDefault();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (typeof checkedProp === 'undefined') {
|
|
136
|
+
setInternalChecked(!internalChecked);
|
|
137
|
+
}
|
|
138
|
+
if (typeof onChange === 'function') {
|
|
139
|
+
onChange(e);
|
|
140
|
+
}
|
|
141
|
+
}, [disabled, readOnly, checkedProp, internalChecked, onChange]);
|
|
142
|
+
|
|
143
|
+
// Expose imperative API via ref
|
|
144
|
+
(0, _react.useImperativeHandle)(ref, () => ({
|
|
145
|
+
focus: () => {
|
|
146
|
+
var _inputElementRef$curr;
|
|
147
|
+
(_inputElementRef$curr = inputElementRef.current) === null || _inputElementRef$curr === void 0 ? void 0 : _inputElementRef$curr.focus();
|
|
148
|
+
},
|
|
149
|
+
get focused() {
|
|
150
|
+
return (0, _isActiveElement.isActiveElement)(inputElementRef.current);
|
|
151
|
+
},
|
|
152
|
+
get checked() {
|
|
153
|
+
return checked;
|
|
154
|
+
},
|
|
155
|
+
get id() {
|
|
156
|
+
return id;
|
|
157
|
+
}
|
|
158
|
+
}), [checked, id]);
|
|
159
|
+
const handleMouseOver = () => {
|
|
160
|
+
setHovered(true);
|
|
161
|
+
};
|
|
162
|
+
const handleMouseOut = () => {
|
|
163
|
+
setHovered(false);
|
|
164
|
+
};
|
|
165
|
+
const passedProps = (0, _passthroughProps.passthroughProps)(rest);
|
|
166
|
+
return (0, _jsxRuntime.jsxs)("div", {
|
|
167
|
+
css: styles === null || styles === void 0 ? void 0 : styles.radioInput,
|
|
168
|
+
"data-cid": "RadioInput",
|
|
169
|
+
ref: containerRef
|
|
170
|
+
/* eslint-disable-next-line jsx-a11y/mouse-events-have-key-events */,
|
|
171
|
+
onMouseOver: handleMouseOver
|
|
172
|
+
/* eslint-disable-next-line jsx-a11y/mouse-events-have-key-events */,
|
|
173
|
+
onMouseOut: handleMouseOut,
|
|
174
|
+
children: [(0, _jsxRuntime.jsx)("input", {
|
|
175
|
+
...passedProps,
|
|
176
|
+
id: id,
|
|
177
|
+
ref: handleInputRef,
|
|
178
|
+
value: value,
|
|
179
|
+
name: name,
|
|
180
|
+
checked: checked,
|
|
181
|
+
type: "radio",
|
|
182
|
+
css: styles === null || styles === void 0 ? void 0 : styles.input,
|
|
183
|
+
readOnly: readOnly,
|
|
184
|
+
disabled: disabled,
|
|
185
|
+
onChange: handleChange,
|
|
186
|
+
onClick: handleClick
|
|
187
|
+
}), (0, _jsxRuntime.jsx)("label", {
|
|
188
|
+
htmlFor: id,
|
|
189
|
+
css: styles === null || styles === void 0 ? void 0 : styles.label,
|
|
190
|
+
children: label
|
|
191
|
+
})]
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
RadioInput.displayName = 'RadioInput';
|
|
195
|
+
var _default = exports.default = RadioInput;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.allowedProps = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* The MIT License (MIT)
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
11
|
+
*
|
|
12
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
* in the Software without restriction, including without limitation the rights
|
|
15
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
* furnished to do so, subject to the following conditions:
|
|
18
|
+
*
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
* copies or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
* SOFTWARE.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
const allowedProps = exports.allowedProps = ['label', 'value', 'id', 'name', 'checked', 'disabled', 'readOnly', 'variant', 'size', 'context', 'inline', 'onClick', 'onChange', 'inputRef'];
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _uiThemes = require("@instructure/ui-themes");
|
|
8
|
+
var _emotion = require("@instructure/emotion");
|
|
9
|
+
/*
|
|
10
|
+
* The MIT License (MIT)
|
|
11
|
+
*
|
|
12
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
13
|
+
*
|
|
14
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
* in the Software without restriction, including without limitation the rights
|
|
17
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
* furnished to do so, subject to the following conditions:
|
|
20
|
+
*
|
|
21
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
22
|
+
* copies or substantial portions of the Software.
|
|
23
|
+
*
|
|
24
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
+
* SOFTWARE.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* ---
|
|
35
|
+
* private: true
|
|
36
|
+
* ---
|
|
37
|
+
* Generates the style object from the theme and provided additional information
|
|
38
|
+
* @param componentTheme The theme variable object.
|
|
39
|
+
* @param params Additional parameters to customize the style.
|
|
40
|
+
* @param sharedTokens Shared token object that stores common values for the theme.
|
|
41
|
+
* @return The final style object, which will be used in the component
|
|
42
|
+
*/
|
|
43
|
+
const generateStyle = (componentTheme, params, sharedTokens) => {
|
|
44
|
+
var _toggleContextBackgro;
|
|
45
|
+
const disabled = params.disabled,
|
|
46
|
+
inline = params.inline,
|
|
47
|
+
hovered = params.hovered,
|
|
48
|
+
size = params.size,
|
|
49
|
+
readOnly = params.readOnly,
|
|
50
|
+
variant = params.variant,
|
|
51
|
+
context = params.context;
|
|
52
|
+
|
|
53
|
+
// 4*2 states: base, hover, disabled, readonly X none/selected
|
|
54
|
+
const insetSizes = {
|
|
55
|
+
small: componentTheme.checkedInsetSm,
|
|
56
|
+
medium: componentTheme.checkedInsetMd,
|
|
57
|
+
large: componentTheme.checkedInsetLg
|
|
58
|
+
};
|
|
59
|
+
const labelColors = {
|
|
60
|
+
// the states here are mutually exclusive
|
|
61
|
+
color: componentTheme.labelBaseColor,
|
|
62
|
+
...(hovered && {
|
|
63
|
+
color: componentTheme.labelHoverColor
|
|
64
|
+
}),
|
|
65
|
+
...(readOnly && {
|
|
66
|
+
color: componentTheme.labelReadonlyColor
|
|
67
|
+
}),
|
|
68
|
+
...(disabled && {
|
|
69
|
+
color: componentTheme.labelDisabledColor
|
|
70
|
+
})
|
|
71
|
+
};
|
|
72
|
+
const getInputColors = () => {
|
|
73
|
+
if (disabled) {
|
|
74
|
+
return {
|
|
75
|
+
background: componentTheme.backgroundDisabledColor,
|
|
76
|
+
borderColor: componentTheme.borderDisabledColor,
|
|
77
|
+
checkedBoxShadow: `inset 0 0 0 ${insetSizes[size]} ${componentTheme.borderDisabledColor}`
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
if (readOnly) {
|
|
81
|
+
return {
|
|
82
|
+
background: componentTheme.backgroundReadonlyColor,
|
|
83
|
+
borderColor: componentTheme.borderReadonlyColor,
|
|
84
|
+
checkedBoxShadow: `inset 0 0 0 ${insetSizes[size]} ${componentTheme.borderSelectedColor}`
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
if (hovered) {
|
|
88
|
+
return {
|
|
89
|
+
background: componentTheme.backgroundHoverColor,
|
|
90
|
+
borderColor: componentTheme.borderHoverColor,
|
|
91
|
+
checkedBoxShadow: `inset 0 0 0 ${insetSizes[size]} ${componentTheme.borderSelectedColor}`
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
background: componentTheme.backgroundColor,
|
|
96
|
+
borderColor: componentTheme.borderColor,
|
|
97
|
+
checkedBoxShadow: `inset 0 0 0 ${insetSizes[size]} ${componentTheme.borderSelectedColor}`
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
const inputColors = getInputColors();
|
|
101
|
+
const toggleContextBackgrounds = {
|
|
102
|
+
success: componentTheme.toggleBackgroundSuccess,
|
|
103
|
+
warning: componentTheme.toggleBackgroundWarning,
|
|
104
|
+
danger: componentTheme.toggleBackgroundDanger,
|
|
105
|
+
off: componentTheme.toggleBackgroundOff
|
|
106
|
+
};
|
|
107
|
+
const toggleBackground = (_toggleContextBackgro = toggleContextBackgrounds[context !== null && context !== void 0 ? context : 'success']) !== null && _toggleContextBackgro !== void 0 ? _toggleContextBackgro : toggleContextBackgrounds['success'];
|
|
108
|
+
const focusOutline = (0, _emotion.calcFocusOutlineStyles)(sharedTokens.focusOutline);
|
|
109
|
+
focusOutline.transition += ', box-shadow 0.2s';
|
|
110
|
+
const inputVariants = {
|
|
111
|
+
simple: {
|
|
112
|
+
base: {
|
|
113
|
+
all: 'initial',
|
|
114
|
+
boxSizing: 'border-box',
|
|
115
|
+
appearance: 'none',
|
|
116
|
+
display: 'block',
|
|
117
|
+
position: 'relative',
|
|
118
|
+
marginInlineEnd: componentTheme.gap,
|
|
119
|
+
marginInlineStart: '0',
|
|
120
|
+
flexShrink: 0,
|
|
121
|
+
minWidth: '1rem',
|
|
122
|
+
borderRadius: '100%',
|
|
123
|
+
borderWidth: componentTheme.borderWidth,
|
|
124
|
+
borderStyle: 'solid',
|
|
125
|
+
background: inputColors.background,
|
|
126
|
+
borderColor: inputColors.borderColor,
|
|
127
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
128
|
+
'&:checked': {
|
|
129
|
+
borderColor: disabled ? componentTheme.borderDisabledColor : componentTheme.borderSelectedColor,
|
|
130
|
+
boxShadow: inputColors.checkedBoxShadow
|
|
131
|
+
},
|
|
132
|
+
marginTop: componentTheme.controlVerticalMargin,
|
|
133
|
+
marginBottom: componentTheme.controlVerticalMargin,
|
|
134
|
+
...focusOutline
|
|
135
|
+
},
|
|
136
|
+
small: {
|
|
137
|
+
width: componentTheme.controlSizeSm,
|
|
138
|
+
height: componentTheme.controlSizeSm
|
|
139
|
+
},
|
|
140
|
+
medium: {
|
|
141
|
+
width: componentTheme.controlSizeMd,
|
|
142
|
+
height: componentTheme.controlSizeMd
|
|
143
|
+
},
|
|
144
|
+
large: {
|
|
145
|
+
width: componentTheme.controlSizeLg,
|
|
146
|
+
height: componentTheme.controlSizeLg
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
toggle: {
|
|
150
|
+
base: {
|
|
151
|
+
all: 'initial',
|
|
152
|
+
boxSizing: 'border-box',
|
|
153
|
+
// Visually hidden but accessible (screen reader, focus, keyboard)
|
|
154
|
+
position: 'absolute',
|
|
155
|
+
opacity: 0.0001 /* selenium cannot find fully transparent elements */,
|
|
156
|
+
width: '1px',
|
|
157
|
+
height: '1px',
|
|
158
|
+
overflow: 'hidden',
|
|
159
|
+
margin: 0,
|
|
160
|
+
padding: 0
|
|
161
|
+
},
|
|
162
|
+
small: {},
|
|
163
|
+
medium: {},
|
|
164
|
+
large: {}
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
const labelVariants = {
|
|
168
|
+
simple: {
|
|
169
|
+
base: {},
|
|
170
|
+
small: {
|
|
171
|
+
fontSize: componentTheme.fontSizeSm,
|
|
172
|
+
lineHeight: componentTheme.lineHeightSm
|
|
173
|
+
},
|
|
174
|
+
medium: {
|
|
175
|
+
fontSize: componentTheme.fontSizeMd,
|
|
176
|
+
lineHeight: componentTheme.lineHeightMd
|
|
177
|
+
},
|
|
178
|
+
large: {
|
|
179
|
+
fontSize: componentTheme.fontSizeLg,
|
|
180
|
+
lineHeight: componentTheme.lineHeightLg
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
toggle: {
|
|
184
|
+
base: {
|
|
185
|
+
flex: '0 0 auto',
|
|
186
|
+
position: 'relative',
|
|
187
|
+
zIndex: 1,
|
|
188
|
+
textTransform: 'uppercase',
|
|
189
|
+
overflow: 'hidden',
|
|
190
|
+
whiteSpace: 'nowrap',
|
|
191
|
+
textOverflow: 'ellipsis',
|
|
192
|
+
lineHeight: 1,
|
|
193
|
+
display: 'flex',
|
|
194
|
+
alignItems: 'center',
|
|
195
|
+
justifyContent: 'center',
|
|
196
|
+
minWidth: '0.0625rem',
|
|
197
|
+
borderRadius: componentTheme.toggleBorderRadius,
|
|
198
|
+
color: disabled ? componentTheme.labelDisabledColor : componentTheme.labelBaseColor,
|
|
199
|
+
background: 'transparent',
|
|
200
|
+
'input:checked + &': {
|
|
201
|
+
color: componentTheme.toggleHandleText,
|
|
202
|
+
background: toggleBackground,
|
|
203
|
+
boxShadow: disabled ? 'none' : (0, _uiThemes.boxShadowObjectsToCSSString)(componentTheme.toggleShadow)
|
|
204
|
+
},
|
|
205
|
+
...(0, _emotion.calcFocusOutlineStyles)(sharedTokens.focusOutline, {
|
|
206
|
+
customCSSSelector: 'input:focus + &&'
|
|
207
|
+
}),
|
|
208
|
+
'input:focus + &': {
|
|
209
|
+
textDecoration: 'underline'
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
small: {
|
|
213
|
+
fontSize: componentTheme.toggleSmallFontSize,
|
|
214
|
+
height: componentTheme.toggleSmallHeight,
|
|
215
|
+
padding: '0 0.5rem',
|
|
216
|
+
svg: {
|
|
217
|
+
fontSize: `calc(${componentTheme.toggleSmallFontSize} + 0.375rem)`
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
medium: {
|
|
221
|
+
fontSize: componentTheme.toggleMediumFontSize,
|
|
222
|
+
height: componentTheme.toggleMediumHeight,
|
|
223
|
+
padding: '0 0.875rem',
|
|
224
|
+
svg: {
|
|
225
|
+
fontSize: `calc(${componentTheme.toggleMediumFontSize} + 0.375rem)`
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
large: {
|
|
229
|
+
fontSize: componentTheme.toggleLargeFontSize,
|
|
230
|
+
height: componentTheme.toggleLargeHeight,
|
|
231
|
+
padding: '0 1rem',
|
|
232
|
+
svg: {
|
|
233
|
+
fontSize: `calc(${componentTheme.toggleLargeFontSize} + 0.375rem)`
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
return {
|
|
239
|
+
radioInput: {
|
|
240
|
+
label: 'radioInput',
|
|
241
|
+
position: 'relative',
|
|
242
|
+
display: 'flex',
|
|
243
|
+
alignItems: 'flex-start',
|
|
244
|
+
width: inline ? 'auto' : '100%',
|
|
245
|
+
...(inline && {
|
|
246
|
+
display: 'inline-flex',
|
|
247
|
+
verticalAlign: 'middle'
|
|
248
|
+
}),
|
|
249
|
+
'&:hover': {
|
|
250
|
+
cursor: 'default',
|
|
251
|
+
...(disabled && {
|
|
252
|
+
cursor: 'not-allowed'
|
|
253
|
+
})
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
input: {
|
|
257
|
+
label: 'radioInput__input',
|
|
258
|
+
...inputVariants[variant].base,
|
|
259
|
+
...inputVariants[variant][size]
|
|
260
|
+
},
|
|
261
|
+
label: {
|
|
262
|
+
label: 'radioInput__label',
|
|
263
|
+
flex: '1 1 auto',
|
|
264
|
+
alignSelf: 'center',
|
|
265
|
+
...labelColors,
|
|
266
|
+
fontFamily: componentTheme.fontFamily,
|
|
267
|
+
fontWeight: componentTheme.fontWeight,
|
|
268
|
+
...labelVariants[variant].base,
|
|
269
|
+
...labelVariants[variant][size],
|
|
270
|
+
cursor: disabled ? 'not-allowed' : 'pointer'
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
var _default = exports.default = generateStyle;
|
|
@@ -6,14 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.RadioInputGroup = void 0;
|
|
8
8
|
var _react = require("react");
|
|
9
|
-
var
|
|
9
|
+
var _v11_ = require("@instructure/ui-form-field/v11_6");
|
|
10
10
|
var _matchComponentTypes = require("@instructure/ui-react-utils/lib/matchComponentTypes.js");
|
|
11
11
|
var _safeCloneElement = require("@instructure/ui-react-utils/lib/safeCloneElement.js");
|
|
12
12
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
13
13
|
var _pickProps = require("@instructure/ui-react-utils/lib/pickProps.js");
|
|
14
14
|
var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
|
|
15
15
|
var _hasVisibleChildren = require("@instructure/ui-a11y-utils/lib/hasVisibleChildren.js");
|
|
16
|
-
var
|
|
16
|
+
var _v = require("../../RadioInput/v1");
|
|
17
17
|
var _emotion = require("@instructure/emotion");
|
|
18
18
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
19
19
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
@@ -48,7 +48,7 @@ var _dec, _dec2, _class, _RadioInputGroup;
|
|
|
48
48
|
category: components
|
|
49
49
|
---
|
|
50
50
|
**/
|
|
51
|
-
let RadioInputGroup = exports.RadioInputGroup = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.
|
|
51
|
+
let RadioInputGroup = exports.RadioInputGroup = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = _dec2(_class = (_RadioInputGroup = class RadioInputGroup extends _react.Component {
|
|
52
52
|
constructor(props) {
|
|
53
53
|
super(props);
|
|
54
54
|
this.ref = null;
|
|
@@ -100,7 +100,7 @@ let RadioInputGroup = exports.RadioInputGroup = (_dec = (0, _withDeterministicId
|
|
|
100
100
|
// This adds the passed in name property to each RadioInput component
|
|
101
101
|
// and checks the input whose value matches the value property
|
|
102
102
|
return _react.Children.map(children, (child, index) => {
|
|
103
|
-
if ((0, _matchComponentTypes.matchComponentTypes)(child, [
|
|
103
|
+
if ((0, _matchComponentTypes.matchComponentTypes)(child, [_v.RadioInput])) {
|
|
104
104
|
const isChecked = this.value === child.props.value;
|
|
105
105
|
const defaultFocus = !this.value && index === 0;
|
|
106
106
|
return (0, _safeCloneElement.safeCloneElement)(child, {
|
|
@@ -138,9 +138,9 @@ let RadioInputGroup = exports.RadioInputGroup = (_dec = (0, _withDeterministicId
|
|
|
138
138
|
children: [' ', "*"]
|
|
139
139
|
})]
|
|
140
140
|
}) : description;
|
|
141
|
-
return (0, _jsxRuntime.jsx)(
|
|
141
|
+
return (0, _jsxRuntime.jsx)(_v11_.FormFieldGroup, {
|
|
142
142
|
...(0, _omitProps.omitProps)(this.props, RadioInputGroup.allowedProps),
|
|
143
|
-
...(0, _pickProps.pickProps)(this.props,
|
|
143
|
+
...(0, _pickProps.pickProps)(this.props, _v11_.FormFieldGroup.allowedProps),
|
|
144
144
|
description: descriptionWithRequired,
|
|
145
145
|
layout: layout === 'columns' && variant === 'toggle' ? 'stacked' : layout // toggles already display in cols
|
|
146
146
|
,
|