uikit-react-public 0.14.21 → 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 -2
- package/dist/components/Accordion/Accordion.Heading.d.ts +5 -4
- package/dist/components/Accordion/Accordion.Panel.d.ts +2 -2
- package/dist/components/Accordion/Accordion.d.ts +1 -1
- package/dist/components/Accordion/Accordion.stories.d.ts +57 -0
- package/dist/components/Accordion/index.d.ts +2 -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/Avatar/Avatar.stories.d.ts +107 -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 +8 -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/Calendar/index.d.ts +1 -1
- package/dist/components/Checkbox/Checkbox.d.ts +1 -0
- package/dist/components/Datepicker/Datepicker.d.ts +1 -1
- package/dist/components/Datepicker/Datepicker.stories.d.ts +4 -3
- package/dist/components/Datepicker/Datepicker.types.d.ts +4 -5
- package/dist/components/Datepicker/subcomponents/CustomDatepicker.d.ts +4 -1
- package/dist/components/Datepicker/subcomponents/DatepickerInput.d.ts +15 -2
- package/dist/components/Datepicker/subcomponents/Panel.d.ts +1 -1
- package/dist/components/Datepicker/subcomponents/VisibleField.d.ts +6 -1
- package/dist/components/Datepicker/subcomponents/index.d.ts +0 -1
- package/dist/components/Datepicker/utils/index.d.ts +0 -1
- package/dist/components/Dialog/BaseDialog.d.ts +2 -1
- package/dist/components/Dialog/Dialog.d.ts +2 -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/index.d.ts +2 -0
- package/dist/components/Header/Header.d.ts +4 -1
- package/dist/components/Header/Header.stories.d.ts +40 -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/Main/Main.d.ts +21 -0
- package/dist/components/Main/Main.stories.d.ts +15 -0
- package/dist/components/Main/__tests__/Main.test.d.ts +1 -0
- package/dist/components/Main/index.d.ts +2 -0
- 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/NativeDatepicker/NativeDatepicker.d.ts +3 -0
- package/dist/components/NativeDatepicker/NativeDatepicker.stories.d.ts +36 -0
- package/dist/components/NativeDatepicker/NativeDatepicker.types.d.ts +10 -0
- package/dist/components/NativeDatepicker/index.d.ts +2 -0
- package/dist/components/{Datepicker → NativeDatepicker}/utils/dateToLocaleISOString/dateToLocaleISOString.d.ts +1 -1
- package/dist/components/NativeDatepicker/utils/dateToLocaleISOString/dateToLocaleISOString.test.d.ts +1 -0
- package/dist/components/NativeDatepicker/utils/index.d.ts +1 -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 +167 -3
- package/dist/components/Select/Select.types.d.ts +75 -19
- package/dist/components/Select/subcomponents/CustomOption.d.ts +1 -1
- package/dist/components/Select/subcomponents/CustomSelect.d.ts +3 -2
- package/dist/components/Select/subcomponents/FilterInput.d.ts +16 -0
- package/dist/components/Select/subcomponents/NativeSelect.d.ts +5 -1
- package/dist/components/Select/subcomponents/VisibleField.d.ts +6 -1
- package/dist/components/Select/subcomponents/index.d.ts +1 -0
- 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/WeekPicker/WeekPicker.d.ts +2 -2
- package/dist/components/WeekPicker/WeekPicker.stories.d.ts +41 -0
- package/dist/components/WeekPicker/WeekPicker.types.d.ts +16 -0
- package/dist/components/WeekPicker/index.d.ts +1 -0
- package/dist/components/WeekPicker/subcomponents/CustomDatepicker.d.ts +1 -1
- package/dist/components/index.d.ts +20 -0
- package/dist/hooks/useFocusTrap.d.ts +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +22204 -16719
- 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/__tests__/announce.test.d.ts +1 -0
- package/dist/utils/addAlphaToHex.d.ts +5 -0
- package/dist/utils/announce.d.ts +6 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/scrollToTop.d.ts +2 -0
- package/lib/components/Accordion/Accordion.Heading.tsx +65 -34
- package/lib/components/Accordion/Accordion.Panel.tsx +11 -7
- package/lib/components/Accordion/Accordion.stories.tsx +139 -0
- package/lib/components/Accordion/Accordion.tsx +39 -31
- package/lib/components/Accordion/__tests__/__snapshots__/Accordion.test.tsx.snap +15 -13
- package/lib/components/Accordion/index.ts +2 -0
- package/lib/components/Alert/Alert.stories.tsx +1 -1
- 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/Avatar/Avatar.mdx +117 -0
- package/lib/components/Avatar/Avatar.stories.tsx +110 -2
- package/lib/components/Badge/Badge.stories.tsx +1 -1
- package/lib/components/Blanket/Blanket.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 +44 -51
- package/lib/components/Button/Button.tsx +166 -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 +1 -1
- package/lib/components/Calendar/Calendar.tsx +2 -2
- package/lib/components/Calendar/__tests__/Calendar.test.tsx +23 -15
- package/lib/components/Calendar/__tests__/__snapshots__/Calendar.test.tsx.snap +99 -95
- package/lib/components/Calendar/index.ts +1 -5
- package/lib/components/Calendar/subcomponents/AcademicWeek.tsx +2 -1
- package/lib/components/Calendar/subcomponents/AcademicWeeks.tsx +1 -1
- package/lib/components/Calendar/subcomponents/ColumnHeading.tsx +2 -2
- 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 +3 -6
- package/lib/components/Calendar/subcomponents/index.ts +1 -1
- package/lib/components/Calendar/utils/getDatesForCalendarGrid/getDatesForCalendarGrid.ts +43 -11
- package/lib/components/Calendar/utils/normaliseMonth/normaliseMonth.test.ts +5 -5
- 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/Datepicker.lld.md +108 -0
- package/lib/components/Datepicker/Datepicker.stories.tsx +44 -5
- package/lib/components/Datepicker/Datepicker.tsx +14 -36
- package/lib/components/Datepicker/Datepicker.types.ts +5 -14
- package/lib/components/Datepicker/__tests__/Datepicker.test.tsx +267 -8
- package/lib/components/Datepicker/__tests__/__snapshots__/Datepicker.test.tsx.snap +20 -42
- package/lib/components/Datepicker/subcomponents/CustomDatepicker.tsx +48 -5
- package/lib/components/Datepicker/subcomponents/DatepickerInput.tsx +30 -17
- package/lib/components/Datepicker/subcomponents/Panel.tsx +6 -2
- package/lib/components/Datepicker/subcomponents/VisibleField.tsx +46 -8
- package/lib/components/Datepicker/subcomponents/index.ts +0 -1
- package/lib/components/Datepicker/utils/index.ts +0 -1
- package/lib/components/Dialog/BaseDialog.tsx +13 -2
- package/lib/components/Dialog/Dialog.stories.tsx +1 -1
- package/lib/components/Dialog/Dialog.tsx +8 -1
- package/lib/components/Dialog/DialogBody.tsx +5 -1
- package/lib/components/Dialog/DialogHeader.tsx +2 -1
- package/lib/components/Divider/Divider.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 +2 -1
- package/lib/components/Field/Field.stories.tsx +1 -1
- package/lib/components/Field/Field.tsx +1 -1
- package/lib/components/Field/HelperText.tsx +3 -1
- package/lib/components/Field/__tests__/Field.test.tsx +13 -0
- 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/Footer.stories.tsx +1 -1
- package/lib/components/Footer/__tests__/__snapshots__/Footer.test.tsx.snap +73 -82
- 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/Header/Header.mdx +52 -0
- package/lib/components/Header/Header.stories.tsx +98 -0
- package/lib/components/Header/Header.tsx +51 -6
- package/lib/components/Header/__tests__/Header.test.tsx +17 -1
- 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/Heading/Heading.stories.tsx +1 -1
- package/lib/components/HeadingNew/Heading.tsx +208 -0
- package/lib/components/HeadingNew/index.ts +2 -0
- package/lib/components/Icon/Icon.stories.tsx +1 -1
- 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.stories.tsx +1 -1
- package/lib/components/IconButton/IconButton.tsx +3 -4
- package/lib/components/IconButton/__tests__/__snapshots__/IconButton.test.tsx.snap +12 -9
- package/lib/components/Input/Input.stories.tsx +1 -1
- package/lib/components/Label/Label.stories.tsx +1 -1
- 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/Main/Main.stories.tsx +36 -0
- package/lib/components/Main/Main.tsx +46 -0
- package/lib/components/Main/__tests__/Main.test.tsx +80 -0
- package/lib/components/Main/__tests__/__snapshots__/Main.test.tsx.snap +33 -0
- package/lib/components/Main/index.ts +2 -0
- 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/NativeDatepicker/NativeDatepicker.stories.tsx +100 -0
- package/lib/components/{Datepicker/subcomponents → NativeDatepicker}/NativeDatepicker.tsx +14 -15
- package/lib/components/NativeDatepicker/NativeDatepicker.types.ts +19 -0
- package/lib/components/NativeDatepicker/index.ts +2 -0
- package/lib/components/{Datepicker → NativeDatepicker}/utils/dateToLocaleISOString/dateToLocaleISOString.ts +1 -1
- package/lib/components/NativeDatepicker/utils/index.ts +1 -0
- package/lib/components/Pagination/Pagination.stories.tsx +1 -1
- package/lib/components/Pagination/PaginationControls.tsx +59 -17
- package/lib/components/Pagination/PaginationInfo.tsx +7 -4
- package/lib/components/Paragraph/Paragraph.stories.tsx +1 -1
- 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/Search.stories.tsx +1 -1
- package/lib/components/Search/Search.tsx +4 -1
- package/lib/components/Search/__tests__/Search.test.tsx +19 -1
- package/lib/components/Search/__tests__/__snapshots__/Search.test.tsx.snap +12 -32
- package/lib/components/Select/Select.mdx +192 -0
- package/lib/components/Select/Select.stories.tsx +229 -48
- package/lib/components/Select/Select.tsx +50 -15
- package/lib/components/Select/Select.types.ts +99 -44
- package/lib/components/Select/__tests__/Select.test.tsx +698 -8
- package/lib/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +5 -4
- package/lib/components/Select/subcomponents/CustomOption.tsx +12 -4
- package/lib/components/Select/subcomponents/CustomSelect.tsx +411 -41
- package/lib/components/Select/subcomponents/FilterInput.tsx +90 -0
- package/lib/components/Select/subcomponents/NativeSelect.tsx +21 -17
- package/lib/components/Select/subcomponents/Panel.tsx +2 -2
- package/lib/components/Select/subcomponents/VisibleField.tsx +59 -6
- package/lib/components/Select/subcomponents/index.tsx +1 -0
- package/lib/components/Snackbar/Snackbar.stories.tsx +1 -1
- package/lib/components/Snackbar/__tests__/__snapshots__/Snackbar.test.tsx.snap +9 -15
- package/lib/components/Spinner/Spinner.stories.tsx +1 -1
- 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/Textarea/Textarea.stories.tsx +1 -1
- package/lib/components/Timepicker/Timepicker.stories.tsx +1 -1
- package/lib/components/Timepicker/Timepicker.tsx +4 -0
- package/lib/components/Timepicker/__tests__/__snapshots__/Timepicker.test.tsx.snap +2 -2
- package/lib/components/Toggle/Toggle.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.stories.tsx +1 -1
- 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 +145 -0
- package/lib/components/WeekPicker/WeekPicker.tsx +2 -2
- package/lib/components/WeekPicker/WeekPicker.types.ts +21 -0
- package/lib/components/WeekPicker/index.ts +1 -0
- package/lib/components/WeekPicker/subcomponents/CustomDatepicker.tsx +1 -1
- package/lib/components/common/Common.mdx +1 -2
- package/lib/components/index.ts +30 -3
- package/lib/hooks/useFocusTrap.ts +40 -4
- package/lib/index.ts +1 -0
- 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/__tests__/announce.test.ts +121 -0
- package/lib/utils/addAlphaToHex.ts +29 -0
- package/lib/utils/announce.ts +134 -0
- package/lib/utils/index.ts +1 -0
- package/lib/utils/scrollToTop.ts +5 -0
- package/package.json +11 -9
- 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/components/Datepicker/subcomponents/NativeDatepicker.d.ts +0 -6
- package/dist/theme/defaultTheme.d.ts +0 -274
- package/lib/components/Accordion/Accordion.stories.tsx.NOT_READY +0 -93
- package/lib/components/Button/buttonPrimaryStyle.ts +0 -62
- package/lib/components/Button/buttonSecondaryStyle.ts +0 -65
- package/lib/components/Button/buttonTertiaryStyle.ts +0 -54
- /package/dist/components/{Datepicker/utils/dateToLocaleISOString/dateToLocaleISOString.test.d.ts → FooterNew/__tests__/Footer.test.d.ts} +0 -0
- /package/lib/components/{Datepicker → NativeDatepicker}/utils/dateToLocaleISOString/dateToLocaleISOString.test.ts +0 -0
|
@@ -1,37 +1,135 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
2
|
import { useArgs } from '@storybook/preview-api';
|
|
3
3
|
import Select from './Select';
|
|
4
|
+
import { css } from '@emotion/css';
|
|
5
|
+
|
|
6
|
+
const select400pxWidthClass = css`
|
|
7
|
+
width: 400px;
|
|
8
|
+
`;
|
|
9
|
+
const storyWrapperStyle: React.CSSProperties = { minHeight: 150, width: 400 };
|
|
4
10
|
|
|
5
11
|
const meta = {
|
|
6
|
-
title: 'Components/
|
|
12
|
+
title: 'Components/Select',
|
|
7
13
|
component: Select,
|
|
8
14
|
argTypes: {
|
|
9
|
-
|
|
15
|
+
selectionBehaviour: {
|
|
16
|
+
description:
|
|
17
|
+
'Keyboard selection behaviour for custom variant: `focus` commits on arrow keys, `commit` commits on Enter/click',
|
|
18
|
+
control: { type: 'radio' },
|
|
19
|
+
options: ['focus', 'commit'],
|
|
20
|
+
table: { type: { summary: "'focus' | 'commit'" } },
|
|
21
|
+
},
|
|
22
|
+
options: {
|
|
23
|
+
description: 'Array of option objects `{ label, value, optionProps? }`',
|
|
24
|
+
control: { type: 'object' },
|
|
25
|
+
table: { type: { summary: 'OptionData[]' } },
|
|
26
|
+
},
|
|
27
|
+
value: {
|
|
28
|
+
description: 'Selected value (string | number | null)',
|
|
29
|
+
control: { type: 'text' },
|
|
30
|
+
table: { type: { summary: 'string | number | null' } },
|
|
31
|
+
},
|
|
32
|
+
onValueChange: {
|
|
33
|
+
description:
|
|
34
|
+
'Change handler for the custom select variant (value, event)',
|
|
35
|
+
control: false,
|
|
36
|
+
table: {
|
|
37
|
+
type: {
|
|
38
|
+
summary:
|
|
39
|
+
'(value: string | number | null, ev: React.SyntheticEvent) => void',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
10
43
|
native: {
|
|
44
|
+
description: 'Render the native `<select>` variant when true',
|
|
11
45
|
control: { type: 'boolean' },
|
|
46
|
+
table: { type: { summary: 'boolean' } },
|
|
47
|
+
},
|
|
48
|
+
nativeHtmlAttributes: {
|
|
49
|
+
description: 'Additional props to spread onto the native `<select>`',
|
|
50
|
+
control: false,
|
|
51
|
+
table: {
|
|
52
|
+
type: { summary: 'React.SelectHTMLAttributes<HTMLSelectElement>' },
|
|
53
|
+
},
|
|
12
54
|
},
|
|
13
55
|
disabled: {
|
|
56
|
+
description: 'Disable interaction',
|
|
14
57
|
control: { type: 'boolean' },
|
|
58
|
+
table: { type: { summary: 'boolean' } },
|
|
15
59
|
},
|
|
16
60
|
placeholder: {
|
|
61
|
+
description: 'Helper text when no value is selected',
|
|
17
62
|
control: { type: 'text' },
|
|
63
|
+
table: { type: { summary: 'string' } },
|
|
18
64
|
},
|
|
19
|
-
|
|
65
|
+
filterable: {
|
|
66
|
+
description:
|
|
67
|
+
'Show a filter input to narrow options in the custom variant',
|
|
68
|
+
control: { type: 'boolean' },
|
|
69
|
+
table: { type: { summary: 'boolean' } },
|
|
70
|
+
},
|
|
71
|
+
clearable: {
|
|
72
|
+
description:
|
|
73
|
+
'Show a clear action in the custom variant when a value is selected',
|
|
74
|
+
control: { type: 'boolean' },
|
|
75
|
+
table: { type: { summary: 'boolean' } },
|
|
76
|
+
},
|
|
77
|
+
filterInputProps: {
|
|
78
|
+
description:
|
|
79
|
+
'Additional props to spread onto the filter input (when filterable)',
|
|
80
|
+
control: { type: 'object' },
|
|
81
|
+
table: {
|
|
82
|
+
type: {
|
|
83
|
+
summary: 'React.InputHTMLAttributes<HTMLInputElement>',
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
id: {
|
|
88
|
+
description: 'Standard HTML id forwarded to the combobox/native select',
|
|
20
89
|
control: { type: 'text' },
|
|
90
|
+
table: { type: { summary: 'string' } },
|
|
91
|
+
},
|
|
92
|
+
title: {
|
|
93
|
+
description:
|
|
94
|
+
'Standard title attribute forwarded to the combobox/native select',
|
|
95
|
+
control: { type: 'text' },
|
|
96
|
+
table: { type: { summary: 'string' } },
|
|
21
97
|
},
|
|
22
98
|
lineBreak: {
|
|
99
|
+
description: 'Wrap long option labels',
|
|
23
100
|
control: { type: 'boolean' },
|
|
101
|
+
table: { type: { summary: 'boolean' } },
|
|
102
|
+
},
|
|
103
|
+
panelClassName: {
|
|
104
|
+
description: 'Custom className for the options panel',
|
|
105
|
+
control: { type: 'text' },
|
|
106
|
+
table: { type: { summary: 'string' } },
|
|
107
|
+
},
|
|
108
|
+
className: {
|
|
109
|
+
description: 'Custom className for the root element',
|
|
110
|
+
control: { type: 'text' },
|
|
111
|
+
table: { type: { summary: 'string' } },
|
|
112
|
+
},
|
|
113
|
+
testId: {
|
|
114
|
+
description: 'Test id applied to the root element',
|
|
115
|
+
control: { type: 'text' },
|
|
116
|
+
table: { type: { summary: 'string' } },
|
|
24
117
|
},
|
|
25
118
|
},
|
|
26
119
|
args: {
|
|
120
|
+
selectionBehaviour: 'focus',
|
|
27
121
|
value: undefined,
|
|
28
|
-
onChange: () => {},
|
|
29
122
|
options: [
|
|
30
123
|
{ label: 'Option one', value: '1' },
|
|
31
124
|
{ label: 'Option two', value: '2' },
|
|
32
125
|
{ label: 'Option three', value: '3' },
|
|
33
126
|
],
|
|
34
127
|
},
|
|
128
|
+
parameters: {
|
|
129
|
+
docs: {
|
|
130
|
+
story: { inline: true },
|
|
131
|
+
},
|
|
132
|
+
},
|
|
35
133
|
} satisfies Meta<typeof Select>;
|
|
36
134
|
|
|
37
135
|
export default meta;
|
|
@@ -40,16 +138,19 @@ type Story = StoryObj<typeof meta>;
|
|
|
40
138
|
export const Default: Story = {
|
|
41
139
|
render: () => {
|
|
42
140
|
const [args, updateArgs] = useArgs();
|
|
43
|
-
const onValueChange = (value: string | number) => {
|
|
141
|
+
const onValueChange = (value: string | number | null) => {
|
|
44
142
|
updateArgs({ value });
|
|
45
143
|
};
|
|
46
144
|
return (
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
145
|
+
<div style={storyWrapperStyle}>
|
|
146
|
+
<Select
|
|
147
|
+
{...args}
|
|
148
|
+
className={select400pxWidthClass}
|
|
149
|
+
options={args.options}
|
|
150
|
+
value={args.value}
|
|
151
|
+
onValueChange={onValueChange}
|
|
152
|
+
/>
|
|
153
|
+
</div>
|
|
53
154
|
);
|
|
54
155
|
},
|
|
55
156
|
};
|
|
@@ -60,16 +161,18 @@ export const Native: Story = {
|
|
|
60
161
|
},
|
|
61
162
|
render: () => {
|
|
62
163
|
const [args, updateArgs] = useArgs();
|
|
63
|
-
const
|
|
64
|
-
updateArgs({ value });
|
|
65
|
-
};
|
|
164
|
+
const onNativeChange = (event: React.ChangeEvent<HTMLSelectElement>) =>
|
|
165
|
+
updateArgs({ value: event.target.value });
|
|
66
166
|
return (
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
167
|
+
<div style={storyWrapperStyle}>
|
|
168
|
+
<Select
|
|
169
|
+
{...args}
|
|
170
|
+
className={select400pxWidthClass}
|
|
171
|
+
options={args.options}
|
|
172
|
+
value={args.value}
|
|
173
|
+
nativeHtmlAttributes={{ onChange: onNativeChange }}
|
|
174
|
+
/>
|
|
175
|
+
</div>
|
|
73
176
|
);
|
|
74
177
|
},
|
|
75
178
|
};
|
|
@@ -80,17 +183,20 @@ export const Disabled: Story = {
|
|
|
80
183
|
},
|
|
81
184
|
render: () => {
|
|
82
185
|
const [args, updateArgs] = useArgs();
|
|
83
|
-
const onValueChange = (value: string | number) => {
|
|
186
|
+
const onValueChange = (value: string | number | null) => {
|
|
84
187
|
updateArgs({ value });
|
|
85
188
|
};
|
|
86
189
|
|
|
87
190
|
return (
|
|
88
|
-
<
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
191
|
+
<div style={storyWrapperStyle}>
|
|
192
|
+
<Select
|
|
193
|
+
{...args}
|
|
194
|
+
className={select400pxWidthClass}
|
|
195
|
+
options={args.options}
|
|
196
|
+
value={args.value}
|
|
197
|
+
onValueChange={onValueChange}
|
|
198
|
+
/>
|
|
199
|
+
</div>
|
|
94
200
|
);
|
|
95
201
|
},
|
|
96
202
|
};
|
|
@@ -99,17 +205,20 @@ export const WithPlaceholder: Story = {
|
|
|
99
205
|
args: { placeholder: 'Please select an option' },
|
|
100
206
|
render: () => {
|
|
101
207
|
const [args, updateArgs] = useArgs();
|
|
102
|
-
const onValueChange = (value: string | number) => {
|
|
208
|
+
const onValueChange = (value: string | number | null) => {
|
|
103
209
|
updateArgs({ value });
|
|
104
210
|
};
|
|
105
211
|
|
|
106
212
|
return (
|
|
107
|
-
<
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
213
|
+
<div style={storyWrapperStyle}>
|
|
214
|
+
<Select
|
|
215
|
+
{...args}
|
|
216
|
+
className={select400pxWidthClass}
|
|
217
|
+
options={args.options}
|
|
218
|
+
value={args.value}
|
|
219
|
+
onValueChange={onValueChange}
|
|
220
|
+
/>
|
|
221
|
+
</div>
|
|
113
222
|
);
|
|
114
223
|
},
|
|
115
224
|
};
|
|
@@ -125,17 +234,20 @@ export const SingleLongOption: Story = {
|
|
|
125
234
|
},
|
|
126
235
|
render: () => {
|
|
127
236
|
const [args, updateArgs] = useArgs();
|
|
128
|
-
const onValueChange = (value: string | number) => {
|
|
237
|
+
const onValueChange = (value: string | number | null) => {
|
|
129
238
|
updateArgs({ value });
|
|
130
239
|
};
|
|
131
240
|
|
|
132
241
|
return (
|
|
133
|
-
<
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
242
|
+
<div style={storyWrapperStyle}>
|
|
243
|
+
<Select
|
|
244
|
+
{...args}
|
|
245
|
+
className={select400pxWidthClass}
|
|
246
|
+
options={args.options}
|
|
247
|
+
value={args.value}
|
|
248
|
+
onValueChange={onValueChange}
|
|
249
|
+
/>
|
|
250
|
+
</div>
|
|
139
251
|
);
|
|
140
252
|
},
|
|
141
253
|
};
|
|
@@ -163,16 +275,85 @@ export const ManyOptions: Story = {
|
|
|
163
275
|
},
|
|
164
276
|
render: () => {
|
|
165
277
|
const [args, updateArgs] = useArgs();
|
|
166
|
-
const onValueChange = (value: string | number) => {
|
|
278
|
+
const onValueChange = (value: string | number | null) => {
|
|
167
279
|
updateArgs({ value });
|
|
168
280
|
};
|
|
169
281
|
return (
|
|
170
|
-
<
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
282
|
+
<div style={storyWrapperStyle}>
|
|
283
|
+
<Select
|
|
284
|
+
{...args}
|
|
285
|
+
className={select400pxWidthClass}
|
|
286
|
+
options={args.options}
|
|
287
|
+
value={args.value}
|
|
288
|
+
onValueChange={onValueChange}
|
|
289
|
+
/>
|
|
290
|
+
</div>
|
|
291
|
+
);
|
|
292
|
+
},
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
export const filterable: Story = {
|
|
296
|
+
args: { filterable: true },
|
|
297
|
+
render: () => {
|
|
298
|
+
const [args, updateArgs] = useArgs();
|
|
299
|
+
const onValueChange = (value: string | number | null) =>
|
|
300
|
+
updateArgs({ value });
|
|
301
|
+
return (
|
|
302
|
+
<div style={storyWrapperStyle}>
|
|
303
|
+
<Select
|
|
304
|
+
{...args}
|
|
305
|
+
className={select400pxWidthClass}
|
|
306
|
+
options={args.options}
|
|
307
|
+
value={args.value}
|
|
308
|
+
onValueChange={onValueChange}
|
|
309
|
+
placeholder='Type to filter...'
|
|
310
|
+
/>
|
|
311
|
+
</div>
|
|
312
|
+
);
|
|
313
|
+
},
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
export const Clearable: Story = {
|
|
317
|
+
args: {
|
|
318
|
+
clearable: true,
|
|
319
|
+
value: '2',
|
|
320
|
+
placeholder: 'Clear selection',
|
|
321
|
+
},
|
|
322
|
+
render: () => {
|
|
323
|
+
const [args, updateArgs] = useArgs();
|
|
324
|
+
const onValueChange = (value: string | number | null) =>
|
|
325
|
+
updateArgs({ value });
|
|
326
|
+
return (
|
|
327
|
+
<div style={storyWrapperStyle}>
|
|
328
|
+
<Select
|
|
329
|
+
{...args}
|
|
330
|
+
className={select400pxWidthClass}
|
|
331
|
+
options={args.options}
|
|
332
|
+
value={args.value}
|
|
333
|
+
onValueChange={onValueChange}
|
|
334
|
+
/>
|
|
335
|
+
</div>
|
|
336
|
+
);
|
|
337
|
+
},
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
export const SelectionBehaviourCommit: Story = {
|
|
341
|
+
name: 'Selection behaviour: commit',
|
|
342
|
+
args: { selectionBehaviour: 'commit' },
|
|
343
|
+
render: () => {
|
|
344
|
+
const [args, updateArgs] = useArgs();
|
|
345
|
+
const onValueChange = (value: string | number | null) =>
|
|
346
|
+
updateArgs({ value });
|
|
347
|
+
return (
|
|
348
|
+
<div style={storyWrapperStyle}>
|
|
349
|
+
<Select
|
|
350
|
+
{...args}
|
|
351
|
+
className={select400pxWidthClass}
|
|
352
|
+
options={args.options}
|
|
353
|
+
value={args.value}
|
|
354
|
+
onValueChange={onValueChange}
|
|
355
|
+
/>
|
|
356
|
+
</div>
|
|
176
357
|
);
|
|
177
358
|
},
|
|
178
359
|
};
|
|
@@ -1,25 +1,60 @@
|
|
|
1
1
|
import { NativeSelect, CustomSelect } from './subcomponents';
|
|
2
|
-
import { SelectProps } from './Select.types';
|
|
2
|
+
import type { InternalSelectProps, SelectProps } from './Select.types';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
type SelectComponent = <T extends string | number = string>(
|
|
5
|
+
props: SelectProps<T>
|
|
6
|
+
) => React.JSX.Element;
|
|
7
|
+
|
|
8
|
+
const Select = (<T extends string | number = string>(
|
|
9
|
+
props: InternalSelectProps<T>
|
|
10
|
+
) => {
|
|
11
|
+
const {
|
|
12
|
+
native,
|
|
13
|
+
nativeHtmlAttributes,
|
|
14
|
+
filterable,
|
|
15
|
+
clearable,
|
|
16
|
+
onValueChange,
|
|
17
|
+
ref,
|
|
18
|
+
...rest
|
|
19
|
+
} = props;
|
|
20
|
+
|
|
21
|
+
if (native) {
|
|
22
|
+
if (filterable) {
|
|
23
|
+
console.warn('filterable is not supported on native Select; ignoring.');
|
|
24
|
+
}
|
|
25
|
+
if (clearable) {
|
|
26
|
+
console.warn('clearable is not supported on native Select; ignoring.');
|
|
27
|
+
}
|
|
28
|
+
const { value, ...nativeRest } = rest;
|
|
29
|
+
const {
|
|
30
|
+
value: nativeAttrValue,
|
|
31
|
+
onChange,
|
|
32
|
+
...nativeAttrs
|
|
33
|
+
} = nativeHtmlAttributes || {};
|
|
34
|
+
const nativeValue: string | number | undefined =
|
|
35
|
+
typeof value === 'string' || typeof value === 'number'
|
|
36
|
+
? value
|
|
37
|
+
: undefined;
|
|
7
38
|
return (
|
|
8
39
|
<NativeSelect
|
|
40
|
+
value={nativeValue ?? (nativeAttrValue as string | number | undefined)}
|
|
9
41
|
onChange={onChange}
|
|
10
|
-
|
|
11
|
-
{...
|
|
12
|
-
|
|
13
|
-
);
|
|
14
|
-
} else {
|
|
15
|
-
const { onValueChange, ...rest } = props;
|
|
16
|
-
return (
|
|
17
|
-
<CustomSelect<T>
|
|
18
|
-
onValueChange={onValueChange}
|
|
19
|
-
{...rest}
|
|
42
|
+
ref={ref as React.Ref<HTMLSelectElement>}
|
|
43
|
+
{...nativeRest}
|
|
44
|
+
{...nativeAttrs}
|
|
20
45
|
/>
|
|
21
46
|
);
|
|
22
47
|
}
|
|
23
|
-
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<CustomSelect<T>
|
|
51
|
+
onValueChange={onValueChange}
|
|
52
|
+
filterable={filterable}
|
|
53
|
+
clearable={clearable}
|
|
54
|
+
ref={ref as React.Ref<HTMLDivElement>}
|
|
55
|
+
{...rest}
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
}) as SelectComponent;
|
|
24
59
|
|
|
25
60
|
export default Select;
|
|
@@ -24,9 +24,29 @@ export type OptionData<T> = {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* Additional props forwarded to the filter input when `filterable` is true
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
export type FilterInputProps = Omit<
|
|
30
|
+
React.InputHTMLAttributes<HTMLInputElement>,
|
|
31
|
+
| 'value'
|
|
32
|
+
| 'onChange'
|
|
33
|
+
| 'disabled'
|
|
34
|
+
| 'ref'
|
|
35
|
+
| 'role'
|
|
36
|
+
| 'aria-autocomplete'
|
|
37
|
+
| 'aria-label'
|
|
38
|
+
>;
|
|
39
|
+
|
|
40
|
+
type SelectBaseProps<T = string | number> = Omit<
|
|
41
|
+
React.HTMLAttributes<HTMLElement>,
|
|
42
|
+
'onChange'
|
|
43
|
+
> & {
|
|
44
|
+
/**
|
|
45
|
+
* Controls keyboard selection behaviour in the custom select variant.
|
|
46
|
+
* - `focus` (default): arrow keys move focus and commit value immediately.
|
|
47
|
+
* - `commit`: arrow keys only move focus; Enter or click commits value.
|
|
48
|
+
*/
|
|
49
|
+
selectionBehaviour?: 'focus' | 'commit';
|
|
30
50
|
/**
|
|
31
51
|
* An array of option data, to be rendered either natively or custom
|
|
32
52
|
*/
|
|
@@ -51,62 +71,97 @@ interface BaseSelectProps<T = string> {
|
|
|
51
71
|
* Native flag determines which implementation to use
|
|
52
72
|
*/
|
|
53
73
|
native?: boolean;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Adds a text input to filter options in the custom variant; ignored for native
|
|
76
|
+
*/
|
|
77
|
+
filterable?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Extra props to apply to the filter input when `filterable` is true
|
|
80
|
+
*/
|
|
81
|
+
filterInputProps?: FilterInputProps;
|
|
82
|
+
/**
|
|
83
|
+
* Extra attributes forwarded to the native <select> when `native` is true
|
|
84
|
+
*/
|
|
85
|
+
nativeHtmlAttributes?: React.SelectHTMLAttributes<HTMLSelectElement>;
|
|
86
|
+
/**
|
|
87
|
+
* Disable interaction
|
|
88
|
+
*/
|
|
89
|
+
disabled?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Allow long option labels to wrap instead of truncating
|
|
92
|
+
*/
|
|
93
|
+
lineBreak?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Custom className for the root element
|
|
96
|
+
*/
|
|
97
|
+
className?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Custom className for the options panel
|
|
100
|
+
*/
|
|
101
|
+
panelClassName?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Ref forwarded to the rendered element
|
|
104
|
+
* (div for custom, select for native)
|
|
105
|
+
*/
|
|
106
|
+
ref?: React.Ref<HTMLDivElement | HTMLSelectElement | null>;
|
|
107
|
+
};
|
|
70
108
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
React.HTMLAttributes<HTMLDivElement>,
|
|
77
|
-
'onChange'
|
|
78
|
-
> &
|
|
79
|
-
BaseSelectProps<T> & {
|
|
80
|
-
native?: false;
|
|
109
|
+
export type NonClearableSelectProps<T = string | number> =
|
|
110
|
+
SelectBaseProps<T> & {
|
|
111
|
+
/**
|
|
112
|
+
* Current value (controlled)
|
|
113
|
+
*/
|
|
81
114
|
value?: T;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
115
|
+
/**
|
|
116
|
+
* Show a clear action in the custom variant when a value is selected
|
|
117
|
+
*/
|
|
118
|
+
clearable?: false | undefined;
|
|
119
|
+
/**
|
|
120
|
+
* Change handler for the custom variant
|
|
121
|
+
*/
|
|
122
|
+
onValueChange?: (value: T, ev: React.SyntheticEvent) => void;
|
|
87
123
|
};
|
|
88
124
|
|
|
125
|
+
export type ClearableSelectProps<T = string | number> = SelectBaseProps<T> & {
|
|
126
|
+
/**
|
|
127
|
+
* Current value (controlled)
|
|
128
|
+
*/
|
|
129
|
+
value?: T | null;
|
|
130
|
+
/**
|
|
131
|
+
* Show a clear action in the custom variant when a value is selected
|
|
132
|
+
*/
|
|
133
|
+
clearable: true;
|
|
134
|
+
/**
|
|
135
|
+
* Change handler for the custom variant
|
|
136
|
+
*/
|
|
137
|
+
onValueChange?: (value: T | null, ev: React.SyntheticEvent) => void;
|
|
138
|
+
};
|
|
139
|
+
|
|
89
140
|
/**
|
|
90
|
-
*
|
|
91
|
-
* Default props like value and onChange are passed to the <select> element automatically
|
|
141
|
+
* Public props for <Select>, used by both custom and native render paths.
|
|
92
142
|
*/
|
|
93
|
-
export type
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
ref?: React.RefObject<HTMLSelectElement | null>;
|
|
97
|
-
};
|
|
143
|
+
export type SelectProps<T = string | number> =
|
|
144
|
+
| NonClearableSelectProps<T>
|
|
145
|
+
| ClearableSelectProps<T>;
|
|
98
146
|
|
|
99
|
-
export type
|
|
147
|
+
export type InternalSelectProps<T = string | number> = SelectBaseProps<T> & {
|
|
148
|
+
value?: T | null;
|
|
149
|
+
clearable?: boolean;
|
|
150
|
+
onValueChange?: (value: T | null, ev: React.SyntheticEvent) => void;
|
|
151
|
+
};
|
|
100
152
|
|
|
101
153
|
/**
|
|
102
154
|
* Each option as displayed in the Panel of <CustomSelect>
|
|
103
155
|
* Roughly equivalent to a custom version of <option>
|
|
104
156
|
*/
|
|
105
|
-
export interface CustomOptionProps<T>
|
|
106
|
-
|
|
157
|
+
export interface CustomOptionProps<T> extends Omit<
|
|
158
|
+
React.HTMLAttributes<HTMLDivElement>,
|
|
159
|
+
'onSelect'
|
|
160
|
+
> {
|
|
107
161
|
value: T;
|
|
162
|
+
optionIndex?: number;
|
|
108
163
|
testId?: string;
|
|
109
164
|
isSelected?: boolean;
|
|
110
|
-
onSelect: (event: React.MouseEvent, value: T) => void;
|
|
165
|
+
onSelect: (event: React.MouseEvent, value: T, optionIndex?: number) => void;
|
|
111
166
|
lineBreak?: boolean;
|
|
112
167
|
}
|