datepicker-pashuk 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 (63) hide show
  1. package/README.md +161 -0
  2. package/dist/index.cjs.js +1163 -0
  3. package/dist/index.cjs.js.map +1 -0
  4. package/dist/index.esm.js +1158 -0
  5. package/dist/index.esm.js.map +1 -0
  6. package/dist/types/.storybook/main.d.ts +3 -0
  7. package/dist/types/.storybook/preview.d.ts +4 -0
  8. package/dist/types/jest.setup.d.ts +1 -0
  9. package/dist/types/src/entities/buggyComponent/ui/BuggyComponent.d.ts +1 -0
  10. package/dist/types/src/entities/calendar/assets/NextIcon.d.ts +1 -0
  11. package/dist/types/src/entities/calendar/assets/PreviousIcon.d.ts +1 -0
  12. package/dist/types/src/entities/calendar/assets/index.d.ts +2 -0
  13. package/dist/types/src/entities/calendar/lib/decorators/BaseCalendarEngine.d.ts +9 -0
  14. package/dist/types/src/entities/calendar/lib/decorators/CalenderDecorator.d.ts +7 -0
  15. package/dist/types/src/entities/calendar/lib/decorators/FromMondayDecorator.d.ts +7 -0
  16. package/dist/types/src/entities/calendar/lib/decorators/HolidayDecorator.d.ts +7 -0
  17. package/dist/types/src/entities/calendar/lib/decorators/MinMaxDecorator.d.ts +12 -0
  18. package/dist/types/src/entities/calendar/lib/decorators/RangeCalenderDecorator.d.ts +23 -0
  19. package/dist/types/src/entities/calendar/lib/decorators/TodoDecorator.d.ts +13 -0
  20. package/dist/types/src/entities/calendar/lib/decorators/ViewByWeekDecorator.d.ts +8 -0
  21. package/dist/types/src/entities/calendar/lib/decorators/WeekdayDecorator.d.ts +6 -0
  22. package/dist/types/src/entities/calendar/lib/helpers/generateMonthArray.d.ts +4 -0
  23. package/dist/types/src/entities/calendar/lib/helpers/generateYearArray.d.ts +1 -0
  24. package/dist/types/src/entities/calendar/lib/helpers/isMinMaxValue.d.ts +1 -0
  25. package/dist/types/src/entities/calendar/lib/helpers/isSameDates.d.ts +1 -0
  26. package/dist/types/src/entities/calendar/lib/helpers/validationInput.d.ts +4 -0
  27. package/dist/types/src/entities/calendar/lib/tests/constants.d.ts +67 -0
  28. package/dist/types/src/entities/calendar/model/constants.d.ts +7 -0
  29. package/dist/types/src/entities/calendar/model/service.d.ts +35 -0
  30. package/dist/types/src/entities/calendar/model/storageService.d.ts +7 -0
  31. package/dist/types/src/entities/calendar/model/types.d.ts +75 -0
  32. package/dist/types/src/entities/calendar/ui/BaseCalendar/BaseCalendar.d.ts +2 -0
  33. package/dist/types/src/entities/calendar/ui/CalendarCell/CalendarCell.d.ts +2 -0
  34. package/dist/types/src/entities/calendar/ui/CalendarGrid/CalendarGrid.d.ts +2 -0
  35. package/dist/types/src/entities/calendar/ui/CalendarHeader/CalendarHeader.d.ts +2 -0
  36. package/dist/types/src/features/calendar/Calendar.d.ts +2 -0
  37. package/dist/types/src/features/calendar/model/constants.d.ts +5 -0
  38. package/dist/types/src/features/calendarWithInput/CalendarWithInput.d.ts +2 -0
  39. package/dist/types/src/features/calendarWithInput/model/types.d.ts +5 -0
  40. package/dist/types/src/features/calenderWithTodo/lib/helperTests.d.ts +91 -0
  41. package/dist/types/src/features/calenderWithTodo/lib/useCalendarPortal.d.ts +8 -0
  42. package/dist/types/src/features/calenderWithTodo/ui/CalenderWithTodo.d.ts +2 -0
  43. package/dist/types/src/features/rangeCalender/lib/useDateRangePicker.d.ts +23 -0
  44. package/dist/types/src/features/rangeCalender/model/types.d.ts +5 -0
  45. package/dist/types/src/features/rangeCalender/ui/RangeCalender.d.ts +2 -0
  46. package/dist/types/src/index.d.ts +5 -0
  47. package/dist/types/src/shared/lib/getThemed.d.ts +2 -0
  48. package/dist/types/src/shared/lib/useCalendarService.d.ts +6 -0
  49. package/dist/types/src/shared/model/constants.d.ts +3 -0
  50. package/dist/types/src/shared/model/helperTest.d.ts +33 -0
  51. package/dist/types/src/shared/ui/ErrorBoundary/types/types.d.ts +7 -0
  52. package/dist/types/src/shared/ui/ErrorBoundary/ui/ErrorBoundary.d.ts +9 -0
  53. package/dist/types/src/shared/ui/Input/lib/maskDate.d.ts +1 -0
  54. package/dist/types/src/shared/ui/Input/model/constants.d.ts +4 -0
  55. package/dist/types/src/shared/ui/Input/model/types.d.ts +9 -0
  56. package/dist/types/src/shared/ui/Input/ui/Input.d.ts +2 -0
  57. package/dist/types/src/shared/ui/Input/ui/InputWithState.d.ts +2 -0
  58. package/dist/types/src/shared/ui/Input/ui/assets/CalendarIcon.d.ts +1 -0
  59. package/dist/types/src/shared/ui/Input/ui/assets/CloseIcon.d.ts +1 -0
  60. package/dist/types/src/shared/ui/Input/ui/assets/index.d.ts +2 -0
  61. package/dist/types/src/shared/ui/Portal/model/types.d.ts +18 -0
  62. package/dist/types/src/shared/ui/Portal/ui/Portal.d.ts +2 -0
  63. package/package.json +93 -0
@@ -0,0 +1,2 @@
1
+ import { BaseCalendarProps } from '@entities/calendar/model/types';
2
+ export declare const BaseCalendar: (props: BaseCalendarProps) => import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { CalendarCellProps } from '@entities/calendar/model/types';
2
+ export declare const CalendarCell: (props: CalendarCellProps) => import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { CalendarGridProps } from '@entities/calendar/model/types';
2
+ export declare const CalendarGrid: (props: CalendarGridProps) => import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { CalenderHeaderProps } from '@entities/calendar/model/types';
2
+ export declare const CalendarHeader: (props: CalenderHeaderProps) => import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { EngineConfig } from '@entities/calendar/model/types';
2
+ export declare const Calendar: (config?: EngineConfig) => import("react").JSX.Element;
@@ -0,0 +1,5 @@
1
+ export declare const MOCK_DATES: Date[];
2
+ export declare enum THEMED {
3
+ LIGHT = "light",
4
+ DARK = "dark"
5
+ }
@@ -0,0 +1,2 @@
1
+ import { CalanderWithInputprops } from './model/types';
2
+ export declare const CalendarWithInput: (props: CalanderWithInputprops) => import("react").JSX.Element;
@@ -0,0 +1,5 @@
1
+ export interface CalanderWithInputprops {
2
+ placeholder?: string;
3
+ label?: string;
4
+ darkThemed?: boolean;
5
+ }
@@ -0,0 +1,91 @@
1
+ import { MouseEvent } from 'react';
2
+ export type BaseCalendarMockProps = {
3
+ onDayClick?: (date: Date, event?: MouseEvent<HTMLDivElement>) => void;
4
+ onDayClickDouble?: (date: Date, event?: MouseEvent<HTMLDivElement>) => void;
5
+ };
6
+ export declare const createReactMockEl: () => {
7
+ BaseCalendar: ({ onDayClick, onDayClickDouble }: BaseCalendarMockProps) => any;
8
+ };
9
+ export declare const TEST_TEXT: {
10
+ CLICK_NO_EVENT: string;
11
+ CLICK_WITH_EVENT: string;
12
+ DBL_NO_EVENT: string;
13
+ DBL_WITH_EVENT: string;
14
+ ADD: string;
15
+ DELETE_LABEL: string;
16
+ CONFIRM: string;
17
+ NEW_TASK: string;
18
+ ADD_BUTTON: string;
19
+ };
20
+ export declare const DEFAULT_DATE: Date;
21
+ export declare const createServiceMock: (todos?: string[]) => {
22
+ addTodo: jest.Mock<any, any, any>;
23
+ deleteTodo: jest.Mock<any, any, any>;
24
+ getTodosByDate: jest.Mock<string[], [], any>;
25
+ setSelectedDate: jest.Mock<any, any, any>;
26
+ };
27
+ export declare const createViewModelMock: () => {
28
+ fromMonday: boolean;
29
+ dateArray: never[];
30
+ month: string;
31
+ year: number;
32
+ yearsArray: number[];
33
+ canNext: boolean;
34
+ canPrev: boolean;
35
+ onClickNext: jest.Mock<any, any, any>;
36
+ onClickPrevious: jest.Mock<any, any, any>;
37
+ onDayClick: jest.Mock<any, any, any>;
38
+ onClickNextYear: jest.Mock<any, any, any>;
39
+ };
40
+ export declare const createPortalMock: (aditiionProps?: {}) => {
41
+ isOpenPortal: boolean;
42
+ selectedDate: Date;
43
+ anchorEl: HTMLDivElement;
44
+ portalRef: {
45
+ current: null;
46
+ };
47
+ closePortal: jest.Mock<any, any, any>;
48
+ openPortal: jest.Mock<any, any, any>;
49
+ };
50
+ export declare const setup: (options?: {
51
+ service?: ReturnType<typeof createServiceMock>;
52
+ portal?: ReturnType<typeof createPortalMock>;
53
+ }) => {
54
+ service: {
55
+ addTodo: jest.Mock<any, any, any>;
56
+ deleteTodo: jest.Mock<any, any, any>;
57
+ getTodosByDate: jest.Mock<string[], [], any>;
58
+ setSelectedDate: jest.Mock<any, any, any>;
59
+ };
60
+ portal: {
61
+ isOpenPortal: boolean;
62
+ selectedDate: Date;
63
+ anchorEl: HTMLDivElement;
64
+ portalRef: {
65
+ current: null;
66
+ };
67
+ closePortal: jest.Mock<any, any, any>;
68
+ openPortal: jest.Mock<any, any, any>;
69
+ };
70
+ user: import("@testing-library/user-event").UserEvent;
71
+ };
72
+ export declare const createElement: () => HTMLDivElement;
73
+ export declare const setupPortal: () => {
74
+ open: (date?: Date, el?: HTMLDivElement) => Promise<{
75
+ date: Date;
76
+ el: HTMLDivElement;
77
+ }>;
78
+ close: () => void;
79
+ rerender: (props?: unknown) => void;
80
+ result: {
81
+ current: {
82
+ isOpenPortal: boolean;
83
+ selectedDate: Date | null;
84
+ anchorEl: HTMLElement | null;
85
+ portalRef: import("react").RefObject<HTMLDivElement | null>;
86
+ openPortal: (date: Date, element: HTMLElement) => void;
87
+ closePortal: () => void;
88
+ };
89
+ };
90
+ unmount: () => void;
91
+ };
@@ -0,0 +1,8 @@
1
+ export declare const useCalendarPortal: () => {
2
+ isOpenPortal: boolean;
3
+ selectedDate: Date | null;
4
+ anchorEl: HTMLElement | null;
5
+ portalRef: import("react").RefObject<HTMLDivElement | null>;
6
+ openPortal: (date: Date, element: HTMLElement) => void;
7
+ closePortal: () => void;
8
+ };
@@ -0,0 +1,2 @@
1
+ import { EngineConfig } from '@entities/calendar/model/types';
2
+ export declare const CalendarWithTodo: (config?: EngineConfig) => import("react").JSX.Element;
@@ -0,0 +1,23 @@
1
+ import { BaseCalendarProps, EngineConfig } from '@entities/calendar/model/types';
2
+ import { ActiveInputType } from '../model/types';
3
+ export declare const useDateRangePicker: (config?: EngineConfig) => {
4
+ viewModel: BaseCalendarProps;
5
+ isOpenCalendar: boolean;
6
+ start: {
7
+ value: string;
8
+ onChange: (val: string) => void;
9
+ onFocus: () => void;
10
+ placeholder: string;
11
+ onClear: () => void;
12
+ };
13
+ end: {
14
+ value: string;
15
+ onChange: (val: string) => void;
16
+ onFocus: () => void;
17
+ placeholder: string;
18
+ onClear: () => void;
19
+ };
20
+ error: string;
21
+ onClear: (inputType?: ActiveInputType) => void;
22
+ toggleCalendar: () => void;
23
+ };
@@ -0,0 +1,5 @@
1
+ export declare const INPUT_TYPE: {
2
+ readonly START: "START";
3
+ readonly END: "END";
4
+ };
5
+ export type ActiveInputType = keyof typeof INPUT_TYPE;
@@ -0,0 +1,2 @@
1
+ import { EngineConfig } from '@entities/calendar/model/types';
2
+ export declare const RangeCalender: (_config?: EngineConfig) => import("react").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import './app/styles/index.scss';
2
+ export { Calendar } from './features/calendar/Calendar';
3
+ export { CalendarWithInput } from './features/calendarWithInput/CalendarWithInput';
4
+ export { CalendarWithTodo } from '@features/calenderWithTodo/ui/CalenderWithTodo';
5
+ export { RangeCalender } from '@features/rangeCalender/ui/RangeCalender';
@@ -0,0 +1,2 @@
1
+ import { THEMED } from '@features/calendar/model/constants';
2
+ export declare const getTheme: (darkThemed?: boolean) => THEMED;
@@ -0,0 +1,6 @@
1
+ import { DatepickerService } from '@entities/calendar/model/service';
2
+ import { BaseCalendarProps, EngineConfig } from '@entities/calendar/model/types';
3
+ export declare const useCalendarService: (config?: EngineConfig, withTodo?: boolean) => {
4
+ service: DatepickerService;
5
+ viewModel: BaseCalendarProps;
6
+ };
@@ -0,0 +1,3 @@
1
+ export declare const DATE_PARTS_LENGTH = 3;
2
+ export declare const MAX_INPUT_LENGTH = 10;
3
+ export declare const FIRST_INDEX = 1;
@@ -0,0 +1,33 @@
1
+ import { DatepickerService } from '@entities/calendar/model/service';
2
+ export declare const VIEW_MODEL_SERVICE: {
3
+ INITIAL: {
4
+ value: string;
5
+ };
6
+ UPDATED: {
7
+ value: string;
8
+ };
9
+ };
10
+ export declare const createServiceMock: () => {
11
+ service: {
12
+ subscribe: jest.Mock<jest.Mock<any, any, any>, [cb: () => void], any>;
13
+ getViewModel: jest.Mock<{
14
+ value: string;
15
+ }, [], any>;
16
+ };
17
+ updateViewModel: (nextValue: (typeof VIEW_MODEL_SERVICE)[keyof typeof VIEW_MODEL_SERVICE]) => void;
18
+ unsubscribe: jest.Mock<any, any, any>;
19
+ };
20
+ export declare const setupService: () => {
21
+ triggerUpdate: (nextState?: {
22
+ value: string;
23
+ }) => void;
24
+ unsubscribe: jest.Mock<any, any, any>;
25
+ rerender: (props?: unknown) => void;
26
+ result: {
27
+ current: {
28
+ service: DatepickerService;
29
+ viewModel: import("../../entities/calendar/model/types").BaseCalendarProps;
30
+ };
31
+ };
32
+ unmount: () => void;
33
+ };
@@ -0,0 +1,7 @@
1
+ import { ReactNode } from 'react';
2
+ export interface Props {
3
+ children?: ReactNode;
4
+ }
5
+ export interface State {
6
+ hasError: boolean;
7
+ }
@@ -0,0 +1,9 @@
1
+ import { Component, ErrorInfo } from 'react';
2
+ import { Props, State } from '../types/types';
3
+ export declare class ErrorBoundary extends Component<Props, State> {
4
+ state: State;
5
+ static getDerivedStateFromError(_: Error): State;
6
+ componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
7
+ private handleReload;
8
+ render(): string | number | bigint | boolean | import("react").JSX.Element | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | null | undefined;
9
+ }
@@ -0,0 +1 @@
1
+ export declare const maskDate: (value: string) => string;
@@ -0,0 +1,4 @@
1
+ export declare const START_DATE_INDEX_ = 0;
2
+ export declare const START_MONTH_INDEX = 2;
3
+ export declare const START_YEAR_INDEX = 4;
4
+ export declare const MAX_DATE_LENGTH = 10;
@@ -0,0 +1,9 @@
1
+ export interface InputProps {
2
+ value: string;
3
+ placeholder?: string;
4
+ error?: string;
5
+ label?: string;
6
+ onChange: (_value: string) => void;
7
+ onClear: () => void;
8
+ handleIsOpen: () => void;
9
+ }
@@ -0,0 +1,2 @@
1
+ import { InputProps } from '../model/types';
2
+ export declare const Input: (props: InputProps) => import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { InputProps } from '../model/types';
2
+ export declare const InputWithState: (args: InputProps) => import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare const CalendarIcon: () => import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare const CloseIcon: () => import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export { CalendarIcon } from './CalendarIcon';
2
+ export { CloseIcon } from './CloseIcon';
@@ -0,0 +1,18 @@
1
+ import { RefObject } from 'react';
2
+ import { THEMED } from '@features/calendar/model/constants';
3
+ export interface PortalProps {
4
+ anchorEl: HTMLElement | null;
5
+ portalRef: RefObject<HTMLDivElement | null>;
6
+ onAddTodo: (date: Date, text: string) => void;
7
+ getTodos: (date: Date) => string[];
8
+ onClose: () => void;
9
+ selectedDate: Date | null;
10
+ isOpenPortal: boolean;
11
+ id: string;
12
+ onDeleteTodo: (date: Date, todo: string) => void;
13
+ themed: THEMED;
14
+ }
15
+ export interface PortalPosition {
16
+ top: string;
17
+ left: string;
18
+ }
@@ -0,0 +1,2 @@
1
+ import { PortalProps } from '../model/types';
2
+ export declare const Portal: (props: PortalProps) => import("react").ReactPortal | null;
package/package.json ADDED
@@ -0,0 +1,93 @@
1
+ {
2
+ "name": "datepicker-pashuk",
3
+ "type": "module",
4
+ "version": "1.0.0",
5
+ "main": "dist/index.cjs.js",
6
+ "module": "dist/index.esm.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "repository": "https://github.com/LesiaPashuk/datepicker.git",
12
+ "author": "LesiaPashuk <alesya5704747@icloud.com>",
13
+ "license": "MIT",
14
+ "devDependencies": {
15
+ "@babel/core": "^7.29.0",
16
+ "@babel/preset-env": "^7.29.2",
17
+ "@babel/preset-react": "^7.28.5",
18
+ "@babel/preset-typescript": "^7.28.5",
19
+ "@commitlint/cli": "^20.5.0",
20
+ "@commitlint/config-conventional": "^20.5.0",
21
+ "@eslint/js": "^10.0.1",
22
+ "@rollup/plugin-alias": "^6.0.0",
23
+ "@rollup/plugin-commonjs": "^29.0.2",
24
+ "@rollup/plugin-node-resolve": "^16.0.3",
25
+ "@rollup/plugin-typescript": "^12.3.0",
26
+ "@storybook/addon-a11y": "^10.3.3",
27
+ "@storybook/addon-docs": "^10.3.3",
28
+ "@storybook/addon-onboarding": "^10.3.3",
29
+ "@storybook/addon-vitest": "^10.3.3",
30
+ "@storybook/react-vite": "^10.3.3",
31
+ "@testing-library/dom": "^10.4.1",
32
+ "@testing-library/jest-dom": "^6.9.1",
33
+ "@testing-library/react": "^16.3.2",
34
+ "@types/jest": "^30.0.0",
35
+ "@types/react": "19",
36
+ "@types/react-dom": "19",
37
+ "@typescript-eslint/eslint-plugin": "^8.57.2",
38
+ "@typescript-eslint/parser": "^8.57.2",
39
+ "@vitest/browser-playwright": "^4.1.1",
40
+ "@vitest/coverage-v8": "^4.1.1",
41
+ "babel-plugin-react-compiler": "^1.0.0",
42
+ "chromatic": "^16.0.0",
43
+ "eslint": "^9.39.4",
44
+ "eslint-config-prettier": "^10.1.8",
45
+ "eslint-plugin-react": "^7.37.5",
46
+ "eslint-plugin-react-compiler": "^19.1.0-rc.2",
47
+ "eslint-plugin-react-hooks": "^7.0.1",
48
+ "eslint-plugin-simple-import-sort": "^12.1.1",
49
+ "eslint-plugin-storybook": "^10.3.3",
50
+ "husky": "^9.1.7",
51
+ "identity-obj-proxy": "^3.0.0",
52
+ "jest": "^30.3.0",
53
+ "jest-environment-jsdom": "^30.3.0",
54
+ "lint-staged": "^16.4.0",
55
+ "playwright": "^1.58.2",
56
+ "postcss": "^8.5.8",
57
+ "prettier": "^3.8.1",
58
+ "react": "19",
59
+ "react-dom": "19",
60
+ "rollup": "^4.60.0",
61
+ "rollup-plugin-postcss": "^4.0.2",
62
+ "sass": "^1.98.0",
63
+ "storybook": "^10.3.3",
64
+ "ts-jest": "^29.4.6",
65
+ "tslib": "^2.8.1",
66
+ "typescript": "^5.2.2",
67
+ "vitest": "^4.1.1"
68
+ },
69
+ "peerDependencies": {
70
+ "react": "^19.0.0",
71
+ "react-dom": "^19.0.0"
72
+ },
73
+ "scripts": {
74
+ "type-check": "tsc --noEmit",
75
+ "lint": "eslint .",
76
+ "lint:fix": "eslint . --fix",
77
+ "format": "prettier --write .",
78
+ "test:watch": "jest --watch",
79
+ "prepare": "husky",
80
+ "build": "rollup -c",
81
+ "test": "jest --passWithNoTests",
82
+ "storybook": "storybook dev -p 6006",
83
+ "build-storybook": "storybook build",
84
+ "chromatic": "chromatic --exit-zero-on-changes",
85
+ "release": "npm publish --access public"
86
+ },
87
+ "lint-staged": {
88
+ "src/**/*.{ts,tsx,js,jsx}": [
89
+ "eslint --fix",
90
+ "prettier --write"
91
+ ]
92
+ }
93
+ }