@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.
Files changed (97) hide show
  1. package/CHANGELOG.md +35 -289
  2. package/es/ToggleDetails/{index.js → v1/index.js} +2 -2
  3. package/es/ToggleDetails/v2/index.js +186 -0
  4. package/{src/index.ts → es/ToggleDetails/v2/props.js} +2 -5
  5. package/es/ToggleDetails/v2/styles.js +186 -0
  6. package/es/ToggleGroup/{index.js → v1/index.js} +4 -4
  7. package/es/ToggleGroup/v2/index.js +172 -0
  8. package/es/ToggleGroup/v2/props.js +26 -0
  9. package/es/ToggleGroup/v2/styles.js +40 -0
  10. package/es/{index.js → exports/a.js} +2 -2
  11. package/es/exports/b.js +25 -0
  12. package/lib/ToggleDetails/{index.js → v1/index.js} +5 -5
  13. package/lib/ToggleDetails/v2/index.js +192 -0
  14. package/lib/ToggleDetails/v2/props.js +31 -0
  15. package/lib/ToggleDetails/v2/styles.js +192 -0
  16. package/lib/ToggleGroup/{index.js → v1/index.js} +12 -12
  17. package/lib/ToggleGroup/v2/index.js +179 -0
  18. package/lib/ToggleGroup/v2/props.js +31 -0
  19. package/lib/ToggleGroup/v2/styles.js +46 -0
  20. package/lib/{index.js → exports/a.js} +4 -4
  21. package/lib/exports/b.js +19 -0
  22. package/package.json +45 -23
  23. package/src/ToggleDetails/{index.tsx → v1/index.tsx} +3 -3
  24. package/src/ToggleDetails/{props.ts → v1/props.ts} +1 -1
  25. package/src/ToggleDetails/v2/README.md +233 -0
  26. package/src/ToggleDetails/v2/index.tsx +205 -0
  27. package/src/ToggleDetails/v2/props.ts +114 -0
  28. package/src/ToggleDetails/v2/styles.ts +188 -0
  29. package/src/ToggleGroup/{index.tsx → v1/index.tsx} +4 -4
  30. package/src/ToggleGroup/v2/README.md +93 -0
  31. package/src/ToggleGroup/v2/index.tsx +213 -0
  32. package/src/ToggleGroup/v2/props.ts +115 -0
  33. package/src/ToggleGroup/v2/styles.ts +47 -0
  34. package/src/exports/a.ts +29 -0
  35. package/src/exports/b.ts +29 -0
  36. package/tsconfig.build.tsbuildinfo +1 -1
  37. package/types/ToggleDetails/{index.d.ts → v1/index.d.ts} +1 -1
  38. package/types/ToggleDetails/v1/index.d.ts.map +1 -0
  39. package/types/ToggleDetails/{props.d.ts → v1/props.d.ts} +1 -1
  40. package/types/ToggleDetails/v1/props.d.ts.map +1 -0
  41. package/types/ToggleDetails/v1/styles.d.ts.map +1 -0
  42. package/types/ToggleDetails/v1/theme.d.ts.map +1 -0
  43. package/types/ToggleDetails/v2/index.d.ts +54 -0
  44. package/types/ToggleDetails/v2/index.d.ts.map +1 -0
  45. package/types/ToggleDetails/v2/props.d.ts +55 -0
  46. package/types/ToggleDetails/v2/props.d.ts.map +1 -0
  47. package/types/ToggleDetails/v2/styles.d.ts +16 -0
  48. package/types/ToggleDetails/v2/styles.d.ts.map +1 -0
  49. package/types/ToggleGroup/v1/index.d.ts.map +1 -0
  50. package/types/ToggleGroup/v1/props.d.ts.map +1 -0
  51. package/types/ToggleGroup/v1/styles.d.ts.map +1 -0
  52. package/types/ToggleGroup/v1/theme.d.ts.map +1 -0
  53. package/types/ToggleGroup/v2/index.d.ts +53 -0
  54. package/types/ToggleGroup/v2/index.d.ts.map +1 -0
  55. package/types/ToggleGroup/v2/props.d.ts +65 -0
  56. package/types/ToggleGroup/v2/props.d.ts.map +1 -0
  57. package/types/ToggleGroup/v2/styles.d.ts +15 -0
  58. package/types/ToggleGroup/v2/styles.d.ts.map +1 -0
  59. package/types/exports/a.d.ts +5 -0
  60. package/types/exports/a.d.ts.map +1 -0
  61. package/types/exports/b.d.ts +5 -0
  62. package/types/exports/b.d.ts.map +1 -0
  63. package/types/ToggleDetails/index.d.ts.map +0 -1
  64. package/types/ToggleDetails/props.d.ts.map +0 -1
  65. package/types/ToggleDetails/styles.d.ts.map +0 -1
  66. package/types/ToggleDetails/theme.d.ts.map +0 -1
  67. package/types/ToggleGroup/index.d.ts.map +0 -1
  68. package/types/ToggleGroup/props.d.ts.map +0 -1
  69. package/types/ToggleGroup/styles.d.ts.map +0 -1
  70. package/types/ToggleGroup/theme.d.ts.map +0 -1
  71. package/types/index.d.ts +0 -5
  72. package/types/index.d.ts.map +0 -1
  73. /package/es/ToggleDetails/{props.js → v1/props.js} +0 -0
  74. /package/es/ToggleDetails/{styles.js → v1/styles.js} +0 -0
  75. /package/es/ToggleDetails/{theme.js → v1/theme.js} +0 -0
  76. /package/es/ToggleGroup/{props.js → v1/props.js} +0 -0
  77. /package/es/ToggleGroup/{styles.js → v1/styles.js} +0 -0
  78. /package/es/ToggleGroup/{theme.js → v1/theme.js} +0 -0
  79. /package/lib/ToggleDetails/{props.js → v1/props.js} +0 -0
  80. /package/lib/ToggleDetails/{styles.js → v1/styles.js} +0 -0
  81. /package/lib/ToggleDetails/{theme.js → v1/theme.js} +0 -0
  82. /package/lib/ToggleGroup/{props.js → v1/props.js} +0 -0
  83. /package/lib/ToggleGroup/{styles.js → v1/styles.js} +0 -0
  84. /package/lib/ToggleGroup/{theme.js → v1/theme.js} +0 -0
  85. /package/src/ToggleDetails/{README.md → v1/README.md} +0 -0
  86. /package/src/ToggleDetails/{styles.ts → v1/styles.ts} +0 -0
  87. /package/src/ToggleDetails/{theme.ts → v1/theme.ts} +0 -0
  88. /package/src/ToggleGroup/{README.md → v1/README.md} +0 -0
  89. /package/src/ToggleGroup/{props.ts → v1/props.ts} +0 -0
  90. /package/src/ToggleGroup/{styles.ts → v1/styles.ts} +0 -0
  91. /package/src/ToggleGroup/{theme.ts → v1/theme.ts} +0 -0
  92. /package/types/ToggleDetails/{styles.d.ts → v1/styles.d.ts} +0 -0
  93. /package/types/ToggleDetails/{theme.d.ts → v1/theme.d.ts} +0 -0
  94. /package/types/ToggleGroup/{index.d.ts → v1/index.d.ts} +0 -0
  95. /package/types/ToggleGroup/{props.d.ts → v1/props.d.ts} +0 -0
  96. /package/types/ToggleGroup/{styles.d.ts → v1/styles.d.ts} +0 -0
  97. /package/types/ToggleGroup/{theme.d.ts → v1/theme.d.ts} +0 -0
@@ -0,0 +1,186 @@
1
+ var _dec, _class, _ToggleDetails;
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, createRef } from 'react';
27
+ import { Button } from '@instructure/ui-buttons/latest';
28
+ import { ChevronRightInstUIIcon, ChevronDownInstUIIcon } from '@instructure/ui-icons';
29
+ import { Expandable } from '@instructure/ui-expandable';
30
+ import { omitProps, pickProps } from '@instructure/ui-react-utils';
31
+ import { isActiveElement } from '@instructure/ui-dom-utils';
32
+ import { withStyle } from '@instructure/emotion';
33
+ import generateStyle from "./styles.js";
34
+ import { allowedProps } from "./props.js";
35
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
36
+ /**
37
+ ---
38
+ category: components
39
+ ---
40
+ **/
41
+ let ToggleDetails = (_dec = withStyle(generateStyle), _dec(_class = (_ToggleDetails = class ToggleDetails extends Component {
42
+ constructor(...args) {
43
+ super(...args);
44
+ this._buttonNode = null;
45
+ this.ref = /*#__PURE__*/createRef();
46
+ // TODO this solution was generated with Gemini, should be tested if it works as fine as before
47
+ this.setButtonRef = node => {
48
+ this._buttonNode = node;
49
+ };
50
+ this.handleToggle = (event, expanded) => {
51
+ if (typeof this.props.onToggle === 'function') {
52
+ this.props.onToggle(event, expanded);
53
+ }
54
+ };
55
+ }
56
+ get focused() {
57
+ return isActiveElement(this._buttonNode);
58
+ }
59
+ focus() {
60
+ var _this$_buttonNode;
61
+ (_this$_buttonNode = this._buttonNode) === null || _this$_buttonNode === void 0 ? void 0 : _this$_buttonNode.focus();
62
+ }
63
+ componentDidMount() {
64
+ var _this$props$makeStyle, _this$props;
65
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
66
+ }
67
+ componentDidUpdate() {
68
+ var _this$props$makeStyle2, _this$props2;
69
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
70
+ }
71
+ renderSummary(expanded) {
72
+ var _this$props$styles, _this$props$styles2;
73
+ const _this$props3 = this.props,
74
+ summary = _this$props3.summary,
75
+ iconPosition = _this$props3.iconPosition;
76
+ return _jsxs("span", {
77
+ css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.summary,
78
+ children: [iconPosition === 'start' && this.renderIcon(expanded), _jsx("span", {
79
+ css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.summaryText,
80
+ children: summary
81
+ }), iconPosition === 'end' && this.renderIcon(expanded)]
82
+ });
83
+ }
84
+ renderToggle(toggleProps, expanded) {
85
+ const variant = this.props.variant;
86
+ const tProps = this.props.children ? toggleProps : {
87
+ onClick: toggleProps.onClick
88
+ };
89
+ const props = {
90
+ ...omitProps(this.props, ToggleDetails.allowedProps),
91
+ ...tProps,
92
+ children: this.renderSummary(expanded)
93
+ };
94
+ const summary = this.renderSummary(expanded);
95
+ if (variant === 'filled') {
96
+ return _jsx(Button, {
97
+ ...props,
98
+ display: "block",
99
+ textAlign: "start",
100
+ elementRef: this.setButtonRef,
101
+ children: summary
102
+ });
103
+ } else if (props.href) {
104
+ var _this$props$styles3;
105
+ return _jsx("a", {
106
+ ...props,
107
+ css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.toggle,
108
+ ref: this.setButtonRef,
109
+ children: summary
110
+ });
111
+ } else {
112
+ var _this$props$styles4;
113
+ return _jsx("button", {
114
+ ...props,
115
+ type: "button",
116
+ css: (_this$props$styles4 = this.props.styles) === null || _this$props$styles4 === void 0 ? void 0 : _this$props$styles4.toggle,
117
+ ref: this.setButtonRef,
118
+ children: summary
119
+ });
120
+ }
121
+ }
122
+ renderIcon(expanded) {
123
+ var _this$props$styles5;
124
+ const Icon = expanded ? this.props.iconExpanded : this.props.icon;
125
+ const iconSize = this.props.size === 'large' ? 'lg' : 'md';
126
+ const iconColor = this.props.variant === 'filled' ? 'actionSecondaryBaseColor' : 'baseColor';
127
+ return this.props.children && Icon ? _jsx("span", {
128
+ css: (_this$props$styles5 = this.props.styles) === null || _this$props$styles5 === void 0 ? void 0 : _this$props$styles5.icon,
129
+ children: _jsx(Icon, {
130
+ size: iconSize,
131
+ color: iconColor
132
+ })
133
+ }) : null;
134
+ }
135
+ renderDetails(expanded, detailsProps) {
136
+ var _this$props$styles6;
137
+ if (!this.props.children) return null;
138
+ const expandedStyles = expanded ? {
139
+ display: 'block'
140
+ } : {
141
+ display: 'none'
142
+ };
143
+ return _jsx("div", {
144
+ ...detailsProps,
145
+ css: [(_this$props$styles6 = this.props.styles) === null || _this$props$styles6 === void 0 ? void 0 : _this$props$styles6.details, expandedStyles],
146
+ children: expanded && this.renderContent()
147
+ });
148
+ }
149
+ renderContent() {
150
+ var _this$props$styles7;
151
+ return _jsx("div", {
152
+ css: (_this$props$styles7 = this.props.styles) === null || _this$props$styles7 === void 0 ? void 0 : _this$props$styles7.content,
153
+ children: this.props.children
154
+ });
155
+ }
156
+ render() {
157
+ return _jsx(Expandable, {
158
+ ...pickProps(this.props, Expandable.allowedProps),
159
+ onToggle: this.handleToggle,
160
+ children: ({
161
+ expanded,
162
+ getToggleProps,
163
+ getDetailsProps
164
+ }) => {
165
+ var _this$props$styles8;
166
+ return _jsxs("div", {
167
+ css: (_this$props$styles8 = this.props.styles) === null || _this$props$styles8 === void 0 ? void 0 : _this$props$styles8.toggleDetails,
168
+ ref: this.ref,
169
+ "data-cid": "ToggleDetails",
170
+ children: [this.renderToggle(getToggleProps(), expanded), this.renderDetails(expanded, getDetailsProps())]
171
+ });
172
+ }
173
+ });
174
+ }
175
+ }, _ToggleDetails.displayName = "ToggleDetails", _ToggleDetails.componentId = 'ToggleDetails', _ToggleDetails.allowedProps = allowedProps, _ToggleDetails.defaultProps = {
176
+ variant: 'default',
177
+ size: 'medium',
178
+ fluidWidth: false,
179
+ icon: ChevronRightInstUIIcon,
180
+ iconExpanded: ChevronDownInstUIIcon,
181
+ iconPosition: 'start',
182
+ defaultExpanded: false,
183
+ children: null
184
+ }, _ToggleDetails)) || _class);
185
+ export default ToggleDetails;
186
+ export { ToggleDetails };
@@ -22,8 +22,5 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
- export { ToggleDetails } from './ToggleDetails'
26
- export { ToggleGroup } from './ToggleGroup'
27
-
28
- export type { ToggleDetailsProps } from './ToggleDetails/props'
29
- export type { ToggleGroupProps } from './ToggleGroup/props'
25
+ const allowedProps = ['variant', 'summary', 'expanded', 'defaultExpanded', 'onToggle', 'icon', 'iconExpanded', 'iconPosition', 'fluidWidth', 'children', 'size'];
26
+ export { allowedProps };
@@ -0,0 +1,186 @@
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
+ import { keyframes } from '@instructure/emotion';
26
+ const contentAnimation = keyframes`
27
+ to {
28
+ opacity: 1;
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} sharedTokens the shared tokens of the component
39
+ * @param {Object} state the state of the component, the style is applied to
40
+ * @return {Object} The final style object, which will be used in the component
41
+ */
42
+ const generateStyle = (componentTheme, props, sharedTokens, _state) => {
43
+ const fluidWidth = props.fluidWidth,
44
+ iconPosition = props.iconPosition,
45
+ size = props.size,
46
+ variant = props.variant;
47
+ const positionIconAtEnd = iconPosition === 'end' && (variant === 'filled' || fluidWidth);
48
+ const fluidWidthStyles = fluidWidth ? {
49
+ display: 'block',
50
+ width: '100%'
51
+ } : {};
52
+ const iconPositionStyles = {
53
+ start: {
54
+ marginInlineEnd: componentTheme.iconMargin,
55
+ marginInlineStart: 0
56
+ },
57
+ end: {
58
+ marginInlineStart: componentTheme.iconMargin,
59
+ marginInlineEnd: 0
60
+ }
61
+ };
62
+ const fontSizeStyles = {
63
+ small: {
64
+ fontSize: componentTheme.fontSizeSmall
65
+ },
66
+ medium: {
67
+ fontSize: componentTheme.fontSizeMedium
68
+ },
69
+ large: {
70
+ fontSize: componentTheme.fontSizeLarge
71
+ }
72
+ };
73
+ const indentDetailsStyles = iconPosition === 'start' && !fluidWidth ? {
74
+ small: {
75
+ paddingInlineStart: `calc(${componentTheme.contentPaddingSmall} + ${componentTheme.togglePadding})`,
76
+ paddingInlineEnd: '0'
77
+ },
78
+ medium: {
79
+ paddingInlineStart: `calc(${componentTheme.contentPaddingMedium} + ${componentTheme.togglePadding})`,
80
+ paddingInlineEnd: '0'
81
+ },
82
+ large: {
83
+ paddingInlineStart: `calc(${componentTheme.contentPaddingLarge} + ${componentTheme.togglePadding})`,
84
+ paddingInlineEnd: '0'
85
+ }
86
+ } : {
87
+ small: {},
88
+ medium: {},
89
+ large: {}
90
+ };
91
+ return {
92
+ toggleDetails: {
93
+ label: 'toggleDetails',
94
+ fontFamily: componentTheme.fontFamily,
95
+ fontWeight: componentTheme.fontWeight
96
+ },
97
+ summary: {
98
+ label: 'toggleDetails__summary',
99
+ position: 'relative',
100
+ display: 'flex',
101
+ alignItems: 'center',
102
+ boxSizing: 'border-box',
103
+ textAlign: 'start'
104
+ },
105
+ summaryText: {
106
+ label: 'toggleDetails__summaryText',
107
+ minWidth: '0.0625rem',
108
+ flexGrow: 1,
109
+ ...(positionIconAtEnd ? {
110
+ flex: 1
111
+ } : {})
112
+ },
113
+ toggle: {
114
+ label: 'toggleDetails__toggle',
115
+ fontFamily: componentTheme.fontFamily,
116
+ lineHeight: componentTheme.lineHeight,
117
+ appearance: 'none',
118
+ cursor: 'pointer',
119
+ userSelect: 'none',
120
+ touchAction: 'manipulation',
121
+ position: 'relative',
122
+ overflow: 'visible',
123
+ boxSizing: 'border-box',
124
+ padding: '0',
125
+ margin: '0',
126
+ outline: 'none',
127
+ border: 'none',
128
+ background: 'transparent',
129
+ color: componentTheme.textColor,
130
+ '&::-moz-focus-inner': {
131
+ padding: '0',
132
+ margin: '0'
133
+ },
134
+ '&::before': {
135
+ content: '""',
136
+ position: 'absolute',
137
+ top: '-0.375rem',
138
+ left: '-0.375rem',
139
+ right: '-0.375rem',
140
+ bottom: '-0.375rem',
141
+ border: `${componentTheme.toggleBorderWidth} ${componentTheme.toggleBorderStyle} ${sharedTokens.focusOutline.infoColor}`,
142
+ borderRadius: `calc(${componentTheme.toggleBorderRadius} * 1.5)`,
143
+ opacity: 0,
144
+ pointerEvents: 'none'
145
+ },
146
+ '&:focus': {
147
+ '&::before': {
148
+ opacity: 1
149
+ }
150
+ },
151
+ '&:focus, &:hover, &:active': {
152
+ textDecoration: 'none',
153
+ color: componentTheme.textColor
154
+ },
155
+ textDecoration: 'none',
156
+ ...fluidWidthStyles,
157
+ ...fontSizeStyles[size]
158
+ },
159
+ icon: {
160
+ label: 'toggleDetails__icon',
161
+ display: 'flex',
162
+ alignItems: 'center',
163
+ '& > svg': {
164
+ display: 'block' /* fix vertical alignment of icon */
165
+ },
166
+ ...iconPositionStyles[iconPosition]
167
+ },
168
+ details: {
169
+ label: 'toggleDetails__details',
170
+ boxSizing: 'border-box',
171
+ paddingTop: componentTheme.togglePadding,
172
+ color: componentTheme.textColor,
173
+ lineHeight: componentTheme.lineHeight,
174
+ ...fontSizeStyles[size],
175
+ ...indentDetailsStyles[size]
176
+ },
177
+ content: {
178
+ label: 'toggleDetails__content',
179
+ opacity: 0.01,
180
+ animationName: contentAnimation,
181
+ animationFillMode: 'forwards',
182
+ animationDuration: '.3s'
183
+ }
184
+ };
185
+ };
186
+ export default generateStyle;
@@ -25,15 +25,15 @@ var _dec, _class, _ToggleGroup;
25
25
 
26
26
  import { Component } from 'react';
27
27
  import { omitProps, pickProps, getElementType, callRenderProp } from '@instructure/ui-react-utils';
28
- import { IconButton } from '@instructure/ui-buttons';
28
+ import { IconButton } from '@instructure/ui-buttons/v11_6';
29
29
  import { Transition } from '@instructure/ui-motion';
30
30
  import { Expandable } from '@instructure/ui-expandable';
31
31
  import { isActiveElement } from '@instructure/ui-dom-utils';
32
- import { Flex } from '@instructure/ui-flex';
33
- import { View } from '@instructure/ui-view';
32
+ import { Flex } from '@instructure/ui-flex/v11_6';
33
+ import { View } from '@instructure/ui-view/v11_6';
34
34
  import { IconArrowOpenEndSolid, IconArrowOpenDownSolid } from '@instructure/ui-icons';
35
35
  import { allowedProps } from "./props.js";
36
- import { withStyle } from '@instructure/emotion';
36
+ import { withStyleLegacy as withStyle } from '@instructure/emotion';
37
37
  import generateStyle from "./styles.js";
38
38
  import generateComponentTheme from "./theme.js";
39
39
  /**
@@ -0,0 +1,172 @@
1
+ var _dec, _class, _ToggleGroup;
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';
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 { withStyle } 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 = withStyle(generateStyle), _dec(_class = (_ToggleGroup = class ToggleGroup extends Component {
51
+ constructor(...args) {
52
+ super(...args);
53
+ this.ref = null;
54
+ this._button = null;
55
+ this._shouldTransition = false;
56
+ this.handleRef = el => {
57
+ const elementRef = this.props.elementRef;
58
+ this.ref = el;
59
+ if (typeof elementRef === 'function') {
60
+ elementRef(el);
61
+ }
62
+ };
63
+ this.handleButtonRef = el => {
64
+ this._button = el;
65
+ };
66
+ }
67
+ get focused() {
68
+ return isActiveElement(this._button);
69
+ }
70
+ focus() {
71
+ var _this$_button;
72
+ (_this$_button = this._button) === null || _this$_button === void 0 ? void 0 : _this$_button.focus();
73
+ }
74
+ componentDidMount() {
75
+ this._shouldTransition = true;
76
+ }
77
+ componentDidUpdate() {
78
+ var _this$props$makeStyle, _this$props;
79
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.state);
80
+ }
81
+ renderIcon(expanded) {
82
+ const Icon = expanded ? this.props.iconExpanded : this.props.icon;
83
+ if (!Icon) return null;
84
+ const iconSize = toggleGroupSizeToIconSize[this.props.size];
85
+ return renderIconWithProps(Icon, iconSize, 'baseColor');
86
+ }
87
+ renderToggle(toggleProps, expanded) {
88
+ const _this$props2 = this.props,
89
+ toggleLabel = _this$props2.toggleLabel,
90
+ size = _this$props2.size;
91
+ let label;
92
+ if (typeof toggleLabel === 'function') {
93
+ label = toggleLabel(expanded);
94
+ } else {
95
+ label = toggleLabel;
96
+ }
97
+ const props = {
98
+ ...toggleProps
99
+ };
100
+ return _jsx(IconButton, {
101
+ ...props,
102
+ withBackground: false,
103
+ withBorder: false,
104
+ size: size === 'large' ? 'medium' : 'small',
105
+ elementRef: this.handleButtonRef,
106
+ screenReaderLabel: label,
107
+ children: this.renderIcon(expanded)
108
+ });
109
+ }
110
+ renderDetails(detailsProps) {
111
+ const styles = this.props.styles;
112
+ return _jsx(View, {
113
+ ...detailsProps,
114
+ display: "block",
115
+ borderWidth: "small none none none",
116
+ borderColor: styles === null || styles === void 0 ? void 0 : styles.borderColor,
117
+ children: this.props.transition && this._shouldTransition ? _jsx(Transition, {
118
+ transitionOnMount: true,
119
+ in: true,
120
+ type: "fade",
121
+ children: this.props.children
122
+ }) : this.props.children
123
+ });
124
+ }
125
+ render() {
126
+ const Element = getElementType(ToggleGroup, this.props);
127
+ const styles = this.props.styles;
128
+ return _jsx(Expandable, {
129
+ ...pickProps(this.props, Expandable.allowedProps),
130
+ children: ({
131
+ expanded,
132
+ getToggleProps,
133
+ getDetailsProps
134
+ }) => {
135
+ return _jsxs(View, {
136
+ ...omitProps(this.props, ToggleGroup.allowedProps),
137
+ borderWidth: this.props.border ? 'small' : 'none',
138
+ as: Element,
139
+ elementRef: this.handleRef,
140
+ display: "block",
141
+ borderRadius: "medium",
142
+ background: "primary",
143
+ borderColor: styles === null || styles === void 0 ? void 0 : styles.borderColor,
144
+ "data-cid": "ToggleGroup",
145
+ children: [_jsxs(Flex, {
146
+ padding: this.props.size === 'small' ? 'x-small' : 'small small small x-small',
147
+ children: [_jsx(Flex.Item, {
148
+ children: this.renderToggle(getToggleProps(), expanded)
149
+ }), _jsx(Flex.Item, {
150
+ shouldGrow: true,
151
+ shouldShrink: true,
152
+ padding: "0 0 0 x-small",
153
+ children: this.props.summary
154
+ })]
155
+ }), expanded ? this.renderDetails(getDetailsProps()) : _jsx("span", {
156
+ ...getDetailsProps()
157
+ })]
158
+ });
159
+ }
160
+ });
161
+ }
162
+ }, _ToggleGroup.displayName = "ToggleGroup", _ToggleGroup.componentId = 'ToggleGroup', _ToggleGroup.allowedProps = allowedProps, _ToggleGroup.defaultProps = {
163
+ size: 'medium',
164
+ icon: ChevronRightInstUIIcon,
165
+ iconExpanded: ChevronDownInstUIIcon,
166
+ defaultExpanded: false,
167
+ transition: true,
168
+ as: 'span',
169
+ border: true
170
+ }, _ToggleGroup)) || _class);
171
+ export default ToggleGroup;
172
+ 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;
@@ -21,5 +21,5 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
- export { ToggleDetails } from "./ToggleDetails/index.js";
25
- export { ToggleGroup } from "./ToggleGroup/index.js";
24
+ export { ToggleDetails } from "../ToggleDetails/v1/index.js";
25
+ export { ToggleGroup } from "../ToggleGroup/v1/index.js";
@@ -0,0 +1,25 @@
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
+ export { ToggleDetails } from "../ToggleDetails/v2/index.js";
25
+ export { ToggleGroup } from "../ToggleGroup/v2/index.js";