uikit-react-public 0.11.16 → 0.11.24
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/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/AcademicWeek.d.ts +5 -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/Calendar/subcomponents/Day.d.ts +12 -0
- package/dist/components/{Datepicker/subcomponents/Day → Calendar/subcomponents}/Day.stories.d.ts +9 -1
- package/dist/components/Calendar/subcomponents/EventDot.d.ts +6 -0
- package/dist/components/Calendar/subcomponents/Grid.d.ts +11 -0
- package/dist/components/Calendar/subcomponents/index.d.ts +7 -0
- package/dist/components/Calendar/utils/getAcademicWeekNumbers/getAcademicWeekNumbers.d.ts +24 -0
- 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/normaliseMonth/normaliseMonth.test.d.ts +1 -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/Datepicker/Datepicker.d.ts +3 -12
- package/dist/components/Datepicker/Datepicker.stories.d.ts +16 -3
- package/dist/components/Datepicker/Datepicker.types.d.ts +23 -0
- package/dist/components/Datepicker/index.d.ts +1 -1
- 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 -2
- 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/Footer/Footer.d.ts +1 -1
- package/dist/components/Header/Header.d.ts +5 -4
- package/dist/components/Header/index.d.ts +1 -1
- package/dist/components/Menu/Menu.d.ts +2 -1
- package/dist/components/Menu/MenuContent.d.ts +1 -0
- package/dist/components/Select/Select.stories.d.ts +1 -1
- package/dist/components/Select/Select.types.d.ts +10 -50
- package/dist/components/Select/index.d.ts +1 -1
- package/dist/components/Select/subcomponents/CustomSelect.d.ts +2 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/index.js +3332 -3063
- 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/Calendar/subcomponents/AcademicWeek.tsx +36 -0
- package/lib/components/Calendar/subcomponents/AcademicWeeks.tsx +46 -0
- 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 +30 -7
- package/lib/components/Calendar/subcomponents/Day.tsx +130 -0
- package/lib/components/Calendar/subcomponents/EventDot.tsx +40 -0
- package/lib/components/Calendar/subcomponents/Grid.tsx +117 -0
- package/lib/components/Calendar/subcomponents/index.ts +7 -0
- package/lib/components/Calendar/utils/getAcademicWeekNumbers/getAcademicWeekNumbers.test.ts +104 -0
- package/lib/components/Calendar/utils/getAcademicWeekNumbers/getAcademicWeekNumbers.ts +85 -0
- 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/Datepicker/Datepicker.stories.tsx +220 -23
- package/lib/components/Datepicker/Datepicker.tsx +34 -137
- package/lib/components/Datepicker/Datepicker.types.ts +38 -0
- package/lib/components/Datepicker/__tests__/Datepicker.test.tsx +53 -112
- package/lib/components/Datepicker/__tests__/__snapshots__/Datepicker.test.tsx.snap +92 -638
- package/lib/components/Datepicker/index.ts +1 -1
- 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 -2
- package/lib/components/Datepicker/utils/parseInputValue/parseInputValue.test.ts +110 -0
- package/lib/components/Datepicker/utils/parseInputValue/parseInputValue.ts +57 -0
- package/lib/components/Footer/Footer.tsx +3 -3
- package/lib/components/Footer/__tests__/__snapshots__/Footer.test.tsx.snap +6 -6
- package/lib/components/Header/Header.tsx +32 -33
- package/lib/components/Header/HeaderMenu.tsx +9 -2
- package/lib/components/Header/__tests__/__snapshots__/Header.test.tsx.snap +40 -48
- package/lib/components/Header/index.ts +5 -1
- package/lib/components/Menu/Menu.tsx +3 -0
- package/lib/components/Menu/MenuContent.tsx +4 -1
- package/lib/components/Select/Select.stories.tsx +38 -39
- package/lib/components/Select/Select.tsx +4 -18
- package/lib/components/Select/Select.types.ts +30 -69
- package/lib/components/Select/__tests__/Select.test.tsx +6 -6
- package/lib/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +1 -1
- package/lib/components/Select/index.ts +1 -1
- package/lib/components/Select/subcomponents/CustomSelect.tsx +22 -12
- package/lib/components/Select/subcomponents/NativeSelect.tsx +7 -3
- package/lib/components/Select/subcomponents/Panel.tsx +4 -4
- package/lib/components/Select/subcomponents/VisibleField.tsx +1 -1
- package/lib/components/index.ts +3 -0
- package/package.json +4 -4
- package/LICENSE +0 -9
- package/dist/components/Datepicker/subcomponents/CalendarGrid/CalendarGrid.d.ts +0 -6
- package/dist/components/Datepicker/subcomponents/CalendarGrid/index.d.ts +0 -1
- package/dist/components/Datepicker/subcomponents/CalendarMenu/CalendarMenu.d.ts +0 -8
- 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/Day.d.ts +0 -10
- 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 -59
- package/lib/components/Datepicker/subcomponents/CalendarGrid/index.ts +0 -1
- package/lib/components/Datepicker/subcomponents/CalendarMenu/CalendarMenu.tsx +0 -64
- 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/Day.tsx +0 -94
- 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/dist/components/{Datepicker/subcomponents/DateField/__tests__/DateField.test.d.ts → Calendar/__tests__/Calendar.test.d.ts} +0 -0
- /package/dist/components/{Datepicker/utils/getDatesForCalendarGrid/getDatesForCalendarGrid.test.d.ts → 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/utils/parseDateForDateField/parseDateForDateField.test.d.ts → Calendar/utils/getDatesForCalendarGrid/getDatesForCalendarGrid.test.d.ts} +0 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { StoryObj } from '@storybook/react';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: ({ pickedDate, onDatePick, minDate, maxDate, events, showAcademicWeeks, academicWeeks, testId, className, }: import('./Calendar.types').CalendarProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
parameters: {
|
|
6
|
+
layout: string;
|
|
7
|
+
};
|
|
8
|
+
argTypes: {
|
|
9
|
+
pickedDate: {
|
|
10
|
+
control: {
|
|
11
|
+
type: "date";
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
minDate: {
|
|
15
|
+
control: {
|
|
16
|
+
type: "date";
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
maxDate: {
|
|
20
|
+
control: {
|
|
21
|
+
type: "date";
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
showAcademicWeeks: {
|
|
25
|
+
control: {
|
|
26
|
+
type: "boolean";
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
testId: {
|
|
30
|
+
control: {
|
|
31
|
+
type: "text";
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
tags: string[];
|
|
36
|
+
};
|
|
37
|
+
export default meta;
|
|
38
|
+
type Story = StoryObj<typeof meta>;
|
|
39
|
+
export declare const Default: Story;
|
|
40
|
+
export declare const WithEvents: Story;
|
|
41
|
+
export declare const WithAcademicWeeks: Story;
|
|
42
|
+
export declare const MinMaxDates: Story;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type CalendarEvent = {
|
|
2
|
+
date: string;
|
|
3
|
+
};
|
|
4
|
+
export type AcademicWeek = {
|
|
5
|
+
start: string;
|
|
6
|
+
number: number;
|
|
7
|
+
};
|
|
8
|
+
export interface CalendarProps {
|
|
9
|
+
pickedDate?: Date | null;
|
|
10
|
+
onDatePick?: (date: Date | null, event?: React.SyntheticEvent) => void;
|
|
11
|
+
minDate?: string | null;
|
|
12
|
+
maxDate?: string | null;
|
|
13
|
+
events?: CalendarEvent[];
|
|
14
|
+
showAcademicWeeks?: boolean;
|
|
15
|
+
academicWeeks?: AcademicWeek[];
|
|
16
|
+
testId?: string;
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AcademicWeek as AcademicWeekType } from '../Calendar.types';
|
|
2
|
+
interface AcademicWeeksProps {
|
|
3
|
+
date: Date;
|
|
4
|
+
weeks: AcademicWeekType[];
|
|
5
|
+
}
|
|
6
|
+
declare const AcademicWeeks: ({ date, weeks }: AcademicWeeksProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export default AcademicWeeks;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CalendarEvent } from '../Calendar.types';
|
|
2
|
+
export interface DayProps {
|
|
3
|
+
date: Date;
|
|
4
|
+
onPick?: (date: Date, event: React.SyntheticEvent) => void;
|
|
5
|
+
isSelected?: boolean;
|
|
6
|
+
isToday?: boolean;
|
|
7
|
+
isInCurrentMonth?: boolean;
|
|
8
|
+
isDisabled?: boolean;
|
|
9
|
+
events?: CalendarEvent[];
|
|
10
|
+
}
|
|
11
|
+
declare const Day: ({ date, onPick, isSelected, isToday, isInCurrentMonth, isDisabled, events, }: DayProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export default Day;
|
package/dist/components/{Datepicker/subcomponents/Day → Calendar/subcomponents}/Day.stories.d.ts
RENAMED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { StoryObj } from '@storybook/react';
|
|
2
2
|
declare const meta: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: ({ date, isSelected, isToday, isInCurrentMonth, isDisabled,
|
|
4
|
+
component: ({ date, onPick, isSelected, isToday, isInCurrentMonth, isDisabled, events, }: import('./Day').DayProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
argTypes: {
|
|
6
|
+
events: {
|
|
7
|
+
table: {
|
|
8
|
+
disable: true;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
};
|
|
5
12
|
};
|
|
6
13
|
export default meta;
|
|
7
14
|
type Story = StoryObj<typeof meta>;
|
|
@@ -10,4 +17,5 @@ export declare const Selected: Story;
|
|
|
10
17
|
export declare const Today: Story;
|
|
11
18
|
export declare const Disabled: Story;
|
|
12
19
|
export declare const NotInCurrentMonth: Story;
|
|
20
|
+
export declare const WithEventDots: Story;
|
|
13
21
|
export declare const AlertOnPick: Story;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CalendarEvent } from '../Calendar.types';
|
|
2
|
+
interface GridProps {
|
|
3
|
+
month: Date;
|
|
4
|
+
pickedDate: Date | null;
|
|
5
|
+
onDatePick?: (date: Date, event: React.SyntheticEvent) => void;
|
|
6
|
+
minDate: Date | null;
|
|
7
|
+
maxDate: Date | null;
|
|
8
|
+
events: CalendarEvent[];
|
|
9
|
+
}
|
|
10
|
+
declare const Grid: ({ month, pickedDate, onDatePick, minDate, maxDate, events, }: GridProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default Grid;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as Controls } from './Controls';
|
|
2
|
+
export { default as AcademicWeeks } from './AcademicWeeks';
|
|
3
|
+
export { default as AcademicWeek } from './AcademicWeek';
|
|
4
|
+
export { default as Grid } from './Grid';
|
|
5
|
+
export { default as ColumnHeading } from './ColumnHeading';
|
|
6
|
+
export { default as Day } from './Day';
|
|
7
|
+
export { default as EventDot } from './EventDot';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AcademicWeek } from '../../';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the Monday for the week of the given date.
|
|
4
|
+
* For example:
|
|
5
|
+
* - If the input date is a Wednesday, it returns the Monday of that week.
|
|
6
|
+
* - If the input date is already a Monday, it returns that date.
|
|
7
|
+
* @param {Date} d - The input date.
|
|
8
|
+
* @returns {Date} The Monday of the week of the input date.
|
|
9
|
+
*/
|
|
10
|
+
export declare const getMonday: (d: Date) => Date;
|
|
11
|
+
/**
|
|
12
|
+
* Calculates the academic week numbers for each week displayed in a calendar month.
|
|
13
|
+
* Used by `<AcademicWeeks />` component in the Datepicker.
|
|
14
|
+
* It determines the Mondays of each week shown in the calendar for the `targetDate`'s month.
|
|
15
|
+
* Then, it maps these Mondays to the corresponding academic week number from the `academicWeeks` array.
|
|
16
|
+
* If an academic week is not found for a given Monday, `undefined` is used, in place in the returned array.
|
|
17
|
+
*
|
|
18
|
+
* @param {AcademicWeek[]} academicWeeks - An array of academic week objects, each with a `start` date and `number`.
|
|
19
|
+
* @param {Date} targetDate - The date used to generate the calendar display.
|
|
20
|
+
* @returns {(number | undefined)[]} An array of academic week numbers or `undefined` for each week in the calendar display.
|
|
21
|
+
* Returns an empty array if `academicWeeks` is empty or `targetDate` is invalid, with console warnings, in the interest of safe usage.
|
|
22
|
+
*/
|
|
23
|
+
declare const getAcademicWeekNumbers: (academicWeeks: AcademicWeek[], targetDate: Date) => (number | undefined)[];
|
|
24
|
+
export default getAcademicWeekNumbers;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as normaliseMonth } from './normaliseMonth/normaliseMonth';
|
|
2
|
+
export { default as parseDateFromString } from './parseDateFromString/parseDateFromString';
|
|
3
|
+
export { default as getAcademicWeekNumbers } from './getAcademicWeekNumbers/getAcademicWeekNumbers';
|
|
4
|
+
export { default as getDatesForCalendarGrid } from './getDatesForCalendarGrid/getDatesForCalendarGrid';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalises a given date to the first day of its month (with the time set to midnight).
|
|
3
|
+
* If the input date is undefined, it returns null.
|
|
4
|
+
* Used in <Calendar> to track the displayed month.
|
|
5
|
+
* @param date The date to normalise.
|
|
6
|
+
* @returns A new Date object set to the first day of the month with the time at midnight, or null if the input was null or undefined.
|
|
7
|
+
*/
|
|
8
|
+
declare const normaliseMonth: (date: Date | null | undefined) => Date | null;
|
|
9
|
+
export default normaliseMonth;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses a date string into a Date object.
|
|
3
|
+
* Returns null if the input is invalid.
|
|
4
|
+
*
|
|
5
|
+
* @param dateString - The date string to parse (can be in ISO format or UNIX timestamp).
|
|
6
|
+
* @returns A Date object, or null if invalid.
|
|
7
|
+
*/
|
|
8
|
+
declare const parseDateFromString: (dateString: string) => Date | null;
|
|
9
|
+
export default parseDateFromString;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
date: Date | null | undefined;
|
|
5
|
-
minDate?: Date | null | undefined;
|
|
6
|
-
maxDate?: Date | null | undefined;
|
|
7
|
-
onDateChange: (date: Date | null | undefined) => void;
|
|
8
|
-
native?: boolean;
|
|
9
|
-
testId?: string;
|
|
10
|
-
}
|
|
11
|
-
declare const _default: import('react').MemoExoticComponent<({ date, minDate, maxDate, onDateChange, native, testId, className, ...props }: DatepickerProps) => import("react/jsx-runtime").JSX.Element>;
|
|
12
|
-
export default _default;
|
|
1
|
+
import { DatepickerProps } from './Datepicker.types';
|
|
2
|
+
declare const Datepicker: ({ value, onValueChange, minDate, maxDate, disabled, className, native, nativeRef, nativeHTMLAttributes, ...props }: DatepickerProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export default Datepicker;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { StoryObj } from '@storybook/react';
|
|
2
2
|
declare const meta: {
|
|
3
3
|
title: string;
|
|
4
|
-
component:
|
|
4
|
+
component: ({ value, onValueChange, minDate, maxDate, disabled, className, native, nativeRef, nativeHTMLAttributes, ...props }: import('./Datepicker.types').DatepickerProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
parameters: {
|
|
6
6
|
layout: string;
|
|
7
7
|
};
|
|
8
8
|
argTypes: {
|
|
9
|
-
|
|
9
|
+
value: {
|
|
10
10
|
control: {
|
|
11
11
|
type: "date";
|
|
12
12
|
};
|
|
@@ -21,15 +21,28 @@ declare const meta: {
|
|
|
21
21
|
type: "date";
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
|
+
disabled: {
|
|
25
|
+
control: {
|
|
26
|
+
type: "boolean";
|
|
27
|
+
};
|
|
28
|
+
};
|
|
24
29
|
native: {
|
|
25
30
|
control: {
|
|
26
31
|
type: "boolean";
|
|
27
32
|
};
|
|
28
33
|
};
|
|
34
|
+
showAcademicWeeks: {
|
|
35
|
+
control: {
|
|
36
|
+
type: "boolean";
|
|
37
|
+
};
|
|
38
|
+
};
|
|
29
39
|
};
|
|
30
40
|
tags: string[];
|
|
31
41
|
};
|
|
32
42
|
export default meta;
|
|
33
43
|
type Story = StoryObj<typeof meta>;
|
|
34
44
|
export declare const Default: Story;
|
|
35
|
-
export declare const
|
|
45
|
+
export declare const WithEvents: Story;
|
|
46
|
+
export declare const WithAcademicWeeks: Story;
|
|
47
|
+
export declare const MinMaxDates: Story;
|
|
48
|
+
export declare const Native: Story;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { InputHTMLAttributes, HTMLAttributes, RefObject } from 'react';
|
|
2
|
+
import { CalendarEvent, AcademicWeek } from '../Calendar';
|
|
3
|
+
export type DatepickerValue = Date | null;
|
|
4
|
+
interface BaseDatepickerProps {
|
|
5
|
+
value?: DatepickerValue;
|
|
6
|
+
onValueChange?: (value: DatepickerValue, event?: React.SyntheticEvent) => void;
|
|
7
|
+
minDate?: string | null;
|
|
8
|
+
maxDate?: string | null;
|
|
9
|
+
events?: CalendarEvent[];
|
|
10
|
+
showAcademicWeeks?: boolean;
|
|
11
|
+
academicWeeks?: AcademicWeek[];
|
|
12
|
+
testId?: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
ref?: RefObject<HTMLDivElement>;
|
|
15
|
+
inputRef?: RefObject<HTMLInputElement>;
|
|
16
|
+
}
|
|
17
|
+
type NativeDatepickerAttributeProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'value' | 'onChange' | 'min' | 'max' | 'className' | 'disabled'>;
|
|
18
|
+
export interface DatepickerProps extends BaseDatepickerProps, HTMLAttributes<HTMLDivElement> {
|
|
19
|
+
native?: boolean;
|
|
20
|
+
nativeHTMLAttributes?: NativeDatepickerAttributeProps;
|
|
21
|
+
nativeRef?: RefObject<HTMLInputElement>;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default } from './Datepicker';
|
|
2
|
-
export type { DatepickerProps } from './Datepicker';
|
|
2
|
+
export type { DatepickerProps } from './Datepicker.types';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DatepickerValue } from '../Datepicker.types';
|
|
2
|
+
import { CalendarEvent, AcademicWeek } from '../../Calendar';
|
|
3
|
+
interface CustomDatepickerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
value?: DatepickerValue;
|
|
5
|
+
onValueChange?: (value: DatepickerValue, event?: React.SyntheticEvent) => void;
|
|
6
|
+
minDate?: string | null;
|
|
7
|
+
maxDate?: string | null;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
events?: CalendarEvent[];
|
|
10
|
+
showAcademicWeeks?: boolean;
|
|
11
|
+
academicWeeks?: AcademicWeek[];
|
|
12
|
+
testId?: string;
|
|
13
|
+
ref?: React.RefObject<HTMLDivElement>;
|
|
14
|
+
inputRef?: React.RefObject<HTMLInputElement>;
|
|
15
|
+
}
|
|
16
|
+
declare const CustomDatepicker: ({ value, onValueChange, minDate, maxDate, disabled, events, showAcademicWeeks, academicWeeks, testId, className, ref, inputRef, ...props }: CustomDatepickerProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export default CustomDatepicker;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface DatepickerInputProps {
|
|
2
|
+
value: string;
|
|
3
|
+
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
4
|
+
onKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
5
|
+
onFocus: () => void;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
ref: React.RefObject<HTMLInputElement | null>;
|
|
8
|
+
}
|
|
9
|
+
declare const DatepickerInput: ({ value, onChange, onKeyDown, onFocus, disabled, ref, }: DatepickerInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default DatepickerInput;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
interface NativeDatepickerProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
2
|
+
testId?: string;
|
|
3
|
+
ref?: React.RefObject<HTMLInputElement>;
|
|
4
|
+
}
|
|
5
|
+
declare const NativeDatepicker: ({ value, onChange, min, max, className, disabled, testId, ref, ...props }: NativeDatepickerProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export default NativeDatepicker;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
interface VisibleFieldProps {
|
|
3
|
+
inputValue: string;
|
|
4
|
+
onInputChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
5
|
+
onInputKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
6
|
+
onInputFocus: () => void;
|
|
7
|
+
onButtonClick: () => void;
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
inputRef: React.RefObject<HTMLInputElement | null>;
|
|
10
|
+
}
|
|
11
|
+
declare const VisibleField: ({ inputValue, onInputChange, onInputKeyDown, onInputFocus, onButtonClick, disabled, inputRef, }: VisibleFieldProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export default VisibleField;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
export { default as
|
|
2
|
-
export { default as
|
|
3
|
-
export { default as
|
|
4
|
-
export { default as
|
|
5
|
-
export { default as
|
|
6
|
-
export { default as Native } from './Native';
|
|
7
|
-
export { default as MonthSelector } from './MonthSelector';
|
|
1
|
+
export { default as CustomDatepicker } from './CustomDatepicker';
|
|
2
|
+
export { default as NativeDatepicker } from './NativeDatepicker';
|
|
3
|
+
export { default as VisibleField } from './VisibleField';
|
|
4
|
+
export { default as DatepickerInput } from './DatepickerInput';
|
|
5
|
+
export { default as Panel } from './Panel';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a Date object to a `YYYY-MM-DD` string based on the user's local timezone.
|
|
3
|
+
*
|
|
4
|
+
* Used for passing dates to <NativeDatepicker> in `Datepicker.tsx`
|
|
5
|
+
*
|
|
6
|
+
* This function uses the Swedish (`sv-SE`) locale with `toLocaleDateString`
|
|
7
|
+
* as it conveniently defaults to the ISO 8601 `YYYY-MM-DD` format, while respecting
|
|
8
|
+
* the local date. This avoids timezone conversion issues that can arise from
|
|
9
|
+
* using `toISOString()`.
|
|
10
|
+
*
|
|
11
|
+
* This implementation should handle daylight saving time, etc, correctly.
|
|
12
|
+
*
|
|
13
|
+
* @param date The date to convert.
|
|
14
|
+
* @returns A string in `YYYY-MM-DD` format, or `null` if the input is `null`.
|
|
15
|
+
*/
|
|
16
|
+
declare const dateToLocaleISOString: (date: Date | null | undefined) => string | null;
|
|
17
|
+
export default dateToLocaleISOString;
|
package/dist/components/Datepicker/utils/dateToLocaleISOString/dateToLocaleISOString.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as
|
|
2
|
-
export { default as
|
|
1
|
+
export { default as dateToLocaleISOString } from './dateToLocaleISOString/dateToLocaleISOString';
|
|
2
|
+
export { default as parseInputValue } from './parseInputValue/parseInputValue';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses a date string into a Date object.
|
|
3
|
+
* Used in <VisibleField> to parse user input into the controlled <input> field.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} value The date string to parse. Expected format is DD/MM/YYYY, DD-MM-YYYY, or DD MM YYYY.
|
|
6
|
+
* @param {string} [minDate] Optional minimum date string in YYYY-MM-DD format. If the parsed date is before this date, the function returns null.
|
|
7
|
+
* @param {string} [maxDate] Optional maximum date string in YYYY-MM-DD format. If the parsed date is after this date, the function returns null.
|
|
8
|
+
* @returns {Date | null} A Date object representing the parsed date, or null if the input is invalid or out of range.
|
|
9
|
+
*/
|
|
10
|
+
declare const parseInputValue: (value: string, minDate?: string | null, maxDate?: string | null) => Date | null;
|
|
11
|
+
export default parseInputValue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,7 +2,7 @@ import { HTMLAttributes } from 'react';
|
|
|
2
2
|
import { default as FooterColumn } from './FooterColumn';
|
|
3
3
|
import { default as FooterNavLink } from './FooterNavLink';
|
|
4
4
|
export declare const NAME = "ucl-uikit-footer";
|
|
5
|
-
export interface FooterProps extends HTMLAttributes<
|
|
5
|
+
export interface FooterProps extends HTMLAttributes<HTMLElement> {
|
|
6
6
|
testId?: string;
|
|
7
7
|
disclaimer?: string;
|
|
8
8
|
freedomOfInformation?: string;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
2
|
import { default as HeaderMenu } from './HeaderMenu';
|
|
3
3
|
export declare const NAME = "ucl-uikit-header";
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
4
|
+
export declare const HEADER_DESKTOP_HEIGHT_PX = 72;
|
|
5
|
+
export declare const HEADER_MOBILE_HEIGHT_PX = 48;
|
|
6
|
+
export declare const DEFAULT_Z_INDEX = 3;
|
|
6
7
|
export interface HeaderProps extends HTMLAttributes<HTMLElement> {
|
|
7
8
|
title?: string;
|
|
8
9
|
fixed?: boolean;
|
|
9
10
|
testId?: string;
|
|
10
11
|
}
|
|
11
|
-
declare const MemoAppHeader:
|
|
12
|
+
declare const MemoAppHeader: import('react').MemoExoticComponent<({ title, fixed, testId, className, children, ...props }: HeaderProps) => import("react/jsx-runtime").JSX.Element>;
|
|
12
13
|
export interface IHeaderSubComponents {
|
|
13
14
|
Menu: typeof HeaderMenu;
|
|
14
15
|
}
|
|
@@ -7,11 +7,12 @@ export interface MenuProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
7
7
|
title?: string;
|
|
8
8
|
menuId?: string;
|
|
9
9
|
testId?: string;
|
|
10
|
+
position?: 'left' | 'right';
|
|
10
11
|
}
|
|
11
12
|
export interface IMenuSubComponents {
|
|
12
13
|
Section: typeof MenuSection;
|
|
13
14
|
Item: typeof MenuItem;
|
|
14
15
|
}
|
|
15
|
-
declare const MemoMenu: import('react').MemoExoticComponent<({ defaultOpen, title, menuId, testId, children, className, ...props }: MenuProps) => import("react/jsx-runtime").JSX.Element>;
|
|
16
|
+
declare const MemoMenu: import('react').MemoExoticComponent<({ defaultOpen, title, position, menuId, testId, children, className, ...props }: MenuProps) => import("react/jsx-runtime").JSX.Element>;
|
|
16
17
|
declare const MenuWithSubComponents: typeof MemoMenu & IMenuSubComponents;
|
|
17
18
|
export default MenuWithSubComponents;
|
|
@@ -3,6 +3,7 @@ export declare const NAME = "ucl-uikit-menu__content";
|
|
|
3
3
|
export interface MenuContentProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
4
|
title?: string;
|
|
5
5
|
testId?: string;
|
|
6
|
+
position?: 'left' | 'right';
|
|
6
7
|
}
|
|
7
8
|
declare const _default: React.NamedExoticComponent<MenuContentProps>;
|
|
8
9
|
export default _default;
|
|
@@ -7,7 +7,7 @@ export type OptionData = {
|
|
|
7
7
|
/**
|
|
8
8
|
* Display text shown to the user
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
label: string;
|
|
11
11
|
/**
|
|
12
12
|
* Data-friendly value that is returned when the option is selected
|
|
13
13
|
* We assume this will be submitted to a server or used in some other way
|
|
@@ -20,12 +20,6 @@ export type OptionData = {
|
|
|
20
20
|
*/
|
|
21
21
|
icon?: React.ReactNode;
|
|
22
22
|
};
|
|
23
|
-
/**
|
|
24
|
-
* Utility type we expose to developers
|
|
25
|
-
* We expect this to be used in typing event handlers
|
|
26
|
-
* This only applies to the top-level <Select> component
|
|
27
|
-
*/
|
|
28
|
-
export type SelectEvent = React.ChangeEvent<HTMLSelectElement> | React.MouseEvent | React.KeyboardEvent;
|
|
29
23
|
/**
|
|
30
24
|
* Top level props that <Select> accepts when implemented
|
|
31
25
|
*/
|
|
@@ -34,20 +28,6 @@ interface BaseSelectProps {
|
|
|
34
28
|
* An array of option data, to be rendered either natively or custom
|
|
35
29
|
*/
|
|
36
30
|
options: OptionData[];
|
|
37
|
-
/**
|
|
38
|
-
* The currently selected value
|
|
39
|
-
* This determines which option is shown when the select is closed
|
|
40
|
-
*/
|
|
41
|
-
value: string | undefined | null;
|
|
42
|
-
/**
|
|
43
|
-
* Generic onChange that splits into native and custom versions
|
|
44
|
-
* The original event is exposed, and the value always returns the value of the selected option
|
|
45
|
-
*/
|
|
46
|
-
onChange: (event: SelectEvent, value: string) => void;
|
|
47
|
-
/**
|
|
48
|
-
* Prevents use, including focus events
|
|
49
|
-
*/
|
|
50
|
-
disabled?: boolean | undefined;
|
|
51
31
|
/**
|
|
52
32
|
* Placeholder text shown when no option is selected
|
|
53
33
|
* Displayed in visible field of custom implementation
|
|
@@ -64,51 +44,31 @@ interface BaseSelectProps {
|
|
|
64
44
|
* as `data-testid`
|
|
65
45
|
*/
|
|
66
46
|
testId?: string;
|
|
67
|
-
/**
|
|
68
|
-
* Optional className for styling
|
|
69
|
-
* This is passed to the root element of the component
|
|
70
|
-
* for additional CSS styling via Emotion.
|
|
71
|
-
*/
|
|
72
|
-
className?: string;
|
|
73
47
|
/**
|
|
74
48
|
* Native flag determines which implementation to use
|
|
75
49
|
*/
|
|
76
50
|
native?: boolean;
|
|
77
51
|
}
|
|
78
|
-
export type SelectProps = BaseSelectProps & (({
|
|
79
|
-
native: true;
|
|
80
|
-
ref?: React.RefObject<HTMLSelectElement | null>;
|
|
81
|
-
} & Omit<React.SelectHTMLAttributes<HTMLSelectElement>, keyof BaseSelectProps>) | ({
|
|
82
|
-
native?: false;
|
|
83
|
-
ref?: React.RefObject<HTMLDivElement | null>;
|
|
84
|
-
} & Omit<React.HTMLAttributes<HTMLDivElement>, keyof BaseSelectProps>));
|
|
85
52
|
/**
|
|
86
53
|
* Internal props for the custom implementation, with <div> as root element
|
|
87
54
|
* onChange already exists on <div>. We override it.
|
|
88
55
|
*/
|
|
89
|
-
export
|
|
90
|
-
|
|
91
|
-
value
|
|
92
|
-
onChange: (event: React.MouseEvent | React.KeyboardEvent, value: string) => void;
|
|
56
|
+
export type CustomSelectProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> & BaseSelectProps & {
|
|
57
|
+
native?: false;
|
|
58
|
+
value?: string | number;
|
|
93
59
|
disabled?: boolean;
|
|
94
|
-
|
|
95
|
-
width?: number;
|
|
96
|
-
testId?: string;
|
|
97
|
-
className?: string;
|
|
60
|
+
onValueChange?: (value: string, ev: React.UIEvent) => void;
|
|
98
61
|
ref?: React.RefObject<HTMLDivElement | null>;
|
|
99
|
-
}
|
|
62
|
+
};
|
|
100
63
|
/**
|
|
101
64
|
* Internal props for native implementation, with <select> as root element
|
|
102
65
|
* Default props like value and onChange are passed to the <select> element automatically
|
|
103
66
|
*/
|
|
104
|
-
export
|
|
105
|
-
|
|
106
|
-
placeholder?: string;
|
|
107
|
-
width?: number;
|
|
108
|
-
testId?: string;
|
|
109
|
-
className?: string;
|
|
67
|
+
export type NativeSelectProps = React.SelectHTMLAttributes<HTMLSelectElement> & BaseSelectProps & {
|
|
68
|
+
native: true;
|
|
110
69
|
ref?: React.RefObject<HTMLSelectElement | null>;
|
|
111
|
-
}
|
|
70
|
+
};
|
|
71
|
+
export type SelectProps = NativeSelectProps | CustomSelectProps;
|
|
112
72
|
/**
|
|
113
73
|
* Each option as displayed in the Panel of <CustomSelect>
|
|
114
74
|
* Roughly equivalent to a custom version of <option>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default } from './Select';
|
|
2
|
-
export type { SelectProps, OptionData
|
|
2
|
+
export type { SelectProps, OptionData } from './Select.types';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { CustomSelectProps } from '../Select.types';
|
|
2
|
-
declare const
|
|
2
|
+
export declare const DEFAULT_WIDTH_PX = 200;
|
|
3
|
+
declare const CustomSelect: ({ value, options, onValueChange, disabled, placeholder, width, testId, className, ref, ...props }: CustomSelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
4
|
export default CustomSelect;
|
|
@@ -77,3 +77,5 @@ export { default as Radio, LabelledRadio } from './Radio';
|
|
|
77
77
|
export type { RadioProps, LabelledRadioProps } from './Radio';
|
|
78
78
|
export { default as Datepicker } from './Datepicker';
|
|
79
79
|
export type { DatepickerProps } from './Datepicker';
|
|
80
|
+
export { default as Calendar } from './Calendar';
|
|
81
|
+
export type { CalendarProps } from './Calendar';
|