@daryasidorovich/modsen-datepicker 1.0.0 → 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/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/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/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
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import classNames from 'classnames';
|
|
2
|
-
|
|
3
|
-
import { isToday } from '@/utils/dateChecks';
|
|
4
|
-
|
|
5
|
-
import styles from './styles.module.scss';
|
|
6
|
-
|
|
7
|
-
export interface DayProps {
|
|
8
|
-
date: Date;
|
|
9
|
-
isSelected?: boolean;
|
|
10
|
-
isDisabled?: boolean;
|
|
11
|
-
isHoliday?: boolean;
|
|
12
|
-
hasTasks?: boolean;
|
|
13
|
-
isRangeStart?: boolean;
|
|
14
|
-
isRangeEnd?: boolean;
|
|
15
|
-
isRangeMiddle?: boolean;
|
|
16
|
-
isCurrentMonth: boolean;
|
|
17
|
-
onClick?: (e: React.MouseEvent<HTMLButtonElement>, date: Date) => void;
|
|
18
|
-
onDoubleClick?: (date: Date) => void;
|
|
19
|
-
onMouseEnter?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
20
|
-
onMouseLeave?: () => void;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const Day = ({
|
|
24
|
-
date,
|
|
25
|
-
isSelected = false,
|
|
26
|
-
isCurrentMonth,
|
|
27
|
-
isDisabled = false,
|
|
28
|
-
isHoliday = false,
|
|
29
|
-
hasTasks = false,
|
|
30
|
-
isRangeStart = false,
|
|
31
|
-
isRangeEnd = false,
|
|
32
|
-
isRangeMiddle = false,
|
|
33
|
-
onClick,
|
|
34
|
-
onDoubleClick,
|
|
35
|
-
onMouseEnter,
|
|
36
|
-
onMouseLeave,
|
|
37
|
-
}: DayProps) => {
|
|
38
|
-
const dayNumber = date.getDate();
|
|
39
|
-
let clickTimeout: ReturnType<typeof setTimeout> | null = null;
|
|
40
|
-
|
|
41
|
-
const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {
|
|
42
|
-
if (clickTimeout) {
|
|
43
|
-
clearTimeout(clickTimeout);
|
|
44
|
-
}
|
|
45
|
-
clickTimeout = setTimeout(() => {
|
|
46
|
-
if (!isDisabled && onClick) {
|
|
47
|
-
onClick(e, date);
|
|
48
|
-
}
|
|
49
|
-
clickTimeout = null;
|
|
50
|
-
}, 250);
|
|
51
|
-
};
|
|
52
|
-
const handleDoubleClick = () => {
|
|
53
|
-
if (clickTimeout) {
|
|
54
|
-
clearTimeout(clickTimeout);
|
|
55
|
-
}
|
|
56
|
-
if (!isDisabled && onDoubleClick) {
|
|
57
|
-
onDoubleClick(date);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const handleMouseEnter = (e: React.MouseEvent<HTMLButtonElement>) => {
|
|
62
|
-
if (!isDisabled && onMouseEnter) {
|
|
63
|
-
onMouseEnter(e);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const handleMouseLeave = () => {
|
|
68
|
-
if (!isDisabled && onMouseLeave) {
|
|
69
|
-
onMouseLeave();
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
return (
|
|
74
|
-
<button
|
|
75
|
-
className={classNames(styles.day, {
|
|
76
|
-
[styles.today]: isToday(date),
|
|
77
|
-
[styles.selected]: isSelected,
|
|
78
|
-
[styles.disabled]: isDisabled,
|
|
79
|
-
[styles.holiday]: isHoliday,
|
|
80
|
-
[styles.hasTasks]: hasTasks,
|
|
81
|
-
[styles.rangeStart]: isRangeStart,
|
|
82
|
-
[styles.rangeEnd]: isRangeEnd,
|
|
83
|
-
[styles.rangeMiddle]: isRangeMiddle,
|
|
84
|
-
[styles.otherMonth]: !isCurrentMonth,
|
|
85
|
-
})}
|
|
86
|
-
onClick={handleClick}
|
|
87
|
-
onDoubleClick={handleDoubleClick}
|
|
88
|
-
onMouseEnter={handleMouseEnter}
|
|
89
|
-
onMouseLeave={handleMouseLeave}
|
|
90
|
-
disabled={isDisabled}
|
|
91
|
-
>
|
|
92
|
-
<span className={styles.number}>{dayNumber}</span>
|
|
93
|
-
</button>
|
|
94
|
-
);
|
|
95
|
-
};
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
.day {
|
|
2
|
-
@include square(32px);
|
|
3
|
-
|
|
4
|
-
@include themify-modules($themes) {
|
|
5
|
-
background-color: themed('background');
|
|
6
|
-
color: themed('text');
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
font-size: $font-size-13;
|
|
10
|
-
padding: $gap-10;
|
|
11
|
-
border-radius: $radius-8;
|
|
12
|
-
display: flex;
|
|
13
|
-
align-items: center;
|
|
14
|
-
justify-content: center;
|
|
15
|
-
font-weight: $font-weight-semibold;
|
|
16
|
-
border: none;
|
|
17
|
-
position: relative;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.holiday {
|
|
21
|
-
@include themify-modules($themes) {
|
|
22
|
-
color: themed('accent');
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.today {
|
|
27
|
-
@include themify-modules($themes) {
|
|
28
|
-
color: themed('selected');
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.selected {
|
|
33
|
-
@include themify-modules($themes) {
|
|
34
|
-
background-color: themed('selected');
|
|
35
|
-
color: themed('white-color');
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.disabled {
|
|
40
|
-
@include themify-modules($themes) {
|
|
41
|
-
color: themed('disabled');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
cursor: not-allowed;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.otherMonth {
|
|
48
|
-
@include themify-modules($themes) {
|
|
49
|
-
color: themed('disabled');
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.rangeStart {
|
|
54
|
-
@include themify-modules($themes) {
|
|
55
|
-
color: themed('white-color');
|
|
56
|
-
background-color: themed('middle-blue');
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
border-top-right-radius: 0;
|
|
60
|
-
border-bottom-right-radius: 0;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.rangeMiddle {
|
|
64
|
-
@include themify-modules($themes) {
|
|
65
|
-
color: themed('blue');
|
|
66
|
-
background-color: themed('light-blue');
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
border-radius: 0;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.rangeEnd {
|
|
73
|
-
@include themify-modules($themes) {
|
|
74
|
-
color: themed('white-color');
|
|
75
|
-
background-color: themed('selected');
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
border-top-left-radius: 0;
|
|
79
|
-
border-bottom-left-radius: 0;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.hasTasks {
|
|
83
|
-
position: relative;
|
|
84
|
-
&::after {
|
|
85
|
-
@include square(4px);
|
|
86
|
-
|
|
87
|
-
@include themify-modules($themes) {
|
|
88
|
-
background-color: themed('marker');
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
content: '';
|
|
92
|
-
position: absolute;
|
|
93
|
-
top: 12%;
|
|
94
|
-
right: 12%;
|
|
95
|
-
border-radius: 100%;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { Input } from '.';
|
|
3
|
-
|
|
4
|
-
const meta: Meta<typeof Input> = {
|
|
5
|
-
component: Input,
|
|
6
|
-
parameters: {
|
|
7
|
-
layout: 'centered',
|
|
8
|
-
},
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export default meta;
|
|
12
|
-
|
|
13
|
-
type Story = StoryObj<typeof Input>;
|
|
14
|
-
|
|
15
|
-
export const Default: Story = {
|
|
16
|
-
args: {
|
|
17
|
-
label: 'Title',
|
|
18
|
-
placeholder: 'Enter title',
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const DefaultDate: Story = {
|
|
23
|
-
args: {
|
|
24
|
-
label: 'Date',
|
|
25
|
-
placeholder: 'Date input...',
|
|
26
|
-
isDateInput: true,
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export const WithError: Story = {
|
|
31
|
-
args: {
|
|
32
|
-
label: 'Date',
|
|
33
|
-
value: '45',
|
|
34
|
-
error: 'Invalid date',
|
|
35
|
-
isDateInput: true,
|
|
36
|
-
},
|
|
37
|
-
};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import Calendar from '@assets/input/Calendar.svg?react';
|
|
2
|
-
import Clear from '@assets/input/Clear.svg?react';
|
|
3
|
-
import classNames from 'classnames';
|
|
4
|
-
import { InputHTMLAttributes, Ref, useId } from 'react';
|
|
5
|
-
|
|
6
|
-
import styles from './styles.module.scss';
|
|
7
|
-
|
|
8
|
-
interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
9
|
-
label?: string;
|
|
10
|
-
error?: string;
|
|
11
|
-
onReset?: () => void;
|
|
12
|
-
ref?: Ref<HTMLInputElement>;
|
|
13
|
-
isDateInput?: boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const Input = ({
|
|
17
|
-
label,
|
|
18
|
-
error,
|
|
19
|
-
className = '',
|
|
20
|
-
id,
|
|
21
|
-
onReset,
|
|
22
|
-
placeholder,
|
|
23
|
-
type = 'text',
|
|
24
|
-
isDateInput = false,
|
|
25
|
-
ref = null,
|
|
26
|
-
...restProps
|
|
27
|
-
}: InputProps) => {
|
|
28
|
-
const generatedId = useId();
|
|
29
|
-
const inputId = id || `input-${generatedId}`;
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<div className={styles.wrapper}>
|
|
33
|
-
{label && (
|
|
34
|
-
<label htmlFor={inputId} className={styles.label}>
|
|
35
|
-
{label}
|
|
36
|
-
</label>
|
|
37
|
-
)}
|
|
38
|
-
|
|
39
|
-
<div
|
|
40
|
-
className={classNames(styles.inputWrapper, {
|
|
41
|
-
[styles.errorWrapper]: error,
|
|
42
|
-
})}
|
|
43
|
-
>
|
|
44
|
-
{isDateInput && <Calendar className={styles.icon} />}
|
|
45
|
-
<input
|
|
46
|
-
id={inputId}
|
|
47
|
-
type={type}
|
|
48
|
-
ref={ref}
|
|
49
|
-
placeholder={placeholder}
|
|
50
|
-
className={classNames(styles.input, className)}
|
|
51
|
-
{...restProps}
|
|
52
|
-
/>
|
|
53
|
-
|
|
54
|
-
{isDateInput && onReset && (
|
|
55
|
-
<button className={styles.clear} onClick={onReset} type="button">
|
|
56
|
-
<Clear className={styles.icon} />
|
|
57
|
-
</button>
|
|
58
|
-
)}
|
|
59
|
-
</div>
|
|
60
|
-
|
|
61
|
-
<span className={styles.error}>{error ?? ''}</span>
|
|
62
|
-
</div>
|
|
63
|
-
);
|
|
64
|
-
};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
.wrapper {
|
|
2
|
-
@include themify-modules($themes) {
|
|
3
|
-
color: themed('text');
|
|
4
|
-
background-color: themed('background');
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
display: flex;
|
|
8
|
-
flex-direction: column;
|
|
9
|
-
align-items: start;
|
|
10
|
-
gap: 2px;
|
|
11
|
-
width: 100%;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.label {
|
|
15
|
-
font-size: $font-size-15;
|
|
16
|
-
font-weight: $font-weight-semibold;
|
|
17
|
-
margin-bottom: $gap-8;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.inputWrapper {
|
|
21
|
-
@include themify-modules($themes) {
|
|
22
|
-
color: themed('text');
|
|
23
|
-
background-color: themed('background');
|
|
24
|
-
border-color: themed('border');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
@include border;
|
|
28
|
-
|
|
29
|
-
padding: $gap-8 15px;
|
|
30
|
-
border-radius: $radius-8;
|
|
31
|
-
display: flex;
|
|
32
|
-
gap: $gap-8;
|
|
33
|
-
justify-content: space-between;
|
|
34
|
-
align-items: center;
|
|
35
|
-
width: 100%;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.errorWrapper {
|
|
39
|
-
@include themify-modules($themes) {
|
|
40
|
-
border-color: themed('accent');
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.input {
|
|
45
|
-
border: none;
|
|
46
|
-
outline: none;
|
|
47
|
-
background-color: transparent;
|
|
48
|
-
width: 100%;
|
|
49
|
-
|
|
50
|
-
@include themify-modules($themes) {
|
|
51
|
-
color: themed('text');
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
&::placeholder {
|
|
55
|
-
@include themify-modules($themes) {
|
|
56
|
-
color: themed('border');
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.clear {
|
|
62
|
-
border: none;
|
|
63
|
-
background-color: transparent;
|
|
64
|
-
width: max-content;
|
|
65
|
-
padding: 0;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.icon {
|
|
69
|
-
@include themify-modules($themes) {
|
|
70
|
-
color: themed('disabled');
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.error {
|
|
75
|
-
@include themify-modules($themes) {
|
|
76
|
-
color: themed('accent');
|
|
77
|
-
}
|
|
78
|
-
height: 15px;
|
|
79
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import classNames from 'classnames';
|
|
2
|
-
|
|
3
|
-
import { Modal } from '..';
|
|
4
|
-
import { CrudModalProps } from '../types';
|
|
5
|
-
import styles from './styles.module.scss';
|
|
6
|
-
|
|
7
|
-
export const CrudModal = ({
|
|
8
|
-
isOpen,
|
|
9
|
-
onClose,
|
|
10
|
-
onConfirm,
|
|
11
|
-
title,
|
|
12
|
-
cancelText = 'No',
|
|
13
|
-
confirmText = 'Yes',
|
|
14
|
-
isLoading = false,
|
|
15
|
-
children,
|
|
16
|
-
showCloseButton = false,
|
|
17
|
-
}: CrudModalProps) => {
|
|
18
|
-
return (
|
|
19
|
-
<Modal isOpen={isOpen} onClose={onClose} showCloseButton={showCloseButton}>
|
|
20
|
-
<div className={styles.header}>
|
|
21
|
-
<h1 className={styles.title}>{title}</h1>
|
|
22
|
-
</div>
|
|
23
|
-
|
|
24
|
-
{children && <div className={styles.children}>{children}</div>}
|
|
25
|
-
|
|
26
|
-
<div className={styles.footer}>
|
|
27
|
-
<button
|
|
28
|
-
className={styles.modalButtons}
|
|
29
|
-
onClick={onClose}
|
|
30
|
-
disabled={isLoading}
|
|
31
|
-
>
|
|
32
|
-
{cancelText}
|
|
33
|
-
</button>
|
|
34
|
-
<button
|
|
35
|
-
className={classNames(styles.confirm, styles.modalButtons)}
|
|
36
|
-
onClick={onConfirm}
|
|
37
|
-
>
|
|
38
|
-
{confirmText}
|
|
39
|
-
</button>
|
|
40
|
-
</div>
|
|
41
|
-
</Modal>
|
|
42
|
-
);
|
|
43
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
.header {
|
|
2
|
-
margin-bottom: $gap-24;
|
|
3
|
-
margin-top: $gap-8;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.title {
|
|
7
|
-
font-size: $font-size-18;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.footer {
|
|
11
|
-
display: flex;
|
|
12
|
-
width: 100%;
|
|
13
|
-
gap: $gap-10;
|
|
14
|
-
justify-content: end;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.children {
|
|
18
|
-
display: flex;
|
|
19
|
-
gap: $gap-8;
|
|
20
|
-
flex-direction: column;
|
|
21
|
-
min-width: 300px;
|
|
22
|
-
width: fit-content;
|
|
23
|
-
margin-bottom: $gap-24;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.modalButtons {
|
|
27
|
-
@include themify-modules($themes) {
|
|
28
|
-
background-color: themed('light-blue');
|
|
29
|
-
border-color: themed('border');
|
|
30
|
-
color: themed('text');
|
|
31
|
-
}
|
|
32
|
-
@include border;
|
|
33
|
-
|
|
34
|
-
padding: $gap-5 $gap-10;
|
|
35
|
-
border-radius: $radius-8;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.confirm {
|
|
39
|
-
@include themify-modules($themes) {
|
|
40
|
-
background-color: themed('middle-blue');
|
|
41
|
-
border-color: themed('border');
|
|
42
|
-
color: themed('white-color');
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import classNames from 'classnames';
|
|
2
|
-
import React, { ReactNode, useRef } from 'react';
|
|
3
|
-
import { createPortal } from 'react-dom';
|
|
4
|
-
|
|
5
|
-
import useLockBodyScroll from '@/hooks/useLockBodyScroll';
|
|
6
|
-
|
|
7
|
-
import styles from './styles.module.scss';
|
|
8
|
-
|
|
9
|
-
export interface ModalProps {
|
|
10
|
-
isOpen: boolean;
|
|
11
|
-
onClose: () => void;
|
|
12
|
-
children: ReactNode;
|
|
13
|
-
showCloseButton?: boolean;
|
|
14
|
-
showOverlay?: boolean;
|
|
15
|
-
className?: string;
|
|
16
|
-
classNameOverlay?: string;
|
|
17
|
-
style?: React.CSSProperties;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const Modal = ({
|
|
21
|
-
isOpen,
|
|
22
|
-
onClose,
|
|
23
|
-
children,
|
|
24
|
-
showOverlay = true,
|
|
25
|
-
showCloseButton = true,
|
|
26
|
-
className = '',
|
|
27
|
-
classNameOverlay = '',
|
|
28
|
-
style = {},
|
|
29
|
-
}: ModalProps) => {
|
|
30
|
-
const modalRoot = document.body;
|
|
31
|
-
const targetElement = modalRoot || document.body;
|
|
32
|
-
const modalRef = useRef(null);
|
|
33
|
-
useLockBodyScroll(isOpen);
|
|
34
|
-
|
|
35
|
-
const handleClick = (e: React.MouseEvent<HTMLDivElement>) => {
|
|
36
|
-
if (e.target === e.currentTarget) {
|
|
37
|
-
onClose();
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
if (!isOpen) return null;
|
|
42
|
-
|
|
43
|
-
const modalContent = (
|
|
44
|
-
<div
|
|
45
|
-
className={classNames(styles.overlay, classNameOverlay, {
|
|
46
|
-
[styles.overlayColor]: showOverlay,
|
|
47
|
-
})}
|
|
48
|
-
onClick={handleClick}
|
|
49
|
-
>
|
|
50
|
-
<div
|
|
51
|
-
ref={modalRef}
|
|
52
|
-
className={classNames(styles.modal, className)}
|
|
53
|
-
style={style}
|
|
54
|
-
>
|
|
55
|
-
{showCloseButton && (
|
|
56
|
-
<button className={styles.closeButton} onClick={onClose}>
|
|
57
|
-
<span>×</span>
|
|
58
|
-
</button>
|
|
59
|
-
)}
|
|
60
|
-
{children}
|
|
61
|
-
</div>
|
|
62
|
-
</div>
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
return createPortal(modalContent, targetElement);
|
|
66
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
.overlay {
|
|
2
|
-
position: fixed;
|
|
3
|
-
inset: 0;
|
|
4
|
-
display: flex;
|
|
5
|
-
align-items: center;
|
|
6
|
-
justify-content: center;
|
|
7
|
-
z-index: $z-index-10;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.overlayColor {
|
|
11
|
-
@include themify-modules($themes) {
|
|
12
|
-
background-color: themed('overlay');
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.modal {
|
|
17
|
-
position: relative;
|
|
18
|
-
@include themify-modules($themes) {
|
|
19
|
-
background-color: themed('background');
|
|
20
|
-
border-color: themed('border');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@include border;
|
|
24
|
-
border-radius: $radius-8;
|
|
25
|
-
padding: $gap-24;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.closeButton {
|
|
29
|
-
border: none;
|
|
30
|
-
background-color: transparent;
|
|
31
|
-
position: absolute;
|
|
32
|
-
right: $gap-8;
|
|
33
|
-
top: 0;
|
|
34
|
-
font-size: 24px;
|
|
35
|
-
line-height: normal;
|
|
36
|
-
|
|
37
|
-
@include themify-modules($themes) {
|
|
38
|
-
color: themed('text');
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
export interface CrudModalProps {
|
|
4
|
-
isOpen: boolean;
|
|
5
|
-
onClose: () => void;
|
|
6
|
-
onConfirm: () => void;
|
|
7
|
-
title: string;
|
|
8
|
-
children?: ReactNode;
|
|
9
|
-
cancelText?: string;
|
|
10
|
-
confirmText?: string;
|
|
11
|
-
isLoading?: boolean;
|
|
12
|
-
showCloseButton?: boolean;
|
|
13
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { Month } from '.';
|
|
3
|
-
|
|
4
|
-
const meta: Meta<typeof Month> = {
|
|
5
|
-
component: Month,
|
|
6
|
-
parameters: {
|
|
7
|
-
layout: 'centered',
|
|
8
|
-
},
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export default meta;
|
|
12
|
-
|
|
13
|
-
type Story = StoryObj<typeof Month>;
|
|
14
|
-
|
|
15
|
-
export const Default: Story = {
|
|
16
|
-
args: {
|
|
17
|
-
date: new Date(),
|
|
18
|
-
},
|
|
19
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import Next from '@assets/arrows/Next.svg?react';
|
|
2
|
-
import Prev from '@assets/arrows/Prev.svg?react';
|
|
3
|
-
|
|
4
|
-
import { MONTHS_NAMES } from '@/constants/monthsNames';
|
|
5
|
-
|
|
6
|
-
import styles from './styles.module.scss';
|
|
7
|
-
|
|
8
|
-
interface MonthProps {
|
|
9
|
-
date: Date;
|
|
10
|
-
onPrev: () => void;
|
|
11
|
-
onNext: () => void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const Month = ({ date, onPrev, onNext }: MonthProps) => {
|
|
15
|
-
const year = date.getFullYear();
|
|
16
|
-
const month = MONTHS_NAMES[date.getMonth()];
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<div className={styles.month}>
|
|
20
|
-
<button className={styles.arrow} onClick={onPrev} type="button">
|
|
21
|
-
<Prev />
|
|
22
|
-
</button>
|
|
23
|
-
<p>
|
|
24
|
-
{month} {year}
|
|
25
|
-
</p>
|
|
26
|
-
<button className={styles.arrow} onClick={onNext} type="button">
|
|
27
|
-
<Next />
|
|
28
|
-
</button>
|
|
29
|
-
</div>
|
|
30
|
-
);
|
|
31
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
.month {
|
|
2
|
-
@include themify-modules($themes) {
|
|
3
|
-
color: themed('text');
|
|
4
|
-
background-color: themed('background');
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
display: flex;
|
|
8
|
-
justify-content: space-between;
|
|
9
|
-
align-items: center;
|
|
10
|
-
width: 100%;
|
|
11
|
-
padding-block: 5px;
|
|
12
|
-
gap: 2px;
|
|
13
|
-
font-weight: $font-weight-bold;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.arrow {
|
|
17
|
-
@include themify-modules($themes) {
|
|
18
|
-
color: themed('text');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
width: max-content;
|
|
22
|
-
border: none;
|
|
23
|
-
background-color: transparent;
|
|
24
|
-
|
|
25
|
-
&:hover {
|
|
26
|
-
@include themify-modules($themes) {
|
|
27
|
-
color: themed('middle-blue');
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|