@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.
- package/CHANGELOG.md +17 -0
- package/lib/cjs/components/CodeView/CodeView.js +1 -1
- package/lib/cjs/components/CodeView/CodeView.test.js +22 -27
- package/lib/cjs/components/CopyText/CopyText.js +1 -1
- package/lib/cjs/components/PopoverMenu/PopoverMenu.js +7 -2
- package/lib/cjs/components/Tab/Tab.js +22 -15
- package/lib/cjs/components/TabPicker/TabPicker.js +239 -0
- package/lib/cjs/components/TabPicker/index.js +18 -0
- package/lib/cjs/components/Tabs/Tabs.js +46 -13
- package/lib/cjs/components/Tabs/Tabs.stories.js +32 -2
- package/lib/cjs/components/Tabs/Tabs.test.js +183 -32
- package/lib/cjs/styles/variants/buttons.js +13 -0
- package/lib/cjs/styles/variants/codeView.js +2 -1
- package/lib/cjs/styles/variants/tabs.js +5 -1
- package/lib/cjs/styles/variants/text.js +7 -2
- package/lib/components/CodeView/CodeView.js +1 -1
- package/lib/components/CodeView/CodeView.test.js +22 -23
- package/lib/components/CopyText/CopyText.js +1 -1
- package/lib/components/PopoverMenu/PopoverMenu.js +7 -2
- package/lib/components/Tab/Tab.js +14 -8
- package/lib/components/TabPicker/TabPicker.js +210 -0
- package/lib/components/TabPicker/index.js +1 -0
- package/lib/components/Tabs/Tabs.js +44 -11
- package/lib/components/Tabs/Tabs.stories.js +27 -0
- package/lib/components/Tabs/Tabs.test.js +165 -32
- package/lib/styles/variants/buttons.js +13 -0
- package/lib/styles/variants/codeView.js +2 -1
- package/lib/styles/variants/tabs.js +5 -1
- package/lib/styles/variants/text.js +7 -2
- package/package.json +1 -1
@@ -10,7 +10,9 @@ _Object$defineProperty(exports, "__esModule", {
|
|
10
10
|
value: true
|
11
11
|
});
|
12
12
|
|
13
|
-
exports.ContentSlots = exports.TabPanelProps = exports.CustomTabLine = exports.DisabledAllTabs = exports.DisabledSingleTab = exports.Centered = exports.WithTooltips = exports.WithIcon = exports.Controlled = exports.Uncontrolled = exports["default"] = void 0;
|
13
|
+
exports.WithList = exports.ContentSlots = exports.TabPanelProps = exports.CustomTabLine = exports.DisabledAllTabs = exports.DisabledSingleTab = exports.Centered = exports.WithTooltips = exports.WithIcon = exports.Controlled = exports.Uncontrolled = exports["default"] = void 0;
|
14
|
+
|
15
|
+
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
14
16
|
|
15
17
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
16
18
|
|
@@ -278,4 +280,32 @@ var ContentSlots = function ContentSlots() {
|
|
278
280
|
}, (0, _react2.jsx)(_Text["default"], null, "Users Matched"))));
|
279
281
|
};
|
280
282
|
|
281
|
-
exports.ContentSlots = ContentSlots;
|
283
|
+
exports.ContentSlots = ContentSlots;
|
284
|
+
|
285
|
+
var WithList = function WithList() {
|
286
|
+
var _context;
|
287
|
+
|
288
|
+
var allTabs = (0, _concat["default"])(_context = []).call(_context, tabs, [{
|
289
|
+
name: 'Tab 4',
|
290
|
+
list: [{
|
291
|
+
key: 'tab1list',
|
292
|
+
name: 'Tab 1 list',
|
293
|
+
children: 'Tab 1 from list'
|
294
|
+
}, {
|
295
|
+
key: 'tab2list',
|
296
|
+
name: 'Tab 2 list',
|
297
|
+
children: 'Tab 2 from list'
|
298
|
+
}]
|
299
|
+
}]);
|
300
|
+
return (0, _react2.jsx)(_Tabs["default"], {
|
301
|
+
items: allTabs,
|
302
|
+
mode: "list"
|
303
|
+
}, function (item) {
|
304
|
+
return (0, _react2.jsx)(_Tab["default"], (0, _extends2["default"])({
|
305
|
+
key: item.name,
|
306
|
+
title: item.name
|
307
|
+
}, item), item.children);
|
308
|
+
});
|
309
|
+
};
|
310
|
+
|
311
|
+
exports.WithList = WithList;
|
@@ -14,6 +14,8 @@ var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-st
|
|
14
14
|
|
15
15
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
16
16
|
|
17
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
18
|
+
|
17
19
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
18
20
|
|
19
21
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
@@ -52,6 +54,21 @@ var defaultTabs = [{
|
|
52
54
|
name: 'Tab 3',
|
53
55
|
children: 'Tab 3 body'
|
54
56
|
}];
|
57
|
+
var tabsWithList = [{
|
58
|
+
name: 'Tab 1',
|
59
|
+
children: 'Tab 1 body'
|
60
|
+
}, {
|
61
|
+
name: 'Tab 2',
|
62
|
+
list: [{
|
63
|
+
key: 'tab1list',
|
64
|
+
name: 'Tab 1 list',
|
65
|
+
children: 'Tab 1 from list'
|
66
|
+
}, {
|
67
|
+
key: 'tab2list',
|
68
|
+
name: 'Tab 2 list',
|
69
|
+
children: 'Tab 2 from list'
|
70
|
+
}]
|
71
|
+
}];
|
55
72
|
var defaultProps = {
|
56
73
|
'data-testid': testId,
|
57
74
|
defaultSelectedKey: defaultTabs[0].name
|
@@ -79,6 +96,20 @@ var getComponent = function getComponent() {
|
|
79
96
|
}))));
|
80
97
|
};
|
81
98
|
|
99
|
+
var getComponentWithDynamicItems = function getComponentWithDynamicItems(props) {
|
100
|
+
return (0, _testWrapper.render)((0, _react2.jsx)(_react2.CacheProvider, {
|
101
|
+
value: emotionCache
|
102
|
+
}, (0, _react2.jsx)(_Tabs["default"], props, function (_ref3) {
|
103
|
+
var name = _ref3.name,
|
104
|
+
children = _ref3.children,
|
105
|
+
tabProps = (0, _objectWithoutProperties2["default"])(_ref3, ["name", "children"]);
|
106
|
+
return (0, _react2.jsx)(_Tab["default"], (0, _extends2["default"])({
|
107
|
+
key: name,
|
108
|
+
title: name
|
109
|
+
}, tabProps), children);
|
110
|
+
})));
|
111
|
+
};
|
112
|
+
|
82
113
|
var getTabs = function getTabs() {
|
83
114
|
var tabs = _testWrapper.screen.queryAllByRole('tab');
|
84
115
|
|
@@ -96,8 +127,8 @@ var getTabs = function getTabs() {
|
|
96
127
|
};
|
97
128
|
|
98
129
|
var testTabPanel = function testTabPanel(expectedTabIndex) {
|
99
|
-
return (0, _forEach["default"])(defaultTabs).call(defaultTabs, function (
|
100
|
-
var children =
|
130
|
+
return (0, _forEach["default"])(defaultTabs).call(defaultTabs, function (_ref4, index) {
|
131
|
+
var children = _ref4.children;
|
101
132
|
return index === expectedTabIndex ? expect(_testWrapper.screen.queryByText(children)).toBeInTheDocument() : expect(_testWrapper.screen.queryByText(children)).not.toBeInTheDocument();
|
102
133
|
});
|
103
134
|
};
|
@@ -163,7 +194,7 @@ test('interacting with tabs via click', function () {
|
|
163
194
|
testSingleTab(tabs, tab0, 'toContainElement', [_testWrapper.screen.getByRole('presentation')]);
|
164
195
|
testTabPanel(0);
|
165
196
|
});
|
166
|
-
test('interacting with tabs
|
197
|
+
test('interacting with tabs with manual activation', function () {
|
167
198
|
getComponent();
|
168
199
|
|
169
200
|
var _getTabs2 = getTabs(),
|
@@ -185,6 +216,41 @@ test('interacting with tabs via focus -- horizontal', function () {
|
|
185
216
|
code: 'ArrowRight'
|
186
217
|
});
|
187
218
|
|
219
|
+
testSingleTab(tabs, tab1, 'toHaveFocus');
|
220
|
+
testTabPanel(0);
|
221
|
+
|
222
|
+
_testWrapper.fireEvent.keyDown(tab1, {
|
223
|
+
key: 'Enter',
|
224
|
+
code: 'Enter'
|
225
|
+
});
|
226
|
+
|
227
|
+
testSingleTab(tabs, tab1, 'toHaveFocus');
|
228
|
+
testTabPanel(1);
|
229
|
+
});
|
230
|
+
test('interacting with tabs via focus -- horizontal', function () {
|
231
|
+
getComponent({
|
232
|
+
keyboardActivation: 'automatic'
|
233
|
+
});
|
234
|
+
|
235
|
+
var _getTabs3 = getTabs(),
|
236
|
+
tabs = _getTabs3.tabs,
|
237
|
+
tab0 = _getTabs3.tab0,
|
238
|
+
tab1 = _getTabs3.tab1;
|
239
|
+
|
240
|
+
(0, _forEach["default"])(tabs).call(tabs, function (tab) {
|
241
|
+
return expect(tab).not.toHaveFocus();
|
242
|
+
});
|
243
|
+
|
244
|
+
_userEvent["default"].tab();
|
245
|
+
|
246
|
+
testSingleTab(tabs, tab0, 'toHaveFocus');
|
247
|
+
testTabPanel(0);
|
248
|
+
|
249
|
+
_testWrapper.fireEvent.keyDown(tab0, {
|
250
|
+
key: 'ArrowRight',
|
251
|
+
code: 'ArrowRight'
|
252
|
+
});
|
253
|
+
|
188
254
|
testSingleTab(tabs, tab1, 'toHaveFocus');
|
189
255
|
testTabPanel(1);
|
190
256
|
|
@@ -198,13 +264,14 @@ test('interacting with tabs via focus -- horizontal', function () {
|
|
198
264
|
});
|
199
265
|
test('interacting with tabs via focus -- vertical', function () {
|
200
266
|
getComponent({
|
201
|
-
orientation: 'vertical'
|
267
|
+
orientation: 'vertical',
|
268
|
+
keyboardActivation: 'automatic'
|
202
269
|
});
|
203
270
|
|
204
|
-
var
|
205
|
-
tabs =
|
206
|
-
tab0 =
|
207
|
-
tab1 =
|
271
|
+
var _getTabs4 = getTabs(),
|
272
|
+
tabs = _getTabs4.tabs,
|
273
|
+
tab0 = _getTabs4.tab0,
|
274
|
+
tab1 = _getTabs4.tab1;
|
208
275
|
|
209
276
|
(0, _forEach["default"])(tabs).call(tabs, function (tab) {
|
210
277
|
return expect(tab).not.toHaveFocus();
|
@@ -236,9 +303,9 @@ test('disabled all tabs', function () {
|
|
236
303
|
isDisabled: true
|
237
304
|
});
|
238
305
|
|
239
|
-
var
|
240
|
-
tab0 =
|
241
|
-
tab1 =
|
306
|
+
var _getTabs5 = getTabs(),
|
307
|
+
tab0 = _getTabs5.tab0,
|
308
|
+
tab1 = _getTabs5.tab1;
|
242
309
|
|
243
310
|
var tabLine = _testWrapper.screen.queryByRole('presentation'); // Tabs cannot be DOM disabled so must check visuals
|
244
311
|
|
@@ -259,15 +326,16 @@ test('disabled all tabs', function () {
|
|
259
326
|
});
|
260
327
|
test('disabled tab is not accessible on click or focus', function () {
|
261
328
|
getComponent({
|
262
|
-
disabledKeys: [defaultTabs[1].name]
|
329
|
+
disabledKeys: [defaultTabs[1].name],
|
330
|
+
keyboardActivation: 'automatic'
|
263
331
|
});
|
264
332
|
testTabPanel(0);
|
265
333
|
|
266
|
-
var
|
267
|
-
tabs =
|
268
|
-
tab0 =
|
269
|
-
tab1 =
|
270
|
-
tab2 =
|
334
|
+
var _getTabs6 = getTabs(),
|
335
|
+
tabs = _getTabs6.tabs,
|
336
|
+
tab0 = _getTabs6.tab0,
|
337
|
+
tab1 = _getTabs6.tab1,
|
338
|
+
tab2 = _getTabs6.tab2; // Ensure that clicking a disabled tab does nothing
|
271
339
|
|
272
340
|
|
273
341
|
_userEvent["default"].click(tab1);
|
@@ -296,11 +364,11 @@ test('controlled tabs', function () {
|
|
296
364
|
}),
|
297
365
|
rerender = _getComponent.rerender;
|
298
366
|
|
299
|
-
var
|
300
|
-
tabs =
|
301
|
-
tab0 =
|
302
|
-
tab1 =
|
303
|
-
tab2 =
|
367
|
+
var _getTabs7 = getTabs(),
|
368
|
+
tabs = _getTabs7.tabs,
|
369
|
+
tab0 = _getTabs7.tab0,
|
370
|
+
tab1 = _getTabs7.tab1,
|
371
|
+
tab2 = _getTabs7.tab2; // Expect the second tab to be selected
|
304
372
|
|
305
373
|
|
306
374
|
expect(onSelectionChange).not.toHaveBeenCalled();
|
@@ -338,9 +406,9 @@ test('tab line props', function () {
|
|
338
406
|
}),
|
339
407
|
rerender = _getComponent2.rerender;
|
340
408
|
|
341
|
-
var
|
342
|
-
tabs =
|
343
|
-
tab0 =
|
409
|
+
var _getTabs8 = getTabs(),
|
410
|
+
tabs = _getTabs8.tabs,
|
411
|
+
tab0 = _getTabs8.tab0;
|
344
412
|
|
345
413
|
var tabLine = _testWrapper.screen.getByRole('presentation'); // Expect the tab line to have a red background
|
346
414
|
|
@@ -369,9 +437,9 @@ test('tab with icon', function () {
|
|
369
437
|
tabs: newTabs
|
370
438
|
});
|
371
439
|
|
372
|
-
var
|
373
|
-
tabs =
|
374
|
-
tab0 =
|
440
|
+
var _getTabs9 = getTabs(),
|
441
|
+
tabs = _getTabs9.tabs,
|
442
|
+
tab0 = _getTabs9.tab0;
|
375
443
|
|
376
444
|
var icon = _testWrapper.screen.getByTestId('icon'); // Expect the tab to have the given icon element
|
377
445
|
|
@@ -379,7 +447,7 @@ test('tab with icon', function () {
|
|
379
447
|
testSingleTab(tabs, tab0, 'toContainElement', [icon]);
|
380
448
|
});
|
381
449
|
test('tooltip renders on tab\'s hover in `tooltip` mode', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
382
|
-
var
|
450
|
+
var _getTabs10, tab0;
|
383
451
|
|
384
452
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
385
453
|
while (1) {
|
@@ -389,7 +457,7 @@ test('tooltip renders on tab\'s hover in `tooltip` mode', /*#__PURE__*/(0, _asyn
|
|
389
457
|
mode: 'tooltip'
|
390
458
|
});
|
391
459
|
expect(_testWrapper.screen.queryByRole('tooltip')).not.toBeInTheDocument();
|
392
|
-
|
460
|
+
_getTabs10 = getTabs(), tab0 = _getTabs10.tab0;
|
393
461
|
|
394
462
|
_testWrapper.fireEvent.mouseMove(tab0);
|
395
463
|
|
@@ -415,8 +483,8 @@ test('tabs without selected keys show null tab panel content', function () {
|
|
415
483
|
test('hover tab style', function () {
|
416
484
|
getComponent();
|
417
485
|
|
418
|
-
var
|
419
|
-
tab0 =
|
486
|
+
var _getTabs11 = getTabs(),
|
487
|
+
tab0 = _getTabs11.tab0;
|
420
488
|
|
421
489
|
expect(tab0).not.toHaveClass('is-hovered');
|
422
490
|
|
@@ -457,4 +525,87 @@ test('will render slots.afterTab if provided', function () {
|
|
457
525
|
tabs: tabs
|
458
526
|
});
|
459
527
|
expect(_testWrapper.screen.getByText(testText)).toBeInTheDocument();
|
528
|
+
});
|
529
|
+
test('will render tab with list if provided', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
530
|
+
var _getTabs12, menuBtn, menuItems, firstListItemContent;
|
531
|
+
|
532
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
533
|
+
while (1) {
|
534
|
+
switch (_context2.prev = _context2.next) {
|
535
|
+
case 0:
|
536
|
+
getComponentWithDynamicItems({
|
537
|
+
items: tabsWithList,
|
538
|
+
mode: 'list'
|
539
|
+
});
|
540
|
+
testTabPanel(0);
|
541
|
+
_getTabs12 = getTabs(), menuBtn = _getTabs12.tab1.parentElement;
|
542
|
+
|
543
|
+
_userEvent["default"].click(menuBtn);
|
544
|
+
|
545
|
+
expect(_testWrapper.screen.queryByRole('menu')).toBeInTheDocument();
|
546
|
+
testTabPanel(0);
|
547
|
+
menuItems = _testWrapper.screen.queryAllByRole('menuitemradio');
|
548
|
+
expect(menuItems).toHaveLength(tabsWithList[1].list.length);
|
549
|
+
expect(menuItems[0]).not.toHaveFocus();
|
550
|
+
|
551
|
+
_userEvent["default"].click(menuItems[0]);
|
552
|
+
|
553
|
+
firstListItemContent = tabsWithList[1].list[0].children;
|
554
|
+
expect(_testWrapper.screen.queryByRole('tabpanel')).toHaveTextContent(firstListItemContent);
|
555
|
+
expect(_testWrapper.screen.queryByRole('menu')).not.toBeInTheDocument();
|
556
|
+
|
557
|
+
case 13:
|
558
|
+
case "end":
|
559
|
+
return _context2.stop();
|
560
|
+
}
|
561
|
+
}
|
562
|
+
}, _callee2);
|
563
|
+
})));
|
564
|
+
test('tab list is accessible via keyboard', function () {
|
565
|
+
getComponentWithDynamicItems({
|
566
|
+
items: tabsWithList,
|
567
|
+
mode: 'list'
|
568
|
+
});
|
569
|
+
|
570
|
+
var _getTabs13 = getTabs(),
|
571
|
+
tabs = _getTabs13.tabs,
|
572
|
+
tab0 = _getTabs13.tab0,
|
573
|
+
tab1 = _getTabs13.tab1;
|
574
|
+
|
575
|
+
(0, _forEach["default"])(tabs).call(tabs, function (tab) {
|
576
|
+
return expect(tab).not.toHaveFocus();
|
577
|
+
});
|
578
|
+
|
579
|
+
_userEvent["default"].tab();
|
580
|
+
|
581
|
+
testTabPanel(0);
|
582
|
+
|
583
|
+
_testWrapper.fireEvent.keyDown(tab0, {
|
584
|
+
key: 'ArrowRight',
|
585
|
+
code: 'ArrowRight'
|
586
|
+
});
|
587
|
+
|
588
|
+
expect(tab1).toHaveFocus();
|
589
|
+
|
590
|
+
_testWrapper.fireEvent.keyDown(tab1, {
|
591
|
+
key: 'Enter',
|
592
|
+
code: 'Enter'
|
593
|
+
});
|
594
|
+
|
595
|
+
expect(_testWrapper.screen.queryByRole('menu')).toBeInTheDocument();
|
596
|
+
testTabPanel(0);
|
597
|
+
|
598
|
+
var menuItems = _testWrapper.screen.queryAllByRole('menuitemradio');
|
599
|
+
|
600
|
+
expect(menuItems).toHaveLength(tabsWithList[1].list.length);
|
601
|
+
expect(menuItems[0]).toHaveFocus();
|
602
|
+
|
603
|
+
_testWrapper.fireEvent.keyDown(menuItems[0], {
|
604
|
+
key: 'Enter',
|
605
|
+
code: 'Enter'
|
606
|
+
});
|
607
|
+
|
608
|
+
var firstListItemContent = tabsWithList[1].list[0].children;
|
609
|
+
expect(_testWrapper.screen.queryByRole('tabpanel')).toHaveTextContent(firstListItemContent);
|
610
|
+
expect(_testWrapper.screen.queryByRole('menu')).not.toBeInTheDocument();
|
460
611
|
});
|
@@ -660,6 +660,18 @@ var colorBlock = {
|
|
660
660
|
borderColor: 'accent.20'
|
661
661
|
}
|
662
662
|
};
|
663
|
+
|
664
|
+
var menuTab = _objectSpread(_objectSpread({}, quiet), {}, {
|
665
|
+
color: 'neutral.40',
|
666
|
+
alignItems: 'center',
|
667
|
+
'&.is-selected *, &.is-hovered *': {
|
668
|
+
color: 'active'
|
669
|
+
},
|
670
|
+
'& + *:not(div:first-of-type)': {
|
671
|
+
'ml': 'md'
|
672
|
+
}
|
673
|
+
});
|
674
|
+
|
663
675
|
var _default = {
|
664
676
|
accordionHeader: accordionHeader,
|
665
677
|
chipDeleteButton: chipDeleteButton,
|
@@ -702,6 +714,7 @@ var _default = {
|
|
702
714
|
tooltipIconButton: tooltipIconButton,
|
703
715
|
tooltipInline: tooltipInline,
|
704
716
|
colorBlock: colorBlock,
|
717
|
+
menuTab: menuTab,
|
705
718
|
multiselectToggle: multiselectToggle,
|
706
719
|
neutralText: neutralText
|
707
720
|
};
|
@@ -23,13 +23,17 @@ var tab = {
|
|
23
23
|
},
|
24
24
|
'&.is-selected.is-vertical': {
|
25
25
|
bg: 'accent.95'
|
26
|
+
},
|
27
|
+
'& > svg': {
|
28
|
+
flexShrink: 0
|
26
29
|
}
|
27
30
|
};
|
28
31
|
exports.tab = tab;
|
29
32
|
var tabLine = {
|
30
33
|
height: '2px',
|
31
34
|
width: '100%',
|
32
|
-
bg: 'active'
|
35
|
+
bg: 'active',
|
36
|
+
flexShrink: 0
|
33
37
|
};
|
34
38
|
exports.tabLine = tabLine;
|
35
39
|
var tabPanel = {
|
@@ -50,11 +50,16 @@ var wordWrap = {
|
|
50
50
|
var tabLabel = _objectSpread(_objectSpread(_objectSpread({}, base), wordWrap), {}, {
|
51
51
|
fontSize: 'sm',
|
52
52
|
fontWeight: 1,
|
53
|
-
mb:
|
53
|
+
mb: 'sm',
|
54
|
+
lineHeight: '16px',
|
54
55
|
color: 'neutral.40',
|
56
|
+
height: '100%',
|
55
57
|
'.is-selected &, .is-hovered &': {
|
58
|
+
color: 'active'
|
59
|
+
},
|
60
|
+
'.is-selected &': {
|
56
61
|
color: 'active',
|
57
|
-
mb:
|
62
|
+
mb: 8
|
58
63
|
},
|
59
64
|
'.is-disabled &': {
|
60
65
|
color: 'neutral.80'
|
@@ -35,8 +35,21 @@ var textValue = "\nexport const Default = args => (\n <>\n <Text sx={{ fontW
|
|
35
35
|
var getComponent = function getComponent() {
|
36
36
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
37
37
|
return render(___EmotionJSX(CodeView, _extends({}, defaultProps, props), textValue));
|
38
|
-
};
|
38
|
+
};
|
39
39
|
|
40
|
+
beforeEach(function () {
|
41
|
+
var mockClipboard = {
|
42
|
+
writeText: jest.fn()
|
43
|
+
};
|
44
|
+
global.navigator.clipboard = mockClipboard;
|
45
|
+
global.document.execCommand = jest.fn();
|
46
|
+
global.document.execCommand.mockReturnValue(true);
|
47
|
+
});
|
48
|
+
afterEach(function () {
|
49
|
+
jest.resetAllMocks();
|
50
|
+
global.navigator.clipboard = originalClipboard;
|
51
|
+
global.document.execCommand = originalExecCommand;
|
52
|
+
}); // Need to be added to each test file to test accessibility using axe.
|
40
53
|
|
41
54
|
axeTest(getComponent);
|
42
55
|
test('renders component in the default state', function () {
|
@@ -45,25 +58,24 @@ test('renders component in the default state', function () {
|
|
45
58
|
expect(container).toBeInstanceOf(HTMLDivElement);
|
46
59
|
expect(container).toBeInTheDocument();
|
47
60
|
});
|
48
|
-
test('
|
61
|
+
test('copy button is hovered and renders tooltip via mouse', function () {
|
49
62
|
getComponent();
|
50
|
-
var
|
51
|
-
|
52
|
-
|
63
|
+
var copyBtn = screen.getByLabelText('copy');
|
64
|
+
expect(copyBtn).not.toHaveFocus();
|
65
|
+
userEvent.hover(copyBtn);
|
66
|
+
expect(copyBtn).toHaveClass('is-hovered');
|
53
67
|
expect(screen.queryByRole('tooltip')).toBeInTheDocument();
|
54
68
|
expect(screen.queryByRole('tooltip')).toHaveTextContent('Copy to clipboard');
|
55
69
|
});
|
56
|
-
test('
|
70
|
+
test('copy button is focused and renders tooltip via keyboard', function () {
|
57
71
|
getComponent();
|
58
|
-
var container = screen.getByTestId(testId);
|
59
|
-
expect(container).not.toHaveFocus();
|
60
|
-
userEvent.tab();
|
61
|
-
expect(container).toHaveFocus();
|
62
72
|
var copyBtn = screen.getByLabelText('copy');
|
63
73
|
expect(copyBtn).not.toHaveFocus();
|
64
74
|
userEvent.tab();
|
65
75
|
expect(copyBtn).toHaveFocus();
|
66
76
|
expect(copyBtn).toHaveClass('is-focused');
|
77
|
+
expect(screen.queryByRole('tooltip')).toBeInTheDocument();
|
78
|
+
expect(screen.queryByRole('tooltip')).toHaveTextContent('Copy to clipboard');
|
67
79
|
});
|
68
80
|
test('doesn\'t render copy button and tooltip with prop hasNoCopyButton', function () {
|
69
81
|
getComponent({
|
@@ -86,19 +98,6 @@ test('renders line numbers with prop hasLineNumbers', function () {
|
|
86
98
|
expect(screen.queryByText('1')).toBeInTheDocument();
|
87
99
|
expect(screen.queryByText(linesLength)).toBeInTheDocument();
|
88
100
|
});
|
89
|
-
beforeEach(function () {
|
90
|
-
var mockClipboard = {
|
91
|
-
writeText: jest.fn()
|
92
|
-
};
|
93
|
-
global.navigator.clipboard = mockClipboard;
|
94
|
-
global.document.execCommand = jest.fn();
|
95
|
-
global.document.execCommand.mockReturnValue(true);
|
96
|
-
});
|
97
|
-
afterEach(function () {
|
98
|
-
jest.resetAllMocks();
|
99
|
-
global.navigator.clipboard = originalClipboard;
|
100
|
-
global.document.execCommand = originalExecCommand;
|
101
|
-
});
|
102
101
|
test('click on copy button copies data to the clipboard', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
103
102
|
var button;
|
104
103
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
@@ -106,7 +106,7 @@ var CopyText = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
106
106
|
ref: ref,
|
107
107
|
isRow: true,
|
108
108
|
variant: "boxes.copy"
|
109
|
-
}, others), content, ___EmotionJSX(TooltipWrapper, {
|
109
|
+
}, wrapperProps, others), content, ___EmotionJSX(TooltipWrapper, {
|
110
110
|
isOpen: isTooltipOpen,
|
111
111
|
tooltip: tooltip
|
112
112
|
}, ___EmotionJSX(CopyButton, _extends({
|
@@ -49,7 +49,8 @@ var PopoverMenu = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
49
49
|
isDefaultOpen = props.isDefaultOpen,
|
50
50
|
isNotFlippable = props.isNotFlippable,
|
51
51
|
isNotClosedOnSelect = props.isNotClosedOnSelect,
|
52
|
-
hasNoArrow = props.hasNoArrow
|
52
|
+
hasNoArrow = props.hasNoArrow,
|
53
|
+
isContainFocus = props.isContainFocus;
|
53
54
|
|
54
55
|
var _React$Children$toArr = React.Children.toArray(children),
|
55
56
|
_React$Children$toArr2 = _slicedToArray(_React$Children$toArr, 2),
|
@@ -90,7 +91,8 @@ var PopoverMenu = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
90
91
|
});
|
91
92
|
|
92
93
|
var contents = ___EmotionJSX(FocusScope, {
|
93
|
-
restoreFocus: true
|
94
|
+
restoreFocus: true,
|
95
|
+
contain: isContainFocus
|
94
96
|
}, ___EmotionJSX(DismissButton, {
|
95
97
|
onDismiss: state.close
|
96
98
|
}), menu, ___EmotionJSX(DismissButton, {
|
@@ -136,6 +138,9 @@ PopoverMenu.propTypes = {
|
|
136
138
|
/** Whether the PopoverMenu hides the arrow. */
|
137
139
|
hasNoArrow: PropTypes.bool,
|
138
140
|
|
141
|
+
/** Whether the PopoverMenu contains focus inside the scope. */
|
142
|
+
isContainFocus: PropTypes.bool,
|
143
|
+
|
139
144
|
/**
|
140
145
|
* Handler that is called when the overlay's open state changes.
|
141
146
|
*
|
@@ -7,13 +7,11 @@ import { useFocusRing } from '@react-aria/focus';
|
|
7
7
|
import { useHover } from '@react-aria/interactions';
|
8
8
|
import { mergeProps } from '@react-aria/utils';
|
9
9
|
import { Item as Tab } from '@react-stately/collections';
|
10
|
-
import Box from '../Box';
|
11
10
|
import { TabsContext } from '../Tabs';
|
12
|
-
import Text from '../Text';
|
13
11
|
import { useStatusClasses, usePropWarning } from '../../hooks';
|
14
12
|
import ORIENTATION from '../../utils/devUtils/constants/orientation';
|
15
|
-
import
|
16
|
-
import Button from '
|
13
|
+
import TabPicker from '../TabPicker';
|
14
|
+
import { Box, Text, TooltipTrigger, Tooltip, Button } from '../..';
|
17
15
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
18
16
|
export var CollectionTab = /*#__PURE__*/forwardRef(function (props, ref) {
|
19
17
|
var className = props.className,
|
@@ -84,6 +82,16 @@ export var CollectionTab = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
84
82
|
variant: "tabLabel"
|
85
83
|
}, tabLabelProps), rendered), isSelected && !isDisabled && ___EmotionJSX(TabLine, tabLineProps)), slots === null || slots === void 0 ? void 0 : slots.afterTab);
|
86
84
|
|
85
|
+
if (mode === 'list' && itemProps.list) {
|
86
|
+
return ___EmotionJSX(TabPicker, _extends({
|
87
|
+
ref: tabRef,
|
88
|
+
className: classNames,
|
89
|
+
items: itemProps.list,
|
90
|
+
state: state,
|
91
|
+
item: item
|
92
|
+
}, mergeProps(focusProps, hoverProps, tabProps), otherItemProps));
|
93
|
+
}
|
94
|
+
|
87
95
|
if (mode === 'tooltip') {
|
88
96
|
return ___EmotionJSX(React.Fragment, null, separator, ___EmotionJSX(TooltipTrigger, _extends({}, tooltipTriggerProps, {
|
89
97
|
isOpen: isHovered || isFocusVisible
|
@@ -103,7 +111,7 @@ CollectionTab.propTypes = {
|
|
103
111
|
rendered: PropTypes.node,
|
104
112
|
tabLineProps: PropTypes.shape({})
|
105
113
|
}),
|
106
|
-
mode: PropTypes.oneOf(['default', 'tooltip']),
|
114
|
+
mode: PropTypes.oneOf(['default', 'tooltip', 'list']),
|
107
115
|
orientation: PropTypes.oneOf(['horizontal', 'vertical']),
|
108
116
|
tooltipTriggerProps: PropTypes.shape({}),
|
109
117
|
slots: PropTypes.shape({
|
@@ -111,13 +119,11 @@ CollectionTab.propTypes = {
|
|
111
119
|
afterTab: PropTypes.node
|
112
120
|
})
|
113
121
|
};
|
114
|
-
|
115
|
-
var TabLine = function TabLine(props) {
|
122
|
+
export var TabLine = function TabLine(props) {
|
116
123
|
return ___EmotionJSX(Box, _extends({
|
117
124
|
role: "presentation",
|
118
125
|
variant: "tabLine"
|
119
126
|
}, props));
|
120
127
|
}; // Export Item as default Tab for simplicity, convert to CollectionTab within Tabs component
|
121
128
|
|
122
|
-
|
123
129
|
export default Tab;
|