uikit-react-public 0.11.24 → 0.17.4
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 +4 -2
- package/dist/components/Accordion/Accordion.Heading.d.ts +4 -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/Avatar/Avatar.stories.d.ts +107 -1
- package/dist/components/Badge/Badge.d.ts +6 -0
- package/dist/components/Badge/Badge.stories.d.ts +15 -0
- package/dist/components/Badge/index.d.ts +2 -0
- package/dist/components/Button/Button.d.ts +3 -1
- package/dist/components/Calendar/index.d.ts +1 -1
- package/dist/components/CookieNotice/CookieNotice.d.ts +16 -0
- package/dist/components/CookieNotice/index.d.ts +2 -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 +8 -2
- package/dist/components/Dialog/Dialog.d.ts +2 -0
- package/dist/components/FileInput/FileInput.d.ts +8 -0
- package/dist/components/FileInput/FileInput.stories.d.ts +16 -0
- package/dist/components/FileInput/index.d.ts +2 -0
- package/dist/components/Header/Header.d.ts +7 -1
- package/dist/components/Header/Header.stories.d.ts +40 -0
- package/dist/components/Heading/Heading.d.ts +1 -1
- package/dist/components/Link/BaseLink.d.ts +10 -0
- package/dist/components/Link/Link.d.ts +5 -10
- package/dist/components/Link/Link.stories.d.ts +1 -1
- package/dist/components/Link/index.d.ts +1 -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/Menu/MenuContent.d.ts +1 -1
- package/dist/components/Menu/MenuItem.d.ts +2 -0
- package/dist/components/Menu/MenuSection.d.ts +1 -1
- 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/Search/Search.d.ts +16 -0
- package/dist/components/Search/Search.stories.d.ts +34 -0
- package/dist/components/Search/__tests__/Search.test.d.ts +1 -0
- package/dist/components/Search/index.d.ts +2 -0
- package/dist/components/Select/Select.d.ts +1 -1
- package/dist/components/Select/Select.stories.d.ts +157 -9
- package/dist/components/Select/Select.types.d.ts +66 -32
- package/dist/components/Select/subcomponents/CustomOption.d.ts +1 -1
- package/dist/components/Select/subcomponents/CustomSelect.d.ts +3 -3
- package/dist/components/Select/subcomponents/FilterInput.d.ts +14 -0
- package/dist/components/Select/subcomponents/NativeSelect.d.ts +5 -1
- package/dist/components/Select/subcomponents/Panel.d.ts +1 -1
- package/dist/components/Select/subcomponents/VisibleField.d.ts +6 -4
- package/dist/components/Select/subcomponents/index.d.ts +1 -0
- package/dist/components/StandaloneLink/StandaloneLink.d.ts +12 -0
- package/dist/components/StandaloneLink/StandaloneLink.stories.d.ts +13 -0
- package/dist/components/StandaloneLink/__tests__/StandaloneLink.test.d.ts +1 -0
- package/dist/components/StandaloneLink/index.d.ts +2 -0
- package/dist/components/Table/Table.d.ts +10 -8
- package/dist/components/Table/Table.stories.d.ts +21 -0
- package/dist/components/Table/Table.types.d.ts +11 -0
- package/dist/components/Table/__tests__/Table.test.d.ts +1 -0
- package/dist/components/Table/index.d.ts +2 -1
- package/dist/components/Table/subcomponents/Body.d.ts +4 -0
- package/dist/components/Table/subcomponents/Cell/Cell.d.ts +12 -0
- package/dist/components/Table/subcomponents/Cell/Cell.stories.d.ts +313 -0
- package/dist/components/Table/subcomponents/Cell/CellContent.d.ts +10 -0
- package/dist/components/Table/subcomponents/Cell/__tests__/Cell.test.d.ts +1 -0
- package/dist/components/Table/subcomponents/Head.d.ts +4 -0
- package/dist/components/Table/subcomponents/HeadCell/HeadCell.d.ts +13 -0
- package/dist/components/Table/subcomponents/HeadCell/HeadCell.stories.d.ts +312 -0
- package/dist/components/Table/subcomponents/HeadCell/HeadCellContent.d.ts +10 -0
- package/dist/components/Table/subcomponents/HeadCell/__tests__/HeadCell.test.d.ts +1 -0
- package/dist/components/Table/subcomponents/Row.d.ts +5 -0
- package/dist/components/Table/subcomponents/SortIcon.d.ts +7 -0
- package/dist/components/Table/subcomponents/index.d.ts +10 -0
- package/dist/components/Tabs/Tab.d.ts +1 -1
- package/dist/components/Tabs/TabContext.d.ts +1 -0
- package/dist/components/Tabs/Tabs.d.ts +3 -1
- package/dist/components/Tabs/Tabs.stories.d.ts +3 -0
- package/dist/components/Timepicker/Timepicker.d.ts +10 -0
- package/dist/components/Timepicker/Timepicker.stories.d.ts +7 -0
- package/dist/components/Timepicker/__tests__/Timepicker.test.d.ts +1 -0
- package/dist/components/Timepicker/index.d.ts +2 -0
- package/dist/components/Timepicker/utils/convertDateToTimeString.d.ts +2 -0
- package/dist/components/Timepicker/utils/convertDateToTimeString.test.d.ts +1 -0
- package/dist/components/Timepicker/utils/index.d.ts +1 -0
- package/dist/components/WeekPicker/WeekPicker.d.ts +3 -0
- 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 +2 -0
- package/dist/components/WeekPicker/subcomponents/CustomDatepicker.d.ts +17 -0
- package/dist/components/WeekPicker/subcomponents/DatepickerInput.d.ts +13 -0
- package/dist/components/WeekPicker/subcomponents/VisibleField.d.ts +15 -0
- package/dist/components/WeekPicker/subcomponents/index.d.ts +3 -0
- package/dist/components/index.d.ts +19 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useFocusTrap.d.ts +10 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6460 -4607
- package/dist/theme/defaultTheme.d.ts +7 -0
- package/dist/theme/useTheme.d.ts +14 -0
- package/dist/utils/__tests__/announce.test.d.ts +1 -0
- package/dist/utils/__tests__/capitalise.test.d.ts +1 -0
- package/dist/utils/announce.d.ts +6 -0
- package/dist/utils/capitalise.d.ts +2 -0
- package/dist/utils/index.d.ts +1 -0
- package/lib/components/Accordion/Accordion.Heading.tsx +27 -8
- package/lib/components/Accordion/Accordion.Panel.tsx +11 -3
- package/lib/components/Accordion/Accordion.stories.tsx +139 -0
- package/lib/components/Accordion/Accordion.tsx +10 -8
- package/lib/components/Accordion/__tests__/__snapshots__/Accordion.test.tsx.snap +7 -7
- package/lib/components/Accordion/index.ts +2 -0
- package/lib/components/Alert/Alert.stories.tsx +1 -1
- package/lib/components/Alert/Alert.tsx +7 -1
- package/lib/components/Alert/__tests__/__snapshots__/Alert.test.tsx.snap +4 -0
- package/lib/components/Avatar/Avatar.mdx +117 -0
- package/lib/components/Avatar/Avatar.stories.tsx +110 -2
- package/lib/components/Badge/Badge.stories.tsx +19 -0
- package/lib/components/Badge/Badge.tsx +48 -0
- package/lib/components/Badge/index.ts +2 -0
- package/lib/components/Blanket/Blanket.stories.tsx +1 -1
- package/lib/components/Breadcrumbs/__tests__/__snapshots__/Breadcrumbs.test.tsx.snap +4 -4
- package/lib/components/Button/Button.stories.tsx +1 -1
- package/lib/components/Button/Button.tsx +6 -2
- package/lib/components/Calendar/Calendar.stories.tsx +12 -32
- package/lib/components/Calendar/__tests__/Calendar.test.tsx +23 -15
- package/lib/components/Calendar/index.ts +1 -5
- package/lib/components/Calendar/subcomponents/AcademicWeeks.tsx +2 -1
- package/lib/components/Calendar/subcomponents/ColumnHeading.tsx +5 -1
- package/lib/components/Calendar/subcomponents/EventDot.tsx +2 -1
- package/lib/components/Calendar/subcomponents/Grid.tsx +0 -1
- 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/CookieNotice/CookieNotice.tsx +114 -0
- package/lib/components/CookieNotice/index.ts +2 -0
- 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 +150 -8
- package/lib/components/Datepicker/__tests__/__snapshots__/Datepicker.test.tsx.snap +10 -4
- package/lib/components/Datepicker/subcomponents/CustomDatepicker.tsx +39 -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 +40 -3
- package/lib/components/Datepicker/subcomponents/index.ts +0 -1
- package/lib/components/Datepicker/utils/index.ts +0 -1
- package/lib/components/Dialog/BaseDialog.tsx +55 -4
- 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/Field/ErrorText.tsx +1 -0
- package/lib/components/Field/Field.stories.tsx +1 -1
- package/lib/components/Field/__tests__/Field.test.tsx +161 -148
- package/lib/components/FileInput/FileInput.stories.tsx +70 -0
- package/lib/components/FileInput/FileInput.tsx +68 -0
- package/lib/components/FileInput/__tests__/FileInput.test.tsx +99 -0
- package/lib/components/FileInput/__tests__/__snapshots__/FileInput.test.tsx.snap +91 -0
- package/lib/components/FileInput/index.ts +2 -0
- package/lib/components/Footer/Footer.stories.tsx +1 -1
- package/lib/components/Footer/__tests__/__snapshots__/Footer.test.tsx.snap +28 -28
- package/lib/components/Header/Header.mdx +52 -0
- package/lib/components/Header/Header.stories.tsx +98 -0
- package/lib/components/Header/Header.tsx +65 -3
- package/lib/components/Header/__tests__/Header.test.tsx +17 -1
- package/lib/components/Header/__tests__/__snapshots__/Header.test.tsx.snap +4 -4
- package/lib/components/Heading/Documentation.mdx +1 -1
- package/lib/components/Heading/Heading.stories.tsx +1 -1
- package/lib/components/Heading/Heading.tsx +1 -1
- package/lib/components/Heading/__tests__/Heading.test.tsx +7 -19
- package/lib/components/Heading/__tests__/__snapshots__/Heading.test.tsx.snap +7 -7
- package/lib/components/Icon/Icon.stories.tsx +1 -1
- package/lib/components/IconButton/IconButton.stories.tsx +1 -1
- package/lib/components/Input/Input.stories.tsx +1 -1
- package/lib/components/Label/Label.stories.tsx +1 -1
- package/lib/components/Label/Label.tsx +0 -2
- package/lib/components/Label/__tests__/__snapshots__/Label.test.tsx.snap +7 -7
- package/lib/components/Link/BaseLink.tsx +84 -0
- package/lib/components/Link/Link.tsx +72 -32
- package/lib/components/Link/__tests__/__snapshots__/link.test.tsx.snap +3 -3
- package/lib/components/Link/__tests__/link.test.tsx +6 -13
- package/lib/components/Link/index.ts +1 -1
- 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/Menu/Menu.context.tsx +3 -1
- package/lib/components/Menu/Menu.tsx +2 -2
- package/lib/components/Menu/MenuContent.tsx +5 -5
- package/lib/components/Menu/MenuItem.tsx +20 -3
- package/lib/components/Menu/MenuSection.tsx +4 -3
- 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/PaginationControls.tsx +56 -15
- package/lib/components/Pagination/PaginationInfo.tsx +5 -1
- package/lib/components/Paragraph/Paragraph.stories.tsx +1 -1
- package/lib/components/Search/Search.stories.tsx +41 -0
- package/lib/components/Search/Search.tsx +170 -0
- package/lib/components/Search/__tests__/Search.test.tsx +112 -0
- package/lib/components/Search/__tests__/__snapshots__/Search.test.tsx.snap +179 -0
- package/lib/components/Search/index.ts +2 -0
- package/lib/components/Select/Select.mdx +169 -0
- package/lib/components/Select/Select.stories.tsx +198 -77
- package/lib/components/Select/Select.tsx +37 -13
- package/lib/components/Select/Select.types.ts +77 -54
- package/lib/components/Select/__tests__/Select.test.tsx +448 -7
- package/lib/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +3 -3
- package/lib/components/Select/subcomponents/CustomOption.tsx +24 -10
- package/lib/components/Select/subcomponents/CustomSelect.tsx +333 -52
- package/lib/components/Select/subcomponents/FilterInput.tsx +80 -0
- package/lib/components/Select/subcomponents/NativeSelect.tsx +13 -1
- package/lib/components/Select/subcomponents/Panel.tsx +4 -5
- package/lib/components/Select/subcomponents/VisibleField.tsx +36 -24
- package/lib/components/Select/subcomponents/index.tsx +1 -0
- package/lib/components/Snackbar/Snackbar.stories.tsx +1 -1
- package/lib/components/Spinner/Spinner.stories.tsx +1 -1
- package/lib/components/StandaloneLink/StandaloneLink.stories.tsx +32 -0
- package/lib/components/StandaloneLink/StandaloneLink.tsx +183 -0
- package/lib/components/StandaloneLink/__tests__/StandaloneLink.test.tsx +57 -0
- package/lib/components/StandaloneLink/__tests__/__snapshots__/StandaloneLink.test.tsx.snap +19 -0
- package/lib/components/StandaloneLink/index.ts +2 -0
- package/lib/components/Table/Table.stories.tsx +337 -0
- package/lib/components/Table/Table.tsx +42 -67
- package/lib/components/Table/Table.types.ts +14 -0
- package/lib/components/Table/__tests__/Table.test.tsx +121 -0
- package/lib/components/Table/__tests__/__snapshots__/Table.test.tsx.snap +210 -0
- package/lib/components/Table/index.ts +8 -1
- package/lib/components/Table/subcomponents/Body.tsx +18 -0
- package/lib/components/Table/subcomponents/Cell/Cell.stories.tsx +151 -0
- package/lib/components/Table/subcomponents/Cell/Cell.tsx +72 -0
- package/lib/components/Table/subcomponents/Cell/CellContent.tsx +91 -0
- package/lib/components/Table/subcomponents/Cell/__tests__/Cell.test.tsx +115 -0
- package/lib/components/Table/subcomponents/Cell/__tests__/__snapshots__/Cell.test.tsx.snap +107 -0
- package/lib/components/Table/subcomponents/Head.tsx +34 -0
- package/lib/components/Table/subcomponents/HeadCell/HeadCell.stories.tsx +85 -0
- package/lib/components/Table/subcomponents/HeadCell/HeadCell.tsx +99 -0
- package/lib/components/Table/subcomponents/HeadCell/HeadCellContent.tsx +61 -0
- package/lib/components/Table/subcomponents/HeadCell/__tests__/HeadCell.test.tsx +137 -0
- package/lib/components/Table/subcomponents/HeadCell/__tests__/__snapshots__/HeadCell.test.tsx.snap +110 -0
- package/lib/components/Table/subcomponents/Row.tsx +49 -0
- package/lib/components/Table/subcomponents/SortIcon.tsx +63 -0
- package/lib/components/Table/subcomponents/index.ts +14 -0
- package/lib/components/Tabs/Tab.tsx +3 -3
- package/lib/components/Tabs/TabContext.tsx +1 -0
- package/lib/components/Tabs/Tabs.stories.tsx +9 -3
- package/lib/components/Tabs/Tabs.tsx +10 -32
- package/lib/components/Tabs/__tests__/Tabs.test.tsx +10 -4
- package/lib/components/Tabs/__tests__/__snapshots__/Tabs.test.tsx.snap +32 -32
- package/lib/components/Textarea/Textarea.stories.tsx +1 -1
- package/lib/components/Timepicker/Timepicker.stories.tsx +43 -0
- package/lib/components/Timepicker/Timepicker.tsx +100 -0
- package/lib/components/Timepicker/__tests__/Timepicker.test.tsx +55 -0
- package/lib/components/Timepicker/__tests__/__snapshots__/Timepicker.test.tsx.snap +19 -0
- package/lib/components/Timepicker/index.tsx +2 -0
- package/lib/components/Timepicker/utils/convertDateToTimeString.test.ts +54 -0
- package/lib/components/Timepicker/utils/convertDateToTimeString.ts +10 -0
- package/lib/components/Timepicker/utils/index.ts +1 -0
- package/lib/components/Toggle/Toggle.stories.tsx +1 -1
- package/lib/components/Tooltip/Tooltip.stories.tsx +1 -1
- package/lib/components/WeekPicker/WeekPicker.stories.tsx +147 -0
- package/lib/components/WeekPicker/WeekPicker.tsx +26 -0
- package/lib/components/WeekPicker/WeekPicker.types.ts +21 -0
- package/lib/components/WeekPicker/index.ts +2 -0
- package/lib/components/WeekPicker/subcomponents/CustomDatepicker.tsx +298 -0
- package/lib/components/WeekPicker/subcomponents/DatepickerInput.tsx +111 -0
- package/lib/components/WeekPicker/subcomponents/VisibleField.tsx +126 -0
- package/lib/components/WeekPicker/subcomponents/index.ts +3 -0
- package/lib/components/common/Common.mdx +1 -1
- package/lib/components/index.ts +28 -2
- package/lib/hooks/index.ts +2 -0
- package/lib/hooks/useFocusTrap.ts +159 -0
- package/lib/index.ts +2 -0
- package/lib/theme/defaultTheme.ts +7 -0
- package/lib/utils/__tests__/announce.test.ts +121 -0
- package/lib/utils/__tests__/capitalise.test.ts +40 -0
- package/lib/utils/announce.ts +134 -0
- package/lib/utils/capitalise.ts +4 -0
- package/lib/utils/index.ts +1 -0
- package/package.json +3 -6
- package/dist/components/Datepicker/subcomponents/NativeDatepicker.d.ts +0 -6
- package/lib/components/Accordion/Accordion.stories.tsx.NOT_READY +0 -93
- package/lib/components/Field/__tests__/__snapshots__/Field.test.tsx.snap +0 -300
- /package/dist/components/{Datepicker/utils/dateToLocaleISOString/dateToLocaleISOString.test.d.ts → FileInput/__tests__/FileInput.test.d.ts} +0 -0
- /package/lib/components/{Datepicker → NativeDatepicker}/utils/dateToLocaleISOString/dateToLocaleISOString.test.ts +0 -0
|
@@ -5,19 +5,23 @@ import { OptionData } from '../Select.types';
|
|
|
5
5
|
|
|
6
6
|
const NAME = 'ucl-uikit-select__visible-field';
|
|
7
7
|
|
|
8
|
-
interface VisibleFieldProps {
|
|
8
|
+
interface VisibleFieldProps<T> {
|
|
9
9
|
isOpen?: boolean;
|
|
10
10
|
disabled?: boolean;
|
|
11
|
-
selectedOption: OptionData | null | undefined;
|
|
11
|
+
selectedOption: OptionData<T> | null | undefined;
|
|
12
12
|
placeholder?: string;
|
|
13
|
+
filterable?: boolean;
|
|
14
|
+
children?: React.ReactNode;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
|
-
const
|
|
17
|
+
const VisibleField = <T extends string | number>({
|
|
16
18
|
selectedOption,
|
|
17
19
|
isOpen,
|
|
18
20
|
placeholder,
|
|
19
21
|
disabled,
|
|
20
|
-
|
|
22
|
+
filterable,
|
|
23
|
+
children,
|
|
24
|
+
}: VisibleFieldProps<T>) => {
|
|
21
25
|
const [theme] = useTheme();
|
|
22
26
|
|
|
23
27
|
const baseStyle = css`
|
|
@@ -29,41 +33,49 @@ const Field = ({
|
|
|
29
33
|
line-height: ${theme.font.lineHeight.h150};
|
|
30
34
|
`;
|
|
31
35
|
|
|
36
|
+
const style = cx(NAME, baseStyle);
|
|
37
|
+
|
|
32
38
|
const innerStyle = css`
|
|
33
|
-
display: inline-flex;
|
|
34
|
-
gap: 8px;
|
|
35
|
-
white-space: nowrap;
|
|
36
39
|
overflow: hidden;
|
|
40
|
+
white-space: nowrap;
|
|
41
|
+
text-overflow: ellipsis;
|
|
37
42
|
`;
|
|
38
43
|
|
|
39
|
-
const
|
|
40
|
-
|
|
44
|
+
const chevronIconBaseStyle = css`
|
|
45
|
+
flex-shrink: 0;
|
|
41
46
|
margin-left: auto;
|
|
42
47
|
color: ${theme.color.interaction.blue70};
|
|
43
|
-
${disabled && `color: ${theme.color.neutral.grey20};`}
|
|
44
|
-
${isOpen && `transform: rotate(180deg);`}
|
|
45
48
|
`;
|
|
46
49
|
|
|
47
|
-
const
|
|
50
|
+
const chevronIconOpenStyle = css`
|
|
51
|
+
transform: rotate(180deg);
|
|
52
|
+
`;
|
|
53
|
+
|
|
54
|
+
const chevronIconDisabledStyle = css`
|
|
55
|
+
color: ${theme.color.neutral.grey20};
|
|
56
|
+
`;
|
|
57
|
+
|
|
58
|
+
const chevronIconStyle = cx(
|
|
59
|
+
chevronIconBaseStyle,
|
|
60
|
+
isOpen && chevronIconOpenStyle,
|
|
61
|
+
disabled && chevronIconDisabledStyle
|
|
62
|
+
);
|
|
48
63
|
|
|
49
64
|
return (
|
|
50
65
|
<div
|
|
51
66
|
className={style}
|
|
52
67
|
data-testid={NAME}
|
|
53
68
|
>
|
|
54
|
-
|
|
55
|
-
{
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
)}
|
|
63
|
-
</span>
|
|
64
|
-
<Icon.ChevronDown className={iconStyle} />
|
|
69
|
+
{filterable && isOpen ? (
|
|
70
|
+
<div className={innerStyle}>{children}</div>
|
|
71
|
+
) : (
|
|
72
|
+
<span className={innerStyle}>
|
|
73
|
+
{selectedOption ? selectedOption.label : placeholder || ''}
|
|
74
|
+
</span>
|
|
75
|
+
)}
|
|
76
|
+
<Icon.ChevronDown className={chevronIconStyle} />
|
|
65
77
|
</div>
|
|
66
78
|
);
|
|
67
79
|
};
|
|
68
80
|
|
|
69
|
-
export default
|
|
81
|
+
export default VisibleField;
|
|
@@ -3,3 +3,4 @@ export { default as NativeSelect } from './NativeSelect';
|
|
|
3
3
|
export { default as CustomOption } from './CustomOption';
|
|
4
4
|
export { default as Panel } from './Panel';
|
|
5
5
|
export { default as VisibleField } from './VisibleField';
|
|
6
|
+
export { default as FilterInput } from './FilterInput';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import Link from './StandaloneLink';
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
title: 'Components/Work in progress/StandaloneLink',
|
|
7
|
+
component: Link,
|
|
8
|
+
args: {
|
|
9
|
+
children: 'Default link text',
|
|
10
|
+
href: 'https://ucl.ac.uk',
|
|
11
|
+
},
|
|
12
|
+
} satisfies Meta<typeof Link>;
|
|
13
|
+
|
|
14
|
+
export default meta;
|
|
15
|
+
|
|
16
|
+
type Story = StoryObj<typeof meta>;
|
|
17
|
+
|
|
18
|
+
export const Default: Story = {
|
|
19
|
+
render: (args) => <Link {...args}>{args.children}</Link>,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const NewTab: Story = {
|
|
23
|
+
name: 'Opens in a new tab',
|
|
24
|
+
render: (args) => (
|
|
25
|
+
<Link
|
|
26
|
+
{...args}
|
|
27
|
+
target='_blank'
|
|
28
|
+
>
|
|
29
|
+
{args.children}
|
|
30
|
+
</Link>
|
|
31
|
+
),
|
|
32
|
+
};
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { cloneElement, forwardRef, ReactElement } from 'react';
|
|
2
|
+
import { css, cx } from '@emotion/css';
|
|
3
|
+
import useTheme from '../../theme/useTheme';
|
|
4
|
+
import { IconProps } from '../Icon';
|
|
5
|
+
import BaseLink, { BaseLinkProps } from '../Link/BaseLink';
|
|
6
|
+
import marginsStyle, { MarginProps } from '../common/marginsStyle';
|
|
7
|
+
|
|
8
|
+
export interface StandaloneLinkBaseProps extends BaseLinkProps {
|
|
9
|
+
variant?: 'primary' | 'secondary' | 'tertiary';
|
|
10
|
+
icon?: ReactElement<IconProps>;
|
|
11
|
+
iconPosition?: 'left' | 'right';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type StandaloneLinkProps = StandaloneLinkBaseProps & MarginProps;
|
|
15
|
+
|
|
16
|
+
const NAME = 'ucl-uikit-standalone-link';
|
|
17
|
+
|
|
18
|
+
const StandaloneLink = forwardRef<HTMLAnchorElement, StandaloneLinkProps>(
|
|
19
|
+
(
|
|
20
|
+
{
|
|
21
|
+
variant = 'primary',
|
|
22
|
+
icon,
|
|
23
|
+
iconPosition = 'left',
|
|
24
|
+
noVisited = false,
|
|
25
|
+
disabled = false,
|
|
26
|
+
testId = NAME,
|
|
27
|
+
className,
|
|
28
|
+
children,
|
|
29
|
+
...props
|
|
30
|
+
},
|
|
31
|
+
ref
|
|
32
|
+
) => {
|
|
33
|
+
const iconSize: number = {
|
|
34
|
+
primary: 24,
|
|
35
|
+
secondary: 16,
|
|
36
|
+
tertiary: 16,
|
|
37
|
+
}[variant];
|
|
38
|
+
|
|
39
|
+
const [theme] = useTheme();
|
|
40
|
+
|
|
41
|
+
const baseStyle = css`
|
|
42
|
+
display: inline-flex;
|
|
43
|
+
align-items: center;
|
|
44
|
+
gap: 8px;
|
|
45
|
+
text-decoration: none;
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
const primaryStyle = css`
|
|
49
|
+
color: ${theme.color.link.default};
|
|
50
|
+
font-weight: 700;
|
|
51
|
+
`;
|
|
52
|
+
|
|
53
|
+
const secondaryStyle = css`
|
|
54
|
+
color: ${theme.color.link.default};
|
|
55
|
+
`;
|
|
56
|
+
|
|
57
|
+
const tertiaryStyle = css`
|
|
58
|
+
color: ${theme.color.text.primary};
|
|
59
|
+
`;
|
|
60
|
+
|
|
61
|
+
const visitedStyle = css`
|
|
62
|
+
&:visited {
|
|
63
|
+
color: ${theme.color.link.visited};
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
|
|
67
|
+
const primaryNoVisitedStyle = css`
|
|
68
|
+
&:visited {
|
|
69
|
+
color: ${theme.color.link.default};
|
|
70
|
+
}
|
|
71
|
+
`;
|
|
72
|
+
|
|
73
|
+
const secondaryNoVisitedStyle = css`
|
|
74
|
+
&:visited {
|
|
75
|
+
color: ${theme.color.link.default};
|
|
76
|
+
}
|
|
77
|
+
`;
|
|
78
|
+
|
|
79
|
+
const tertiaryNoVisitedStyle = css`
|
|
80
|
+
&:visited {
|
|
81
|
+
color: ${theme.color.text.primary};
|
|
82
|
+
}
|
|
83
|
+
`;
|
|
84
|
+
|
|
85
|
+
const primaryHoverAndActiveStyle = css`
|
|
86
|
+
&:hover {
|
|
87
|
+
color: ${theme.color.link.hover};
|
|
88
|
+
text-decoration: underline;
|
|
89
|
+
text-decoration-skip-ink: none;
|
|
90
|
+
text-decoration-thickness: 10%;
|
|
91
|
+
text-underline-offset: 25%;
|
|
92
|
+
text-underline-position: from-font;
|
|
93
|
+
}
|
|
94
|
+
&:active {
|
|
95
|
+
color: ${theme.color.link.hover};
|
|
96
|
+
}
|
|
97
|
+
`;
|
|
98
|
+
|
|
99
|
+
const secondaryHoverAndActiveStyle = css`
|
|
100
|
+
&:hover {
|
|
101
|
+
color: ${theme.color.link.hover};
|
|
102
|
+
text-decoration: underline;
|
|
103
|
+
text-decoration-skip-ink: none;
|
|
104
|
+
text-decoration-thickness: 10%;
|
|
105
|
+
text-underline-offset: 25%;
|
|
106
|
+
text-underline-position: from-font;
|
|
107
|
+
}
|
|
108
|
+
&:active {
|
|
109
|
+
color: ${theme.color.link.hover};
|
|
110
|
+
}
|
|
111
|
+
`;
|
|
112
|
+
|
|
113
|
+
const tertiaryHoverAndActiveStyle = css`
|
|
114
|
+
&:hover {
|
|
115
|
+
text-decoration: underline;
|
|
116
|
+
text-decoration-skip-ink: none;
|
|
117
|
+
text-decoration-thickness: 10%;
|
|
118
|
+
text-underline-offset: 25%;
|
|
119
|
+
text-underline-position: from-font;
|
|
120
|
+
}
|
|
121
|
+
&:hover {
|
|
122
|
+
color: ${theme.color.text.primary};
|
|
123
|
+
}
|
|
124
|
+
`;
|
|
125
|
+
|
|
126
|
+
let variantStyle = undefined;
|
|
127
|
+
if (variant === 'primary') {
|
|
128
|
+
variantStyle = cx(
|
|
129
|
+
primaryStyle,
|
|
130
|
+
noVisited && !disabled && primaryNoVisitedStyle,
|
|
131
|
+
!disabled && primaryHoverAndActiveStyle,
|
|
132
|
+
!noVisited && !disabled && visitedStyle
|
|
133
|
+
);
|
|
134
|
+
} else if (variant === 'secondary') {
|
|
135
|
+
variantStyle = cx(
|
|
136
|
+
secondaryStyle,
|
|
137
|
+
noVisited && !disabled && secondaryNoVisitedStyle,
|
|
138
|
+
!disabled && secondaryHoverAndActiveStyle,
|
|
139
|
+
!noVisited && !disabled && visitedStyle
|
|
140
|
+
);
|
|
141
|
+
} else if (variant === 'tertiary') {
|
|
142
|
+
variantStyle = cx(
|
|
143
|
+
tertiaryStyle,
|
|
144
|
+
!disabled && tertiaryNoVisitedStyle,
|
|
145
|
+
!disabled && tertiaryHoverAndActiveStyle
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const disabledStyle = css`
|
|
150
|
+
cursor: not-allowed;
|
|
151
|
+
color: ${theme.color.link.disabled};
|
|
152
|
+
`;
|
|
153
|
+
|
|
154
|
+
const style = cx(
|
|
155
|
+
NAME,
|
|
156
|
+
baseStyle,
|
|
157
|
+
marginsStyle(props, theme),
|
|
158
|
+
variantStyle,
|
|
159
|
+
disabled && disabledStyle,
|
|
160
|
+
className
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
return (
|
|
164
|
+
<BaseLink
|
|
165
|
+
ref={ref}
|
|
166
|
+
className={style}
|
|
167
|
+
testId={testId}
|
|
168
|
+
disabled={disabled}
|
|
169
|
+
{...props}
|
|
170
|
+
>
|
|
171
|
+
{icon &&
|
|
172
|
+
iconPosition === 'left' &&
|
|
173
|
+
cloneElement(icon, { size: iconSize })}
|
|
174
|
+
{children}
|
|
175
|
+
{icon &&
|
|
176
|
+
iconPosition === 'right' &&
|
|
177
|
+
cloneElement(icon, { size: iconSize })}
|
|
178
|
+
</BaseLink>
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
export default StandaloneLink;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import StandaloneLink from '../StandaloneLink';
|
|
4
|
+
import { ThemeContextProvider } from '../../../theme/useTheme';
|
|
5
|
+
|
|
6
|
+
describe('Link', () => {
|
|
7
|
+
// Snapshot tests
|
|
8
|
+
|
|
9
|
+
test('snapshot: no props', () => {
|
|
10
|
+
const renderResult = render(
|
|
11
|
+
<ThemeContextProvider>
|
|
12
|
+
<StandaloneLink>test</StandaloneLink>
|
|
13
|
+
</ThemeContextProvider>
|
|
14
|
+
);
|
|
15
|
+
expect(renderResult.container.firstChild).toMatchSnapshot();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('snapshot: testId prop', () => {
|
|
19
|
+
const renderResult = render(
|
|
20
|
+
<ThemeContextProvider>
|
|
21
|
+
<StandaloneLink testId='test123'> testidlink </StandaloneLink>
|
|
22
|
+
</ThemeContextProvider>
|
|
23
|
+
);
|
|
24
|
+
expect(renderResult.container.firstChild).toMatchSnapshot();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('test ID: default', () => {
|
|
28
|
+
render(
|
|
29
|
+
<ThemeContextProvider>
|
|
30
|
+
<StandaloneLink> testidlink </StandaloneLink>
|
|
31
|
+
</ThemeContextProvider>
|
|
32
|
+
);
|
|
33
|
+
const link = screen.getByTestId('ucl-uikit-standalone-link');
|
|
34
|
+
expect(link).toBeDefined();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('test ID: custom', () => {
|
|
38
|
+
render(
|
|
39
|
+
<ThemeContextProvider>
|
|
40
|
+
<StandaloneLink testId='custom-test-id'> testidlink </StandaloneLink>
|
|
41
|
+
</ThemeContextProvider>
|
|
42
|
+
);
|
|
43
|
+
const link = screen.getByTestId('custom-test-id');
|
|
44
|
+
expect(link).toBeDefined();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('href value', async () => {
|
|
48
|
+
render(
|
|
49
|
+
<ThemeContextProvider>
|
|
50
|
+
<StandaloneLink href='/testlink'>linktext</StandaloneLink>
|
|
51
|
+
</ThemeContextProvider>
|
|
52
|
+
);
|
|
53
|
+
const link = screen.getByRole('link') as HTMLAnchorElement;
|
|
54
|
+
expect(link.textContent).toBe('linktext');
|
|
55
|
+
expect(link.href).toBe('http://localhost:3000/testlink');
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`Link > snapshot: no props 1`] = `
|
|
4
|
+
<a
|
|
5
|
+
class="ucl-uikit-base-link ucl-uikit-standalone-link css-1fdgbfz"
|
|
6
|
+
data-testid="ucl-uikit-standalone-link"
|
|
7
|
+
>
|
|
8
|
+
test
|
|
9
|
+
</a>
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
exports[`Link > snapshot: testId prop 1`] = `
|
|
13
|
+
<a
|
|
14
|
+
class="ucl-uikit-base-link ucl-uikit-standalone-link css-1fdgbfz"
|
|
15
|
+
data-testid="test123"
|
|
16
|
+
>
|
|
17
|
+
testidlink
|
|
18
|
+
</a>
|
|
19
|
+
`;
|