@instructure/ui-toggle-details 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 +35 -289
- package/es/ToggleDetails/{index.js → v1/index.js} +2 -2
- package/es/ToggleDetails/v2/index.js +186 -0
- package/{src/index.ts → es/ToggleDetails/v2/props.js} +2 -5
- package/es/ToggleDetails/v2/styles.js +186 -0
- package/es/ToggleGroup/{index.js → v1/index.js} +4 -4
- package/es/ToggleGroup/v2/index.js +172 -0
- package/es/ToggleGroup/v2/props.js +26 -0
- package/es/ToggleGroup/v2/styles.js +40 -0
- package/es/{index.js → exports/a.js} +2 -2
- package/es/exports/b.js +25 -0
- package/lib/ToggleDetails/{index.js → v1/index.js} +5 -5
- package/lib/ToggleDetails/v2/index.js +192 -0
- package/lib/ToggleDetails/v2/props.js +31 -0
- package/lib/ToggleDetails/v2/styles.js +192 -0
- package/lib/ToggleGroup/{index.js → v1/index.js} +12 -12
- package/lib/ToggleGroup/v2/index.js +179 -0
- package/lib/ToggleGroup/v2/props.js +31 -0
- package/lib/ToggleGroup/v2/styles.js +46 -0
- package/lib/{index.js → exports/a.js} +4 -4
- package/lib/exports/b.js +19 -0
- package/package.json +45 -23
- package/src/ToggleDetails/{index.tsx → v1/index.tsx} +3 -3
- package/src/ToggleDetails/{props.ts → v1/props.ts} +1 -1
- package/src/ToggleDetails/v2/README.md +233 -0
- package/src/ToggleDetails/v2/index.tsx +205 -0
- package/src/ToggleDetails/v2/props.ts +114 -0
- package/src/ToggleDetails/v2/styles.ts +188 -0
- package/src/ToggleGroup/{index.tsx → v1/index.tsx} +4 -4
- package/src/ToggleGroup/v2/README.md +93 -0
- package/src/ToggleGroup/v2/index.tsx +213 -0
- package/src/ToggleGroup/v2/props.ts +115 -0
- package/src/ToggleGroup/v2/styles.ts +47 -0
- package/src/exports/a.ts +29 -0
- package/src/exports/b.ts +29 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/ToggleDetails/{index.d.ts → v1/index.d.ts} +1 -1
- package/types/ToggleDetails/v1/index.d.ts.map +1 -0
- package/types/ToggleDetails/{props.d.ts → v1/props.d.ts} +1 -1
- package/types/ToggleDetails/v1/props.d.ts.map +1 -0
- package/types/ToggleDetails/v1/styles.d.ts.map +1 -0
- package/types/ToggleDetails/v1/theme.d.ts.map +1 -0
- package/types/ToggleDetails/v2/index.d.ts +54 -0
- package/types/ToggleDetails/v2/index.d.ts.map +1 -0
- package/types/ToggleDetails/v2/props.d.ts +55 -0
- package/types/ToggleDetails/v2/props.d.ts.map +1 -0
- package/types/ToggleDetails/v2/styles.d.ts +16 -0
- package/types/ToggleDetails/v2/styles.d.ts.map +1 -0
- package/types/ToggleGroup/v1/index.d.ts.map +1 -0
- package/types/ToggleGroup/v1/props.d.ts.map +1 -0
- package/types/ToggleGroup/v1/styles.d.ts.map +1 -0
- package/types/ToggleGroup/v1/theme.d.ts.map +1 -0
- package/types/ToggleGroup/v2/index.d.ts +53 -0
- package/types/ToggleGroup/v2/index.d.ts.map +1 -0
- package/types/ToggleGroup/v2/props.d.ts +65 -0
- package/types/ToggleGroup/v2/props.d.ts.map +1 -0
- package/types/ToggleGroup/v2/styles.d.ts +15 -0
- package/types/ToggleGroup/v2/styles.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/ToggleDetails/index.d.ts.map +0 -1
- package/types/ToggleDetails/props.d.ts.map +0 -1
- package/types/ToggleDetails/styles.d.ts.map +0 -1
- package/types/ToggleDetails/theme.d.ts.map +0 -1
- package/types/ToggleGroup/index.d.ts.map +0 -1
- package/types/ToggleGroup/props.d.ts.map +0 -1
- package/types/ToggleGroup/styles.d.ts.map +0 -1
- package/types/ToggleGroup/theme.d.ts.map +0 -1
- package/types/index.d.ts +0 -5
- package/types/index.d.ts.map +0 -1
- /package/es/ToggleDetails/{props.js → v1/props.js} +0 -0
- /package/es/ToggleDetails/{styles.js → v1/styles.js} +0 -0
- /package/es/ToggleDetails/{theme.js → v1/theme.js} +0 -0
- /package/es/ToggleGroup/{props.js → v1/props.js} +0 -0
- /package/es/ToggleGroup/{styles.js → v1/styles.js} +0 -0
- /package/es/ToggleGroup/{theme.js → v1/theme.js} +0 -0
- /package/lib/ToggleDetails/{props.js → v1/props.js} +0 -0
- /package/lib/ToggleDetails/{styles.js → v1/styles.js} +0 -0
- /package/lib/ToggleDetails/{theme.js → v1/theme.js} +0 -0
- /package/lib/ToggleGroup/{props.js → v1/props.js} +0 -0
- /package/lib/ToggleGroup/{styles.js → v1/styles.js} +0 -0
- /package/lib/ToggleGroup/{theme.js → v1/theme.js} +0 -0
- /package/src/ToggleDetails/{README.md → v1/README.md} +0 -0
- /package/src/ToggleDetails/{styles.ts → v1/styles.ts} +0 -0
- /package/src/ToggleDetails/{theme.ts → v1/theme.ts} +0 -0
- /package/src/ToggleGroup/{README.md → v1/README.md} +0 -0
- /package/src/ToggleGroup/{props.ts → v1/props.ts} +0 -0
- /package/src/ToggleGroup/{styles.ts → v1/styles.ts} +0 -0
- /package/src/ToggleGroup/{theme.ts → v1/theme.ts} +0 -0
- /package/types/ToggleDetails/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/ToggleDetails/{theme.d.ts → v1/theme.d.ts} +0 -0
- /package/types/ToggleGroup/{index.d.ts → v1/index.d.ts} +0 -0
- /package/types/ToggleGroup/{props.d.ts → v1/props.d.ts} +0 -0
- /package/types/ToggleGroup/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/ToggleGroup/{theme.d.ts → v1/theme.d.ts} +0 -0
|
@@ -0,0 +1,179 @@
|
|
|
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.ToggleGroup = void 0;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
10
|
+
var _pickProps = require("@instructure/ui-react-utils/lib/pickProps.js");
|
|
11
|
+
var _getElementType = require("@instructure/ui-react-utils/lib/getElementType.js");
|
|
12
|
+
var _latest = require("@instructure/ui-buttons/latest");
|
|
13
|
+
var _Transition = require("@instructure/ui-motion/lib/Transition");
|
|
14
|
+
var _Expandable = require("@instructure/ui-expandable/lib/Expandable");
|
|
15
|
+
var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js");
|
|
16
|
+
var _latest2 = require("@instructure/ui-flex/latest");
|
|
17
|
+
var _latest3 = require("@instructure/ui-view/latest");
|
|
18
|
+
var _uiIcons = require("@instructure/ui-icons");
|
|
19
|
+
var _props = require("./props");
|
|
20
|
+
var _emotion = require("@instructure/emotion");
|
|
21
|
+
var _styles = _interopRequireDefault(require("./styles"));
|
|
22
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
23
|
+
var _dec, _class, _ToggleGroup;
|
|
24
|
+
/*
|
|
25
|
+
* The MIT License (MIT)
|
|
26
|
+
*
|
|
27
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
28
|
+
*
|
|
29
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
30
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
31
|
+
* in the Software without restriction, including without limitation the rights
|
|
32
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
33
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
34
|
+
* furnished to do so, subject to the following conditions:
|
|
35
|
+
*
|
|
36
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
37
|
+
* copies or substantial portions of the Software.
|
|
38
|
+
*
|
|
39
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
40
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
41
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
42
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
43
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
44
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
45
|
+
* SOFTWARE.
|
|
46
|
+
*/
|
|
47
|
+
const toggleGroupSizeToIconSize = {
|
|
48
|
+
small: 'md',
|
|
49
|
+
medium: 'md',
|
|
50
|
+
large: 'lg'
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
---
|
|
55
|
+
category: components
|
|
56
|
+
---
|
|
57
|
+
**/
|
|
58
|
+
let ToggleGroup = exports.ToggleGroup = (_dec = (0, _emotion.withStyle)(_styles.default), _dec(_class = (_ToggleGroup = class ToggleGroup extends _react.Component {
|
|
59
|
+
constructor(...args) {
|
|
60
|
+
super(...args);
|
|
61
|
+
this.ref = null;
|
|
62
|
+
this._button = null;
|
|
63
|
+
this._shouldTransition = false;
|
|
64
|
+
this.handleRef = el => {
|
|
65
|
+
const elementRef = this.props.elementRef;
|
|
66
|
+
this.ref = el;
|
|
67
|
+
if (typeof elementRef === 'function') {
|
|
68
|
+
elementRef(el);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
this.handleButtonRef = el => {
|
|
72
|
+
this._button = el;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
get focused() {
|
|
76
|
+
return (0, _isActiveElement.isActiveElement)(this._button);
|
|
77
|
+
}
|
|
78
|
+
focus() {
|
|
79
|
+
var _this$_button;
|
|
80
|
+
(_this$_button = this._button) === null || _this$_button === void 0 ? void 0 : _this$_button.focus();
|
|
81
|
+
}
|
|
82
|
+
componentDidMount() {
|
|
83
|
+
this._shouldTransition = true;
|
|
84
|
+
}
|
|
85
|
+
componentDidUpdate() {
|
|
86
|
+
var _this$props$makeStyle, _this$props;
|
|
87
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.state);
|
|
88
|
+
}
|
|
89
|
+
renderIcon(expanded) {
|
|
90
|
+
const Icon = expanded ? this.props.iconExpanded : this.props.icon;
|
|
91
|
+
if (!Icon) return null;
|
|
92
|
+
const iconSize = toggleGroupSizeToIconSize[this.props.size];
|
|
93
|
+
return (0, _uiIcons.renderIconWithProps)(Icon, iconSize, 'baseColor');
|
|
94
|
+
}
|
|
95
|
+
renderToggle(toggleProps, expanded) {
|
|
96
|
+
const _this$props2 = this.props,
|
|
97
|
+
toggleLabel = _this$props2.toggleLabel,
|
|
98
|
+
size = _this$props2.size;
|
|
99
|
+
let label;
|
|
100
|
+
if (typeof toggleLabel === 'function') {
|
|
101
|
+
label = toggleLabel(expanded);
|
|
102
|
+
} else {
|
|
103
|
+
label = toggleLabel;
|
|
104
|
+
}
|
|
105
|
+
const props = {
|
|
106
|
+
...toggleProps
|
|
107
|
+
};
|
|
108
|
+
return (0, _jsxRuntime.jsx)(_latest.IconButton, {
|
|
109
|
+
...props,
|
|
110
|
+
withBackground: false,
|
|
111
|
+
withBorder: false,
|
|
112
|
+
size: size === 'large' ? 'medium' : 'small',
|
|
113
|
+
elementRef: this.handleButtonRef,
|
|
114
|
+
screenReaderLabel: label,
|
|
115
|
+
children: this.renderIcon(expanded)
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
renderDetails(detailsProps) {
|
|
119
|
+
const styles = this.props.styles;
|
|
120
|
+
return (0, _jsxRuntime.jsx)(_latest3.View, {
|
|
121
|
+
...detailsProps,
|
|
122
|
+
display: "block",
|
|
123
|
+
borderWidth: "small none none none",
|
|
124
|
+
borderColor: styles === null || styles === void 0 ? void 0 : styles.borderColor,
|
|
125
|
+
children: this.props.transition && this._shouldTransition ? (0, _jsxRuntime.jsx)(_Transition.Transition, {
|
|
126
|
+
transitionOnMount: true,
|
|
127
|
+
in: true,
|
|
128
|
+
type: "fade",
|
|
129
|
+
children: this.props.children
|
|
130
|
+
}) : this.props.children
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
render() {
|
|
134
|
+
const Element = (0, _getElementType.getElementType)(ToggleGroup, this.props);
|
|
135
|
+
const styles = this.props.styles;
|
|
136
|
+
return (0, _jsxRuntime.jsx)(_Expandable.Expandable, {
|
|
137
|
+
...(0, _pickProps.pickProps)(this.props, _Expandable.Expandable.allowedProps),
|
|
138
|
+
children: ({
|
|
139
|
+
expanded,
|
|
140
|
+
getToggleProps,
|
|
141
|
+
getDetailsProps
|
|
142
|
+
}) => {
|
|
143
|
+
return (0, _jsxRuntime.jsxs)(_latest3.View, {
|
|
144
|
+
...(0, _omitProps.omitProps)(this.props, ToggleGroup.allowedProps),
|
|
145
|
+
borderWidth: this.props.border ? 'small' : 'none',
|
|
146
|
+
as: Element,
|
|
147
|
+
elementRef: this.handleRef,
|
|
148
|
+
display: "block",
|
|
149
|
+
borderRadius: "medium",
|
|
150
|
+
background: "primary",
|
|
151
|
+
borderColor: styles === null || styles === void 0 ? void 0 : styles.borderColor,
|
|
152
|
+
"data-cid": "ToggleGroup",
|
|
153
|
+
children: [(0, _jsxRuntime.jsxs)(_latest2.Flex, {
|
|
154
|
+
padding: this.props.size === 'small' ? 'x-small' : 'small small small x-small',
|
|
155
|
+
children: [(0, _jsxRuntime.jsx)(_latest2.Flex.Item, {
|
|
156
|
+
children: this.renderToggle(getToggleProps(), expanded)
|
|
157
|
+
}), (0, _jsxRuntime.jsx)(_latest2.Flex.Item, {
|
|
158
|
+
shouldGrow: true,
|
|
159
|
+
shouldShrink: true,
|
|
160
|
+
padding: "0 0 0 x-small",
|
|
161
|
+
children: this.props.summary
|
|
162
|
+
})]
|
|
163
|
+
}), expanded ? this.renderDetails(getDetailsProps()) : (0, _jsxRuntime.jsx)("span", {
|
|
164
|
+
...getDetailsProps()
|
|
165
|
+
})]
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}, _ToggleGroup.displayName = "ToggleGroup", _ToggleGroup.componentId = 'ToggleGroup', _ToggleGroup.allowedProps = _props.allowedProps, _ToggleGroup.defaultProps = {
|
|
171
|
+
size: 'medium',
|
|
172
|
+
icon: _uiIcons.ChevronRightInstUIIcon,
|
|
173
|
+
iconExpanded: _uiIcons.ChevronDownInstUIIcon,
|
|
174
|
+
defaultExpanded: false,
|
|
175
|
+
transition: true,
|
|
176
|
+
as: 'span',
|
|
177
|
+
border: true
|
|
178
|
+
}, _ToggleGroup)) || _class);
|
|
179
|
+
var _default = exports.default = ToggleGroup;
|
|
@@ -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 = ['children', 'summary', 'toggleLabel', 'as', 'elementRef', 'size', 'expanded', 'defaultExpanded', 'onToggle', 'icon', 'iconExpanded', 'transition', 'border'];
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = 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
|
+
/**
|
|
32
|
+
* ---
|
|
33
|
+
* private: true
|
|
34
|
+
* ---
|
|
35
|
+
* Generates the style object from the theme and provided additional information
|
|
36
|
+
* @param {Object} componentTheme The theme variable object.
|
|
37
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
38
|
+
* @param {Object} state the state of the component, the style is applied to
|
|
39
|
+
* @return {Object} The final style object, which will be used in the component
|
|
40
|
+
*/
|
|
41
|
+
const generateStyle = (componentTheme, _props) => {
|
|
42
|
+
return {
|
|
43
|
+
borderColor: componentTheme.borderColor
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
var _default = exports.default = generateStyle;
|
|
@@ -6,14 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
Object.defineProperty(exports, "ToggleDetails", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
|
-
return
|
|
9
|
+
return _v.ToggleDetails;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "ToggleGroup", {
|
|
13
13
|
enumerable: true,
|
|
14
14
|
get: function () {
|
|
15
|
-
return
|
|
15
|
+
return _v2.ToggleGroup;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
var
|
|
19
|
-
var
|
|
18
|
+
var _v = require("../ToggleDetails/v1");
|
|
19
|
+
var _v2 = require("../ToggleGroup/v1");
|
package/lib/exports/b.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "ToggleDetails", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _v.ToggleDetails;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "ToggleGroup", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _v2.ToggleGroup;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _v = require("../ToggleDetails/v2");
|
|
19
|
+
var _v2 = require("../ToggleGroup/v2");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-toggle-details",
|
|
3
|
-
"version": "11.6.
|
|
3
|
+
"version": "11.6.1-snapshot-129",
|
|
4
4
|
"description": "A styled toggleable, accordion-like component.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -15,27 +15,27 @@
|
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@babel/runtime": "^7.27.6",
|
|
18
|
-
"@instructure/
|
|
19
|
-
"@instructure/
|
|
20
|
-
"@instructure/ui-
|
|
21
|
-
"@instructure/
|
|
22
|
-
"@instructure/ui-expandable": "11.6.
|
|
23
|
-
"@instructure/ui-flex": "11.6.
|
|
24
|
-
"@instructure/ui-icons": "11.6.
|
|
25
|
-
"@instructure/ui-
|
|
26
|
-
"@instructure/ui-
|
|
27
|
-
"@instructure/ui-
|
|
28
|
-
"@instructure/ui-view": "11.6.
|
|
29
|
-
"@instructure/uid": "11.6.
|
|
18
|
+
"@instructure/shared-types": "11.6.1-snapshot-129",
|
|
19
|
+
"@instructure/emotion": "11.6.1-snapshot-129",
|
|
20
|
+
"@instructure/ui-buttons": "11.6.1-snapshot-129",
|
|
21
|
+
"@instructure/ui-dom-utils": "11.6.1-snapshot-129",
|
|
22
|
+
"@instructure/ui-expandable": "11.6.1-snapshot-129",
|
|
23
|
+
"@instructure/ui-flex": "11.6.1-snapshot-129",
|
|
24
|
+
"@instructure/ui-icons": "11.6.1-snapshot-129",
|
|
25
|
+
"@instructure/ui-utils": "11.6.1-snapshot-129",
|
|
26
|
+
"@instructure/ui-react-utils": "11.6.1-snapshot-129",
|
|
27
|
+
"@instructure/ui-motion": "11.6.1-snapshot-129",
|
|
28
|
+
"@instructure/ui-view": "11.6.1-snapshot-129",
|
|
29
|
+
"@instructure/uid": "11.6.1-snapshot-129"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@testing-library/jest-dom": "^6.6.3",
|
|
33
33
|
"@testing-library/react": "15.0.7",
|
|
34
34
|
"@testing-library/user-event": "^14.6.1",
|
|
35
35
|
"vitest": "^3.2.2",
|
|
36
|
-
"@instructure/ui-axe-check": "11.6.
|
|
37
|
-
"@instructure/ui-
|
|
38
|
-
"@instructure/ui-
|
|
36
|
+
"@instructure/ui-axe-check": "11.6.1-snapshot-129",
|
|
37
|
+
"@instructure/ui-themes": "11.6.1-snapshot-129",
|
|
38
|
+
"@instructure/ui-babel-preset": "11.6.1-snapshot-129"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"react": ">=18 <=19"
|
|
@@ -45,17 +45,39 @@
|
|
|
45
45
|
},
|
|
46
46
|
"sideEffects": false,
|
|
47
47
|
"exports": {
|
|
48
|
-
".": {
|
|
49
|
-
"types": "./types/index.d.ts",
|
|
50
|
-
"import": "./es/index.js",
|
|
51
|
-
"require": "./lib/index.js",
|
|
52
|
-
"default": "./es/index.js"
|
|
53
|
-
},
|
|
54
48
|
"./lib/*": "./lib/*",
|
|
55
49
|
"./es/*": "./es/*",
|
|
56
50
|
"./types/*": "./types/*",
|
|
57
51
|
"./package.json": "./package.json",
|
|
58
|
-
"./src/*": "./src/*"
|
|
52
|
+
"./src/*": "./src/*",
|
|
53
|
+
".": {
|
|
54
|
+
"src": "./src/exports/a.ts",
|
|
55
|
+
"types": "./types/exports/a.d.ts",
|
|
56
|
+
"import": "./es/exports/a.js",
|
|
57
|
+
"require": "./lib/exports/a.js",
|
|
58
|
+
"default": "./es/exports/a.js"
|
|
59
|
+
},
|
|
60
|
+
"./v11_6": {
|
|
61
|
+
"src": "./src/exports/a.ts",
|
|
62
|
+
"types": "./types/exports/a.d.ts",
|
|
63
|
+
"import": "./es/exports/a.js",
|
|
64
|
+
"require": "./lib/exports/a.js",
|
|
65
|
+
"default": "./es/exports/a.js"
|
|
66
|
+
},
|
|
67
|
+
"./v11_7": {
|
|
68
|
+
"src": "./src/exports/b.ts",
|
|
69
|
+
"types": "./types/exports/b.d.ts",
|
|
70
|
+
"import": "./es/exports/b.js",
|
|
71
|
+
"require": "./lib/exports/b.js",
|
|
72
|
+
"default": "./es/exports/b.js"
|
|
73
|
+
},
|
|
74
|
+
"./latest": {
|
|
75
|
+
"src": "./src/exports/b.ts",
|
|
76
|
+
"types": "./types/exports/b.d.ts",
|
|
77
|
+
"import": "./es/exports/b.js",
|
|
78
|
+
"require": "./lib/exports/b.js",
|
|
79
|
+
"default": "./es/exports/b.js"
|
|
80
|
+
}
|
|
59
81
|
},
|
|
60
82
|
"scripts": {
|
|
61
83
|
"lint": "ui-scripts lint",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import { Component, createRef } from 'react'
|
|
26
|
-
import { Button } from '@instructure/ui-buttons'
|
|
26
|
+
import { Button } from '@instructure/ui-buttons/v11_6'
|
|
27
27
|
import {
|
|
28
28
|
IconArrowOpenEndSolid,
|
|
29
29
|
IconArrowOpenDownSolid
|
|
@@ -32,13 +32,13 @@ import { Expandable } from '@instructure/ui-expandable'
|
|
|
32
32
|
import { omitProps, pickProps } from '@instructure/ui-react-utils'
|
|
33
33
|
import { isActiveElement } from '@instructure/ui-dom-utils'
|
|
34
34
|
|
|
35
|
-
import { withStyle } from '@instructure/emotion'
|
|
35
|
+
import { withStyleLegacy as withStyle } from '@instructure/emotion'
|
|
36
36
|
import generateStyle from './styles'
|
|
37
37
|
import generateComponentTheme from './theme'
|
|
38
38
|
import type { ToggleDetailsProps } from './props'
|
|
39
39
|
import { allowedProps } from './props'
|
|
40
40
|
import type { ExpandableToggleProps } from '@instructure/ui-expandable'
|
|
41
|
-
import type { ViewProps } from '@instructure/ui-view'
|
|
41
|
+
import type { ViewProps } from '@instructure/ui-view/v11_6'
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
---
|
|
@@ -29,7 +29,7 @@ import type {
|
|
|
29
29
|
ToggleDetailsTheme
|
|
30
30
|
} from '@instructure/shared-types'
|
|
31
31
|
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
32
|
-
import type { ViewProps } from '@instructure/ui-view'
|
|
32
|
+
import type { ViewProps } from '@instructure/ui-view/v11_6'
|
|
33
33
|
|
|
34
34
|
type ToggleDetailsOwnProps = {
|
|
35
35
|
variant?: 'default' | 'filled'
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
---
|
|
2
|
+
describes: ToggleDetails
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
The ToggleDetails component can be used to show/hide content in response to user action.
|
|
6
|
+
|
|
7
|
+
By default, ToggleDetails content is hidden. To override, pass in the `defaultExpanded` prop.
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
---
|
|
11
|
+
type: example
|
|
12
|
+
---
|
|
13
|
+
<ToggleDetails
|
|
14
|
+
summary="Click to hide me!"
|
|
15
|
+
defaultExpanded
|
|
16
|
+
>
|
|
17
|
+
<Text weight="bold">I am expanded!</Text> {lorem.paragraph()}
|
|
18
|
+
</ToggleDetails>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
ToggleDetails can be controlled:
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
---
|
|
25
|
+
type: example
|
|
26
|
+
---
|
|
27
|
+
const Example = () => {
|
|
28
|
+
const [expanded, setExpanded] = useState(true)
|
|
29
|
+
|
|
30
|
+
const handleChange = (event, expanded) => {
|
|
31
|
+
setExpanded(expanded)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const handleToggle = () => {
|
|
35
|
+
setExpanded((prevExpanded) => !prevExpanded)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div>
|
|
40
|
+
<Button onClick={handleToggle}>
|
|
41
|
+
<div aria-live="polite">
|
|
42
|
+
This Button {expanded ? 'Collapses' : 'Expands'}
|
|
43
|
+
</div>
|
|
44
|
+
</Button>
|
|
45
|
+
<br />
|
|
46
|
+
<br />
|
|
47
|
+
<ToggleDetails
|
|
48
|
+
summary="Click to hide me!"
|
|
49
|
+
expanded={expanded}
|
|
50
|
+
onToggle={handleChange}
|
|
51
|
+
>
|
|
52
|
+
<Text weight="bold">I am controlled and expanded!</Text>
|
|
53
|
+
{lorem.paragraph()}
|
|
54
|
+
</ToggleDetails>
|
|
55
|
+
</div>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
render(<Example />)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Setting ToggleDetails to `filled` will make the toggle use a full-width [Button](Button) component.
|
|
63
|
+
|
|
64
|
+
```js
|
|
65
|
+
---
|
|
66
|
+
type: example
|
|
67
|
+
---
|
|
68
|
+
<ToggleDetails
|
|
69
|
+
variant="filled"
|
|
70
|
+
summary="Click to expand me!"
|
|
71
|
+
>
|
|
72
|
+
{lorem.paragraph()}
|
|
73
|
+
</ToggleDetails>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Icon size / summary text formatting
|
|
77
|
+
|
|
78
|
+
Icon size can be adjusted using the `size` prop with small, medium, and large options.
|
|
79
|
+
|
|
80
|
+
The `summary` prop accepts any node, allowing you to format the summary text as
|
|
81
|
+
you see fit. In these examples, we are formatting it with the
|
|
82
|
+
[Text](Text) component.
|
|
83
|
+
|
|
84
|
+
```js
|
|
85
|
+
---
|
|
86
|
+
type: example
|
|
87
|
+
---
|
|
88
|
+
<div>
|
|
89
|
+
<ToggleDetails
|
|
90
|
+
size="small"
|
|
91
|
+
summary="Small icon"
|
|
92
|
+
>
|
|
93
|
+
{lorem.paragraph()}
|
|
94
|
+
</ToggleDetails>
|
|
95
|
+
|
|
96
|
+
<br />
|
|
97
|
+
|
|
98
|
+
<ToggleDetails summary="Medium icon">
|
|
99
|
+
{lorem.paragraph()}
|
|
100
|
+
</ToggleDetails>
|
|
101
|
+
|
|
102
|
+
<br />
|
|
103
|
+
|
|
104
|
+
<ToggleDetails
|
|
105
|
+
size="large"
|
|
106
|
+
summary="Large icon"
|
|
107
|
+
>
|
|
108
|
+
{lorem.paragraph()}
|
|
109
|
+
</ToggleDetails>
|
|
110
|
+
</div>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Icon positioning and block display
|
|
114
|
+
|
|
115
|
+
The `iconPosition` prop determines if the icon comes before or after the summary.
|
|
116
|
+
|
|
117
|
+
When the `fluidWidth` prop is set, the toggle fills the width of its
|
|
118
|
+
container.
|
|
119
|
+
|
|
120
|
+
```js
|
|
121
|
+
---
|
|
122
|
+
type: example
|
|
123
|
+
---
|
|
124
|
+
<ToggleDetails
|
|
125
|
+
summary="Block display"
|
|
126
|
+
iconPosition="end"
|
|
127
|
+
defaultExpanded
|
|
128
|
+
fluidWidth
|
|
129
|
+
>
|
|
130
|
+
<Text>
|
|
131
|
+
{lorem.paragraph()}
|
|
132
|
+
</Text>
|
|
133
|
+
</ToggleDetails>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Example to demonstrate more properties
|
|
137
|
+
|
|
138
|
+
```js
|
|
139
|
+
---
|
|
140
|
+
type: example
|
|
141
|
+
---
|
|
142
|
+
const Example = () => {
|
|
143
|
+
const [state, setState] = useState({
|
|
144
|
+
expanded: true,
|
|
145
|
+
fluidWidth: true,
|
|
146
|
+
iconPosition: 'start',
|
|
147
|
+
size: 'small',
|
|
148
|
+
variant: 'default'
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
const handleChange = (field, value) => setState(prevState => ({ ...prevState, [field]: value }));
|
|
152
|
+
const handleToggle = () => setState(prevState => ({ ...prevState, expanded: !prevState.expanded }));
|
|
153
|
+
|
|
154
|
+
const renderOptions = () => {
|
|
155
|
+
const { fluidWidth, iconPosition, size, variant } = state;
|
|
156
|
+
const options = [
|
|
157
|
+
{ name: 'iconPosition', values: ['start', 'end'] },
|
|
158
|
+
{ name: 'size', values: ['small', 'medium', 'large'] },
|
|
159
|
+
{ name: 'variant', values: ['default', 'filled'] },
|
|
160
|
+
];
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<Flex alignItems="start">
|
|
164
|
+
{options.map(({ name, values }) => (
|
|
165
|
+
<Flex.Item margin="small" key={name}>
|
|
166
|
+
<RadioInputGroup
|
|
167
|
+
name={name}
|
|
168
|
+
description={name}
|
|
169
|
+
value={state[name]}
|
|
170
|
+
onChange={(e, value) => handleChange(name, value)}
|
|
171
|
+
>
|
|
172
|
+
{values.map(val => (
|
|
173
|
+
<RadioInput label={val} value={val} key={val} />
|
|
174
|
+
))}
|
|
175
|
+
</RadioInputGroup>
|
|
176
|
+
</Flex.Item>
|
|
177
|
+
))}
|
|
178
|
+
<Flex.Item margin="small">
|
|
179
|
+
<Checkbox
|
|
180
|
+
label="fluidWidth"
|
|
181
|
+
checked={fluidWidth}
|
|
182
|
+
onChange={() => handleChange('fluidWidth', !fluidWidth)}
|
|
183
|
+
/>
|
|
184
|
+
</Flex.Item>
|
|
185
|
+
</Flex>
|
|
186
|
+
);
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const { expanded, iconPosition, size, variant, fluidWidth } = state;
|
|
190
|
+
|
|
191
|
+
return (
|
|
192
|
+
<div>
|
|
193
|
+
{renderOptions()}
|
|
194
|
+
<Button onClick={handleToggle}>
|
|
195
|
+
This Button {expanded ? 'Collapses' : 'Expands'}
|
|
196
|
+
</Button>
|
|
197
|
+
<br />
|
|
198
|
+
<br />
|
|
199
|
+
<ToggleDetails
|
|
200
|
+
summary="Click to hide me!"
|
|
201
|
+
expanded={expanded}
|
|
202
|
+
onToggle={(_, expanded) => handleChange('expanded', expanded)}
|
|
203
|
+
fluidWidth={fluidWidth}
|
|
204
|
+
iconPosition={iconPosition}
|
|
205
|
+
size={size}
|
|
206
|
+
variant={variant}
|
|
207
|
+
>
|
|
208
|
+
<span>
|
|
209
|
+
I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!
|
|
210
|
+
</span>
|
|
211
|
+
</ToggleDetails>
|
|
212
|
+
</div>
|
|
213
|
+
);
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
render(<Example />)
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Guidelines
|
|
220
|
+
|
|
221
|
+
```js
|
|
222
|
+
---
|
|
223
|
+
type: embed
|
|
224
|
+
---
|
|
225
|
+
<Guidelines>
|
|
226
|
+
<Figure recommendation="yes" title="Do">
|
|
227
|
+
<Figure.Item>Use ToggleDetails when descriptive text is longer than a short phrase</Figure.Item>
|
|
228
|
+
</Figure>
|
|
229
|
+
<Figure recommendation="no" title="Don't">
|
|
230
|
+
<Figure.Item>Nest ToggleDetails within another ToggleDetails</Figure.Item>
|
|
231
|
+
</Figure>
|
|
232
|
+
</Guidelines>
|
|
233
|
+
```
|