@ohos-ports/instructure-ui-toggle-details 11.7.5-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/CHANGELOG.md +1323 -0
  2. package/LICENSE.md +28 -0
  3. package/README.md +42 -0
  4. package/es/ToggleDetails/v1/index.js +177 -0
  5. package/es/ToggleDetails/v1/props.js +26 -0
  6. package/es/ToggleDetails/v1/styles.js +196 -0
  7. package/es/ToggleDetails/v1/theme.js +75 -0
  8. package/es/ToggleDetails/v2/index.js +181 -0
  9. package/es/ToggleDetails/v2/props.js +26 -0
  10. package/es/ToggleDetails/v2/styles.js +188 -0
  11. package/es/ToggleGroup/v1/index.js +172 -0
  12. package/es/ToggleGroup/v1/props.js +26 -0
  13. package/es/ToggleGroup/v1/styles.js +40 -0
  14. package/es/ToggleGroup/v1/theme.js +41 -0
  15. package/es/ToggleGroup/v2/index.js +178 -0
  16. package/es/ToggleGroup/v2/props.js +26 -0
  17. package/es/ToggleGroup/v2/styles.js +40 -0
  18. package/es/exports/a.js +26 -0
  19. package/es/exports/b.js +26 -0
  20. package/lib/ToggleDetails/v1/index.js +184 -0
  21. package/lib/ToggleDetails/v1/props.js +31 -0
  22. package/lib/ToggleDetails/v1/styles.js +202 -0
  23. package/lib/ToggleDetails/v1/theme.js +81 -0
  24. package/lib/ToggleDetails/v2/index.js +187 -0
  25. package/lib/ToggleDetails/v2/props.js +31 -0
  26. package/lib/ToggleDetails/v2/styles.js +194 -0
  27. package/lib/ToggleGroup/v1/index.js +180 -0
  28. package/lib/ToggleGroup/v1/props.js +31 -0
  29. package/lib/ToggleGroup/v1/styles.js +46 -0
  30. package/lib/ToggleGroup/v1/theme.js +47 -0
  31. package/lib/ToggleGroup/v2/index.js +185 -0
  32. package/lib/ToggleGroup/v2/props.js +31 -0
  33. package/lib/ToggleGroup/v2/styles.js +46 -0
  34. package/lib/exports/a.js +19 -0
  35. package/lib/exports/b.js +19 -0
  36. package/lib/package.json +1 -0
  37. package/package.json +94 -0
  38. package/src/ToggleDetails/v1/README.md +233 -0
  39. package/src/ToggleDetails/v1/index.tsx +204 -0
  40. package/src/ToggleDetails/v1/props.ts +114 -0
  41. package/src/ToggleDetails/v1/styles.ts +190 -0
  42. package/src/ToggleDetails/v1/theme.ts +80 -0
  43. package/src/ToggleDetails/v2/README.md +233 -0
  44. package/src/ToggleDetails/v2/index.tsx +206 -0
  45. package/src/ToggleDetails/v2/props.ts +115 -0
  46. package/src/ToggleDetails/v2/styles.ts +188 -0
  47. package/src/ToggleGroup/v1/README.md +93 -0
  48. package/src/ToggleGroup/v1/index.tsx +206 -0
  49. package/src/ToggleGroup/v1/props.ts +115 -0
  50. package/src/ToggleGroup/v1/styles.ts +47 -0
  51. package/src/ToggleGroup/v1/theme.ts +43 -0
  52. package/src/ToggleGroup/v2/README.md +93 -0
  53. package/src/ToggleGroup/v2/index.tsx +214 -0
  54. package/src/ToggleGroup/v2/props.ts +115 -0
  55. package/src/ToggleGroup/v2/styles.ts +47 -0
  56. package/src/exports/a.ts +29 -0
  57. package/src/exports/b.ts +29 -0
  58. package/tsconfig.build.json +26 -0
  59. package/tsconfig.json +4 -0
  60. package/types/ToggleDetails/v1/index.d.ts +56 -0
  61. package/types/ToggleDetails/v1/index.d.ts.map +1 -0
  62. package/types/ToggleDetails/v1/props.d.ts +55 -0
  63. package/types/ToggleDetails/v1/props.d.ts.map +1 -0
  64. package/types/ToggleDetails/v1/styles.d.ts +15 -0
  65. package/types/ToggleDetails/v1/styles.d.ts.map +1 -0
  66. package/types/ToggleDetails/v1/theme.d.ts +10 -0
  67. package/types/ToggleDetails/v1/theme.d.ts.map +1 -0
  68. package/types/ToggleDetails/v2/index.d.ts +55 -0
  69. package/types/ToggleDetails/v2/index.d.ts.map +1 -0
  70. package/types/ToggleDetails/v2/props.d.ts +56 -0
  71. package/types/ToggleDetails/v2/props.d.ts.map +1 -0
  72. package/types/ToggleDetails/v2/styles.d.ts +16 -0
  73. package/types/ToggleDetails/v2/styles.d.ts.map +1 -0
  74. package/types/ToggleGroup/v1/index.d.ts +55 -0
  75. package/types/ToggleGroup/v1/index.d.ts.map +1 -0
  76. package/types/ToggleGroup/v1/props.d.ts +65 -0
  77. package/types/ToggleGroup/v1/props.d.ts.map +1 -0
  78. package/types/ToggleGroup/v1/styles.d.ts +15 -0
  79. package/types/ToggleGroup/v1/styles.d.ts.map +1 -0
  80. package/types/ToggleGroup/v1/theme.d.ts +10 -0
  81. package/types/ToggleGroup/v1/theme.d.ts.map +1 -0
  82. package/types/ToggleGroup/v2/index.d.ts +54 -0
  83. package/types/ToggleGroup/v2/index.d.ts.map +1 -0
  84. package/types/ToggleGroup/v2/props.d.ts +66 -0
  85. package/types/ToggleGroup/v2/props.d.ts.map +1 -0
  86. package/types/ToggleGroup/v2/styles.d.ts +15 -0
  87. package/types/ToggleGroup/v2/styles.d.ts.map +1 -0
  88. package/types/exports/a.d.ts +5 -0
  89. package/types/exports/a.d.ts.map +1 -0
  90. package/types/exports/b.d.ts +5 -0
  91. package/types/exports/b.d.ts.map +1 -0
@@ -0,0 +1,180 @@
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 _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
13
+ var _v11_ = require("@instructure/ui-buttons/v11_6");
14
+ var _Transition = require("@instructure/ui-motion/lib/Transition");
15
+ var _uiExpandable = require("@instructure/ui-expandable");
16
+ var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js");
17
+ var _v11_2 = require("@instructure/ui-flex/v11_6");
18
+ var _v11_3 = require("@instructure/ui-view/v11_6");
19
+ var _IconArrowOpenEndSolid = require("@instructure/ui-icons/lib/generated/IconArrowOpenEndSolid.js");
20
+ var _IconArrowOpenDownSolid = require("@instructure/ui-icons/lib/generated/IconArrowOpenDownSolid.js");
21
+ var _props = require("./props.js");
22
+ var _emotion = require("@instructure/emotion");
23
+ var _styles = _interopRequireDefault(require("./styles.js"));
24
+ var _theme = _interopRequireDefault(require("./theme.js"));
25
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
26
+ var _dec, _class;
27
+ /*
28
+ * The MIT License (MIT)
29
+ *
30
+ * Copyright (c) 2015 - present Instructure, Inc.
31
+ *
32
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
33
+ * of this software and associated documentation files (the "Software"), to deal
34
+ * in the Software without restriction, including without limitation the rights
35
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
36
+ * copies of the Software, and to permit persons to whom the Software is
37
+ * furnished to do so, subject to the following conditions:
38
+ *
39
+ * The above copyright notice and this permission notice shall be included in all
40
+ * copies or substantial portions of the Software.
41
+ *
42
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
45
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
46
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
47
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
48
+ * SOFTWARE.
49
+ */
50
+ /**
51
+ ---
52
+ category: components
53
+ ---
54
+ **/
55
+ let ToggleGroup = exports.ToggleGroup = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = class ToggleGroup extends _react.Component {
56
+ static displayName = 'ToggleGroup';
57
+ static componentId = 'ToggleGroup';
58
+ static allowedProps = _props.allowedProps;
59
+ static defaultProps = {
60
+ size: 'medium',
61
+ icon: _IconArrowOpenEndSolid.IconArrowOpenEndSolid,
62
+ iconExpanded: _IconArrowOpenDownSolid.IconArrowOpenDownSolid,
63
+ defaultExpanded: false,
64
+ transition: true,
65
+ as: 'span',
66
+ border: true
67
+ };
68
+ ref = null;
69
+ _button = null;
70
+ _shouldTransition = false;
71
+ handleRef = el => {
72
+ const {
73
+ elementRef
74
+ } = this.props;
75
+ this.ref = el;
76
+ if (typeof elementRef === 'function') {
77
+ elementRef(el);
78
+ }
79
+ };
80
+ handleButtonRef = el => {
81
+ this._button = el;
82
+ };
83
+ get focused() {
84
+ return (0, _isActiveElement.isActiveElement)(this._button);
85
+ }
86
+ focus() {
87
+ this._button?.focus();
88
+ }
89
+ componentDidMount() {
90
+ this._shouldTransition = true;
91
+ }
92
+ componentDidUpdate() {
93
+ this.props.makeStyles?.(this.state);
94
+ }
95
+ renderIcon(expanded) {
96
+ const Icon = expanded ? this.props.iconExpanded : this.props.icon;
97
+ return Icon ? (0, _callRenderProp.callRenderProp)(Icon) : null;
98
+ }
99
+ renderToggle(toggleProps, expanded) {
100
+ const {
101
+ toggleLabel,
102
+ size
103
+ } = this.props;
104
+ let label;
105
+ if (typeof toggleLabel === 'function') {
106
+ label = toggleLabel(expanded);
107
+ } else {
108
+ label = toggleLabel;
109
+ }
110
+ const props = {
111
+ ...toggleProps
112
+ };
113
+ return (0, _jsxRuntime.jsx)(_v11_.IconButton, {
114
+ ...props,
115
+ withBackground: false,
116
+ withBorder: false,
117
+ size: size === 'large' ? 'medium' : 'small',
118
+ elementRef: this.handleButtonRef,
119
+ screenReaderLabel: label,
120
+ children: this.renderIcon(expanded)
121
+ });
122
+ }
123
+ renderDetails(detailsProps) {
124
+ const {
125
+ styles
126
+ } = this.props;
127
+ return (0, _jsxRuntime.jsx)(_v11_3.View, {
128
+ ...detailsProps,
129
+ display: "block",
130
+ borderWidth: "small none none none",
131
+ borderColor: styles?.borderColor,
132
+ children: this.props.transition && this._shouldTransition ? (0, _jsxRuntime.jsx)(_Transition.Transition, {
133
+ transitionOnMount: true,
134
+ in: true,
135
+ type: "fade",
136
+ children: this.props.children
137
+ }) : this.props.children
138
+ });
139
+ }
140
+ render() {
141
+ const Element = (0, _getElementType.getElementType)(ToggleGroup, this.props);
142
+ const {
143
+ styles
144
+ } = this.props;
145
+ return (0, _jsxRuntime.jsx)(_uiExpandable.Expandable, {
146
+ ...(0, _pickProps.pickProps)(this.props, _uiExpandable.Expandable.allowedProps),
147
+ children: ({
148
+ expanded,
149
+ getToggleProps,
150
+ getDetailsProps
151
+ }) => {
152
+ return (0, _jsxRuntime.jsxs)(_v11_3.View, {
153
+ ...(0, _omitProps.omitProps)(this.props, ToggleGroup.allowedProps),
154
+ borderWidth: this.props.border ? 'small' : 'none',
155
+ as: Element,
156
+ elementRef: this.handleRef,
157
+ display: "block",
158
+ borderRadius: "medium",
159
+ background: "primary",
160
+ borderColor: styles?.borderColor,
161
+ "data-cid": "ToggleGroup",
162
+ children: [(0, _jsxRuntime.jsxs)(_v11_2.Flex, {
163
+ padding: this.props.size === 'small' ? 'x-small' : 'small small small x-small',
164
+ children: [(0, _jsxRuntime.jsx)(_v11_2.Flex.Item, {
165
+ children: this.renderToggle(getToggleProps(), expanded)
166
+ }), (0, _jsxRuntime.jsx)(_v11_2.Flex.Item, {
167
+ shouldGrow: true,
168
+ shouldShrink: true,
169
+ padding: "0 0 0 x-small",
170
+ children: this.props.summary
171
+ })]
172
+ }), expanded ? this.renderDetails(getDetailsProps()) : (0, _jsxRuntime.jsx)("span", {
173
+ ...getDetailsProps()
174
+ })]
175
+ });
176
+ }
177
+ });
178
+ }
179
+ }) || _class);
180
+ 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;
@@ -0,0 +1,47 @@
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
+ * Generates the theme object for the component from the theme and provided additional information
33
+ * @param {Object} theme The actual theme object.
34
+ * @return {Object} The final theme object with the overrides and component variables
35
+ */
36
+ const generateComponentTheme = theme => {
37
+ const {
38
+ colors
39
+ } = theme;
40
+ const componentVariables = {
41
+ borderColor: colors?.contrasts?.grey3045
42
+ };
43
+ return {
44
+ ...componentVariables
45
+ };
46
+ };
47
+ var _default = exports.default = generateComponentTheme;
@@ -0,0 +1,185 @@
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 _latest2 = require("@instructure/ui-expandable/latest");
15
+ var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js");
16
+ var _latest3 = require("@instructure/ui-flex/latest");
17
+ var _latest4 = require("@instructure/ui-view/latest");
18
+ var _uiIcons = require("@instructure/ui-icons");
19
+ var _props = require("./props.js");
20
+ var _emotion = require("@instructure/emotion");
21
+ var _styles = _interopRequireDefault(require("./styles.js"));
22
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
23
+ var _dec, _class;
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.withStyleNew)(_styles.default), _dec(_class = class ToggleGroup extends _react.Component {
59
+ static displayName = 'ToggleGroup';
60
+ static componentId = 'ToggleGroup';
61
+ static allowedProps = _props.allowedProps;
62
+ static defaultProps = {
63
+ size: 'medium',
64
+ icon: _uiIcons.ChevronRightInstUIIcon,
65
+ iconExpanded: _uiIcons.ChevronDownInstUIIcon,
66
+ defaultExpanded: false,
67
+ transition: true,
68
+ as: 'span',
69
+ border: true
70
+ };
71
+ ref = null;
72
+ _button = null;
73
+ _shouldTransition = false;
74
+ handleRef = el => {
75
+ const {
76
+ elementRef
77
+ } = this.props;
78
+ this.ref = el;
79
+ if (typeof elementRef === 'function') {
80
+ elementRef(el);
81
+ }
82
+ };
83
+ handleButtonRef = el => {
84
+ this._button = el;
85
+ };
86
+ get focused() {
87
+ return (0, _isActiveElement.isActiveElement)(this._button);
88
+ }
89
+ focus() {
90
+ this._button?.focus();
91
+ }
92
+ componentDidMount() {
93
+ this._shouldTransition = true;
94
+ }
95
+ componentDidUpdate() {
96
+ this.props.makeStyles?.(this.state);
97
+ }
98
+ renderIcon(expanded) {
99
+ const Icon = expanded ? this.props.iconExpanded : this.props.icon;
100
+ if (!Icon) return null;
101
+ const iconSize = toggleGroupSizeToIconSize[this.props.size];
102
+ return (0, _uiIcons.renderIconWithProps)(Icon, iconSize, 'baseColor');
103
+ }
104
+ renderToggle(toggleProps, expanded) {
105
+ const {
106
+ toggleLabel,
107
+ size
108
+ } = this.props;
109
+ let label;
110
+ if (typeof toggleLabel === 'function') {
111
+ label = toggleLabel(expanded);
112
+ } else {
113
+ label = toggleLabel;
114
+ }
115
+ const props = {
116
+ ...toggleProps
117
+ };
118
+ return (0, _jsxRuntime.jsx)(_latest.IconButton, {
119
+ ...props,
120
+ withBackground: false,
121
+ withBorder: false,
122
+ size: size === 'large' ? 'medium' : 'small',
123
+ elementRef: this.handleButtonRef,
124
+ screenReaderLabel: label,
125
+ children: this.renderIcon(expanded)
126
+ });
127
+ }
128
+ renderDetails(detailsProps) {
129
+ const {
130
+ styles
131
+ } = this.props;
132
+ return (0, _jsxRuntime.jsx)(_latest4.View, {
133
+ ...detailsProps,
134
+ display: "block",
135
+ borderWidth: "small none none none",
136
+ borderColor: styles?.borderColor,
137
+ children: this.props.transition && this._shouldTransition ? (0, _jsxRuntime.jsx)(_Transition.Transition, {
138
+ transitionOnMount: true,
139
+ in: true,
140
+ type: "fade",
141
+ children: this.props.children
142
+ }) : this.props.children
143
+ });
144
+ }
145
+ render() {
146
+ const Element = (0, _getElementType.getElementType)(ToggleGroup, this.props);
147
+ const {
148
+ styles
149
+ } = this.props;
150
+ return (0, _jsxRuntime.jsx)(_latest2.Expandable, {
151
+ ...(0, _pickProps.pickProps)(this.props, _latest2.Expandable.allowedProps),
152
+ children: ({
153
+ expanded,
154
+ getToggleProps,
155
+ getDetailsProps
156
+ }) => {
157
+ return (0, _jsxRuntime.jsxs)(_latest4.View, {
158
+ ...(0, _omitProps.omitProps)(this.props, ToggleGroup.allowedProps),
159
+ borderWidth: this.props.border ? 'small' : 'none',
160
+ as: Element,
161
+ elementRef: this.handleRef,
162
+ display: "block",
163
+ borderRadius: "medium",
164
+ background: "primary",
165
+ borderColor: styles?.borderColor,
166
+ "data-cid": "ToggleGroup",
167
+ children: [(0, _jsxRuntime.jsxs)(_latest3.Flex, {
168
+ padding: this.props.size === 'small' ? 'x-small' : 'small small small x-small',
169
+ children: [(0, _jsxRuntime.jsx)(_latest3.Flex.Item, {
170
+ children: this.renderToggle(getToggleProps(), expanded)
171
+ }), (0, _jsxRuntime.jsx)(_latest3.Flex.Item, {
172
+ shouldGrow: true,
173
+ shouldShrink: true,
174
+ padding: "0 0 0 x-small",
175
+ children: this.props.summary
176
+ })]
177
+ }), expanded ? this.renderDetails(getDetailsProps()) : (0, _jsxRuntime.jsx)("span", {
178
+ ...getDetailsProps()
179
+ })]
180
+ });
181
+ }
182
+ });
183
+ }
184
+ }) || _class);
185
+ 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;
@@ -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 _index.ToggleDetails;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "ToggleGroup", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _index2.ToggleGroup;
16
+ }
17
+ });
18
+ var _index = require("../ToggleDetails/v1/index.js");
19
+ var _index2 = require("../ToggleGroup/v1/index.js");
@@ -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 _index.ToggleDetails;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "ToggleGroup", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _index2.ToggleGroup;
16
+ }
17
+ });
18
+ var _index = require("../ToggleDetails/v2/index.js");
19
+ var _index2 = require("../ToggleGroup/v2/index.js");
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}