uikit-react-public 0.11.20 → 0.14.21
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/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 +2 -1
- package/dist/components/Calendar/Calendar.d.ts +3 -0
- package/dist/components/Calendar/Calendar.stories.d.ts +42 -0
- package/dist/components/Calendar/Calendar.types.d.ts +18 -0
- package/dist/components/Calendar/index.d.ts +2 -0
- package/dist/components/Calendar/subcomponents/AcademicWeeks.d.ts +7 -0
- package/dist/components/Calendar/subcomponents/ColumnHeading.d.ts +7 -0
- package/dist/components/Calendar/subcomponents/Controls.d.ts +6 -0
- package/dist/components/{Datepicker/subcomponents/Day → Calendar/subcomponents}/Day.d.ts +3 -3
- package/dist/components/{Datepicker → Calendar}/subcomponents/EventDot.d.ts +2 -2
- package/dist/components/Calendar/subcomponents/Grid.d.ts +11 -0
- package/dist/components/Calendar/subcomponents/index.d.ts +7 -0
- package/dist/components/{Datepicker → Calendar}/utils/getAcademicWeekNumbers/getAcademicWeekNumbers.d.ts +1 -1
- package/dist/components/Calendar/utils/index.d.ts +4 -0
- package/dist/components/Calendar/utils/normaliseMonth/normaliseMonth.d.ts +9 -0
- package/dist/components/Calendar/utils/parseDateFromString/parseDateFromString.d.ts +9 -0
- package/dist/components/Calendar/utils/parseDateFromString/parseDateFromString.test.d.ts +1 -0
- 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 +3 -16
- package/dist/components/Datepicker/Datepicker.stories.d.ts +9 -3
- package/dist/components/Datepicker/Datepicker.types.d.ts +23 -7
- package/dist/components/Datepicker/index.d.ts +1 -2
- package/dist/components/Datepicker/subcomponents/CustomDatepicker.d.ts +17 -0
- package/dist/components/Datepicker/subcomponents/DatepickerInput.d.ts +10 -0
- package/dist/components/Datepicker/subcomponents/NativeDatepicker.d.ts +6 -0
- package/dist/components/Datepicker/subcomponents/Panel.d.ts +6 -0
- package/dist/components/Datepicker/subcomponents/VisibleField.d.ts +12 -0
- package/dist/components/Datepicker/subcomponents/index.d.ts +5 -7
- package/dist/components/Datepicker/utils/dateToLocaleISOString/dateToLocaleISOString.d.ts +17 -0
- package/dist/components/Datepicker/utils/dateToLocaleISOString/dateToLocaleISOString.test.d.ts +1 -0
- package/dist/components/Datepicker/utils/index.d.ts +2 -3
- package/dist/components/Datepicker/utils/parseInputValue/parseInputValue.d.ts +11 -0
- package/dist/components/Datepicker/utils/parseInputValue/parseInputValue.test.d.ts +1 -0
- package/dist/components/Dialog/BaseDialog.d.ts +7 -2
- package/dist/components/FileInput/FileInput.d.ts +8 -0
- package/dist/components/FileInput/FileInput.stories.d.ts +16 -0
- package/dist/components/FileInput/__tests__/FileInput.test.d.ts +1 -0
- package/dist/components/FileInput/index.d.ts +2 -0
- package/dist/components/Footer/Footer.d.ts +1 -1
- package/dist/components/Header/Header.d.ts +4 -1
- 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/Menu/Menu.d.ts +2 -1
- package/dist/components/Menu/MenuContent.d.ts +2 -1
- package/dist/components/Menu/MenuItem.d.ts +2 -0
- package/dist/components/Menu/MenuSection.d.ts +1 -1
- 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 +3 -7
- package/dist/components/Select/Select.types.d.ts +19 -14
- package/dist/components/Select/subcomponents/CustomOption.d.ts +1 -1
- package/dist/components/Select/subcomponents/CustomSelect.d.ts +1 -2
- package/dist/components/Select/subcomponents/Panel.d.ts +1 -1
- package/dist/components/Select/subcomponents/VisibleField.d.ts +4 -4
- 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/index.d.ts +1 -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 +13 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useFocusTrap.d.ts +9 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6006 -4599
- package/dist/theme/defaultTheme.d.ts +7 -0
- package/dist/theme/useTheme.d.ts +14 -0
- package/dist/utils/__tests__/capitalise.test.d.ts +1 -0
- package/dist/utils/capitalise.d.ts +2 -0
- package/lib/components/Alert/Alert.tsx +7 -1
- package/lib/components/Alert/__tests__/__snapshots__/Alert.test.tsx.snap +4 -0
- 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/Breadcrumbs/__tests__/__snapshots__/Breadcrumbs.test.tsx.snap +4 -4
- package/lib/components/Button/Button.tsx +5 -2
- package/lib/components/Calendar/Calendar.stories.tsx +209 -0
- package/lib/components/Calendar/Calendar.tsx +121 -0
- package/lib/components/Calendar/Calendar.types.ts +21 -0
- package/lib/components/Calendar/__tests__/Calendar.test.tsx +71 -0
- package/lib/components/Calendar/__tests__/__snapshots__/Calendar.test.tsx.snap +1218 -0
- package/lib/components/Calendar/index.ts +6 -0
- package/lib/components/{Datepicker → Calendar}/subcomponents/AcademicWeek.tsx +1 -1
- package/lib/components/{Datepicker → Calendar}/subcomponents/AcademicWeeks.tsx +9 -7
- package/lib/components/Calendar/subcomponents/ColumnHeading.tsx +40 -0
- package/lib/components/{Datepicker/subcomponents/MonthSelector/MonthSelector.tsx → Calendar/subcomponents/Controls.tsx} +17 -17
- package/lib/components/{Datepicker/subcomponents/Day → Calendar/subcomponents}/Day.stories.tsx +8 -8
- package/lib/components/{Datepicker/subcomponents/Day → Calendar/subcomponents}/Day.tsx +28 -16
- package/lib/components/{Datepicker → Calendar}/subcomponents/EventDot.tsx +3 -3
- package/lib/components/Calendar/subcomponents/Grid.tsx +116 -0
- package/lib/components/Calendar/subcomponents/index.ts +7 -0
- package/lib/components/{Datepicker → Calendar}/utils/getAcademicWeekNumbers/getAcademicWeekNumbers.test.ts +1 -1
- package/lib/components/{Datepicker → Calendar}/utils/getAcademicWeekNumbers/getAcademicWeekNumbers.ts +1 -1
- package/lib/components/{Datepicker → Calendar}/utils/getDatesForCalendarGrid/getDatesForCalendarGrid.test.ts +29 -65
- package/lib/components/{Datepicker → Calendar}/utils/getDatesForCalendarGrid/getDatesForCalendarGrid.ts +11 -43
- package/lib/components/Calendar/utils/index.ts +4 -0
- package/lib/components/Calendar/utils/normaliseMonth/normaliseMonth.test.ts +40 -0
- package/lib/components/Calendar/utils/normaliseMonth/normaliseMonth.ts +16 -0
- package/lib/components/Calendar/utils/parseDateFromString/parseDateFromString.test.ts +15 -0
- package/lib/components/Calendar/utils/parseDateFromString/parseDateFromString.ts +19 -0
- package/lib/components/CookieNotice/CookieNotice.tsx +114 -0
- package/lib/components/CookieNotice/index.ts +2 -0
- package/lib/components/Datepicker/Datepicker.stories.tsx +128 -64
- package/lib/components/Datepicker/Datepicker.tsx +34 -114
- package/lib/components/Datepicker/Datepicker.types.ts +38 -9
- package/lib/components/Datepicker/__tests__/Datepicker.test.tsx +53 -112
- package/lib/components/Datepicker/__tests__/__snapshots__/Datepicker.test.tsx.snap +92 -747
- package/lib/components/Datepicker/index.ts +1 -2
- package/lib/components/Datepicker/subcomponents/CustomDatepicker.tsx +209 -0
- package/lib/components/Datepicker/subcomponents/DatepickerInput.tsx +74 -0
- package/lib/components/Datepicker/subcomponents/NativeDatepicker.tsx +70 -0
- package/lib/components/Datepicker/subcomponents/Panel.tsx +32 -0
- package/lib/components/Datepicker/subcomponents/VisibleField.tsx +104 -0
- package/lib/components/Datepicker/subcomponents/index.ts +5 -7
- package/lib/components/Datepicker/utils/dateToLocaleISOString/dateToLocaleISOString.test.ts +32 -0
- package/lib/components/Datepicker/utils/dateToLocaleISOString/dateToLocaleISOString.ts +23 -0
- package/lib/components/Datepicker/utils/index.ts +2 -3
- package/lib/components/Datepicker/utils/parseInputValue/parseInputValue.test.ts +110 -0
- package/lib/components/Datepicker/utils/parseInputValue/parseInputValue.ts +57 -0
- package/lib/components/Dialog/BaseDialog.tsx +44 -4
- package/lib/components/Field/__tests__/Field.test.tsx +148 -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.tsx +3 -3
- package/lib/components/Footer/__tests__/__snapshots__/Footer.test.tsx.snap +31 -31
- package/lib/components/Header/Header.tsx +19 -2
- 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.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/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/Menu/Menu.context.tsx +3 -1
- package/lib/components/Menu/Menu.tsx +5 -2
- package/lib/components/Menu/MenuContent.tsx +9 -6
- package/lib/components/Menu/MenuItem.tsx +20 -3
- package/lib/components/Menu/MenuSection.tsx +4 -3
- package/lib/components/Pagination/PaginationControls.tsx +1 -3
- package/lib/components/Search/Search.stories.tsx +41 -0
- package/lib/components/Search/Search.tsx +167 -0
- package/lib/components/Search/__tests__/Search.test.tsx +94 -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.stories.tsx +8 -35
- package/lib/components/Select/Select.tsx +2 -2
- package/lib/components/Select/Select.types.ts +20 -15
- package/lib/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +3 -3
- package/lib/components/Select/subcomponents/CustomOption.tsx +22 -9
- package/lib/components/Select/subcomponents/CustomSelect.tsx +31 -20
- package/lib/components/Select/subcomponents/Panel.tsx +4 -5
- package/lib/components/Select/subcomponents/VisibleField.tsx +26 -22
- 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/Timepicker/Timepicker.stories.tsx +43 -0
- package/lib/components/Timepicker/Timepicker.tsx +96 -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/WeekPicker/WeekPicker.tsx +26 -0
- package/lib/components/WeekPicker/index.ts +1 -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/index.ts +20 -0
- package/lib/hooks/index.ts +2 -0
- package/lib/hooks/useFocusTrap.ts +123 -0
- package/lib/index.ts +1 -0
- package/lib/theme/defaultTheme.ts +7 -0
- package/lib/utils/__tests__/capitalise.test.ts +40 -0
- package/lib/utils/capitalise.ts +4 -0
- package/package.json +2 -2
- package/dist/components/Datepicker/subcomponents/AcademicWeeks.d.ts +0 -7
- package/dist/components/Datepicker/subcomponents/CalendarGrid/CalendarGrid.d.ts +0 -8
- package/dist/components/Datepicker/subcomponents/CalendarGrid/index.d.ts +0 -1
- package/dist/components/Datepicker/subcomponents/CalendarMenu/CalendarMenu.d.ts +0 -12
- package/dist/components/Datepicker/subcomponents/CalendarMenu/index.d.ts +0 -1
- package/dist/components/Datepicker/subcomponents/ColumnHeadings/ColumnHeadings.d.ts +0 -2
- package/dist/components/Datepicker/subcomponents/ColumnHeadings/index.d.ts +0 -1
- package/dist/components/Datepicker/subcomponents/DateField/DateField.d.ts +0 -7
- package/dist/components/Datepicker/subcomponents/DateField/index.d.ts +0 -1
- package/dist/components/Datepicker/subcomponents/Day/index.d.ts +0 -1
- package/dist/components/Datepicker/subcomponents/MonthSelector/MonthSelector.d.ts +0 -6
- package/dist/components/Datepicker/subcomponents/MonthSelector/index.d.ts +0 -1
- package/dist/components/Datepicker/subcomponents/Native/Native.d.ts +0 -9
- package/dist/components/Datepicker/subcomponents/Native/index.d.ts +0 -1
- package/dist/components/Datepicker/utils/parseDateForDateField/parseDateForDateField.d.ts +0 -20
- package/lib/components/Datepicker/subcomponents/CalendarGrid/CalendarGrid.tsx +0 -54
- package/lib/components/Datepicker/subcomponents/CalendarGrid/index.ts +0 -1
- package/lib/components/Datepicker/subcomponents/CalendarMenu/CalendarMenu.tsx +0 -90
- package/lib/components/Datepicker/subcomponents/CalendarMenu/index.ts +0 -1
- package/lib/components/Datepicker/subcomponents/ColumnHeadings/ColumnHeadings.tsx +0 -35
- package/lib/components/Datepicker/subcomponents/ColumnHeadings/index.ts +0 -1
- package/lib/components/Datepicker/subcomponents/DateField/DateField.tsx +0 -155
- package/lib/components/Datepicker/subcomponents/DateField/__tests__/DateField.test.tsx +0 -191
- package/lib/components/Datepicker/subcomponents/DateField/index.ts +0 -1
- package/lib/components/Datepicker/subcomponents/Day/index.ts +0 -1
- package/lib/components/Datepicker/subcomponents/MonthSelector/index.ts +0 -1
- package/lib/components/Datepicker/subcomponents/Native/Native.tsx +0 -59
- package/lib/components/Datepicker/subcomponents/Native/index.ts +0 -1
- package/lib/components/Datepicker/utils/parseDateForDateField/parseDateForDateField.test.ts +0 -41
- package/lib/components/Datepicker/utils/parseDateForDateField/parseDateForDateField.ts +0 -48
- package/lib/components/Field/__tests__/__snapshots__/Field.test.tsx.snap +0 -300
- /package/dist/components/{Datepicker/subcomponents/DateField/__tests__/DateField.test.d.ts → Calendar/__tests__/Calendar.test.d.ts} +0 -0
- /package/dist/components/{Datepicker → Calendar}/subcomponents/AcademicWeek.d.ts +0 -0
- /package/dist/components/{Datepicker/subcomponents/Day → Calendar/subcomponents}/Day.stories.d.ts +0 -0
- /package/dist/components/{Datepicker → Calendar}/utils/getAcademicWeekNumbers/getAcademicWeekNumbers.test.d.ts +0 -0
- /package/dist/components/{Datepicker → Calendar}/utils/getDatesForCalendarGrid/getDatesForCalendarGrid.d.ts +0 -0
- /package/dist/components/{Datepicker → Calendar}/utils/getDatesForCalendarGrid/getDatesForCalendarGrid.test.d.ts +0 -0
- /package/dist/components/{Datepicker/utils/parseDateForDateField/parseDateForDateField.test.d.ts → Calendar/utils/normaliseMonth/normaliseMonth.test.d.ts} +0 -0
|
@@ -20,6 +20,7 @@ declare const blackAndWhite: {
|
|
|
20
20
|
white: string;
|
|
21
21
|
};
|
|
22
22
|
declare const theme: {
|
|
23
|
+
p0: number;
|
|
23
24
|
p2: string;
|
|
24
25
|
p4: string;
|
|
25
26
|
p6: string;
|
|
@@ -35,6 +36,7 @@ declare const theme: {
|
|
|
35
36
|
p64: string;
|
|
36
37
|
p72: string;
|
|
37
38
|
p80: string;
|
|
39
|
+
m0: number;
|
|
38
40
|
m2: string;
|
|
39
41
|
m4: string;
|
|
40
42
|
m6: string;
|
|
@@ -114,7 +116,9 @@ declare const theme: {
|
|
|
114
116
|
};
|
|
115
117
|
link: {
|
|
116
118
|
default: string;
|
|
119
|
+
secondaryDefault: string;
|
|
117
120
|
hover: string;
|
|
121
|
+
secondaryHover: string;
|
|
118
122
|
visited: string;
|
|
119
123
|
disabled: string;
|
|
120
124
|
};
|
|
@@ -122,6 +126,7 @@ declare const theme: {
|
|
|
122
126
|
black: string;
|
|
123
127
|
grey90: string;
|
|
124
128
|
grey80: string;
|
|
129
|
+
grey70: string;
|
|
125
130
|
grey60: string;
|
|
126
131
|
grey40: string;
|
|
127
132
|
grey20: string;
|
|
@@ -153,6 +158,7 @@ declare const theme: {
|
|
|
153
158
|
h80: string;
|
|
154
159
|
};
|
|
155
160
|
margin: {
|
|
161
|
+
m0: number;
|
|
156
162
|
m2: string;
|
|
157
163
|
m4: string;
|
|
158
164
|
m6: string;
|
|
@@ -170,6 +176,7 @@ declare const theme: {
|
|
|
170
176
|
m80: string;
|
|
171
177
|
};
|
|
172
178
|
padding: {
|
|
179
|
+
p0: number;
|
|
173
180
|
p2: string;
|
|
174
181
|
p4: string;
|
|
175
182
|
p6: string;
|
package/dist/theme/useTheme.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export declare const ThemeContextProvider: React.FC<{
|
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
}>;
|
|
5
5
|
declare const useTheme: () => [{
|
|
6
|
+
p0: number;
|
|
6
7
|
p2: string;
|
|
7
8
|
p4: string;
|
|
8
9
|
p6: string;
|
|
@@ -18,6 +19,7 @@ declare const useTheme: () => [{
|
|
|
18
19
|
p64: string;
|
|
19
20
|
p72: string;
|
|
20
21
|
p80: string;
|
|
22
|
+
m0: number;
|
|
21
23
|
m2: string;
|
|
22
24
|
m4: string;
|
|
23
25
|
m6: string;
|
|
@@ -97,7 +99,9 @@ declare const useTheme: () => [{
|
|
|
97
99
|
};
|
|
98
100
|
link: {
|
|
99
101
|
default: string;
|
|
102
|
+
secondaryDefault: string;
|
|
100
103
|
hover: string;
|
|
104
|
+
secondaryHover: string;
|
|
101
105
|
visited: string;
|
|
102
106
|
disabled: string;
|
|
103
107
|
};
|
|
@@ -105,6 +109,7 @@ declare const useTheme: () => [{
|
|
|
105
109
|
black: string;
|
|
106
110
|
grey90: string;
|
|
107
111
|
grey80: string;
|
|
112
|
+
grey70: string;
|
|
108
113
|
grey60: string;
|
|
109
114
|
grey40: string;
|
|
110
115
|
grey20: string;
|
|
@@ -136,6 +141,7 @@ declare const useTheme: () => [{
|
|
|
136
141
|
h80: string;
|
|
137
142
|
};
|
|
138
143
|
margin: {
|
|
144
|
+
m0: number;
|
|
139
145
|
m2: string;
|
|
140
146
|
m4: string;
|
|
141
147
|
m6: string;
|
|
@@ -153,6 +159,7 @@ declare const useTheme: () => [{
|
|
|
153
159
|
m80: string;
|
|
154
160
|
};
|
|
155
161
|
padding: {
|
|
162
|
+
p0: number;
|
|
156
163
|
p2: string;
|
|
157
164
|
p4: string;
|
|
158
165
|
p6: string;
|
|
@@ -244,6 +251,7 @@ declare const useTheme: () => [{
|
|
|
244
251
|
custom: (breakpoint: number) => string;
|
|
245
252
|
};
|
|
246
253
|
}, import('react').Dispatch<import('react').SetStateAction<{
|
|
254
|
+
p0: number;
|
|
247
255
|
p2: string;
|
|
248
256
|
p4: string;
|
|
249
257
|
p6: string;
|
|
@@ -259,6 +267,7 @@ declare const useTheme: () => [{
|
|
|
259
267
|
p64: string;
|
|
260
268
|
p72: string;
|
|
261
269
|
p80: string;
|
|
270
|
+
m0: number;
|
|
262
271
|
m2: string;
|
|
263
272
|
m4: string;
|
|
264
273
|
m6: string;
|
|
@@ -338,7 +347,9 @@ declare const useTheme: () => [{
|
|
|
338
347
|
};
|
|
339
348
|
link: {
|
|
340
349
|
default: string;
|
|
350
|
+
secondaryDefault: string;
|
|
341
351
|
hover: string;
|
|
352
|
+
secondaryHover: string;
|
|
342
353
|
visited: string;
|
|
343
354
|
disabled: string;
|
|
344
355
|
};
|
|
@@ -346,6 +357,7 @@ declare const useTheme: () => [{
|
|
|
346
357
|
black: string;
|
|
347
358
|
grey90: string;
|
|
348
359
|
grey80: string;
|
|
360
|
+
grey70: string;
|
|
349
361
|
grey60: string;
|
|
350
362
|
grey40: string;
|
|
351
363
|
grey20: string;
|
|
@@ -377,6 +389,7 @@ declare const useTheme: () => [{
|
|
|
377
389
|
h80: string;
|
|
378
390
|
};
|
|
379
391
|
margin: {
|
|
392
|
+
m0: number;
|
|
380
393
|
m2: string;
|
|
381
394
|
m4: string;
|
|
382
395
|
m6: string;
|
|
@@ -394,6 +407,7 @@ declare const useTheme: () => [{
|
|
|
394
407
|
m80: string;
|
|
395
408
|
};
|
|
396
409
|
padding: {
|
|
410
|
+
p0: number;
|
|
397
411
|
p2: string;
|
|
398
412
|
p4: string;
|
|
399
413
|
p6: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -5,6 +5,7 @@ import AlertMessage from './AlertMessage';
|
|
|
5
5
|
import AlertTitle from './AlertTitle';
|
|
6
6
|
import marginsStyle, { MarginProps } from '../common/marginsStyle';
|
|
7
7
|
import { useTheme } from '../../theme';
|
|
8
|
+
import capitalise from '../../utils/capitalise';
|
|
8
9
|
|
|
9
10
|
export const NAME = 'ucl-uikit-alert';
|
|
10
11
|
|
|
@@ -38,6 +39,8 @@ const Alert = ({
|
|
|
38
39
|
className,
|
|
39
40
|
...props
|
|
40
41
|
}: AlertProps) => {
|
|
42
|
+
const typeName = capitalise(type);
|
|
43
|
+
|
|
41
44
|
const [theme] = useTheme();
|
|
42
45
|
|
|
43
46
|
const { padding } = theme;
|
|
@@ -117,7 +120,10 @@ const Alert = ({
|
|
|
117
120
|
role='alert'
|
|
118
121
|
{...props}
|
|
119
122
|
>
|
|
120
|
-
<IconComp
|
|
123
|
+
<IconComp
|
|
124
|
+
className={iconStyle}
|
|
125
|
+
aria-label={typeName}
|
|
126
|
+
/>
|
|
121
127
|
<div>{children}</div>
|
|
122
128
|
</div>
|
|
123
129
|
</AlertContext.Provider>
|
|
@@ -7,6 +7,7 @@ exports[`Alert > snapshot: type=error 1`] = `
|
|
|
7
7
|
role="alert"
|
|
8
8
|
>
|
|
9
9
|
<svg
|
|
10
|
+
aria-label="Error"
|
|
10
11
|
class="ucl-uikit-icon css-nysdxe"
|
|
11
12
|
data-testid="ucl-uikit-icon"
|
|
12
13
|
fill="none"
|
|
@@ -61,6 +62,7 @@ exports[`Alert > snapshot: type=info, no title 1`] = `
|
|
|
61
62
|
role="alert"
|
|
62
63
|
>
|
|
63
64
|
<svg
|
|
65
|
+
aria-label="Info"
|
|
64
66
|
class="ucl-uikit-icon css-1oh4ubr"
|
|
65
67
|
data-testid="ucl-uikit-icon"
|
|
66
68
|
fill="none"
|
|
@@ -109,6 +111,7 @@ exports[`Alert > snapshot: type=success 1`] = `
|
|
|
109
111
|
role="alert"
|
|
110
112
|
>
|
|
111
113
|
<svg
|
|
114
|
+
aria-label="Success"
|
|
112
115
|
class="ucl-uikit-icon css-4xbsfp"
|
|
113
116
|
data-testid="ucl-uikit-icon"
|
|
114
117
|
fill="none"
|
|
@@ -152,6 +155,7 @@ exports[`Alert > snapshot: type=warning 1`] = `
|
|
|
152
155
|
role="alert"
|
|
153
156
|
>
|
|
154
157
|
<svg
|
|
158
|
+
aria-label="Warning"
|
|
155
159
|
class="ucl-uikit-icon css-dwkbnw"
|
|
156
160
|
data-testid="ucl-uikit-icon"
|
|
157
161
|
fill="none"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import Badge from './Badge';
|
|
3
|
+
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'Components/Work in progress/Badge',
|
|
6
|
+
component: Badge,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: 'centered',
|
|
9
|
+
},
|
|
10
|
+
args: {
|
|
11
|
+
children: 'Badge',
|
|
12
|
+
},
|
|
13
|
+
tags: ['autodocs'],
|
|
14
|
+
} satisfies Meta<typeof Badge>;
|
|
15
|
+
|
|
16
|
+
export default meta;
|
|
17
|
+
type Story = StoryObj<typeof meta>;
|
|
18
|
+
|
|
19
|
+
export const Default: Story = {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { css, cx } from '@emotion/css';
|
|
2
|
+
import { useTheme } from '../../theme';
|
|
3
|
+
|
|
4
|
+
export interface BadgeProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
testId?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const NAME = 'ucl-uikit-badge';
|
|
10
|
+
|
|
11
|
+
const Badge = ({
|
|
12
|
+
testId = NAME,
|
|
13
|
+
className,
|
|
14
|
+
children,
|
|
15
|
+
...props
|
|
16
|
+
}: BadgeProps) => {
|
|
17
|
+
const [theme] = useTheme();
|
|
18
|
+
|
|
19
|
+
const baseStyle = css`
|
|
20
|
+
display: inline-flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
height: 24px;
|
|
25
|
+
padding: ${theme.padding.p8};
|
|
26
|
+
color: ${theme.color.text.secondary};
|
|
27
|
+
background-color: #e4e4e4; // TODO: Add design token
|
|
28
|
+
font-family: ${theme.font.family.primary};
|
|
29
|
+
font-size: ${theme.font.size.f14};
|
|
30
|
+
font-weight: ${theme.font.weight.regular};
|
|
31
|
+
border-radius: ${theme.radius.r4};
|
|
32
|
+
white-space: nowrap;
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
const style = cx(baseStyle, NAME, className);
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div
|
|
39
|
+
data-testid={testId}
|
|
40
|
+
className={style}
|
|
41
|
+
{...props}
|
|
42
|
+
>
|
|
43
|
+
{children}
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default Badge;
|
|
@@ -36,7 +36,7 @@ exports[`Breadcrumbs > Snapshot: No props 1`] = `
|
|
|
36
36
|
class="css-4ys53n"
|
|
37
37
|
>
|
|
38
38
|
<a
|
|
39
|
-
class="ucl-link ucl-timetable-breadcrumb ucl-timetable-breadcrumb--inactive css-
|
|
39
|
+
class="ucl-uikit-base-link ucl-uikit-link ucl-timetable-breadcrumb ucl-timetable-breadcrumb--inactive css-c7kkpi"
|
|
40
40
|
data-testid="ucl-timetable-breadcrumb"
|
|
41
41
|
href="/showcase"
|
|
42
42
|
>
|
|
@@ -64,7 +64,7 @@ exports[`Breadcrumbs > Snapshot: No props 1`] = `
|
|
|
64
64
|
class="css-4ys53n"
|
|
65
65
|
>
|
|
66
66
|
<a
|
|
67
|
-
class="ucl-link ucl-timetable-breadcrumb ucl-timetable-breadcrumb--inactive css-
|
|
67
|
+
class="ucl-uikit-base-link ucl-uikit-link ucl-timetable-breadcrumb ucl-timetable-breadcrumb--inactive css-c7kkpi"
|
|
68
68
|
data-testid="ucl-timetable-breadcrumb"
|
|
69
69
|
href="/showcase/breadcrumbs"
|
|
70
70
|
>
|
|
@@ -110,7 +110,7 @@ exports[`Breadcrumbs > snapshot: Custom Test ID 1`] = `
|
|
|
110
110
|
class="css-4ys53n"
|
|
111
111
|
>
|
|
112
112
|
<a
|
|
113
|
-
class="ucl-link ucl-timetable-breadcrumb ucl-timetable-breadcrumb--inactive css-
|
|
113
|
+
class="ucl-uikit-base-link ucl-uikit-link ucl-timetable-breadcrumb ucl-timetable-breadcrumb--inactive css-c7kkpi"
|
|
114
114
|
data-testid="custom-testid-2"
|
|
115
115
|
href="/showcase"
|
|
116
116
|
>
|
|
@@ -138,7 +138,7 @@ exports[`Breadcrumbs > snapshot: Custom Test ID 1`] = `
|
|
|
138
138
|
class="css-4ys53n"
|
|
139
139
|
>
|
|
140
140
|
<a
|
|
141
|
-
class="ucl-link ucl-timetable-breadcrumb ucl-timetable-breadcrumb--inactive css-
|
|
141
|
+
class="ucl-uikit-base-link ucl-uikit-link ucl-timetable-breadcrumb ucl-timetable-breadcrumb--inactive css-c7kkpi"
|
|
142
142
|
data-testid="custom-testid-3"
|
|
143
143
|
href="/showcase/breadcrumbs"
|
|
144
144
|
>
|
|
@@ -11,8 +11,10 @@ import useTheme from '../../theme/useTheme';
|
|
|
11
11
|
import buttonPrimaryStyle from './buttonPrimaryStyle';
|
|
12
12
|
import buttonSecondaryStyle from './buttonSecondaryStyle';
|
|
13
13
|
import buttonTertiaryStyle from './buttonTertiaryStyle';
|
|
14
|
-
import
|
|
15
|
-
import
|
|
14
|
+
import Spinner from '../Spinner/Spinner';
|
|
15
|
+
import Overlay from '../Overlay/Overlay';
|
|
16
|
+
import Tooltip from '../Tooltip/Tooltip';
|
|
17
|
+
import marginsStyle, { MarginProps } from '../common/marginsStyle';
|
|
16
18
|
|
|
17
19
|
export const NAME = 'ucl-uikit-button';
|
|
18
20
|
|
|
@@ -35,6 +37,7 @@ export type ButtonProps<C extends ElementType = 'button'> = {
|
|
|
35
37
|
as?: C;
|
|
36
38
|
ref?: PolymorphicRef<C>;
|
|
37
39
|
} & ButtonBaseProps &
|
|
40
|
+
MarginProps &
|
|
38
41
|
Omit<ComponentPropsWithRef<C>, keyof ButtonBaseProps | 'as'>;
|
|
39
42
|
|
|
40
43
|
const Button = <C extends ElementType = 'button'>({
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import Calendar from './Calendar';
|
|
3
|
+
import { useArgs } from '@storybook/preview-api';
|
|
4
|
+
import type { AcademicWeek } from './Calendar.types';
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Components/Work in progress/Calendar',
|
|
8
|
+
component: Calendar,
|
|
9
|
+
parameters: { layout: 'padded' },
|
|
10
|
+
argTypes: {
|
|
11
|
+
pickedDate: { control: { type: 'date' } },
|
|
12
|
+
minDate: { control: { type: 'date' } },
|
|
13
|
+
maxDate: { control: { type: 'date' } },
|
|
14
|
+
showAcademicWeeks: { control: { type: 'boolean' } },
|
|
15
|
+
testId: { control: { type: 'text' } },
|
|
16
|
+
},
|
|
17
|
+
tags: ['autodocs'],
|
|
18
|
+
} satisfies Meta<typeof Calendar>;
|
|
19
|
+
|
|
20
|
+
export default meta;
|
|
21
|
+
type Story = StoryObj<typeof meta>;
|
|
22
|
+
|
|
23
|
+
// Convert UNIX timestamp from Storybook controls to `Date` object
|
|
24
|
+
// https://storybook.js.org/docs/essentials/controls#annotation
|
|
25
|
+
const parseDateFromUNIXTimestamp = (timestamp: number) => {
|
|
26
|
+
const date = new Date(timestamp);
|
|
27
|
+
return isNaN(date.getTime()) ? null : date;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const dateToISOString = (date: Date) => {
|
|
31
|
+
return date.toISOString().split('T')[0];
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const Default: Story = {
|
|
35
|
+
render: () => {
|
|
36
|
+
const [args, updateArgs] = useArgs();
|
|
37
|
+
args.pickedDate = args.pickedDate
|
|
38
|
+
? parseDateFromUNIXTimestamp(args.pickedDate)
|
|
39
|
+
: null;
|
|
40
|
+
const onDatePick = (date: Date | null) => updateArgs({ pickedDate: date });
|
|
41
|
+
return (
|
|
42
|
+
<Calendar
|
|
43
|
+
{...args}
|
|
44
|
+
onDatePick={onDatePick}
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// Story repeated in Datepicker.stories.tsx
|
|
51
|
+
export const WithEvents: Story = {
|
|
52
|
+
name: 'With events',
|
|
53
|
+
args: {
|
|
54
|
+
// IIFE gives us event dots for the current month
|
|
55
|
+
events: (() => {
|
|
56
|
+
const currentDate = new Date();
|
|
57
|
+
const currentYear = currentDate.getFullYear();
|
|
58
|
+
const currentMonth = currentDate.getMonth();
|
|
59
|
+
return [
|
|
60
|
+
// Grey event dots
|
|
61
|
+
{ date: dateToISOString(new Date(currentYear, currentMonth, -2)) },
|
|
62
|
+
{ date: dateToISOString(new Date(currentYear, currentMonth, -1)) },
|
|
63
|
+
{ date: dateToISOString(new Date(currentYear, currentMonth, -1)) },
|
|
64
|
+
{ date: dateToISOString(new Date(currentYear, currentMonth, 0)) },
|
|
65
|
+
{ date: dateToISOString(new Date(currentYear, currentMonth, 0)) },
|
|
66
|
+
{ date: dateToISOString(new Date(currentYear, currentMonth, 0)) },
|
|
67
|
+
// Blue event dots
|
|
68
|
+
{ date: dateToISOString(new Date(currentYear, currentMonth, 1)) },
|
|
69
|
+
{ date: dateToISOString(new Date(currentYear, currentMonth, 2)) },
|
|
70
|
+
{ date: dateToISOString(new Date(currentYear, currentMonth, 2)) },
|
|
71
|
+
{ date: dateToISOString(new Date(currentYear, currentMonth, 3)) },
|
|
72
|
+
{ date: dateToISOString(new Date(currentYear, currentMonth, 3)) },
|
|
73
|
+
{ date: dateToISOString(new Date(currentYear, currentMonth, 3)) },
|
|
74
|
+
];
|
|
75
|
+
})(),
|
|
76
|
+
},
|
|
77
|
+
render: () => {
|
|
78
|
+
const [args, updateArgs] = useArgs();
|
|
79
|
+
args.pickedDate = args.pickedDate
|
|
80
|
+
? parseDateFromUNIXTimestamp(args.pickedDate)
|
|
81
|
+
: null;
|
|
82
|
+
const onDatePick = (date: Date | null) => updateArgs({ pickedDate: date });
|
|
83
|
+
return (
|
|
84
|
+
<Calendar
|
|
85
|
+
{...args}
|
|
86
|
+
onDatePick={onDatePick}
|
|
87
|
+
/>
|
|
88
|
+
);
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const academicWeeks: AcademicWeek[] = [
|
|
93
|
+
{ start: '2025-08-25', number: 1 },
|
|
94
|
+
{ start: '2025-09-01', number: 2 },
|
|
95
|
+
{ start: '2025-09-08', number: 3 },
|
|
96
|
+
{ start: '2025-09-15', number: 4 },
|
|
97
|
+
{ start: '2025-09-22', number: 5 },
|
|
98
|
+
{ start: '2025-09-29', number: 6 },
|
|
99
|
+
{ start: '2025-10-06', number: 7 },
|
|
100
|
+
{ start: '2025-10-13', number: 8 },
|
|
101
|
+
{ start: '2025-10-20', number: 9 },
|
|
102
|
+
{ start: '2025-10-27', number: 10 },
|
|
103
|
+
{ start: '2025-11-03', number: 11 },
|
|
104
|
+
{ start: '2025-11-10', number: 12 },
|
|
105
|
+
{ start: '2025-11-17', number: 13 },
|
|
106
|
+
{ start: '2025-11-24', number: 14 },
|
|
107
|
+
{ start: '2025-12-01', number: 15 },
|
|
108
|
+
{ start: '2025-12-08', number: 16 },
|
|
109
|
+
{ start: '2025-12-15', number: 17 },
|
|
110
|
+
{ start: '2025-12-22', number: 18 },
|
|
111
|
+
{ start: '2025-12-29', number: 19 },
|
|
112
|
+
{ start: '2026-01-05', number: 20 },
|
|
113
|
+
{ start: '2026-01-12', number: 21 },
|
|
114
|
+
{ start: '2026-01-19', number: 22 },
|
|
115
|
+
{ start: '2026-01-26', number: 23 },
|
|
116
|
+
{ start: '2026-02-02', number: 24 },
|
|
117
|
+
{ start: '2026-02-09', number: 25 },
|
|
118
|
+
{ start: '2026-02-16', number: 26 },
|
|
119
|
+
{ start: '2026-02-23', number: 27 },
|
|
120
|
+
{ start: '2026-03-02', number: 28 },
|
|
121
|
+
{ start: '2026-03-09', number: 29 },
|
|
122
|
+
{ start: '2026-03-16', number: 30 },
|
|
123
|
+
{ start: '2026-03-23', number: 31 },
|
|
124
|
+
{ start: '2026-03-30', number: 32 },
|
|
125
|
+
{ start: '2026-04-06', number: 33 },
|
|
126
|
+
{ start: '2026-04-13', number: 34 },
|
|
127
|
+
{ start: '2026-04-20', number: 35 },
|
|
128
|
+
{ start: '2026-04-27', number: 36 },
|
|
129
|
+
{ start: '2026-05-04', number: 37 },
|
|
130
|
+
{ start: '2026-05-11', number: 38 },
|
|
131
|
+
{ start: '2026-05-18', number: 39 },
|
|
132
|
+
{ start: '2026-05-25', number: 40 },
|
|
133
|
+
{ start: '2026-06-01', number: 41 },
|
|
134
|
+
{ start: '2026-06-08', number: 42 },
|
|
135
|
+
{ start: '2026-06-15', number: 43 },
|
|
136
|
+
{ start: '2026-06-22', number: 44 },
|
|
137
|
+
{ start: '2026-06-29', number: 45 },
|
|
138
|
+
{ start: '2026-07-06', number: 46 },
|
|
139
|
+
{ start: '2026-07-13', number: 47 },
|
|
140
|
+
{ start: '2026-07-20', number: 48 },
|
|
141
|
+
{ start: '2026-07-27', number: 49 },
|
|
142
|
+
{ start: '2026-08-03', number: 50 },
|
|
143
|
+
{ start: '2026-08-10', number: 51 },
|
|
144
|
+
{ start: '2026-08-17', number: 52 },
|
|
145
|
+
{ start: '2026-08-24', number: 53 },
|
|
146
|
+
];
|
|
147
|
+
|
|
148
|
+
// Story repeated in Datepicker.stories.tsx
|
|
149
|
+
export const WithAcademicWeeks: Story = {
|
|
150
|
+
name: 'With academic weeks',
|
|
151
|
+
args: {
|
|
152
|
+
showAcademicWeeks: true,
|
|
153
|
+
academicWeeks: academicWeeks,
|
|
154
|
+
pickedDate: new Date(academicWeeks[0].start), // So the week numbers appear on story mount
|
|
155
|
+
},
|
|
156
|
+
render: () => {
|
|
157
|
+
const [args, updateArgs] = useArgs();
|
|
158
|
+
args.pickedDate = args.pickedDate
|
|
159
|
+
? parseDateFromUNIXTimestamp(args.pickedDate)
|
|
160
|
+
: null;
|
|
161
|
+
const onDatePick = (date: Date | null) => updateArgs({ pickedDate: date });
|
|
162
|
+
return (
|
|
163
|
+
<Calendar
|
|
164
|
+
{...args}
|
|
165
|
+
onDatePick={onDatePick}
|
|
166
|
+
/>
|
|
167
|
+
);
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
// Story repeated in Datepicker.stories.tsx
|
|
172
|
+
export const MinMaxDates: Story = {
|
|
173
|
+
name: 'With min and max dates',
|
|
174
|
+
args: {
|
|
175
|
+
// Initialise min date as 5 days into the current month
|
|
176
|
+
minDate: (() => {
|
|
177
|
+
const now = new Date();
|
|
178
|
+
return new Date(now.getFullYear(), now.getMonth(), 5)
|
|
179
|
+
.toISOString()
|
|
180
|
+
.split('T')[0];
|
|
181
|
+
})(),
|
|
182
|
+
// Initialise max date as 5 days before the last day of the current month
|
|
183
|
+
maxDate: (() => {
|
|
184
|
+
const now = new Date();
|
|
185
|
+
// Get last day of current month
|
|
186
|
+
const lastDay = new Date(
|
|
187
|
+
now.getFullYear(),
|
|
188
|
+
now.getMonth() + 1,
|
|
189
|
+
0
|
|
190
|
+
).getDate();
|
|
191
|
+
return new Date(now.getFullYear(), now.getMonth(), lastDay - 5)
|
|
192
|
+
.toISOString()
|
|
193
|
+
.split('T')[0];
|
|
194
|
+
})(),
|
|
195
|
+
},
|
|
196
|
+
render: () => {
|
|
197
|
+
const [args, updateArgs] = useArgs();
|
|
198
|
+
args.pickedDate = args.pickedDate
|
|
199
|
+
? parseDateFromUNIXTimestamp(args.pickedDate)
|
|
200
|
+
: null;
|
|
201
|
+
const onDatePick = (date: Date | null) => updateArgs({ pickedDate: date });
|
|
202
|
+
return (
|
|
203
|
+
<Calendar
|
|
204
|
+
{...args}
|
|
205
|
+
onDatePick={onDatePick}
|
|
206
|
+
/>
|
|
207
|
+
);
|
|
208
|
+
},
|
|
209
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { useState, useEffect, useRef } from 'react';
|
|
2
|
+
import { css, cx } from '@emotion/css';
|
|
3
|
+
import { Controls, AcademicWeeks, Grid } from './subcomponents';
|
|
4
|
+
import { normaliseMonth, parseDateFromString } from './utils';
|
|
5
|
+
import { useTheme } from '../../theme';
|
|
6
|
+
import type { CalendarProps } from './Calendar.types';
|
|
7
|
+
|
|
8
|
+
const NAME = 'ucl-uikit-calendar';
|
|
9
|
+
|
|
10
|
+
const Calendar = ({
|
|
11
|
+
pickedDate = null,
|
|
12
|
+
onDatePick,
|
|
13
|
+
minDate = null,
|
|
14
|
+
maxDate = null,
|
|
15
|
+
events = [],
|
|
16
|
+
showAcademicWeeks = false,
|
|
17
|
+
academicWeeks = [],
|
|
18
|
+
testId = NAME,
|
|
19
|
+
className,
|
|
20
|
+
}: CalendarProps) => {
|
|
21
|
+
const [theme] = useTheme();
|
|
22
|
+
|
|
23
|
+
if (pickedDate && isNaN(pickedDate.getTime())) {
|
|
24
|
+
console.warn('Calendar: pickedDate is invalid, defaulting to null');
|
|
25
|
+
pickedDate = null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Used to track prop value changes
|
|
29
|
+
const pickedDateRef = useRef<Date | null>(pickedDate ?? null);
|
|
30
|
+
|
|
31
|
+
// Determines the month currently displayed in the calendar
|
|
32
|
+
const [displayMonth, setDisplayMonth] = useState<Date>(
|
|
33
|
+
// Display month initialises as either the picked date's month or the current month
|
|
34
|
+
normaliseMonth(pickedDate ?? new Date()) as Date
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
// Parse min and max dates from strings to Date objects
|
|
38
|
+
const minDateParsed = minDate ? parseDateFromString(minDate) : null;
|
|
39
|
+
const maxDateParsed = maxDate ? parseDateFromString(maxDate) : null;
|
|
40
|
+
|
|
41
|
+
// Snap displayed month to the picked date's month if it changes
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (
|
|
44
|
+
// If the picked date is valid
|
|
45
|
+
pickedDate &&
|
|
46
|
+
!isNaN(pickedDate.getTime()) &&
|
|
47
|
+
// If the picked date has changed
|
|
48
|
+
pickedDateRef.current?.getTime() !== pickedDate.getTime()
|
|
49
|
+
) {
|
|
50
|
+
// If the picked date is not in the currently displayed month
|
|
51
|
+
if (
|
|
52
|
+
pickedDate.getMonth() !== displayMonth.getMonth() ||
|
|
53
|
+
pickedDate.getFullYear() !== displayMonth.getFullYear()
|
|
54
|
+
) {
|
|
55
|
+
// Update the display month to the picked date's month
|
|
56
|
+
setDisplayMonth(normaliseMonth(pickedDate) as Date);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// Update the ref to the new picked date
|
|
60
|
+
pickedDateRef.current = pickedDate;
|
|
61
|
+
}, [pickedDate, displayMonth]);
|
|
62
|
+
|
|
63
|
+
const handleMonthChange = (change: number) => {
|
|
64
|
+
const newDate = new Date(displayMonth);
|
|
65
|
+
newDate.setMonth(newDate.getMonth() + change);
|
|
66
|
+
setDisplayMonth(normaliseMonth(newDate) as Date);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const width = showAcademicWeeks ? '370' : '312';
|
|
70
|
+
|
|
71
|
+
const baseStyle = css`
|
|
72
|
+
display: flex;
|
|
73
|
+
flex-direction: column;
|
|
74
|
+
align-items: center;
|
|
75
|
+
gap: 16px;
|
|
76
|
+
width: ${width}px;
|
|
77
|
+
box-sizing: border-box;
|
|
78
|
+
border: 1px solid ${theme.color.neutral.grey20};
|
|
79
|
+
padding: 16px;
|
|
80
|
+
background-color: ${theme.color.neutral.white};
|
|
81
|
+
`;
|
|
82
|
+
|
|
83
|
+
const innerContainerStyle = css`
|
|
84
|
+
display: flex;
|
|
85
|
+
flex-direction: row;
|
|
86
|
+
gap: 8px;
|
|
87
|
+
width: 100%;
|
|
88
|
+
`;
|
|
89
|
+
|
|
90
|
+
const style = cx(testId, baseStyle, className);
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<div
|
|
94
|
+
className={style}
|
|
95
|
+
data-testid={testId}
|
|
96
|
+
>
|
|
97
|
+
<Controls
|
|
98
|
+
month={displayMonth}
|
|
99
|
+
changeMonth={handleMonthChange}
|
|
100
|
+
/>
|
|
101
|
+
<div className={innerContainerStyle}>
|
|
102
|
+
{showAcademicWeeks && (
|
|
103
|
+
<AcademicWeeks
|
|
104
|
+
date={displayMonth}
|
|
105
|
+
weeks={academicWeeks}
|
|
106
|
+
/>
|
|
107
|
+
)}
|
|
108
|
+
<Grid
|
|
109
|
+
month={displayMonth}
|
|
110
|
+
pickedDate={pickedDate}
|
|
111
|
+
onDatePick={onDatePick}
|
|
112
|
+
minDate={minDateParsed}
|
|
113
|
+
maxDate={maxDateParsed}
|
|
114
|
+
events={events}
|
|
115
|
+
/>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export default Calendar;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Used to display EventDots inside `<Day>` component
|
|
2
|
+
export type CalendarEvent = {
|
|
3
|
+
date: string; // Date string in YYYY-MM-DD format
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export type AcademicWeek = {
|
|
7
|
+
start: string; // ISO date string: YYYY-MM-DD format
|
|
8
|
+
number: number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export interface CalendarProps {
|
|
12
|
+
pickedDate?: Date | null;
|
|
13
|
+
onDatePick?: (date: Date | null, event?: React.SyntheticEvent) => void;
|
|
14
|
+
minDate?: string | null; // ISO date string: YYYY-MM-DD format
|
|
15
|
+
maxDate?: string | null; // ISO date string: YYYY-MM-DD format
|
|
16
|
+
events?: CalendarEvent[];
|
|
17
|
+
showAcademicWeeks?: boolean;
|
|
18
|
+
academicWeeks?: AcademicWeek[];
|
|
19
|
+
testId?: string;
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|