@daryasidorovich/modsen-datepicker 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +302 -302
- package/package.json +111 -106
- package/.babelrc.json +0 -7
- package/.github/workflows/chromatic.yml +0 -25
- package/.github/workflows/ci.yml +0 -56
- package/.husky/commit-msg +0 -1
- package/.husky/pre-commit +0 -1
- package/.prettierignore +0 -16
- package/.prettierrc +0 -6
- package/.storybook/main.js +0 -93
- package/.storybook/main.ts +0 -16
- package/.storybook/preview-head.html +0 -6
- package/.storybook/preview.js +0 -26
- package/.storybook/preview.tsx +0 -18
- package/commitlint.config.js +0 -23
- package/eslint.config.ts +0 -80
- package/jest.config.json +0 -21
- package/rollup.config.js +0 -65
- package/src/assets/actions/Delete.svg +0 -4
- package/src/assets/actions/Edit.svg +0 -3
- package/src/assets/arrows/Next.svg +0 -4
- package/src/assets/arrows/Prev.svg +0 -4
- package/src/assets/input/Calendar.svg +0 -3
- package/src/assets/input/Clear.svg +0 -3
- package/src/components/BaseCalendar/BaseCalendar.stories.tsx +0 -77
- package/src/components/BaseCalendar/index.tsx +0 -63
- package/src/components/BaseCalendar/styles.module.scss +0 -15
- package/src/components/Button/Button.stories.tsx +0 -16
- package/src/components/Button/Button.tsx +0 -14
- package/src/components/Button/index.ts +0 -1
- package/src/components/Button/styles.module.scss +0 -3
- package/src/components/CalendarGrid/CalendarGrid.stories.tsx +0 -136
- package/src/components/CalendarGrid/CalendarGridWithTasks/Tooltip/index.tsx +0 -27
- package/src/components/CalendarGrid/CalendarGridWithTasks/Tooltip/styles.module.scss +0 -9
- package/src/components/CalendarGrid/CalendarGridWithTasks/index.tsx +0 -51
- package/src/components/CalendarGrid/CalendarGridWithoutTasks/CalendarGridWithoutTasks.test.tsx +0 -223
- package/src/components/CalendarGrid/CalendarGridWithoutTasks/index.tsx +0 -36
- package/src/components/CalendarGrid/CalendarGridWithoutTasks/styles.module.scss +0 -11
- package/src/components/CalendarGrid/index.tsx +0 -19
- package/src/components/CalendarGrid/types.ts +0 -26
- package/src/components/Clear/Clear.stories.tsx +0 -16
- package/src/components/Clear/index.tsx +0 -12
- package/src/components/Clear/styles.module.scss +0 -34
- package/src/components/DatePicker/DatePicker.stories.tsx +0 -127
- package/src/components/DatePicker/index.tsx +0 -72
- package/src/components/DatePicker/styles.module.scss +0 -10
- package/src/components/Day/Day.stories.tsx +0 -75
- package/src/components/Day/index.tsx +0 -95
- package/src/components/Day/styles.module.scss +0 -97
- package/src/components/Input/Input.stories.tsx +0 -37
- package/src/components/Input/index.tsx +0 -64
- package/src/components/Input/styles.module.scss +0 -79
- package/src/components/Modal/CrudModal/index.tsx +0 -43
- package/src/components/Modal/CrudModal/styles.module.scss +0 -44
- package/src/components/Modal/index.tsx +0 -66
- package/src/components/Modal/styles.module.scss +0 -40
- package/src/components/Modal/types.ts +0 -13
- package/src/components/Month/Month.stories.tsx +0 -19
- package/src/components/Month/index.tsx +0 -31
- package/src/components/Month/styles.module.scss +0 -30
- package/src/components/RangePicker/RangePicker.stories.tsx +0 -134
- package/src/components/RangePicker/index.tsx +0 -144
- package/src/components/RangePicker/styles.module.scss +0 -19
- package/src/components/TasksManager/AddModal/index.tsx +0 -62
- package/src/components/TasksManager/DeleteModal/index.tsx +0 -22
- package/src/components/TasksManager/EditModal/index.tsx +0 -96
- package/src/components/TasksManager/index.tsx +0 -112
- package/src/components/TasksManager/styles.module.scss +0 -62
- package/src/components/Week/Week.stories.tsx +0 -49
- package/src/components/Week/index.tsx +0 -68
- package/src/components/Week/styles.module.scss +0 -7
- package/src/components/WeekDay/WeekDay.stories.tsx +0 -38
- package/src/components/WeekDay/index.tsx +0 -35
- package/src/components/WeekDay/styles.module.scss +0 -19
- package/src/constants/dateMask.ts +0 -23
- package/src/constants/firstDayOfWeek.ts +0 -7
- package/src/constants/holidays.ts +0 -32
- package/src/constants/modes.ts +0 -6
- package/src/constants/monthsNames.ts +0 -14
- package/src/constants/weekdaysNames.ts +0 -1
- package/src/hooks/useCalendar.ts +0 -62
- package/src/hooks/useLockBodyScroll.ts +0 -19
- package/src/hooks/useModal.ts +0 -45
- package/src/hooks/useTooltip.ts +0 -41
- package/src/hooks/useValidate.ts +0 -80
- package/src/index.ts +0 -15
- package/src/services/calendarService.ts +0 -62
- package/src/services/decorators/withHolidays.test.ts +0 -64
- package/src/services/decorators/withHolidays.ts +0 -12
- package/src/services/decorators/withMinMax.test.ts +0 -77
- package/src/services/decorators/withMinMax.ts +0 -19
- package/src/services/holidayService.ts +0 -56
- package/src/setupTests.ts +0 -1
- package/src/store/localStorage.ts +0 -33
- package/src/store/tasksStore.test.tsx +0 -208
- package/src/store/tasksStore.tsx +0 -146
- package/src/store/types.ts +0 -22
- package/src/stories/Button.stories.ts +0 -54
- package/src/stories/Button.tsx +0 -37
- package/src/stories/Configure.mdx +0 -388
- package/src/stories/Header.stories.ts +0 -34
- package/src/stories/Header.tsx +0 -56
- package/src/stories/Page.stories.ts +0 -33
- package/src/stories/Page.tsx +0 -73
- package/src/stories/assets/accessibility.png +0 -0
- package/src/stories/assets/accessibility.svg +0 -1
- 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 +0 -1
- package/src/stories/assets/docs.png +0 -0
- package/src/stories/assets/figma-plugin.png +0 -0
- package/src/stories/assets/github.svg +0 -1
- 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 +0 -1
- package/src/stories/assets/youtube.svg +0 -1
- package/src/stories/button.css +0 -30
- package/src/stories/header.css +0 -32
- package/src/stories/page.css +0 -68
- package/src/styles/_border.scss +0 -9
- package/src/styles/_colors.scss +0 -53
- package/src/styles/_gap.scss +0 -4
- package/src/styles/_globals.scss +0 -61
- package/src/styles/_grid.scss +0 -9
- package/src/styles/_mixins.scss +0 -6
- package/src/styles/_reset.scss +0 -98
- package/src/styles/_theme-mixins.scss +0 -51
- package/src/styles/_typography.scss +0 -10
- package/src/styles/_variables.scss +0 -8
- package/src/styles/main.scss +0 -3
- package/src/types/types.d.ts +0 -15
- package/src/utils/calendar.test.ts +0 -154
- package/src/utils/calendar.ts +0 -82
- package/src/utils/controlDate.ts +0 -3
- package/src/utils/dateChecks.test.ts +0 -216
- package/src/utils/dateChecks.ts +0 -75
- package/src/utils/formatDate.test.ts +0 -57
- package/src/utils/formatDate.ts +0 -27
- package/src/utils/schema.test.ts +0 -40
- package/src/utils/schema.ts +0 -8
- package/src/utils/weekdayOrder.test.ts +0 -11
- package/src/utils/weekdayOrder.ts +0 -7
- package/tsconfig.json +0 -31
- package/vitest.config.ts +0 -38
- package/vitest.shims.d.ts +0 -1
package/src/stories/header.css
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
.storybook-header {
|
|
2
|
-
display: flex;
|
|
3
|
-
justify-content: space-between;
|
|
4
|
-
align-items: center;
|
|
5
|
-
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
|
6
|
-
padding: 15px 20px;
|
|
7
|
-
font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.storybook-header svg {
|
|
11
|
-
display: inline-block;
|
|
12
|
-
vertical-align: top;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.storybook-header h1 {
|
|
16
|
-
display: inline-block;
|
|
17
|
-
vertical-align: top;
|
|
18
|
-
margin: 6px 0 6px 10px;
|
|
19
|
-
font-weight: 700;
|
|
20
|
-
font-size: 20px;
|
|
21
|
-
line-height: 1;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.storybook-header button + button {
|
|
25
|
-
margin-left: 10px;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.storybook-header .welcome {
|
|
29
|
-
margin-right: 10px;
|
|
30
|
-
color: #333;
|
|
31
|
-
font-size: 14px;
|
|
32
|
-
}
|
package/src/stories/page.css
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
.storybook-page {
|
|
2
|
-
margin: 0 auto;
|
|
3
|
-
padding: 48px 20px;
|
|
4
|
-
max-width: 600px;
|
|
5
|
-
color: #333;
|
|
6
|
-
font-size: 14px;
|
|
7
|
-
line-height: 24px;
|
|
8
|
-
font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.storybook-page h2 {
|
|
12
|
-
display: inline-block;
|
|
13
|
-
vertical-align: top;
|
|
14
|
-
margin: 0 0 4px;
|
|
15
|
-
font-weight: 700;
|
|
16
|
-
font-size: 32px;
|
|
17
|
-
line-height: 1;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.storybook-page p {
|
|
21
|
-
margin: 1em 0;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.storybook-page a {
|
|
25
|
-
color: inherit;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.storybook-page ul {
|
|
29
|
-
margin: 1em 0;
|
|
30
|
-
padding-left: 30px;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.storybook-page li {
|
|
34
|
-
margin-bottom: 8px;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.storybook-page .tip {
|
|
38
|
-
display: inline-block;
|
|
39
|
-
vertical-align: top;
|
|
40
|
-
margin-right: 10px;
|
|
41
|
-
border-radius: 1em;
|
|
42
|
-
background: #e7fdd8;
|
|
43
|
-
padding: 4px 12px;
|
|
44
|
-
color: #357a14;
|
|
45
|
-
font-weight: 700;
|
|
46
|
-
font-size: 11px;
|
|
47
|
-
line-height: 12px;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.storybook-page .tip-wrapper {
|
|
51
|
-
margin-top: 40px;
|
|
52
|
-
margin-bottom: 40px;
|
|
53
|
-
font-size: 13px;
|
|
54
|
-
line-height: 20px;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.storybook-page .tip-wrapper svg {
|
|
58
|
-
display: inline-block;
|
|
59
|
-
vertical-align: top;
|
|
60
|
-
margin-top: 3px;
|
|
61
|
-
margin-right: 4px;
|
|
62
|
-
width: 12px;
|
|
63
|
-
height: 12px;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.storybook-page .tip-wrapper svg path {
|
|
67
|
-
fill: #1ea7fd;
|
|
68
|
-
}
|
package/src/styles/_border.scss
DELETED
package/src/styles/_colors.scss
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
@use 'sass:map';
|
|
2
|
-
|
|
3
|
-
$colors: (
|
|
4
|
-
color-blue: #2f80ed,
|
|
5
|
-
color-blue-60: #2f81ed93,
|
|
6
|
-
color-blue-10: #2f81ed2a,
|
|
7
|
-
|
|
8
|
-
color-white: #ffffff,
|
|
9
|
-
color-black: #333333,
|
|
10
|
-
|
|
11
|
-
color-red: #ff383c,
|
|
12
|
-
color-green: #62d0a2,
|
|
13
|
-
color-light-gray: #e1e1e1,
|
|
14
|
-
color-gray: #aaaaaa,
|
|
15
|
-
color-dark-gray: #2c314466,
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
@function color($key) {
|
|
19
|
-
@return map.get($colors, $key);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
$themes: (
|
|
23
|
-
light: (
|
|
24
|
-
border: color(color-light-gray),
|
|
25
|
-
background: color(color-white),
|
|
26
|
-
text: color(color-black),
|
|
27
|
-
middle-blue: color(color-blue-60),
|
|
28
|
-
light-blue: color(color-blue-10),
|
|
29
|
-
blue: color(color-blue),
|
|
30
|
-
disabled: color(color-gray),
|
|
31
|
-
selected: color(color-blue),
|
|
32
|
-
accent: color(color-red),
|
|
33
|
-
marker: color(color-green),
|
|
34
|
-
white-color: color(color-white),
|
|
35
|
-
button-hover: color(color-blue-60),
|
|
36
|
-
overlay: color(color-dark-gray),
|
|
37
|
-
),
|
|
38
|
-
dark: (
|
|
39
|
-
border: color(color-gray),
|
|
40
|
-
background: color(color-black),
|
|
41
|
-
text: color(color-white),
|
|
42
|
-
middle-blue: color(color-blue-60),
|
|
43
|
-
light-blue: color(color-blue-10),
|
|
44
|
-
blue: color(color-blue),
|
|
45
|
-
disabled: color(color-gray),
|
|
46
|
-
selected: color(color-blue),
|
|
47
|
-
accent: color(color-red),
|
|
48
|
-
marker: color(color-green),
|
|
49
|
-
white-color: color(color-light-gray),
|
|
50
|
-
button-hover: color(color-gray),
|
|
51
|
-
overlay: color(color-dark-gray),
|
|
52
|
-
),
|
|
53
|
-
);
|
package/src/styles/_gap.scss
DELETED
package/src/styles/_globals.scss
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
@use './colors' as *;
|
|
2
|
-
@use './typography' as *;
|
|
3
|
-
@use './border' as *;
|
|
4
|
-
@use './variables' as *;
|
|
5
|
-
@use './mixins' as *;
|
|
6
|
-
@use './theme-mixins' as *;
|
|
7
|
-
|
|
8
|
-
html {
|
|
9
|
-
&.is-lock {
|
|
10
|
-
overflow: hidden;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
body {
|
|
15
|
-
font-weight: $font-weight-regular;
|
|
16
|
-
font-family: $font-family-base;
|
|
17
|
-
font-size: $font-size-14;
|
|
18
|
-
|
|
19
|
-
@include themify($themes) {
|
|
20
|
-
color: themed('text');
|
|
21
|
-
background: themed('gradient');
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
h1,
|
|
26
|
-
h2 {
|
|
27
|
-
margin: 0;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
h1 {
|
|
31
|
-
font-size: $font-size-15;
|
|
32
|
-
font-weight: $font-weight-semibold;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
h2 {
|
|
36
|
-
font-weight: $font-weight-bold;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
a,
|
|
40
|
-
button,
|
|
41
|
-
label,
|
|
42
|
-
input,
|
|
43
|
-
textarea,
|
|
44
|
-
select,
|
|
45
|
-
svg * {
|
|
46
|
-
transition:
|
|
47
|
-
color $transition-duration $easing,
|
|
48
|
-
background-color $transition-duration $easing,
|
|
49
|
-
border-color $transition-duration $easing,
|
|
50
|
-
fill $transition-duration $easing,
|
|
51
|
-
opacity $transition-duration $easing;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
a,
|
|
55
|
-
button {
|
|
56
|
-
&:has(svg) {
|
|
57
|
-
display: flex;
|
|
58
|
-
justify-content: center;
|
|
59
|
-
align-items: center;
|
|
60
|
-
}
|
|
61
|
-
}
|
package/src/styles/_grid.scss
DELETED
package/src/styles/_mixins.scss
DELETED
package/src/styles/_reset.scss
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
*,
|
|
2
|
-
::before,
|
|
3
|
-
::after {
|
|
4
|
-
box-sizing: border-box;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
:where(ul, ol):where([class]) {
|
|
8
|
-
padding-left: 0;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
body,
|
|
12
|
-
:where(blockquote, figure):where([class]) {
|
|
13
|
-
margin: 0;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
:where(h1, h2, h3, h4, h5, h6, p, ul, ol, dl):where([class]) {
|
|
17
|
-
margin-block: 0;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
:where(dd[class]) {
|
|
21
|
-
margin-left: 0;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
:where(fieldset[class]) {
|
|
25
|
-
margin-left: 0;
|
|
26
|
-
padding: 0;
|
|
27
|
-
border: none;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
:where(ul[class]) {
|
|
31
|
-
list-style: none;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
:where(address[class]) {
|
|
35
|
-
font-style: normal;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
p {
|
|
39
|
-
margin-block: 0;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
img,
|
|
43
|
-
video {
|
|
44
|
-
display: block;
|
|
45
|
-
max-width: 100%;
|
|
46
|
-
height: auto;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
input,
|
|
50
|
-
textarea,
|
|
51
|
-
select,
|
|
52
|
-
button {
|
|
53
|
-
font: inherit;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
html {
|
|
57
|
-
height: 100%;
|
|
58
|
-
|
|
59
|
-
scrollbar-gutter: stable;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
html,
|
|
63
|
-
:has(:target) {
|
|
64
|
-
scroll-behavior: smooth;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
body {
|
|
68
|
-
min-height: 100%;
|
|
69
|
-
|
|
70
|
-
line-height: 1.5;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
a:where([class]) {
|
|
74
|
-
display: inline-flex;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
button,
|
|
78
|
-
label {
|
|
79
|
-
cursor: pointer;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
[stroke] {
|
|
83
|
-
stroke: currentColor;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
svg * {
|
|
87
|
-
transition-property: fill, stroke;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
@media (prefers-reduced-motion: reduce) {
|
|
91
|
-
*,
|
|
92
|
-
::before,
|
|
93
|
-
::after {
|
|
94
|
-
animation-duration: 0.01ms !important;
|
|
95
|
-
animation-iteration-count: 1 !important;
|
|
96
|
-
scroll-behavior: auto !important;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
@use 'sass:map';
|
|
2
|
-
@use './colors' as *;
|
|
3
|
-
|
|
4
|
-
$theme-map: null;
|
|
5
|
-
|
|
6
|
-
@mixin themify-modules($themes) {
|
|
7
|
-
@each $theme, $map in $themes {
|
|
8
|
-
:global(.theme-#{$theme}) & {
|
|
9
|
-
$theme-map: () !global;
|
|
10
|
-
|
|
11
|
-
@each $key, $value in $map {
|
|
12
|
-
$theme-map: map.merge(
|
|
13
|
-
$theme-map,
|
|
14
|
-
(
|
|
15
|
-
$key: $value,
|
|
16
|
-
)
|
|
17
|
-
) !global;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
@content;
|
|
21
|
-
|
|
22
|
-
$theme-map: null !global;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
@mixin themify($themes) {
|
|
28
|
-
@each $theme, $map in $themes {
|
|
29
|
-
.theme-#{$theme} & {
|
|
30
|
-
$theme-map: () !global;
|
|
31
|
-
|
|
32
|
-
@each $key, $submap in $map {
|
|
33
|
-
$value: map.get(map.get($themes, $theme), $key);
|
|
34
|
-
$theme-map: map.merge(
|
|
35
|
-
$theme-map,
|
|
36
|
-
(
|
|
37
|
-
$key: $value,
|
|
38
|
-
)
|
|
39
|
-
) !global;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
@content;
|
|
43
|
-
|
|
44
|
-
$theme-map: null !global;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@function themed($key) {
|
|
50
|
-
@return map.get($theme-map, $key);
|
|
51
|
-
}
|
package/src/styles/main.scss
DELETED
package/src/types/types.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
declare module '*.module.css' {
|
|
2
|
-
const classes: { [key: string]: string };
|
|
3
|
-
export default classes;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
declare module '*.module.scss' {
|
|
7
|
-
const classes: { [key: string]: string };
|
|
8
|
-
export default classes;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
declare module '*.svg?react' {
|
|
12
|
-
import React from 'react';
|
|
13
|
-
const SVG: React.FC<React.SVGProps<SVGSVGElement>>;
|
|
14
|
-
export default SVG;
|
|
15
|
-
}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getDaysInMonth,
|
|
3
|
-
getFirstDayOfMonth,
|
|
4
|
-
getLastDayOfMonth,
|
|
5
|
-
getMonthDays,
|
|
6
|
-
getWeekDayIndex,
|
|
7
|
-
getWeekDays,
|
|
8
|
-
getWeeksFromDays,
|
|
9
|
-
} from './calendar';
|
|
10
|
-
|
|
11
|
-
describe('getFirstDayOfMonth:', () => {
|
|
12
|
-
it('returns the first day of month', () => {
|
|
13
|
-
const result = getFirstDayOfMonth(new Date(2026, 8, 18));
|
|
14
|
-
expect(result.getMonth()).toBe(8);
|
|
15
|
-
expect(result.getDate()).toBe(1);
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
describe('getLastDayOfMonth:', () => {
|
|
20
|
-
it('returns the last day of month', () => {
|
|
21
|
-
const result = getLastDayOfMonth(new Date(2026, 0, 10));
|
|
22
|
-
expect(result.getDate()).toBe(31);
|
|
23
|
-
expect(result.getMonth()).toBe(0);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('handles February in a leap year', () => {
|
|
27
|
-
const result = getLastDayOfMonth(new Date(2024, 1, 1));
|
|
28
|
-
expect(result.getDate()).toBe(29);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('handles February in a non-leap year', () => {
|
|
32
|
-
const result = getLastDayOfMonth(new Date(2025, 1, 1));
|
|
33
|
-
expect(result.getDate()).toBe(28);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
describe('getDaysInMonth:', () => {
|
|
38
|
-
it('returns count of days in the month', () => {
|
|
39
|
-
expect(getDaysInMonth(new Date(2026, 8, 1))).toBe(30);
|
|
40
|
-
expect(getDaysInMonth(new Date(2026, 7, 1))).toBe(31);
|
|
41
|
-
expect(getDaysInMonth(new Date(2026, 6, 1))).toBe(31);
|
|
42
|
-
expect(getDaysInMonth(new Date(2023, 5, 1))).toBe(30);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
describe('getWeekDayIndex:', () => {
|
|
47
|
-
it('return 0 for Sunday if the first of week is 0', () => {
|
|
48
|
-
const sunday = new Date(2026, 8, 6);
|
|
49
|
-
expect(getWeekDayIndex(sunday, 0)).toBe(0);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('return 1 for Monday if the first of week is 0', () => {
|
|
53
|
-
const monday = new Date(2026, 8, 7);
|
|
54
|
-
expect(getWeekDayIndex(monday, 0)).toBe(1);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('return 6 for Sunday if the first of week is 1', () => {
|
|
58
|
-
const sunday = new Date(2026, 8, 6);
|
|
59
|
-
expect(getWeekDayIndex(sunday, 1)).toBe(6);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('return 0 for Monday if the first of week is 1', () => {
|
|
63
|
-
const monday = new Date(2026, 8, 7);
|
|
64
|
-
expect(getWeekDayIndex(monday, 1)).toBe(0);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('uses firstDayOfWeek = 1 by default', () => {
|
|
68
|
-
const monday = new Date(2026, 8, 7);
|
|
69
|
-
expect(getWeekDayIndex(monday)).toBe(0);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
describe('getMonthDays:', () => {
|
|
74
|
-
it('returns a grid with a step of 7', () => {
|
|
75
|
-
const result = getMonthDays(new Date(2026, 8, 1));
|
|
76
|
-
expect(result.length % 7).toBe(0);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('includes all month days', () => {
|
|
80
|
-
const result = getMonthDays(new Date(2026, 8, 1));
|
|
81
|
-
const daysInCurrentMonth = result.filter(
|
|
82
|
-
(day) => day.getMonth() === 8 && day.getFullYear() === 2026
|
|
83
|
-
);
|
|
84
|
-
expect(daysInCurrentMonth.length).toBe(30);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('the first day of a grid is Monday if firstDayOfWeek = 1', () => {
|
|
88
|
-
const result = getMonthDays(new Date(2026, 8, 1), 1);
|
|
89
|
-
expect(result[0].getDay()).toBe(1);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it('the first day of a grid is Sunday if firstDayOfWeek = 0', () => {
|
|
93
|
-
const result = getMonthDays(new Date(2026, 8, 1), 0);
|
|
94
|
-
expect(result[0].getDay()).toBe(0);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('correctly adds days of the previous and the next monthes', () => {
|
|
98
|
-
const result = getMonthDays(new Date(2026, 7, 1), 1);
|
|
99
|
-
expect(result[0].getMonth()).toBe(6);
|
|
100
|
-
expect(result[4].getMonth()).toBe(6);
|
|
101
|
-
expect(result[result.length - 1].getMonth()).toBe(8);
|
|
102
|
-
expect(result[result.length - 6].getMonth()).toBe(8);
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
describe('getWeeksFromDays:', () => {
|
|
107
|
-
const mockDays: Date[] = Array.from(
|
|
108
|
-
{ length: 30 },
|
|
109
|
-
(_, i) => new Date(2026, 8, i + 1)
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
it('splits the array of days into weeks of 7', () => {
|
|
113
|
-
const weeks = getWeeksFromDays(mockDays, 7);
|
|
114
|
-
expect(weeks.length).toBe(5);
|
|
115
|
-
expect(weeks[0].length).toBe(7);
|
|
116
|
-
expect(weeks[3].length).toBe(7);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it('splits the array of days into weeks of 5', () => {
|
|
120
|
-
const weeks = getWeeksFromDays(mockDays, 5);
|
|
121
|
-
weeks.forEach((week) => expect(week.length).toBe(5));
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('handles correctly the last incomplete week', () => {
|
|
125
|
-
const weeks = getWeeksFromDays(mockDays);
|
|
126
|
-
expect(weeks[0].length).toBe(7);
|
|
127
|
-
expect(weeks[4].length).toBe(2);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it('returns emply array for an empty entry array', () => {
|
|
131
|
-
expect(getWeeksFromDays([], 7)).toEqual([]);
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
describe('getWeekDays:', () => {
|
|
136
|
-
it('return 7 days', () => {
|
|
137
|
-
const result = getWeekDays(new Date(2026, 8, 16));
|
|
138
|
-
expect(result.length).toBe(7);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it('starts from Monday if firstDayOfWeek = 1', () => {
|
|
142
|
-
const wednesday = new Date(2026, 8, 16);
|
|
143
|
-
const result = getWeekDays(wednesday, 1);
|
|
144
|
-
expect(result[0].getDay()).toBe(1);
|
|
145
|
-
expect(result[0].getDate()).toBe(14);
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it('starts from Sunday if firstDayOfWeek = 0', () => {
|
|
149
|
-
const wednesday = new Date(2026, 8, 16);
|
|
150
|
-
const result = getWeekDays(wednesday, 0);
|
|
151
|
-
expect(result[0].getDay()).toBe(0);
|
|
152
|
-
expect(result[0].getDate()).toBe(13);
|
|
153
|
-
});
|
|
154
|
-
});
|
package/src/utils/calendar.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
export const getFirstDayOfMonth = (date: Date): Date => {
|
|
2
|
-
return new Date(date.getFullYear(), date.getMonth(), 1);
|
|
3
|
-
};
|
|
4
|
-
|
|
5
|
-
export const getLastDayOfMonth = (date: Date): Date => {
|
|
6
|
-
return new Date(date.getFullYear(), date.getMonth() + 1, 0);
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const getDaysInMonth = (date: Date): number => {
|
|
10
|
-
return getLastDayOfMonth(date).getDate();
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const getWeekDayIndex = (
|
|
14
|
-
date: Date,
|
|
15
|
-
firstDayOfWeek: 0 | 1 = 1
|
|
16
|
-
): number => {
|
|
17
|
-
let index = date.getDay();
|
|
18
|
-
if (firstDayOfWeek === 1) {
|
|
19
|
-
index = index === 0 ? 6 : index - 1;
|
|
20
|
-
}
|
|
21
|
-
return index;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const getMonthDays = (date: Date, firstDayOfWeek: 0 | 1 = 1): Date[] => {
|
|
25
|
-
const year = date.getFullYear();
|
|
26
|
-
const month = date.getMonth();
|
|
27
|
-
|
|
28
|
-
const firstDay = getFirstDayOfMonth(date);
|
|
29
|
-
const daysInMonth = getDaysInMonth(date);
|
|
30
|
-
const firstDayIndex = getWeekDayIndex(firstDay, firstDayOfWeek);
|
|
31
|
-
|
|
32
|
-
const totalDays = Math.ceil((firstDayIndex + daysInMonth) / 7) * 7;
|
|
33
|
-
const days: Date[] = [];
|
|
34
|
-
|
|
35
|
-
for (let i = 0; i < firstDayIndex; i++) {
|
|
36
|
-
days.push(new Date(year, month, 1 - firstDayIndex + i));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
for (let i = 1; i <= daysInMonth; i++) {
|
|
40
|
-
days.push(new Date(year, month, i));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const remaining = totalDays - days.length;
|
|
44
|
-
for (let i = 1; i <= remaining; i++) {
|
|
45
|
-
days.push(new Date(year, month + 1, i));
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return days;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export const getWeeksFromDays = (
|
|
52
|
-
days: Date[],
|
|
53
|
-
weekLength: 5 | 7 = 7
|
|
54
|
-
): Date[][] => {
|
|
55
|
-
const weeks: Date[][] = [];
|
|
56
|
-
for (let i = 0; i < days.length; i += weekLength) {
|
|
57
|
-
weeks.push(days.slice(i, i + weekLength));
|
|
58
|
-
}
|
|
59
|
-
return weeks;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export const getWeekDays = (date: Date, firstDayOfWeek: 0 | 1 = 1): Date[] => {
|
|
63
|
-
const year = date.getFullYear();
|
|
64
|
-
const month = date.getMonth();
|
|
65
|
-
const day = date.getDate();
|
|
66
|
-
|
|
67
|
-
const currentDayOfWeek = date.getDay();
|
|
68
|
-
|
|
69
|
-
const offset =
|
|
70
|
-
firstDayOfWeek === 1 ? (currentDayOfWeek + 6) % 7 : currentDayOfWeek;
|
|
71
|
-
|
|
72
|
-
const startDate = new Date(year, month, day - offset);
|
|
73
|
-
|
|
74
|
-
const weekDays: Date[] = [];
|
|
75
|
-
for (let i = 0; i < 7; i++) {
|
|
76
|
-
const newDate = new Date(startDate);
|
|
77
|
-
newDate.setDate(startDate.getDate() + i);
|
|
78
|
-
weekDays.push(newDate);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return weekDays;
|
|
82
|
-
};
|
package/src/utils/controlDate.ts
DELETED