@daryasidorovich/modsen-datepicker 1.0.0

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.
Files changed (183) hide show
  1. package/.babelrc.json +7 -0
  2. package/.github/workflows/chromatic.yml +25 -0
  3. package/.github/workflows/ci.yml +56 -0
  4. package/.husky/commit-msg +1 -0
  5. package/.husky/pre-commit +1 -0
  6. package/.prettierignore +16 -0
  7. package/.prettierrc +6 -0
  8. package/.storybook/main.js +93 -0
  9. package/.storybook/preview-head.html +6 -0
  10. package/.storybook/preview.js +26 -0
  11. package/.storybook/preview.tsx +18 -0
  12. package/README.md +302 -0
  13. package/commitlint.config.js +23 -0
  14. package/dist/components/BaseCalendar/index.d.ts +2 -0
  15. package/dist/components/CalendarGrid/CalendarGridWithTasks/Tooltip/index.d.ts +8 -0
  16. package/dist/components/CalendarGrid/CalendarGridWithTasks/index.d.ts +2 -0
  17. package/dist/components/CalendarGrid/CalendarGridWithoutTasks/CalendarGridWithoutTasks.test.d.ts +1 -0
  18. package/dist/components/CalendarGrid/CalendarGridWithoutTasks/index.d.ts +4 -0
  19. package/dist/components/CalendarGrid/index.d.ts +2 -0
  20. package/dist/components/CalendarGrid/types.d.ts +21 -0
  21. package/dist/components/Clear/index.d.ts +5 -0
  22. package/dist/components/DatePicker/index.d.ts +5 -0
  23. package/dist/components/Day/index.d.ts +16 -0
  24. package/dist/components/Input/index.d.ts +10 -0
  25. package/dist/components/Modal/CrudModal/index.d.ts +2 -0
  26. package/dist/components/Modal/index.d.ts +12 -0
  27. package/dist/components/Modal/types.d.ts +12 -0
  28. package/dist/components/Month/index.d.ts +7 -0
  29. package/dist/components/RangePicker/index.d.ts +6 -0
  30. package/dist/components/TasksManager/AddModal/index.d.ts +6 -0
  31. package/dist/components/TasksManager/DeleteModal/index.d.ts +6 -0
  32. package/dist/components/TasksManager/EditModal/index.d.ts +7 -0
  33. package/dist/components/TasksManager/index.d.ts +9 -0
  34. package/dist/components/Week/index.d.ts +17 -0
  35. package/dist/components/WeekDay/index.d.ts +7 -0
  36. package/dist/constants/dateMask.d.ts +21 -0
  37. package/dist/constants/firstDayOfWeek.d.ts +5 -0
  38. package/dist/constants/holidays.d.ts +1 -0
  39. package/dist/constants/modes.d.ts +5 -0
  40. package/dist/constants/monthsNames.d.ts +1 -0
  41. package/dist/constants/weekdaysNames.d.ts +1 -0
  42. package/dist/hooks/useCalendar.d.ts +7 -0
  43. package/dist/hooks/useLockBodyScroll.d.ts +2 -0
  44. package/dist/hooks/useModal.d.ts +13 -0
  45. package/dist/hooks/useTooltip.d.ts +9 -0
  46. package/dist/hooks/useValidate.d.ts +11 -0
  47. package/dist/index.cjs +17250 -0
  48. package/dist/index.cjs.map +1 -0
  49. package/dist/index.d.ts +11 -0
  50. package/dist/index.js +17233 -0
  51. package/dist/index.js.map +1 -0
  52. package/dist/services/calendarService.d.ts +19 -0
  53. package/dist/services/decorators/withHolidays.d.ts +2 -0
  54. package/dist/services/decorators/withHolidays.test.d.ts +1 -0
  55. package/dist/services/decorators/withMinMax.d.ts +2 -0
  56. package/dist/services/decorators/withMinMax.test.d.ts +1 -0
  57. package/dist/services/holidayService.d.ts +5 -0
  58. package/dist/setupTests.d.ts +1 -0
  59. package/dist/store/localStorage.d.ts +3 -0
  60. package/dist/store/tasksStore.d.ts +8 -0
  61. package/dist/store/tasksStore.test.d.ts +1 -0
  62. package/dist/store/types.d.ts +18 -0
  63. package/dist/utils/calendar.d.ts +7 -0
  64. package/dist/utils/calendar.test.d.ts +1 -0
  65. package/dist/utils/controlDate.d.ts +1 -0
  66. package/dist/utils/dateChecks.d.ts +10 -0
  67. package/dist/utils/dateChecks.test.d.ts +1 -0
  68. package/dist/utils/formatDate.d.ts +3 -0
  69. package/dist/utils/formatDate.test.d.ts +1 -0
  70. package/dist/utils/schema.d.ts +6 -0
  71. package/dist/utils/schema.test.d.ts +1 -0
  72. package/dist/utils/weekdayOrder.d.ts +1 -0
  73. package/dist/utils/weekdayOrder.test.d.ts +1 -0
  74. package/docs/base-calendar.png +0 -0
  75. package/docs/dark-theme.png +0 -0
  76. package/docs/datepicker.png +0 -0
  77. package/docs/rangepicker-with-error.png +0 -0
  78. package/docs/rangepicker.png +0 -0
  79. package/eslint.config.ts +80 -0
  80. package/jest.config.json +21 -0
  81. package/package.json +106 -0
  82. package/rollup.config.js +65 -0
  83. package/src/assets/actions/Delete.svg +4 -0
  84. package/src/assets/actions/Edit.svg +3 -0
  85. package/src/assets/arrows/Next.svg +4 -0
  86. package/src/assets/arrows/Prev.svg +4 -0
  87. package/src/assets/input/Calendar.svg +3 -0
  88. package/src/assets/input/Clear.svg +3 -0
  89. package/src/components/BaseCalendar/BaseCalendar.stories.tsx +77 -0
  90. package/src/components/BaseCalendar/index.tsx +63 -0
  91. package/src/components/BaseCalendar/styles.module.scss +15 -0
  92. package/src/components/CalendarGrid/CalendarGrid.stories.tsx +136 -0
  93. package/src/components/CalendarGrid/CalendarGridWithTasks/Tooltip/index.tsx +27 -0
  94. package/src/components/CalendarGrid/CalendarGridWithTasks/Tooltip/styles.module.scss +9 -0
  95. package/src/components/CalendarGrid/CalendarGridWithTasks/index.tsx +51 -0
  96. package/src/components/CalendarGrid/CalendarGridWithoutTasks/CalendarGridWithoutTasks.test.tsx +223 -0
  97. package/src/components/CalendarGrid/CalendarGridWithoutTasks/index.tsx +36 -0
  98. package/src/components/CalendarGrid/CalendarGridWithoutTasks/styles.module.scss +11 -0
  99. package/src/components/CalendarGrid/index.tsx +19 -0
  100. package/src/components/CalendarGrid/types.ts +26 -0
  101. package/src/components/Clear/Clear.stories.tsx +16 -0
  102. package/src/components/Clear/index.tsx +12 -0
  103. package/src/components/Clear/styles.module.scss +34 -0
  104. package/src/components/DatePicker/DatePicker.stories.tsx +127 -0
  105. package/src/components/DatePicker/index.tsx +72 -0
  106. package/src/components/DatePicker/styles.module.scss +10 -0
  107. package/src/components/Day/Day.stories.tsx +75 -0
  108. package/src/components/Day/index.tsx +95 -0
  109. package/src/components/Day/styles.module.scss +97 -0
  110. package/src/components/Input/Input.stories.tsx +37 -0
  111. package/src/components/Input/index.tsx +64 -0
  112. package/src/components/Input/styles.module.scss +79 -0
  113. package/src/components/Modal/CrudModal/index.tsx +43 -0
  114. package/src/components/Modal/CrudModal/styles.module.scss +44 -0
  115. package/src/components/Modal/index.tsx +66 -0
  116. package/src/components/Modal/styles.module.scss +40 -0
  117. package/src/components/Modal/types.ts +13 -0
  118. package/src/components/Month/Month.stories.tsx +19 -0
  119. package/src/components/Month/index.tsx +31 -0
  120. package/src/components/Month/styles.module.scss +30 -0
  121. package/src/components/RangePicker/RangePicker.stories.tsx +134 -0
  122. package/src/components/RangePicker/index.tsx +144 -0
  123. package/src/components/RangePicker/styles.module.scss +19 -0
  124. package/src/components/TasksManager/AddModal/index.tsx +62 -0
  125. package/src/components/TasksManager/DeleteModal/index.tsx +22 -0
  126. package/src/components/TasksManager/EditModal/index.tsx +96 -0
  127. package/src/components/TasksManager/index.tsx +112 -0
  128. package/src/components/TasksManager/styles.module.scss +62 -0
  129. package/src/components/Week/Week.stories.tsx +49 -0
  130. package/src/components/Week/index.tsx +68 -0
  131. package/src/components/Week/styles.module.scss +7 -0
  132. package/src/components/WeekDay/WeekDay.stories.tsx +38 -0
  133. package/src/components/WeekDay/index.tsx +35 -0
  134. package/src/components/WeekDay/styles.module.scss +19 -0
  135. package/src/constants/dateMask.ts +23 -0
  136. package/src/constants/firstDayOfWeek.ts +7 -0
  137. package/src/constants/holidays.ts +32 -0
  138. package/src/constants/modes.ts +6 -0
  139. package/src/constants/monthsNames.ts +14 -0
  140. package/src/constants/weekdaysNames.ts +1 -0
  141. package/src/hooks/useCalendar.ts +62 -0
  142. package/src/hooks/useLockBodyScroll.ts +19 -0
  143. package/src/hooks/useModal.ts +45 -0
  144. package/src/hooks/useTooltip.ts +41 -0
  145. package/src/hooks/useValidate.ts +80 -0
  146. package/src/index.ts +15 -0
  147. package/src/services/calendarService.ts +62 -0
  148. package/src/services/decorators/withHolidays.test.ts +64 -0
  149. package/src/services/decorators/withHolidays.ts +12 -0
  150. package/src/services/decorators/withMinMax.test.ts +77 -0
  151. package/src/services/decorators/withMinMax.ts +19 -0
  152. package/src/services/holidayService.ts +56 -0
  153. package/src/setupTests.ts +1 -0
  154. package/src/store/localStorage.ts +33 -0
  155. package/src/store/tasksStore.test.tsx +208 -0
  156. package/src/store/tasksStore.tsx +146 -0
  157. package/src/store/types.ts +22 -0
  158. package/src/styles/_border.scss +9 -0
  159. package/src/styles/_colors.scss +53 -0
  160. package/src/styles/_gap.scss +4 -0
  161. package/src/styles/_globals.scss +61 -0
  162. package/src/styles/_grid.scss +9 -0
  163. package/src/styles/_mixins.scss +6 -0
  164. package/src/styles/_reset.scss +98 -0
  165. package/src/styles/_theme-mixins.scss +51 -0
  166. package/src/styles/_typography.scss +10 -0
  167. package/src/styles/_variables.scss +8 -0
  168. package/src/styles/main.scss +3 -0
  169. package/src/types/types.d.ts +15 -0
  170. package/src/utils/calendar.test.ts +154 -0
  171. package/src/utils/calendar.ts +82 -0
  172. package/src/utils/controlDate.ts +3 -0
  173. package/src/utils/dateChecks.test.ts +216 -0
  174. package/src/utils/dateChecks.ts +75 -0
  175. package/src/utils/formatDate.test.ts +57 -0
  176. package/src/utils/formatDate.ts +27 -0
  177. package/src/utils/schema.test.ts +40 -0
  178. package/src/utils/schema.ts +8 -0
  179. package/src/utils/weekdayOrder.test.ts +11 -0
  180. package/src/utils/weekdayOrder.ts +7 -0
  181. package/tsconfig.json +31 -0
  182. package/vitest.config.ts +38 -0
  183. package/vitest.shims.d.ts +1 -0
@@ -0,0 +1,19 @@
1
+ import { FIRST_DAY_OF_WEEK_TYPES } from '@/constants/firstDayOfWeek';
2
+ import { MODES_TYPES } from '@/constants/modes';
3
+ export declare class CalendarService {
4
+ monthDate: Date;
5
+ firstDayOfWeek?: FIRST_DAY_OF_WEEK_TYPES | undefined;
6
+ selectedDate?: Date | undefined;
7
+ mode: MODES_TYPES;
8
+ rangeStart?: Date | undefined;
9
+ rangeEnd?: Date | undefined;
10
+ private hideWeekends;
11
+ constructor(monthDate?: Date, firstDayOfWeek?: FIRST_DAY_OF_WEEK_TYPES | undefined, selectedDate?: Date | undefined, mode?: MODES_TYPES, rangeStart?: Date | undefined, rangeEnd?: Date | undefined);
12
+ setHideWeekends(value: boolean): this;
13
+ getDays(): Date[];
14
+ private applyFilters;
15
+ getWeeks(): Date[][];
16
+ getIsCurrentMonth: (date: Date) => boolean;
17
+ getIsDisabled: (_date: Date) => boolean;
18
+ getIsHoliday: (_date: Date) => boolean;
19
+ }
@@ -0,0 +1,2 @@
1
+ import { CalendarService } from '../calendarService';
2
+ export declare const withHolidays: (calendar: CalendarService, holidays: Date[]) => CalendarService;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { CalendarService } from '../calendarService';
2
+ export declare function withMinMax(calendar: CalendarService, minDate?: Date, maxDate?: Date): CalendarService;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export interface Holiday {
2
+ name: string;
3
+ date: string;
4
+ }
5
+ export declare const getHolidays: (year?: number, signal?: AbortSignal) => Promise<Date[]>;
@@ -0,0 +1 @@
1
+ import '@testing-library/jest-dom';
@@ -0,0 +1,3 @@
1
+ import { Task } from './types';
2
+ export declare const loadTasksFromStorage: () => Task[];
3
+ export declare const saveTasksToStorage: (tasks: Task[]) => void;
@@ -0,0 +1,8 @@
1
+ import { ReactNode } from 'react';
2
+ import { TasksContextValue } from './types';
3
+ interface TasksProviderProps {
4
+ children: ReactNode;
5
+ }
6
+ export declare const TasksProvider: ({ children }: TasksProviderProps) => import("react").JSX.Element;
7
+ export declare const useTasks: () => TasksContextValue;
8
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ export interface Task {
2
+ id: string;
3
+ date: Date;
4
+ title: string;
5
+ completed: boolean;
6
+ }
7
+ export interface TasksContextValue {
8
+ tasks: Task[];
9
+ loading: boolean;
10
+ error: string;
11
+ getTasksByDate: (date: Date) => Task[];
12
+ hasTasks: (date: Date) => boolean;
13
+ addTask: (date: Date, title: string) => Task;
14
+ editTask: (id: string, updates: Partial<Omit<Task, 'id'>>) => Task | undefined;
15
+ deleteTask: (id: string) => boolean;
16
+ toggleTask: (id: string) => Task | undefined;
17
+ loadTasks: () => void;
18
+ }
@@ -0,0 +1,7 @@
1
+ export declare const getFirstDayOfMonth: (date: Date) => Date;
2
+ export declare const getLastDayOfMonth: (date: Date) => Date;
3
+ export declare const getDaysInMonth: (date: Date) => number;
4
+ export declare const getWeekDayIndex: (date: Date, firstDayOfWeek?: 0 | 1) => number;
5
+ export declare const getMonthDays: (date: Date, firstDayOfWeek?: 0 | 1) => Date[];
6
+ export declare const getWeeksFromDays: (days: Date[], weekLength?: 5 | 7) => Date[][];
7
+ export declare const getWeekDays: (date: Date, firstDayOfWeek?: 0 | 1) => Date[];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const setControlDate: (date: Date | undefined) => Date | undefined;
@@ -0,0 +1,10 @@
1
+ export declare const isSameDay: (date1: Date, date2: Date) => boolean;
2
+ export declare const isCurrentMonth: (date: Date, monthDate: Date) => boolean;
3
+ export declare const isWeekend: (date: Date) => boolean;
4
+ export declare const isToday: (date: Date) => boolean;
5
+ export declare const isSelected: (date: Date, selectedDate?: Date) => boolean;
6
+ export declare const isDisabled: (date: Date, minDate?: Date | null, maxDate?: Date | null) => boolean;
7
+ export declare const isInRange: (date: Date, start?: Date, end?: Date) => boolean;
8
+ export declare const isRangeStart: (date: Date, start?: Date) => boolean;
9
+ export declare const isRangeEnd: (date: Date, end?: Date) => boolean;
10
+ export declare const getRangeError: (date: Date, startDate: Date) => string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export declare const formatDate: (date: Date) => string;
2
+ export declare const formatDateForInput: (date: Date) => string;
3
+ export declare const parseDate: (value: string) => Date | null;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import * as z from 'zod';
2
+ export declare const formSchema: z.ZodObject<{
3
+ title: z.ZodString;
4
+ date: z.ZodString;
5
+ }, z.core.$strip>;
6
+ export type FormData = z.infer<typeof formSchema>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const getOrderedDays: (firstDayOfWeek: 0 | 1) => Array<number>;
@@ -0,0 +1 @@
1
+ export {};
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,80 @@
1
+ import js from '@eslint/js';
2
+ import pluginImport from 'eslint-plugin-import';
3
+ import react from 'eslint-plugin-react';
4
+ import reactHooks from 'eslint-plugin-react-hooks';
5
+ import simpleImportSort from 'eslint-plugin-simple-import-sort';
6
+ import storybook from 'eslint-plugin-storybook';
7
+ import tseslint from 'typescript-eslint';
8
+
9
+ export default [
10
+ js.configs.recommended,
11
+ ...tseslint.configs.recommended,
12
+ {
13
+ files: ['**/*.{ts,tsx,js,jsx}'],
14
+ plugins: {
15
+ react: react,
16
+ 'react-hooks': reactHooks,
17
+ 'simple-import-sort': simpleImportSort,
18
+ import: pluginImport,
19
+ },
20
+ rules: {
21
+ 'react/react-in-jsx-scope': 'off',
22
+ 'react-hooks/rules-of-hooks': 'error',
23
+ 'react-hooks/exhaustive-deps': 'warn',
24
+ 'simple-import-sort/imports': 'error',
25
+ 'simple-import-sort/exports': 'error',
26
+ '@typescript-eslint/no-unused-vars': [
27
+ 'error',
28
+ { argsIgnorePattern: '^_' },
29
+ ],
30
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
31
+ 'react/destructuring-assignment': ['error', 'always'],
32
+ 'prefer-destructuring': [
33
+ 'error',
34
+ {
35
+ VariableDeclarator: { array: false, object: true },
36
+ AssignmentExpression: { array: false, object: false },
37
+ },
38
+ ],
39
+ },
40
+ settings: {
41
+ react: {
42
+ version: 'detect',
43
+ },
44
+ 'import/resolver': {
45
+ alias: {
46
+ map: [
47
+ ['@', './src'],
48
+ ['@components', './src/components'],
49
+ ['@utils', './src/utils'],
50
+ ['@styles', './src/styles'],
51
+ ['@assets', './src/assets'],
52
+ ],
53
+ extensions: ['.ts', '.tsx', '.js', '.jsx'],
54
+ },
55
+ },
56
+ },
57
+ languageOptions: {
58
+ ecmaVersion: 2022,
59
+ sourceType: 'module',
60
+ parserOptions: {
61
+ ecmaFeatures: {
62
+ jsx: true,
63
+ },
64
+ },
65
+
66
+ globals: {
67
+ process: 'readonly',
68
+ },
69
+ },
70
+ },
71
+ {
72
+ ignores: [
73
+ 'dist/**',
74
+ 'node_modules/**',
75
+ '**/*.test.tsx',
76
+ '**/*.stories.tsx',
77
+ ],
78
+ },
79
+ ...storybook.configs['flat/recommended'],
80
+ ];
@@ -0,0 +1,21 @@
1
+ {
2
+ "clearMocks": true,
3
+ "logHeapUsage": true,
4
+ "passWithNoTests": true,
5
+ "testEnvironment": "jsdom",
6
+ "transform": {
7
+ "^.+\\.(ts|tsx|js|jsx)$": "babel-jest"
8
+ },
9
+ "transformIgnorePatterns": ["node_modules/(?!(react|react-dom)/)"],
10
+ "moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json"],
11
+ "setupFilesAfterEnv": ["<rootDir>/src/setupTests.ts"],
12
+ "moduleNameMapper": {
13
+ "^@/(.*)$": "<rootDir>/src/$1",
14
+ "^@components/(.*)$": "<rootDir>/src/components/$1",
15
+ "^@utils/(.*)$": "<rootDir>/src/utils/$1",
16
+ "^@store/(.*)$": "<rootDir>/src/store/$1",
17
+ "^@styles/(.*)$": "<rootDir>/src/styles/$1",
18
+ "^@assets/(.*)$": "<rootDir>/src/assets/$1",
19
+ "\\.(css|less|scss|sass)$": "identity-obj-proxy"
20
+ }
21
+ }
package/package.json ADDED
@@ -0,0 +1,106 @@
1
+ {
2
+ "name": "@daryasidorovich/modsen-datepicker",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.esm.js",
7
+ "typings": "types.d.ts",
8
+ "style": "index.css",
9
+ "scripts": {
10
+ "clean": "rimraf dist lib",
11
+ "build": "npm run clean && rollup -c --bundleConfigAsCjs",
12
+ "pack": "npm run build && npm pack",
13
+ "dev": "rollup -c -w",
14
+ "storybook": "storybook dev -p 6006",
15
+ "build-storybook": "storybook build",
16
+ "lint": "eslint src/ --ext .ts,.tsx",
17
+ "lint:fix": "eslint src/ --ext .ts,.tsx --fix",
18
+ "format": "prettier . --write",
19
+ "format:check": "prettier . --check",
20
+ "test": "jest",
21
+ "test:watch": "jest --watch",
22
+ "test:coverage": "jest --coverage",
23
+ "chromatic": "npx chromatic --project-token=chpt_0fa93e1434c19df",
24
+ "prepare": "husky"
25
+ },
26
+ "lint-staged": {
27
+ "src/**/*.{js,jsx,ts,tsx}": [
28
+ "eslint --fix",
29
+ "prettier --write"
30
+ ],
31
+ "src/**/*.{scss,css}": [
32
+ "prettier --write"
33
+ ],
34
+ "*.{js,cjs}": [
35
+ "prettier --write"
36
+ ]
37
+ },
38
+ "keywords": [],
39
+ "author": "",
40
+ "license": "ISC",
41
+ "type": "module",
42
+ "devDependencies": {
43
+ "@babel/preset-env": "^7.29.7",
44
+ "@babel/preset-react": "^7.29.7",
45
+ "@babel/preset-typescript": "^7.29.7",
46
+ "@chromatic-com/storybook": "latest",
47
+ "@commitlint/cli": "^21.2.2",
48
+ "@commitlint/config-conventional": "^21.2.2",
49
+ "@eslint/js": "^9.7.0",
50
+ "@rollup/plugin-commonjs": "^29.0.3",
51
+ "@rollup/plugin-node-resolve": "^16.0.3",
52
+ "@rollup/plugin-typescript": "^12.3.0",
53
+ "@storybook/addon-a11y": "^10.5.10",
54
+ "@storybook/addon-docs": "^10.5.10",
55
+ "@storybook/addon-themes": "^10.5.10",
56
+ "@storybook/addon-vitest": "^10.5.10",
57
+ "@storybook/react-vite": "^10.5.10",
58
+ "@svgr/rollup": "^8.1.0",
59
+ "@testing-library/dom": "^10.4.1",
60
+ "@testing-library/jest-dom": "^7.0.1",
61
+ "@testing-library/react": "^16.3.2",
62
+ "@testing-library/user-event": "^14.6.5",
63
+ "@types/jest": "^30.0.0",
64
+ "@types/react": "^18.2.0",
65
+ "@types/react-dom": "^18.2.0",
66
+ "@vitest/browser-playwright": "latest",
67
+ "@vitest/coverage-v8": "latest",
68
+ "chromatic": "^18.5.0",
69
+ "classnames": "^2.5.1",
70
+ "eslint": "^9.7.0",
71
+ "eslint-plugin-import": "^2.32.0",
72
+ "eslint-plugin-react": "^7.37.5",
73
+ "eslint-plugin-react-hooks": "^5.0.0",
74
+ "eslint-plugin-simple-import-sort": "^14.0.0",
75
+ "eslint-plugin-storybook": "^10.5.10",
76
+ "globals": "^17.11.0",
77
+ "husky": "^9.1.7",
78
+ "identity-obj-proxy": "^3.0.0",
79
+ "jest": "^30.4.2",
80
+ "jest-environment-jsdom": "^30.4.1",
81
+ "jiti": "^2.7.0",
82
+ "lint-staged": "^16.4.0",
83
+ "playwright": "latest",
84
+ "postcss": "^8.5.26",
85
+ "prettier": "3.9.6",
86
+ "react": "^19.2.8",
87
+ "react-dom": "^19.2.8",
88
+ "rimraf": "^6.1.3",
89
+ "rollup": "^2.80.0",
90
+ "rollup-plugin-babel": "^4.4.0",
91
+ "rollup-plugin-styles": "^4.0.0",
92
+ "sass": "^1.103.1",
93
+ "storybook": "^10.5.10",
94
+ "typescript": "^5.6.2",
95
+ "typescript-eslint": "^8.0.0",
96
+ "vite-plugin-svgr": "^5.2.0",
97
+ "vitest": "latest"
98
+ },
99
+ "dependencies": {
100
+ "@hookform/resolvers": "^5.9.1",
101
+ "react-hook-form": "^7.87.0",
102
+ "react-imask": "^7.6.1",
103
+ "tslib": "^2.8.1",
104
+ "zod": "^4.5.4"
105
+ }
106
+ }
@@ -0,0 +1,65 @@
1
+ import commonjs from '@rollup/plugin-commonjs';
2
+ import resolve from '@rollup/plugin-node-resolve';
3
+ import typescript from '@rollup/plugin-typescript';
4
+ import svgr from '@svgr/rollup';
5
+ import { readFileSync } from 'fs';
6
+ import styles from 'rollup-plugin-styles';
7
+
8
+ const pkg = JSON.parse(readFileSync('./package.json', 'utf8'));
9
+
10
+ const external = Object.keys(pkg.peerDependencies || {});
11
+
12
+ const baseOutput = {
13
+ dir: 'dist',
14
+ sourcemap: true,
15
+ exports: 'named',
16
+ };
17
+
18
+ const plugins = [
19
+ resolve({
20
+ extensions: ['.ts', '.tsx', '.js', '.jsx', '.scss', '.css'],
21
+ }),
22
+ commonjs(),
23
+ styles({
24
+ mode: 'inject',
25
+ sass: {
26
+ data: `
27
+ @import "src/styles/variables.scss";
28
+ @import "src/styles/mixins.scss";
29
+ @import "src/styles/border.scss";
30
+ @import "src/styles/theme-mixins.scss";
31
+ @import "src/styles/colors.scss";
32
+ @import "src/styles/typography.scss";
33
+ @import "src/styles/gap.scss";
34
+ `,
35
+ },
36
+ }),
37
+ svgr({
38
+ include: ['**/*.svg', '**/*.svg?react'],
39
+ }),
40
+ typescript({
41
+ declaration: true,
42
+ declarationDir: 'dist',
43
+ outDir: 'dist',
44
+ rootDir: 'src',
45
+ }),
46
+ ];
47
+
48
+ export default [
49
+ {
50
+ input: 'src/index.ts',
51
+ output: [
52
+ {
53
+ ...baseOutput,
54
+ format: 'esm',
55
+ },
56
+ {
57
+ ...baseOutput,
58
+ format: 'cjs',
59
+ entryFileNames: '[name].cjs',
60
+ },
61
+ ],
62
+ external,
63
+ plugins,
64
+ },
65
+ ];
@@ -0,0 +1,4 @@
1
+ <svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M12.5833 0.583313L0.583313 12.5833" stroke="currentColor" stroke-width="1.16667" stroke-linecap="round" stroke-linejoin="round"/>
3
+ <path d="M0.583313 0.583313L12.5833 12.5833" stroke="currentColor" stroke-width="1.16667" stroke-linecap="round" stroke-linejoin="round"/>
4
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M21.174 6.81201C21.7027 6.28344 21.9998 5.56648 21.9999 4.81887C22 4.07125 21.7031 3.35422 21.1745 2.82551C20.6459 2.29681 19.929 1.99973 19.1813 1.99963C18.4337 1.99954 17.7167 2.29644 17.188 2.82501L3.842 16.174C3.60981 16.4055 3.43811 16.6905 3.342 17.004L2.021 21.356C1.99515 21.4425 1.9932 21.5344 2.01535 21.6219C2.03749 21.7094 2.08292 21.7892 2.14679 21.853C2.21067 21.9168 2.29062 21.9621 2.37815 21.9841C2.46569 22.0061 2.55755 22.004 2.644 21.978L6.997 20.658C7.31016 20.5628 7.59517 20.3921 7.827 20.161L21.174 6.81201Z" stroke="currentColor" stroke-width="1.16667" stroke-linecap="round" stroke-linejoin="round"/>
3
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M4.27337 4L3.33337 4.94L6.38671 8L3.33337 11.06L4.27337 12L8.27337 8L4.27337 4Z" fill="currentColor"/>
3
+ <path d="M8.66668 4L7.72668 4.94L10.78 8L7.72668 11.06L8.66668 12L12.6667 8L8.66668 4Z" fill="currentColor"/>
4
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M11.7266 12L12.6666 11.06L9.61329 8L12.6666 4.94L11.7266 4L7.72663 8L11.7266 12Z" fill="currentColor"/>
3
+ <path d="M7.33332 12L8.27332 11.06L5.21998 8L8.27331 4.94L7.33331 4L3.33332 8L7.33332 12Z" fill="currentColor"/>
4
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M8.2 9.6C7.97333 9.6 7.78347 9.5232 7.6304 9.3696C7.4768 9.21653 7.4 9.02667 7.4 8.8C7.4 8.57333 7.4768 8.3832 7.6304 8.2296C7.78347 8.07653 7.97333 8 8.2 8C8.42667 8 8.6168 8.07653 8.7704 8.2296C8.92347 8.3832 9 8.57333 9 8.8C9 9.02667 8.92347 9.21653 8.7704 9.3696C8.6168 9.5232 8.42667 9.6 8.2 9.6ZM5 9.6C4.77333 9.6 4.5832 9.5232 4.4296 9.3696C4.27653 9.21653 4.2 9.02667 4.2 8.8C4.2 8.57333 4.27653 8.3832 4.4296 8.2296C4.5832 8.07653 4.77333 8 5 8C5.22667 8 5.4168 8.07653 5.5704 8.2296C5.72347 8.3832 5.8 8.57333 5.8 8.8C5.8 9.02667 5.72347 9.21653 5.5704 9.3696C5.4168 9.5232 5.22667 9.6 5 9.6ZM11.4 9.6C11.1733 9.6 10.9835 9.5232 10.8304 9.3696C10.6768 9.21653 10.6 9.02667 10.6 8.8C10.6 8.57333 10.6768 8.3832 10.8304 8.2296C10.9835 8.07653 11.1733 8 11.4 8C11.6267 8 11.8165 8.07653 11.9696 8.2296C12.1232 8.3832 12.2 8.57333 12.2 8.8C12.2 9.02667 12.1232 9.21653 11.9696 9.3696C11.8165 9.5232 11.6267 9.6 11.4 9.6ZM8.2 12.8C7.97333 12.8 7.78347 12.7232 7.6304 12.5696C7.4768 12.4165 7.4 12.2267 7.4 12C7.4 11.7733 7.4768 11.5835 7.6304 11.4304C7.78347 11.2768 7.97333 11.2 8.2 11.2C8.42667 11.2 8.6168 11.2768 8.7704 11.4304C8.92347 11.5835 9 11.7733 9 12C9 12.2267 8.92347 12.4165 8.7704 12.5696C8.6168 12.7232 8.42667 12.8 8.2 12.8ZM5 12.8C4.77333 12.8 4.5832 12.7232 4.4296 12.5696C4.27653 12.4165 4.2 12.2267 4.2 12C4.2 11.7733 4.27653 11.5835 4.4296 11.4304C4.5832 11.2768 4.77333 11.2 5 11.2C5.22667 11.2 5.4168 11.2768 5.5704 11.4304C5.72347 11.5835 5.8 11.7733 5.8 12C5.8 12.2267 5.72347 12.4165 5.5704 12.5696C5.4168 12.7232 5.22667 12.8 5 12.8ZM11.4 12.8C11.1733 12.8 10.9835 12.7232 10.8304 12.5696C10.6768 12.4165 10.6 12.2267 10.6 12C10.6 11.7733 10.6768 11.5835 10.8304 11.4304C10.9835 11.2768 11.1733 11.2 11.4 11.2C11.6267 11.2 11.8165 11.2768 11.9696 11.4304C12.1232 11.5835 12.2 11.7733 12.2 12C12.2 12.2267 12.1232 12.4165 11.9696 12.5696C11.8165 12.7232 11.6267 12.8 11.4 12.8ZM2.6 16C2.16 16 1.7832 15.8435 1.4696 15.5304C1.15653 15.2168 1 14.84 1 14.4V3.2C1 2.76 1.15653 2.38347 1.4696 2.0704C1.7832 1.7568 2.16 1.6 2.6 1.6H3.4V0H5V1.6H11.4V0H13V1.6H13.8C14.24 1.6 14.6168 1.7568 14.9304 2.0704C15.2435 2.38347 15.4 2.76 15.4 3.2V14.4C15.4 14.84 15.2435 15.2168 14.9304 15.5304C14.6168 15.8435 14.24 16 13.8 16H2.6ZM2.6 14.4H13.8V6.4H2.6V14.4Z" fill="currentColor"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M12.9872 3.04239C10.2573 0.319202 5.77739 0.319202 3.04745 3.04239C0.317516 5.76559 0.317516 10.2344 3.04745 12.9576C5.77739 15.6808 10.1873 15.6808 12.9172 12.9576C15.6471 10.2344 15.7171 5.76559 12.9872 3.04239ZM9.97728 10.9327L8.01733 8.97756L6.05738 10.9327L5.0774 9.95511L7.03735 8L5.0774 6.04489L6.05738 5.06733L8.01733 7.02244L9.97728 5.06733L10.9573 6.04489L8.99731 8L10.9573 9.95511L9.97728 10.9327Z" fill="currentColor"/>
3
+ </svg>
@@ -0,0 +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
+ };
@@ -0,0 +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
+ };
@@ -0,0 +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
+ }