baseui 0.0.0-next-5855449 → 0.0.0-next-29453ad
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/accordion/accordion.js +60 -2
- package/accordion/accordion.js.flow +48 -0
- package/accordion/panel.js +6 -3
- package/accordion/panel.js.flow +20 -14
- package/es/accordion/accordion.js +52 -2
- package/es/accordion/panel.js +6 -3
- package/es/menu/stateful-container.js +0 -1
- package/esm/accordion/accordion.js +60 -2
- package/esm/accordion/panel.js +6 -3
- package/esm/menu/stateful-container.js +0 -1
- package/menu/stateful-container.js +0 -1
- package/menu/stateful-container.js.flow +0 -1
- package/package.json +1 -1
package/accordion/accordion.js
CHANGED
|
@@ -87,6 +87,8 @@ var Accordion = /*#__PURE__*/function (_React$Component) {
|
|
|
87
87
|
expanded: []
|
|
88
88
|
}, _this.props.initialState));
|
|
89
89
|
|
|
90
|
+
_defineProperty(_assertThisInitialized(_this), "itemRefs", []);
|
|
91
|
+
|
|
90
92
|
return _this;
|
|
91
93
|
}
|
|
92
94
|
|
|
@@ -133,6 +135,56 @@ var Accordion = /*#__PURE__*/function (_React$Component) {
|
|
|
133
135
|
this.setState(newState);
|
|
134
136
|
typeof onChange === 'function' && onChange(newState);
|
|
135
137
|
}
|
|
138
|
+
}, {
|
|
139
|
+
key: "handleKeyDown",
|
|
140
|
+
value: function handleKeyDown(e) {
|
|
141
|
+
if (this.props.disabled) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
var itemRefs = this.itemRefs;
|
|
146
|
+
var HOME = 36;
|
|
147
|
+
var END = 35;
|
|
148
|
+
var ARROW_UP = 38;
|
|
149
|
+
var ARROW_DOWN = 40;
|
|
150
|
+
|
|
151
|
+
if (e.keyCode === HOME) {
|
|
152
|
+
e.preventDefault();
|
|
153
|
+
var firstItem = itemRefs[0];
|
|
154
|
+
firstItem.current && firstItem.current.focus();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (e.keyCode === END) {
|
|
158
|
+
e.preventDefault();
|
|
159
|
+
var lastItem = itemRefs[itemRefs.length - 1];
|
|
160
|
+
lastItem.current && lastItem.current.focus();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (e.keyCode === ARROW_UP) {
|
|
164
|
+
e.preventDefault();
|
|
165
|
+
var activeItemIdx = itemRefs.findIndex(function (item) {
|
|
166
|
+
return item.current === document.activeElement;
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
if (activeItemIdx > 0) {
|
|
170
|
+
var prevItem = itemRefs[activeItemIdx - 1];
|
|
171
|
+
prevItem.current && prevItem.current.focus();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (e.keyCode === ARROW_DOWN) {
|
|
176
|
+
e.preventDefault();
|
|
177
|
+
|
|
178
|
+
var _activeItemIdx = itemRefs.findIndex(function (item) {
|
|
179
|
+
return item.current === document.activeElement;
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
if (_activeItemIdx < itemRefs.length - 1) {
|
|
183
|
+
var nextItem = itemRefs[_activeItemIdx + 1];
|
|
184
|
+
nextItem.current && nextItem.current.focus();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
136
188
|
}, {
|
|
137
189
|
key: "getItems",
|
|
138
190
|
value: function getItems() {
|
|
@@ -148,7 +200,11 @@ var Accordion = /*#__PURE__*/function (_React$Component) {
|
|
|
148
200
|
overrides = _this$props2.overrides; // flowlint-next-line unclear-type:off
|
|
149
201
|
|
|
150
202
|
return React.Children.map(children, function (child, index) {
|
|
151
|
-
if (!child) return;
|
|
203
|
+
if (!child) return;
|
|
204
|
+
var itemRef = /*#__PURE__*/React.createRef();
|
|
205
|
+
|
|
206
|
+
_this2.itemRefs.push(itemRef); // If there is no key provided use the panel order as a default key
|
|
207
|
+
|
|
152
208
|
|
|
153
209
|
var key = child.key || String(index);
|
|
154
210
|
var isExpanded = false;
|
|
@@ -161,6 +217,7 @@ var Accordion = /*#__PURE__*/function (_React$Component) {
|
|
|
161
217
|
|
|
162
218
|
var props = {
|
|
163
219
|
key: key,
|
|
220
|
+
ref: itemRef,
|
|
164
221
|
expanded: isExpanded || child.props.expanded,
|
|
165
222
|
accordion: accordion,
|
|
166
223
|
renderPanelContent: renderPanelContent,
|
|
@@ -201,7 +258,8 @@ var Accordion = /*#__PURE__*/function (_React$Component) {
|
|
|
201
258
|
return /*#__PURE__*/React.createElement(Root, _extends({
|
|
202
259
|
"data-baseweb": "accordion",
|
|
203
260
|
$disabled: this.props.disabled,
|
|
204
|
-
$isFocusVisible: false
|
|
261
|
+
$isFocusVisible: false,
|
|
262
|
+
onKeyDown: this.handleKeyDown.bind(this)
|
|
205
263
|
}, rootProps), this.getItems());
|
|
206
264
|
}
|
|
207
265
|
}]);
|
|
@@ -31,6 +31,8 @@ export default class Accordion extends React.Component<AccordionPropsT, Accordio
|
|
|
31
31
|
...this.props.initialState,
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
+
itemRefs = [];
|
|
35
|
+
|
|
34
36
|
//flowlint-next-line unclear-type:off
|
|
35
37
|
onPanelChange(key: React.Key, onChange: () => {}, ...args: Array<any>) {
|
|
36
38
|
let activeKeys = this.state.expanded;
|
|
@@ -61,12 +63,56 @@ export default class Accordion extends React.Component<AccordionPropsT, Accordio
|
|
|
61
63
|
typeof onChange === 'function' && onChange(newState);
|
|
62
64
|
}
|
|
63
65
|
|
|
66
|
+
handleKeyDown(e: KeyboardEvent) {
|
|
67
|
+
if (this.props.disabled) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const itemRefs = this.itemRefs;
|
|
72
|
+
|
|
73
|
+
const HOME = 36;
|
|
74
|
+
const END = 35;
|
|
75
|
+
const ARROW_UP = 38;
|
|
76
|
+
const ARROW_DOWN = 40;
|
|
77
|
+
|
|
78
|
+
if (e.keyCode === HOME) {
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
const firstItem = itemRefs[0];
|
|
81
|
+
firstItem.current && firstItem.current.focus();
|
|
82
|
+
}
|
|
83
|
+
if (e.keyCode === END) {
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
const lastItem = itemRefs[itemRefs.length - 1];
|
|
86
|
+
lastItem.current && lastItem.current.focus();
|
|
87
|
+
}
|
|
88
|
+
if (e.keyCode === ARROW_UP) {
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
const activeItemIdx = itemRefs.findIndex((item) => item.current === document.activeElement);
|
|
91
|
+
if (activeItemIdx > 0) {
|
|
92
|
+
const prevItem = itemRefs[activeItemIdx - 1];
|
|
93
|
+
prevItem.current && prevItem.current.focus();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (e.keyCode === ARROW_DOWN) {
|
|
97
|
+
e.preventDefault();
|
|
98
|
+
const activeItemIdx = itemRefs.findIndex((item) => item.current === document.activeElement);
|
|
99
|
+
if (activeItemIdx < itemRefs.length - 1) {
|
|
100
|
+
const nextItem = itemRefs[activeItemIdx + 1];
|
|
101
|
+
nextItem.current && nextItem.current.focus();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
64
106
|
getItems() {
|
|
65
107
|
const { expanded } = this.state;
|
|
66
108
|
const { accordion, disabled, children, renderPanelContent, renderAll, overrides } = this.props;
|
|
67
109
|
// flowlint-next-line unclear-type:off
|
|
68
110
|
return React.Children.map(children, (child: any, index) => {
|
|
69
111
|
if (!child) return;
|
|
112
|
+
|
|
113
|
+
const itemRef = React.createRef<HTMLDivElement>();
|
|
114
|
+
this.itemRefs.push(itemRef);
|
|
115
|
+
|
|
70
116
|
// If there is no key provided use the panel order as a default key
|
|
71
117
|
const key = child.key || String(index);
|
|
72
118
|
let isExpanded = false;
|
|
@@ -78,6 +124,7 @@ export default class Accordion extends React.Component<AccordionPropsT, Accordio
|
|
|
78
124
|
|
|
79
125
|
const props = {
|
|
80
126
|
key,
|
|
127
|
+
ref: itemRef,
|
|
81
128
|
expanded: isExpanded || child.props.expanded,
|
|
82
129
|
accordion,
|
|
83
130
|
renderPanelContent,
|
|
@@ -108,6 +155,7 @@ export default class Accordion extends React.Component<AccordionPropsT, Accordio
|
|
|
108
155
|
data-baseweb="accordion"
|
|
109
156
|
$disabled={this.props.disabled}
|
|
110
157
|
$isFocusVisible={false}
|
|
158
|
+
onKeyDown={this.handleKeyDown.bind(this)}
|
|
111
159
|
{...rootProps}
|
|
112
160
|
>
|
|
113
161
|
{this.getItems()}
|
package/accordion/panel.js
CHANGED
|
@@ -41,7 +41,7 @@ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(
|
|
|
41
41
|
|
|
42
42
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
43
43
|
|
|
44
|
-
var Panel = function Panel(_ref) {
|
|
44
|
+
var Panel = function Panel(_ref, ref) {
|
|
45
45
|
var ariaControls = _ref['aria-controls'],
|
|
46
46
|
children = _ref.children,
|
|
47
47
|
_ref$disabled = _ref.disabled,
|
|
@@ -214,7 +214,8 @@ var Panel = function Panel(_ref) {
|
|
|
214
214
|
onClick: handleClick,
|
|
215
215
|
onKeyDown: handleKeyDown,
|
|
216
216
|
onFocus: (0, _focusVisible.forkFocus)(headerProps, handleFocus),
|
|
217
|
-
onBlur: (0, _focusVisible.forkBlur)(headerProps, handleBlur)
|
|
217
|
+
onBlur: (0, _focusVisible.forkBlur)(headerProps, handleBlur),
|
|
218
|
+
ref: ref
|
|
218
219
|
}), title, /*#__PURE__*/React.createElement(ToggleIcon, _extends({
|
|
219
220
|
viewBox: "0 0 24 24",
|
|
220
221
|
title: localState.expanded ? locale.accordion.collapse : locale.accordion.expand,
|
|
@@ -244,5 +245,7 @@ var Panel = function Panel(_ref) {
|
|
|
244
245
|
});
|
|
245
246
|
};
|
|
246
247
|
|
|
247
|
-
var
|
|
248
|
+
var ForwardedPanel = /*#__PURE__*/React.forwardRef(Panel);
|
|
249
|
+
ForwardedPanel.displayName = 'Panel';
|
|
250
|
+
var _default = ForwardedPanel;
|
|
248
251
|
exports.default = _default;
|
package/accordion/panel.js.flow
CHANGED
|
@@ -20,19 +20,22 @@ import { isFocusVisible, forkFocus, forkBlur } from '../utils/focusVisible.js';
|
|
|
20
20
|
|
|
21
21
|
import type { PanelPropsT } from './types.js';
|
|
22
22
|
|
|
23
|
-
const Panel = (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
23
|
+
const Panel = (
|
|
24
|
+
{
|
|
25
|
+
'aria-controls': ariaControls,
|
|
26
|
+
children,
|
|
27
|
+
disabled = false,
|
|
28
|
+
expanded = false,
|
|
29
|
+
onChange = () => {},
|
|
30
|
+
onClick = () => {},
|
|
31
|
+
onKeyDown = () => {},
|
|
32
|
+
overrides = {},
|
|
33
|
+
title = '',
|
|
34
|
+
renderPanelContent = false,
|
|
35
|
+
renderAll = false,
|
|
36
|
+
}: PanelPropsT,
|
|
37
|
+
ref
|
|
38
|
+
) => {
|
|
36
39
|
const [localState, setLocalState] = React.useState({
|
|
37
40
|
expanded,
|
|
38
41
|
isFocusVisible: false,
|
|
@@ -176,6 +179,7 @@ const Panel = ({
|
|
|
176
179
|
onKeyDown={handleKeyDown}
|
|
177
180
|
onFocus={forkFocus(headerProps, handleFocus)}
|
|
178
181
|
onBlur={forkBlur(headerProps, handleBlur)}
|
|
182
|
+
ref={ref}
|
|
179
183
|
>
|
|
180
184
|
{title}
|
|
181
185
|
<ToggleIcon
|
|
@@ -229,7 +233,9 @@ const Panel = ({
|
|
|
229
233
|
);
|
|
230
234
|
};
|
|
231
235
|
|
|
232
|
-
|
|
236
|
+
const ForwardedPanel = React.forwardRef<PanelPropsT, HTMLElement>(Panel);
|
|
237
|
+
ForwardedPanel.displayName = 'Panel';
|
|
238
|
+
export default ForwardedPanel;
|
|
233
239
|
|
|
234
240
|
declare var __DEV__: boolean;
|
|
235
241
|
declare var __NODE__: boolean;
|
|
@@ -22,6 +22,8 @@ export default class Accordion extends React.Component {
|
|
|
22
22
|
expanded: [],
|
|
23
23
|
...this.props.initialState
|
|
24
24
|
});
|
|
25
|
+
|
|
26
|
+
_defineProperty(this, "itemRefs", []);
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
//flowlint-next-line unclear-type:off
|
|
@@ -64,6 +66,50 @@ export default class Accordion extends React.Component {
|
|
|
64
66
|
typeof onChange === 'function' && onChange(newState);
|
|
65
67
|
}
|
|
66
68
|
|
|
69
|
+
handleKeyDown(e) {
|
|
70
|
+
if (this.props.disabled) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const itemRefs = this.itemRefs;
|
|
75
|
+
const HOME = 36;
|
|
76
|
+
const END = 35;
|
|
77
|
+
const ARROW_UP = 38;
|
|
78
|
+
const ARROW_DOWN = 40;
|
|
79
|
+
|
|
80
|
+
if (e.keyCode === HOME) {
|
|
81
|
+
e.preventDefault();
|
|
82
|
+
const firstItem = itemRefs[0];
|
|
83
|
+
firstItem.current && firstItem.current.focus();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (e.keyCode === END) {
|
|
87
|
+
e.preventDefault();
|
|
88
|
+
const lastItem = itemRefs[itemRefs.length - 1];
|
|
89
|
+
lastItem.current && lastItem.current.focus();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (e.keyCode === ARROW_UP) {
|
|
93
|
+
e.preventDefault();
|
|
94
|
+
const activeItemIdx = itemRefs.findIndex(item => item.current === document.activeElement);
|
|
95
|
+
|
|
96
|
+
if (activeItemIdx > 0) {
|
|
97
|
+
const prevItem = itemRefs[activeItemIdx - 1];
|
|
98
|
+
prevItem.current && prevItem.current.focus();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (e.keyCode === ARROW_DOWN) {
|
|
103
|
+
e.preventDefault();
|
|
104
|
+
const activeItemIdx = itemRefs.findIndex(item => item.current === document.activeElement);
|
|
105
|
+
|
|
106
|
+
if (activeItemIdx < itemRefs.length - 1) {
|
|
107
|
+
const nextItem = itemRefs[activeItemIdx + 1];
|
|
108
|
+
nextItem.current && nextItem.current.focus();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
67
113
|
getItems() {
|
|
68
114
|
const {
|
|
69
115
|
expanded
|
|
@@ -78,7 +124,9 @@ export default class Accordion extends React.Component {
|
|
|
78
124
|
} = this.props; // flowlint-next-line unclear-type:off
|
|
79
125
|
|
|
80
126
|
return React.Children.map(children, (child, index) => {
|
|
81
|
-
if (!child) return;
|
|
127
|
+
if (!child) return;
|
|
128
|
+
const itemRef = /*#__PURE__*/React.createRef();
|
|
129
|
+
this.itemRefs.push(itemRef); // If there is no key provided use the panel order as a default key
|
|
82
130
|
|
|
83
131
|
const key = child.key || String(index);
|
|
84
132
|
let isExpanded = false;
|
|
@@ -91,6 +139,7 @@ export default class Accordion extends React.Component {
|
|
|
91
139
|
|
|
92
140
|
const props = {
|
|
93
141
|
key,
|
|
142
|
+
ref: itemRef,
|
|
94
143
|
expanded: isExpanded || child.props.expanded,
|
|
95
144
|
accordion,
|
|
96
145
|
renderPanelContent,
|
|
@@ -121,7 +170,8 @@ export default class Accordion extends React.Component {
|
|
|
121
170
|
return /*#__PURE__*/React.createElement(Root, _extends({
|
|
122
171
|
"data-baseweb": "accordion",
|
|
123
172
|
$disabled: this.props.disabled,
|
|
124
|
-
$isFocusVisible: false
|
|
173
|
+
$isFocusVisible: false,
|
|
174
|
+
onKeyDown: this.handleKeyDown.bind(this)
|
|
125
175
|
}, rootProps), this.getItems());
|
|
126
176
|
}
|
|
127
177
|
|
package/es/accordion/panel.js
CHANGED
|
@@ -24,7 +24,7 @@ const Panel = ({
|
|
|
24
24
|
title = '',
|
|
25
25
|
renderPanelContent = false,
|
|
26
26
|
renderAll = false
|
|
27
|
-
}) => {
|
|
27
|
+
}, ref) => {
|
|
28
28
|
const [localState, setLocalState] = React.useState({
|
|
29
29
|
expanded,
|
|
30
30
|
isFocusVisible: false,
|
|
@@ -148,7 +148,8 @@ const Panel = ({
|
|
|
148
148
|
onClick: handleClick,
|
|
149
149
|
onKeyDown: handleKeyDown,
|
|
150
150
|
onFocus: forkFocus(headerProps, handleFocus),
|
|
151
|
-
onBlur: forkBlur(headerProps, handleBlur)
|
|
151
|
+
onBlur: forkBlur(headerProps, handleBlur),
|
|
152
|
+
ref: ref
|
|
152
153
|
}), title, /*#__PURE__*/React.createElement(ToggleIcon, _extends({
|
|
153
154
|
viewBox: "0 0 24 24",
|
|
154
155
|
title: localState.expanded ? locale.accordion.collapse : locale.accordion.expand,
|
|
@@ -177,4 +178,6 @@ const Panel = ({
|
|
|
177
178
|
} : {}), localState.expanded || renderAll || renderPanelContent || localState.animationInProgress ? children : null))));
|
|
178
179
|
};
|
|
179
180
|
|
|
180
|
-
|
|
181
|
+
const ForwardedPanel = /*#__PURE__*/React.forwardRef(Panel);
|
|
182
|
+
ForwardedPanel.displayName = 'Panel';
|
|
183
|
+
export default ForwardedPanel;
|
|
@@ -98,7 +98,6 @@ class MenuStatefulContainerInner extends React.Component {
|
|
|
98
98
|
this.typeAheadChars = '';
|
|
99
99
|
}, 500);
|
|
100
100
|
var nextIndex = prevIndex;
|
|
101
|
-
event.preventDefault();
|
|
102
101
|
var list = this.getItems();
|
|
103
102
|
if (list.length === 0 || !('label' in list[0])) return;
|
|
104
103
|
var notMatch = true;
|
|
@@ -81,6 +81,8 @@ var Accordion = /*#__PURE__*/function (_React$Component) {
|
|
|
81
81
|
expanded: []
|
|
82
82
|
}, _this.props.initialState));
|
|
83
83
|
|
|
84
|
+
_defineProperty(_assertThisInitialized(_this), "itemRefs", []);
|
|
85
|
+
|
|
84
86
|
return _this;
|
|
85
87
|
}
|
|
86
88
|
|
|
@@ -127,6 +129,56 @@ var Accordion = /*#__PURE__*/function (_React$Component) {
|
|
|
127
129
|
this.setState(newState);
|
|
128
130
|
typeof onChange === 'function' && onChange(newState);
|
|
129
131
|
}
|
|
132
|
+
}, {
|
|
133
|
+
key: "handleKeyDown",
|
|
134
|
+
value: function handleKeyDown(e) {
|
|
135
|
+
if (this.props.disabled) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
var itemRefs = this.itemRefs;
|
|
140
|
+
var HOME = 36;
|
|
141
|
+
var END = 35;
|
|
142
|
+
var ARROW_UP = 38;
|
|
143
|
+
var ARROW_DOWN = 40;
|
|
144
|
+
|
|
145
|
+
if (e.keyCode === HOME) {
|
|
146
|
+
e.preventDefault();
|
|
147
|
+
var firstItem = itemRefs[0];
|
|
148
|
+
firstItem.current && firstItem.current.focus();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (e.keyCode === END) {
|
|
152
|
+
e.preventDefault();
|
|
153
|
+
var lastItem = itemRefs[itemRefs.length - 1];
|
|
154
|
+
lastItem.current && lastItem.current.focus();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (e.keyCode === ARROW_UP) {
|
|
158
|
+
e.preventDefault();
|
|
159
|
+
var activeItemIdx = itemRefs.findIndex(function (item) {
|
|
160
|
+
return item.current === document.activeElement;
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
if (activeItemIdx > 0) {
|
|
164
|
+
var prevItem = itemRefs[activeItemIdx - 1];
|
|
165
|
+
prevItem.current && prevItem.current.focus();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (e.keyCode === ARROW_DOWN) {
|
|
170
|
+
e.preventDefault();
|
|
171
|
+
|
|
172
|
+
var _activeItemIdx = itemRefs.findIndex(function (item) {
|
|
173
|
+
return item.current === document.activeElement;
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
if (_activeItemIdx < itemRefs.length - 1) {
|
|
177
|
+
var nextItem = itemRefs[_activeItemIdx + 1];
|
|
178
|
+
nextItem.current && nextItem.current.focus();
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
130
182
|
}, {
|
|
131
183
|
key: "getItems",
|
|
132
184
|
value: function getItems() {
|
|
@@ -142,7 +194,11 @@ var Accordion = /*#__PURE__*/function (_React$Component) {
|
|
|
142
194
|
overrides = _this$props2.overrides; // flowlint-next-line unclear-type:off
|
|
143
195
|
|
|
144
196
|
return React.Children.map(children, function (child, index) {
|
|
145
|
-
if (!child) return;
|
|
197
|
+
if (!child) return;
|
|
198
|
+
var itemRef = /*#__PURE__*/React.createRef();
|
|
199
|
+
|
|
200
|
+
_this2.itemRefs.push(itemRef); // If there is no key provided use the panel order as a default key
|
|
201
|
+
|
|
146
202
|
|
|
147
203
|
var key = child.key || String(index);
|
|
148
204
|
var isExpanded = false;
|
|
@@ -155,6 +211,7 @@ var Accordion = /*#__PURE__*/function (_React$Component) {
|
|
|
155
211
|
|
|
156
212
|
var props = {
|
|
157
213
|
key: key,
|
|
214
|
+
ref: itemRef,
|
|
158
215
|
expanded: isExpanded || child.props.expanded,
|
|
159
216
|
accordion: accordion,
|
|
160
217
|
renderPanelContent: renderPanelContent,
|
|
@@ -195,7 +252,8 @@ var Accordion = /*#__PURE__*/function (_React$Component) {
|
|
|
195
252
|
return /*#__PURE__*/React.createElement(Root, _extends({
|
|
196
253
|
"data-baseweb": "accordion",
|
|
197
254
|
$disabled: this.props.disabled,
|
|
198
|
-
$isFocusVisible: false
|
|
255
|
+
$isFocusVisible: false,
|
|
256
|
+
onKeyDown: this.handleKeyDown.bind(this)
|
|
199
257
|
}, rootProps), this.getItems());
|
|
200
258
|
}
|
|
201
259
|
}]);
|
package/esm/accordion/panel.js
CHANGED
|
@@ -30,7 +30,7 @@ import { getOverrides } from '../helpers/overrides.js';
|
|
|
30
30
|
import { PanelContainer as StyledPanelContainer, Header as StyledHeader, Content as StyledContent, ToggleIcon as StyledToggleIcon, ToggleIconGroup as StyledToggleIconGroup, ContentAnimationContainer as StyledContentAnimationContainer } from './styled-components.js';
|
|
31
31
|
import { isFocusVisible, forkFocus, forkBlur } from '../utils/focusVisible.js';
|
|
32
32
|
|
|
33
|
-
var Panel = function Panel(_ref) {
|
|
33
|
+
var Panel = function Panel(_ref, ref) {
|
|
34
34
|
var ariaControls = _ref['aria-controls'],
|
|
35
35
|
children = _ref.children,
|
|
36
36
|
_ref$disabled = _ref.disabled,
|
|
@@ -203,7 +203,8 @@ var Panel = function Panel(_ref) {
|
|
|
203
203
|
onClick: handleClick,
|
|
204
204
|
onKeyDown: handleKeyDown,
|
|
205
205
|
onFocus: forkFocus(headerProps, handleFocus),
|
|
206
|
-
onBlur: forkBlur(headerProps, handleBlur)
|
|
206
|
+
onBlur: forkBlur(headerProps, handleBlur),
|
|
207
|
+
ref: ref
|
|
207
208
|
}), title, /*#__PURE__*/React.createElement(ToggleIcon, _extends({
|
|
208
209
|
viewBox: "0 0 24 24",
|
|
209
210
|
title: localState.expanded ? locale.accordion.collapse : locale.accordion.expand,
|
|
@@ -233,4 +234,6 @@ var Panel = function Panel(_ref) {
|
|
|
233
234
|
});
|
|
234
235
|
};
|
|
235
236
|
|
|
236
|
-
|
|
237
|
+
var ForwardedPanel = /*#__PURE__*/React.forwardRef(Panel);
|
|
238
|
+
ForwardedPanel.displayName = 'Panel';
|
|
239
|
+
export default ForwardedPanel;
|