@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,62 +1,62 @@
|
|
|
1
|
-
.tasksManager {
|
|
2
|
-
min-width: 300px;
|
|
3
|
-
width: fit-content;
|
|
4
|
-
display: flex;
|
|
5
|
-
flex-direction: column;
|
|
6
|
-
gap: $gap-24;
|
|
7
|
-
max-height: 70%;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.tasks {
|
|
11
|
-
display: flex;
|
|
12
|
-
flex-direction: column;
|
|
13
|
-
gap: $gap-8;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.task {
|
|
17
|
-
display: flex;
|
|
18
|
-
gap: $gap-8;
|
|
19
|
-
justify-content: space-between;
|
|
20
|
-
align-items: center;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.checked {
|
|
24
|
-
@include themify-modules($themes) {
|
|
25
|
-
color: themed('disabled');
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.title {
|
|
30
|
-
margin-right: auto;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.action {
|
|
34
|
-
border: none;
|
|
35
|
-
background-color: transparent;
|
|
36
|
-
|
|
37
|
-
@include themify-modules($themes) {
|
|
38
|
-
color: themed('text');
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.delete {
|
|
43
|
-
@include themify-modules($themes) {
|
|
44
|
-
color: themed('accent');
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.add {
|
|
49
|
-
@include themify-modules($themes) {
|
|
50
|
-
background-color: themed('middle-blue');
|
|
51
|
-
border-color: themed('border');
|
|
52
|
-
color: themed('white-color');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
@include border;
|
|
56
|
-
|
|
57
|
-
border-radius: $radius-8;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.header {
|
|
61
|
-
font-size: $font-size-18;
|
|
62
|
-
}
|
|
1
|
+
.tasksManager {
|
|
2
|
+
min-width: 300px;
|
|
3
|
+
width: fit-content;
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
gap: $gap-24;
|
|
7
|
+
max-height: 70%;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.tasks {
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
gap: $gap-8;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.task {
|
|
17
|
+
display: flex;
|
|
18
|
+
gap: $gap-8;
|
|
19
|
+
justify-content: space-between;
|
|
20
|
+
align-items: center;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.checked {
|
|
24
|
+
@include themify-modules($themes) {
|
|
25
|
+
color: themed('disabled');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.title {
|
|
30
|
+
margin-right: auto;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.action {
|
|
34
|
+
border: none;
|
|
35
|
+
background-color: transparent;
|
|
36
|
+
|
|
37
|
+
@include themify-modules($themes) {
|
|
38
|
+
color: themed('text');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.delete {
|
|
43
|
+
@include themify-modules($themes) {
|
|
44
|
+
color: themed('accent');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.add {
|
|
49
|
+
@include themify-modules($themes) {
|
|
50
|
+
background-color: themed('middle-blue');
|
|
51
|
+
border-color: themed('border');
|
|
52
|
+
color: themed('white-color');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@include border;
|
|
56
|
+
|
|
57
|
+
border-radius: $radius-8;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.header {
|
|
61
|
+
font-size: $font-size-18;
|
|
62
|
+
}
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { Week } from '.';
|
|
3
|
-
|
|
4
|
-
const meta: Meta<typeof Week> = {
|
|
5
|
-
component: Week,
|
|
6
|
-
parameters: {
|
|
7
|
-
layout: 'centered',
|
|
8
|
-
},
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export default meta;
|
|
12
|
-
|
|
13
|
-
const weekDaysArr = [
|
|
14
|
-
new Date(2026, 7, 25),
|
|
15
|
-
new Date(2026, 7, 26),
|
|
16
|
-
new Date(2026, 7, 27),
|
|
17
|
-
new Date(2026, 7, 28),
|
|
18
|
-
new Date(2026, 7, 29),
|
|
19
|
-
new Date(2026, 7, 30),
|
|
20
|
-
new Date(2026, 7, 31),
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
const baseArgs = {
|
|
24
|
-
weekDays: weekDaysArr,
|
|
25
|
-
getIsCurrentMonth: () => {
|
|
26
|
-
return true;
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
type Story = StoryObj<typeof Week>;
|
|
31
|
-
|
|
32
|
-
export const Default: Story = {
|
|
33
|
-
args: { ...baseArgs },
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const WithSelectedDate: Story = {
|
|
37
|
-
args: {
|
|
38
|
-
...baseArgs,
|
|
39
|
-
selectedDate: new Date(2026, 7, 28),
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const WithRange: Story = {
|
|
44
|
-
args: {
|
|
45
|
-
...baseArgs,
|
|
46
|
-
rangeStart: new Date(2026, 7, 26),
|
|
47
|
-
rangeEnd: new Date(2026, 7, 30),
|
|
48
|
-
},
|
|
49
|
-
};
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Week } from '.';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof Week> = {
|
|
5
|
+
component: Week,
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: 'centered',
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default meta;
|
|
12
|
+
|
|
13
|
+
const weekDaysArr = [
|
|
14
|
+
new Date(2026, 7, 25),
|
|
15
|
+
new Date(2026, 7, 26),
|
|
16
|
+
new Date(2026, 7, 27),
|
|
17
|
+
new Date(2026, 7, 28),
|
|
18
|
+
new Date(2026, 7, 29),
|
|
19
|
+
new Date(2026, 7, 30),
|
|
20
|
+
new Date(2026, 7, 31),
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
const baseArgs = {
|
|
24
|
+
weekDays: weekDaysArr,
|
|
25
|
+
getIsCurrentMonth: () => {
|
|
26
|
+
return true;
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
type Story = StoryObj<typeof Week>;
|
|
31
|
+
|
|
32
|
+
export const Default: Story = {
|
|
33
|
+
args: { ...baseArgs },
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const WithSelectedDate: Story = {
|
|
37
|
+
args: {
|
|
38
|
+
...baseArgs,
|
|
39
|
+
selectedDate: new Date(2026, 7, 28),
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const WithRange: Story = {
|
|
44
|
+
args: {
|
|
45
|
+
...baseArgs,
|
|
46
|
+
rangeStart: new Date(2026, 7, 26),
|
|
47
|
+
rangeEnd: new Date(2026, 7, 30),
|
|
48
|
+
},
|
|
49
|
+
};
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isInRange,
|
|
3
|
-
isRangeEnd,
|
|
4
|
-
isRangeStart,
|
|
5
|
-
isSelected,
|
|
6
|
-
} from '@/utils/dateChecks';
|
|
7
|
-
|
|
8
|
-
import { Day } from '../Day';
|
|
9
|
-
import styles from './styles.module.scss';
|
|
10
|
-
|
|
11
|
-
export interface WeekProps {
|
|
12
|
-
weekDays: Date[];
|
|
13
|
-
selectedDate?: Date;
|
|
14
|
-
rangeStart?: Date;
|
|
15
|
-
rangeEnd?: Date;
|
|
16
|
-
getIsHoliday?: (date: Date) => boolean;
|
|
17
|
-
getHasTask?: (date: Date) => boolean;
|
|
18
|
-
getIsDisabled?: (date: Date) => boolean;
|
|
19
|
-
getIsCurrentMonth: (date: Date) => boolean;
|
|
20
|
-
getIsWeekend?: (date: Date) => boolean;
|
|
21
|
-
hasTasks?: (date: Date) => boolean;
|
|
22
|
-
onDateClick?: (e: React.MouseEvent<HTMLButtonElement>, date: Date) => void;
|
|
23
|
-
onDateDoubleClick?: (date: Date) => void;
|
|
24
|
-
onMouseEnter?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
25
|
-
onMouseLeave?: () => void;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const Week = ({
|
|
29
|
-
weekDays,
|
|
30
|
-
selectedDate,
|
|
31
|
-
getIsHoliday,
|
|
32
|
-
getIsDisabled,
|
|
33
|
-
getIsCurrentMonth,
|
|
34
|
-
rangeStart,
|
|
35
|
-
rangeEnd,
|
|
36
|
-
hasTasks,
|
|
37
|
-
onDateClick,
|
|
38
|
-
onDateDoubleClick,
|
|
39
|
-
onMouseEnter,
|
|
40
|
-
onMouseLeave,
|
|
41
|
-
}: WeekProps) => {
|
|
42
|
-
return (
|
|
43
|
-
<div className={styles.week}>
|
|
44
|
-
{weekDays.map((date) => {
|
|
45
|
-
return (
|
|
46
|
-
<Day
|
|
47
|
-
key={date.toISOString()}
|
|
48
|
-
date={date}
|
|
49
|
-
isSelected={isSelected(date, selectedDate)}
|
|
50
|
-
isDisabled={getIsDisabled?.(date) || false}
|
|
51
|
-
isCurrentMonth={getIsCurrentMonth(date)}
|
|
52
|
-
isHoliday={getIsHoliday?.(date) || false}
|
|
53
|
-
hasTasks={hasTasks?.(date) || false}
|
|
54
|
-
isRangeStart={isRangeStart(date, rangeStart)}
|
|
55
|
-
isRangeEnd={isRangeEnd(date, rangeEnd)}
|
|
56
|
-
isRangeMiddle={isInRange(date, rangeStart, rangeEnd)}
|
|
57
|
-
onClick={getIsDisabled?.(date) ? undefined : onDateClick}
|
|
58
|
-
onDoubleClick={
|
|
59
|
-
getIsDisabled?.(date) ? undefined : onDateDoubleClick
|
|
60
|
-
}
|
|
61
|
-
onMouseEnter={getIsDisabled?.(date) ? undefined : onMouseEnter}
|
|
62
|
-
onMouseLeave={getIsDisabled?.(date) ? undefined : onMouseLeave}
|
|
63
|
-
/>
|
|
64
|
-
);
|
|
65
|
-
})}
|
|
66
|
-
</div>
|
|
67
|
-
);
|
|
68
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
isInRange,
|
|
3
|
+
isRangeEnd,
|
|
4
|
+
isRangeStart,
|
|
5
|
+
isSelected,
|
|
6
|
+
} from '@/utils/dateChecks';
|
|
7
|
+
|
|
8
|
+
import { Day } from '../Day';
|
|
9
|
+
import styles from './styles.module.scss';
|
|
10
|
+
|
|
11
|
+
export interface WeekProps {
|
|
12
|
+
weekDays: Date[];
|
|
13
|
+
selectedDate?: Date;
|
|
14
|
+
rangeStart?: Date;
|
|
15
|
+
rangeEnd?: Date;
|
|
16
|
+
getIsHoliday?: (date: Date) => boolean;
|
|
17
|
+
getHasTask?: (date: Date) => boolean;
|
|
18
|
+
getIsDisabled?: (date: Date) => boolean;
|
|
19
|
+
getIsCurrentMonth: (date: Date) => boolean;
|
|
20
|
+
getIsWeekend?: (date: Date) => boolean;
|
|
21
|
+
hasTasks?: (date: Date) => boolean;
|
|
22
|
+
onDateClick?: (e: React.MouseEvent<HTMLButtonElement>, date: Date) => void;
|
|
23
|
+
onDateDoubleClick?: (date: Date) => void;
|
|
24
|
+
onMouseEnter?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
25
|
+
onMouseLeave?: () => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const Week = ({
|
|
29
|
+
weekDays,
|
|
30
|
+
selectedDate,
|
|
31
|
+
getIsHoliday,
|
|
32
|
+
getIsDisabled,
|
|
33
|
+
getIsCurrentMonth,
|
|
34
|
+
rangeStart,
|
|
35
|
+
rangeEnd,
|
|
36
|
+
hasTasks,
|
|
37
|
+
onDateClick,
|
|
38
|
+
onDateDoubleClick,
|
|
39
|
+
onMouseEnter,
|
|
40
|
+
onMouseLeave,
|
|
41
|
+
}: WeekProps) => {
|
|
42
|
+
return (
|
|
43
|
+
<div className={styles.week}>
|
|
44
|
+
{weekDays.map((date) => {
|
|
45
|
+
return (
|
|
46
|
+
<Day
|
|
47
|
+
key={date.toISOString()}
|
|
48
|
+
date={date}
|
|
49
|
+
isSelected={isSelected(date, selectedDate)}
|
|
50
|
+
isDisabled={getIsDisabled?.(date) || false}
|
|
51
|
+
isCurrentMonth={getIsCurrentMonth(date)}
|
|
52
|
+
isHoliday={getIsHoliday?.(date) || false}
|
|
53
|
+
hasTasks={hasTasks?.(date) || false}
|
|
54
|
+
isRangeStart={isRangeStart(date, rangeStart)}
|
|
55
|
+
isRangeEnd={isRangeEnd(date, rangeEnd)}
|
|
56
|
+
isRangeMiddle={isInRange(date, rangeStart, rangeEnd)}
|
|
57
|
+
onClick={getIsDisabled?.(date) ? undefined : onDateClick}
|
|
58
|
+
onDoubleClick={
|
|
59
|
+
getIsDisabled?.(date) ? undefined : onDateDoubleClick
|
|
60
|
+
}
|
|
61
|
+
onMouseEnter={getIsDisabled?.(date) ? undefined : onMouseEnter}
|
|
62
|
+
onMouseLeave={getIsDisabled?.(date) ? undefined : onMouseLeave}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
})}
|
|
66
|
+
</div>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
.week {
|
|
2
|
-
display: flex;
|
|
3
|
-
|
|
4
|
-
@include themify-modules($themes) {
|
|
5
|
-
background-color: themed('background');
|
|
6
|
-
}
|
|
7
|
-
}
|
|
1
|
+
.week {
|
|
2
|
+
display: flex;
|
|
3
|
+
|
|
4
|
+
@include themify-modules($themes) {
|
|
5
|
+
background-color: themed('background');
|
|
6
|
+
}
|
|
7
|
+
}
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { WeekDay } from '.';
|
|
3
|
-
|
|
4
|
-
const meta: Meta<typeof WeekDay> = {
|
|
5
|
-
component: WeekDay,
|
|
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 WeekDay>;
|
|
20
|
-
|
|
21
|
-
export const MondayFirst: Story = {
|
|
22
|
-
args: {
|
|
23
|
-
firstDayOfWeek: 1,
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const SundayFirst: Story = {
|
|
28
|
-
args: {
|
|
29
|
-
firstDayOfWeek: 0,
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const HideWeekends: Story = {
|
|
34
|
-
args: {
|
|
35
|
-
firstDayOfWeek: 0,
|
|
36
|
-
hideWeekends: true,
|
|
37
|
-
},
|
|
38
|
-
};
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { WeekDay } from '.';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof WeekDay> = {
|
|
5
|
+
component: WeekDay,
|
|
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 WeekDay>;
|
|
20
|
+
|
|
21
|
+
export const MondayFirst: Story = {
|
|
22
|
+
args: {
|
|
23
|
+
firstDayOfWeek: 1,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const SundayFirst: Story = {
|
|
28
|
+
args: {
|
|
29
|
+
firstDayOfWeek: 0,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const HideWeekends: Story = {
|
|
34
|
+
args: {
|
|
35
|
+
firstDayOfWeek: 0,
|
|
36
|
+
hideWeekends: true,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import classNames from 'classnames';
|
|
2
|
-
|
|
3
|
-
import { WEEKDAYS_NAMES } from '@/constants/weekdaysNames';
|
|
4
|
-
import { getOrderedDays } from '@/utils/weekdayOrder';
|
|
5
|
-
|
|
6
|
-
import styles from './styles.module.scss';
|
|
7
|
-
|
|
8
|
-
interface WeekDayProps {
|
|
9
|
-
firstDayOfWeek?: 0 | 1;
|
|
10
|
-
className?: string;
|
|
11
|
-
hideWeekends?: boolean;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const WeekDay = ({
|
|
15
|
-
firstDayOfWeek = 1,
|
|
16
|
-
className = '',
|
|
17
|
-
hideWeekends = false,
|
|
18
|
-
}: WeekDayProps) => {
|
|
19
|
-
let days = getOrderedDays(firstDayOfWeek);
|
|
20
|
-
|
|
21
|
-
if (hideWeekends) {
|
|
22
|
-
days = days.filter((dayIndex) => dayIndex !== 0 && dayIndex !== 6);
|
|
23
|
-
}
|
|
24
|
-
return (
|
|
25
|
-
<div className={classNames(styles.weekDay, className)}>
|
|
26
|
-
{days.map((index) => {
|
|
27
|
-
return (
|
|
28
|
-
<span key={WEEKDAYS_NAMES[index]} className={styles.dayName}>
|
|
29
|
-
{WEEKDAYS_NAMES[index]}
|
|
30
|
-
</span>
|
|
31
|
-
);
|
|
32
|
-
})}
|
|
33
|
-
</div>
|
|
34
|
-
);
|
|
35
|
-
};
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
|
|
3
|
+
import { WEEKDAYS_NAMES } from '@/constants/weekdaysNames';
|
|
4
|
+
import { getOrderedDays } from '@/utils/weekdayOrder';
|
|
5
|
+
|
|
6
|
+
import styles from './styles.module.scss';
|
|
7
|
+
|
|
8
|
+
interface WeekDayProps {
|
|
9
|
+
firstDayOfWeek?: 0 | 1;
|
|
10
|
+
className?: string;
|
|
11
|
+
hideWeekends?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const WeekDay = ({
|
|
15
|
+
firstDayOfWeek = 1,
|
|
16
|
+
className = '',
|
|
17
|
+
hideWeekends = false,
|
|
18
|
+
}: WeekDayProps) => {
|
|
19
|
+
let days = getOrderedDays(firstDayOfWeek);
|
|
20
|
+
|
|
21
|
+
if (hideWeekends) {
|
|
22
|
+
days = days.filter((dayIndex) => dayIndex !== 0 && dayIndex !== 6);
|
|
23
|
+
}
|
|
24
|
+
return (
|
|
25
|
+
<div className={classNames(styles.weekDay, className)}>
|
|
26
|
+
{days.map((index) => {
|
|
27
|
+
return (
|
|
28
|
+
<span key={WEEKDAYS_NAMES[index]} className={styles.dayName}>
|
|
29
|
+
{WEEKDAYS_NAMES[index]}
|
|
30
|
+
</span>
|
|
31
|
+
);
|
|
32
|
+
})}
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
.weekDay {
|
|
2
|
-
display: flex;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.dayName {
|
|
6
|
-
@include square(32px);
|
|
7
|
-
|
|
8
|
-
@include themify-modules($themes) {
|
|
9
|
-
background-color: themed('background');
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
font-size: $font-size-13;
|
|
13
|
-
padding: $gap-10;
|
|
14
|
-
border-radius: $radius-8;
|
|
15
|
-
display: flex;
|
|
16
|
-
align-items: center;
|
|
17
|
-
justify-content: center;
|
|
18
|
-
font-weight: $font-weight-semibold;
|
|
19
|
-
}
|
|
1
|
+
.weekDay {
|
|
2
|
+
display: flex;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.dayName {
|
|
6
|
+
@include square(32px);
|
|
7
|
+
|
|
8
|
+
@include themify-modules($themes) {
|
|
9
|
+
background-color: themed('background');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
font-size: $font-size-13;
|
|
13
|
+
padding: $gap-10;
|
|
14
|
+
border-radius: $radius-8;
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
font-weight: $font-weight-semibold;
|
|
19
|
+
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { IMask } from 'react-imask';
|
|
2
|
-
|
|
3
|
-
export const DATE_MASK = {
|
|
4
|
-
mask: 'dd/mm/yyyy',
|
|
5
|
-
blocks: {
|
|
6
|
-
dd: {
|
|
7
|
-
mask: IMask.MaskedRange,
|
|
8
|
-
from: 1,
|
|
9
|
-
to: 31,
|
|
10
|
-
},
|
|
11
|
-
mm: {
|
|
12
|
-
mask: IMask.MaskedRange,
|
|
13
|
-
from: 1,
|
|
14
|
-
to: 12,
|
|
15
|
-
},
|
|
16
|
-
yyyy: {
|
|
17
|
-
mask: IMask.MaskedRange,
|
|
18
|
-
from: 1900,
|
|
19
|
-
to: 2100,
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
autofix: true,
|
|
23
|
-
} as const;
|
|
1
|
+
import { IMask } from 'react-imask';
|
|
2
|
+
|
|
3
|
+
export const DATE_MASK = {
|
|
4
|
+
mask: 'dd/mm/yyyy',
|
|
5
|
+
blocks: {
|
|
6
|
+
dd: {
|
|
7
|
+
mask: IMask.MaskedRange,
|
|
8
|
+
from: 1,
|
|
9
|
+
to: 31,
|
|
10
|
+
},
|
|
11
|
+
mm: {
|
|
12
|
+
mask: IMask.MaskedRange,
|
|
13
|
+
from: 1,
|
|
14
|
+
to: 12,
|
|
15
|
+
},
|
|
16
|
+
yyyy: {
|
|
17
|
+
mask: IMask.MaskedRange,
|
|
18
|
+
from: 1900,
|
|
19
|
+
to: 2100,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
autofix: true,
|
|
23
|
+
} as const;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export const FIRST_DAY_OF_WEEK = {
|
|
2
|
-
MONDAY: 1,
|
|
3
|
-
SUNDAY: 0,
|
|
4
|
-
} as const;
|
|
5
|
-
|
|
6
|
-
export type FIRST_DAY_OF_WEEK_TYPES =
|
|
7
|
-
(typeof FIRST_DAY_OF_WEEK)[keyof typeof FIRST_DAY_OF_WEEK];
|
|
1
|
+
export const FIRST_DAY_OF_WEEK = {
|
|
2
|
+
MONDAY: 1,
|
|
3
|
+
SUNDAY: 0,
|
|
4
|
+
} as const;
|
|
5
|
+
|
|
6
|
+
export type FIRST_DAY_OF_WEEK_TYPES =
|
|
7
|
+
(typeof FIRST_DAY_OF_WEEK)[keyof typeof FIRST_DAY_OF_WEEK];
|