@zohodesk/components 1.0.0-temp-262 → 1.0.0-temp-262.1
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/es/v1/Tab/Tab.js +9 -4
- package/es/v1/Tab/__tests__/Tab.spec.js +300 -22
- package/es/v1/Tab/__tests__/__snapshots__/Tab.spec.js.snap +692 -443
- package/es/v1/Tab/constants/index.js +7 -0
- package/es/v1/Tab/constants/presets.js +25 -10
- package/es/v1/Tab/css/Tab_v1.module.css +276 -285
- package/es/v1/Tab/css/tab.cva.js +92 -50
- package/es/v1/Tab/index.js +1 -1
- package/lib/v1/Tab/Tab.js +8 -3
- package/lib/v1/Tab/__tests__/Tab.spec.js +327 -34
- package/lib/v1/Tab/__tests__/__snapshots__/Tab.spec.js.snap +692 -443
- package/lib/v1/Tab/constants/index.js +6 -2
- package/lib/v1/Tab/constants/presets.js +42 -8
- package/lib/v1/Tab/css/Tab_v1.module.css +276 -285
- package/lib/v1/Tab/css/tab.cva.js +58 -39
- package/lib/v1/Tab/index.js +18 -0
- package/package.json +1 -1
|
@@ -70,6 +70,10 @@ var ITEMS = [{
|
|
|
70
70
|
text: 'Charlie'
|
|
71
71
|
}];
|
|
72
72
|
|
|
73
|
+
var readStylesheet = function readStylesheet() {
|
|
74
|
+
return _fs["default"].readFileSync(_path["default"].join(__dirname, '..', 'css', 'Tab_v1.module.css'), 'utf8');
|
|
75
|
+
};
|
|
76
|
+
|
|
73
77
|
function Group(_ref) {
|
|
74
78
|
var _ref$uniqueId = _ref.uniqueId,
|
|
75
79
|
uniqueId = _ref$uniqueId === void 0 ? 'tabs' : _ref$uniqueId,
|
|
@@ -636,7 +640,7 @@ describe('Tab - Snapshot', function () {
|
|
|
636
640
|
expect(baseElement).toMatchSnapshot();
|
|
637
641
|
});
|
|
638
642
|
describe('Presets', function () {
|
|
639
|
-
var presets = [['INFO_BAR_RAIL', _presets.INFO_BAR_RAIL], ['SUBTAB_STRIP', _presets.SUBTAB_STRIP]];
|
|
643
|
+
var presets = [['INFO_BAR_RAIL', _presets.INFO_BAR_RAIL], ['INFO_BAR_RAIL_TEXT', _presets.INFO_BAR_RAIL_TEXT], ['INFO_BAR_RAIL_ICON_LEFT', _presets.INFO_BAR_RAIL_ICON_LEFT], ['INFO_BAR_RAIL_ICON_TOP', _presets.INFO_BAR_RAIL_ICON_TOP], ['SUBTAB_STRIP', _presets.SUBTAB_STRIP]];
|
|
640
644
|
test.each(presets)('Should render preset %s', function (_name, preset) {
|
|
641
645
|
var _render41 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(Group, _extends({}, preset, {
|
|
642
646
|
tabProps: {
|
|
@@ -649,6 +653,160 @@ describe('Tab - Snapshot', function () {
|
|
|
649
653
|
});
|
|
650
654
|
});
|
|
651
655
|
});
|
|
656
|
+
describe('Tab - Info bar rail presets', function () {
|
|
657
|
+
var railPresets = [_presets.INFO_BAR_RAIL, _presets.INFO_BAR_RAIL_TEXT, _presets.INFO_BAR_RAIL_ICON_LEFT, _presets.INFO_BAR_RAIL_ICON_TOP];
|
|
658
|
+
test('every rail preset is the same vertical rail, differing only in its label', function () {
|
|
659
|
+
railPresets.forEach(function (preset) {
|
|
660
|
+
expect(preset).toMatchObject({
|
|
661
|
+
position: _constants.POSITION.LEFT,
|
|
662
|
+
hasSurface: true,
|
|
663
|
+
hasListBorder: true
|
|
664
|
+
});
|
|
665
|
+
});
|
|
666
|
+
});
|
|
667
|
+
test('INFO_BAR_RAIL_TEXT renders the text and drops the icon', function () {
|
|
668
|
+
var _render42 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(Group, _extends({}, _presets.INFO_BAR_RAIL_TEXT, {
|
|
669
|
+
tabProps: {
|
|
670
|
+
iconName: 'ZD-TB-menu'
|
|
671
|
+
}
|
|
672
|
+
}))),
|
|
673
|
+
container = _render42.container;
|
|
674
|
+
|
|
675
|
+
var tab = container.querySelector('[role="tab"]');
|
|
676
|
+
expect(tab.textContent).toContain('one');
|
|
677
|
+
expect(tab.querySelector('.iconBox')).toBeNull();
|
|
678
|
+
});
|
|
679
|
+
test.each([['INFO_BAR_RAIL_ICON_LEFT', _presets.INFO_BAR_RAIL_ICON_LEFT, _constants.ICON_PLACEMENT.LEFT], ['INFO_BAR_RAIL_ICON_TOP', _presets.INFO_BAR_RAIL_ICON_TOP, _constants.ICON_PLACEMENT.TOP]])('%s renders icon and text with its iconPlacement', function (_name, preset, placement) {
|
|
680
|
+
expect(preset.labelStyle).toBe(_constants.LABEL_STYLE.ICON_AND_TEXT);
|
|
681
|
+
expect(preset.iconPlacement).toBe(placement);
|
|
682
|
+
|
|
683
|
+
var _render43 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(Group, _extends({}, preset, {
|
|
684
|
+
tabProps: {
|
|
685
|
+
iconName: 'ZD-TB-menu'
|
|
686
|
+
}
|
|
687
|
+
}))),
|
|
688
|
+
container = _render43.container;
|
|
689
|
+
|
|
690
|
+
var tab = container.querySelector('[role="tab"]');
|
|
691
|
+
expect(tab.textContent).toContain('one');
|
|
692
|
+
expect(tab.querySelector('.iconBox')).not.toBeNull();
|
|
693
|
+
});
|
|
694
|
+
|
|
695
|
+
var getLabelParts = function getLabelParts(container) {
|
|
696
|
+
var tab = container.querySelector('[role="tab"]');
|
|
697
|
+
var content = tab.firstElementChild;
|
|
698
|
+
var text = Array.from(content.children).find(function (node) {
|
|
699
|
+
return node.textContent === 'one';
|
|
700
|
+
});
|
|
701
|
+
return {
|
|
702
|
+
tab: tab,
|
|
703
|
+
content: content,
|
|
704
|
+
text: text
|
|
705
|
+
};
|
|
706
|
+
};
|
|
707
|
+
|
|
708
|
+
test.each([['INFO_BAR_RAIL_ICON_LEFT', _presets.INFO_BAR_RAIL_ICON_LEFT]])('%s aligns the label to the start of the rail with left-aligned text', function (_name, preset) {
|
|
709
|
+
var _render44 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(Group, _extends({}, preset, {
|
|
710
|
+
tabProps: {
|
|
711
|
+
iconName: 'ZD-TB-menu'
|
|
712
|
+
}
|
|
713
|
+
}))),
|
|
714
|
+
container = _render44.container;
|
|
715
|
+
|
|
716
|
+
var _getLabelParts = getLabelParts(container),
|
|
717
|
+
tab = _getLabelParts.tab,
|
|
718
|
+
content = _getLabelParts.content,
|
|
719
|
+
text = _getLabelParts.text;
|
|
720
|
+
|
|
721
|
+
expect(tab.className).toContain('d-justify-start');
|
|
722
|
+
expect(content.className).toContain('d-justify-start');
|
|
723
|
+
expect(text.className).toContain('textalign_left');
|
|
724
|
+
});
|
|
725
|
+
test.each([['INFO_BAR_RAIL_ICON_TOP', _presets.INFO_BAR_RAIL_ICON_TOP], ['INFO_BAR_RAIL_TEXT', _presets.INFO_BAR_RAIL_TEXT]])('%s centres the label and its text', function (_name, preset) {
|
|
726
|
+
var _render45 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(Group, _extends({}, preset, {
|
|
727
|
+
tabProps: {
|
|
728
|
+
iconName: 'ZD-TB-menu'
|
|
729
|
+
}
|
|
730
|
+
}))),
|
|
731
|
+
container = _render45.container;
|
|
732
|
+
|
|
733
|
+
var _getLabelParts2 = getLabelParts(container),
|
|
734
|
+
tab = _getLabelParts2.tab,
|
|
735
|
+
content = _getLabelParts2.content,
|
|
736
|
+
text = _getLabelParts2.text;
|
|
737
|
+
|
|
738
|
+
expect(tab.className).toContain('d-justify-center');
|
|
739
|
+
expect(content.className).toContain('d-justify-center');
|
|
740
|
+
expect(text.className).toContain('textalign_center');
|
|
741
|
+
});
|
|
742
|
+
test('a horizontal strip keeps a side-icon label centred in its tab', function () {
|
|
743
|
+
var _render46 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(Group, {
|
|
744
|
+
labelStyle: _constants.LABEL_STYLE.ICON_AND_TEXT,
|
|
745
|
+
isFullWidth: true,
|
|
746
|
+
tabProps: {
|
|
747
|
+
iconName: 'ZD-TB-menu'
|
|
748
|
+
}
|
|
749
|
+
})),
|
|
750
|
+
container = _render46.container;
|
|
751
|
+
|
|
752
|
+
var _getLabelParts3 = getLabelParts(container),
|
|
753
|
+
tab = _getLabelParts3.tab,
|
|
754
|
+
content = _getLabelParts3.content;
|
|
755
|
+
|
|
756
|
+
expect(tab.className).toContain('d-justify-center');
|
|
757
|
+
expect(content.className).toContain('d-justify-center');
|
|
758
|
+
});
|
|
759
|
+
test.each(_constants.ICON_SPACING)('iconSpacing %s maps to a gap utility that css-utility defines', function (spacing) {
|
|
760
|
+
var utilities = _fs["default"].readFileSync(require.resolve('@dot-system/css-utility/es/utilities.plain.css'), 'utf8');
|
|
761
|
+
|
|
762
|
+
var _render47 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(Group, _extends({}, _presets.INFO_BAR_RAIL_ICON_LEFT, {
|
|
763
|
+
iconSpacing: spacing,
|
|
764
|
+
tabProps: {
|
|
765
|
+
iconName: 'ZD-TB-menu'
|
|
766
|
+
}
|
|
767
|
+
}))),
|
|
768
|
+
container = _render47.container;
|
|
769
|
+
|
|
770
|
+
var content = container.querySelector('[role="tab"]').firstElementChild;
|
|
771
|
+
var gapClass = "d-gap-[".concat(spacing, "px]");
|
|
772
|
+
expect(content.classList.contains(gapClass)).toBe(true);
|
|
773
|
+
expect(utilities).toContain(".d-gap-\\[".concat(spacing, "px\\]"));
|
|
774
|
+
});
|
|
775
|
+
test('SUBTAB_STRIP mirrors the ticket detail-view subtabs (v0 delta tabs)', function () {
|
|
776
|
+
expect(_presets.SUBTAB_STRIP).toMatchObject({
|
|
777
|
+
position: _constants.POSITION.TOP,
|
|
778
|
+
size: _constants.SIZE.SMALL,
|
|
779
|
+
variant: _constants.VARIANT.DOTTED,
|
|
780
|
+
labelStyle: _constants.LABEL_STYLE.TEXT,
|
|
781
|
+
textTransform: 'upper',
|
|
782
|
+
textTruncate: 'ellipsis',
|
|
783
|
+
hasListBorder: true,
|
|
784
|
+
hasListPadding: true
|
|
785
|
+
});
|
|
786
|
+
|
|
787
|
+
var _render48 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(Group, _presets.SUBTAB_STRIP)),
|
|
788
|
+
container = _render48.container;
|
|
789
|
+
|
|
790
|
+
var list = container.querySelector('[role="tablist"]');
|
|
791
|
+
var tab = container.querySelector('[role="tab"]');
|
|
792
|
+
expect(list.className).toContain('listDotted'); // The strip draws its own bottom border and start inset; a consumer only adjusts them.
|
|
793
|
+
|
|
794
|
+
expect(list.className).toContain('listTop');
|
|
795
|
+
expect(list.className).not.toContain('listNoBorder');
|
|
796
|
+
expect(list.className).not.toContain('listNoPadding');
|
|
797
|
+
expect(tab.className).toContain('tabDotted');
|
|
798
|
+
expect(tab.className).toContain('tabSmall');
|
|
799
|
+
expect(tab.querySelector('.transform_upper')).not.toBeNull();
|
|
800
|
+
});
|
|
801
|
+
test('a rail preset can move to the right edge by overriding position', function () {
|
|
802
|
+
var _render49 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(Group, _extends({}, _presets.INFO_BAR_RAIL_ICON_TOP, {
|
|
803
|
+
position: _constants.POSITION.RIGHT
|
|
804
|
+
}))),
|
|
805
|
+
container = _render49.container;
|
|
806
|
+
|
|
807
|
+
expect(container.querySelector('[role="tablist"]').className).toContain('listRight');
|
|
808
|
+
});
|
|
809
|
+
});
|
|
652
810
|
/*
|
|
653
811
|
* The behaviour these cover is not visible in a snapshot: the F1 font-size
|
|
654
812
|
* cascade fix, the F2 customClass merge fix, a keyboard model, and a click
|
|
@@ -656,42 +814,177 @@ describe('Tab - Snapshot', function () {
|
|
|
656
814
|
*/
|
|
657
815
|
|
|
658
816
|
describe('Tab - Behaviour', function () {
|
|
659
|
-
test('size is the sole font-size axis: no variant
|
|
817
|
+
test('size is the sole font-size axis: no variant declares font-size', function () {
|
|
660
818
|
/*
|
|
661
|
-
* The F1 regression.
|
|
662
|
-
*
|
|
663
|
-
*
|
|
664
|
-
*
|
|
665
|
-
* `size` silently had no visible effect whenever a variant was also set.
|
|
819
|
+
* The F1 regression. Size and variant classes sit on the same tab element
|
|
820
|
+
* at equal specificity, and the variant blocks come later in the file - so
|
|
821
|
+
* a variant that declared font-size would always win, and `size` would
|
|
822
|
+
* silently have no visible effect whenever a variant was also set.
|
|
666
823
|
*
|
|
667
824
|
* jsdom applies no CSS-module styles, so the guard is in two parts: both
|
|
668
|
-
* the size and variant classes must reach the
|
|
669
|
-
* the stylesheet must declare
|
|
670
|
-
*
|
|
825
|
+
* the size and variant classes must reach the tab element together, and
|
|
826
|
+
* the stylesheet must declare font-size in exactly the size blocks, never
|
|
827
|
+
* in the variant blocks.
|
|
671
828
|
*/
|
|
672
|
-
var
|
|
829
|
+
var _render50 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(Group, {
|
|
673
830
|
size: "large",
|
|
674
831
|
variant: "elevated"
|
|
675
832
|
})),
|
|
676
|
-
container =
|
|
677
|
-
|
|
678
|
-
var root = container.firstChild;
|
|
679
|
-
expect(root.className).toContain('large');
|
|
680
|
-
expect(root.className).toContain('elevated');
|
|
833
|
+
container = _render50.container;
|
|
681
834
|
|
|
682
|
-
var
|
|
835
|
+
var tab = container.querySelector('[role="tab"]');
|
|
836
|
+
expect(tab.className).toContain('tabLarge');
|
|
837
|
+
expect(tab.className).toContain('tabElevated');
|
|
838
|
+
var css = readStylesheet();
|
|
683
839
|
|
|
684
840
|
var block = function block(selector) {
|
|
685
841
|
var match = css.match(new RegExp("\\.".concat(selector, "\\s*\\{([^}]*)\\}")));
|
|
686
842
|
return match ? match[1] : '';
|
|
687
843
|
};
|
|
688
844
|
|
|
689
|
-
expect(block('
|
|
690
|
-
expect(block('
|
|
691
|
-
expect(block('
|
|
692
|
-
expect(block('
|
|
693
|
-
expect(block('
|
|
694
|
-
expect(block('
|
|
845
|
+
expect(block('tabSmall')).toMatch(/font-size/);
|
|
846
|
+
expect(block('tabMedium')).toMatch(/font-size/);
|
|
847
|
+
expect(block('tabLarge')).toMatch(/font-size/);
|
|
848
|
+
expect(block('tabElevated')).not.toMatch(/font-size/);
|
|
849
|
+
expect(block('tabSpaced')).not.toMatch(/font-size/);
|
|
850
|
+
expect(block('tabDotted')).not.toMatch(/font-size/);
|
|
851
|
+
});
|
|
852
|
+
test('the stylesheet exposes no --local-* variables: customClass is the only override path', function () {
|
|
853
|
+
expect(readStylesheet()).not.toMatch(/--local-/);
|
|
854
|
+
});
|
|
855
|
+
test('modifier classes land on the slots, not on the Tabs root', function () {
|
|
856
|
+
var _render51 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(Group, {
|
|
857
|
+
size: "small",
|
|
858
|
+
variant: "dotted",
|
|
859
|
+
position: "left",
|
|
860
|
+
hasSurface: true,
|
|
861
|
+
hasListBorder: false,
|
|
862
|
+
hasListPadding: false
|
|
863
|
+
})),
|
|
864
|
+
container = _render51.container;
|
|
865
|
+
|
|
866
|
+
var root = container.firstChild;
|
|
867
|
+
var list = container.querySelector('[role="tablist"]');
|
|
868
|
+
var tab = container.querySelector('[role="tab"]');
|
|
869
|
+
var panel = container.querySelector('[role="tabpanel"]');
|
|
870
|
+
expect(root.className).not.toMatch(/\b(small|dotted|left|vertical|hasSurface)\b/);
|
|
871
|
+
expect(list.className).toEqual(expect.stringContaining('listDotted'));
|
|
872
|
+
expect(list.className).toEqual(expect.stringContaining('listLeft'));
|
|
873
|
+
expect(list.className).toEqual(expect.stringContaining('listVertical'));
|
|
874
|
+
expect(list.className).toEqual(expect.stringContaining('listSurface'));
|
|
875
|
+
expect(list.className).toEqual(expect.stringContaining('listNoBorder'));
|
|
876
|
+
expect(list.className).toEqual(expect.stringContaining('listNoPadding'));
|
|
877
|
+
expect(tab.className).toEqual(expect.stringContaining('tabSmall'));
|
|
878
|
+
expect(tab.className).toEqual(expect.stringContaining('tabDotted'));
|
|
879
|
+
expect(tab.className).toEqual(expect.stringContaining('tabLeft'));
|
|
880
|
+
expect(tab.className).toEqual(expect.stringContaining('tabVertical'));
|
|
881
|
+
expect(tab.className).toEqual(expect.stringContaining('tabSurface'));
|
|
882
|
+
expect(panel.className).toEqual(expect.stringContaining('panelSurface'));
|
|
883
|
+
expect(panel.className).toEqual(expect.stringContaining('panelDotted'));
|
|
884
|
+
});
|
|
885
|
+
test('a nested Tabs does not inherit the outer variant', function () {
|
|
886
|
+
(0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Tabs["default"], {
|
|
887
|
+
uniqueId: "outer",
|
|
888
|
+
variant: "elevated"
|
|
889
|
+
}, /*#__PURE__*/_react["default"].createElement(_TabList["default"], {
|
|
890
|
+
ariaLabel: "Outer"
|
|
891
|
+
}, /*#__PURE__*/_react["default"].createElement(_Tab["default"], {
|
|
892
|
+
value: "o1",
|
|
893
|
+
text: "o1"
|
|
894
|
+
})), /*#__PURE__*/_react["default"].createElement(_TabPanel["default"], {
|
|
895
|
+
value: "o1"
|
|
896
|
+
}, /*#__PURE__*/_react["default"].createElement(_Tabs["default"], {
|
|
897
|
+
uniqueId: "inner",
|
|
898
|
+
variant: "underline"
|
|
899
|
+
}, /*#__PURE__*/_react["default"].createElement(_TabList["default"], {
|
|
900
|
+
ariaLabel: "Inner"
|
|
901
|
+
}, /*#__PURE__*/_react["default"].createElement(_Tab["default"], {
|
|
902
|
+
value: "i1",
|
|
903
|
+
text: "i1"
|
|
904
|
+
})), /*#__PURE__*/_react["default"].createElement(_TabPanel["default"], {
|
|
905
|
+
value: "i1"
|
|
906
|
+
}, "Inner panel")))));
|
|
907
|
+
|
|
908
|
+
var outerTab = _react2.screen.getByRole('tab', {
|
|
909
|
+
name: 'o1'
|
|
910
|
+
});
|
|
911
|
+
|
|
912
|
+
var innerTab = _react2.screen.getByRole('tab', {
|
|
913
|
+
name: 'i1'
|
|
914
|
+
});
|
|
915
|
+
|
|
916
|
+
expect(outerTab.className).toContain('tabElevated');
|
|
917
|
+
expect(innerTab.className).not.toContain('tabElevated');
|
|
918
|
+
expect(_react2.screen.getByRole('tablist', {
|
|
919
|
+
name: 'Inner'
|
|
920
|
+
}).className).not.toContain('listElevated');
|
|
921
|
+
});
|
|
922
|
+
test('single-value properties come from d-* utilities, as mutually exclusive variants', function () {
|
|
923
|
+
/*
|
|
924
|
+
* The utility layer and the component layer have no declared order, so a
|
|
925
|
+
* d-* class must never compete with a component rule for one property.
|
|
926
|
+
* Exclusive values are cva variants: exactly one of each pair is applied.
|
|
927
|
+
*/
|
|
928
|
+
(0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Tabs["default"], {
|
|
929
|
+
uniqueId: "tabs",
|
|
930
|
+
variant: "dotted"
|
|
931
|
+
}, /*#__PURE__*/_react["default"].createElement(_TabList["default"], {
|
|
932
|
+
ariaLabel: "Cities"
|
|
933
|
+
}, /*#__PURE__*/_react["default"].createElement(_Tab["default"], {
|
|
934
|
+
value: "one",
|
|
935
|
+
text: "one"
|
|
936
|
+
}), /*#__PURE__*/_react["default"].createElement(_Tab["default"], {
|
|
937
|
+
value: "two",
|
|
938
|
+
text: "two",
|
|
939
|
+
isDisabled: true
|
|
940
|
+
}))));
|
|
941
|
+
|
|
942
|
+
var _screen$getAllByRole = _react2.screen.getAllByRole('tab'),
|
|
943
|
+
_screen$getAllByRole2 = _slicedToArray(_screen$getAllByRole, 2),
|
|
944
|
+
enabled = _screen$getAllByRole2[0],
|
|
945
|
+
disabled = _screen$getAllByRole2[1];
|
|
946
|
+
|
|
947
|
+
var list = _react2.screen.getByRole('tablist');
|
|
948
|
+
|
|
949
|
+
expect(enabled.className).toContain('d-cursor-pointer');
|
|
950
|
+
expect(enabled.className).not.toContain('d-cursor-not-allowed');
|
|
951
|
+
expect(disabled.className).toContain('d-cursor-not-allowed');
|
|
952
|
+
expect(disabled.className).not.toContain('d-cursor-pointer');
|
|
953
|
+
expect(list.className).toContain('d-border-dotted');
|
|
954
|
+
expect(list.className).not.toContain('d-border-solid'); // margins are set per variant in the stylesheet, so no d-m-0 to fight them
|
|
955
|
+
|
|
956
|
+
expect(enabled.className).not.toContain('d-m-0');
|
|
957
|
+
});
|
|
958
|
+
test('the stylesheet does not re-declare what a d-* utility now owns', function () {
|
|
959
|
+
var css = readStylesheet();
|
|
960
|
+
|
|
961
|
+
var block = function block(selector) {
|
|
962
|
+
var match = css.match(new RegExp("(?:^|\\n)\\.".concat(selector, "\\s*\\{([^}]*)\\}")));
|
|
963
|
+
return match ? match[1] : null;
|
|
964
|
+
};
|
|
965
|
+
|
|
966
|
+
expect(block('content')).toBeNull();
|
|
967
|
+
expect(block('tabText')).toBeNull();
|
|
968
|
+
expect(block('moreWrapper')).toBeNull();
|
|
969
|
+
expect(block('moreItem')).toBeNull();
|
|
970
|
+
expect(block('list')).not.toMatch(/border-style/);
|
|
971
|
+
expect(block('tab')).not.toMatch(/cursor/);
|
|
972
|
+
expect(css).not.toMatch(/\.listDotted\s*\{[^}]*border-style/);
|
|
973
|
+
});
|
|
974
|
+
test('a customClass slot class is appended after the component classes', function () {
|
|
975
|
+
var _render52 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(Group, {
|
|
976
|
+
variant: "elevated",
|
|
977
|
+
customClass: {
|
|
978
|
+
tab: 'my-tab',
|
|
979
|
+
list: 'my-list'
|
|
980
|
+
}
|
|
981
|
+
})),
|
|
982
|
+
container = _render52.container;
|
|
983
|
+
|
|
984
|
+
var tab = container.querySelector('[role="tab"]');
|
|
985
|
+
var list = container.querySelector('[role="tablist"]');
|
|
986
|
+
expect(tab.className.trim().split(/\s+/).pop()).toBe('my-tab');
|
|
987
|
+
expect(list.className).toMatch(/listElevated.*my-list/);
|
|
695
988
|
});
|
|
696
989
|
test('a group customClass.tab is merged with, not overwritten by, a per-tab getClasses call', function () {
|
|
697
990
|
/*
|
|
@@ -701,12 +994,12 @@ describe('Tab - Behaviour', function () {
|
|
|
701
994
|
* the tab has no per-tab `customClass` of its own - replaced the group's
|
|
702
995
|
* `customClass` outright with `undefined` instead of layering onto it.
|
|
703
996
|
*/
|
|
704
|
-
var
|
|
997
|
+
var _render53 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(Group, {
|
|
705
998
|
customClass: {
|
|
706
999
|
tab: 'group-tab-class'
|
|
707
1000
|
}
|
|
708
1001
|
})),
|
|
709
|
-
container =
|
|
1002
|
+
container = _render53.container;
|
|
710
1003
|
|
|
711
1004
|
var tab = container.querySelector('[role="tab"]');
|
|
712
1005
|
expect(tab.className).toContain('group-tab-class');
|
|
@@ -791,11 +1084,11 @@ describe('Tab - Behaviour', function () {
|
|
|
791
1084
|
text: "three"
|
|
792
1085
|
}))));
|
|
793
1086
|
|
|
794
|
-
var _screen$
|
|
795
|
-
_screen$
|
|
796
|
-
one = _screen$
|
|
797
|
-
two = _screen$
|
|
798
|
-
three = _screen$
|
|
1087
|
+
var _screen$getAllByRole3 = _react2.screen.getAllByRole('tab'),
|
|
1088
|
+
_screen$getAllByRole4 = _slicedToArray(_screen$getAllByRole3, 3),
|
|
1089
|
+
one = _screen$getAllByRole4[0],
|
|
1090
|
+
two = _screen$getAllByRole4[1],
|
|
1091
|
+
three = _screen$getAllByRole4[2];
|
|
799
1092
|
/* Dispatched on the focused tab, which is where a real keypress lands - the
|
|
800
1093
|
* tablist sees it on the way through, in the capture phase. */
|
|
801
1094
|
|
|
@@ -839,10 +1132,10 @@ describe('Tab - Behaviour', function () {
|
|
|
839
1132
|
text: "three"
|
|
840
1133
|
}))));
|
|
841
1134
|
|
|
842
|
-
var _screen$
|
|
843
|
-
_screen$
|
|
844
|
-
one = _screen$
|
|
845
|
-
three = _screen$
|
|
1135
|
+
var _screen$getAllByRole5 = _react2.screen.getAllByRole('tab'),
|
|
1136
|
+
_screen$getAllByRole6 = _slicedToArray(_screen$getAllByRole5, 3),
|
|
1137
|
+
one = _screen$getAllByRole6[0],
|
|
1138
|
+
three = _screen$getAllByRole6[2];
|
|
846
1139
|
|
|
847
1140
|
one.focus();
|
|
848
1141
|
|