@instructure/ui-toggle-details 10.26.1-snapshot-2 → 10.26.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -18
- package/es/ToggleDetails/index.js +21 -20
- package/es/ToggleDetails/props.js +16 -1
- package/es/ToggleGroup/index.js +6 -6
- package/es/ToggleGroup/props.js +18 -1
- package/lib/ToggleDetails/index.js +19 -18
- package/lib/ToggleDetails/props.js +17 -1
- package/lib/ToggleGroup/index.js +5 -5
- package/lib/ToggleGroup/props.js +19 -1
- package/package.json +21 -18
- package/src/ToggleDetails/index.tsx +19 -16
- package/src/ToggleDetails/props.ts +20 -1
- package/src/ToggleGroup/index.tsx +4 -2
- package/src/ToggleGroup/props.ts +22 -1
- package/tsconfig.build.json +2 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/ToggleDetails/index.d.ts +16 -3
- package/types/ToggleDetails/index.d.ts.map +1 -1
- package/types/ToggleDetails/props.d.ts +3 -2
- package/types/ToggleDetails/props.d.ts.map +1 -1
- package/types/ToggleGroup/index.d.ts +15 -0
- package/types/ToggleGroup/index.d.ts.map +1 -1
- package/types/ToggleGroup/props.d.ts +3 -2
- package/types/ToggleGroup/props.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,30 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [10.26.
|
|
6
|
+
## [10.26.2](https://github.com/instructure/instructure-ui/compare/v10.26.1...v10.26.2) (2025-10-13)
|
|
7
7
|
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-toggle-details
|
|
8
9
|
|
|
9
|
-
### Features
|
|
10
10
|
|
|
11
|
-
* **many:** instUI v11 release ([36f5438](https://github.com/instructure/instructure-ui/commit/36f54382669186227ba24798bbf7201ef2f5cd4c))
|
|
12
11
|
|
|
13
12
|
|
|
14
|
-
### BREAKING CHANGES
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
- remove `CodeEditor` component
|
|
20
|
-
- remove `@instui/theme-registry` package
|
|
21
|
-
- remove `@testable`, `@experimental`, `@hack` decorators
|
|
22
|
-
- InstUISettingsProvider's `as` prop is removed
|
|
23
|
-
- `canvas.use()`, `canvasHighContrast.use()` functions are removed
|
|
24
|
-
- `canvasThemeLocal`, `canvasHighContrastThemeLocal` are removed
|
|
25
|
-
- `variables` field on theme objects are removed
|
|
26
|
-
- remove deprecated props from Table: Row's `isStacked`, Body's
|
|
27
|
-
`isStacked`, `hover`, and `headers`
|
|
28
|
-
- `Table`'s `caption` prop is now required
|
|
29
|
-
- `ui-dom-utils`'s `getComputedStyle` can now return `undefined`
|
|
14
|
+
## [10.26.1](https://github.com/instructure/instructure-ui/compare/v10.26.0...v10.26.1) (2025-10-06)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @instructure/ui-toggle-details
|
|
30
17
|
|
|
31
18
|
|
|
32
19
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _class, _ToggleDetails;
|
|
1
|
+
var _dec, _dec2, _class, _ToggleDetails;
|
|
2
2
|
/*
|
|
3
3
|
* The MIT License (MIT)
|
|
4
4
|
*
|
|
@@ -23,31 +23,29 @@ var _dec, _class, _ToggleDetails;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import { Component
|
|
26
|
+
import { Component } from 'react';
|
|
27
27
|
import { Button } from '@instructure/ui-buttons';
|
|
28
28
|
import { IconArrowOpenEndSolid, IconArrowOpenDownSolid } from '@instructure/ui-icons';
|
|
29
29
|
import { Expandable } from '@instructure/ui-expandable';
|
|
30
30
|
import { omitProps, pickProps } from '@instructure/ui-react-utils';
|
|
31
31
|
import { isActiveElement } from '@instructure/ui-dom-utils';
|
|
32
|
+
import { testable } from '@instructure/ui-testable';
|
|
32
33
|
import { withStyle } from '@instructure/emotion';
|
|
33
34
|
import generateStyle from './styles';
|
|
34
35
|
import generateComponentTheme from './theme';
|
|
35
|
-
import { allowedProps } from './props';
|
|
36
|
+
import { allowedProps, propTypes } from './props';
|
|
36
37
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
37
38
|
/**
|
|
38
39
|
---
|
|
39
40
|
category: components
|
|
40
41
|
---
|
|
41
42
|
**/
|
|
42
|
-
let ToggleDetails = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = (_ToggleDetails = class ToggleDetails extends Component {
|
|
43
|
+
let ToggleDetails = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_ToggleDetails = class ToggleDetails extends Component {
|
|
43
44
|
constructor(...args) {
|
|
44
45
|
super(...args);
|
|
45
|
-
this.
|
|
46
|
-
this.
|
|
47
|
-
|
|
48
|
-
this.setButtonRef = node => {
|
|
49
|
-
this._buttonNode = node;
|
|
50
|
-
};
|
|
46
|
+
this.ref = null;
|
|
47
|
+
this._button = null;
|
|
48
|
+
this.getButtonRef = el => this._button = el;
|
|
51
49
|
this.handleToggle = (event, expanded) => {
|
|
52
50
|
if (typeof this.props.onToggle === 'function') {
|
|
53
51
|
this.props.onToggle(event, expanded);
|
|
@@ -55,11 +53,11 @@ let ToggleDetails = (_dec = withStyle(generateStyle, generateComponentTheme), _d
|
|
|
55
53
|
};
|
|
56
54
|
}
|
|
57
55
|
get focused() {
|
|
58
|
-
return isActiveElement(this.
|
|
56
|
+
return isActiveElement(this._button);
|
|
59
57
|
}
|
|
60
58
|
focus() {
|
|
61
|
-
var _this$
|
|
62
|
-
(_this$
|
|
59
|
+
var _this$_button;
|
|
60
|
+
(_this$_button = this._button) === null || _this$_button === void 0 ? void 0 : _this$_button.focus();
|
|
63
61
|
}
|
|
64
62
|
componentDidMount() {
|
|
65
63
|
var _this$props$makeStyle, _this$props;
|
|
@@ -84,6 +82,8 @@ let ToggleDetails = (_dec = withStyle(generateStyle, generateComponentTheme), _d
|
|
|
84
82
|
}
|
|
85
83
|
renderToggle(toggleProps, expanded) {
|
|
86
84
|
const variant = this.props.variant;
|
|
85
|
+
// Do not put aria-controls and aria-expanded into the toggle if there
|
|
86
|
+
// is nothing to open
|
|
87
87
|
const tProps = this.props.children ? toggleProps : {
|
|
88
88
|
onClick: toggleProps.onClick
|
|
89
89
|
};
|
|
@@ -98,7 +98,7 @@ let ToggleDetails = (_dec = withStyle(generateStyle, generateComponentTheme), _d
|
|
|
98
98
|
...props,
|
|
99
99
|
display: "block",
|
|
100
100
|
textAlign: "start",
|
|
101
|
-
elementRef: this.
|
|
101
|
+
elementRef: this.getButtonRef,
|
|
102
102
|
children: summary
|
|
103
103
|
});
|
|
104
104
|
} else if (props.href) {
|
|
@@ -106,7 +106,7 @@ let ToggleDetails = (_dec = withStyle(generateStyle, generateComponentTheme), _d
|
|
|
106
106
|
return _jsx("a", {
|
|
107
107
|
...props,
|
|
108
108
|
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.toggle,
|
|
109
|
-
ref: this.
|
|
109
|
+
ref: this.getButtonRef,
|
|
110
110
|
children: summary
|
|
111
111
|
});
|
|
112
112
|
} else {
|
|
@@ -115,7 +115,7 @@ let ToggleDetails = (_dec = withStyle(generateStyle, generateComponentTheme), _d
|
|
|
115
115
|
...props,
|
|
116
116
|
type: "button",
|
|
117
117
|
css: (_this$props$styles4 = this.props.styles) === null || _this$props$styles4 === void 0 ? void 0 : _this$props$styles4.toggle,
|
|
118
|
-
ref: this.
|
|
118
|
+
ref: this.getButtonRef,
|
|
119
119
|
children: summary
|
|
120
120
|
});
|
|
121
121
|
}
|
|
@@ -161,14 +161,15 @@ let ToggleDetails = (_dec = withStyle(generateStyle, generateComponentTheme), _d
|
|
|
161
161
|
var _this$props$styles8;
|
|
162
162
|
return _jsxs("div", {
|
|
163
163
|
css: (_this$props$styles8 = this.props.styles) === null || _this$props$styles8 === void 0 ? void 0 : _this$props$styles8.toggleDetails,
|
|
164
|
-
ref:
|
|
165
|
-
|
|
164
|
+
ref: el => {
|
|
165
|
+
this.ref = el;
|
|
166
|
+
},
|
|
166
167
|
children: [this.renderToggle(getToggleProps(), expanded), this.renderDetails(expanded, getDetailsProps())]
|
|
167
168
|
});
|
|
168
169
|
}
|
|
169
170
|
});
|
|
170
171
|
}
|
|
171
|
-
}, _ToggleDetails.displayName = "ToggleDetails", _ToggleDetails.componentId = 'ToggleDetails', _ToggleDetails.allowedProps = allowedProps, _ToggleDetails.defaultProps = {
|
|
172
|
+
}, _ToggleDetails.displayName = "ToggleDetails", _ToggleDetails.componentId = 'ToggleDetails', _ToggleDetails.allowedProps = allowedProps, _ToggleDetails.propTypes = propTypes, _ToggleDetails.defaultProps = {
|
|
172
173
|
variant: 'default',
|
|
173
174
|
size: 'medium',
|
|
174
175
|
fluidWidth: false,
|
|
@@ -177,6 +178,6 @@ let ToggleDetails = (_dec = withStyle(generateStyle, generateComponentTheme), _d
|
|
|
177
178
|
iconPosition: 'start',
|
|
178
179
|
defaultExpanded: false,
|
|
179
180
|
children: null
|
|
180
|
-
}, _ToggleDetails)) || _class);
|
|
181
|
+
}, _ToggleDetails)) || _class) || _class);
|
|
181
182
|
export default ToggleDetails;
|
|
182
183
|
export { ToggleDetails };
|
|
@@ -22,5 +22,20 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
+
import PropTypes from 'prop-types';
|
|
26
|
+
import { controllable } from '@instructure/ui-prop-types';
|
|
27
|
+
const propTypes = {
|
|
28
|
+
variant: PropTypes.oneOf(['default', 'filled']),
|
|
29
|
+
summary: PropTypes.node.isRequired,
|
|
30
|
+
expanded: controllable(PropTypes.bool, 'onToggle', 'defaultExpanded'),
|
|
31
|
+
defaultExpanded: PropTypes.bool,
|
|
32
|
+
onToggle: PropTypes.func,
|
|
33
|
+
icon: PropTypes.func,
|
|
34
|
+
iconExpanded: PropTypes.func,
|
|
35
|
+
iconPosition: PropTypes.oneOf(['start', 'end']),
|
|
36
|
+
fluidWidth: PropTypes.bool,
|
|
37
|
+
children: PropTypes.node,
|
|
38
|
+
size: PropTypes.oneOf(['small', 'medium', 'large'])
|
|
39
|
+
};
|
|
25
40
|
const allowedProps = ['variant', 'summary', 'expanded', 'defaultExpanded', 'onToggle', 'icon', 'iconExpanded', 'iconPosition', 'fluidWidth', 'children', 'size'];
|
|
26
|
-
export { allowedProps };
|
|
41
|
+
export { propTypes, allowedProps };
|
package/es/ToggleGroup/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _class, _ToggleGroup;
|
|
1
|
+
var _dec, _dec2, _class, _ToggleGroup;
|
|
2
2
|
/*
|
|
3
3
|
* The MIT License (MIT)
|
|
4
4
|
*
|
|
@@ -32,7 +32,8 @@ import { isActiveElement } from '@instructure/ui-dom-utils';
|
|
|
32
32
|
import { Flex } from '@instructure/ui-flex';
|
|
33
33
|
import { View } from '@instructure/ui-view';
|
|
34
34
|
import { IconArrowOpenEndSolid, IconArrowOpenDownSolid } from '@instructure/ui-icons';
|
|
35
|
-
import {
|
|
35
|
+
import { testable } from '@instructure/ui-testable';
|
|
36
|
+
import { allowedProps, propTypes } from './props';
|
|
36
37
|
import { withStyle } from '@instructure/emotion';
|
|
37
38
|
import generateStyle from './styles';
|
|
38
39
|
import generateComponentTheme from './theme';
|
|
@@ -43,7 +44,7 @@ category: components
|
|
|
43
44
|
---
|
|
44
45
|
**/
|
|
45
46
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
46
|
-
let ToggleGroup = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = (_ToggleGroup = class ToggleGroup extends Component {
|
|
47
|
+
let ToggleGroup = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_ToggleGroup = class ToggleGroup extends Component {
|
|
47
48
|
constructor(...args) {
|
|
48
49
|
super(...args);
|
|
49
50
|
this.ref = null;
|
|
@@ -135,7 +136,6 @@ let ToggleGroup = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
135
136
|
borderRadius: "medium",
|
|
136
137
|
background: "primary",
|
|
137
138
|
borderColor: styles === null || styles === void 0 ? void 0 : styles.borderColor,
|
|
138
|
-
"data-cid": "ToggleGroup",
|
|
139
139
|
children: [_jsxs(Flex, {
|
|
140
140
|
padding: this.props.size === 'small' ? 'x-small' : 'small small small x-small',
|
|
141
141
|
children: [_jsx(Flex.Item, {
|
|
@@ -153,7 +153,7 @@ let ToggleGroup = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
153
153
|
}
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
|
-
}, _ToggleGroup.displayName = "ToggleGroup", _ToggleGroup.componentId = 'ToggleGroup', _ToggleGroup.allowedProps = allowedProps, _ToggleGroup.defaultProps = {
|
|
156
|
+
}, _ToggleGroup.displayName = "ToggleGroup", _ToggleGroup.componentId = 'ToggleGroup', _ToggleGroup.allowedProps = allowedProps, _ToggleGroup.propTypes = propTypes, _ToggleGroup.defaultProps = {
|
|
157
157
|
size: 'medium',
|
|
158
158
|
icon: IconArrowOpenEndSolid,
|
|
159
159
|
iconExpanded: IconArrowOpenDownSolid,
|
|
@@ -161,6 +161,6 @@ let ToggleGroup = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
161
161
|
transition: true,
|
|
162
162
|
as: 'span',
|
|
163
163
|
border: true
|
|
164
|
-
}, _ToggleGroup)) || _class);
|
|
164
|
+
}, _ToggleGroup)) || _class) || _class);
|
|
165
165
|
export default ToggleGroup;
|
|
166
166
|
export { ToggleGroup };
|
package/es/ToggleGroup/props.js
CHANGED
|
@@ -22,5 +22,22 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
+
import PropTypes from 'prop-types';
|
|
26
|
+
import { controllable } from '@instructure/ui-prop-types';
|
|
27
|
+
const propTypes = {
|
|
28
|
+
children: PropTypes.node.isRequired,
|
|
29
|
+
summary: PropTypes.node.isRequired,
|
|
30
|
+
toggleLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired,
|
|
31
|
+
as: PropTypes.elementType,
|
|
32
|
+
elementRef: PropTypes.func,
|
|
33
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
34
|
+
expanded: controllable(PropTypes.bool, 'onToggle', 'defaultExpanded'),
|
|
35
|
+
defaultExpanded: PropTypes.bool,
|
|
36
|
+
onToggle: PropTypes.func,
|
|
37
|
+
icon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
38
|
+
iconExpanded: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
39
|
+
transition: PropTypes.bool,
|
|
40
|
+
border: PropTypes.bool
|
|
41
|
+
};
|
|
25
42
|
const allowedProps = ['children', 'summary', 'toggleLabel', 'as', 'elementRef', 'size', 'expanded', 'defaultExpanded', 'onToggle', 'icon', 'iconExpanded', 'transition', 'border'];
|
|
26
|
-
export { allowedProps };
|
|
43
|
+
export { propTypes, allowedProps };
|
|
@@ -13,12 +13,13 @@ var _Expandable = require("@instructure/ui-expandable/lib/Expandable");
|
|
|
13
13
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
14
14
|
var _pickProps = require("@instructure/ui-react-utils/lib/pickProps.js");
|
|
15
15
|
var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js");
|
|
16
|
+
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
16
17
|
var _emotion = require("@instructure/emotion");
|
|
17
18
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
18
19
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
19
20
|
var _props = require("./props");
|
|
20
21
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
21
|
-
var _dec, _class, _ToggleDetails;
|
|
22
|
+
var _dec, _dec2, _class, _ToggleDetails;
|
|
22
23
|
/*
|
|
23
24
|
* The MIT License (MIT)
|
|
24
25
|
*
|
|
@@ -47,15 +48,12 @@ var _dec, _class, _ToggleDetails;
|
|
|
47
48
|
category: components
|
|
48
49
|
---
|
|
49
50
|
**/
|
|
50
|
-
let ToggleDetails = exports.ToggleDetails = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = (_ToggleDetails = class ToggleDetails extends _react.Component {
|
|
51
|
+
let ToggleDetails = exports.ToggleDetails = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_ToggleDetails = class ToggleDetails extends _react.Component {
|
|
51
52
|
constructor(...args) {
|
|
52
53
|
super(...args);
|
|
53
|
-
this.
|
|
54
|
-
this.
|
|
55
|
-
|
|
56
|
-
this.setButtonRef = node => {
|
|
57
|
-
this._buttonNode = node;
|
|
58
|
-
};
|
|
54
|
+
this.ref = null;
|
|
55
|
+
this._button = null;
|
|
56
|
+
this.getButtonRef = el => this._button = el;
|
|
59
57
|
this.handleToggle = (event, expanded) => {
|
|
60
58
|
if (typeof this.props.onToggle === 'function') {
|
|
61
59
|
this.props.onToggle(event, expanded);
|
|
@@ -63,11 +61,11 @@ let ToggleDetails = exports.ToggleDetails = (_dec = (0, _emotion.withStyle)(_sty
|
|
|
63
61
|
};
|
|
64
62
|
}
|
|
65
63
|
get focused() {
|
|
66
|
-
return (0, _isActiveElement.isActiveElement)(this.
|
|
64
|
+
return (0, _isActiveElement.isActiveElement)(this._button);
|
|
67
65
|
}
|
|
68
66
|
focus() {
|
|
69
|
-
var _this$
|
|
70
|
-
(_this$
|
|
67
|
+
var _this$_button;
|
|
68
|
+
(_this$_button = this._button) === null || _this$_button === void 0 ? void 0 : _this$_button.focus();
|
|
71
69
|
}
|
|
72
70
|
componentDidMount() {
|
|
73
71
|
var _this$props$makeStyle, _this$props;
|
|
@@ -92,6 +90,8 @@ let ToggleDetails = exports.ToggleDetails = (_dec = (0, _emotion.withStyle)(_sty
|
|
|
92
90
|
}
|
|
93
91
|
renderToggle(toggleProps, expanded) {
|
|
94
92
|
const variant = this.props.variant;
|
|
93
|
+
// Do not put aria-controls and aria-expanded into the toggle if there
|
|
94
|
+
// is nothing to open
|
|
95
95
|
const tProps = this.props.children ? toggleProps : {
|
|
96
96
|
onClick: toggleProps.onClick
|
|
97
97
|
};
|
|
@@ -106,7 +106,7 @@ let ToggleDetails = exports.ToggleDetails = (_dec = (0, _emotion.withStyle)(_sty
|
|
|
106
106
|
...props,
|
|
107
107
|
display: "block",
|
|
108
108
|
textAlign: "start",
|
|
109
|
-
elementRef: this.
|
|
109
|
+
elementRef: this.getButtonRef,
|
|
110
110
|
children: summary
|
|
111
111
|
});
|
|
112
112
|
} else if (props.href) {
|
|
@@ -114,7 +114,7 @@ let ToggleDetails = exports.ToggleDetails = (_dec = (0, _emotion.withStyle)(_sty
|
|
|
114
114
|
return (0, _jsxRuntime.jsx)("a", {
|
|
115
115
|
...props,
|
|
116
116
|
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.toggle,
|
|
117
|
-
ref: this.
|
|
117
|
+
ref: this.getButtonRef,
|
|
118
118
|
children: summary
|
|
119
119
|
});
|
|
120
120
|
} else {
|
|
@@ -123,7 +123,7 @@ let ToggleDetails = exports.ToggleDetails = (_dec = (0, _emotion.withStyle)(_sty
|
|
|
123
123
|
...props,
|
|
124
124
|
type: "button",
|
|
125
125
|
css: (_this$props$styles4 = this.props.styles) === null || _this$props$styles4 === void 0 ? void 0 : _this$props$styles4.toggle,
|
|
126
|
-
ref: this.
|
|
126
|
+
ref: this.getButtonRef,
|
|
127
127
|
children: summary
|
|
128
128
|
});
|
|
129
129
|
}
|
|
@@ -169,14 +169,15 @@ let ToggleDetails = exports.ToggleDetails = (_dec = (0, _emotion.withStyle)(_sty
|
|
|
169
169
|
var _this$props$styles8;
|
|
170
170
|
return (0, _jsxRuntime.jsxs)("div", {
|
|
171
171
|
css: (_this$props$styles8 = this.props.styles) === null || _this$props$styles8 === void 0 ? void 0 : _this$props$styles8.toggleDetails,
|
|
172
|
-
ref:
|
|
173
|
-
|
|
172
|
+
ref: el => {
|
|
173
|
+
this.ref = el;
|
|
174
|
+
},
|
|
174
175
|
children: [this.renderToggle(getToggleProps(), expanded), this.renderDetails(expanded, getDetailsProps())]
|
|
175
176
|
});
|
|
176
177
|
}
|
|
177
178
|
});
|
|
178
179
|
}
|
|
179
|
-
}, _ToggleDetails.displayName = "ToggleDetails", _ToggleDetails.componentId = 'ToggleDetails', _ToggleDetails.allowedProps = _props.allowedProps, _ToggleDetails.defaultProps = {
|
|
180
|
+
}, _ToggleDetails.displayName = "ToggleDetails", _ToggleDetails.componentId = 'ToggleDetails', _ToggleDetails.allowedProps = _props.allowedProps, _ToggleDetails.propTypes = _props.propTypes, _ToggleDetails.defaultProps = {
|
|
180
181
|
variant: 'default',
|
|
181
182
|
size: 'medium',
|
|
182
183
|
fluidWidth: false,
|
|
@@ -185,5 +186,5 @@ let ToggleDetails = exports.ToggleDetails = (_dec = (0, _emotion.withStyle)(_sty
|
|
|
185
186
|
iconPosition: 'start',
|
|
186
187
|
defaultExpanded: false,
|
|
187
188
|
children: null
|
|
188
|
-
}, _ToggleDetails)) || _class);
|
|
189
|
+
}, _ToggleDetails)) || _class) || _class);
|
|
189
190
|
var _default = exports.default = ToggleDetails;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.allowedProps = void 0;
|
|
7
|
+
exports.propTypes = exports.allowedProps = void 0;
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _controllable = require("@instructure/ui-prop-types/lib/controllable.js");
|
|
7
10
|
/*
|
|
8
11
|
* The MIT License (MIT)
|
|
9
12
|
*
|
|
@@ -28,4 +31,17 @@ exports.allowedProps = void 0;
|
|
|
28
31
|
* SOFTWARE.
|
|
29
32
|
*/
|
|
30
33
|
|
|
34
|
+
const propTypes = exports.propTypes = {
|
|
35
|
+
variant: _propTypes.default.oneOf(['default', 'filled']),
|
|
36
|
+
summary: _propTypes.default.node.isRequired,
|
|
37
|
+
expanded: (0, _controllable.controllable)(_propTypes.default.bool, 'onToggle', 'defaultExpanded'),
|
|
38
|
+
defaultExpanded: _propTypes.default.bool,
|
|
39
|
+
onToggle: _propTypes.default.func,
|
|
40
|
+
icon: _propTypes.default.func,
|
|
41
|
+
iconExpanded: _propTypes.default.func,
|
|
42
|
+
iconPosition: _propTypes.default.oneOf(['start', 'end']),
|
|
43
|
+
fluidWidth: _propTypes.default.bool,
|
|
44
|
+
children: _propTypes.default.node,
|
|
45
|
+
size: _propTypes.default.oneOf(['small', 'medium', 'large'])
|
|
46
|
+
};
|
|
31
47
|
const allowedProps = exports.allowedProps = ['variant', 'summary', 'expanded', 'defaultExpanded', 'onToggle', 'icon', 'iconExpanded', 'iconPosition', 'fluidWidth', 'children', 'size'];
|
package/lib/ToggleGroup/index.js
CHANGED
|
@@ -18,12 +18,13 @@ var _Flex = require("@instructure/ui-flex/lib/Flex");
|
|
|
18
18
|
var _View = require("@instructure/ui-view/lib/View");
|
|
19
19
|
var _IconArrowOpenEndSolid = require("@instructure/ui-icons/lib/IconArrowOpenEndSolid.js");
|
|
20
20
|
var _IconArrowOpenDownSolid = require("@instructure/ui-icons/lib/IconArrowOpenDownSolid.js");
|
|
21
|
+
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
21
22
|
var _props = require("./props");
|
|
22
23
|
var _emotion = require("@instructure/emotion");
|
|
23
24
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
24
25
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
25
26
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
26
|
-
var _dec, _class, _ToggleGroup;
|
|
27
|
+
var _dec, _dec2, _class, _ToggleGroup;
|
|
27
28
|
/*
|
|
28
29
|
* The MIT License (MIT)
|
|
29
30
|
*
|
|
@@ -52,7 +53,7 @@ var _dec, _class, _ToggleGroup;
|
|
|
52
53
|
category: components
|
|
53
54
|
---
|
|
54
55
|
**/
|
|
55
|
-
let ToggleGroup = exports.ToggleGroup = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = (_ToggleGroup = class ToggleGroup extends _react.Component {
|
|
56
|
+
let ToggleGroup = exports.ToggleGroup = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_ToggleGroup = class ToggleGroup extends _react.Component {
|
|
56
57
|
constructor(...args) {
|
|
57
58
|
super(...args);
|
|
58
59
|
this.ref = null;
|
|
@@ -144,7 +145,6 @@ let ToggleGroup = exports.ToggleGroup = (_dec = (0, _emotion.withStyle)(_styles.
|
|
|
144
145
|
borderRadius: "medium",
|
|
145
146
|
background: "primary",
|
|
146
147
|
borderColor: styles === null || styles === void 0 ? void 0 : styles.borderColor,
|
|
147
|
-
"data-cid": "ToggleGroup",
|
|
148
148
|
children: [(0, _jsxRuntime.jsxs)(_Flex.Flex, {
|
|
149
149
|
padding: this.props.size === 'small' ? 'x-small' : 'small small small x-small',
|
|
150
150
|
children: [(0, _jsxRuntime.jsx)(_Flex.Flex.Item, {
|
|
@@ -162,7 +162,7 @@ let ToggleGroup = exports.ToggleGroup = (_dec = (0, _emotion.withStyle)(_styles.
|
|
|
162
162
|
}
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
|
-
}, _ToggleGroup.displayName = "ToggleGroup", _ToggleGroup.componentId = 'ToggleGroup', _ToggleGroup.allowedProps = _props.allowedProps, _ToggleGroup.defaultProps = {
|
|
165
|
+
}, _ToggleGroup.displayName = "ToggleGroup", _ToggleGroup.componentId = 'ToggleGroup', _ToggleGroup.allowedProps = _props.allowedProps, _ToggleGroup.propTypes = _props.propTypes, _ToggleGroup.defaultProps = {
|
|
166
166
|
size: 'medium',
|
|
167
167
|
icon: _IconArrowOpenEndSolid.IconArrowOpenEndSolid,
|
|
168
168
|
iconExpanded: _IconArrowOpenDownSolid.IconArrowOpenDownSolid,
|
|
@@ -170,5 +170,5 @@ let ToggleGroup = exports.ToggleGroup = (_dec = (0, _emotion.withStyle)(_styles.
|
|
|
170
170
|
transition: true,
|
|
171
171
|
as: 'span',
|
|
172
172
|
border: true
|
|
173
|
-
}, _ToggleGroup)) || _class);
|
|
173
|
+
}, _ToggleGroup)) || _class) || _class);
|
|
174
174
|
var _default = exports.default = ToggleGroup;
|
package/lib/ToggleGroup/props.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.allowedProps = void 0;
|
|
7
|
+
exports.propTypes = exports.allowedProps = void 0;
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _controllable = require("@instructure/ui-prop-types/lib/controllable.js");
|
|
7
10
|
/*
|
|
8
11
|
* The MIT License (MIT)
|
|
9
12
|
*
|
|
@@ -28,4 +31,19 @@ exports.allowedProps = void 0;
|
|
|
28
31
|
* SOFTWARE.
|
|
29
32
|
*/
|
|
30
33
|
|
|
34
|
+
const propTypes = exports.propTypes = {
|
|
35
|
+
children: _propTypes.default.node.isRequired,
|
|
36
|
+
summary: _propTypes.default.node.isRequired,
|
|
37
|
+
toggleLabel: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]).isRequired,
|
|
38
|
+
as: _propTypes.default.elementType,
|
|
39
|
+
elementRef: _propTypes.default.func,
|
|
40
|
+
size: _propTypes.default.oneOf(['small', 'medium', 'large']),
|
|
41
|
+
expanded: (0, _controllable.controllable)(_propTypes.default.bool, 'onToggle', 'defaultExpanded'),
|
|
42
|
+
defaultExpanded: _propTypes.default.bool,
|
|
43
|
+
onToggle: _propTypes.default.func,
|
|
44
|
+
icon: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
45
|
+
iconExpanded: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
46
|
+
transition: _propTypes.default.bool,
|
|
47
|
+
border: _propTypes.default.bool
|
|
48
|
+
};
|
|
31
49
|
const allowedProps = exports.allowedProps = ['children', 'summary', 'toggleLabel', 'as', 'elementRef', 'size', 'expanded', 'defaultExpanded', 'onToggle', 'icon', 'iconExpanded', 'transition', 'border'];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-toggle-details",
|
|
3
|
-
"version": "10.26.
|
|
3
|
+
"version": "10.26.2",
|
|
4
4
|
"description": "A styled toggleable, accordion-like component.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -23,31 +23,34 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-axe-check": "10.26.
|
|
27
|
-
"@instructure/ui-babel-preset": "10.26.
|
|
28
|
-
"@instructure/ui-themes": "10.26.
|
|
26
|
+
"@instructure/ui-axe-check": "10.26.2",
|
|
27
|
+
"@instructure/ui-babel-preset": "10.26.2",
|
|
28
|
+
"@instructure/ui-themes": "10.26.2",
|
|
29
29
|
"@testing-library/jest-dom": "^6.6.3",
|
|
30
|
-
"@testing-library/react": "
|
|
30
|
+
"@testing-library/react": "^16.0.1",
|
|
31
31
|
"@testing-library/user-event": "^14.6.1",
|
|
32
32
|
"vitest": "^3.2.2"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@babel/runtime": "^7.27.6",
|
|
36
|
-
"@instructure/emotion": "10.26.
|
|
37
|
-
"@instructure/shared-types": "10.26.
|
|
38
|
-
"@instructure/ui-buttons": "10.26.
|
|
39
|
-
"@instructure/ui-dom-utils": "10.26.
|
|
40
|
-
"@instructure/ui-expandable": "10.26.
|
|
41
|
-
"@instructure/ui-flex": "10.26.
|
|
42
|
-
"@instructure/ui-icons": "10.26.
|
|
43
|
-
"@instructure/ui-motion": "10.26.
|
|
44
|
-
"@instructure/ui-
|
|
45
|
-
"@instructure/ui-utils": "10.26.
|
|
46
|
-
"@instructure/ui-
|
|
47
|
-
"@instructure/
|
|
36
|
+
"@instructure/emotion": "10.26.2",
|
|
37
|
+
"@instructure/shared-types": "10.26.2",
|
|
38
|
+
"@instructure/ui-buttons": "10.26.2",
|
|
39
|
+
"@instructure/ui-dom-utils": "10.26.2",
|
|
40
|
+
"@instructure/ui-expandable": "10.26.2",
|
|
41
|
+
"@instructure/ui-flex": "10.26.2",
|
|
42
|
+
"@instructure/ui-icons": "10.26.2",
|
|
43
|
+
"@instructure/ui-motion": "10.26.2",
|
|
44
|
+
"@instructure/ui-prop-types": "10.26.2",
|
|
45
|
+
"@instructure/ui-react-utils": "10.26.2",
|
|
46
|
+
"@instructure/ui-testable": "10.26.2",
|
|
47
|
+
"@instructure/ui-utils": "10.26.2",
|
|
48
|
+
"@instructure/ui-view": "10.26.2",
|
|
49
|
+
"@instructure/uid": "10.26.2",
|
|
50
|
+
"prop-types": "^15.8.1"
|
|
48
51
|
},
|
|
49
52
|
"peerDependencies": {
|
|
50
|
-
"react": ">=
|
|
53
|
+
"react": ">=16.14 <=18"
|
|
51
54
|
},
|
|
52
55
|
"publishConfig": {
|
|
53
56
|
"access": "public"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
import { Component
|
|
25
|
+
import { Component } from 'react'
|
|
26
26
|
import { Button } from '@instructure/ui-buttons'
|
|
27
27
|
import {
|
|
28
28
|
IconArrowOpenEndSolid,
|
|
@@ -31,12 +31,13 @@ import {
|
|
|
31
31
|
import { Expandable } from '@instructure/ui-expandable'
|
|
32
32
|
import { omitProps, pickProps } from '@instructure/ui-react-utils'
|
|
33
33
|
import { isActiveElement } from '@instructure/ui-dom-utils'
|
|
34
|
+
import { testable } from '@instructure/ui-testable'
|
|
34
35
|
|
|
35
36
|
import { withStyle } from '@instructure/emotion'
|
|
36
37
|
import generateStyle from './styles'
|
|
37
38
|
import generateComponentTheme from './theme'
|
|
38
39
|
import type { ToggleDetailsProps } from './props'
|
|
39
|
-
import { allowedProps } from './props'
|
|
40
|
+
import { allowedProps, propTypes } from './props'
|
|
40
41
|
import type { ExpandableToggleProps } from '@instructure/ui-expandable'
|
|
41
42
|
import type { ViewProps } from '@instructure/ui-view'
|
|
42
43
|
|
|
@@ -46,9 +47,11 @@ category: components
|
|
|
46
47
|
---
|
|
47
48
|
**/
|
|
48
49
|
@withStyle(generateStyle, generateComponentTheme)
|
|
50
|
+
@testable()
|
|
49
51
|
class ToggleDetails extends Component<ToggleDetailsProps> {
|
|
50
52
|
static readonly componentId = 'ToggleDetails'
|
|
51
53
|
static allowedProps = allowedProps
|
|
54
|
+
static propTypes = propTypes
|
|
52
55
|
|
|
53
56
|
static defaultProps = {
|
|
54
57
|
variant: 'default',
|
|
@@ -61,20 +64,15 @@ class ToggleDetails extends Component<ToggleDetailsProps> {
|
|
|
61
64
|
children: null
|
|
62
65
|
}
|
|
63
66
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
// TODO this solution was generated with Gemini, should be tested if it works as fine as before
|
|
68
|
-
setButtonRef = (node: Element | null) => {
|
|
69
|
-
this._buttonNode = node as HTMLElement | null
|
|
70
|
-
}
|
|
67
|
+
ref: Element | null = null
|
|
68
|
+
_button: HTMLElement | null = null
|
|
71
69
|
|
|
72
70
|
get focused() {
|
|
73
|
-
return isActiveElement(this.
|
|
71
|
+
return isActiveElement(this._button)
|
|
74
72
|
}
|
|
75
73
|
|
|
76
74
|
focus() {
|
|
77
|
-
this.
|
|
75
|
+
this._button?.focus()
|
|
78
76
|
}
|
|
79
77
|
|
|
80
78
|
componentDidMount() {
|
|
@@ -85,6 +83,8 @@ class ToggleDetails extends Component<ToggleDetailsProps> {
|
|
|
85
83
|
this.props.makeStyles?.()
|
|
86
84
|
}
|
|
87
85
|
|
|
86
|
+
getButtonRef = (el: Element | null) => (this._button = el as HTMLElement)
|
|
87
|
+
|
|
88
88
|
renderSummary(expanded: boolean) {
|
|
89
89
|
const { summary, iconPosition } = this.props
|
|
90
90
|
|
|
@@ -102,6 +102,8 @@ class ToggleDetails extends Component<ToggleDetailsProps> {
|
|
|
102
102
|
expanded: boolean
|
|
103
103
|
) {
|
|
104
104
|
const { variant } = this.props
|
|
105
|
+
// Do not put aria-controls and aria-expanded into the toggle if there
|
|
106
|
+
// is nothing to open
|
|
105
107
|
const tProps = this.props.children
|
|
106
108
|
? toggleProps
|
|
107
109
|
: { onClick: toggleProps.onClick }
|
|
@@ -118,14 +120,14 @@ class ToggleDetails extends Component<ToggleDetailsProps> {
|
|
|
118
120
|
{...props}
|
|
119
121
|
display="block"
|
|
120
122
|
textAlign="start"
|
|
121
|
-
elementRef={this.
|
|
123
|
+
elementRef={this.getButtonRef}
|
|
122
124
|
>
|
|
123
125
|
{summary}
|
|
124
126
|
</Button>
|
|
125
127
|
)
|
|
126
128
|
} else if (props.href) {
|
|
127
129
|
return (
|
|
128
|
-
<a {...props} css={this.props.styles?.toggle} ref={this.
|
|
130
|
+
<a {...props} css={this.props.styles?.toggle} ref={this.getButtonRef}>
|
|
129
131
|
{summary}
|
|
130
132
|
</a>
|
|
131
133
|
)
|
|
@@ -135,7 +137,7 @@ class ToggleDetails extends Component<ToggleDetailsProps> {
|
|
|
135
137
|
{...props}
|
|
136
138
|
type="button"
|
|
137
139
|
css={this.props.styles?.toggle}
|
|
138
|
-
ref={this.
|
|
140
|
+
ref={this.getButtonRef}
|
|
139
141
|
>
|
|
140
142
|
{summary}
|
|
141
143
|
</button>
|
|
@@ -186,8 +188,9 @@ class ToggleDetails extends Component<ToggleDetailsProps> {
|
|
|
186
188
|
return (
|
|
187
189
|
<div
|
|
188
190
|
css={this.props.styles?.toggleDetails}
|
|
189
|
-
ref={
|
|
190
|
-
|
|
191
|
+
ref={(el) => {
|
|
192
|
+
this.ref = el
|
|
193
|
+
}}
|
|
191
194
|
>
|
|
192
195
|
{this.renderToggle(getToggleProps(), expanded)}
|
|
193
196
|
{this.renderDetails(expanded, getDetailsProps())}
|