@pingux/astro 1.5.0-alpha.0 → 1.5.0

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.
@@ -0,0 +1,210 @@
1
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
2
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
3
+ import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
4
+ import _findIndexInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find-index";
5
+ import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
6
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
7
+ import _someInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/some";
8
+ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
9
+ import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
10
+ import React, { forwardRef, useEffect, useMemo, useRef, useState } from 'react';
11
+ import PropTypes from 'prop-types';
12
+ import { Item as Tab } from '@react-stately/collections';
13
+ import ArrowDropUpIcon from 'mdi-react/ArrowDropUpIcon';
14
+ import ArrowDropDownIcon from 'mdi-react/ArrowDropDownIcon';
15
+ import { useStatusClasses } from '../../hooks';
16
+ import { Box, Text, Button, PopoverMenu, Icon, Menu } from '../..';
17
+ import { TabLine } from '../Tab';
18
+ /* istanbul ignore next */
19
+
20
+ import { jsx as ___EmotionJSX } from "@emotion/react";
21
+ var TabPicker = /*#__PURE__*/forwardRef(function (_ref, ref) {
22
+ var className = _ref.className,
23
+ items = _ref.items,
24
+ state = _ref.state,
25
+ item = _ref.item,
26
+ others = _objectWithoutProperties(_ref, ["className", "items", "state", "item"]);
27
+
28
+ var _useState = useState(false),
29
+ _useState2 = _slicedToArray(_useState, 2),
30
+ isOpen = _useState2[0],
31
+ setIsOpen = _useState2[1];
32
+
33
+ var _useState3 = useState(state.selectedKey),
34
+ _useState4 = _slicedToArray(_useState3, 2),
35
+ selectedItem = _useState4[0],
36
+ setSelectedItem = _useState4[1];
37
+
38
+ var selectionManager = state.selectionManager;
39
+
40
+ var _useState5 = useState(selectionManager.focusedKey),
41
+ _useState6 = _slicedToArray(_useState5, 2),
42
+ focusedItem = _useState6[0],
43
+ setFocusedItem = _useState6[1];
44
+
45
+ var isTabFocused = selectionManager.focusedKey === item.key;
46
+ var isTabSelected = state.selectedKey === item.key;
47
+
48
+ var isListItemFocused = _someInstanceProperty(items).call(items, function (el) {
49
+ return el.key === selectionManager.focusedKey;
50
+ });
51
+
52
+ var isListItemSelected = _someInstanceProperty(items).call(items, function (el) {
53
+ return el.key === state.selectedKey;
54
+ });
55
+
56
+ var _useMemo = useMemo(function () {
57
+ var _context, _tabs$prevIndex, _tabs$nextIndex;
58
+
59
+ var tabs = _filterInstanceProperty(_context = _Array$from(state.collection)).call(_context, function (tab) {
60
+ var _tab$value;
61
+
62
+ return !(tab === null || tab === void 0 ? void 0 : (_tab$value = tab.value) === null || _tab$value === void 0 ? void 0 : _tab$value.isListItem);
63
+ });
64
+
65
+ var prevIndex = _findIndexInstanceProperty(tabs).call(tabs, function (tab) {
66
+ return tab.key === item.key;
67
+ }) - 1;
68
+ var nextIndex = _findIndexInstanceProperty(tabs).call(tabs, function (tab) {
69
+ return tab.key === item.key;
70
+ }) + 1;
71
+ return {
72
+ prevKey: ((_tabs$prevIndex = tabs[prevIndex]) === null || _tabs$prevIndex === void 0 ? void 0 : _tabs$prevIndex.key) || tabs[tabs.length].key,
73
+ nextKey: ((_tabs$nextIndex = tabs[nextIndex]) === null || _tabs$nextIndex === void 0 ? void 0 : _tabs$nextIndex.key) || tabs[0].key
74
+ };
75
+ }, []),
76
+ prevKey = _useMemo.prevKey,
77
+ nextKey = _useMemo.nextKey;
78
+
79
+ var _useStatusClasses = useStatusClasses(className, {
80
+ isSelected: isListItemSelected
81
+ }),
82
+ classNames = _useStatusClasses.classNames;
83
+
84
+ var menuRef = useRef();
85
+
86
+ var handleSelectedItem = function handleSelectedItem(currentItem) {
87
+ state.setSelectedKey(currentItem);
88
+ setFocusedItem(currentItem);
89
+ };
90
+
91
+ useEffect(function () {
92
+ if (selectedItem) {
93
+ handleSelectedItem(selectedItem);
94
+ }
95
+ }, [selectedItem]);
96
+ useEffect(function () {
97
+ if (focusedItem) {
98
+ selectionManager.setFocusedKey(focusedItem);
99
+ }
100
+ }, [focusedItem]);
101
+ useEffect(function () {
102
+ if (isOpen && (isTabFocused || isListItemSelected) && menuRef.current) {
103
+ if (focusedItem) {
104
+ var _context2;
105
+
106
+ _findInstanceProperty(_context2 = _Array$from(menuRef.current.children)).call(_context2, function (el) {
107
+ return el.dataset.key === focusedItem;
108
+ }).focus();
109
+ } else {
110
+ menuRef.current.firstChild.focus();
111
+ }
112
+ }
113
+
114
+ if (!isOpen && isTabSelected && !selectedItem) {
115
+ setSelectedItem(selectionManager.focusedKey);
116
+ }
117
+ }, [isOpen]);
118
+ useEffect(function () {
119
+ if (isOpen && isListItemFocused) {
120
+ setFocusedItem(selectionManager.focusedKey);
121
+ } else if (!isOpen && isListItemFocused) {
122
+ selectionManager.setFocusedKey(item.key);
123
+ }
124
+ }, [selectionManager.focusedKey]);
125
+ useEffect(function () {
126
+ if (isTabSelected || isTabFocused) {
127
+ if (selectedItem) {
128
+ handleSelectedItem(selectedItem);
129
+ } else if (isListItemSelected && !selectedItem) {
130
+ setSelectedItem(state.selectedKey);
131
+ } else {
132
+ setFocusedItem(items[0].key);
133
+ }
134
+ } else if (!isListItemSelected && !isListItemFocused) {
135
+ setIsOpen(false);
136
+ setSelectedItem(null);
137
+ setFocusedItem(null);
138
+ }
139
+ }, [isTabSelected, isListItemSelected]);
140
+
141
+ var handleKeyNavigation = function handleKeyNavigation(e) {
142
+ switch (e.key) {
143
+ case 'ArrowRight':
144
+ {
145
+ selectionManager.setFocusedKey(nextKey);
146
+ break;
147
+ }
148
+
149
+ case 'ArrowLeft':
150
+ {
151
+ selectionManager.setFocusedKey(prevKey);
152
+ break;
153
+ }
154
+
155
+ default:
156
+ break;
157
+ }
158
+ };
159
+
160
+ var tabProps = others;
161
+ delete tabProps.onPointerDown;
162
+ delete tabProps.onKeyDown;
163
+ return ___EmotionJSX(PopoverMenu, {
164
+ onOpenChange: setIsOpen,
165
+ isOpen: isOpen,
166
+ isContainFocus: true
167
+ }, ___EmotionJSX(Button, {
168
+ className: classNames,
169
+ variant: "menuTab",
170
+ onKeyDown: handleKeyNavigation
171
+ }, ___EmotionJSX(Box, _extends({
172
+ className: classNames,
173
+ variant: "tab",
174
+ ref: ref
175
+ }, tabProps), ___EmotionJSX(Text, {
176
+ variant: "tabLabel"
177
+ }, item.props.name), selectedItem && ___EmotionJSX(TabLine, null)), ___EmotionJSX(Icon, {
178
+ icon: isOpen ? ArrowDropUpIcon : ArrowDropDownIcon
179
+ })), ___EmotionJSX(Menu, {
180
+ onAction: setSelectedItem,
181
+ selectionMode: "single",
182
+ selectedKeys: [selectionManager.focusedKey],
183
+ ref: menuRef
184
+ }, _mapInstanceProperty(items).call(items, function (tab) {
185
+ return ___EmotionJSX(Tab, {
186
+ key: tab.key
187
+ }, tab.name);
188
+ })));
189
+ });
190
+ TabPicker.propTypes = {
191
+ item: PropTypes.shape({
192
+ key: PropTypes.string,
193
+ props: PropTypes.shape({
194
+ name: PropTypes.string
195
+ })
196
+ }),
197
+ items: PropTypes.arrayOf(PropTypes.shape({
198
+ key: PropTypes.string
199
+ })),
200
+ state: PropTypes.shape({
201
+ collection: PropTypes.shape({}),
202
+ selectedKey: PropTypes.string,
203
+ setSelectedKey: PropTypes["function"],
204
+ selectionManager: PropTypes.shape({
205
+ focusedKey: PropTypes.string,
206
+ setFocusedKey: PropTypes["function"]
207
+ })
208
+ })
209
+ };
210
+ export default TabPicker;
@@ -0,0 +1 @@
1
+ export { default } from './TabPicker';
@@ -1,20 +1,21 @@
1
1
  import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
2
2
  import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
3
3
  import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
4
- import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
5
4
  import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
6
- import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
7
5
  import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
8
6
  import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
9
7
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
10
8
  import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
11
- import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
9
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
12
10
  import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
11
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
12
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
13
+ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
13
14
  import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
14
15
 
15
16
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
16
17
 
17
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context2; _forEachInstanceProperty(_context2 = ownKeys(Object(source), true)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context3; _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
18
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context6; _forEachInstanceProperty(_context6 = ownKeys(Object(source), true)).call(_context6, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context7; _forEachInstanceProperty(_context7 = ownKeys(Object(source))).call(_context7, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
18
19
 
19
20
  import React, { forwardRef, useImperativeHandle, useRef } from 'react';
20
21
  import PropTypes from 'prop-types';
@@ -27,16 +28,17 @@ import { usePropWarning } from '../../hooks';
27
28
  import { jsx as ___EmotionJSX } from "@emotion/react";
28
29
  export var TabsContext = /*#__PURE__*/React.createContext({});
29
30
  var Tabs = /*#__PURE__*/forwardRef(function (props, ref) {
30
- var _context;
31
+ var _context4, _context5;
31
32
 
32
33
  var children = props.children,
33
34
  isDisabled = props.isDisabled,
35
+ items = props.items,
34
36
  onSelectionChange = props.onSelectionChange,
35
37
  orientation = props.orientation,
36
38
  mode = props.mode,
37
39
  tabListProps = props.tabListProps,
38
40
  tabPanelProps = props.tabPanelProps,
39
- others = _objectWithoutProperties(props, ["children", "isDisabled", "onSelectionChange", "orientation", "mode", "tabListProps", "tabPanelProps"]);
41
+ others = _objectWithoutProperties(props, ["children", "isDisabled", "items", "onSelectionChange", "orientation", "mode", "tabListProps", "tabPanelProps"]);
40
42
 
41
43
  var tabListRef = useRef();
42
44
  usePropWarning(props, 'disabled', 'isDisabled');
@@ -51,8 +53,31 @@ var Tabs = /*#__PURE__*/forwardRef(function (props, ref) {
51
53
  useImperativeHandle(ref, function () {
52
54
  return tabPanelRef.current;
53
55
  });
56
+ var allItems = [];
57
+
58
+ if (mode === 'list') {
59
+ _forEachInstanceProperty(items).call(items, function (item) {
60
+ var _context;
61
+
62
+ allItems = _concatInstanceProperty(_context = []).call(_context, allItems, [item]);
63
+
64
+ if (item.list) {
65
+ var _context2, _context3;
66
+
67
+ var list = _mapInstanceProperty(_context2 = item.list).call(_context2, function (el) {
68
+ return _objectSpread(_objectSpread({}, el), {}, {
69
+ isListItem: true
70
+ });
71
+ });
72
+
73
+ allItems = _concatInstanceProperty(_context3 = []).call(_context3, allItems, list);
74
+ }
75
+ });
76
+ }
77
+
54
78
  var state = useTabListState(_objectSpread(_objectSpread({}, props), {}, {
55
- onSelectionChange: onSelectionChange
79
+ onSelectionChange: onSelectionChange,
80
+ items: mode === 'list' ? allItems : items
56
81
  }));
57
82
 
58
83
  var _useTabList = useTabList(props, state, tabListRef),
@@ -70,7 +95,11 @@ var Tabs = /*#__PURE__*/forwardRef(function (props, ref) {
70
95
  isRow: orientation === ORIENTATION.HORIZONTAL
71
96
  }, tabListProps, raTabListProps, {
72
97
  ref: tabListRef
73
- }), _mapInstanceProperty(_context = _Array$from(state.collection)).call(_context, function (item) {
98
+ }), _mapInstanceProperty(_context4 = _filterInstanceProperty(_context5 = _Array$from(state.collection)).call(_context5, function (item) {
99
+ var _item$value;
100
+
101
+ return !(item === null || item === void 0 ? void 0 : (_item$value = item.value) === null || _item$value === void 0 ? void 0 : _item$value.isListItem);
102
+ })).call(_context4, function (item) {
74
103
  var _item$props;
75
104
 
76
105
  return ___EmotionJSX(CollectionTab, {
@@ -100,7 +129,7 @@ Tabs.propTypes = {
100
129
  orientation: PropTypes.oneOf(['horizontal', 'vertical']),
101
130
 
102
131
  /** Determines the behavior model for the tabs. */
103
- mode: PropTypes.oneOf(['default', 'tooltip']),
132
+ mode: PropTypes.oneOf(['default', 'tooltip', 'list']),
104
133
 
105
134
  /**
106
135
  * *For performance reasons, use this prop instead of Array.map when iteratively rendering Items*.
@@ -118,12 +147,16 @@ Tabs.propTypes = {
118
147
  tabListProps: PropTypes.shape({}),
119
148
 
120
149
  /** Props object that is spread directly into all of the tab panel wrapper elements. */
121
- tabPanelProps: PropTypes.shape({})
150
+ tabPanelProps: PropTypes.shape({}),
151
+
152
+ /** Whether tabs are activated automatically on focus or manually¸ */
153
+ keyboardActivation: PropTypes.oneOf(['automatic', 'manual'])
122
154
  };
123
155
  Tabs.defaultProps = {
124
156
  isDisabled: false,
125
157
  orientation: 'horizontal',
126
- mode: 'default'
158
+ mode: 'default',
159
+ keyboardActivation: 'manual'
127
160
  };
128
161
  Tabs.displayName = 'Tabs';
129
162
  export default Tabs;
@@ -1,3 +1,4 @@
1
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
1
2
  import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
2
3
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
3
4
  import React, { useState } from 'react';
@@ -225,4 +226,30 @@ export var ContentSlots = function ContentSlots() {
225
226
  afterTab: afterTabNode
226
227
  }
227
228
  }, ___EmotionJSX(Text, null, "Users Matched"))));
229
+ };
230
+ export var WithList = function WithList() {
231
+ var _context;
232
+
233
+ var allTabs = _concatInstanceProperty(_context = []).call(_context, tabs, [{
234
+ name: 'Tab 4',
235
+ list: [{
236
+ key: 'tab1list',
237
+ name: 'Tab 1 list',
238
+ children: 'Tab 1 from list'
239
+ }, {
240
+ key: 'tab2list',
241
+ name: 'Tab 2 list',
242
+ children: 'Tab 2 from list'
243
+ }]
244
+ }]);
245
+
246
+ return ___EmotionJSX(Tabs, {
247
+ items: allTabs,
248
+ mode: "list"
249
+ }, function (item) {
250
+ return ___EmotionJSX(Tab, _extends({
251
+ key: item.name,
252
+ title: item.name
253
+ }, item), item.children);
254
+ });
228
255
  };
@@ -4,6 +4,7 @@ import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerat
4
4
  import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
5
5
  import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
6
6
  import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
7
+ import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
7
8
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
8
9
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
9
10
  import React from 'react';
@@ -33,6 +34,21 @@ var defaultTabs = [{
33
34
  name: 'Tab 3',
34
35
  children: 'Tab 3 body'
35
36
  }];
37
+ var tabsWithList = [{
38
+ name: 'Tab 1',
39
+ children: 'Tab 1 body'
40
+ }, {
41
+ name: 'Tab 2',
42
+ list: [{
43
+ key: 'tab1list',
44
+ name: 'Tab 1 list',
45
+ children: 'Tab 1 from list'
46
+ }, {
47
+ key: 'tab2list',
48
+ name: 'Tab 2 list',
49
+ children: 'Tab 2 from list'
50
+ }]
51
+ }];
36
52
  var defaultProps = {
37
53
  'data-testid': testId,
38
54
  defaultSelectedKey: defaultTabs[0].name
@@ -60,6 +76,21 @@ var getComponent = function getComponent() {
60
76
  }))));
61
77
  };
62
78
 
79
+ var getComponentWithDynamicItems = function getComponentWithDynamicItems(props) {
80
+ return render(___EmotionJSX(CacheProvider, {
81
+ value: emotionCache
82
+ }, ___EmotionJSX(Tabs, props, function (_ref3) {
83
+ var name = _ref3.name,
84
+ children = _ref3.children,
85
+ tabProps = _objectWithoutProperties(_ref3, ["name", "children"]);
86
+
87
+ return ___EmotionJSX(Tab, _extends({
88
+ key: name,
89
+ title: name
90
+ }, tabProps), children);
91
+ })));
92
+ };
93
+
63
94
  var getTabs = function getTabs() {
64
95
  var tabs = screen.queryAllByRole('tab');
65
96
 
@@ -77,8 +108,8 @@ var getTabs = function getTabs() {
77
108
  };
78
109
 
79
110
  var testTabPanel = function testTabPanel(expectedTabIndex) {
80
- return _forEachInstanceProperty(defaultTabs).call(defaultTabs, function (_ref3, index) {
81
- var children = _ref3.children;
111
+ return _forEachInstanceProperty(defaultTabs).call(defaultTabs, function (_ref4, index) {
112
+ var children = _ref4.children;
82
113
  return index === expectedTabIndex ? expect(screen.queryByText(children)).toBeInTheDocument() : expect(screen.queryByText(children)).not.toBeInTheDocument();
83
114
  });
84
115
  };
@@ -138,7 +169,7 @@ test('interacting with tabs via click', function () {
138
169
  testSingleTab(tabs, tab0, 'toContainElement', [screen.getByRole('presentation')]);
139
170
  testTabPanel(0);
140
171
  });
141
- test('interacting with tabs via focus -- horizontal', function () {
172
+ test('interacting with tabs with manual activation', function () {
142
173
  getComponent();
143
174
 
144
175
  var _getTabs2 = getTabs(),
@@ -150,6 +181,36 @@ test('interacting with tabs via focus -- horizontal', function () {
150
181
  return expect(tab).not.toHaveFocus();
151
182
  });
152
183
 
184
+ userEvent.tab();
185
+ testSingleTab(tabs, tab0, 'toHaveFocus');
186
+ testTabPanel(0);
187
+ fireEvent.keyDown(tab0, {
188
+ key: 'ArrowRight',
189
+ code: 'ArrowRight'
190
+ });
191
+ testSingleTab(tabs, tab1, 'toHaveFocus');
192
+ testTabPanel(0);
193
+ fireEvent.keyDown(tab1, {
194
+ key: 'Enter',
195
+ code: 'Enter'
196
+ });
197
+ testSingleTab(tabs, tab1, 'toHaveFocus');
198
+ testTabPanel(1);
199
+ });
200
+ test('interacting with tabs via focus -- horizontal', function () {
201
+ getComponent({
202
+ keyboardActivation: 'automatic'
203
+ });
204
+
205
+ var _getTabs3 = getTabs(),
206
+ tabs = _getTabs3.tabs,
207
+ tab0 = _getTabs3.tab0,
208
+ tab1 = _getTabs3.tab1;
209
+
210
+ _forEachInstanceProperty(tabs).call(tabs, function (tab) {
211
+ return expect(tab).not.toHaveFocus();
212
+ });
213
+
153
214
  userEvent.tab();
154
215
  testSingleTab(tabs, tab0, 'toHaveFocus');
155
216
  testTabPanel(0);
@@ -168,13 +229,14 @@ test('interacting with tabs via focus -- horizontal', function () {
168
229
  });
169
230
  test('interacting with tabs via focus -- vertical', function () {
170
231
  getComponent({
171
- orientation: 'vertical'
232
+ orientation: 'vertical',
233
+ keyboardActivation: 'automatic'
172
234
  });
173
235
 
174
- var _getTabs3 = getTabs(),
175
- tabs = _getTabs3.tabs,
176
- tab0 = _getTabs3.tab0,
177
- tab1 = _getTabs3.tab1;
236
+ var _getTabs4 = getTabs(),
237
+ tabs = _getTabs4.tabs,
238
+ tab0 = _getTabs4.tab0,
239
+ tab1 = _getTabs4.tab1;
178
240
 
179
241
  _forEachInstanceProperty(tabs).call(tabs, function (tab) {
180
242
  return expect(tab).not.toHaveFocus();
@@ -201,9 +263,9 @@ test('disabled all tabs', function () {
201
263
  isDisabled: true
202
264
  });
203
265
 
204
- var _getTabs4 = getTabs(),
205
- tab0 = _getTabs4.tab0,
206
- tab1 = _getTabs4.tab1;
266
+ var _getTabs5 = getTabs(),
267
+ tab0 = _getTabs5.tab0,
268
+ tab1 = _getTabs5.tab1;
207
269
 
208
270
  var tabLine = screen.queryByRole('presentation'); // Tabs cannot be DOM disabled so must check visuals
209
271
 
@@ -222,15 +284,16 @@ test('disabled all tabs', function () {
222
284
  });
223
285
  test('disabled tab is not accessible on click or focus', function () {
224
286
  getComponent({
225
- disabledKeys: [defaultTabs[1].name]
287
+ disabledKeys: [defaultTabs[1].name],
288
+ keyboardActivation: 'automatic'
226
289
  });
227
290
  testTabPanel(0);
228
291
 
229
- var _getTabs5 = getTabs(),
230
- tabs = _getTabs5.tabs,
231
- tab0 = _getTabs5.tab0,
232
- tab1 = _getTabs5.tab1,
233
- tab2 = _getTabs5.tab2; // Ensure that clicking a disabled tab does nothing
292
+ var _getTabs6 = getTabs(),
293
+ tabs = _getTabs6.tabs,
294
+ tab0 = _getTabs6.tab0,
295
+ tab1 = _getTabs6.tab1,
296
+ tab2 = _getTabs6.tab2; // Ensure that clicking a disabled tab does nothing
234
297
 
235
298
 
236
299
  userEvent.click(tab1);
@@ -255,11 +318,11 @@ test('controlled tabs', function () {
255
318
  }),
256
319
  rerender = _getComponent.rerender;
257
320
 
258
- var _getTabs6 = getTabs(),
259
- tabs = _getTabs6.tabs,
260
- tab0 = _getTabs6.tab0,
261
- tab1 = _getTabs6.tab1,
262
- tab2 = _getTabs6.tab2; // Expect the second tab to be selected
321
+ var _getTabs7 = getTabs(),
322
+ tabs = _getTabs7.tabs,
323
+ tab0 = _getTabs7.tab0,
324
+ tab1 = _getTabs7.tab1,
325
+ tab2 = _getTabs7.tab2; // Expect the second tab to be selected
263
326
 
264
327
 
265
328
  expect(onSelectionChange).not.toHaveBeenCalled();
@@ -296,9 +359,9 @@ test('tab line props', function () {
296
359
  }),
297
360
  rerender = _getComponent2.rerender;
298
361
 
299
- var _getTabs7 = getTabs(),
300
- tabs = _getTabs7.tabs,
301
- tab0 = _getTabs7.tab0;
362
+ var _getTabs8 = getTabs(),
363
+ tabs = _getTabs8.tabs,
364
+ tab0 = _getTabs8.tab0;
302
365
 
303
366
  var tabLine = screen.getByRole('presentation'); // Expect the tab line to have a red background
304
367
 
@@ -327,16 +390,16 @@ test('tab with icon', function () {
327
390
  tabs: newTabs
328
391
  });
329
392
 
330
- var _getTabs8 = getTabs(),
331
- tabs = _getTabs8.tabs,
332
- tab0 = _getTabs8.tab0;
393
+ var _getTabs9 = getTabs(),
394
+ tabs = _getTabs9.tabs,
395
+ tab0 = _getTabs9.tab0;
333
396
 
334
397
  var icon = screen.getByTestId('icon'); // Expect the tab to have the given icon element
335
398
 
336
399
  testSingleTab(tabs, tab0, 'toContainElement', [icon]);
337
400
  });
338
401
  test('tooltip renders on tab\'s hover in `tooltip` mode', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
339
- var _getTabs9, tab0;
402
+ var _getTabs10, tab0;
340
403
 
341
404
  return _regeneratorRuntime.wrap(function _callee$(_context) {
342
405
  while (1) {
@@ -346,7 +409,7 @@ test('tooltip renders on tab\'s hover in `tooltip` mode', /*#__PURE__*/_asyncToG
346
409
  mode: 'tooltip'
347
410
  });
348
411
  expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
349
- _getTabs9 = getTabs(), tab0 = _getTabs9.tab0;
412
+ _getTabs10 = getTabs(), tab0 = _getTabs10.tab0;
350
413
  fireEvent.mouseMove(tab0);
351
414
  fireEvent.mouseEnter(tab0);
352
415
 
@@ -370,8 +433,8 @@ test('tabs without selected keys show null tab panel content', function () {
370
433
  test('hover tab style', function () {
371
434
  getComponent();
372
435
 
373
- var _getTabs10 = getTabs(),
374
- tab0 = _getTabs10.tab0;
436
+ var _getTabs11 = getTabs(),
437
+ tab0 = _getTabs11.tab0;
375
438
 
376
439
  expect(tab0).not.toHaveClass('is-hovered');
377
440
  userEvent.hover(tab0);
@@ -414,4 +477,74 @@ test('will render slots.afterTab if provided', function () {
414
477
  tabs: tabs
415
478
  });
416
479
  expect(screen.getByText(testText)).toBeInTheDocument();
480
+ });
481
+ test('will render tab with list if provided', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
482
+ var _getTabs12, menuBtn, menuItems, firstListItemContent;
483
+
484
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
485
+ while (1) {
486
+ switch (_context2.prev = _context2.next) {
487
+ case 0:
488
+ getComponentWithDynamicItems({
489
+ items: tabsWithList,
490
+ mode: 'list'
491
+ });
492
+ testTabPanel(0);
493
+ _getTabs12 = getTabs(), menuBtn = _getTabs12.tab1.parentElement;
494
+ userEvent.click(menuBtn);
495
+ expect(screen.queryByRole('menu')).toBeInTheDocument();
496
+ testTabPanel(0);
497
+ menuItems = screen.queryAllByRole('menuitemradio');
498
+ expect(menuItems).toHaveLength(tabsWithList[1].list.length);
499
+ expect(menuItems[0]).not.toHaveFocus();
500
+ userEvent.click(menuItems[0]);
501
+ firstListItemContent = tabsWithList[1].list[0].children;
502
+ expect(screen.queryByRole('tabpanel')).toHaveTextContent(firstListItemContent);
503
+ expect(screen.queryByRole('menu')).not.toBeInTheDocument();
504
+
505
+ case 13:
506
+ case "end":
507
+ return _context2.stop();
508
+ }
509
+ }
510
+ }, _callee2);
511
+ })));
512
+ test('tab list is accessible via keyboard', function () {
513
+ getComponentWithDynamicItems({
514
+ items: tabsWithList,
515
+ mode: 'list'
516
+ });
517
+
518
+ var _getTabs13 = getTabs(),
519
+ tabs = _getTabs13.tabs,
520
+ tab0 = _getTabs13.tab0,
521
+ tab1 = _getTabs13.tab1;
522
+
523
+ _forEachInstanceProperty(tabs).call(tabs, function (tab) {
524
+ return expect(tab).not.toHaveFocus();
525
+ });
526
+
527
+ userEvent.tab();
528
+ testTabPanel(0);
529
+ fireEvent.keyDown(tab0, {
530
+ key: 'ArrowRight',
531
+ code: 'ArrowRight'
532
+ });
533
+ expect(tab1).toHaveFocus();
534
+ fireEvent.keyDown(tab1, {
535
+ key: 'Enter',
536
+ code: 'Enter'
537
+ });
538
+ expect(screen.queryByRole('menu')).toBeInTheDocument();
539
+ testTabPanel(0);
540
+ var menuItems = screen.queryAllByRole('menuitemradio');
541
+ expect(menuItems).toHaveLength(tabsWithList[1].list.length);
542
+ expect(menuItems[0]).toHaveFocus();
543
+ fireEvent.keyDown(menuItems[0], {
544
+ key: 'Enter',
545
+ code: 'Enter'
546
+ });
547
+ var firstListItemContent = tabsWithList[1].list[0].children;
548
+ expect(screen.queryByRole('tabpanel')).toHaveTextContent(firstListItemContent);
549
+ expect(screen.queryByRole('menu')).not.toBeInTheDocument();
417
550
  });