@zohodesk/components 1.0.0-temp-262 → 1.0.0-temp-262.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,8 +8,8 @@ import Tabs from "../Tabs";
8
8
  import TabList from "../TabList";
9
9
  import Tab from "../Tab";
10
10
  import TabPanel from "../TabPanel";
11
- import { SIZE, VARIANT, POSITION, LABEL_STYLE, ICON_PLACEMENT } from "../constants";
12
- import { INFO_BAR_RAIL, SUBTAB_STRIP } from "../constants/presets";
11
+ import { SIZE, VARIANT, POSITION, LABEL_STYLE, ICON_PLACEMENT, ICON_SPACING } from "../constants";
12
+ import { INFO_BAR_RAIL, INFO_BAR_RAIL_TEXT, INFO_BAR_RAIL_ICON_LEFT, INFO_BAR_RAIL_ICON_TOP, SUBTAB_STRIP } from "../constants/presets";
13
13
  /*
14
14
  * `uniqueId` is passed on every render on purpose. The id scope is otherwise
15
15
  * counter-based, so every id, aria-controls and aria-labelledby recorded below
@@ -33,6 +33,8 @@ const ITEMS = [{
33
33
  text: 'Charlie'
34
34
  }];
35
35
 
36
+ const readStylesheet = () => fs.readFileSync(path.join(__dirname, '..', 'css', 'Tab_v1.module.css'), 'utf8');
37
+
36
38
  function Group({
37
39
  uniqueId = 'tabs',
38
40
  tabProps,
@@ -578,7 +580,7 @@ describe('Tab - Snapshot', () => {
578
580
  expect(baseElement).toMatchSnapshot();
579
581
  });
580
582
  describe('Presets', () => {
581
- const presets = [['INFO_BAR_RAIL', INFO_BAR_RAIL], ['SUBTAB_STRIP', SUBTAB_STRIP]];
583
+ const presets = [['INFO_BAR_RAIL', INFO_BAR_RAIL], ['INFO_BAR_RAIL_TEXT', INFO_BAR_RAIL_TEXT], ['INFO_BAR_RAIL_ICON_LEFT', INFO_BAR_RAIL_ICON_LEFT], ['INFO_BAR_RAIL_ICON_TOP', INFO_BAR_RAIL_ICON_TOP], ['SUBTAB_STRIP', SUBTAB_STRIP]];
582
584
  test.each(presets)('Should render preset %s', (_name, preset) => {
583
585
  const {
584
586
  asFragment
@@ -591,6 +593,155 @@ describe('Tab - Snapshot', () => {
591
593
  });
592
594
  });
593
595
  });
596
+ describe('Tab - Info bar rail presets', () => {
597
+ const railPresets = [INFO_BAR_RAIL, INFO_BAR_RAIL_TEXT, INFO_BAR_RAIL_ICON_LEFT, INFO_BAR_RAIL_ICON_TOP];
598
+ test('every rail preset is the same vertical rail, differing only in its label', () => {
599
+ railPresets.forEach(preset => {
600
+ expect(preset).toMatchObject({
601
+ position: POSITION.LEFT,
602
+ hasSurface: true,
603
+ hasListBorder: true
604
+ });
605
+ });
606
+ });
607
+ test('INFO_BAR_RAIL_TEXT renders the text and drops the icon', () => {
608
+ const {
609
+ container
610
+ } = render( /*#__PURE__*/React.createElement(Group, _extends({}, INFO_BAR_RAIL_TEXT, {
611
+ tabProps: {
612
+ iconName: 'ZD-TB-menu'
613
+ }
614
+ })));
615
+ const tab = container.querySelector('[role="tab"]');
616
+ expect(tab.textContent).toContain('one');
617
+ expect(tab.querySelector('.iconBox')).toBeNull();
618
+ });
619
+ test.each([['INFO_BAR_RAIL_ICON_LEFT', INFO_BAR_RAIL_ICON_LEFT, ICON_PLACEMENT.LEFT], ['INFO_BAR_RAIL_ICON_TOP', INFO_BAR_RAIL_ICON_TOP, ICON_PLACEMENT.TOP]])('%s renders icon and text with its iconPlacement', (_name, preset, placement) => {
620
+ expect(preset.labelStyle).toBe(LABEL_STYLE.ICON_AND_TEXT);
621
+ expect(preset.iconPlacement).toBe(placement);
622
+ const {
623
+ container
624
+ } = render( /*#__PURE__*/React.createElement(Group, _extends({}, preset, {
625
+ tabProps: {
626
+ iconName: 'ZD-TB-menu'
627
+ }
628
+ })));
629
+ const tab = container.querySelector('[role="tab"]');
630
+ expect(tab.textContent).toContain('one');
631
+ expect(tab.querySelector('.iconBox')).not.toBeNull();
632
+ });
633
+
634
+ const getLabelParts = container => {
635
+ const tab = container.querySelector('[role="tab"]');
636
+ const content = tab.firstElementChild;
637
+ const text = Array.from(content.children).find(node => node.textContent === 'one');
638
+ return {
639
+ tab,
640
+ content,
641
+ text
642
+ };
643
+ };
644
+
645
+ test.each([['INFO_BAR_RAIL_ICON_LEFT', INFO_BAR_RAIL_ICON_LEFT]])('%s aligns the label to the start of the rail with left-aligned text', (_name, preset) => {
646
+ const {
647
+ container
648
+ } = render( /*#__PURE__*/React.createElement(Group, _extends({}, preset, {
649
+ tabProps: {
650
+ iconName: 'ZD-TB-menu'
651
+ }
652
+ })));
653
+ const {
654
+ tab,
655
+ content,
656
+ text
657
+ } = getLabelParts(container);
658
+ expect(tab.className).toContain('d-justify-start');
659
+ expect(content.className).toContain('d-justify-start');
660
+ expect(text.className).toContain('textalign_left');
661
+ });
662
+ test.each([['INFO_BAR_RAIL_ICON_TOP', INFO_BAR_RAIL_ICON_TOP], ['INFO_BAR_RAIL_TEXT', INFO_BAR_RAIL_TEXT]])('%s centres the label and its text', (_name, preset) => {
663
+ const {
664
+ container
665
+ } = render( /*#__PURE__*/React.createElement(Group, _extends({}, preset, {
666
+ tabProps: {
667
+ iconName: 'ZD-TB-menu'
668
+ }
669
+ })));
670
+ const {
671
+ tab,
672
+ content,
673
+ text
674
+ } = getLabelParts(container);
675
+ expect(tab.className).toContain('d-justify-center');
676
+ expect(content.className).toContain('d-justify-center');
677
+ expect(text.className).toContain('textalign_center');
678
+ });
679
+ test('a horizontal strip keeps a side-icon label centred in its tab', () => {
680
+ const {
681
+ container
682
+ } = render( /*#__PURE__*/React.createElement(Group, {
683
+ labelStyle: LABEL_STYLE.ICON_AND_TEXT,
684
+ isFullWidth: true,
685
+ tabProps: {
686
+ iconName: 'ZD-TB-menu'
687
+ }
688
+ }));
689
+ const {
690
+ tab,
691
+ content
692
+ } = getLabelParts(container);
693
+ expect(tab.className).toContain('d-justify-center');
694
+ expect(content.className).toContain('d-justify-center');
695
+ });
696
+ test.each(ICON_SPACING)('iconSpacing %s maps to a gap utility that css-utility defines', spacing => {
697
+ const utilities = fs.readFileSync(require.resolve('@dot-system/css-utility/es/utilities.plain.css'), 'utf8');
698
+ const {
699
+ container
700
+ } = render( /*#__PURE__*/React.createElement(Group, _extends({}, INFO_BAR_RAIL_ICON_LEFT, {
701
+ iconSpacing: spacing,
702
+ tabProps: {
703
+ iconName: 'ZD-TB-menu'
704
+ }
705
+ })));
706
+ const content = container.querySelector('[role="tab"]').firstElementChild;
707
+ const gapClass = `d-gap-[${spacing}px]`;
708
+ expect(content.classList.contains(gapClass)).toBe(true);
709
+ expect(utilities).toContain(`.d-gap-\\[${spacing}px\\]`);
710
+ });
711
+ test('SUBTAB_STRIP mirrors the ticket detail-view subtabs (v0 delta tabs)', () => {
712
+ expect(SUBTAB_STRIP).toMatchObject({
713
+ position: POSITION.TOP,
714
+ size: SIZE.SMALL,
715
+ variant: VARIANT.DOTTED,
716
+ labelStyle: LABEL_STYLE.TEXT,
717
+ textTransform: 'upper',
718
+ textTruncate: 'ellipsis',
719
+ hasListBorder: true,
720
+ hasListPadding: true
721
+ });
722
+ const {
723
+ container
724
+ } = render( /*#__PURE__*/React.createElement(Group, SUBTAB_STRIP));
725
+ const list = container.querySelector('[role="tablist"]');
726
+ const tab = container.querySelector('[role="tab"]');
727
+ expect(list.className).toContain('listDotted'); // The strip draws its own bottom border and start inset; a consumer only adjusts them.
728
+
729
+ expect(list.className).toContain('listTop');
730
+ expect(list.className).not.toContain('listNoBorder');
731
+ expect(list.className).not.toContain('listNoPadding');
732
+ expect(tab.className).toContain('tabDotted');
733
+ expect(tab.className).toContain('tabSmall');
734
+ expect(tab.querySelector('.transform_upper')).not.toBeNull();
735
+ });
736
+ test('a rail preset can move to the right edge by overriding position', () => {
737
+ const {
738
+ container
739
+ } = render( /*#__PURE__*/React.createElement(Group, _extends({}, INFO_BAR_RAIL_ICON_TOP, {
740
+ position: POSITION.RIGHT
741
+ })));
742
+ expect(container.querySelector('[role="tablist"]').className).toContain('listRight');
743
+ });
744
+ });
594
745
  /*
595
746
  * The behaviour these cover is not visible in a snapshot: the F1 font-size
596
747
  * cascade fix, the F2 customClass merge fix, a keyboard model, and a click
@@ -598,18 +749,17 @@ describe('Tab - Snapshot', () => {
598
749
  */
599
750
 
600
751
  describe('Tab - Behaviour', () => {
601
- test('size is the sole font-size axis: no variant re-declares --local-tab-font-size', () => {
752
+ test('size is the sole font-size axis: no variant declares font-size', () => {
602
753
  /*
603
- * The F1 regression. `--local-tab-font-size` is set by `.small` / `.medium`
604
- * / `.large`, but the `.elevated` / `.spaced` / `.dotted` preset-variant
605
- * blocks used to redeclare it too - and, appearing later in the file at
606
- * equal specificity on the same <Tabs> root element, they always won, so
607
- * `size` silently had no visible effect whenever a variant was also set.
754
+ * The F1 regression. Size and variant classes sit on the same tab element
755
+ * at equal specificity, and the variant blocks come later in the file - so
756
+ * a variant that declared font-size would always win, and `size` would
757
+ * silently have no visible effect whenever a variant was also set.
608
758
  *
609
759
  * jsdom applies no CSS-module styles, so the guard is in two parts: both
610
- * the size and variant classes must reach the root element together, and
611
- * the stylesheet must declare `--local-tab-font-size` in exactly the size
612
- * blocks, never in the variant blocks.
760
+ * the size and variant classes must reach the tab element together, and
761
+ * the stylesheet must declare font-size in exactly the size blocks, never
762
+ * in the variant blocks.
613
763
  */
614
764
  const {
615
765
  container
@@ -617,22 +767,150 @@ describe('Tab - Behaviour', () => {
617
767
  size: "large",
618
768
  variant: "elevated"
619
769
  }));
620
- const root = container.firstChild;
621
- expect(root.className).toContain('large');
622
- expect(root.className).toContain('elevated');
623
- const css = fs.readFileSync(path.join(__dirname, '..', 'css', 'Tab_v1.module.css'), 'utf8');
770
+ const tab = container.querySelector('[role="tab"]');
771
+ expect(tab.className).toContain('tabLarge');
772
+ expect(tab.className).toContain('tabElevated');
773
+ const css = readStylesheet();
624
774
 
625
775
  const block = selector => {
626
776
  const match = css.match(new RegExp(`\\.${selector}\\s*\\{([^}]*)\\}`));
627
777
  return match ? match[1] : '';
628
778
  };
629
779
 
630
- expect(block('small')).toMatch(/--local-tab-font-size/);
631
- expect(block('medium')).toMatch(/--local-tab-font-size/);
632
- expect(block('large')).toMatch(/--local-tab-font-size/);
633
- expect(block('elevated')).not.toMatch(/--local-tab-font-size/);
634
- expect(block('spaced')).not.toMatch(/--local-tab-font-size/);
635
- expect(block('dotted')).not.toMatch(/--local-tab-font-size/);
780
+ expect(block('tabSmall')).toMatch(/font-size/);
781
+ expect(block('tabMedium')).toMatch(/font-size/);
782
+ expect(block('tabLarge')).toMatch(/font-size/);
783
+ expect(block('tabElevated')).not.toMatch(/font-size/);
784
+ expect(block('tabSpaced')).not.toMatch(/font-size/);
785
+ expect(block('tabDotted')).not.toMatch(/font-size/);
786
+ });
787
+ test('the stylesheet exposes no --local-* variables: customClass is the only override path', () => {
788
+ expect(readStylesheet()).not.toMatch(/--local-/);
789
+ });
790
+ test('modifier classes land on the slots, not on the Tabs root', () => {
791
+ const {
792
+ container
793
+ } = render( /*#__PURE__*/React.createElement(Group, {
794
+ size: "small",
795
+ variant: "dotted",
796
+ position: "left",
797
+ hasSurface: true,
798
+ hasListBorder: false,
799
+ hasListPadding: false
800
+ }));
801
+ const root = container.firstChild;
802
+ const list = container.querySelector('[role="tablist"]');
803
+ const tab = container.querySelector('[role="tab"]');
804
+ const panel = container.querySelector('[role="tabpanel"]');
805
+ expect(root.className).not.toMatch(/\b(small|dotted|left|vertical|hasSurface)\b/);
806
+ expect(list.className).toEqual(expect.stringContaining('listDotted'));
807
+ expect(list.className).toEqual(expect.stringContaining('listLeft'));
808
+ expect(list.className).toEqual(expect.stringContaining('listVertical'));
809
+ expect(list.className).toEqual(expect.stringContaining('listSurface'));
810
+ expect(list.className).toEqual(expect.stringContaining('listNoBorder'));
811
+ expect(list.className).toEqual(expect.stringContaining('listNoPadding'));
812
+ expect(tab.className).toEqual(expect.stringContaining('tabSmall'));
813
+ expect(tab.className).toEqual(expect.stringContaining('tabDotted'));
814
+ expect(tab.className).toEqual(expect.stringContaining('tabLeft'));
815
+ expect(tab.className).toEqual(expect.stringContaining('tabVertical'));
816
+ expect(tab.className).toEqual(expect.stringContaining('tabSurface'));
817
+ expect(panel.className).toEqual(expect.stringContaining('panelSurface'));
818
+ expect(panel.className).toEqual(expect.stringContaining('panelDotted'));
819
+ });
820
+ test('a nested Tabs does not inherit the outer variant', () => {
821
+ render( /*#__PURE__*/React.createElement(Tabs, {
822
+ uniqueId: "outer",
823
+ variant: "elevated"
824
+ }, /*#__PURE__*/React.createElement(TabList, {
825
+ ariaLabel: "Outer"
826
+ }, /*#__PURE__*/React.createElement(Tab, {
827
+ value: "o1",
828
+ text: "o1"
829
+ })), /*#__PURE__*/React.createElement(TabPanel, {
830
+ value: "o1"
831
+ }, /*#__PURE__*/React.createElement(Tabs, {
832
+ uniqueId: "inner",
833
+ variant: "underline"
834
+ }, /*#__PURE__*/React.createElement(TabList, {
835
+ ariaLabel: "Inner"
836
+ }, /*#__PURE__*/React.createElement(Tab, {
837
+ value: "i1",
838
+ text: "i1"
839
+ })), /*#__PURE__*/React.createElement(TabPanel, {
840
+ value: "i1"
841
+ }, "Inner panel")))));
842
+ const outerTab = screen.getByRole('tab', {
843
+ name: 'o1'
844
+ });
845
+ const innerTab = screen.getByRole('tab', {
846
+ name: 'i1'
847
+ });
848
+ expect(outerTab.className).toContain('tabElevated');
849
+ expect(innerTab.className).not.toContain('tabElevated');
850
+ expect(screen.getByRole('tablist', {
851
+ name: 'Inner'
852
+ }).className).not.toContain('listElevated');
853
+ });
854
+ test('single-value properties come from d-* utilities, as mutually exclusive variants', () => {
855
+ /*
856
+ * The utility layer and the component layer have no declared order, so a
857
+ * d-* class must never compete with a component rule for one property.
858
+ * Exclusive values are cva variants: exactly one of each pair is applied.
859
+ */
860
+ render( /*#__PURE__*/React.createElement(Tabs, {
861
+ uniqueId: "tabs",
862
+ variant: "dotted"
863
+ }, /*#__PURE__*/React.createElement(TabList, {
864
+ ariaLabel: "Cities"
865
+ }, /*#__PURE__*/React.createElement(Tab, {
866
+ value: "one",
867
+ text: "one"
868
+ }), /*#__PURE__*/React.createElement(Tab, {
869
+ value: "two",
870
+ text: "two",
871
+ isDisabled: true
872
+ }))));
873
+ const [enabled, disabled] = screen.getAllByRole('tab');
874
+ const list = screen.getByRole('tablist');
875
+ expect(enabled.className).toContain('d-cursor-pointer');
876
+ expect(enabled.className).not.toContain('d-cursor-not-allowed');
877
+ expect(disabled.className).toContain('d-cursor-not-allowed');
878
+ expect(disabled.className).not.toContain('d-cursor-pointer');
879
+ expect(list.className).toContain('d-border-dotted');
880
+ expect(list.className).not.toContain('d-border-solid'); // margins are set per variant in the stylesheet, so no d-m-0 to fight them
881
+
882
+ expect(enabled.className).not.toContain('d-m-0');
883
+ });
884
+ test('the stylesheet does not re-declare what a d-* utility now owns', () => {
885
+ const css = readStylesheet();
886
+
887
+ const block = selector => {
888
+ const match = css.match(new RegExp(`(?:^|\\n)\\.${selector}\\s*\\{([^}]*)\\}`));
889
+ return match ? match[1] : null;
890
+ };
891
+
892
+ expect(block('content')).toBeNull();
893
+ expect(block('tabText')).toBeNull();
894
+ expect(block('moreWrapper')).toBeNull();
895
+ expect(block('moreItem')).toBeNull();
896
+ expect(block('list')).not.toMatch(/border-style/);
897
+ expect(block('tab')).not.toMatch(/cursor/);
898
+ expect(css).not.toMatch(/\.listDotted\s*\{[^}]*border-style/);
899
+ });
900
+ test('a customClass slot class is appended after the component classes', () => {
901
+ const {
902
+ container
903
+ } = render( /*#__PURE__*/React.createElement(Group, {
904
+ variant: "elevated",
905
+ customClass: {
906
+ tab: 'my-tab',
907
+ list: 'my-list'
908
+ }
909
+ }));
910
+ const tab = container.querySelector('[role="tab"]');
911
+ const list = container.querySelector('[role="tablist"]');
912
+ expect(tab.className.trim().split(/\s+/).pop()).toBe('my-tab');
913
+ expect(list.className).toMatch(/listElevated.*my-list/);
636
914
  });
637
915
  test('a group customClass.tab is merged with, not overwritten by, a per-tab getClasses call', () => {
638
916
  /*
@@ -821,4 +1099,191 @@ describe('Tab - Behaviour', () => {
821
1099
 
822
1100
  expect(document.querySelector('input[name="search"]')).toBeNull();
823
1101
  });
1102
+ });
1103
+ /*
1104
+ * Per-item customClass and renderAction exist for the ticket detail-view
1105
+ * subtab strip: a custom-lookup tab caps its own width, and the conversation
1106
+ * tab carries an interactive view-type menu that must not nest inside the
1107
+ * <button role="tab">.
1108
+ */
1109
+
1110
+ describe('Tab - Item customClass, renderAction and an inline more menu', () => {
1111
+ test('a data-driven item customClass lands on that tab only', () => {
1112
+ render( /*#__PURE__*/React.createElement(Tabs, {
1113
+ uniqueId: "tabs"
1114
+ }, /*#__PURE__*/React.createElement(TabList, {
1115
+ ariaLabel: "Cities",
1116
+ minVisibleTabs: ITEMS.length,
1117
+ items: ITEMS.map(item => item.value === 'b' ? { ...item,
1118
+ customClass: {
1119
+ tab: 'capped-tab'
1120
+ }
1121
+ } : item)
1122
+ })));
1123
+ expect(screen.getByRole('tab', {
1124
+ name: 'Bravo'
1125
+ }).className).toContain('capped-tab');
1126
+ expect(screen.getByRole('tab', {
1127
+ name: 'Alpha'
1128
+ }).className).not.toContain('capped-tab');
1129
+ expect(screen.getByRole('tab', {
1130
+ name: 'Charlie'
1131
+ }).className).not.toContain('capped-tab');
1132
+ });
1133
+ test('changing only an item customClass re-renders that tab', () => {
1134
+ const renderList = tabClass => /*#__PURE__*/React.createElement(Tabs, {
1135
+ uniqueId: "tabs"
1136
+ }, /*#__PURE__*/React.createElement(TabList, {
1137
+ ariaLabel: "Cities",
1138
+ minVisibleTabs: ITEMS.length,
1139
+ items: ITEMS.map(item => item.value === 'a' ? { ...item,
1140
+ customClass: {
1141
+ tab: tabClass
1142
+ }
1143
+ } : item)
1144
+ }));
1145
+
1146
+ const {
1147
+ rerender
1148
+ } = render(renderList('first-class'));
1149
+ rerender(renderList('second-class'));
1150
+ const tab = screen.getByRole('tab', {
1151
+ name: 'Alpha'
1152
+ });
1153
+ expect(tab.className).toContain('second-class');
1154
+ expect(tab.className).not.toContain('first-class');
1155
+ });
1156
+ test('renderAction renders beside the tab button, never inside it', () => {
1157
+ render( /*#__PURE__*/React.createElement(Tabs, {
1158
+ uniqueId: "tabs",
1159
+ selectedValue: "one"
1160
+ }, /*#__PURE__*/React.createElement(TabList, {
1161
+ ariaLabel: "Cities"
1162
+ }, /*#__PURE__*/React.createElement(Tab, {
1163
+ value: "one",
1164
+ text: "one",
1165
+ customId: "one_Tab",
1166
+ renderAction: () => /*#__PURE__*/React.createElement("button", {
1167
+ type: "button"
1168
+ }, "view")
1169
+ }), /*#__PURE__*/React.createElement(Tab, {
1170
+ value: "two",
1171
+ text: "two"
1172
+ }))));
1173
+ const tab = screen.getByRole('tab', {
1174
+ name: 'one'
1175
+ });
1176
+ const action = screen.getByRole('button', {
1177
+ name: 'view'
1178
+ });
1179
+ expect(tab.contains(action)).toBe(false);
1180
+ expect(tab.querySelector('button')).toBeNull();
1181
+ /* The wrapper is the visual tab: it holds both, carries the state and the ids. */
1182
+
1183
+ const wrapper = tab.parentElement;
1184
+ expect(wrapper.contains(action)).toBe(true);
1185
+ expect(wrapper).toHaveAttribute('data-selected', 'true');
1186
+ expect(wrapper).toHaveAttribute('data-id', 'one_Tab');
1187
+ expect(tab).not.toHaveAttribute('data-id', 'one_Tab');
1188
+ expect(wrapper.className).toContain('tab');
1189
+ expect(tab.className).toContain('tabTrigger');
1190
+ /* The wrapper is the direct child the adaptive renderer measures. */
1191
+
1192
+ expect(wrapper.parentElement).toBe(screen.getByRole('tablist'));
1193
+ });
1194
+ test('without renderAction the tab DOM is unchanged', () => {
1195
+ render( /*#__PURE__*/React.createElement(Tabs, {
1196
+ uniqueId: "tabs"
1197
+ }, /*#__PURE__*/React.createElement(TabList, {
1198
+ ariaLabel: "Cities"
1199
+ }, /*#__PURE__*/React.createElement(Tab, {
1200
+ value: "one",
1201
+ text: "one"
1202
+ }))));
1203
+ const tab = screen.getByRole('tab', {
1204
+ name: 'one'
1205
+ });
1206
+ expect(tab.parentElement).toBe(screen.getByRole('tablist'));
1207
+ expect(tab.className).not.toContain('tabTrigger');
1208
+ });
1209
+ test('the wrapper follows selection and the trigger still selects on click', () => {
1210
+ const onChange = jest.fn();
1211
+ render( /*#__PURE__*/React.createElement(Tabs, {
1212
+ uniqueId: "tabs",
1213
+ defaultValue: "one",
1214
+ onChange: onChange
1215
+ }, /*#__PURE__*/React.createElement(TabList, {
1216
+ ariaLabel: "Cities"
1217
+ }, /*#__PURE__*/React.createElement(Tab, {
1218
+ value: "one",
1219
+ text: "one"
1220
+ }), /*#__PURE__*/React.createElement(Tab, {
1221
+ value: "two",
1222
+ text: "two",
1223
+ renderAction: () => /*#__PURE__*/React.createElement("span", null, "action")
1224
+ }))));
1225
+ const two = screen.getByRole('tab', {
1226
+ name: 'two'
1227
+ });
1228
+ expect(two.parentElement).toHaveAttribute('data-selected', 'false');
1229
+ onChange.mockClear();
1230
+ fireEvent.click(two);
1231
+ expect(onChange).toHaveBeenCalledWith(expect.objectContaining({
1232
+ value: 'two'
1233
+ }), expect.anything());
1234
+ expect(two.parentElement).toHaveAttribute('data-selected', 'true');
1235
+ });
1236
+ test('a data-driven item forwards renderAction, with the slot state', () => {
1237
+ render( /*#__PURE__*/React.createElement(Tabs, {
1238
+ uniqueId: "tabs",
1239
+ selectedValue: "a"
1240
+ }, /*#__PURE__*/React.createElement(TabList, {
1241
+ ariaLabel: "Cities",
1242
+ minVisibleTabs: ITEMS.length,
1243
+ items: ITEMS.map(item => item.value === 'a' ? { ...item,
1244
+ renderAction: ({
1245
+ isSelected
1246
+ }) => /*#__PURE__*/React.createElement("span", null, `action-${isSelected}`)
1247
+ } : item)
1248
+ })));
1249
+ const tab = screen.getByRole('tab', {
1250
+ name: 'Alpha'
1251
+ });
1252
+ const action = screen.getByText('action-true');
1253
+ expect(tab.contains(action)).toBe(false);
1254
+ expect(tab.parentElement.contains(action)).toBe(true);
1255
+ });
1256
+ test('selected and disabled styles also target the action wrapper', () => {
1257
+ const css = readStylesheet();
1258
+ ['tab', 'tabElevated', 'tabSpaced', 'tabDotted'].forEach(selector => {
1259
+ expect(css).toMatch(new RegExp(`\\.${selector}\\[data-selected='true'\\]`));
1260
+ });
1261
+ expect(css).toMatch(/\.tab\[data-disabled='true'\]/);
1262
+ });
1263
+ test('the data-driven list clips overflow only while the more menu is portalled', () => {
1264
+ const {
1265
+ rerender
1266
+ } = render( /*#__PURE__*/React.createElement(Tabs, {
1267
+ uniqueId: "tabs"
1268
+ }, /*#__PURE__*/React.createElement(TabList, {
1269
+ ariaLabel: "Cities",
1270
+ items: ITEMS
1271
+ })));
1272
+ expect(screen.getByRole('tablist').className).toContain('d-overflow-hidden');
1273
+ /* An inline (absolutely positioned) menu renders inside the list, so a
1274
+ * clipping list would hide it. */
1275
+
1276
+ rerender( /*#__PURE__*/React.createElement(Tabs, {
1277
+ uniqueId: "tabs"
1278
+ }, /*#__PURE__*/React.createElement(TabList, {
1279
+ ariaLabel: "Cities",
1280
+ items: ITEMS,
1281
+ customProps: {
1282
+ popup: {
1283
+ isAbsolutePositioningNeeded: true
1284
+ }
1285
+ }
1286
+ })));
1287
+ expect(screen.getByRole('tablist').className).not.toContain('d-overflow-hidden');
1288
+ });
824
1289
  });