@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,202 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _emotion = require("@instructure/emotion");
8
+ /*
9
+ * The MIT License (MIT)
10
+ *
11
+ * Copyright (c) 2015 - present Instructure, Inc.
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ * of this software and associated documentation files (the "Software"), to deal
15
+ * in the Software without restriction, including without limitation the rights
16
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ * copies of the Software, and to permit persons to whom the Software is
18
+ * furnished to do so, subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included in all
21
+ * copies or substantial portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ * SOFTWARE.
30
+ */
31
+
32
+ const contentAnimation = (0, _emotion.keyframes)`
33
+ to {
34
+ opacity: 1;
35
+ }`;
36
+
37
+ /**
38
+ * ---
39
+ * private: true
40
+ * ---
41
+ * Generates the style object from the theme and provided additional information
42
+ * @param {Object} componentTheme The theme variable object.
43
+ * @param {Object} props the props of the component, the style is applied to
44
+ * @param {Object} state the state of the component, the style is applied to
45
+ * @return {Object} The final style object, which will be used in the component
46
+ */
47
+ const generateStyle = (componentTheme, props, _state) => {
48
+ const {
49
+ fluidWidth,
50
+ iconPosition,
51
+ size,
52
+ variant
53
+ } = props;
54
+ const positionIconAtEnd = iconPosition === 'end' && (variant === 'filled' || fluidWidth);
55
+ const fluidWidthStyles = fluidWidth ? {
56
+ display: 'block',
57
+ width: '100%'
58
+ } : {};
59
+ const iconPositionStyles = {
60
+ start: {
61
+ marginInlineEnd: componentTheme.iconMargin,
62
+ marginInlineStart: 0
63
+ },
64
+ end: {
65
+ marginInlineStart: componentTheme.iconMargin,
66
+ marginInlineEnd: 0
67
+ }
68
+ };
69
+ const fontSizeStyles = {
70
+ small: {
71
+ fontSize: componentTheme.fontSizeSmall
72
+ },
73
+ medium: {
74
+ fontSize: componentTheme.fontSizeMedium
75
+ },
76
+ large: {
77
+ fontSize: componentTheme.fontSizeLarge
78
+ }
79
+ };
80
+ const iconSizeStyles = {
81
+ small: {
82
+ fontSize: componentTheme.smallIconSize
83
+ },
84
+ medium: {
85
+ fontSize: componentTheme.mediumIconSize
86
+ },
87
+ large: {
88
+ fontSize: componentTheme.largeIconSize
89
+ }
90
+ };
91
+ const indentDetailsStyles = iconPosition === 'start' && !fluidWidth ? {
92
+ small: {
93
+ paddingInlineStart: `calc(${componentTheme.smallIconSize} + ${componentTheme.togglePadding})`,
94
+ paddingInlineEnd: '0'
95
+ },
96
+ medium: {
97
+ paddingInlineStart: `calc(${componentTheme.mediumIconSize} + ${componentTheme.togglePadding})`,
98
+ paddingInlineEnd: '0'
99
+ },
100
+ large: {
101
+ paddingInlineStart: `calc(${componentTheme.largeIconSize} + ${componentTheme.togglePadding})`,
102
+ paddingInlineEnd: '0'
103
+ }
104
+ } : {
105
+ small: {},
106
+ medium: {},
107
+ large: {}
108
+ };
109
+ return {
110
+ toggleDetails: {
111
+ label: 'toggleDetails',
112
+ fontFamily: componentTheme.fontFamily,
113
+ fontWeight: componentTheme.fontWeight,
114
+ lineHeight: componentTheme.lineHeight
115
+ },
116
+ summary: {
117
+ label: 'toggleDetails__summary',
118
+ position: 'relative',
119
+ display: 'flex',
120
+ alignItems: 'center',
121
+ boxSizing: 'border-box',
122
+ textAlign: 'start'
123
+ },
124
+ summaryText: {
125
+ label: 'toggleDetails__summaryText',
126
+ minWidth: '0.0625rem',
127
+ flexGrow: 1,
128
+ ...(positionIconAtEnd ? {
129
+ flex: 1
130
+ } : {})
131
+ },
132
+ toggle: {
133
+ label: 'toggleDetails__toggle',
134
+ fontFamily: componentTheme.fontFamily,
135
+ appearance: 'none',
136
+ cursor: 'pointer',
137
+ userSelect: 'none',
138
+ touchAction: 'manipulation',
139
+ position: 'relative',
140
+ overflow: 'visible',
141
+ boxSizing: 'border-box',
142
+ padding: '0',
143
+ margin: '0',
144
+ outline: 'none',
145
+ border: 'none',
146
+ background: 'transparent',
147
+ color: componentTheme.textColor,
148
+ '&::-moz-focus-inner': {
149
+ padding: '0',
150
+ margin: '0'
151
+ },
152
+ '&::before': {
153
+ content: '""',
154
+ position: 'absolute',
155
+ top: '-0.375rem',
156
+ left: '-0.375rem',
157
+ right: '-0.375rem',
158
+ bottom: '-0.375rem',
159
+ border: `${componentTheme.toggleBorderWidth} ${componentTheme.toggleBorderStyle} ${componentTheme.toggleFocusBorderColor}`,
160
+ borderRadius: `calc(${componentTheme.toggleBorderRadius} * 1.5)`,
161
+ opacity: 0,
162
+ pointerEvents: 'none'
163
+ },
164
+ '&:focus': {
165
+ '&::before': {
166
+ opacity: 1
167
+ }
168
+ },
169
+ '&:focus, &:hover, &:active': {
170
+ textDecoration: 'none',
171
+ color: componentTheme.textColor
172
+ },
173
+ textDecoration: 'none',
174
+ ...fluidWidthStyles,
175
+ ...fontSizeStyles[size]
176
+ },
177
+ icon: {
178
+ label: 'toggleDetails__icon',
179
+ '& > svg': {
180
+ display: 'block' /* fix vertical alignment of icon */
181
+ },
182
+ ...iconPositionStyles[iconPosition],
183
+ ...iconSizeStyles[size]
184
+ },
185
+ details: {
186
+ label: 'toggleDetails__details',
187
+ boxSizing: 'border-box',
188
+ paddingTop: componentTheme.togglePadding,
189
+ color: componentTheme.textColor,
190
+ ...fontSizeStyles[size],
191
+ ...indentDetailsStyles[size]
192
+ },
193
+ content: {
194
+ label: 'toggleDetails__content',
195
+ opacity: 0.01,
196
+ animationName: contentAnimation,
197
+ animationFillMode: 'forwards',
198
+ animationDuration: '.3s'
199
+ }
200
+ };
201
+ };
202
+ var _default = exports.default = generateStyle;
@@ -0,0 +1,81 @@
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
+ spacing,
40
+ borders,
41
+ typography,
42
+ key: themeName
43
+ } = theme;
44
+ const themeSpecificStyle = {
45
+ canvas: {
46
+ toggleFocusBorderColor: theme['ic-brand-primary'],
47
+ iconColor: theme['ic-brand-font-color-dark'],
48
+ textColor: theme['ic-brand-font-color-dark']
49
+ }
50
+ };
51
+ const componentVariables = {
52
+ fontFamily: typography?.fontFamily,
53
+ fontWeight: typography?.fontWeightNormal,
54
+ lineHeight: typography?.lineHeight,
55
+ textColor: colors?.contrasts?.grey125125,
56
+ fontSizeSmall: typography?.fontSizeSmall,
57
+ fontSizeMedium: typography?.fontSizeMedium,
58
+ fontSizeLarge: typography?.fontSizeLarge,
59
+ smallIconSize: '0.5rem',
60
+ mediumIconSize: '0.75rem',
61
+ largeIconSize: '1rem',
62
+ iconMargin: spacing?.xxSmall,
63
+ iconColor: colors?.contrasts?.grey125125,
64
+ togglePadding: spacing?.xxSmall,
65
+ toggleBorderRadius: borders?.radiusMedium,
66
+ toggleBorderWidth: borders?.widthMedium,
67
+ toggleBorderStyle: borders?.style,
68
+ toggleFocusBorderColor: colors?.contrasts?.blue4570,
69
+ filledBackgroundColor: colors?.contrasts?.grey1111,
70
+ filledBorderWidth: borders?.widthSmall,
71
+ filledBorderStyle: borders?.style,
72
+ filledBorderColor: colors?.contrasts?.grey1424,
73
+ filledBorderRadius: borders?.radiusMedium,
74
+ filledPadding: spacing?.small
75
+ };
76
+ return {
77
+ ...componentVariables,
78
+ ...themeSpecificStyle[themeName]
79
+ };
80
+ };
81
+ var _default = exports.default = generateComponentTheme;
@@ -0,0 +1,187 @@
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 _latest = require("@instructure/ui-buttons/latest");
10
+ var _uiIcons = require("@instructure/ui-icons");
11
+ var _latest2 = require("@instructure/ui-expandable/latest");
12
+ var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
13
+ var _pickProps = require("@instructure/ui-react-utils/lib/pickProps.js");
14
+ var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js");
15
+ var _emotion = require("@instructure/emotion");
16
+ var _styles = _interopRequireDefault(require("./styles.js"));
17
+ var _props = require("./props.js");
18
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
19
+ var _dec, _class;
20
+ /*
21
+ * The MIT License (MIT)
22
+ *
23
+ * Copyright (c) 2015 - present Instructure, Inc.
24
+ *
25
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
26
+ * of this software and associated documentation files (the "Software"), to deal
27
+ * in the Software without restriction, including without limitation the rights
28
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
29
+ * copies of the Software, and to permit persons to whom the Software is
30
+ * furnished to do so, subject to the following conditions:
31
+ *
32
+ * The above copyright notice and this permission notice shall be included in all
33
+ * copies or substantial portions of the Software.
34
+ *
35
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
38
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
40
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
41
+ * SOFTWARE.
42
+ */
43
+ /**
44
+ ---
45
+ category: components
46
+ ---
47
+ **/
48
+ let ToggleDetails = exports.ToggleDetails = (_dec = (0, _emotion.withStyleNew)(_styles.default), _dec(_class = class ToggleDetails extends _react.Component {
49
+ static displayName = 'ToggleDetails';
50
+ static componentId = 'ToggleDetails';
51
+ static allowedProps = _props.allowedProps;
52
+ static defaultProps = {
53
+ variant: 'default',
54
+ size: 'medium',
55
+ fluidWidth: false,
56
+ icon: _uiIcons.ChevronRightInstUIIcon,
57
+ iconExpanded: _uiIcons.ChevronDownInstUIIcon,
58
+ iconPosition: 'start',
59
+ defaultExpanded: false,
60
+ children: null
61
+ };
62
+ _buttonNode = null;
63
+ ref = /*#__PURE__*/(0, _react.createRef)();
64
+
65
+ // TODO this solution was generated with Gemini, should be tested if it works as fine as before
66
+ setButtonRef = node => {
67
+ this._buttonNode = node;
68
+ };
69
+ get focused() {
70
+ return (0, _isActiveElement.isActiveElement)(this._buttonNode);
71
+ }
72
+ focus() {
73
+ this._buttonNode?.focus();
74
+ }
75
+ componentDidMount() {
76
+ this.props.makeStyles?.();
77
+ }
78
+ componentDidUpdate() {
79
+ this.props.makeStyles?.();
80
+ }
81
+ renderSummary(expanded) {
82
+ const {
83
+ summary,
84
+ iconPosition
85
+ } = this.props;
86
+ return (0, _jsxRuntime.jsxs)("span", {
87
+ css: this.props.styles?.summary,
88
+ children: [iconPosition === 'start' && this.renderIcon(expanded), (0, _jsxRuntime.jsx)("span", {
89
+ css: this.props.styles?.summaryText,
90
+ children: summary
91
+ }), iconPosition === 'end' && this.renderIcon(expanded)]
92
+ });
93
+ }
94
+ renderToggle(toggleProps, expanded) {
95
+ const {
96
+ variant
97
+ } = this.props;
98
+ const tProps = this.props.children ? toggleProps : {
99
+ onClick: toggleProps.onClick
100
+ };
101
+ const props = {
102
+ ...(0, _omitProps.omitProps)(this.props, ToggleDetails.allowedProps),
103
+ ...tProps,
104
+ children: this.renderSummary(expanded)
105
+ };
106
+ const summary = this.renderSummary(expanded);
107
+ if (variant === 'filled') {
108
+ return (0, _jsxRuntime.jsx)(_latest.Button, {
109
+ ...props,
110
+ display: "block",
111
+ textAlign: "start",
112
+ elementRef: this.setButtonRef,
113
+ children: summary
114
+ });
115
+ } else if (props.href) {
116
+ return (0, _jsxRuntime.jsx)("a", {
117
+ ...props,
118
+ css: this.props.styles?.toggle,
119
+ ref: this.setButtonRef,
120
+ children: summary
121
+ });
122
+ } else {
123
+ return (0, _jsxRuntime.jsx)("button", {
124
+ ...props,
125
+ type: "button",
126
+ css: this.props.styles?.toggle,
127
+ ref: this.setButtonRef,
128
+ children: summary
129
+ });
130
+ }
131
+ }
132
+ renderIcon(expanded) {
133
+ const Icon = expanded ? this.props.iconExpanded : this.props.icon;
134
+ const iconSize = this.props.size === 'large' ? 'lg' : 'md';
135
+ const iconColor = this.props.variant === 'filled' ? 'actionSecondaryBaseColor' : 'baseColor';
136
+ return this.props.children && Icon ? (0, _jsxRuntime.jsx)("span", {
137
+ css: this.props.styles?.icon,
138
+ children: (0, _jsxRuntime.jsx)(Icon, {
139
+ size: iconSize,
140
+ color: iconColor
141
+ })
142
+ }) : null;
143
+ }
144
+ renderDetails(expanded, detailsProps) {
145
+ if (!this.props.children) return null;
146
+ const expandedStyles = expanded ? {
147
+ display: 'block'
148
+ } : {
149
+ display: 'none'
150
+ };
151
+ return (0, _jsxRuntime.jsx)("div", {
152
+ ...detailsProps,
153
+ css: [this.props.styles?.details, expandedStyles],
154
+ children: expanded && this.renderContent()
155
+ });
156
+ }
157
+ renderContent() {
158
+ return (0, _jsxRuntime.jsx)("div", {
159
+ css: this.props.styles?.content,
160
+ children: this.props.children
161
+ });
162
+ }
163
+ handleToggle = (event, expanded) => {
164
+ if (typeof this.props.onToggle === 'function') {
165
+ this.props.onToggle(event, expanded);
166
+ }
167
+ };
168
+ render() {
169
+ return (0, _jsxRuntime.jsx)(_latest2.Expandable, {
170
+ ...(0, _pickProps.pickProps)(this.props, _latest2.Expandable.allowedProps),
171
+ onToggle: this.handleToggle,
172
+ children: ({
173
+ expanded,
174
+ getToggleProps,
175
+ getDetailsProps
176
+ }) => {
177
+ return (0, _jsxRuntime.jsxs)("div", {
178
+ css: this.props.styles?.toggleDetails,
179
+ ref: this.ref,
180
+ "data-cid": "ToggleDetails",
181
+ children: [this.renderToggle(getToggleProps(), expanded), this.renderDetails(expanded, getDetailsProps())]
182
+ });
183
+ }
184
+ });
185
+ }
186
+ }) || _class);
187
+ 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'];
@@ -0,0 +1,194 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _emotion = require("@instructure/emotion");
8
+ /*
9
+ * The MIT License (MIT)
10
+ *
11
+ * Copyright (c) 2015 - present Instructure, Inc.
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ * of this software and associated documentation files (the "Software"), to deal
15
+ * in the Software without restriction, including without limitation the rights
16
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ * copies of the Software, and to permit persons to whom the Software is
18
+ * furnished to do so, subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included in all
21
+ * copies or substantial portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ * SOFTWARE.
30
+ */
31
+
32
+ const contentAnimation = (0, _emotion.keyframes)`
33
+ to {
34
+ opacity: 1;
35
+ }`;
36
+
37
+ /**
38
+ * ---
39
+ * private: true
40
+ * ---
41
+ * Generates the style object from the theme and provided additional information
42
+ * @param {Object} componentTheme The theme variable object.
43
+ * @param {Object} props the props of the component, the style is applied to
44
+ * @param {Object} sharedTokens the shared tokens of the component
45
+ * @param {Object} state the state of the component, the style is applied to
46
+ * @return {Object} The final style object, which will be used in the component
47
+ */
48
+ const generateStyle = (componentTheme, props, sharedTokens, _state) => {
49
+ const {
50
+ fluidWidth,
51
+ iconPosition,
52
+ size,
53
+ variant
54
+ } = props;
55
+ const positionIconAtEnd = iconPosition === 'end' && (variant === 'filled' || fluidWidth);
56
+ const fluidWidthStyles = fluidWidth ? {
57
+ display: 'block',
58
+ width: '100%'
59
+ } : {};
60
+ const iconPositionStyles = {
61
+ start: {
62
+ marginInlineEnd: componentTheme.iconMargin,
63
+ marginInlineStart: 0
64
+ },
65
+ end: {
66
+ marginInlineStart: componentTheme.iconMargin,
67
+ marginInlineEnd: 0
68
+ }
69
+ };
70
+ const fontSizeStyles = {
71
+ small: {
72
+ fontSize: componentTheme.fontSizeSmall
73
+ },
74
+ medium: {
75
+ fontSize: componentTheme.fontSizeMedium
76
+ },
77
+ large: {
78
+ fontSize: componentTheme.fontSizeLarge
79
+ }
80
+ };
81
+ const indentDetailsStyles = iconPosition === 'start' && !fluidWidth ? {
82
+ small: {
83
+ paddingInlineStart: `calc(${componentTheme.contentPaddingSmall} + ${componentTheme.togglePadding})`,
84
+ paddingInlineEnd: '0'
85
+ },
86
+ medium: {
87
+ paddingInlineStart: `calc(${componentTheme.contentPaddingMedium} + ${componentTheme.togglePadding})`,
88
+ paddingInlineEnd: '0'
89
+ },
90
+ large: {
91
+ paddingInlineStart: `calc(${componentTheme.contentPaddingLarge} + ${componentTheme.togglePadding})`,
92
+ paddingInlineEnd: '0'
93
+ }
94
+ } : {
95
+ small: {},
96
+ medium: {},
97
+ large: {}
98
+ };
99
+ return {
100
+ toggleDetails: {
101
+ label: 'toggleDetails',
102
+ fontFamily: componentTheme.fontFamily,
103
+ fontWeight: componentTheme.fontWeight
104
+ },
105
+ summary: {
106
+ label: 'toggleDetails__summary',
107
+ position: 'relative',
108
+ display: 'flex',
109
+ alignItems: 'center',
110
+ boxSizing: 'border-box',
111
+ textAlign: 'start'
112
+ },
113
+ summaryText: {
114
+ label: 'toggleDetails__summaryText',
115
+ minWidth: '0.0625rem',
116
+ flexGrow: 1,
117
+ ...(positionIconAtEnd ? {
118
+ flex: 1
119
+ } : {})
120
+ },
121
+ toggle: {
122
+ label: 'toggleDetails__toggle',
123
+ fontFamily: componentTheme.fontFamily,
124
+ lineHeight: componentTheme.lineHeight,
125
+ appearance: 'none',
126
+ cursor: 'pointer',
127
+ userSelect: 'none',
128
+ touchAction: 'manipulation',
129
+ position: 'relative',
130
+ overflow: 'visible',
131
+ boxSizing: 'border-box',
132
+ padding: '0',
133
+ margin: '0',
134
+ outline: 'none',
135
+ border: 'none',
136
+ background: 'transparent',
137
+ color: componentTheme.textColor,
138
+ '&::-moz-focus-inner': {
139
+ padding: '0',
140
+ margin: '0'
141
+ },
142
+ '&::before': {
143
+ content: '""',
144
+ position: 'absolute',
145
+ top: '-0.375rem',
146
+ left: '-0.375rem',
147
+ right: '-0.375rem',
148
+ bottom: '-0.375rem',
149
+ border: `${componentTheme.toggleBorderWidth} ${componentTheme.toggleBorderStyle} ${sharedTokens.focusOutline.infoColor}`,
150
+ borderRadius: `calc(${componentTheme.toggleBorderRadius} * 1.5)`,
151
+ opacity: 0,
152
+ pointerEvents: 'none'
153
+ },
154
+ '&:focus': {
155
+ '&::before': {
156
+ opacity: 1
157
+ }
158
+ },
159
+ '&:focus, &:hover, &:active': {
160
+ textDecoration: 'none',
161
+ color: componentTheme.textColor
162
+ },
163
+ textDecoration: 'none',
164
+ ...fluidWidthStyles,
165
+ ...fontSizeStyles[size]
166
+ },
167
+ icon: {
168
+ label: 'toggleDetails__icon',
169
+ display: 'flex',
170
+ alignItems: 'center',
171
+ '& > svg': {
172
+ display: 'block' /* fix vertical alignment of icon */
173
+ },
174
+ ...iconPositionStyles[iconPosition]
175
+ },
176
+ details: {
177
+ label: 'toggleDetails__details',
178
+ boxSizing: 'border-box',
179
+ paddingTop: componentTheme.togglePadding,
180
+ color: componentTheme.textColor,
181
+ lineHeight: componentTheme.lineHeight,
182
+ ...fontSizeStyles[size],
183
+ ...indentDetailsStyles[size]
184
+ },
185
+ content: {
186
+ label: 'toggleDetails__content',
187
+ opacity: 0.01,
188
+ animationName: contentAnimation,
189
+ animationFillMode: 'forwards',
190
+ animationDuration: '.3s'
191
+ }
192
+ };
193
+ };
194
+ var _default = exports.default = generateStyle;