@instructure/ui-toggle-details 8.33.1 → 8.33.2
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 +4 -0
- package/es/ToggleDetails/ToggleDetailsLocator.js +2 -5
- package/es/ToggleDetails/index.js +9 -36
- package/es/ToggleDetails/props.js +1 -0
- package/es/ToggleDetails/styles.js +7 -8
- package/es/ToggleDetails/theme.js +6 -6
- package/es/ToggleGroup/ToggleGroupLocator.js +2 -4
- package/es/ToggleGroup/index.js +8 -21
- package/es/ToggleGroup/props.js +1 -0
- package/es/index.js +1 -0
- package/lib/ToggleDetails/ToggleDetailsLocator.js +3 -8
- package/lib/ToggleDetails/index.js +9 -50
- package/lib/ToggleDetails/locator.js +0 -2
- package/lib/ToggleDetails/props.js +1 -4
- package/lib/ToggleDetails/styles.js +7 -10
- package/lib/ToggleDetails/theme.js +6 -7
- package/lib/ToggleGroup/ToggleGroupLocator.js +3 -7
- package/lib/ToggleGroup/index.js +6 -37
- package/lib/ToggleGroup/locator.js +0 -2
- package/lib/ToggleGroup/props.js +1 -4
- package/lib/index.js +0 -2
- package/package.json +21 -21
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -1,42 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
-
|
|
5
4
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.default = exports.ToggleDetails = void 0;
|
|
11
|
-
|
|
12
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
-
|
|
14
10
|
var _Button = require("@instructure/ui-buttons/lib/Button");
|
|
15
|
-
|
|
16
11
|
var _IconArrowOpenEndSolid = require("@instructure/ui-icons/lib/IconArrowOpenEndSolid.js");
|
|
17
|
-
|
|
18
12
|
var _IconArrowOpenDownSolid = require("@instructure/ui-icons/lib/IconArrowOpenDownSolid.js");
|
|
19
|
-
|
|
20
13
|
var _Expandable = require("@instructure/ui-expandable/lib/Expandable");
|
|
21
|
-
|
|
22
14
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
23
|
-
|
|
24
15
|
var _pickProps = require("@instructure/ui-react-utils/lib/pickProps.js");
|
|
25
|
-
|
|
26
16
|
var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js");
|
|
27
|
-
|
|
28
17
|
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
29
|
-
|
|
30
18
|
var _emotion = require("@instructure/emotion");
|
|
31
|
-
|
|
32
19
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
33
|
-
|
|
34
20
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
35
|
-
|
|
36
21
|
var _props = require("./props");
|
|
37
|
-
|
|
38
22
|
var _dec, _dec2, _class, _class2;
|
|
39
|
-
|
|
40
23
|
/**
|
|
41
24
|
---
|
|
42
25
|
category: components
|
|
@@ -48,70 +31,57 @@ let ToggleDetails = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defa
|
|
|
48
31
|
super(...arguments);
|
|
49
32
|
this.ref = null;
|
|
50
33
|
this._button = null;
|
|
51
|
-
|
|
52
34
|
this.getButtonRef = el => this._button = el;
|
|
53
|
-
|
|
54
35
|
this.handleToggle = (event, expanded) => {
|
|
55
36
|
var _this$props$makeStyle, _this$props;
|
|
56
|
-
|
|
57
37
|
if (typeof this.props.onToggle === 'function') {
|
|
58
38
|
this.props.onToggle(event, expanded);
|
|
59
39
|
}
|
|
60
|
-
|
|
61
40
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, {
|
|
62
41
|
animate: true
|
|
63
42
|
});
|
|
64
43
|
};
|
|
65
44
|
}
|
|
66
|
-
|
|
67
45
|
get focused() {
|
|
68
46
|
return (0, _isActiveElement.isActiveElement)(this._button);
|
|
69
47
|
}
|
|
70
|
-
|
|
71
48
|
focus() {
|
|
72
49
|
var _this$_button;
|
|
73
|
-
|
|
74
50
|
(_this$_button = this._button) === null || _this$_button === void 0 ? void 0 : _this$_button.focus();
|
|
75
51
|
}
|
|
76
|
-
|
|
77
52
|
componentDidMount() {
|
|
78
53
|
var _this$props$makeStyle2, _this$props2;
|
|
79
|
-
|
|
80
54
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, {
|
|
81
55
|
animate: false
|
|
82
56
|
});
|
|
83
57
|
}
|
|
84
|
-
|
|
85
58
|
componentDidUpdate() {
|
|
86
59
|
var _this$props$makeStyle3, _this$props3;
|
|
87
|
-
|
|
88
60
|
(_this$props$makeStyle3 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle3 === void 0 ? void 0 : _this$props$makeStyle3.call(_this$props3, {
|
|
89
61
|
animate: true
|
|
90
62
|
});
|
|
91
63
|
}
|
|
92
|
-
|
|
93
64
|
renderSummary(expanded) {
|
|
94
65
|
var _this$props$styles, _this$props$styles2;
|
|
95
|
-
|
|
96
66
|
const _this$props4 = this.props,
|
|
97
|
-
|
|
98
|
-
|
|
67
|
+
summary = _this$props4.summary,
|
|
68
|
+
iconPosition = _this$props4.iconPosition;
|
|
99
69
|
return (0, _emotion.jsx)("span", {
|
|
100
70
|
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.summary
|
|
101
71
|
}, iconPosition === 'start' && this.renderIcon(expanded), (0, _emotion.jsx)("span", {
|
|
102
72
|
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.summaryText
|
|
103
73
|
}, summary), iconPosition === 'end' && this.renderIcon(expanded));
|
|
104
74
|
}
|
|
105
|
-
|
|
106
75
|
renderToggle(toggleProps, expanded) {
|
|
107
76
|
const variant = this.props.variant;
|
|
108
|
-
const props = {
|
|
77
|
+
const props = {
|
|
78
|
+
...(0, _omitProps.omitProps)(this.props, ToggleDetails.allowedProps),
|
|
109
79
|
...toggleProps,
|
|
110
|
-
children: this.renderSummary(expanded)
|
|
111
|
-
|
|
80
|
+
children: this.renderSummary(expanded)
|
|
81
|
+
// spread operator makes toggleProps loose Record<string, any>>
|
|
112
82
|
};
|
|
113
|
-
const summary = this.renderSummary(expanded);
|
|
114
83
|
|
|
84
|
+
const summary = this.renderSummary(expanded);
|
|
115
85
|
if (variant === 'filled') {
|
|
116
86
|
return (0, _emotion.jsx)(_Button.Button, Object.assign({}, props, {
|
|
117
87
|
display: "block",
|
|
@@ -120,14 +90,12 @@ let ToggleDetails = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defa
|
|
|
120
90
|
}), summary);
|
|
121
91
|
} else if (props.href) {
|
|
122
92
|
var _this$props$styles3;
|
|
123
|
-
|
|
124
93
|
return (0, _emotion.jsx)("a", Object.assign({}, props, {
|
|
125
94
|
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.toggle,
|
|
126
95
|
ref: this.getButtonRef
|
|
127
96
|
}), summary);
|
|
128
97
|
} else {
|
|
129
98
|
var _this$props$styles4;
|
|
130
|
-
|
|
131
99
|
return (0, _emotion.jsx)("button", Object.assign({}, props, {
|
|
132
100
|
type: "button",
|
|
133
101
|
css: (_this$props$styles4 = this.props.styles) === null || _this$props$styles4 === void 0 ? void 0 : _this$props$styles4.toggle,
|
|
@@ -135,19 +103,15 @@ let ToggleDetails = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defa
|
|
|
135
103
|
}), summary);
|
|
136
104
|
}
|
|
137
105
|
}
|
|
138
|
-
|
|
139
106
|
renderIcon(expanded) {
|
|
140
107
|
var _this$props$styles5;
|
|
141
|
-
|
|
142
108
|
const Icon = expanded ? this.props.iconExpanded : this.props.icon;
|
|
143
109
|
return this.props.children && Icon ? (0, _emotion.jsx)("span", {
|
|
144
110
|
css: (_this$props$styles5 = this.props.styles) === null || _this$props$styles5 === void 0 ? void 0 : _this$props$styles5.icon
|
|
145
111
|
}, (0, _emotion.jsx)(Icon, null)) : null;
|
|
146
112
|
}
|
|
147
|
-
|
|
148
113
|
renderDetails(expanded, detailsProps) {
|
|
149
114
|
var _this$props$styles6;
|
|
150
|
-
|
|
151
115
|
const children = this.props.children;
|
|
152
116
|
const expandedStyles = expanded ? {
|
|
153
117
|
display: 'block'
|
|
@@ -158,24 +122,20 @@ let ToggleDetails = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defa
|
|
|
158
122
|
css: [(_this$props$styles6 = this.props.styles) === null || _this$props$styles6 === void 0 ? void 0 : _this$props$styles6.details, expandedStyles]
|
|
159
123
|
}), children && expanded && this.renderContent());
|
|
160
124
|
}
|
|
161
|
-
|
|
162
125
|
renderContent() {
|
|
163
126
|
var _this$props$styles7;
|
|
164
|
-
|
|
165
127
|
return (0, _emotion.jsx)("div", {
|
|
166
128
|
css: (_this$props$styles7 = this.props.styles) === null || _this$props$styles7 === void 0 ? void 0 : _this$props$styles7.content
|
|
167
129
|
}, this.props.children);
|
|
168
130
|
}
|
|
169
|
-
|
|
170
131
|
render() {
|
|
171
132
|
return (0, _emotion.jsx)(_Expandable.Expandable, Object.assign({}, (0, _pickProps.pickProps)(this.props, _Expandable.Expandable.allowedProps), {
|
|
172
133
|
onToggle: this.handleToggle
|
|
173
134
|
}), _ref => {
|
|
174
135
|
var _this$props$styles8;
|
|
175
|
-
|
|
176
136
|
let expanded = _ref.expanded,
|
|
177
|
-
|
|
178
|
-
|
|
137
|
+
getToggleProps = _ref.getToggleProps,
|
|
138
|
+
getDetailsProps = _ref.getDetailsProps;
|
|
179
139
|
return (0, _emotion.jsx)("div", {
|
|
180
140
|
css: (_this$props$styles8 = this.props.styles) === null || _this$props$styles8 === void 0 ? void 0 : _this$props$styles8.toggleDetails,
|
|
181
141
|
ref: el => {
|
|
@@ -184,7 +144,6 @@ let ToggleDetails = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defa
|
|
|
184
144
|
}, this.renderToggle(getToggleProps(), expanded), this.renderDetails(expanded, getDetailsProps()));
|
|
185
145
|
});
|
|
186
146
|
}
|
|
187
|
-
|
|
188
147
|
}, _class2.displayName = "ToggleDetails", _class2.componentId = 'ToggleDetails', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
189
148
|
variant: 'default',
|
|
190
149
|
size: 'medium',
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.propTypes = exports.allowedProps = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _controllable = require("@instructure/ui-prop-types/lib/controllable.js");
|
|
13
|
-
|
|
14
10
|
/*
|
|
15
11
|
* The MIT License (MIT)
|
|
16
12
|
*
|
|
@@ -34,6 +30,7 @@ var _controllable = require("@instructure/ui-prop-types/lib/controllable.js");
|
|
|
34
30
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
35
31
|
* SOFTWARE.
|
|
36
32
|
*/
|
|
33
|
+
|
|
37
34
|
const propTypes = {
|
|
38
35
|
variant: _propTypes.default.oneOf(['default', 'filled']),
|
|
39
36
|
summary: _propTypes.default.node.isRequired,
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _emotion = require("@instructure/emotion");
|
|
9
|
-
|
|
10
8
|
/*
|
|
11
9
|
* The MIT License (MIT)
|
|
12
10
|
*
|
|
@@ -30,10 +28,12 @@ var _emotion = require("@instructure/emotion");
|
|
|
30
28
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
29
|
* SOFTWARE.
|
|
32
30
|
*/
|
|
31
|
+
|
|
33
32
|
const contentAnimation = (0, _emotion.keyframes)`
|
|
34
33
|
to {
|
|
35
34
|
opacity: 1;
|
|
36
35
|
}`;
|
|
36
|
+
|
|
37
37
|
/**
|
|
38
38
|
* ---
|
|
39
39
|
* private: true
|
|
@@ -44,12 +44,11 @@ const contentAnimation = (0, _emotion.keyframes)`
|
|
|
44
44
|
* @param {Object} state the state of the component, the style is applied to
|
|
45
45
|
* @return {Object} The final style object, which will be used in the component
|
|
46
46
|
*/
|
|
47
|
-
|
|
48
47
|
const generateStyle = (componentTheme, props, state) => {
|
|
49
48
|
const fluidWidth = props.fluidWidth,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
iconPosition = props.iconPosition,
|
|
50
|
+
size = props.size,
|
|
51
|
+
variant = props.variant;
|
|
53
52
|
const animate = state.animate;
|
|
54
53
|
const positionIconAtEnd = iconPosition === 'end' && (variant === 'filled' || fluidWidth);
|
|
55
54
|
const fluidWidthStyles = fluidWidth ? {
|
|
@@ -177,10 +176,9 @@ const generateStyle = (componentTheme, props, state) => {
|
|
|
177
176
|
icon: {
|
|
178
177
|
label: 'toggleDetails__icon',
|
|
179
178
|
'& > svg': {
|
|
180
|
-
display: 'block'
|
|
181
|
-
/* fix vertical alignment of icon */
|
|
182
|
-
|
|
179
|
+
display: 'block' /* fix vertical alignment of icon */
|
|
183
180
|
},
|
|
181
|
+
|
|
184
182
|
...iconPositionStyles[iconPosition],
|
|
185
183
|
...iconSizeStyles[size]
|
|
186
184
|
},
|
|
@@ -201,6 +199,5 @@ const generateStyle = (componentTheme, props, state) => {
|
|
|
201
199
|
} : {}
|
|
202
200
|
};
|
|
203
201
|
};
|
|
204
|
-
|
|
205
202
|
var _default = generateStyle;
|
|
206
203
|
exports.default = _default;
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -36,10 +35,10 @@ exports.default = void 0;
|
|
|
36
35
|
*/
|
|
37
36
|
const generateComponentTheme = theme => {
|
|
38
37
|
const colors = theme.colors,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
spacing = theme.spacing,
|
|
39
|
+
borders = theme.borders,
|
|
40
|
+
typography = theme.typography,
|
|
41
|
+
themeName = theme.key;
|
|
43
42
|
const themeSpecificStyle = {
|
|
44
43
|
canvas: {
|
|
45
44
|
toggleFocusBorderColor: theme['ic-brand-primary'],
|
|
@@ -72,10 +71,10 @@ const generateComponentTheme = theme => {
|
|
|
72
71
|
filledBorderRadius: borders === null || borders === void 0 ? void 0 : borders.radiusMedium,
|
|
73
72
|
filledPadding: spacing === null || spacing === void 0 ? void 0 : spacing.small
|
|
74
73
|
};
|
|
75
|
-
return {
|
|
74
|
+
return {
|
|
75
|
+
...componentVariables,
|
|
76
76
|
...themeSpecificStyle[themeName]
|
|
77
77
|
};
|
|
78
78
|
};
|
|
79
|
-
|
|
80
79
|
var _default = generateComponentTheme;
|
|
81
80
|
exports.default = _default;
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.customMethods = exports.ToggleGroupLocator = void 0;
|
|
7
|
-
|
|
8
7
|
var _locator = require("@instructure/ui-test-locator/lib/utils/locator.js");
|
|
9
|
-
|
|
10
8
|
var _index = require("./index");
|
|
11
|
-
|
|
12
9
|
/*
|
|
13
10
|
* The MIT License (MIT)
|
|
14
11
|
*
|
|
@@ -32,13 +29,13 @@ var _index = require("./index");
|
|
|
32
29
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
30
|
* SOFTWARE.
|
|
34
31
|
*/
|
|
32
|
+
|
|
35
33
|
const ToggleLocator = (0, _locator.locator)('[aria-expanded][aria-controls]');
|
|
36
34
|
const customMethods = {
|
|
37
35
|
clickToggle: async function (element) {
|
|
38
36
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
39
37
|
args[_key - 1] = arguments[_key];
|
|
40
38
|
}
|
|
41
|
-
|
|
42
39
|
return (await ToggleLocator.find(element)).click(...args);
|
|
43
40
|
},
|
|
44
41
|
findToggle: async function () {
|
|
@@ -46,19 +43,18 @@ const customMethods = {
|
|
|
46
43
|
},
|
|
47
44
|
findContent: async function (element) {
|
|
48
45
|
const toggle = await ToggleLocator.find(element);
|
|
49
|
-
|
|
50
46
|
if (toggle) {
|
|
51
47
|
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
52
48
|
args[_key2 - 1] = arguments[_key2];
|
|
53
49
|
}
|
|
54
|
-
|
|
55
50
|
return (0, _locator.locator)(`#${toggle.getAttribute('aria-controls')}`).find(...args);
|
|
56
51
|
} else {
|
|
57
52
|
return null;
|
|
58
53
|
}
|
|
59
54
|
}
|
|
60
|
-
};
|
|
55
|
+
};
|
|
61
56
|
|
|
57
|
+
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
62
58
|
exports.customMethods = customMethods;
|
|
63
59
|
const ToggleGroupLocator = (0, _locator.locator)(_index.ToggleGroup.selector, customMethods);
|
|
64
60
|
exports.ToggleGroupLocator = ToggleGroupLocator;
|
package/lib/ToggleGroup/index.js
CHANGED
|
@@ -1,44 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = exports.ToggleGroup = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
9
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
13
|
-
|
|
14
10
|
var _pickProps = require("@instructure/ui-react-utils/lib/pickProps.js");
|
|
15
|
-
|
|
16
11
|
var _getElementType = require("@instructure/ui-react-utils/lib/getElementType.js");
|
|
17
|
-
|
|
18
12
|
var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
|
|
19
|
-
|
|
20
13
|
var _IconButton = require("@instructure/ui-buttons/lib/IconButton");
|
|
21
|
-
|
|
22
14
|
var _Transition = require("@instructure/ui-motion/lib/Transition");
|
|
23
|
-
|
|
24
15
|
var _Expandable = require("@instructure/ui-expandable/lib/Expandable");
|
|
25
|
-
|
|
26
16
|
var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js");
|
|
27
|
-
|
|
28
17
|
var _Flex = require("@instructure/ui-flex/lib/Flex");
|
|
29
|
-
|
|
30
18
|
var _View = require("@instructure/ui-view/lib/View");
|
|
31
|
-
|
|
32
19
|
var _IconArrowOpenEndSolid = require("@instructure/ui-icons/lib/IconArrowOpenEndSolid.js");
|
|
33
|
-
|
|
34
20
|
var _IconArrowOpenDownSolid = require("@instructure/ui-icons/lib/IconArrowOpenDownSolid.js");
|
|
35
|
-
|
|
36
21
|
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
37
|
-
|
|
38
22
|
var _props = require("./props");
|
|
39
|
-
|
|
40
23
|
var _dec, _class, _class2;
|
|
41
|
-
|
|
42
24
|
/**
|
|
43
25
|
---
|
|
44
26
|
category: components
|
|
@@ -51,53 +33,43 @@ let ToggleGroup = (_dec = (0, _testable.testable)(), _dec(_class = (_class2 = cl
|
|
|
51
33
|
this.ref = null;
|
|
52
34
|
this._button = null;
|
|
53
35
|
this._shouldTransition = false;
|
|
54
|
-
|
|
55
36
|
this.handleRef = el => {
|
|
56
37
|
const elementRef = this.props.elementRef;
|
|
57
38
|
this.ref = el;
|
|
58
|
-
|
|
59
39
|
if (typeof elementRef === 'function') {
|
|
60
40
|
elementRef(el);
|
|
61
41
|
}
|
|
62
42
|
};
|
|
63
|
-
|
|
64
43
|
this.handleButtonRef = el => {
|
|
65
44
|
this._button = el;
|
|
66
45
|
};
|
|
67
46
|
}
|
|
68
|
-
|
|
69
47
|
get focused() {
|
|
70
48
|
return (0, _isActiveElement.isActiveElement)(this._button);
|
|
71
49
|
}
|
|
72
|
-
|
|
73
50
|
focus() {
|
|
74
51
|
var _this$_button;
|
|
75
|
-
|
|
76
52
|
(_this$_button = this._button) === null || _this$_button === void 0 ? void 0 : _this$_button.focus();
|
|
77
53
|
}
|
|
78
|
-
|
|
79
54
|
componentDidMount() {
|
|
80
55
|
this._shouldTransition = true;
|
|
81
56
|
}
|
|
82
|
-
|
|
83
57
|
renderIcon(expanded) {
|
|
84
58
|
const Icon = expanded ? this.props.iconExpanded : this.props.icon;
|
|
85
59
|
return Icon ? (0, _callRenderProp.callRenderProp)(Icon) : null;
|
|
86
60
|
}
|
|
87
|
-
|
|
88
61
|
renderToggle(toggleProps, expanded) {
|
|
89
62
|
const _this$props = this.props,
|
|
90
|
-
|
|
91
|
-
|
|
63
|
+
toggleLabel = _this$props.toggleLabel,
|
|
64
|
+
size = _this$props.size;
|
|
92
65
|
let label;
|
|
93
|
-
|
|
94
66
|
if (typeof toggleLabel === 'function') {
|
|
95
67
|
label = toggleLabel(expanded);
|
|
96
68
|
} else {
|
|
97
69
|
label = toggleLabel;
|
|
98
70
|
}
|
|
99
|
-
|
|
100
|
-
|
|
71
|
+
const props = {
|
|
72
|
+
...toggleProps
|
|
101
73
|
};
|
|
102
74
|
return /*#__PURE__*/_react.default.createElement(_IconButton.IconButton, Object.assign({}, props, {
|
|
103
75
|
withBackground: false,
|
|
@@ -107,7 +79,6 @@ let ToggleGroup = (_dec = (0, _testable.testable)(), _dec(_class = (_class2 = cl
|
|
|
107
79
|
screenReaderLabel: label
|
|
108
80
|
}), this.renderIcon(expanded));
|
|
109
81
|
}
|
|
110
|
-
|
|
111
82
|
renderDetails(detailsProps) {
|
|
112
83
|
return /*#__PURE__*/_react.default.createElement(_View.View, Object.assign({}, detailsProps, {
|
|
113
84
|
display: "block",
|
|
@@ -118,13 +89,12 @@ let ToggleGroup = (_dec = (0, _testable.testable)(), _dec(_class = (_class2 = cl
|
|
|
118
89
|
type: "fade"
|
|
119
90
|
}, this.props.children) : this.props.children);
|
|
120
91
|
}
|
|
121
|
-
|
|
122
92
|
render() {
|
|
123
93
|
const Element = (0, _getElementType.getElementType)(ToggleGroup, this.props);
|
|
124
94
|
return /*#__PURE__*/_react.default.createElement(_Expandable.Expandable, (0, _pickProps.pickProps)(this.props, _Expandable.Expandable.allowedProps), _ref => {
|
|
125
95
|
let expanded = _ref.expanded,
|
|
126
|
-
|
|
127
|
-
|
|
96
|
+
getToggleProps = _ref.getToggleProps,
|
|
97
|
+
getDetailsProps = _ref.getDetailsProps;
|
|
128
98
|
return /*#__PURE__*/_react.default.createElement(_View.View, Object.assign({}, (0, _omitProps.omitProps)(this.props, ToggleGroup.allowedProps), {
|
|
129
99
|
borderWidth: this.props.border ? 'small' : 'none',
|
|
130
100
|
as: Element,
|
|
@@ -141,7 +111,6 @@ let ToggleGroup = (_dec = (0, _testable.testable)(), _dec(_class = (_class2 = cl
|
|
|
141
111
|
}, this.props.summary)), expanded ? this.renderDetails(getDetailsProps()) : /*#__PURE__*/_react.default.createElement("span", getDetailsProps()));
|
|
142
112
|
});
|
|
143
113
|
}
|
|
144
|
-
|
|
145
114
|
}, _class2.displayName = "ToggleGroup", _class2.componentId = 'ToggleGroup', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
146
115
|
size: 'medium',
|
|
147
116
|
icon: _IconArrowOpenEndSolid.IconArrowOpenEndSolid,
|
package/lib/ToggleGroup/props.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.propTypes = exports.allowedProps = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _controllable = require("@instructure/ui-prop-types/lib/controllable.js");
|
|
13
|
-
|
|
14
10
|
/*
|
|
15
11
|
* The MIT License (MIT)
|
|
16
12
|
*
|
|
@@ -34,6 +30,7 @@ var _controllable = require("@instructure/ui-prop-types/lib/controllable.js");
|
|
|
34
30
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
35
31
|
* SOFTWARE.
|
|
36
32
|
*/
|
|
33
|
+
|
|
37
34
|
const propTypes = {
|
|
38
35
|
children: _propTypes.default.node.isRequired,
|
|
39
36
|
summary: _propTypes.default.node.isRequired,
|
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-toggle-details",
|
|
3
|
-
"version": "8.33.
|
|
3
|
+
"version": "8.33.2",
|
|
4
4
|
"description": "A styled toggleable, accordion-like component.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -23,29 +23,29 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-babel-preset": "8.33.
|
|
27
|
-
"@instructure/ui-test-locator": "8.33.
|
|
28
|
-
"@instructure/ui-test-queries": "8.33.
|
|
29
|
-
"@instructure/ui-test-utils": "8.33.
|
|
30
|
-
"@instructure/ui-themes": "8.33.
|
|
26
|
+
"@instructure/ui-babel-preset": "8.33.2",
|
|
27
|
+
"@instructure/ui-test-locator": "8.33.2",
|
|
28
|
+
"@instructure/ui-test-queries": "8.33.2",
|
|
29
|
+
"@instructure/ui-test-utils": "8.33.2",
|
|
30
|
+
"@instructure/ui-themes": "8.33.2"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/runtime": "^7.13.10",
|
|
34
|
-
"@instructure/emotion": "8.33.
|
|
35
|
-
"@instructure/shared-types": "8.33.
|
|
36
|
-
"@instructure/ui-buttons": "8.33.
|
|
37
|
-
"@instructure/ui-dom-utils": "8.33.
|
|
38
|
-
"@instructure/ui-expandable": "8.33.
|
|
39
|
-
"@instructure/ui-flex": "8.33.
|
|
40
|
-
"@instructure/ui-icons": "8.33.
|
|
41
|
-
"@instructure/ui-menu": "8.33.
|
|
42
|
-
"@instructure/ui-motion": "8.33.
|
|
43
|
-
"@instructure/ui-prop-types": "8.33.
|
|
44
|
-
"@instructure/ui-react-utils": "8.33.
|
|
45
|
-
"@instructure/ui-testable": "8.33.
|
|
46
|
-
"@instructure/ui-utils": "8.33.
|
|
47
|
-
"@instructure/ui-view": "8.33.
|
|
48
|
-
"@instructure/uid": "8.33.
|
|
34
|
+
"@instructure/emotion": "8.33.2",
|
|
35
|
+
"@instructure/shared-types": "8.33.2",
|
|
36
|
+
"@instructure/ui-buttons": "8.33.2",
|
|
37
|
+
"@instructure/ui-dom-utils": "8.33.2",
|
|
38
|
+
"@instructure/ui-expandable": "8.33.2",
|
|
39
|
+
"@instructure/ui-flex": "8.33.2",
|
|
40
|
+
"@instructure/ui-icons": "8.33.2",
|
|
41
|
+
"@instructure/ui-menu": "8.33.2",
|
|
42
|
+
"@instructure/ui-motion": "8.33.2",
|
|
43
|
+
"@instructure/ui-prop-types": "8.33.2",
|
|
44
|
+
"@instructure/ui-react-utils": "8.33.2",
|
|
45
|
+
"@instructure/ui-testable": "8.33.2",
|
|
46
|
+
"@instructure/ui-utils": "8.33.2",
|
|
47
|
+
"@instructure/ui-view": "8.33.2",
|
|
48
|
+
"@instructure/uid": "8.33.2",
|
|
49
49
|
"prop-types": "^15"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|