@instructure/ui-toggle-details 8.8.1-snapshot.8 → 8.9.0
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 +6 -0
- package/es/ToggleDetails/index.js +38 -72
- package/es/ToggleDetails/props.js +76 -0
- package/es/ToggleGroup/index.js +3 -67
- package/es/ToggleGroup/props.js +90 -0
- package/lib/ToggleDetails/index.js +38 -73
- package/lib/ToggleDetails/props.js +88 -0
- package/lib/ToggleGroup/index.js +3 -70
- package/lib/ToggleGroup/props.js +102 -0
- package/package.json +22 -23
- package/src/ToggleDetails/index.tsx +16 -64
- package/src/ToggleDetails/props.ts +112 -0
- package/src/ToggleDetails/styles.ts +1 -1
- package/src/ToggleGroup/index.tsx +5 -58
- package/src/ToggleGroup/props.ts +124 -0
- package/src/index.ts +2 -2
- package/types/ToggleDetails/index.d.ts +27 -45
- package/types/ToggleDetails/index.d.ts.map +1 -1
- package/types/ToggleDetails/props.d.ts +27 -0
- package/types/ToggleDetails/props.d.ts.map +1 -0
- package/types/ToggleDetails/styles.d.ts +1 -1
- package/types/ToggleGroup/index.d.ts +32 -56
- package/types/ToggleGroup/index.d.ts.map +1 -1
- package/types/ToggleGroup/props.d.ts +25 -0
- package/types/ToggleGroup/props.d.ts.map +1 -0
- package/types/index.d.ts +2 -2
- package/LICENSE.md +0 -27
- package/es/ToggleDetails/types.js +0 -1
- package/es/ToggleGroup/types.js +0 -1
- package/lib/ToggleDetails/types.js +0 -1
- package/lib/ToggleGroup/types.js +0 -1
- package/src/ToggleDetails/types.ts +0 -42
- package/src/ToggleGroup/types.ts +0 -41
- package/types/ToggleDetails/types.d.ts +0 -19
- package/types/ToggleDetails/types.d.ts.map +0 -1
- package/types/ToggleGroup/types.d.ts +0 -17
- package/types/ToggleGroup/types.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
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.0](https://github.com/instructure/instructure-ui/compare/v8.8.0...v8.9.0) (2021-09-15)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- fix shared-types TS errors ([7b83164](https://github.com/instructure/instructure-ui/commit/7b83164f4c5872f3a217e010563f59bf584ae4fc))
|
|
11
|
+
|
|
6
12
|
# [8.8.0](https://github.com/instructure/instructure-ui/compare/v8.7.0...v8.8.0) (2021-08-27)
|
|
7
13
|
|
|
8
14
|
### Features
|
|
@@ -26,23 +26,22 @@ 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 { Button } from '@instructure/ui-buttons';
|
|
31
30
|
import { IconArrowOpenEndSolid, IconArrowOpenDownSolid } from '@instructure/ui-icons';
|
|
32
31
|
import { Expandable } from '@instructure/ui-expandable';
|
|
33
|
-
import { controllable } from '@instructure/ui-prop-types';
|
|
34
32
|
import { omitProps, pickProps } from '@instructure/ui-react-utils';
|
|
35
33
|
import { isActiveElement } from '@instructure/ui-dom-utils';
|
|
36
34
|
import { testable } from '@instructure/ui-testable';
|
|
37
35
|
import { withStyle, jsx } from '@instructure/emotion';
|
|
38
36
|
import generateStyle from './styles';
|
|
39
37
|
import generateComponentTheme from './theme';
|
|
40
|
-
|
|
38
|
+
import { allowedProps, propTypes } from './props';
|
|
41
39
|
/**
|
|
42
40
|
---
|
|
43
41
|
category: components
|
|
44
42
|
---
|
|
45
43
|
**/
|
|
44
|
+
|
|
46
45
|
let ToggleDetails = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_temp = _class2 = class ToggleDetails extends Component {
|
|
47
46
|
constructor(...args) {
|
|
48
47
|
super(...args);
|
|
@@ -50,8 +49,10 @@ let ToggleDetails = (_dec = withStyle(generateStyle, generateComponentTheme), _d
|
|
|
50
49
|
this.getButtonRef = el => this._button = el;
|
|
51
50
|
|
|
52
51
|
this.handleToggle = (event, expanded) => {
|
|
52
|
+
var _this$props$makeStyle, _this$props;
|
|
53
|
+
|
|
53
54
|
this.props.onToggle(event, expanded);
|
|
54
|
-
this.props.makeStyles({
|
|
55
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, {
|
|
55
56
|
animate: true
|
|
56
57
|
});
|
|
57
58
|
};
|
|
@@ -66,25 +67,31 @@ let ToggleDetails = (_dec = withStyle(generateStyle, generateComponentTheme), _d
|
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
componentDidMount() {
|
|
69
|
-
|
|
70
|
+
var _this$props$makeStyle2, _this$props2;
|
|
71
|
+
|
|
72
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, {
|
|
70
73
|
animate: false
|
|
71
74
|
});
|
|
72
75
|
}
|
|
73
76
|
|
|
74
77
|
componentDidUpdate() {
|
|
75
|
-
|
|
78
|
+
var _this$props$makeStyle3, _this$props3;
|
|
79
|
+
|
|
80
|
+
(_this$props$makeStyle3 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle3 === void 0 ? void 0 : _this$props$makeStyle3.call(_this$props3, {
|
|
76
81
|
animate: true
|
|
77
82
|
});
|
|
78
83
|
}
|
|
79
84
|
|
|
80
85
|
renderSummary(expanded) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
86
|
+
var _this$props$styles, _this$props$styles2;
|
|
87
|
+
|
|
88
|
+
const _this$props4 = this.props,
|
|
89
|
+
summary = _this$props4.summary,
|
|
90
|
+
iconPosition = _this$props4.iconPosition;
|
|
84
91
|
return jsx("span", {
|
|
85
|
-
css: this.props.styles.summary
|
|
92
|
+
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.summary
|
|
86
93
|
}, iconPosition === 'start' && this.renderIcon(expanded), jsx("span", {
|
|
87
|
-
css: this.props.styles.summaryText
|
|
94
|
+
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.summaryText
|
|
88
95
|
}, summary), iconPosition === 'end' && this.renderIcon(expanded));
|
|
89
96
|
}
|
|
90
97
|
|
|
@@ -103,27 +110,35 @@ let ToggleDetails = (_dec = withStyle(generateStyle, generateComponentTheme), _d
|
|
|
103
110
|
elementRef: this.getButtonRef
|
|
104
111
|
}), summary);
|
|
105
112
|
} else if (props.href) {
|
|
113
|
+
var _this$props$styles3;
|
|
114
|
+
|
|
106
115
|
return jsx("a", Object.assign({}, props, {
|
|
107
|
-
css: this.props.styles.toggle,
|
|
116
|
+
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.toggle,
|
|
108
117
|
ref: this.getButtonRef
|
|
109
118
|
}), summary);
|
|
110
119
|
} else {
|
|
120
|
+
var _this$props$styles4;
|
|
121
|
+
|
|
111
122
|
return jsx("button", Object.assign({}, props, {
|
|
112
123
|
type: "button",
|
|
113
|
-
css: this.props.styles.toggle,
|
|
124
|
+
css: (_this$props$styles4 = this.props.styles) === null || _this$props$styles4 === void 0 ? void 0 : _this$props$styles4.toggle,
|
|
114
125
|
ref: this.getButtonRef
|
|
115
126
|
}), summary);
|
|
116
127
|
}
|
|
117
128
|
}
|
|
118
129
|
|
|
119
130
|
renderIcon(expanded) {
|
|
131
|
+
var _this$props$styles5;
|
|
132
|
+
|
|
120
133
|
const Icon = expanded ? this.props.iconExpanded : this.props.icon;
|
|
121
134
|
return this.props.children ? jsx("span", {
|
|
122
|
-
css: this.props.styles.icon
|
|
135
|
+
css: (_this$props$styles5 = this.props.styles) === null || _this$props$styles5 === void 0 ? void 0 : _this$props$styles5.icon
|
|
123
136
|
}, jsx(Icon, null)) : null;
|
|
124
137
|
}
|
|
125
138
|
|
|
126
139
|
renderDetails(expanded, detailsProps) {
|
|
140
|
+
var _this$props$styles6;
|
|
141
|
+
|
|
127
142
|
const children = this.props.children;
|
|
128
143
|
const expandedStyles = expanded ? {
|
|
129
144
|
display: 'block'
|
|
@@ -131,13 +146,15 @@ let ToggleDetails = (_dec = withStyle(generateStyle, generateComponentTheme), _d
|
|
|
131
146
|
display: 'none'
|
|
132
147
|
};
|
|
133
148
|
return jsx("div", Object.assign({}, detailsProps, {
|
|
134
|
-
css: [this.props.styles.details, expandedStyles]
|
|
149
|
+
css: [(_this$props$styles6 = this.props.styles) === null || _this$props$styles6 === void 0 ? void 0 : _this$props$styles6.details, expandedStyles]
|
|
135
150
|
}), children && expanded && this.renderContent());
|
|
136
151
|
}
|
|
137
152
|
|
|
138
153
|
renderContent() {
|
|
154
|
+
var _this$props$styles7;
|
|
155
|
+
|
|
139
156
|
return jsx("div", {
|
|
140
|
-
css: this.props.styles.content
|
|
157
|
+
css: (_this$props$styles7 = this.props.styles) === null || _this$props$styles7 === void 0 ? void 0 : _this$props$styles7.content
|
|
141
158
|
}, this.props.children);
|
|
142
159
|
}
|
|
143
160
|
|
|
@@ -149,65 +166,15 @@ let ToggleDetails = (_dec = withStyle(generateStyle, generateComponentTheme), _d
|
|
|
149
166
|
getToggleProps,
|
|
150
167
|
getDetailsProps
|
|
151
168
|
}) => {
|
|
169
|
+
var _this$props$styles8;
|
|
170
|
+
|
|
152
171
|
return jsx("div", {
|
|
153
|
-
css: this.props.styles.toggleDetails
|
|
172
|
+
css: (_this$props$styles8 = this.props.styles) === null || _this$props$styles8 === void 0 ? void 0 : _this$props$styles8.toggleDetails
|
|
154
173
|
}, this.renderToggle(getToggleProps(), expanded), this.renderDetails(expanded, getDetailsProps()));
|
|
155
174
|
});
|
|
156
175
|
}
|
|
157
176
|
|
|
158
|
-
}, _class2.displayName = "ToggleDetails", _class2.componentId = 'ToggleDetails', _class2.propTypes = {
|
|
159
|
-
// eslint-disable-next-line react/require-default-props
|
|
160
|
-
makeStyles: PropTypes.func,
|
|
161
|
-
// eslint-disable-next-line react/require-default-props
|
|
162
|
-
styles: PropTypes.object,
|
|
163
|
-
variant: PropTypes.oneOf(['default', 'filled']),
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* The summary that displays and can be interacted with
|
|
167
|
-
*/
|
|
168
|
-
summary: PropTypes.node.isRequired,
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Whether the content is expanded or hidden
|
|
172
|
-
*/
|
|
173
|
-
expanded: controllable(PropTypes.bool, 'onToggle', 'defaultExpanded'),
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Whether the content is initially expanded or hidden (uncontrolled)
|
|
177
|
-
*/
|
|
178
|
-
defaultExpanded: PropTypes.bool,
|
|
179
|
-
onToggle: PropTypes.func,
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* The icon to display next to the summary text when content is hidden
|
|
183
|
-
*/
|
|
184
|
-
icon: PropTypes.func,
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* The icon to display when content is expanded
|
|
188
|
-
*/
|
|
189
|
-
iconExpanded: PropTypes.func,
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Icon position at the start or end of the summary text
|
|
193
|
-
*/
|
|
194
|
-
iconPosition: PropTypes.oneOf(['start', 'end']),
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* should the summary fill the width of its container
|
|
198
|
-
*/
|
|
199
|
-
fluidWidth: PropTypes.bool,
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* The toggleable content passed inside the ToggleDetails component
|
|
203
|
-
*/
|
|
204
|
-
children: PropTypes.node,
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Choose a size for the expand/collapse icon
|
|
208
|
-
*/
|
|
209
|
-
size: PropTypes.oneOf(['small', 'medium', 'large'])
|
|
210
|
-
}, _class2.defaultProps = {
|
|
177
|
+
}, _class2.displayName = "ToggleDetails", _class2.componentId = 'ToggleDetails', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
211
178
|
variant: 'default',
|
|
212
179
|
size: 'medium',
|
|
213
180
|
fluidWidth: false,
|
|
@@ -216,8 +183,7 @@ let ToggleDetails = (_dec = withStyle(generateStyle, generateComponentTheme), _d
|
|
|
216
183
|
iconPosition: 'start',
|
|
217
184
|
defaultExpanded: false,
|
|
218
185
|
onToggle: function (event, expanded) {},
|
|
219
|
-
children: null
|
|
220
|
-
expanded: void 0
|
|
186
|
+
children: null
|
|
221
187
|
}, _temp)) || _class) || _class);
|
|
222
188
|
export default ToggleDetails;
|
|
223
189
|
export { ToggleDetails };
|
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
const propTypes = {
|
|
27
|
+
variant: PropTypes.oneOf(['default', 'filled']),
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The summary that displays and can be interacted with
|
|
31
|
+
*/
|
|
32
|
+
summary: PropTypes.node.isRequired,
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Whether the content is expanded or hidden
|
|
36
|
+
*/
|
|
37
|
+
expanded: controllable(PropTypes.bool, 'onToggle', 'defaultExpanded'),
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Whether the content is initially expanded or hidden (uncontrolled)
|
|
41
|
+
*/
|
|
42
|
+
defaultExpanded: PropTypes.bool,
|
|
43
|
+
onToggle: PropTypes.func,
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The icon to display next to the summary text when content is hidden
|
|
47
|
+
*/
|
|
48
|
+
icon: PropTypes.func,
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The icon to display when content is expanded
|
|
52
|
+
*/
|
|
53
|
+
iconExpanded: PropTypes.func,
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Icon position at the start or end of the summary text
|
|
57
|
+
*/
|
|
58
|
+
iconPosition: PropTypes.oneOf(['start', 'end']),
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* should the summary fill the width of its container
|
|
62
|
+
*/
|
|
63
|
+
fluidWidth: PropTypes.bool,
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The toggleable content passed inside the ToggleDetails component
|
|
67
|
+
*/
|
|
68
|
+
children: PropTypes.node,
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Choose a size for the expand/collapse icon
|
|
72
|
+
*/
|
|
73
|
+
size: PropTypes.oneOf(['small', 'medium', 'large'])
|
|
74
|
+
};
|
|
75
|
+
const allowedProps = ['variant', 'summary', 'expanded', 'defaultExpanded', 'onToggle', 'icon', 'iconExpanded', 'iconPosition', 'fluidWidth', 'children', 'size'];
|
|
76
|
+
export { propTypes, allowedProps };
|
package/es/ToggleGroup/index.js
CHANGED
|
@@ -24,23 +24,22 @@ var _dec, _class, _class2, _temp;
|
|
|
24
24
|
* SOFTWARE.
|
|
25
25
|
*/
|
|
26
26
|
import React, { Component } from 'react';
|
|
27
|
-
import PropTypes from 'prop-types';
|
|
28
27
|
import { omitProps, pickProps, getElementType } from '@instructure/ui-react-utils';
|
|
29
28
|
import { IconButton } from '@instructure/ui-buttons';
|
|
30
29
|
import { Transition } from '@instructure/ui-motion';
|
|
31
30
|
import { Expandable } from '@instructure/ui-expandable';
|
|
32
|
-
import { controllable } from '@instructure/ui-prop-types';
|
|
33
31
|
import { isActiveElement } from '@instructure/ui-dom-utils';
|
|
34
32
|
import { Flex } from '@instructure/ui-flex';
|
|
35
33
|
import { View } from '@instructure/ui-view';
|
|
36
34
|
import { IconArrowOpenEndSolid, IconArrowOpenDownSolid } from '@instructure/ui-icons';
|
|
37
35
|
import { testable } from '@instructure/ui-testable';
|
|
38
|
-
|
|
36
|
+
import { allowedProps, propTypes } from './props';
|
|
39
37
|
/**
|
|
40
38
|
---
|
|
41
39
|
category: components
|
|
42
40
|
---
|
|
43
41
|
**/
|
|
42
|
+
|
|
44
43
|
let ToggleGroup = (_dec = testable(), _dec(_class = (_temp = _class2 = class ToggleGroup extends Component {
|
|
45
44
|
constructor(...args) {
|
|
46
45
|
super(...args);
|
|
@@ -123,70 +122,7 @@ let ToggleGroup = (_dec = testable(), _dec(_class = (_temp = _class2 = class Tog
|
|
|
123
122
|
});
|
|
124
123
|
}
|
|
125
124
|
|
|
126
|
-
}, _class2.displayName = "ToggleGroup", _class2.componentId = 'ToggleGroup', _class2.propTypes = {
|
|
127
|
-
/**
|
|
128
|
-
* the content to show and hide
|
|
129
|
-
*/
|
|
130
|
-
children: PropTypes.node.isRequired,
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* the content area next to the toggle button
|
|
134
|
-
*/
|
|
135
|
-
summary: PropTypes.node.isRequired,
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* provides a screenreader label for the toggle button
|
|
139
|
-
* (takes `expanded` as an argument if a function)
|
|
140
|
-
*/
|
|
141
|
-
toggleLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired,
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* the element type to render as
|
|
145
|
-
*/
|
|
146
|
-
as: PropTypes.elementType,
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* provides a reference to the underlying html root element
|
|
150
|
-
*/
|
|
151
|
-
elementRef: PropTypes.func,
|
|
152
|
-
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Whether the content is expanded or hidden
|
|
156
|
-
*/
|
|
157
|
-
expanded: controllable(PropTypes.bool, 'onToggle', 'defaultExpanded'),
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Whether the content is initially expanded or hidden (uncontrolled)
|
|
161
|
-
*/
|
|
162
|
-
defaultExpanded: PropTypes.bool,
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Fired when the content display is toggled
|
|
166
|
-
*/
|
|
167
|
-
onToggle: PropTypes.func,
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* The icon displayed in the toggle button when the content is hidden
|
|
171
|
-
*/
|
|
172
|
-
icon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* The icon displayed in the toggle button when the content is showing
|
|
176
|
-
*/
|
|
177
|
-
iconExpanded: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Transition content into view
|
|
181
|
-
*/
|
|
182
|
-
transition: PropTypes.bool,
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Toggle the border around the component
|
|
186
|
-
*/
|
|
187
|
-
border: PropTypes.bool
|
|
188
|
-
}, _class2.defaultProps = {
|
|
189
|
-
expanded: void 0,
|
|
125
|
+
}, _class2.displayName = "ToggleGroup", _class2.componentId = 'ToggleGroup', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
190
126
|
size: 'medium',
|
|
191
127
|
icon: IconArrowOpenEndSolid,
|
|
192
128
|
iconExpanded: IconArrowOpenDownSolid,
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
const propTypes = {
|
|
27
|
+
/**
|
|
28
|
+
* the content to show and hide
|
|
29
|
+
*/
|
|
30
|
+
children: PropTypes.node.isRequired,
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* the content area next to the toggle button
|
|
34
|
+
*/
|
|
35
|
+
summary: PropTypes.node.isRequired,
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* provides a screenreader label for the toggle button
|
|
39
|
+
* (takes `expanded` as an argument if a function)
|
|
40
|
+
*/
|
|
41
|
+
toggleLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired,
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* the element type to render as
|
|
45
|
+
*/
|
|
46
|
+
as: PropTypes.elementType,
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* provides a reference to the underlying html root element
|
|
50
|
+
*/
|
|
51
|
+
elementRef: PropTypes.func,
|
|
52
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Whether the content is expanded or hidden
|
|
56
|
+
*/
|
|
57
|
+
expanded: controllable(PropTypes.bool, 'onToggle', 'defaultExpanded'),
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Whether the content is initially expanded or hidden (uncontrolled)
|
|
61
|
+
*/
|
|
62
|
+
defaultExpanded: PropTypes.bool,
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Fired when the content display is toggled
|
|
66
|
+
*/
|
|
67
|
+
onToggle: PropTypes.func,
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The icon displayed in the toggle button when the content is hidden
|
|
71
|
+
*/
|
|
72
|
+
icon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The icon displayed in the toggle button when the content is showing
|
|
76
|
+
*/
|
|
77
|
+
iconExpanded: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Transition content into view
|
|
81
|
+
*/
|
|
82
|
+
transition: PropTypes.bool,
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Toggle the border around the component
|
|
86
|
+
*/
|
|
87
|
+
border: PropTypes.bool
|
|
88
|
+
};
|
|
89
|
+
const allowedProps = ['children', 'summary', 'toggleLabel', 'as', 'elementRef', 'size', 'expanded', 'defaultExpanded', 'onToggle', 'icon', 'iconExpanded', 'transition', 'border'];
|
|
90
|
+
export { propTypes, allowedProps };
|