uikit-react-public 0.17.4 → 0.21.8
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/README.md +2 -4
- package/dist/components/Accordion/Accordion.Heading.d.ts +1 -0
- package/dist/components/AppHeader/AppHeader.d.ts +1 -1
- package/dist/components/AppHeader/AppHeaderBottom.d.ts +1 -1
- package/dist/components/AppHeader/AppHeaderNav.d.ts +1 -1
- package/dist/components/AppHeader/AppHeaderTop.d.ts +1 -1
- package/dist/components/Breadcrumbs/Breadcrumb.d.ts +3 -4
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.stories.d.ts +1 -1
- package/dist/components/Button/Button.d.ts +7 -3
- package/dist/components/Button/Button.stories.d.ts +17 -7
- package/dist/components/Button/style/buttonAccentStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonPrimaryDestructiveStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonPrimaryStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonPrimarySubtleStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonPrimaryWarningStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonSecondaryDestructiveStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonSecondaryStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonSecondarySubtleStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonTertiaryDestructiveStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonTertiaryNoPaddingStyle.d.ts +4 -0
- package/dist/components/Button/style/buttonTertiaryStyle.d.ts +4 -0
- package/dist/components/Checkbox/Checkbox.d.ts +1 -0
- package/dist/components/FooterNew/BackToTop.d.ts +8 -0
- package/dist/components/FooterNew/Footer.d.ts +23 -0
- package/dist/components/FooterNew/FooterColumn.d.ts +8 -0
- package/dist/components/FooterNew/FooterLinks.d.ts +7 -0
- package/dist/components/FooterNew/FooterNavLink.d.ts +8 -0
- package/dist/components/FooterNew/LegalAndCopyright.d.ts +14 -0
- package/dist/components/FooterNew/LogoAddressAndSocial.d.ts +10 -0
- package/dist/components/FooterNew/SocialLink.d.ts +8 -0
- package/dist/components/FooterNew/__tests__/Footer.test.d.ts +1 -0
- package/dist/components/FooterNew/index.d.ts +2 -0
- package/dist/components/HeaderNew/Header.d.ts +18 -0
- package/dist/components/HeaderNew/HeaderBorder.d.ts +7 -0
- package/dist/components/HeaderNew/HeaderLogo.d.ts +9 -0
- package/dist/components/HeaderNew/HeaderMenuContainer.d.ts +7 -0
- package/dist/components/HeaderNew/HeaderTitle.d.ts +9 -0
- package/dist/components/HeaderNew/__tests__/Header.test.d.ts +1 -0
- package/dist/components/HeaderNew/constants.d.ts +3 -0
- package/dist/components/HeaderNew/index.d.ts +3 -0
- package/dist/components/HeadingNew/Heading.d.ts +13 -0
- package/dist/components/HeadingNew/index.d.ts +2 -0
- package/dist/components/Icon/svgImports.d.ts +7 -881
- package/dist/components/Link/BaseLink.d.ts +14 -5
- package/dist/components/Link/Link.d.ts +8 -3
- package/dist/components/Link/Link.stories.d.ts +3 -1
- package/dist/components/MenuNew/Menu.context.d.ts +14 -0
- package/dist/components/MenuNew/Menu.d.ts +20 -0
- package/dist/components/MenuNew/MenuContent.d.ts +9 -0
- package/dist/components/MenuNew/MenuItem.d.ts +10 -0
- package/dist/components/MenuNew/MenuSection.d.ts +7 -0
- package/dist/components/MenuNew/index.d.ts +6 -0
- package/dist/components/MenuNew/trigger/ButtonMenuTrigger.d.ts +8 -0
- package/dist/components/MenuNew/trigger/IconMenuTrigger.d.ts +8 -0
- package/dist/components/Overlay/Overlay.stories.d.ts +12 -12
- package/dist/components/ParagraphNew/Paragraph.d.ts +13 -0
- package/dist/components/ParagraphNew/index.d.ts +4 -0
- package/dist/components/Select/Select.d.ts +2 -1
- package/dist/components/Select/Select.stories.d.ts +13 -1
- package/dist/components/Select/Select.types.d.ts +40 -13
- package/dist/components/Select/subcomponents/CustomSelect.d.ts +3 -3
- package/dist/components/Select/subcomponents/FilterInput.d.ts +3 -1
- package/dist/components/Select/subcomponents/NativeSelect.d.ts +2 -2
- package/dist/components/Select/subcomponents/VisibleField.d.ts +4 -1
- package/dist/components/Spinner/Spinner.d.ts +2 -0
- package/dist/components/StandaloneLink/StandaloneLink.d.ts +8 -5
- package/dist/components/StandaloneLink/StandaloneLink.stories.d.ts +3 -1
- package/dist/components/Table/Table.d.ts +3 -3
- package/dist/components/Table/Table.stories.d.ts +3 -3
- package/dist/components/Table/Table.types.d.ts +1 -0
- package/dist/components/Table/subcomponents/Cell/Cell.d.ts +5 -1
- package/dist/components/Table/subcomponents/Cell/Cell.stories.d.ts +15 -13
- package/dist/components/Table/subcomponents/Cell/CellContent.d.ts +5 -1
- package/dist/components/Table/subcomponents/HeadCell/HeadCell.d.ts +2 -1
- package/dist/components/Table/subcomponents/HeadCell/HeadCell.stories.d.ts +14 -13
- package/dist/components/Table/subcomponents/HeadCell/HeadCellContent.d.ts +2 -1
- package/dist/components/Table/subcomponents/__tests__/Row.test.d.ts +1 -0
- package/dist/components/UclLogoNew/UclLogo.d.ts +8 -0
- package/dist/components/UclLogoNew/index.d.ts +2 -0
- package/dist/components/index.d.ts +12 -0
- package/dist/index.js +20909 -16022
- package/dist/theme/__tests__/fonts.test.d.ts +1 -0
- package/dist/theme/common/themeCommon.d.ts +904 -0
- package/dist/theme/fonts.d.ts +18 -0
- package/dist/theme/index.d.ts +6 -3
- package/dist/theme/light/lightColour.d.ts +126 -0
- package/dist/theme/light/lightTheme.d.ts +3 -0
- package/dist/theme/original/color.d.ts +166 -0
- package/dist/theme/original/defaultTheme.d.ts +1340 -0
- package/dist/theme/original/originalColourNewStructure.d.ts +126 -0
- package/dist/theme/useTheme.d.ts +2174 -0
- package/dist/utils/addAlphaToHex.d.ts +5 -0
- package/dist/utils/scrollToTop.d.ts +2 -0
- package/lib/components/Accordion/Accordion.Heading.tsx +51 -39
- package/lib/components/Accordion/Accordion.Panel.tsx +0 -4
- package/lib/components/Accordion/Accordion.tsx +34 -28
- package/lib/components/Accordion/__tests__/__snapshots__/Accordion.test.tsx.snap +12 -10
- package/lib/components/Alert/Alert.tsx +12 -12
- package/lib/components/Alert/__tests__/__snapshots__/Alert.test.tsx.snap +13 -39
- package/lib/components/AppHeader/AppHeader.tsx +6 -11
- package/lib/components/AppHeader/AppHeaderBottom.tsx +2 -3
- package/lib/components/AppHeader/AppHeaderNav.tsx +2 -3
- package/lib/components/AppHeader/AppHeaderTop.tsx +1 -1
- package/lib/components/AppHeader/__tests__/__snapshots__/AppHeader.test.tsx.snap +2 -2
- package/lib/components/AppMenu/__tests__/__snapshots__/AppMenu.test.tsx.snap +6 -19
- package/lib/components/Badge/Badge.stories.tsx +1 -1
- package/lib/components/Breadcrumbs/Breadcrumb.tsx +26 -12
- package/lib/components/Breadcrumbs/Breadcrumbs.tsx +1 -1
- package/lib/components/Breadcrumbs/__tests__/Breadcrumbs.test.tsx +9 -27
- package/lib/components/Breadcrumbs/__tests__/__snapshots__/Breadcrumbs.test.tsx.snap +24 -20
- package/lib/components/Button/Button.mdx +32 -279
- package/lib/components/Button/Button.stories.tsx +43 -50
- package/lib/components/Button/Button.tsx +165 -25
- package/lib/components/Button/__tests__/Button.test.tsx +49 -15
- package/lib/components/Button/__tests__/__snapshots__/Button.test.tsx.snap +80 -73
- package/lib/components/Button/style/buttonAccentStyle.ts +53 -0
- package/lib/components/Button/style/buttonPrimaryDestructiveStyle.ts +55 -0
- package/lib/components/Button/style/buttonPrimaryStyle.ts +53 -0
- package/lib/components/Button/style/buttonPrimarySubtleStyle.ts +64 -0
- package/lib/components/Button/style/buttonPrimaryWarningStyle.ts +56 -0
- package/lib/components/Button/style/buttonSecondaryDestructiveStyle.ts +63 -0
- package/lib/components/Button/style/buttonSecondaryStyle.ts +62 -0
- package/lib/components/Button/style/buttonSecondarySubtleStyle.ts +72 -0
- package/lib/components/Button/style/buttonTertiaryDestructiveStyle.ts +65 -0
- package/lib/components/Button/style/buttonTertiaryNoPaddingStyle.ts +52 -0
- package/lib/components/Button/style/buttonTertiaryStyle.ts +62 -0
- package/lib/components/Calendar/Calendar.stories.tsx +33 -13
- package/lib/components/Calendar/Calendar.tsx +2 -2
- package/lib/components/Calendar/__tests__/__snapshots__/Calendar.test.tsx.snap +99 -95
- package/lib/components/Calendar/subcomponents/AcademicWeek.tsx +2 -1
- package/lib/components/Calendar/subcomponents/AcademicWeeks.tsx +2 -3
- package/lib/components/Calendar/subcomponents/ColumnHeading.tsx +3 -7
- package/lib/components/Calendar/subcomponents/Controls.tsx +1 -1
- package/lib/components/Calendar/subcomponents/Day.stories.tsx +1 -1
- package/lib/components/Calendar/subcomponents/Day.tsx +7 -9
- package/lib/components/Calendar/subcomponents/EventDot.tsx +4 -8
- package/lib/components/Checkbox/Checkbox.stories.tsx +1 -1
- package/lib/components/Checkbox/Checkbox.tsx +12 -10
- package/lib/components/Checkbox/__tests__/Checkbox.test.tsx +29 -0
- package/lib/components/Checkbox/__tests__/__snapshots__/Checkbox.test.tsx.snap +4 -4
- package/lib/components/Datepicker/__tests__/Datepicker.test.tsx +117 -0
- package/lib/components/Datepicker/__tests__/__snapshots__/Datepicker.test.tsx.snap +16 -44
- package/lib/components/Datepicker/subcomponents/CustomDatepicker.tsx +10 -1
- package/lib/components/Datepicker/subcomponents/VisibleField.tsx +24 -23
- package/lib/components/Dialog/BaseDialog.tsx +2 -2
- package/lib/components/Dialog/Dialog.stories.tsx +1 -1
- package/lib/components/Divider/__tests__/__snapshots__/Breadcrumbs.test.tsx.snap +12 -12
- package/lib/components/FeedbackDialog/FeedbackDialog.stories.tsx +1 -1
- package/lib/components/FeedbackDialog/FeedbackDialog.tsx +4 -6
- package/lib/components/Field/CharacterCount.tsx +2 -2
- package/lib/components/Field/ErrorText.tsx +1 -1
- package/lib/components/Field/Field.tsx +1 -1
- package/lib/components/Field/HelperText.tsx +3 -1
- package/lib/components/FileInput/FileInput.stories.tsx +1 -1
- package/lib/components/FileInput/__tests__/__snapshots__/FileInput.test.tsx.snap +4 -20
- package/lib/components/Footer/__tests__/__snapshots__/Footer.test.tsx.snap +70 -79
- package/lib/components/FooterNew/BackToTop.tsx +83 -0
- package/lib/components/FooterNew/Footer.tsx +110 -0
- package/lib/components/FooterNew/FooterColumn.tsx +79 -0
- package/lib/components/FooterNew/FooterLinks.tsx +44 -0
- package/lib/components/FooterNew/FooterNavLink.tsx +63 -0
- package/lib/components/FooterNew/LegalAndCopyright.tsx +150 -0
- package/lib/components/FooterNew/LogoAddressAndSocial.tsx +154 -0
- package/lib/components/FooterNew/SocialLink.tsx +108 -0
- package/lib/components/FooterNew/__tests__/Footer.test.tsx +51 -0
- package/lib/components/FooterNew/__tests__/__snapshots__/Footer.test.tsx.snap +1107 -0
- package/lib/components/FooterNew/index.ts +2 -0
- package/lib/components/HeaderDraft/__tests__/__snapshots__/Header.test.tsx.snap +3 -2
- package/lib/components/HeaderNew/Header.tsx +93 -0
- package/lib/components/HeaderNew/HeaderBorder.tsx +55 -0
- package/lib/components/HeaderNew/HeaderLogo.tsx +70 -0
- package/lib/components/HeaderNew/HeaderMenuContainer.tsx +35 -0
- package/lib/components/HeaderNew/HeaderTitle.tsx +53 -0
- package/lib/components/HeaderNew/__tests__/Header.test.tsx +42 -0
- package/lib/components/HeaderNew/__tests__/__snapshots__/Header.test.tsx.snap +79 -0
- package/lib/components/HeaderNew/constants.ts +3 -0
- package/lib/components/HeaderNew/index.ts +7 -0
- package/lib/components/HeadingNew/Heading.tsx +208 -0
- package/lib/components/HeadingNew/index.ts +2 -0
- package/lib/components/Icon/__tests__/__snapshots__/Icon.test.tsx.snap +16 -12
- package/lib/components/Icon/svgImports.ts +318 -296
- package/lib/components/IconButton/IconButton.tsx +3 -4
- package/lib/components/IconButton/__tests__/__snapshots__/IconButton.test.tsx.snap +12 -9
- package/lib/components/Link/BaseLink.tsx +114 -71
- package/lib/components/Link/Link.stories.tsx +1 -1
- package/lib/components/Link/Link.tsx +120 -109
- package/lib/components/Link/__tests__/__snapshots__/link.test.tsx.snap +2 -2
- package/lib/components/MenuNew/Menu.context.tsx +149 -0
- package/lib/components/MenuNew/Menu.tsx +75 -0
- package/lib/components/MenuNew/MenuContent.tsx +140 -0
- package/lib/components/MenuNew/MenuItem.tsx +101 -0
- package/lib/components/MenuNew/MenuSection.tsx +47 -0
- package/lib/components/MenuNew/index.ts +8 -0
- package/lib/components/MenuNew/trigger/ButtonMenuTrigger.tsx +42 -0
- package/lib/components/MenuNew/trigger/IconMenuTrigger.tsx +40 -0
- package/lib/components/Pagination/Pagination.stories.tsx +1 -1
- package/lib/components/Pagination/PaginationControls.tsx +4 -5
- package/lib/components/Pagination/PaginationInfo.tsx +2 -3
- package/lib/components/ParagraphNew/Paragraph.tsx +200 -0
- package/lib/components/ParagraphNew/index.ts +6 -0
- package/lib/components/Radio/Radio.stories.tsx +1 -1
- package/lib/components/Radio/Radio.tsx +8 -8
- package/lib/components/Radio/__tests__/__snapshots__/Radio.test.tsx.snap +4 -4
- package/lib/components/Search/__tests__/__snapshots__/Search.test.tsx.snap +12 -32
- package/lib/components/Select/Select.mdx +23 -0
- package/lib/components/Select/Select.stories.tsx +43 -10
- package/lib/components/Select/Select.tsx +14 -3
- package/lib/components/Select/Select.types.ts +53 -16
- package/lib/components/Select/__tests__/Select.test.tsx +250 -1
- package/lib/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +5 -4
- package/lib/components/Select/subcomponents/CustomOption.tsx +10 -3
- package/lib/components/Select/subcomponents/CustomSelect.tsx +110 -10
- package/lib/components/Select/subcomponents/FilterInput.tsx +13 -3
- package/lib/components/Select/subcomponents/NativeSelect.tsx +10 -18
- package/lib/components/Select/subcomponents/Panel.tsx +2 -2
- package/lib/components/Select/subcomponents/VisibleField.tsx +48 -3
- package/lib/components/Snackbar/__tests__/__snapshots__/Snackbar.test.tsx.snap +9 -15
- package/lib/components/Spinner/Spinner.tsx +24 -5
- package/lib/components/Spinner/__tests__/Spinner.test.tsx +35 -5
- package/lib/components/Spinner/__tests__/__snapshots__/Spinner.test.tsx.snap +40 -16
- package/lib/components/StandaloneLink/StandaloneLink.stories.tsx +1 -1
- package/lib/components/StandaloneLink/StandaloneLink.tsx +180 -163
- package/lib/components/StandaloneLink/__tests__/__snapshots__/StandaloneLink.test.tsx.snap +2 -2
- package/lib/components/Table/Table.stories.tsx +1 -1
- package/lib/components/Table/Table.tsx +2 -0
- package/lib/components/Table/Table.types.ts +1 -0
- package/lib/components/Table/__tests__/Table.test.tsx +19 -0
- package/lib/components/Table/__tests__/__snapshots__/Table.test.tsx.snap +7 -3
- package/lib/components/Table/subcomponents/Cell/Cell.stories.tsx +1 -1
- package/lib/components/Table/subcomponents/Cell/Cell.tsx +23 -2
- package/lib/components/Table/subcomponents/Cell/CellContent.tsx +12 -1
- package/lib/components/Table/subcomponents/Cell/__tests__/Cell.test.tsx +106 -0
- package/lib/components/Table/subcomponents/Cell/__tests__/__snapshots__/Cell.test.tsx.snap +4 -3
- package/lib/components/Table/subcomponents/HeadCell/HeadCell.stories.tsx +1 -1
- package/lib/components/Table/subcomponents/HeadCell/HeadCell.tsx +28 -6
- package/lib/components/Table/subcomponents/HeadCell/HeadCellContent.tsx +3 -0
- package/lib/components/Table/subcomponents/HeadCell/__tests__/HeadCell.test.tsx +221 -2
- package/lib/components/Table/subcomponents/HeadCell/__tests__/__snapshots__/HeadCell.test.tsx.snap +6 -4
- package/lib/components/Table/subcomponents/Row.tsx +2 -2
- package/lib/components/Table/subcomponents/SortIcon.tsx +1 -0
- package/lib/components/Table/subcomponents/__tests__/Row.test.tsx +59 -0
- package/lib/components/Tabs/Tab.tsx +3 -3
- package/lib/components/Tabs/Tabs.stories.tsx +1 -1
- package/lib/components/Tabs/Tabs.tsx +5 -3
- package/lib/components/Tabs/__tests__/__snapshots__/Tabs.test.tsx.snap +4 -4
- package/lib/components/Timepicker/Timepicker.stories.tsx +1 -1
- package/lib/components/Toggle/Toggle.tsx +5 -5
- package/lib/components/Toggle/ToggleHandle.tsx +2 -3
- package/lib/components/Tooltip/Tooltip.tsx +2 -2
- package/lib/components/Tooltip/__tests__/__snapshots__/tooltip.test.tsx.snap +2 -2
- package/lib/components/UclLogoNew/UclLogo.tsx +42 -0
- package/lib/components/UclLogoNew/index.ts +2 -0
- package/lib/components/WeekPicker/WeekPicker.stories.tsx +3 -5
- package/lib/components/common/Common.mdx +0 -1
- package/lib/components/index.ts +19 -1
- package/lib/theme/Colours.mdx +1 -1
- package/lib/theme/Theme.mdx +1 -1
- package/lib/theme/Typography.mdx +1 -1
- package/lib/theme/__tests__/fonts.test.ts +37 -0
- package/lib/theme/common/themeCommon.ts +515 -0
- package/lib/theme/fonts.ts +110 -0
- package/lib/theme/index.ts +6 -6
- package/lib/theme/light/lightColour.ts +232 -0
- package/lib/theme/light/lightTheme.ts +37 -0
- package/lib/theme/{defaultTheme.ts → original/color.ts} +17 -199
- package/lib/theme/original/defaultTheme.ts +207 -0
- package/lib/theme/original/originalColourNewStructure.ts +185 -0
- package/lib/theme/useTheme.tsx +72 -15
- package/lib/types/assets.d.ts +10 -0
- package/lib/utils/addAlphaToHex.ts +29 -0
- package/lib/utils/scrollToTop.ts +5 -0
- package/package.json +11 -6
- package/dist/components/Button/buttonPrimaryStyle.d.ts +0 -4
- package/dist/components/Button/buttonSecondaryStyle.d.ts +0 -4
- package/dist/components/Button/buttonTertiaryStyle.d.ts +0 -4
- package/dist/theme/defaultTheme.d.ts +0 -274
- package/lib/components/Button/buttonPrimaryStyle.ts +0 -62
- package/lib/components/Button/buttonSecondaryStyle.ts +0 -65
- package/lib/components/Button/buttonTertiaryStyle.ts +0 -54
|
@@ -112,4 +112,110 @@ describe('Cell', () => {
|
|
|
112
112
|
buttonCell.click();
|
|
113
113
|
expect(handleButtonClick).toHaveBeenCalled();
|
|
114
114
|
});
|
|
115
|
+
|
|
116
|
+
// Accessibility tests
|
|
117
|
+
|
|
118
|
+
test('warns when variant="checkbox" is used without checkboxProps.ariaLabel', () => {
|
|
119
|
+
const consoleWarn = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
120
|
+
render(
|
|
121
|
+
<ThemeContextProvider>
|
|
122
|
+
<table>
|
|
123
|
+
<tbody>
|
|
124
|
+
<tr>
|
|
125
|
+
<Cell variant='checkbox' />
|
|
126
|
+
</tr>
|
|
127
|
+
</tbody>
|
|
128
|
+
</table>
|
|
129
|
+
</ThemeContextProvider>
|
|
130
|
+
);
|
|
131
|
+
expect(consoleWarn).toHaveBeenCalledWith(
|
|
132
|
+
expect.stringContaining('checkboxProps.ariaLabel is required')
|
|
133
|
+
);
|
|
134
|
+
consoleWarn.mockRestore();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test('does not warn when variant="checkbox" has checkboxProps.ariaLabel', () => {
|
|
138
|
+
const consoleWarn = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
139
|
+
render(
|
|
140
|
+
<ThemeContextProvider>
|
|
141
|
+
<table>
|
|
142
|
+
<tbody>
|
|
143
|
+
<tr>
|
|
144
|
+
<Cell
|
|
145
|
+
variant='checkbox'
|
|
146
|
+
checkboxProps={{ ariaLabel: 'Select John Smith' }}
|
|
147
|
+
/>
|
|
148
|
+
</tr>
|
|
149
|
+
</tbody>
|
|
150
|
+
</table>
|
|
151
|
+
</ThemeContextProvider>
|
|
152
|
+
);
|
|
153
|
+
expect(consoleWarn).not.toHaveBeenCalled();
|
|
154
|
+
consoleWarn.mockRestore();
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test('does not warn when variant="checkbox" has checkboxProps[aria-label]', () => {
|
|
158
|
+
const consoleWarn = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
159
|
+
render(
|
|
160
|
+
<ThemeContextProvider>
|
|
161
|
+
<table>
|
|
162
|
+
<tbody>
|
|
163
|
+
<tr>
|
|
164
|
+
<Cell
|
|
165
|
+
variant='checkbox'
|
|
166
|
+
checkboxProps={{ 'aria-label': 'Select John Smith' }}
|
|
167
|
+
/>
|
|
168
|
+
</tr>
|
|
169
|
+
</tbody>
|
|
170
|
+
</table>
|
|
171
|
+
</ThemeContextProvider>
|
|
172
|
+
);
|
|
173
|
+
expect(consoleWarn).not.toHaveBeenCalled();
|
|
174
|
+
consoleWarn.mockRestore();
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test('checkbox variant applies ariaLabel to the input via checkboxProps', () => {
|
|
178
|
+
const consoleWarn = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
179
|
+
render(
|
|
180
|
+
<ThemeContextProvider>
|
|
181
|
+
<table>
|
|
182
|
+
<tbody>
|
|
183
|
+
<tr>
|
|
184
|
+
<Cell
|
|
185
|
+
variant='checkbox'
|
|
186
|
+
checkboxProps={{ ariaLabel: 'Select John Smith' }}
|
|
187
|
+
/>
|
|
188
|
+
</tr>
|
|
189
|
+
</tbody>
|
|
190
|
+
</table>
|
|
191
|
+
</ThemeContextProvider>
|
|
192
|
+
);
|
|
193
|
+
expect(screen.getByRole('checkbox')).toHaveAttribute(
|
|
194
|
+
'aria-label',
|
|
195
|
+
'Select John Smith'
|
|
196
|
+
);
|
|
197
|
+
consoleWarn.mockRestore();
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
test('button variant applies aria-label via buttonProps', () => {
|
|
201
|
+
render(
|
|
202
|
+
<ThemeContextProvider>
|
|
203
|
+
<table>
|
|
204
|
+
<tbody>
|
|
205
|
+
<tr>
|
|
206
|
+
<Cell
|
|
207
|
+
variant='button'
|
|
208
|
+
buttonProps={{ 'aria-label': 'Edit John Smith' }}
|
|
209
|
+
>
|
|
210
|
+
Edit
|
|
211
|
+
</Cell>
|
|
212
|
+
</tr>
|
|
213
|
+
</tbody>
|
|
214
|
+
</table>
|
|
215
|
+
</ThemeContextProvider>
|
|
216
|
+
);
|
|
217
|
+
expect(
|
|
218
|
+
screen.getByRole('button', { name: 'Edit John Smith' })
|
|
219
|
+
).toBeInTheDocument();
|
|
220
|
+
});
|
|
115
221
|
});
|
|
@@ -44,7 +44,7 @@ exports[`Cell > Snapshot: variants 1`] = `
|
|
|
44
44
|
data-testid="ucl-uikit-table__cell-content"
|
|
45
45
|
>
|
|
46
46
|
<span
|
|
47
|
-
class="ucl-uikit-checkbox css-
|
|
47
|
+
class="ucl-uikit-checkbox css-tumlz"
|
|
48
48
|
>
|
|
49
49
|
<input
|
|
50
50
|
class="css-nzy7im"
|
|
@@ -66,6 +66,7 @@ exports[`Cell > Snapshot: variants 1`] = `
|
|
|
66
66
|
class="ucl-uikit-icon css-148hpxb"
|
|
67
67
|
data-testid="ucl-uikit-icon"
|
|
68
68
|
fill="none"
|
|
69
|
+
focusable="false"
|
|
69
70
|
height="24"
|
|
70
71
|
stroke="currentColor"
|
|
71
72
|
stroke-linecap="round"
|
|
@@ -79,7 +80,7 @@ exports[`Cell > Snapshot: variants 1`] = `
|
|
|
79
80
|
d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"
|
|
80
81
|
/>
|
|
81
82
|
<path
|
|
82
|
-
d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-
|
|
83
|
+
d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4z"
|
|
83
84
|
/>
|
|
84
85
|
</svg>
|
|
85
86
|
</div>
|
|
@@ -94,7 +95,7 @@ exports[`Cell > Snapshot: variants 1`] = `
|
|
|
94
95
|
>
|
|
95
96
|
<button
|
|
96
97
|
aria-disabled="false"
|
|
97
|
-
class="ucl-uikit-button css-
|
|
98
|
+
class="ucl-uikit-button css-9aah8t"
|
|
98
99
|
data-testid="ucl-uikit-button"
|
|
99
100
|
>
|
|
100
101
|
Button
|
|
@@ -3,8 +3,7 @@ import { useTheme } from '../../../../theme';
|
|
|
3
3
|
import HeadCellContent from './HeadCellContent';
|
|
4
4
|
import type { ColumnVariant, SortOrder } from '../../Table.types';
|
|
5
5
|
|
|
6
|
-
export interface TableHeadCellProps
|
|
7
|
-
extends React.HTMLAttributes<HTMLTableCellElement> {
|
|
6
|
+
export interface TableHeadCellProps extends React.HTMLAttributes<HTMLTableCellElement> {
|
|
8
7
|
variant?: ColumnVariant;
|
|
9
8
|
accessor?: string;
|
|
10
9
|
sort?: SortOrder;
|
|
@@ -20,6 +19,7 @@ export interface TableHeadCellProps
|
|
|
20
19
|
event: React.ChangeEvent<HTMLInputElement>
|
|
21
20
|
) => void;
|
|
22
21
|
testId?: string;
|
|
22
|
+
checkboxAriaLabel?: string;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const NAME = 'ucl-uikit-table__head-cell';
|
|
@@ -35,17 +35,17 @@ const HeadCell = ({
|
|
|
35
35
|
testId = NAME,
|
|
36
36
|
className,
|
|
37
37
|
children,
|
|
38
|
+
checkboxAriaLabel = 'Select all rows',
|
|
38
39
|
...props
|
|
39
40
|
}: TableHeadCellProps) => {
|
|
40
41
|
const [theme] = useTheme();
|
|
41
42
|
|
|
42
43
|
const isSortable = variant !== 'checkbox' && onSortChange && accessor;
|
|
43
44
|
|
|
44
|
-
const
|
|
45
|
+
const handleSortChange = (event: React.UIEvent) => {
|
|
45
46
|
if (onSortChange && !accessor)
|
|
46
47
|
console.warn(`${NAME}: onSortChange requires an accessor to be defined.`);
|
|
47
48
|
else if (isSortable) {
|
|
48
|
-
// Rotate sorting order on click
|
|
49
49
|
if (sort === 'asc') {
|
|
50
50
|
onSortChange(accessor, 'desc', event);
|
|
51
51
|
} else if (sort === 'desc') {
|
|
@@ -56,6 +56,17 @@ const HeadCell = ({
|
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
+
const handleClick = (event: React.MouseEvent) => {
|
|
60
|
+
handleSortChange(event);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const handleKeyDown = (event: React.KeyboardEvent) => {
|
|
64
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
handleSortChange(event);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
59
70
|
const handleCheckboxChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
60
71
|
if (variant === 'checkbox' && onCheck) onCheck(event.target.checked, event);
|
|
61
72
|
};
|
|
@@ -66,7 +77,7 @@ const HeadCell = ({
|
|
|
66
77
|
font-family: ${theme.font.family.primary};
|
|
67
78
|
font-weight: 400;
|
|
68
79
|
text-align: left;
|
|
69
|
-
cursor: pointer;
|
|
80
|
+
cursor: ${isSortable ? 'pointer' : 'default'};
|
|
70
81
|
user-select: none;
|
|
71
82
|
`;
|
|
72
83
|
|
|
@@ -75,12 +86,22 @@ const HeadCell = ({
|
|
|
75
86
|
return (
|
|
76
87
|
<th
|
|
77
88
|
onClick={handleClick}
|
|
89
|
+
onKeyDown={handleKeyDown}
|
|
78
90
|
scope='col'
|
|
79
91
|
className={style}
|
|
80
92
|
data-testid={testId}
|
|
81
93
|
data-accessor={accessor}
|
|
82
94
|
data-sort={sort}
|
|
83
|
-
|
|
95
|
+
tabIndex={isSortable ? 0 : undefined}
|
|
96
|
+
aria-sort={
|
|
97
|
+
isSortable
|
|
98
|
+
? sort === 'asc'
|
|
99
|
+
? 'ascending'
|
|
100
|
+
: sort === 'desc'
|
|
101
|
+
? 'descending'
|
|
102
|
+
: 'none'
|
|
103
|
+
: undefined
|
|
104
|
+
}
|
|
84
105
|
{...props}
|
|
85
106
|
>
|
|
86
107
|
<HeadCellContent
|
|
@@ -89,6 +110,7 @@ const HeadCell = ({
|
|
|
89
110
|
showSortIcon={showSortIcon}
|
|
90
111
|
checked={checked}
|
|
91
112
|
onCheckboxChange={handleCheckboxChange}
|
|
113
|
+
checkboxAriaLabel={checkboxAriaLabel}
|
|
92
114
|
>
|
|
93
115
|
{children}
|
|
94
116
|
</HeadCellContent>
|
|
@@ -8,6 +8,7 @@ interface HeadCellContentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
8
8
|
sort: SortOrder;
|
|
9
9
|
showSortIcon: boolean;
|
|
10
10
|
checked: boolean;
|
|
11
|
+
checkboxAriaLabel: string;
|
|
11
12
|
onCheckboxChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
12
13
|
}
|
|
13
14
|
|
|
@@ -19,6 +20,7 @@ const HeadCellContent = ({
|
|
|
19
20
|
showSortIcon,
|
|
20
21
|
checked,
|
|
21
22
|
onCheckboxChange,
|
|
23
|
+
checkboxAriaLabel,
|
|
22
24
|
children,
|
|
23
25
|
}: HeadCellContentProps) => {
|
|
24
26
|
const baseStyle = css`
|
|
@@ -52,6 +54,7 @@ const HeadCellContent = ({
|
|
|
52
54
|
<Checkbox
|
|
53
55
|
checked={checked}
|
|
54
56
|
onChange={onCheckboxChange}
|
|
57
|
+
ariaLabel={checkboxAriaLabel}
|
|
55
58
|
/>
|
|
56
59
|
)}
|
|
57
60
|
</div>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { describe, expect, test } from 'vitest';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
1
|
+
import { describe, expect, test, vi } from 'vitest';
|
|
2
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
3
|
import HeadCell from '../HeadCell';
|
|
4
4
|
import { ThemeContextProvider } from '../../../../../theme/useTheme';
|
|
5
5
|
|
|
@@ -134,4 +134,223 @@ describe('HeadCell', () => {
|
|
|
134
134
|
accessor
|
|
135
135
|
);
|
|
136
136
|
});
|
|
137
|
+
|
|
138
|
+
// Accessibility tests
|
|
139
|
+
|
|
140
|
+
test('sortable header has aria-sort="none" when sort is null', () => {
|
|
141
|
+
render(
|
|
142
|
+
<ThemeContextProvider>
|
|
143
|
+
<table>
|
|
144
|
+
<thead>
|
|
145
|
+
<tr>
|
|
146
|
+
<HeadCell
|
|
147
|
+
accessor='name'
|
|
148
|
+
onSortChange={vi.fn()}
|
|
149
|
+
>
|
|
150
|
+
Name
|
|
151
|
+
</HeadCell>
|
|
152
|
+
</tr>
|
|
153
|
+
</thead>
|
|
154
|
+
</table>
|
|
155
|
+
</ThemeContextProvider>
|
|
156
|
+
);
|
|
157
|
+
expect(screen.getByTestId('ucl-uikit-table__head-cell')).toHaveAttribute(
|
|
158
|
+
'aria-sort',
|
|
159
|
+
'none'
|
|
160
|
+
);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
test('sortable header has aria-sort="ascending" when sort is "asc"', () => {
|
|
164
|
+
render(
|
|
165
|
+
<ThemeContextProvider>
|
|
166
|
+
<table>
|
|
167
|
+
<thead>
|
|
168
|
+
<tr>
|
|
169
|
+
<HeadCell
|
|
170
|
+
accessor='name'
|
|
171
|
+
sort='asc'
|
|
172
|
+
onSortChange={vi.fn()}
|
|
173
|
+
>
|
|
174
|
+
Name
|
|
175
|
+
</HeadCell>
|
|
176
|
+
</tr>
|
|
177
|
+
</thead>
|
|
178
|
+
</table>
|
|
179
|
+
</ThemeContextProvider>
|
|
180
|
+
);
|
|
181
|
+
expect(screen.getByTestId('ucl-uikit-table__head-cell')).toHaveAttribute(
|
|
182
|
+
'aria-sort',
|
|
183
|
+
'ascending'
|
|
184
|
+
);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
test('sortable header has aria-sort="descending" when sort is "desc"', () => {
|
|
188
|
+
render(
|
|
189
|
+
<ThemeContextProvider>
|
|
190
|
+
<table>
|
|
191
|
+
<thead>
|
|
192
|
+
<tr>
|
|
193
|
+
<HeadCell
|
|
194
|
+
accessor='name'
|
|
195
|
+
sort='desc'
|
|
196
|
+
onSortChange={vi.fn()}
|
|
197
|
+
>
|
|
198
|
+
Name
|
|
199
|
+
</HeadCell>
|
|
200
|
+
</tr>
|
|
201
|
+
</thead>
|
|
202
|
+
</table>
|
|
203
|
+
</ThemeContextProvider>
|
|
204
|
+
);
|
|
205
|
+
expect(screen.getByTestId('ucl-uikit-table__head-cell')).toHaveAttribute(
|
|
206
|
+
'aria-sort',
|
|
207
|
+
'descending'
|
|
208
|
+
);
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
test('non-sortable header does not have aria-sort', () => {
|
|
212
|
+
render(
|
|
213
|
+
<ThemeContextProvider>
|
|
214
|
+
<table>
|
|
215
|
+
<thead>
|
|
216
|
+
<tr>
|
|
217
|
+
<HeadCell>Non-sortable</HeadCell>
|
|
218
|
+
</tr>
|
|
219
|
+
</thead>
|
|
220
|
+
</table>
|
|
221
|
+
</ThemeContextProvider>
|
|
222
|
+
);
|
|
223
|
+
expect(
|
|
224
|
+
screen.getByTestId('ucl-uikit-table__head-cell')
|
|
225
|
+
).not.toHaveAttribute('aria-sort');
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
test('sortable header has tabIndex={0}', () => {
|
|
229
|
+
render(
|
|
230
|
+
<ThemeContextProvider>
|
|
231
|
+
<table>
|
|
232
|
+
<thead>
|
|
233
|
+
<tr>
|
|
234
|
+
<HeadCell
|
|
235
|
+
accessor='name'
|
|
236
|
+
onSortChange={vi.fn()}
|
|
237
|
+
>
|
|
238
|
+
Name
|
|
239
|
+
</HeadCell>
|
|
240
|
+
</tr>
|
|
241
|
+
</thead>
|
|
242
|
+
</table>
|
|
243
|
+
</ThemeContextProvider>
|
|
244
|
+
);
|
|
245
|
+
expect(screen.getByTestId('ucl-uikit-table__head-cell')).toHaveAttribute(
|
|
246
|
+
'tabindex',
|
|
247
|
+
'0'
|
|
248
|
+
);
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
test('non-sortable header does not have tabIndex', () => {
|
|
252
|
+
render(
|
|
253
|
+
<ThemeContextProvider>
|
|
254
|
+
<table>
|
|
255
|
+
<thead>
|
|
256
|
+
<tr>
|
|
257
|
+
<HeadCell>Non-sortable</HeadCell>
|
|
258
|
+
</tr>
|
|
259
|
+
</thead>
|
|
260
|
+
</table>
|
|
261
|
+
</ThemeContextProvider>
|
|
262
|
+
);
|
|
263
|
+
expect(
|
|
264
|
+
screen.getByTestId('ucl-uikit-table__head-cell')
|
|
265
|
+
).not.toHaveAttribute('tabindex');
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
test('pressing Enter on a sortable header calls onSortChange', () => {
|
|
269
|
+
const onSortChange = vi.fn();
|
|
270
|
+
render(
|
|
271
|
+
<ThemeContextProvider>
|
|
272
|
+
<table>
|
|
273
|
+
<thead>
|
|
274
|
+
<tr>
|
|
275
|
+
<HeadCell
|
|
276
|
+
accessor='name'
|
|
277
|
+
onSortChange={onSortChange}
|
|
278
|
+
>
|
|
279
|
+
Name
|
|
280
|
+
</HeadCell>
|
|
281
|
+
</tr>
|
|
282
|
+
</thead>
|
|
283
|
+
</table>
|
|
284
|
+
</ThemeContextProvider>
|
|
285
|
+
);
|
|
286
|
+
fireEvent.keyDown(screen.getByTestId('ucl-uikit-table__head-cell'), {
|
|
287
|
+
key: 'Enter',
|
|
288
|
+
});
|
|
289
|
+
expect(onSortChange).toHaveBeenCalledWith('name', 'asc', expect.anything());
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
test('pressing Space on a sortable header calls onSortChange', () => {
|
|
293
|
+
const onSortChange = vi.fn();
|
|
294
|
+
render(
|
|
295
|
+
<ThemeContextProvider>
|
|
296
|
+
<table>
|
|
297
|
+
<thead>
|
|
298
|
+
<tr>
|
|
299
|
+
<HeadCell
|
|
300
|
+
accessor='name'
|
|
301
|
+
onSortChange={onSortChange}
|
|
302
|
+
>
|
|
303
|
+
Name
|
|
304
|
+
</HeadCell>
|
|
305
|
+
</tr>
|
|
306
|
+
</thead>
|
|
307
|
+
</table>
|
|
308
|
+
</ThemeContextProvider>
|
|
309
|
+
);
|
|
310
|
+
fireEvent.keyDown(screen.getByTestId('ucl-uikit-table__head-cell'), {
|
|
311
|
+
key: ' ',
|
|
312
|
+
});
|
|
313
|
+
expect(onSortChange).toHaveBeenCalledWith('name', 'asc', expect.anything());
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
test('checkbox variant has default aria-label "Select all rows"', () => {
|
|
317
|
+
render(
|
|
318
|
+
<ThemeContextProvider>
|
|
319
|
+
<table>
|
|
320
|
+
<thead>
|
|
321
|
+
<tr>
|
|
322
|
+
<HeadCell variant='checkbox'>Checkbox header</HeadCell>
|
|
323
|
+
</tr>
|
|
324
|
+
</thead>
|
|
325
|
+
</table>
|
|
326
|
+
</ThemeContextProvider>
|
|
327
|
+
);
|
|
328
|
+
expect(screen.getByRole('checkbox')).toHaveAttribute(
|
|
329
|
+
'aria-label',
|
|
330
|
+
'Select all rows'
|
|
331
|
+
);
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
test('checkbox variant aria-label can be customised via checkboxAriaLabel', () => {
|
|
335
|
+
render(
|
|
336
|
+
<ThemeContextProvider>
|
|
337
|
+
<table>
|
|
338
|
+
<thead>
|
|
339
|
+
<tr>
|
|
340
|
+
<HeadCell
|
|
341
|
+
variant='checkbox'
|
|
342
|
+
checkboxAriaLabel='Select all orders'
|
|
343
|
+
>
|
|
344
|
+
Checkbox header
|
|
345
|
+
</HeadCell>
|
|
346
|
+
</tr>
|
|
347
|
+
</thead>
|
|
348
|
+
</table>
|
|
349
|
+
</ThemeContextProvider>
|
|
350
|
+
);
|
|
351
|
+
expect(screen.getByRole('checkbox')).toHaveAttribute(
|
|
352
|
+
'aria-label',
|
|
353
|
+
'Select all orders'
|
|
354
|
+
);
|
|
355
|
+
});
|
|
137
356
|
});
|
package/lib/components/Table/subcomponents/HeadCell/__tests__/__snapshots__/HeadCell.test.tsx.snap
CHANGED
|
@@ -5,7 +5,7 @@ exports[`HeadCell > Snapshot: checkbox variant 1`] = `
|
|
|
5
5
|
<thead>
|
|
6
6
|
<tr>
|
|
7
7
|
<th
|
|
8
|
-
class="css-
|
|
8
|
+
class="css-19iwbn3 ucl-uikit-table__head-cell"
|
|
9
9
|
data-testid="ucl-uikit-table__head-cell"
|
|
10
10
|
scope="col"
|
|
11
11
|
>
|
|
@@ -14,9 +14,10 @@ exports[`HeadCell > Snapshot: checkbox variant 1`] = `
|
|
|
14
14
|
data-testid="ucl-uikit-table__head-cell-content"
|
|
15
15
|
>
|
|
16
16
|
<span
|
|
17
|
-
class="ucl-uikit-checkbox css-
|
|
17
|
+
class="ucl-uikit-checkbox css-tumlz"
|
|
18
18
|
>
|
|
19
19
|
<input
|
|
20
|
+
aria-label="Select all rows"
|
|
20
21
|
class="css-nzy7im"
|
|
21
22
|
data-testid="ucl-uikit-checkbox"
|
|
22
23
|
type="checkbox"
|
|
@@ -34,7 +35,7 @@ exports[`HeadCell > Snapshot: default 1`] = `
|
|
|
34
35
|
<thead>
|
|
35
36
|
<tr>
|
|
36
37
|
<th
|
|
37
|
-
class="css-
|
|
38
|
+
class="css-19iwbn3 ucl-uikit-table__head-cell"
|
|
38
39
|
data-testid="ucl-uikit-table__head-cell"
|
|
39
40
|
scope="col"
|
|
40
41
|
>
|
|
@@ -44,6 +45,7 @@ exports[`HeadCell > Snapshot: default 1`] = `
|
|
|
44
45
|
>
|
|
45
46
|
Default header cell
|
|
46
47
|
<svg
|
|
48
|
+
aria-hidden="true"
|
|
47
49
|
fill="none"
|
|
48
50
|
height="16"
|
|
49
51
|
viewBox="0 0 48 48"
|
|
@@ -93,7 +95,7 @@ exports[`HeadCell > no sorting icon 1`] = `
|
|
|
93
95
|
<thead>
|
|
94
96
|
<tr>
|
|
95
97
|
<th
|
|
96
|
-
class="css-
|
|
98
|
+
class="css-19iwbn3 ucl-uikit-table__head-cell"
|
|
97
99
|
data-testid="ucl-uikit-table__head-cell"
|
|
98
100
|
scope="col"
|
|
99
101
|
>
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { css, cx } from '@emotion/css';
|
|
2
2
|
import { useTheme } from '../../../theme';
|
|
3
3
|
|
|
4
|
-
export interface TableRowProps
|
|
5
|
-
extends React.HTMLAttributes<HTMLTableRowElement> {
|
|
4
|
+
export interface TableRowProps extends React.HTMLAttributes<HTMLTableRowElement> {
|
|
6
5
|
selected?: boolean;
|
|
7
6
|
}
|
|
8
7
|
|
|
@@ -39,6 +38,7 @@ const Row = ({
|
|
|
39
38
|
<tr
|
|
40
39
|
className={style}
|
|
41
40
|
data-testid={NAME}
|
|
41
|
+
aria-selected={selected}
|
|
42
42
|
{...props}
|
|
43
43
|
>
|
|
44
44
|
{children}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import Row from '../Row';
|
|
4
|
+
import { ThemeContextProvider } from '../../../../theme/useTheme';
|
|
5
|
+
|
|
6
|
+
describe('Row', () => {
|
|
7
|
+
test('Can be found via default testId', () => {
|
|
8
|
+
render(
|
|
9
|
+
<ThemeContextProvider>
|
|
10
|
+
<table>
|
|
11
|
+
<tbody>
|
|
12
|
+
<Row>
|
|
13
|
+
<td>Cell</td>
|
|
14
|
+
</Row>
|
|
15
|
+
</tbody>
|
|
16
|
+
</table>
|
|
17
|
+
</ThemeContextProvider>
|
|
18
|
+
);
|
|
19
|
+
expect(screen.getByTestId('ucl-uikit-table__row')).toBeInTheDocument();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// Accessibility tests
|
|
23
|
+
|
|
24
|
+
test('aria-selected is false by default', () => {
|
|
25
|
+
render(
|
|
26
|
+
<ThemeContextProvider>
|
|
27
|
+
<table>
|
|
28
|
+
<tbody>
|
|
29
|
+
<Row>
|
|
30
|
+
<td>Cell</td>
|
|
31
|
+
</Row>
|
|
32
|
+
</tbody>
|
|
33
|
+
</table>
|
|
34
|
+
</ThemeContextProvider>
|
|
35
|
+
);
|
|
36
|
+
expect(screen.getByTestId('ucl-uikit-table__row')).toHaveAttribute(
|
|
37
|
+
'aria-selected',
|
|
38
|
+
'false'
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('aria-selected is true when selected prop is true', () => {
|
|
43
|
+
render(
|
|
44
|
+
<ThemeContextProvider>
|
|
45
|
+
<table>
|
|
46
|
+
<tbody>
|
|
47
|
+
<Row selected>
|
|
48
|
+
<td>Cell</td>
|
|
49
|
+
</Row>
|
|
50
|
+
</tbody>
|
|
51
|
+
</table>
|
|
52
|
+
</ThemeContextProvider>
|
|
53
|
+
);
|
|
54
|
+
expect(screen.getByTestId('ucl-uikit-table__row')).toHaveAttribute(
|
|
55
|
+
'aria-selected',
|
|
56
|
+
'true'
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -31,7 +31,7 @@ const Tab = ({
|
|
|
31
31
|
border: none;
|
|
32
32
|
cursor: pointer;
|
|
33
33
|
font-family: ${theme.font.family.primary};
|
|
34
|
-
color: ${theme.
|
|
34
|
+
color: ${theme.colour.text.secondary};
|
|
35
35
|
border-bottom: 4px solid transparent;
|
|
36
36
|
text-align: center;
|
|
37
37
|
font-style: normal;
|
|
@@ -53,8 +53,8 @@ const Tab = ({
|
|
|
53
53
|
`;
|
|
54
54
|
|
|
55
55
|
const activeStyle = css`
|
|
56
|
-
border-bottom: 4px solid ${color || theme.
|
|
57
|
-
color: ${theme.
|
|
56
|
+
border-bottom: 4px solid ${color || theme.colour.border.brand};
|
|
57
|
+
color: ${theme.colour.text.default};
|
|
58
58
|
margin-bottom: -1px;
|
|
59
59
|
font-weight: 700;
|
|
60
60
|
|
|
@@ -7,8 +7,10 @@ import marginsStyle, { MarginProps } from '../common/marginsStyle';
|
|
|
7
7
|
|
|
8
8
|
export const NAME = 'ucl-uikit-tabs';
|
|
9
9
|
|
|
10
|
-
export interface TabsBaseProps
|
|
11
|
-
|
|
10
|
+
export interface TabsBaseProps extends Omit<
|
|
11
|
+
HTMLAttributes<HTMLDivElement>,
|
|
12
|
+
'onChange'
|
|
13
|
+
> {
|
|
12
14
|
activeTab: string;
|
|
13
15
|
onChange?: (value: string) => void;
|
|
14
16
|
fullWidth?: boolean;
|
|
@@ -42,7 +44,7 @@ const TabsBase = ({
|
|
|
42
44
|
|
|
43
45
|
const baseStyle = css`
|
|
44
46
|
display: flex;
|
|
45
|
-
border-bottom: 1px solid ${theme.
|
|
47
|
+
border-bottom: 1px solid ${theme.colour.border.subtle};
|
|
46
48
|
`;
|
|
47
49
|
|
|
48
50
|
const style = cx(NAME, baseStyle, marginsStyle(props, theme), className);
|