@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,178 @@
1
+ var _dec, _class;
2
+ /*
3
+ * The MIT License (MIT)
4
+ *
5
+ * Copyright (c) 2015 - present Instructure, Inc.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
26
+ import { Component } from 'react';
27
+ import { omitProps, pickProps, getElementType } from '@instructure/ui-react-utils';
28
+ import { IconButton } from '@instructure/ui-buttons/latest';
29
+ import { Transition } from '@instructure/ui-motion';
30
+ import { Expandable } from '@instructure/ui-expandable/latest';
31
+ import { isActiveElement } from '@instructure/ui-dom-utils';
32
+ import { Flex } from '@instructure/ui-flex/latest';
33
+ import { View } from '@instructure/ui-view/latest';
34
+ import { ChevronRightInstUIIcon, ChevronDownInstUIIcon, renderIconWithProps } from '@instructure/ui-icons';
35
+ import { allowedProps } from './props.js';
36
+ import { withStyleNew } from '@instructure/emotion';
37
+ import generateStyle from './styles.js';
38
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
39
+ const toggleGroupSizeToIconSize = {
40
+ small: 'md',
41
+ medium: 'md',
42
+ large: 'lg'
43
+ };
44
+
45
+ /**
46
+ ---
47
+ category: components
48
+ ---
49
+ **/
50
+ let ToggleGroup = (_dec = withStyleNew(generateStyle), _dec(_class = class ToggleGroup extends Component {
51
+ static displayName = 'ToggleGroup';
52
+ static componentId = 'ToggleGroup';
53
+ static allowedProps = allowedProps;
54
+ static defaultProps = {
55
+ size: 'medium',
56
+ icon: ChevronRightInstUIIcon,
57
+ iconExpanded: ChevronDownInstUIIcon,
58
+ defaultExpanded: false,
59
+ transition: true,
60
+ as: 'span',
61
+ border: true
62
+ };
63
+ ref = null;
64
+ _button = null;
65
+ _shouldTransition = false;
66
+ handleRef = el => {
67
+ const {
68
+ elementRef
69
+ } = this.props;
70
+ this.ref = el;
71
+ if (typeof elementRef === 'function') {
72
+ elementRef(el);
73
+ }
74
+ };
75
+ handleButtonRef = el => {
76
+ this._button = el;
77
+ };
78
+ get focused() {
79
+ return isActiveElement(this._button);
80
+ }
81
+ focus() {
82
+ this._button?.focus();
83
+ }
84
+ componentDidMount() {
85
+ this._shouldTransition = true;
86
+ }
87
+ componentDidUpdate() {
88
+ this.props.makeStyles?.(this.state);
89
+ }
90
+ renderIcon(expanded) {
91
+ const Icon = expanded ? this.props.iconExpanded : this.props.icon;
92
+ if (!Icon) return null;
93
+ const iconSize = toggleGroupSizeToIconSize[this.props.size];
94
+ return renderIconWithProps(Icon, iconSize, 'baseColor');
95
+ }
96
+ renderToggle(toggleProps, expanded) {
97
+ const {
98
+ toggleLabel,
99
+ size
100
+ } = this.props;
101
+ let label;
102
+ if (typeof toggleLabel === 'function') {
103
+ label = toggleLabel(expanded);
104
+ } else {
105
+ label = toggleLabel;
106
+ }
107
+ const props = {
108
+ ...toggleProps
109
+ };
110
+ return _jsx(IconButton, {
111
+ ...props,
112
+ withBackground: false,
113
+ withBorder: false,
114
+ size: size === 'large' ? 'medium' : 'small',
115
+ elementRef: this.handleButtonRef,
116
+ screenReaderLabel: label,
117
+ children: this.renderIcon(expanded)
118
+ });
119
+ }
120
+ renderDetails(detailsProps) {
121
+ const {
122
+ styles
123
+ } = this.props;
124
+ return _jsx(View, {
125
+ ...detailsProps,
126
+ display: "block",
127
+ borderWidth: "small none none none",
128
+ borderColor: styles?.borderColor,
129
+ children: this.props.transition && this._shouldTransition ? _jsx(Transition, {
130
+ transitionOnMount: true,
131
+ in: true,
132
+ type: "fade",
133
+ children: this.props.children
134
+ }) : this.props.children
135
+ });
136
+ }
137
+ render() {
138
+ const Element = getElementType(ToggleGroup, this.props);
139
+ const {
140
+ styles
141
+ } = this.props;
142
+ return _jsx(Expandable, {
143
+ ...pickProps(this.props, Expandable.allowedProps),
144
+ children: ({
145
+ expanded,
146
+ getToggleProps,
147
+ getDetailsProps
148
+ }) => {
149
+ return _jsxs(View, {
150
+ ...omitProps(this.props, ToggleGroup.allowedProps),
151
+ borderWidth: this.props.border ? 'small' : 'none',
152
+ as: Element,
153
+ elementRef: this.handleRef,
154
+ display: "block",
155
+ borderRadius: "medium",
156
+ background: "primary",
157
+ borderColor: styles?.borderColor,
158
+ "data-cid": "ToggleGroup",
159
+ children: [_jsxs(Flex, {
160
+ padding: this.props.size === 'small' ? 'x-small' : 'small small small x-small',
161
+ children: [_jsx(Flex.Item, {
162
+ children: this.renderToggle(getToggleProps(), expanded)
163
+ }), _jsx(Flex.Item, {
164
+ shouldGrow: true,
165
+ shouldShrink: true,
166
+ padding: "0 0 0 x-small",
167
+ children: this.props.summary
168
+ })]
169
+ }), expanded ? this.renderDetails(getDetailsProps()) : _jsx("span", {
170
+ ...getDetailsProps()
171
+ })]
172
+ });
173
+ }
174
+ });
175
+ }
176
+ }) || _class);
177
+ export default ToggleGroup;
178
+ export { ToggleGroup };
@@ -0,0 +1,26 @@
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
+
25
+ const allowedProps = ['children', 'summary', 'toggleLabel', 'as', 'elementRef', 'size', 'expanded', 'defaultExpanded', 'onToggle', 'icon', 'iconExpanded', 'transition', 'border'];
26
+ export { allowedProps };
@@ -0,0 +1,40 @@
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
+
25
+ /**
26
+ * ---
27
+ * private: true
28
+ * ---
29
+ * Generates the style object from the theme and provided additional information
30
+ * @param {Object} componentTheme The theme variable object.
31
+ * @param {Object} props the props of the component, the style is applied to
32
+ * @param {Object} state the state of the component, the style is applied to
33
+ * @return {Object} The final style object, which will be used in the component
34
+ */
35
+ const generateStyle = (componentTheme, _props) => {
36
+ return {
37
+ borderColor: componentTheme.borderColor
38
+ };
39
+ };
40
+ export default generateStyle;
@@ -0,0 +1,26 @@
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
+
25
+ export { ToggleDetails } from '../ToggleDetails/v1/index.js';
26
+ export { ToggleGroup } from '../ToggleGroup/v1/index.js';
@@ -0,0 +1,26 @@
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
+
25
+ export { ToggleDetails } from '../ToggleDetails/v2/index.js';
26
+ export { ToggleGroup } from '../ToggleGroup/v2/index.js';
@@ -0,0 +1,184 @@
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.ToggleDetails = void 0;
8
+ var _react = require("react");
9
+ var _v11_ = require("@instructure/ui-buttons/v11_6");
10
+ var _IconArrowOpenEndSolid = require("@instructure/ui-icons/lib/generated/IconArrowOpenEndSolid.js");
11
+ var _IconArrowOpenDownSolid = require("@instructure/ui-icons/lib/generated/IconArrowOpenDownSolid.js");
12
+ var _uiExpandable = require("@instructure/ui-expandable");
13
+ var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
14
+ var _pickProps = require("@instructure/ui-react-utils/lib/pickProps.js");
15
+ var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js");
16
+ var _emotion = require("@instructure/emotion");
17
+ var _styles = _interopRequireDefault(require("./styles.js"));
18
+ var _theme = _interopRequireDefault(require("./theme.js"));
19
+ var _props = require("./props.js");
20
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
21
+ var _dec, _class;
22
+ /*
23
+ * The MIT License (MIT)
24
+ *
25
+ * Copyright (c) 2015 - present Instructure, Inc.
26
+ *
27
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
28
+ * of this software and associated documentation files (the "Software"), to deal
29
+ * in the Software without restriction, including without limitation the rights
30
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
31
+ * copies of the Software, and to permit persons to whom the Software is
32
+ * furnished to do so, subject to the following conditions:
33
+ *
34
+ * The above copyright notice and this permission notice shall be included in all
35
+ * copies or substantial portions of the Software.
36
+ *
37
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
38
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
39
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
40
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
41
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
42
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
43
+ * SOFTWARE.
44
+ */
45
+ /**
46
+ ---
47
+ category: components
48
+ ---
49
+ **/
50
+ let ToggleDetails = exports.ToggleDetails = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = class ToggleDetails extends _react.Component {
51
+ static displayName = 'ToggleDetails';
52
+ static componentId = 'ToggleDetails';
53
+ static allowedProps = _props.allowedProps;
54
+ static defaultProps = {
55
+ variant: 'default',
56
+ size: 'medium',
57
+ fluidWidth: false,
58
+ icon: _IconArrowOpenEndSolid.IconArrowOpenEndSolid,
59
+ iconExpanded: _IconArrowOpenDownSolid.IconArrowOpenDownSolid,
60
+ iconPosition: 'start',
61
+ defaultExpanded: false,
62
+ children: null
63
+ };
64
+ _buttonNode = null;
65
+ ref = /*#__PURE__*/(0, _react.createRef)();
66
+
67
+ // TODO this solution was generated with Gemini, should be tested if it works as fine as before
68
+ setButtonRef = node => {
69
+ this._buttonNode = node;
70
+ };
71
+ get focused() {
72
+ return (0, _isActiveElement.isActiveElement)(this._buttonNode);
73
+ }
74
+ focus() {
75
+ this._buttonNode?.focus();
76
+ }
77
+ componentDidMount() {
78
+ this.props.makeStyles?.();
79
+ }
80
+ componentDidUpdate() {
81
+ this.props.makeStyles?.();
82
+ }
83
+ renderSummary(expanded) {
84
+ const {
85
+ summary,
86
+ iconPosition
87
+ } = this.props;
88
+ return (0, _jsxRuntime.jsxs)("span", {
89
+ css: this.props.styles?.summary,
90
+ children: [iconPosition === 'start' && this.renderIcon(expanded), (0, _jsxRuntime.jsx)("span", {
91
+ css: this.props.styles?.summaryText,
92
+ children: summary
93
+ }), iconPosition === 'end' && this.renderIcon(expanded)]
94
+ });
95
+ }
96
+ renderToggle(toggleProps, expanded) {
97
+ const {
98
+ variant
99
+ } = this.props;
100
+ const tProps = this.props.children ? toggleProps : {
101
+ onClick: toggleProps.onClick
102
+ };
103
+ const props = {
104
+ ...(0, _omitProps.omitProps)(this.props, ToggleDetails.allowedProps),
105
+ ...tProps,
106
+ children: this.renderSummary(expanded)
107
+ };
108
+ const summary = this.renderSummary(expanded);
109
+ if (variant === 'filled') {
110
+ return (0, _jsxRuntime.jsx)(_v11_.Button, {
111
+ ...props,
112
+ display: "block",
113
+ textAlign: "start",
114
+ elementRef: this.setButtonRef,
115
+ children: summary
116
+ });
117
+ } else if (props.href) {
118
+ return (0, _jsxRuntime.jsx)("a", {
119
+ ...props,
120
+ css: this.props.styles?.toggle,
121
+ ref: this.setButtonRef,
122
+ children: summary
123
+ });
124
+ } else {
125
+ return (0, _jsxRuntime.jsx)("button", {
126
+ ...props,
127
+ type: "button",
128
+ css: this.props.styles?.toggle,
129
+ ref: this.setButtonRef,
130
+ children: summary
131
+ });
132
+ }
133
+ }
134
+ renderIcon(expanded) {
135
+ const Icon = expanded ? this.props.iconExpanded : this.props.icon;
136
+ return this.props.children && Icon ? (0, _jsxRuntime.jsx)("span", {
137
+ css: this.props.styles?.icon,
138
+ children: (0, _jsxRuntime.jsx)(Icon, {})
139
+ }) : null;
140
+ }
141
+ renderDetails(expanded, detailsProps) {
142
+ if (!this.props.children) return null;
143
+ const expandedStyles = expanded ? {
144
+ display: 'block'
145
+ } : {
146
+ display: 'none'
147
+ };
148
+ return (0, _jsxRuntime.jsx)("div", {
149
+ ...detailsProps,
150
+ css: [this.props.styles?.details, expandedStyles],
151
+ children: expanded && this.renderContent()
152
+ });
153
+ }
154
+ renderContent() {
155
+ return (0, _jsxRuntime.jsx)("div", {
156
+ css: this.props.styles?.content,
157
+ children: this.props.children
158
+ });
159
+ }
160
+ handleToggle = (event, expanded) => {
161
+ if (typeof this.props.onToggle === 'function') {
162
+ this.props.onToggle(event, expanded);
163
+ }
164
+ };
165
+ render() {
166
+ return (0, _jsxRuntime.jsx)(_uiExpandable.Expandable, {
167
+ ...(0, _pickProps.pickProps)(this.props, _uiExpandable.Expandable.allowedProps),
168
+ onToggle: this.handleToggle,
169
+ children: ({
170
+ expanded,
171
+ getToggleProps,
172
+ getDetailsProps
173
+ }) => {
174
+ return (0, _jsxRuntime.jsxs)("div", {
175
+ css: this.props.styles?.toggleDetails,
176
+ ref: this.ref,
177
+ "data-cid": "ToggleDetails",
178
+ children: [this.renderToggle(getToggleProps(), expanded), this.renderDetails(expanded, getDetailsProps())]
179
+ });
180
+ }
181
+ });
182
+ }
183
+ }) || _class);
184
+ var _default = exports.default = ToggleDetails;
@@ -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 = ['variant', 'summary', 'expanded', 'defaultExpanded', 'onToggle', 'icon', 'iconExpanded', 'iconPosition', 'fluidWidth', 'children', 'size'];