@daryasidorovich/modsen-datepicker 1.0.0 → 1.0.1
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/.prettierrc +6 -6
- package/.storybook/main.js +93 -93
- package/.storybook/main.ts +16 -0
- package/.storybook/preview.js +26 -26
- package/.storybook/preview.tsx +18 -18
- package/README.md +5 -5
- package/commitlint.config.js +23 -23
- package/package.json +1 -1
- package/rollup.config.js +65 -65
- package/src/components/BaseCalendar/BaseCalendar.stories.tsx +77 -77
- package/src/components/BaseCalendar/index.tsx +63 -63
- package/src/components/BaseCalendar/styles.module.scss +15 -15
- package/src/components/Button/Button.stories.tsx +16 -0
- package/src/components/Button/Button.tsx +14 -0
- package/src/components/Button/index.ts +1 -0
- package/src/components/Button/styles.module.scss +3 -0
- package/src/components/CalendarGrid/CalendarGrid.stories.tsx +136 -136
- package/src/components/CalendarGrid/CalendarGridWithTasks/Tooltip/index.tsx +27 -27
- package/src/components/CalendarGrid/CalendarGridWithTasks/Tooltip/styles.module.scss +9 -9
- package/src/components/CalendarGrid/CalendarGridWithTasks/index.tsx +51 -51
- package/src/components/CalendarGrid/CalendarGridWithoutTasks/index.tsx +36 -36
- package/src/components/CalendarGrid/CalendarGridWithoutTasks/styles.module.scss +11 -11
- package/src/components/CalendarGrid/index.tsx +19 -19
- package/src/components/CalendarGrid/types.ts +26 -26
- package/src/components/Clear/Clear.stories.tsx +16 -16
- package/src/components/Clear/index.tsx +12 -12
- package/src/components/Clear/styles.module.scss +34 -34
- package/src/components/DatePicker/DatePicker.stories.tsx +127 -127
- package/src/components/DatePicker/index.tsx +72 -72
- package/src/components/DatePicker/styles.module.scss +10 -10
- package/src/components/Day/Day.stories.tsx +75 -75
- package/src/components/Day/index.tsx +95 -95
- package/src/components/Day/styles.module.scss +97 -97
- package/src/components/Input/Input.stories.tsx +37 -37
- package/src/components/Input/index.tsx +64 -64
- package/src/components/Input/styles.module.scss +79 -79
- package/src/components/Modal/CrudModal/index.tsx +43 -43
- package/src/components/Modal/CrudModal/styles.module.scss +44 -44
- package/src/components/Modal/index.tsx +66 -66
- package/src/components/Modal/styles.module.scss +40 -40
- package/src/components/Modal/types.ts +13 -13
- package/src/components/Month/Month.stories.tsx +19 -19
- package/src/components/Month/index.tsx +31 -31
- package/src/components/Month/styles.module.scss +30 -30
- package/src/components/RangePicker/RangePicker.stories.tsx +134 -134
- package/src/components/RangePicker/index.tsx +144 -144
- package/src/components/RangePicker/styles.module.scss +19 -19
- package/src/components/TasksManager/AddModal/index.tsx +62 -62
- package/src/components/TasksManager/DeleteModal/index.tsx +22 -22
- package/src/components/TasksManager/EditModal/index.tsx +96 -96
- package/src/components/TasksManager/index.tsx +112 -112
- package/src/components/TasksManager/styles.module.scss +62 -62
- package/src/components/Week/Week.stories.tsx +49 -49
- package/src/components/Week/index.tsx +68 -68
- package/src/components/Week/styles.module.scss +7 -7
- package/src/components/WeekDay/WeekDay.stories.tsx +38 -38
- package/src/components/WeekDay/index.tsx +35 -35
- package/src/components/WeekDay/styles.module.scss +19 -19
- package/src/constants/dateMask.ts +23 -23
- package/src/constants/firstDayOfWeek.ts +7 -7
- package/src/constants/holidays.ts +32 -32
- package/src/constants/modes.ts +6 -6
- package/src/constants/monthsNames.ts +14 -14
- package/src/constants/weekdaysNames.ts +1 -1
- package/src/hooks/useCalendar.ts +62 -62
- package/src/hooks/useLockBodyScroll.ts +19 -19
- package/src/hooks/useModal.ts +45 -45
- package/src/hooks/useTooltip.ts +41 -41
- package/src/hooks/useValidate.ts +80 -80
- package/src/index.ts +15 -15
- package/src/services/calendarService.ts +62 -62
- package/src/services/decorators/withHolidays.ts +12 -12
- package/src/services/decorators/withMinMax.test.ts +77 -77
- package/src/services/decorators/withMinMax.ts +19 -19
- package/src/services/holidayService.ts +56 -56
- package/src/store/localStorage.ts +33 -33
- package/src/store/tasksStore.tsx +146 -146
- package/src/store/types.ts +22 -22
- package/src/stories/Button.stories.ts +54 -0
- package/src/stories/Button.tsx +37 -0
- package/src/stories/Configure.mdx +388 -0
- package/src/stories/Header.stories.ts +34 -0
- package/src/stories/Header.tsx +56 -0
- package/src/stories/Page.stories.ts +33 -0
- package/src/stories/Page.tsx +73 -0
- package/src/stories/assets/accessibility.png +0 -0
- package/src/stories/assets/accessibility.svg +1 -0
- package/src/stories/assets/addon-library.png +0 -0
- package/src/stories/assets/assets.png +0 -0
- package/src/stories/assets/avif-test-image.avif +0 -0
- package/src/stories/assets/context.png +0 -0
- package/src/stories/assets/discord.svg +1 -0
- package/src/stories/assets/docs.png +0 -0
- package/src/stories/assets/figma-plugin.png +0 -0
- package/src/stories/assets/github.svg +1 -0
- package/src/stories/assets/share.png +0 -0
- package/src/stories/assets/styling.png +0 -0
- package/src/stories/assets/testing.png +0 -0
- package/src/stories/assets/theming.png +0 -0
- package/src/stories/assets/tutorials.svg +1 -0
- package/src/stories/assets/youtube.svg +1 -0
- package/src/stories/button.css +30 -0
- package/src/stories/header.css +32 -0
- package/src/stories/page.css +68 -0
- package/src/styles/_border.scss +9 -9
- package/src/styles/_colors.scss +53 -53
- package/src/styles/_gap.scss +4 -4
- package/src/styles/_globals.scss +61 -61
- package/src/styles/_grid.scss +9 -9
- package/src/styles/_mixins.scss +6 -6
- package/src/styles/_reset.scss +98 -98
- package/src/styles/_theme-mixins.scss +51 -51
- package/src/styles/_typography.scss +10 -10
- package/src/styles/_variables.scss +8 -8
- package/src/styles/main.scss +3 -3
- package/src/types/types.d.ts +15 -15
- package/src/utils/calendar.test.ts +154 -154
- package/src/utils/calendar.ts +82 -82
- package/src/utils/controlDate.ts +3 -3
- package/src/utils/dateChecks.test.ts +216 -216
- package/src/utils/dateChecks.ts +75 -75
- package/src/utils/formatDate.ts +27 -27
- package/src/utils/schema.test.ts +40 -40
- package/src/utils/schema.ts +8 -8
- package/src/utils/weekdayOrder.test.ts +11 -11
- package/src/utils/weekdayOrder.ts +7 -7
- package/vitest.config.ts +38 -38
- package/vitest.shims.d.ts +1 -1
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { BaseCalendar } from './index';
|
|
3
|
-
|
|
4
|
-
const meta: Meta<typeof BaseCalendar> = {
|
|
5
|
-
component: BaseCalendar,
|
|
6
|
-
parameters: {
|
|
7
|
-
layout: 'centered',
|
|
8
|
-
},
|
|
9
|
-
argTypes: {
|
|
10
|
-
firstDayOfWeek: {
|
|
11
|
-
control: 'select',
|
|
12
|
-
options: [0, 1],
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export default meta;
|
|
18
|
-
|
|
19
|
-
type Story = StoryObj<typeof BaseCalendar>;
|
|
20
|
-
|
|
21
|
-
export const Default: Story = {
|
|
22
|
-
args: {
|
|
23
|
-
monthDate: new Date(2026, 7, 1),
|
|
24
|
-
firstDayOfWeek: 1,
|
|
25
|
-
selectedDate: new Date(2026, 7, 15),
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const WithTasks: Story = {
|
|
30
|
-
args: {
|
|
31
|
-
monthDate: new Date(2026, 7, 25),
|
|
32
|
-
firstDayOfWeek: 1,
|
|
33
|
-
enableTasks: true,
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const HideWeekends: Story = {
|
|
38
|
-
args: {
|
|
39
|
-
monthDate: new Date(2026, 8, 7),
|
|
40
|
-
firstDayOfWeek: 1,
|
|
41
|
-
hideWeekends: true,
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const ShowHolidays: Story = {
|
|
46
|
-
args: {
|
|
47
|
-
monthDate: new Date(2025, 0, 3),
|
|
48
|
-
firstDayOfWeek: 1,
|
|
49
|
-
showHolidays: true,
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export const WeekMode: Story = {
|
|
54
|
-
args: {
|
|
55
|
-
monthDate: new Date(2025, 0, 31),
|
|
56
|
-
firstDayOfWeek: 1,
|
|
57
|
-
showHolidays: true,
|
|
58
|
-
mode: 'week',
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export const HideWeekendsFirstDaySundayWeekMode: Story = {
|
|
63
|
-
args: {
|
|
64
|
-
monthDate: new Date(2025, 0, 3),
|
|
65
|
-
mode: 'week',
|
|
66
|
-
firstDayOfWeek: 0,
|
|
67
|
-
hideWeekends: true,
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export const HideWeekendsFirstDaySundayMonthMode: Story = {
|
|
72
|
-
args: {
|
|
73
|
-
monthDate: new Date(2025, 2, 31),
|
|
74
|
-
firstDayOfWeek: 0,
|
|
75
|
-
hideWeekends: true,
|
|
76
|
-
},
|
|
77
|
-
};
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { BaseCalendar } from './index';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof BaseCalendar> = {
|
|
5
|
+
component: BaseCalendar,
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: 'centered',
|
|
8
|
+
},
|
|
9
|
+
argTypes: {
|
|
10
|
+
firstDayOfWeek: {
|
|
11
|
+
control: 'select',
|
|
12
|
+
options: [0, 1],
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default meta;
|
|
18
|
+
|
|
19
|
+
type Story = StoryObj<typeof BaseCalendar>;
|
|
20
|
+
|
|
21
|
+
export const Default: Story = {
|
|
22
|
+
args: {
|
|
23
|
+
monthDate: new Date(2026, 7, 1),
|
|
24
|
+
firstDayOfWeek: 1,
|
|
25
|
+
selectedDate: new Date(2026, 7, 15),
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const WithTasks: Story = {
|
|
30
|
+
args: {
|
|
31
|
+
monthDate: new Date(2026, 7, 25),
|
|
32
|
+
firstDayOfWeek: 1,
|
|
33
|
+
enableTasks: true,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const HideWeekends: Story = {
|
|
38
|
+
args: {
|
|
39
|
+
monthDate: new Date(2026, 8, 7),
|
|
40
|
+
firstDayOfWeek: 1,
|
|
41
|
+
hideWeekends: true,
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const ShowHolidays: Story = {
|
|
46
|
+
args: {
|
|
47
|
+
monthDate: new Date(2025, 0, 3),
|
|
48
|
+
firstDayOfWeek: 1,
|
|
49
|
+
showHolidays: true,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const WeekMode: Story = {
|
|
54
|
+
args: {
|
|
55
|
+
monthDate: new Date(2025, 0, 31),
|
|
56
|
+
firstDayOfWeek: 1,
|
|
57
|
+
showHolidays: true,
|
|
58
|
+
mode: 'week',
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const HideWeekendsFirstDaySundayWeekMode: Story = {
|
|
63
|
+
args: {
|
|
64
|
+
monthDate: new Date(2025, 0, 3),
|
|
65
|
+
mode: 'week',
|
|
66
|
+
firstDayOfWeek: 0,
|
|
67
|
+
hideWeekends: true,
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const HideWeekendsFirstDaySundayMonthMode: Story = {
|
|
72
|
+
args: {
|
|
73
|
+
monthDate: new Date(2025, 2, 31),
|
|
74
|
+
firstDayOfWeek: 0,
|
|
75
|
+
hideWeekends: true,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { MODES } from '@/constants/modes';
|
|
4
|
-
|
|
5
|
-
import { CalendarGrid } from '../CalendarGrid';
|
|
6
|
-
import { BaseCalendarProps } from '../CalendarGrid/types';
|
|
7
|
-
import { Month } from '../Month';
|
|
8
|
-
import { WeekDay } from '../WeekDay';
|
|
9
|
-
import styles from './styles.module.scss';
|
|
10
|
-
|
|
11
|
-
export const BaseCalendar = ({
|
|
12
|
-
mode = MODES.MONTH,
|
|
13
|
-
monthDate,
|
|
14
|
-
firstDayOfWeek = 1,
|
|
15
|
-
hideWeekends = false,
|
|
16
|
-
...props
|
|
17
|
-
}: BaseCalendarProps) => {
|
|
18
|
-
const [baseDate, setBaseDate] = useState(monthDate);
|
|
19
|
-
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
setBaseDate(monthDate);
|
|
22
|
-
}, [monthDate]);
|
|
23
|
-
|
|
24
|
-
const onPrev = () => {
|
|
25
|
-
const newDate = new Date(baseDate);
|
|
26
|
-
|
|
27
|
-
if (mode === MODES.MONTH) {
|
|
28
|
-
newDate.setDate(1);
|
|
29
|
-
newDate.setMonth(baseDate.getMonth() - 1);
|
|
30
|
-
} else {
|
|
31
|
-
newDate.setDate(baseDate.getDate() - 7);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
setBaseDate(newDate);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const onNext = () => {
|
|
38
|
-
const newDate = new Date(baseDate);
|
|
39
|
-
|
|
40
|
-
if (mode === MODES.MONTH) {
|
|
41
|
-
newDate.setDate(1);
|
|
42
|
-
newDate.setMonth(baseDate.getMonth() + 1);
|
|
43
|
-
} else {
|
|
44
|
-
newDate.setDate(baseDate.getDate() + 7);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
setBaseDate(newDate);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<div className={styles.calendarGrid}>
|
|
52
|
-
<Month date={baseDate} onPrev={onPrev} onNext={onNext} />
|
|
53
|
-
<WeekDay firstDayOfWeek={firstDayOfWeek} hideWeekends={hideWeekends} />
|
|
54
|
-
<CalendarGrid
|
|
55
|
-
mode={mode}
|
|
56
|
-
monthDate={baseDate}
|
|
57
|
-
firstDayOfWeek={firstDayOfWeek}
|
|
58
|
-
hideWeekends={hideWeekends}
|
|
59
|
-
{...props}
|
|
60
|
-
/>
|
|
61
|
-
</div>
|
|
62
|
-
);
|
|
63
|
-
};
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { MODES } from '@/constants/modes';
|
|
4
|
+
|
|
5
|
+
import { CalendarGrid } from '../CalendarGrid';
|
|
6
|
+
import { BaseCalendarProps } from '../CalendarGrid/types';
|
|
7
|
+
import { Month } from '../Month';
|
|
8
|
+
import { WeekDay } from '../WeekDay';
|
|
9
|
+
import styles from './styles.module.scss';
|
|
10
|
+
|
|
11
|
+
export const BaseCalendar = ({
|
|
12
|
+
mode = MODES.MONTH,
|
|
13
|
+
monthDate,
|
|
14
|
+
firstDayOfWeek = 1,
|
|
15
|
+
hideWeekends = false,
|
|
16
|
+
...props
|
|
17
|
+
}: BaseCalendarProps) => {
|
|
18
|
+
const [baseDate, setBaseDate] = useState(monthDate);
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
setBaseDate(monthDate);
|
|
22
|
+
}, [monthDate]);
|
|
23
|
+
|
|
24
|
+
const onPrev = () => {
|
|
25
|
+
const newDate = new Date(baseDate);
|
|
26
|
+
|
|
27
|
+
if (mode === MODES.MONTH) {
|
|
28
|
+
newDate.setDate(1);
|
|
29
|
+
newDate.setMonth(baseDate.getMonth() - 1);
|
|
30
|
+
} else {
|
|
31
|
+
newDate.setDate(baseDate.getDate() - 7);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
setBaseDate(newDate);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const onNext = () => {
|
|
38
|
+
const newDate = new Date(baseDate);
|
|
39
|
+
|
|
40
|
+
if (mode === MODES.MONTH) {
|
|
41
|
+
newDate.setDate(1);
|
|
42
|
+
newDate.setMonth(baseDate.getMonth() + 1);
|
|
43
|
+
} else {
|
|
44
|
+
newDate.setDate(baseDate.getDate() + 7);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
setBaseDate(newDate);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<div className={styles.calendarGrid}>
|
|
52
|
+
<Month date={baseDate} onPrev={onPrev} onNext={onNext} />
|
|
53
|
+
<WeekDay firstDayOfWeek={firstDayOfWeek} hideWeekends={hideWeekends} />
|
|
54
|
+
<CalendarGrid
|
|
55
|
+
mode={mode}
|
|
56
|
+
monthDate={baseDate}
|
|
57
|
+
firstDayOfWeek={firstDayOfWeek}
|
|
58
|
+
hideWeekends={hideWeekends}
|
|
59
|
+
{...props}
|
|
60
|
+
/>
|
|
61
|
+
</div>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
.calendarGrid {
|
|
2
|
-
@include border;
|
|
3
|
-
|
|
4
|
-
@include themify-modules($themes) {
|
|
5
|
-
border-color: themed('border');
|
|
6
|
-
background-color: themed('background');
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
padding: $gap-10;
|
|
10
|
-
border-radius: $radius-8;
|
|
11
|
-
display: flex;
|
|
12
|
-
flex-direction: column;
|
|
13
|
-
gap: 2px;
|
|
14
|
-
align-items: center;
|
|
15
|
-
}
|
|
1
|
+
.calendarGrid {
|
|
2
|
+
@include border;
|
|
3
|
+
|
|
4
|
+
@include themify-modules($themes) {
|
|
5
|
+
border-color: themed('border');
|
|
6
|
+
background-color: themed('background');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
padding: $gap-10;
|
|
10
|
+
border-radius: $radius-8;
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
gap: 2px;
|
|
14
|
+
align-items: center;
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import Button from "./Button";
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof Button> = {
|
|
5
|
+
component: Button,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export default meta;
|
|
9
|
+
|
|
10
|
+
type Story = StoryObj<typeof Button>;
|
|
11
|
+
|
|
12
|
+
export const Basic: Story = {
|
|
13
|
+
args: {
|
|
14
|
+
children: "Apply",
|
|
15
|
+
},
|
|
16
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ButtonHTMLAttributes, DetailedHTMLProps } from "react";
|
|
2
|
+
import styles from "./styles.module.scss";
|
|
3
|
+
|
|
4
|
+
type ButtonProps = DetailedHTMLProps<
|
|
5
|
+
ButtonHTMLAttributes<HTMLButtonElement>,
|
|
6
|
+
HTMLButtonElement
|
|
7
|
+
>;
|
|
8
|
+
|
|
9
|
+
const Button = (props: ButtonProps) => {
|
|
10
|
+
return <button {...props} className={styles.button} />;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type { ButtonProps };
|
|
14
|
+
export default Button;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Button";
|
|
@@ -1,136 +1,136 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { CalendarGrid } from '.';
|
|
3
|
-
|
|
4
|
-
const meta: Meta<typeof CalendarGrid> = {
|
|
5
|
-
component: CalendarGrid,
|
|
6
|
-
parameters: {
|
|
7
|
-
layout: 'centered',
|
|
8
|
-
},
|
|
9
|
-
argTypes: {
|
|
10
|
-
firstDayOfWeek: {
|
|
11
|
-
control: 'select',
|
|
12
|
-
options: [0, 1],
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export default meta;
|
|
18
|
-
|
|
19
|
-
type Story = StoryObj<typeof CalendarGrid>;
|
|
20
|
-
|
|
21
|
-
export const Default: Story = {
|
|
22
|
-
args: {
|
|
23
|
-
monthDate: new Date(2026, 7, 1),
|
|
24
|
-
firstDayOfWeek: 1,
|
|
25
|
-
selectedDate: new Date(2026, 7, 15),
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const SundayFirst: Story = {
|
|
30
|
-
args: {
|
|
31
|
-
monthDate: new Date(2026, 7, 1),
|
|
32
|
-
firstDayOfWeek: 0,
|
|
33
|
-
selectedDate: new Date(2026, 7, 15),
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const WithSelectedDate: Story = {
|
|
38
|
-
args: {
|
|
39
|
-
monthDate: new Date(2026, 7, 1),
|
|
40
|
-
firstDayOfWeek: 1,
|
|
41
|
-
selectedDate: new Date(2026, 7, 27),
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const WithMinMax: Story = {
|
|
46
|
-
args: {
|
|
47
|
-
monthDate: new Date(2026, 7, 1),
|
|
48
|
-
firstDayOfWeek: 1,
|
|
49
|
-
selectedDate: new Date(2026, 7, 15),
|
|
50
|
-
minDate: new Date(2026, 7, 10),
|
|
51
|
-
maxDate: new Date(2026, 7, 20),
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export const WeekMode: Story = {
|
|
56
|
-
args: {
|
|
57
|
-
monthDate: new Date(2026, 7, 1),
|
|
58
|
-
firstDayOfWeek: 1,
|
|
59
|
-
selectedDate: new Date(2026, 7, 15),
|
|
60
|
-
mode: 'week',
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export const FullFeatured: Story = {
|
|
65
|
-
args: {
|
|
66
|
-
monthDate: new Date(2026, 7, 1),
|
|
67
|
-
firstDayOfWeek: 1,
|
|
68
|
-
selectedDate: new Date(2026, 7, 15),
|
|
69
|
-
minDate: new Date(2026, 7, 1),
|
|
70
|
-
maxDate: new Date(2026, 7, 15),
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export const September: Story = {
|
|
75
|
-
args: {
|
|
76
|
-
monthDate: new Date(2026, 8, 1),
|
|
77
|
-
firstDayOfWeek: 1,
|
|
78
|
-
selectedDate: new Date(2026, 8, 15),
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export const CurrentMonth: Story = {
|
|
83
|
-
args: {
|
|
84
|
-
monthDate: new Date(),
|
|
85
|
-
firstDayOfWeek: 1,
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export const WithRange: Story = {
|
|
90
|
-
args: {
|
|
91
|
-
monthDate: new Date(),
|
|
92
|
-
firstDayOfWeek: 1,
|
|
93
|
-
rangeStart: new Date(2026, 7, 10),
|
|
94
|
-
rangeEnd: new Date(2026, 7, 19),
|
|
95
|
-
},
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export const HideWeekends: Story = {
|
|
99
|
-
args: {
|
|
100
|
-
monthDate: new Date(),
|
|
101
|
-
firstDayOfWeek: 1,
|
|
102
|
-
hideWeekends: true,
|
|
103
|
-
},
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
export const ShowHolidays: Story = {
|
|
107
|
-
args: {
|
|
108
|
-
monthDate: new Date(2025, 0, 3),
|
|
109
|
-
firstDayOfWeek: 1,
|
|
110
|
-
showHolidays: true,
|
|
111
|
-
},
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
export const WithError: Story = {
|
|
115
|
-
args: {
|
|
116
|
-
monthDate: new Date(2026, 0, 3),
|
|
117
|
-
firstDayOfWeek: 1,
|
|
118
|
-
showHolidays: true,
|
|
119
|
-
},
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export const WithTasks: Story = {
|
|
123
|
-
args: {
|
|
124
|
-
monthDate: new Date(2026, 7, 25),
|
|
125
|
-
firstDayOfWeek: 1,
|
|
126
|
-
enableTasks: true,
|
|
127
|
-
},
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
export const WithoutTasks: Story = {
|
|
131
|
-
args: {
|
|
132
|
-
monthDate: new Date(2026, 7, 25),
|
|
133
|
-
firstDayOfWeek: 1,
|
|
134
|
-
enableTasks: false,
|
|
135
|
-
},
|
|
136
|
-
};
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { CalendarGrid } from '.';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof CalendarGrid> = {
|
|
5
|
+
component: CalendarGrid,
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: 'centered',
|
|
8
|
+
},
|
|
9
|
+
argTypes: {
|
|
10
|
+
firstDayOfWeek: {
|
|
11
|
+
control: 'select',
|
|
12
|
+
options: [0, 1],
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default meta;
|
|
18
|
+
|
|
19
|
+
type Story = StoryObj<typeof CalendarGrid>;
|
|
20
|
+
|
|
21
|
+
export const Default: Story = {
|
|
22
|
+
args: {
|
|
23
|
+
monthDate: new Date(2026, 7, 1),
|
|
24
|
+
firstDayOfWeek: 1,
|
|
25
|
+
selectedDate: new Date(2026, 7, 15),
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const SundayFirst: Story = {
|
|
30
|
+
args: {
|
|
31
|
+
monthDate: new Date(2026, 7, 1),
|
|
32
|
+
firstDayOfWeek: 0,
|
|
33
|
+
selectedDate: new Date(2026, 7, 15),
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const WithSelectedDate: Story = {
|
|
38
|
+
args: {
|
|
39
|
+
monthDate: new Date(2026, 7, 1),
|
|
40
|
+
firstDayOfWeek: 1,
|
|
41
|
+
selectedDate: new Date(2026, 7, 27),
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const WithMinMax: Story = {
|
|
46
|
+
args: {
|
|
47
|
+
monthDate: new Date(2026, 7, 1),
|
|
48
|
+
firstDayOfWeek: 1,
|
|
49
|
+
selectedDate: new Date(2026, 7, 15),
|
|
50
|
+
minDate: new Date(2026, 7, 10),
|
|
51
|
+
maxDate: new Date(2026, 7, 20),
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const WeekMode: Story = {
|
|
56
|
+
args: {
|
|
57
|
+
monthDate: new Date(2026, 7, 1),
|
|
58
|
+
firstDayOfWeek: 1,
|
|
59
|
+
selectedDate: new Date(2026, 7, 15),
|
|
60
|
+
mode: 'week',
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const FullFeatured: Story = {
|
|
65
|
+
args: {
|
|
66
|
+
monthDate: new Date(2026, 7, 1),
|
|
67
|
+
firstDayOfWeek: 1,
|
|
68
|
+
selectedDate: new Date(2026, 7, 15),
|
|
69
|
+
minDate: new Date(2026, 7, 1),
|
|
70
|
+
maxDate: new Date(2026, 7, 15),
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const September: Story = {
|
|
75
|
+
args: {
|
|
76
|
+
monthDate: new Date(2026, 8, 1),
|
|
77
|
+
firstDayOfWeek: 1,
|
|
78
|
+
selectedDate: new Date(2026, 8, 15),
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const CurrentMonth: Story = {
|
|
83
|
+
args: {
|
|
84
|
+
monthDate: new Date(),
|
|
85
|
+
firstDayOfWeek: 1,
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const WithRange: Story = {
|
|
90
|
+
args: {
|
|
91
|
+
monthDate: new Date(),
|
|
92
|
+
firstDayOfWeek: 1,
|
|
93
|
+
rangeStart: new Date(2026, 7, 10),
|
|
94
|
+
rangeEnd: new Date(2026, 7, 19),
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export const HideWeekends: Story = {
|
|
99
|
+
args: {
|
|
100
|
+
monthDate: new Date(),
|
|
101
|
+
firstDayOfWeek: 1,
|
|
102
|
+
hideWeekends: true,
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export const ShowHolidays: Story = {
|
|
107
|
+
args: {
|
|
108
|
+
monthDate: new Date(2025, 0, 3),
|
|
109
|
+
firstDayOfWeek: 1,
|
|
110
|
+
showHolidays: true,
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export const WithError: Story = {
|
|
115
|
+
args: {
|
|
116
|
+
monthDate: new Date(2026, 0, 3),
|
|
117
|
+
firstDayOfWeek: 1,
|
|
118
|
+
showHolidays: true,
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const WithTasks: Story = {
|
|
123
|
+
args: {
|
|
124
|
+
monthDate: new Date(2026, 7, 25),
|
|
125
|
+
firstDayOfWeek: 1,
|
|
126
|
+
enableTasks: true,
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export const WithoutTasks: Story = {
|
|
131
|
+
args: {
|
|
132
|
+
monthDate: new Date(2026, 7, 25),
|
|
133
|
+
firstDayOfWeek: 1,
|
|
134
|
+
enableTasks: false,
|
|
135
|
+
},
|
|
136
|
+
};
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { createPortal } from 'react-dom';
|
|
2
|
-
|
|
3
|
-
import styles from './styles.module.scss';
|
|
4
|
-
|
|
5
|
-
interface TooltipProps {
|
|
6
|
-
isVisible: boolean;
|
|
7
|
-
text: string;
|
|
8
|
-
x: number;
|
|
9
|
-
y: number;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const Tooltip = ({ isVisible, text, x, y }: TooltipProps) => {
|
|
13
|
-
if (!isVisible) return;
|
|
14
|
-
|
|
15
|
-
const Tooltip = (
|
|
16
|
-
<div
|
|
17
|
-
className={styles.tooltip}
|
|
18
|
-
style={{
|
|
19
|
-
top: y,
|
|
20
|
-
left: x,
|
|
21
|
-
}}
|
|
22
|
-
>
|
|
23
|
-
<p>{text}</p>
|
|
24
|
-
</div>
|
|
25
|
-
);
|
|
26
|
-
return createPortal(Tooltip, document.body);
|
|
27
|
-
};
|
|
1
|
+
import { createPortal } from 'react-dom';
|
|
2
|
+
|
|
3
|
+
import styles from './styles.module.scss';
|
|
4
|
+
|
|
5
|
+
interface TooltipProps {
|
|
6
|
+
isVisible: boolean;
|
|
7
|
+
text: string;
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const Tooltip = ({ isVisible, text, x, y }: TooltipProps) => {
|
|
13
|
+
if (!isVisible) return;
|
|
14
|
+
|
|
15
|
+
const Tooltip = (
|
|
16
|
+
<div
|
|
17
|
+
className={styles.tooltip}
|
|
18
|
+
style={{
|
|
19
|
+
top: y,
|
|
20
|
+
left: x,
|
|
21
|
+
}}
|
|
22
|
+
>
|
|
23
|
+
<p>{text}</p>
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
return createPortal(Tooltip, document.body);
|
|
27
|
+
};
|