@alfalab/core-components-date-range-input 2.4.1 → 3.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.
- package/Component-63dec22f.d.ts +167 -0
- package/Component-89a3cf4c.d.ts +6 -0
- package/Component-8b5756fe.d.ts +380 -0
- package/Component.desktop-2e2b2125.d.ts +6 -0
- package/Component.desktop-8b5756fe.d.ts +197 -0
- package/Component.desktop.d.ts +1 -1
- package/Component.desktop.js +4 -3
- package/Component.mobile-755fbaa3.d.ts +6 -0
- package/Component.mobile-ebda875c.d.ts +6 -0
- package/Component.mobile.d.ts +1 -1
- package/Component.mobile.js +4 -3
- package/Component.responsive-2e2b2125.d.ts +66 -0
- package/Component.responsive.d.ts +1 -1
- package/Component.responsive.js +5 -2
- package/components/date-range-input/Component.d.ts +7 -2
- package/components/date-range-input/Component.js +10 -11
- package/components/date-range-input/index.css +7 -7
- package/components/date-range-input/index.js +1 -2
- package/cssm/Component-63dec22f.d.ts +167 -0
- package/cssm/Component-89a3cf4c.d.ts +6 -0
- package/cssm/Component-8b5756fe.d.ts +380 -0
- package/cssm/Component.desktop-2e2b2125.d.ts +6 -0
- package/cssm/Component.desktop-8b5756fe.d.ts +197 -0
- package/cssm/Component.desktop.d.ts +1 -1
- package/cssm/Component.desktop.js +4 -3
- package/cssm/Component.mobile-755fbaa3.d.ts +6 -0
- package/cssm/Component.mobile-ebda875c.d.ts +6 -0
- package/cssm/Component.mobile.d.ts +1 -1
- package/cssm/Component.mobile.js +4 -3
- package/cssm/Component.responsive-2e2b2125.d.ts +66 -0
- package/cssm/Component.responsive.d.ts +1 -1
- package/cssm/Component.responsive.js +5 -2
- package/cssm/components/date-range-input/Component.d.ts +7 -2
- package/cssm/components/date-range-input/Component.js +9 -10
- package/cssm/components/date-range-input/index.js +1 -2
- package/cssm/desktop-63dec22f.d.ts +2 -0
- package/cssm/desktop.js +3 -2
- package/cssm/index-89a3cf4c.d.ts +3 -0
- package/cssm/index-9211a437.d.ts +2 -0
- package/cssm/index-ebda875c.d.ts +35 -0
- package/cssm/index-f034f741.d.ts +80 -0
- package/cssm/index.d.ts +3 -2
- package/cssm/index.js +5 -2
- package/cssm/mobile-c219f8ca.d.ts +1 -0
- package/cssm/mobile.js +3 -2
- package/cssm/types-ebda875c.d.ts +113 -0
- package/cssm/typings-5684a67d.d.ts +23 -0
- package/cssm/typings-9211a437.d.ts +95 -0
- package/cssm/useCalendar-5684a67d.d.ts +97 -0
- package/cssm/utils-5684a67d.d.ts +88 -0
- package/desktop-63dec22f.d.ts +2 -0
- package/desktop.js +3 -2
- package/esm/Component-63dec22f.d.ts +167 -0
- package/esm/Component-89a3cf4c.d.ts +6 -0
- package/esm/Component-8b5756fe.d.ts +380 -0
- package/esm/Component.desktop-2e2b2125.d.ts +6 -0
- package/esm/Component.desktop-8b5756fe.d.ts +197 -0
- package/esm/Component.desktop.d.ts +1 -1
- package/esm/Component.desktop.js +4 -3
- package/esm/Component.mobile-755fbaa3.d.ts +6 -0
- package/esm/Component.mobile-ebda875c.d.ts +6 -0
- package/esm/Component.mobile.d.ts +1 -1
- package/esm/Component.mobile.js +4 -3
- package/esm/Component.responsive-2e2b2125.d.ts +66 -0
- package/esm/Component.responsive.d.ts +1 -1
- package/esm/Component.responsive.js +5 -2
- package/esm/components/date-range-input/Component.d.ts +7 -2
- package/esm/components/date-range-input/Component.js +10 -11
- package/esm/components/date-range-input/index.css +7 -7
- package/esm/components/date-range-input/index.js +1 -2
- package/esm/desktop-63dec22f.d.ts +2 -0
- package/esm/desktop.js +3 -2
- package/esm/index-89a3cf4c.d.ts +3 -0
- package/esm/index-9211a437.d.ts +2 -0
- package/esm/index-ebda875c.d.ts +35 -0
- package/esm/index-f034f741.d.ts +80 -0
- package/esm/index.d.ts +3 -2
- package/esm/index.js +5 -2
- package/esm/mobile-c219f8ca.d.ts +1 -0
- package/esm/mobile.js +3 -2
- package/esm/types-ebda875c.d.ts +113 -0
- package/esm/typings-5684a67d.d.ts +23 -0
- package/esm/typings-9211a437.d.ts +95 -0
- package/esm/useCalendar-5684a67d.d.ts +97 -0
- package/esm/utils-5684a67d.d.ts +88 -0
- package/index-89a3cf4c.d.ts +3 -0
- package/index-9211a437.d.ts +2 -0
- package/index-ebda875c.d.ts +35 -0
- package/index-f034f741.d.ts +80 -0
- package/index.d.ts +3 -2
- package/index.js +5 -2
- package/mobile-c219f8ca.d.ts +1 -0
- package/mobile.js +3 -2
- package/modern/Component-63dec22f.d.ts +167 -0
- package/modern/Component-89a3cf4c.d.ts +6 -0
- package/modern/Component-8b5756fe.d.ts +380 -0
- package/modern/Component.desktop-2e2b2125.d.ts +6 -0
- package/modern/Component.desktop-8b5756fe.d.ts +197 -0
- package/modern/Component.desktop.d.ts +1 -1
- package/modern/Component.desktop.js +4 -3
- package/modern/Component.mobile-755fbaa3.d.ts +6 -0
- package/modern/Component.mobile-ebda875c.d.ts +6 -0
- package/modern/Component.mobile.d.ts +1 -1
- package/modern/Component.mobile.js +4 -3
- package/modern/Component.responsive-2e2b2125.d.ts +66 -0
- package/modern/Component.responsive.d.ts +1 -1
- package/modern/Component.responsive.js +5 -2
- package/modern/components/date-range-input/Component.d.ts +7 -2
- package/modern/components/date-range-input/Component.js +7 -8
- package/modern/components/date-range-input/index.css +7 -7
- package/modern/components/date-range-input/index.js +1 -2
- package/modern/desktop-63dec22f.d.ts +2 -0
- package/modern/desktop.js +3 -2
- package/modern/index-89a3cf4c.d.ts +3 -0
- package/modern/index-9211a437.d.ts +2 -0
- package/modern/index-ebda875c.d.ts +35 -0
- package/modern/index-f034f741.d.ts +80 -0
- package/modern/index.d.ts +3 -2
- package/modern/index.js +5 -2
- package/modern/mobile-c219f8ca.d.ts +1 -0
- package/modern/mobile.js +3 -2
- package/modern/types-ebda875c.d.ts +113 -0
- package/modern/typings-5684a67d.d.ts +23 -0
- package/modern/typings-9211a437.d.ts +95 -0
- package/modern/useCalendar-5684a67d.d.ts +97 -0
- package/modern/utils-5684a67d.d.ts +88 -0
- package/package.json +25 -5
- package/src/Component.desktop.tsx +29 -0
- package/src/Component.mobile.tsx +30 -0
- package/src/Component.responsive.tsx +41 -0
- package/src/components/date-range-input/Component.tsx +519 -0
- package/src/components/date-range-input/index.module.css +37 -0
- package/src/components/date-range-input/index.ts +1 -0
- package/src/desktop.ts +1 -0
- package/src/index.ts +2 -0
- package/src/mobile.ts +1 -0
- package/src/utils/format.ts +91 -0
- package/src/utils/index.ts +1 -0
- package/types-ebda875c.d.ts +113 -0
- package/typings-5684a67d.d.ts +23 -0
- package/typings-9211a437.d.ts +95 -0
- package/useCalendar-5684a67d.d.ts +97 -0
- package/utils-5684a67d.d.ts +88 -0
- package/cssm/responsive.d.ts +0 -2
- package/cssm/responsive.js +0 -27
- package/esm/responsive.d.ts +0 -2
- package/esm/responsive.js +0 -18
- package/modern/responsive.d.ts +0 -2
- package/modern/responsive.js +0 -17
- package/responsive.d.ts +0 -2
- package/responsive.js +0 -26
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { KeyboardEvent, MouseEvent, Ref } from 'react';
|
|
3
|
+
import { Day, DayAddons, Month, View } from "./typings-5684a67d";
|
|
4
|
+
type UseCalendarProps = {
|
|
5
|
+
/**
|
|
6
|
+
* Активный вид (выбор дней, месяцев, лет)
|
|
7
|
+
*/
|
|
8
|
+
view?: View;
|
|
9
|
+
/**
|
|
10
|
+
* Выбранный месяц (controlled)
|
|
11
|
+
*/
|
|
12
|
+
month?: Date;
|
|
13
|
+
/**
|
|
14
|
+
* Начальный месяц
|
|
15
|
+
*/
|
|
16
|
+
defaultMonth: Date;
|
|
17
|
+
/**
|
|
18
|
+
* Минимальная дата, доступная для выбора
|
|
19
|
+
*/
|
|
20
|
+
minDate?: Date;
|
|
21
|
+
/**
|
|
22
|
+
* Максимальная дата, доступная для выбора
|
|
23
|
+
*/
|
|
24
|
+
maxDate?: Date;
|
|
25
|
+
/**
|
|
26
|
+
* Выбранная дата
|
|
27
|
+
*/
|
|
28
|
+
selected?: Date;
|
|
29
|
+
/**
|
|
30
|
+
* Список событий
|
|
31
|
+
*/
|
|
32
|
+
events?: Array<Date | number>;
|
|
33
|
+
/**
|
|
34
|
+
* Список отключенных для выбора дней
|
|
35
|
+
*/
|
|
36
|
+
offDays?: Array<Date | number>;
|
|
37
|
+
/**
|
|
38
|
+
* Список выходных дней
|
|
39
|
+
*/
|
|
40
|
+
holidays?: Array<Date | number>;
|
|
41
|
+
/**
|
|
42
|
+
* Обработчик изменения месяца (или года)
|
|
43
|
+
*/
|
|
44
|
+
onMonthChange?: (month: number) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Обработчик выбора даты
|
|
47
|
+
*/
|
|
48
|
+
onChange?: (date: number) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Дополнительный контент под числом
|
|
51
|
+
*/
|
|
52
|
+
dayAddons?: DayAddons[];
|
|
53
|
+
};
|
|
54
|
+
declare function useCalendar({ defaultMonth, month, minDate, view, maxDate, selected, events, offDays, holidays, dayAddons, onMonthChange, onChange, }: UseCalendarProps): {
|
|
55
|
+
activeMonth: Date;
|
|
56
|
+
weeks: Day[][];
|
|
57
|
+
months: Month[];
|
|
58
|
+
years: Date[];
|
|
59
|
+
canSetPrevMonth: boolean;
|
|
60
|
+
canSetNextMonth: boolean;
|
|
61
|
+
highlighted: number | Date | undefined;
|
|
62
|
+
setPrevMonth: () => void;
|
|
63
|
+
setNextMonth: () => void;
|
|
64
|
+
setMonthByDate: (newMonth: Date) => void;
|
|
65
|
+
getDayProps: (day: Day) => {
|
|
66
|
+
'data-date': number;
|
|
67
|
+
'aria-selected': boolean | undefined;
|
|
68
|
+
ref: (node: HTMLTableDataCellElement) => void;
|
|
69
|
+
tabIndex: number;
|
|
70
|
+
onMouseEnter: (event: MouseEvent<HTMLTableDataCellElement>) => void;
|
|
71
|
+
onMouseLeave: () => void;
|
|
72
|
+
onClick: (event: MouseEvent<HTMLTableDataCellElement>) => void;
|
|
73
|
+
};
|
|
74
|
+
getMonthProps: (currMonth: Month) => {
|
|
75
|
+
'data-date': number;
|
|
76
|
+
'aria-selected': boolean;
|
|
77
|
+
ref: (node: HTMLButtonElement) => void;
|
|
78
|
+
tabIndex: number;
|
|
79
|
+
disabled: boolean | undefined;
|
|
80
|
+
onClick: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
81
|
+
};
|
|
82
|
+
getYearProps: (year: Date) => {
|
|
83
|
+
'data-date': number;
|
|
84
|
+
'aria-selected': boolean;
|
|
85
|
+
ref: (node: HTMLButtonElement) => void;
|
|
86
|
+
tabIndex: number;
|
|
87
|
+
onClick: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
88
|
+
};
|
|
89
|
+
getRootProps: ({ ref }: {
|
|
90
|
+
ref?: Ref<HTMLDivElement> | undefined;
|
|
91
|
+
}) => {
|
|
92
|
+
onKeyDown: (event: KeyboardEvent<HTMLDivElement>) => void;
|
|
93
|
+
ref: (instance: HTMLDivElement | null) => void;
|
|
94
|
+
tabIndex: number;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
export { UseCalendarProps, useCalendar };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { DateShift, Day, DayAddons, Month, SpecialDays, SpecialDaysAddon } from "./typings-5684a67d";
|
|
3
|
+
declare const DAYS_IN_WEEK = 7;
|
|
4
|
+
declare const MONTHS_IN_YEAR = 12;
|
|
5
|
+
declare const SUNDAY_INDEX = 6;
|
|
6
|
+
declare const DATE_FORMAT = "dd.MM.yyyy";
|
|
7
|
+
declare const NATIVE_DATE_FORMAT = "yyyy-MM-dd";
|
|
8
|
+
declare const WEEKDAYS: string[];
|
|
9
|
+
declare const MONTHS: string[];
|
|
10
|
+
/**
|
|
11
|
+
* Возвращает «правильный» индекс дня недели, 0 - пн, 1 - вт и так далее.
|
|
12
|
+
*/
|
|
13
|
+
declare function russianWeekDay(date: Date): number;
|
|
14
|
+
/**
|
|
15
|
+
* Возвращает таблицу-календарь с заполненными датами для переданного месяца
|
|
16
|
+
*/
|
|
17
|
+
declare function generateWeeks(month: Date, options: {
|
|
18
|
+
minDate?: Date;
|
|
19
|
+
maxDate?: Date;
|
|
20
|
+
selected?: Date;
|
|
21
|
+
eventsMap?: SpecialDays;
|
|
22
|
+
offDaysMap?: SpecialDays;
|
|
23
|
+
holidaysMap?: SpecialDays;
|
|
24
|
+
dayAddonsMap?: SpecialDaysAddon;
|
|
25
|
+
}): Day[][];
|
|
26
|
+
/**
|
|
27
|
+
* Возвращает массив с месяцами для переданного года
|
|
28
|
+
*/
|
|
29
|
+
declare function generateMonths(year: Date, options: {
|
|
30
|
+
minMonth?: Date;
|
|
31
|
+
maxMonth?: Date;
|
|
32
|
+
}): Month[];
|
|
33
|
+
/**
|
|
34
|
+
* Возвращает массив лет от minYear до maxYear
|
|
35
|
+
*/
|
|
36
|
+
declare function generateYears(minYear: Date, maxYear: Date): Date[];
|
|
37
|
+
/**
|
|
38
|
+
* Добавляет метаданные для переданного дня
|
|
39
|
+
*/
|
|
40
|
+
declare function buildDay(day: Date, options: {
|
|
41
|
+
minDate?: Date;
|
|
42
|
+
maxDate?: Date;
|
|
43
|
+
selected?: Date;
|
|
44
|
+
eventsMap?: SpecialDays;
|
|
45
|
+
offDaysMap?: SpecialDays;
|
|
46
|
+
holidaysMap?: SpecialDays;
|
|
47
|
+
dayAddonsMap?: SpecialDaysAddon;
|
|
48
|
+
}): Day;
|
|
49
|
+
/**
|
|
50
|
+
* Добавляет метаданные для переданного месяца
|
|
51
|
+
*/
|
|
52
|
+
declare function buildMonth(month: Date, options: {
|
|
53
|
+
minMonth?: Date;
|
|
54
|
+
maxMonth?: Date;
|
|
55
|
+
}): Month;
|
|
56
|
+
/**
|
|
57
|
+
* Ограничивает дату на отрезке [minDate, maxDate]
|
|
58
|
+
*/
|
|
59
|
+
declare function limitDate(date: Date | number, minDate?: Date | number, maxDate?: Date | number): Date;
|
|
60
|
+
/**
|
|
61
|
+
* Проверяет, находится ли переданная дата в указанных границах
|
|
62
|
+
*/
|
|
63
|
+
declare function dateInLimits(date?: Date | number | null, minDate?: Date | number, maxDate?: Date | number): boolean | 0 | null | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Возвращает русское название месяца с большой буквы
|
|
66
|
+
*/
|
|
67
|
+
declare function monthName(month: Date): string;
|
|
68
|
+
/**
|
|
69
|
+
* Превращает массив в объект, у которого ключи составляются из элементов массива
|
|
70
|
+
*/
|
|
71
|
+
declare function dateArrayToHashTable(arr: Array<Date | number>): Record<number, boolean>;
|
|
72
|
+
declare function addonArrayToHashTable(arr: DayAddons[]): Record<number, ReactNode>;
|
|
73
|
+
/**
|
|
74
|
+
* Возвращает корректный отрезок дат для выделения
|
|
75
|
+
*/
|
|
76
|
+
declare function getSelectionRange(from?: Date | number, to?: Date | number, highlighted?: Date | number): {
|
|
77
|
+
start: Date;
|
|
78
|
+
end: Date;
|
|
79
|
+
} | null;
|
|
80
|
+
declare function modifyDateByShift(shift: DateShift, date: Date, minDate?: Date, maxDate?: Date, offDaysMap?: Record<number, boolean>): Date;
|
|
81
|
+
/**
|
|
82
|
+
* Если дата была выбрана мышкой — фокусную обводку не видно
|
|
83
|
+
* TODO: добавить в useFocus возможность переключать метод ввода программно
|
|
84
|
+
*/
|
|
85
|
+
declare function simulateTab(node: HTMLElement): void;
|
|
86
|
+
declare const formatDate: (date: Date | number, dateFormat?: string) => string;
|
|
87
|
+
declare const parseDateString: (value: string, dateFormat?: string) => Date;
|
|
88
|
+
export { DAYS_IN_WEEK, MONTHS_IN_YEAR, SUNDAY_INDEX, DATE_FORMAT, NATIVE_DATE_FORMAT, WEEKDAYS, MONTHS, russianWeekDay, generateWeeks, generateMonths, generateYears, buildDay, buildMonth, limitDate, dateInLimits, monthName, dateArrayToHashTable, addonArrayToHashTable, getSelectionRange, modifyDateByShift, simulateTab, formatDate, parseDateString };
|
package/package.json
CHANGED
|
@@ -1,11 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfalab/core-components-date-range-input",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"module": "./esm/index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./esm/index.js",
|
|
12
|
+
"require": "./index.js"
|
|
13
|
+
},
|
|
14
|
+
"./mobile": {
|
|
15
|
+
"import": "./esm/mobile.js",
|
|
16
|
+
"require": "./mobile.js"
|
|
17
|
+
},
|
|
18
|
+
"./desktop": {
|
|
19
|
+
"import": "./esm/desktop.js",
|
|
20
|
+
"require": "./desktop.js"
|
|
21
|
+
},
|
|
22
|
+
"./esm": "./esm/index.js",
|
|
23
|
+
"./cssm": "./cssm/index.js",
|
|
24
|
+
"./modern": "./modern/index.js",
|
|
25
|
+
"./esm/*": "./esm/*",
|
|
26
|
+
"./cssm/*": "./cssm/*",
|
|
27
|
+
"./modern/*": "./modern/*"
|
|
28
|
+
},
|
|
9
29
|
"publishConfig": {
|
|
10
30
|
"access": "public",
|
|
11
31
|
"directory": "dist"
|
|
@@ -15,10 +35,10 @@
|
|
|
15
35
|
"react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0"
|
|
16
36
|
},
|
|
17
37
|
"dependencies": {
|
|
18
|
-
"@alfalab/core-components-input": "^
|
|
19
|
-
"@alfalab/core-components-icon-button": "^6.
|
|
20
|
-
"@alfalab/core-components-calendar": "^
|
|
21
|
-
"@alfalab/core-components-popover": "^6.0
|
|
38
|
+
"@alfalab/core-components-input": "^12.0.0",
|
|
39
|
+
"@alfalab/core-components-icon-button": "^6.2.0",
|
|
40
|
+
"@alfalab/core-components-calendar": "^7.0.0",
|
|
41
|
+
"@alfalab/core-components-popover": "^6.1.0",
|
|
22
42
|
"@alfalab/hooks": "^1.13.0",
|
|
23
43
|
"classnames": "^2.3.1",
|
|
24
44
|
"tslib": "^2.4.0"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
|
|
3
|
+
import { CalendarDesktop } from '@alfalab/core-components-calendar/desktop';
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
5
|
+
import { InputProps } from '@alfalab/core-components-input';
|
|
6
|
+
import { InputDesktop } from '@alfalab/core-components-input/desktop';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
ConditionalProps,
|
|
10
|
+
DateRangeInput,
|
|
11
|
+
DateRangeInputProps,
|
|
12
|
+
} from './components/date-range-input';
|
|
13
|
+
|
|
14
|
+
export type DateRangeInputDesktopProps = Omit<
|
|
15
|
+
DateRangeInputProps,
|
|
16
|
+
'view' | 'picker' | 'onClose' | 'InputComponent'
|
|
17
|
+
> &
|
|
18
|
+
ConditionalProps;
|
|
19
|
+
|
|
20
|
+
export const DateRangeInputDesktop = forwardRef<HTMLInputElement, DateRangeInputDesktopProps>(
|
|
21
|
+
(props, ref) => (
|
|
22
|
+
<DateRangeInput
|
|
23
|
+
InputComponent={InputDesktop}
|
|
24
|
+
Calendar={CalendarDesktop}
|
|
25
|
+
{...props}
|
|
26
|
+
ref={ref}
|
|
27
|
+
/>
|
|
28
|
+
),
|
|
29
|
+
);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
|
|
3
|
+
import { CalendarMobile } from '@alfalab/core-components-calendar/mobile';
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
5
|
+
import { InputProps } from '@alfalab/core-components-input';
|
|
6
|
+
import { InputMobile } from '@alfalab/core-components-input/mobile';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
ConditionalProps,
|
|
10
|
+
DateRangeInput,
|
|
11
|
+
DateRangeInputProps,
|
|
12
|
+
} from './components/date-range-input';
|
|
13
|
+
|
|
14
|
+
export type DateRangeInputMobileProps = Omit<
|
|
15
|
+
DateRangeInputProps,
|
|
16
|
+
'view' | 'picker' | 'onClose' | 'InputComponent'
|
|
17
|
+
> &
|
|
18
|
+
ConditionalProps;
|
|
19
|
+
|
|
20
|
+
export const DateRangeInputMobile = forwardRef<HTMLInputElement, DateRangeInputMobileProps>(
|
|
21
|
+
(props, ref) => (
|
|
22
|
+
<DateRangeInput
|
|
23
|
+
InputComponent={InputMobile}
|
|
24
|
+
Calendar={CalendarMobile}
|
|
25
|
+
view='mobile'
|
|
26
|
+
{...props}
|
|
27
|
+
ref={ref}
|
|
28
|
+
/>
|
|
29
|
+
),
|
|
30
|
+
);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import { InputProps } from '@alfalab/core-components-input';
|
|
5
|
+
import { useMedia } from '@alfalab/hooks';
|
|
6
|
+
|
|
7
|
+
import { ConditionalProps, DateRangeInputProps } from './components/date-range-input';
|
|
8
|
+
import { DateRangeInputDesktop } from './Component.desktop';
|
|
9
|
+
import { DateRangeInputMobile } from './Component.mobile';
|
|
10
|
+
|
|
11
|
+
export type DateRangeInputResponsiveProps = Omit<
|
|
12
|
+
DateRangeInputProps,
|
|
13
|
+
'view' | 'picker' | 'onClose' | 'InputComponent'
|
|
14
|
+
> &
|
|
15
|
+
ConditionalProps & {
|
|
16
|
+
/**
|
|
17
|
+
* Контрольная точка, с нее начинается desktop версия
|
|
18
|
+
* @default 1024
|
|
19
|
+
*/
|
|
20
|
+
breakpoint?: number;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type DateRangeInputMedia = 'desktop' | 'mobile';
|
|
24
|
+
|
|
25
|
+
export const DateRangeInputResponsive = forwardRef<HTMLInputElement, DateRangeInputResponsiveProps>(
|
|
26
|
+
({ breakpoint = 1024, ...restProps }, ref) => {
|
|
27
|
+
const [view] = useMedia<DateRangeInputMedia>(
|
|
28
|
+
[
|
|
29
|
+
['mobile', `(max-width: ${breakpoint - 1}px)`],
|
|
30
|
+
['desktop', `(min-width: ${breakpoint}px)`],
|
|
31
|
+
],
|
|
32
|
+
'desktop',
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
return view === 'desktop' ? (
|
|
36
|
+
<DateRangeInputDesktop {...restProps} ref={ref} />
|
|
37
|
+
) : (
|
|
38
|
+
<DateRangeInputMobile {...restProps} ref={ref} />
|
|
39
|
+
);
|
|
40
|
+
},
|
|
41
|
+
);
|