@alfalab/core-components-calendar-range 7.1.6 → 7.2.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 (110) hide show
  1. package/Component-5684a67d.d.ts +18 -0
  2. package/Component-63dec22f.d.ts +24 -0
  3. package/Component-8c6198cc.d.ts +23 -0
  4. package/Component.desktop-2e2b2125.d.ts +6 -0
  5. package/Component.desktop-8c6198cc.d.ts +134 -0
  6. package/Component.js +4 -2
  7. package/Component.responsive-2e2b2125.d.ts +68 -0
  8. package/components/divider/Component.js +1 -1
  9. package/components/divider/index.css +8 -8
  10. package/cssm/Component-5684a67d.d.ts +18 -0
  11. package/cssm/Component-63dec22f.d.ts +24 -0
  12. package/cssm/Component-8c6198cc.d.ts +23 -0
  13. package/cssm/Component.desktop-2e2b2125.d.ts +6 -0
  14. package/cssm/Component.desktop-8c6198cc.d.ts +134 -0
  15. package/cssm/Component.js +3 -1
  16. package/cssm/Component.responsive-2e2b2125.d.ts +68 -0
  17. package/cssm/desktop-63dec22f.d.ts +2 -0
  18. package/cssm/index-9211a437.d.ts +2 -0
  19. package/cssm/index-ebda875c.d.ts +2 -0
  20. package/cssm/index-f034f741.d.ts +2 -0
  21. package/cssm/index.js +3 -1
  22. package/cssm/shared-848397c5.d.ts +35 -0
  23. package/cssm/shared-c111a9fd.d.ts +13 -0
  24. package/cssm/typings-5684a67d.d.ts +23 -0
  25. package/cssm/typings-9211a437.d.ts +95 -0
  26. package/cssm/useCalendar-71d94e2b.d.ts +97 -0
  27. package/cssm/utils-8c6198cc.d.ts +88 -0
  28. package/cssm/utils-e0a54580.d.ts +8 -0
  29. package/cssm/views/popover.js +9 -8
  30. package/cssm/views/static.js +18 -17
  31. package/desktop-63dec22f.d.ts +2 -0
  32. package/esm/Component-5684a67d.d.ts +18 -0
  33. package/esm/Component-63dec22f.d.ts +24 -0
  34. package/esm/Component-8c6198cc.d.ts +23 -0
  35. package/esm/Component.desktop-2e2b2125.d.ts +6 -0
  36. package/esm/Component.desktop-8c6198cc.d.ts +134 -0
  37. package/esm/Component.js +4 -2
  38. package/esm/Component.responsive-2e2b2125.d.ts +68 -0
  39. package/esm/components/divider/Component.js +1 -1
  40. package/esm/components/divider/index.css +8 -8
  41. package/esm/desktop-63dec22f.d.ts +2 -0
  42. package/esm/index-9211a437.d.ts +2 -0
  43. package/esm/index-ebda875c.d.ts +2 -0
  44. package/esm/index-f034f741.d.ts +2 -0
  45. package/esm/index.js +4 -2
  46. package/esm/index.module-a7e95baa.js +4 -0
  47. package/esm/shared-848397c5.d.ts +35 -0
  48. package/esm/shared-c111a9fd.d.ts +13 -0
  49. package/esm/typings-5684a67d.d.ts +23 -0
  50. package/esm/typings-9211a437.d.ts +95 -0
  51. package/esm/useCalendar-71d94e2b.d.ts +97 -0
  52. package/esm/utils-8c6198cc.d.ts +88 -0
  53. package/esm/utils-e0a54580.d.ts +8 -0
  54. package/esm/views/index.css +7 -7
  55. package/esm/views/popover.js +3 -2
  56. package/esm/views/static.js +6 -5
  57. package/index-9211a437.d.ts +2 -0
  58. package/index-ebda875c.d.ts +2 -0
  59. package/index-f034f741.d.ts +2 -0
  60. package/index.js +4 -2
  61. package/index.module-41e6ec4a.js +6 -0
  62. package/modern/Component-5684a67d.d.ts +18 -0
  63. package/modern/Component-63dec22f.d.ts +24 -0
  64. package/modern/Component-8c6198cc.d.ts +23 -0
  65. package/modern/Component.desktop-2e2b2125.d.ts +6 -0
  66. package/modern/Component.desktop-8c6198cc.d.ts +134 -0
  67. package/modern/Component.js +4 -2
  68. package/modern/Component.responsive-2e2b2125.d.ts +68 -0
  69. package/modern/components/divider/Component.js +1 -1
  70. package/modern/components/divider/index.css +8 -8
  71. package/modern/desktop-63dec22f.d.ts +2 -0
  72. package/modern/index-9211a437.d.ts +2 -0
  73. package/modern/index-ebda875c.d.ts +2 -0
  74. package/modern/index-f034f741.d.ts +2 -0
  75. package/modern/index.js +4 -2
  76. package/modern/index.module-f2d65966.js +4 -0
  77. package/modern/shared-848397c5.d.ts +35 -0
  78. package/modern/shared-c111a9fd.d.ts +13 -0
  79. package/modern/typings-5684a67d.d.ts +23 -0
  80. package/modern/typings-9211a437.d.ts +95 -0
  81. package/modern/useCalendar-71d94e2b.d.ts +97 -0
  82. package/modern/utils-8c6198cc.d.ts +88 -0
  83. package/modern/utils-e0a54580.d.ts +8 -0
  84. package/modern/views/index.css +7 -7
  85. package/modern/views/popover.js +3 -2
  86. package/modern/views/static.js +6 -5
  87. package/package.json +4 -4
  88. package/shared-848397c5.d.ts +35 -0
  89. package/shared-c111a9fd.d.ts +13 -0
  90. package/src/Component.tsx +113 -0
  91. package/src/components/divider/Component.tsx +23 -0
  92. package/src/components/divider/index.module.css +41 -0
  93. package/src/components/divider/index.ts +1 -0
  94. package/src/hooks.ts +201 -0
  95. package/src/index.ts +1 -0
  96. package/src/utils.ts +2 -0
  97. package/src/views/index.module.css +28 -0
  98. package/src/views/popover.tsx +223 -0
  99. package/src/views/static.tsx +338 -0
  100. package/typings-5684a67d.d.ts +23 -0
  101. package/typings-9211a437.d.ts +95 -0
  102. package/useCalendar-71d94e2b.d.ts +97 -0
  103. package/utils-8c6198cc.d.ts +88 -0
  104. package/utils-e0a54580.d.ts +8 -0
  105. package/views/index.css +7 -7
  106. package/views/popover.js +10 -9
  107. package/views/static.js +19 -18
  108. package/esm/index.module-8ff2af7b.js +0 -4
  109. package/index.module-bda4cfcc.js +0 -6
  110. package/modern/index.module-0176534f.js +0 -4
package/cssm/index.js CHANGED
@@ -9,6 +9,7 @@ require('./views/popover.js');
9
9
  require('classnames');
10
10
  require('date-fns/startOfMonth');
11
11
  require('@alfalab/core-components-calendar-input/cssm');
12
+ require('@alfalab/core-components-calendar-input/cssm/shared');
12
13
  require('@alfalab/core-components-date-input/cssm');
13
14
  require('@alfalab/hooks');
14
15
  require('./components/divider/Component.js');
@@ -23,7 +24,8 @@ require('./views/index.module.css');
23
24
  require('./views/static.js');
24
25
  require('date-fns/endOfMonth');
25
26
  require('date-fns/isSameMonth');
26
- require('@alfalab/core-components-calendar/cssm');
27
+ require('@alfalab/core-components-calendar/cssm/desktop');
28
+ require('@alfalab/core-components-calendar/cssm/shared');
27
29
  require('./utils.js');
28
30
 
29
31
 
@@ -0,0 +1,35 @@
1
+ // eslint-disable-next-line @typescript-eslint/naming-convention
2
+ type usePeriodProps = {
3
+ /**
4
+ * Обработчик изменения выделенного периода
5
+ */
6
+ onPeriodChange?: (selectedFrom?: number, selectedTo?: number) => void;
7
+ /**
8
+ * Начальное значение начала выделенного периода
9
+ */
10
+ initialSelectedFrom?: number;
11
+ /**
12
+ * Начальное значение конца выделенного периода
13
+ */
14
+ initialSelectedTo?: number;
15
+ };
16
+ declare function usePeriod({ onPeriodChange, initialSelectedFrom, initialSelectedTo }?: usePeriodProps): {
17
+ selectedFrom: number | undefined;
18
+ selectedTo: number | undefined;
19
+ setStart: (date?: number) => void;
20
+ setEnd: (date?: number) => void;
21
+ resetPeriod: () => void;
22
+ updatePeriod: (date?: number) => void;
23
+ };
24
+ declare function usePeriodWithReset({ onPeriodChange, initialSelectedFrom, initialSelectedTo }?: usePeriodProps): {
25
+ selectedFrom: number | undefined;
26
+ selectedTo: number | undefined;
27
+ setStart: (date?: number) => void;
28
+ setEnd: (date?: number) => void;
29
+ resetPeriod: () => void;
30
+ updatePeriod: (date?: number) => void;
31
+ };
32
+ export { usePeriod, usePeriodWithReset };
33
+ export { russianWeekDay, dateInLimits, limitDate, monthName, DAYS_IN_WEEK, MONTHS, MONTHS_IN_YEAR, SUNDAY_INDEX, WEEKDAYS, DATE_FORMAT } from "./utils-8c6198cc";
34
+ export { useCalendar } from "./useCalendar-71d94e2b";
35
+ export * from "./index-f034f741";
@@ -0,0 +1,13 @@
1
+ declare const DATE_FORMAT = "dd.MM.yyyy";
2
+ declare const NATIVE_DATE_FORMAT = "yyyy-MM-dd";
3
+ declare const DATE_MASK: (string | RegExp)[];
4
+ declare const IS_BROWSER: boolean;
5
+ declare const SUPPORTS_INPUT_TYPE_DATE: boolean;
6
+ declare const formatDate: (date: Date | number, dateFormat?: string) => string;
7
+ declare const parseDateString: (value: string, dateFormat?: string) => Date;
8
+ /**
9
+ * Возвращает `true`, если поддерживается `input[type="date"]`
10
+ */
11
+ declare function isInputDateSupported(): boolean;
12
+ declare const isValidInputValue: (newInputValue: string | undefined, minDate: number | undefined, maxDate: number | undefined, offDays?: Array<number | Date>) => boolean;
13
+ export { DATE_FORMAT, NATIVE_DATE_FORMAT, DATE_MASK, IS_BROWSER, SUPPORTS_INPUT_TYPE_DATE, formatDate, parseDateString, isInputDateSupported, isValidInputValue };
@@ -0,0 +1,23 @@
1
+ import { ReactNode } from 'react';
2
+ type SpecialDays = Record<number, boolean>;
3
+ type DayAddons = {
4
+ date: Date | number;
5
+ addon: ReactNode;
6
+ };
7
+ type SpecialDaysAddon = Record<number, ReactNode>;
8
+ type Day = {
9
+ date: Date;
10
+ disabled?: boolean;
11
+ event?: boolean;
12
+ selected?: boolean;
13
+ holiday?: boolean;
14
+ dayAddon?: ReactNode;
15
+ };
16
+ type Month = {
17
+ date: Date;
18
+ disabled?: boolean;
19
+ };
20
+ type DateShift = 'prev' | 'prevWeek' | 'prevMonth' | 'startOfWeek' | 'next' | 'nextWeek' | 'nextMonth' | 'endOfWeek';
21
+ type View = 'years' | 'months' | 'days';
22
+ type SelectorView = 'month-only' | 'full';
23
+ export { SpecialDays, DayAddons, SpecialDaysAddon, Day, Month, DateShift, View, SelectorView };
@@ -0,0 +1,95 @@
1
+ import { AnchorHTMLAttributes, ButtonHTMLAttributes, ElementType, ReactNode } from 'react';
2
+ type StyleColors = {
3
+ default: {
4
+ [key: string]: string;
5
+ };
6
+ inverted: {
7
+ [key: string]: string;
8
+ };
9
+ };
10
+ type ComponentProps = {
11
+ /**
12
+ * Тип кнопки
13
+ * @default secondary
14
+ */
15
+ view?: 'accent' | 'primary' | 'secondary' | 'tertiary' | 'outlined' | 'filled' | 'transparent' | 'link' | 'ghost';
16
+ /**
17
+ * Слот слева
18
+ */
19
+ leftAddons?: ReactNode;
20
+ /**
21
+ * Слот справа
22
+ */
23
+ rightAddons?: ReactNode;
24
+ /**
25
+ * Размер компонента
26
+ * @default m
27
+ */
28
+ size?: 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl';
29
+ /**
30
+ * Растягивает компонент на ширину контейнера
31
+ * @default false
32
+ */
33
+ block?: boolean;
34
+ /**
35
+ * Дополнительный класс
36
+ */
37
+ className?: string;
38
+ /**
39
+ * Дополнительный класс для спиннера
40
+ */
41
+ spinnerClassName?: string;
42
+ /**
43
+ * Выводит ссылку в виде кнопки
44
+ */
45
+ href?: string;
46
+ /**
47
+ * Позволяет использовать кастомный компонент для кнопки (например Link из роутера)
48
+ */
49
+ Component?: ElementType;
50
+ /**
51
+ * Идентификатор для систем автоматизированного тестирования
52
+ */
53
+ dataTestId?: string;
54
+ /**
55
+ * Показать лоадер
56
+ * @default false
57
+ */
58
+ loading?: boolean;
59
+ /**
60
+ * Не переносить текст кнопки на новую строку
61
+ * @default false
62
+ */
63
+ nowrap?: boolean;
64
+ /**
65
+ * Набор цветов для компонента
66
+ */
67
+ colors?: 'default' | 'inverted';
68
+ /**
69
+ * Дочерние элементы.
70
+ */
71
+ children?: ReactNode;
72
+ /**
73
+ * Основные стили компонента.
74
+ */
75
+ styles: {
76
+ [key: string]: string;
77
+ };
78
+ /**
79
+ * Стили компонента для default и inverted режима.
80
+ */
81
+ colorStylesMap: StyleColors;
82
+ };
83
+ type AnchorBaseButtonProps = ComponentProps & AnchorHTMLAttributes<HTMLAnchorElement>;
84
+ type NativeBaseButtonProps = ComponentProps & ButtonHTMLAttributes<HTMLButtonElement>;
85
+ type BaseButtonProps = Partial<AnchorBaseButtonProps | NativeBaseButtonProps>;
86
+ type AnchorButtonProps = Omit<BaseButtonProps, 'styles' | 'colorStylesMap'> & AnchorHTMLAttributes<HTMLAnchorElement>;
87
+ type NativeButtonProps = Omit<BaseButtonProps, 'styles' | 'colorStylesMap'> & ButtonHTMLAttributes<HTMLButtonElement>;
88
+ type ButtonProps = Partial<AnchorButtonProps | NativeButtonProps> & {
89
+ /**
90
+ * Контрольная точка, с нее начинается desktop версия
91
+ * @default 1024
92
+ */
93
+ breakpoint?: number;
94
+ };
95
+ export { StyleColors, ComponentProps, AnchorBaseButtonProps, NativeBaseButtonProps, BaseButtonProps, AnchorButtonProps, NativeButtonProps, ButtonProps };
@@ -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 };
@@ -0,0 +1,8 @@
1
+ import { PeriodType } from "./index-f034f741";
2
+ declare const formatPeriod: (valueFrom: Date, valueTo: Date, periodType: PeriodType, showCurrentYear?: boolean) => string;
3
+ declare const getYearSelectorValue: (valueFrom: Date | undefined, showCurrentYear: boolean) => number | "";
4
+ declare const shiftValues: (valueFrom: Date, valueTo: Date, periodType: PeriodType, direction: 'prev' | 'next') => {
5
+ valueFrom: Date;
6
+ valueTo: Date;
7
+ };
8
+ export { formatPeriod, getYearSelectorValue, shiftValues };
@@ -7,6 +7,7 @@ var React = require('react');
7
7
  var cn = require('classnames');
8
8
  var startOfMonth = require('date-fns/startOfMonth');
9
9
  var coreComponentsCalendarInput = require('@alfalab/core-components-calendar-input/cssm');
10
+ var shared = require('@alfalab/core-components-calendar-input/cssm/shared');
10
11
  var coreComponentsDateInput = require('@alfalab/core-components-date-input/cssm');
11
12
  var hooks$1 = require('@alfalab/hooks');
12
13
  var components_divider_Component = require('../components/divider/Component.js');
@@ -36,17 +37,17 @@ var CalendarRangePopover = function (_a) {
36
37
  * — при следующем открытии в календаре будет установлен начальный месяц
37
38
  */
38
39
  var _o = React.useState(0), resetKey = _o[0], setResetKey = _o[1];
39
- var dateFrom = coreComponentsCalendarInput.isValidInputValue(inputFromValue, minDate, maxDate, offDays)
40
- ? coreComponentsCalendarInput.parseDateString(inputFromValue).getTime()
40
+ var dateFrom = shared.isValidInputValue(inputFromValue, minDate, maxDate, offDays)
41
+ ? shared.parseDateString(inputFromValue).getTime()
41
42
  : null;
42
- var dateTo = coreComponentsCalendarInput.isValidInputValue(inputToValue, dateFrom || minDate, maxDate, offDays)
43
- ? coreComponentsCalendarInput.parseDateString(inputToValue).getTime()
43
+ var dateTo = shared.isValidInputValue(inputToValue, dateFrom || minDate, maxDate, offDays)
44
+ ? shared.parseDateString(inputToValue).getTime()
44
45
  : null;
45
46
  var _p = React.useState(coreComponentsDateInput.isCompleteDateInput(inputFromValue) && dateFrom === null), inputFromInvalid = _p[0], setInputFromInvalid = _p[1];
46
47
  var _q = React.useState(coreComponentsDateInput.isCompleteDateInput(inputToValue) && dateTo === null), inputToInvalid = _q[0], setInputToInvalid = _q[1];
47
48
  var bothInvalid = coreComponentsDateInput.isCompleteDateInput(inputFromValue) &&
48
49
  coreComponentsDateInput.isCompleteDateInput(inputToValue) &&
49
- coreComponentsCalendarInput.parseDateString(inputFromValue).getTime() > coreComponentsCalendarInput.parseDateString(inputToValue).getTime();
50
+ shared.parseDateString(inputFromValue).getTime() > shared.parseDateString(inputToValue).getTime();
50
51
  var hasValidateError = inputFromInvalid || inputToInvalid || bothInvalid;
51
52
  var _r = hooks.usePopoverViewMonthes({
52
53
  dateFrom: dateFrom,
@@ -55,11 +56,11 @@ var CalendarRangePopover = function (_a) {
55
56
  resetKey: resetKey,
56
57
  }), monthFrom = _r.monthFrom, monthTo = _r.monthTo, handleMonthFromChange = _r.handleMonthFromChange, handleMonthToChange = _r.handleMonthToChange;
57
58
  var handleValidInputFrom = React.useCallback(function () {
58
- setInputFromInvalid(inputFromValue !== '' && !coreComponentsCalendarInput.isValidInputValue(inputFromValue, minDate, maxDate, offDays));
59
+ setInputFromInvalid(inputFromValue !== '' && !shared.isValidInputValue(inputFromValue, minDate, maxDate, offDays));
59
60
  }, [inputFromValue, maxDate, minDate, offDays]);
60
61
  var handleValidInputTo = React.useCallback(function () {
61
62
  setInputToInvalid(inputToValue !== '' &&
62
- !coreComponentsCalendarInput.isValidInputValue(inputToValue, dateFrom || minDate, maxDate, offDays));
63
+ !shared.isValidInputValue(inputToValue, dateFrom || minDate, maxDate, offDays));
63
64
  }, [dateFrom, inputToValue, maxDate, minDate, offDays]);
64
65
  var handleInputFromChange = function (event, payload) {
65
66
  var _a;
@@ -109,7 +110,7 @@ var CalendarRangePopover = function (_a) {
109
110
  // eslint-disable-next-line no-nested-ternary
110
111
  var inputDateTo = returnInvalidDates
111
112
  ? coreComponentsDateInput.isCompleteDateInput(inputToValue)
112
- ? coreComponentsCalendarInput.parseDateString(inputToValue).getTime()
113
+ ? shared.parseDateString(inputToValue).getTime()
113
114
  : null
114
115
  : dateTo;
115
116
  onChange({
@@ -11,8 +11,9 @@ var isSameMonth = require('date-fns/isSameMonth');
11
11
  var max = require('date-fns/max');
12
12
  var startOfMonth = require('date-fns/startOfMonth');
13
13
  var subMonths = require('date-fns/subMonths');
14
- var coreComponentsCalendar = require('@alfalab/core-components-calendar/cssm');
15
- var coreComponentsCalendarInput = require('@alfalab/core-components-calendar-input/cssm');
14
+ var desktop = require('@alfalab/core-components-calendar/cssm/desktop');
15
+ var shared$1 = require('@alfalab/core-components-calendar/cssm/shared');
16
+ var shared = require('@alfalab/core-components-calendar-input/cssm/shared');
16
17
  var coreComponentsDateInput = require('@alfalab/core-components-date-input/cssm');
17
18
  var components_divider_Component = require('../components/divider/Component.js');
18
19
  var hooks = require('../hooks.js');
@@ -38,25 +39,25 @@ var CalendarRangeStatic = function (_a) {
38
39
  var className = _a.className, _b = _a.defaultMonth, defaultMonth = _b === void 0 ? startOfMonth__default.default(new Date()).getTime() : _b, _c = _a.defaultMonthPosition, defaultMonthPosition = _c === void 0 ? 'left' : _c, minDate = _a.minDate, maxDate = _a.maxDate, _d = _a.valueFrom, valueFrom = _d === void 0 ? '' : _d, _e = _a.valueTo, valueTo = _e === void 0 ? '' : _e, _f = _a.onDateFromChange, onDateFromChange = _f === void 0 ? function () { return null; } : _f, _g = _a.onDateToChange, onDateToChange = _g === void 0 ? function () { return null; } : _g, _h = _a.onChange, onChange = _h === void 0 ? function () { return null; } : _h, onError = _a.onError, _j = _a.inputFromProps, inputFromProps = _j === void 0 ? {} : _j, _k = _a.inputToProps, inputToProps = _k === void 0 ? {} : _k, offDays = _a.offDays, events = _a.events, _l = _a.returnInvalidDates, returnInvalidDates = _l === void 0 ? false : _l, dataTestId = _a.dataTestId;
39
40
  var _m = React.useState(valueFrom), inputFromValue = _m[0], setInputFromValue = _m[1];
40
41
  var _o = React.useState(valueTo), inputToValue = _o[0], setInputToValue = _o[1];
41
- var dateFrom = coreComponentsCalendarInput.isValidInputValue(inputFromValue, minDate, maxDate, offDays)
42
- ? coreComponentsCalendarInput.parseDateString(inputFromValue).getTime()
42
+ var dateFrom = shared.isValidInputValue(inputFromValue, minDate, maxDate, offDays)
43
+ ? shared.parseDateString(inputFromValue).getTime()
43
44
  : null;
44
- var dateTo = coreComponentsCalendarInput.isValidInputValue(inputToValue, dateFrom || minDate, maxDate, offDays)
45
- ? coreComponentsCalendarInput.parseDateString(inputToValue).getTime()
45
+ var dateTo = shared.isValidInputValue(inputToValue, dateFrom || minDate, maxDate, offDays)
46
+ ? shared.parseDateString(inputToValue).getTime()
46
47
  : null;
47
48
  if (coreComponentsDateInput.isCompleteDateInput(inputToValue) && !dateTo && !returnInvalidDates) {
48
49
  dateFrom = null;
49
50
  }
50
51
  var bothInvalid = coreComponentsDateInput.isCompleteDateInput(inputFromValue) &&
51
52
  coreComponentsDateInput.isCompleteDateInput(inputToValue) &&
52
- coreComponentsCalendarInput.parseDateString(inputFromValue).getTime() > coreComponentsCalendarInput.parseDateString(inputToValue).getTime();
53
+ shared.parseDateString(inputFromValue).getTime() > shared.parseDateString(inputToValue).getTime();
53
54
  var _p = React.useState(undefined), highlightedDate = _p[0], setHighlightedDate = _p[1];
54
- var period = coreComponentsCalendar.usePeriodWithReset({
55
- initialSelectedFrom: dateFrom ? coreComponentsCalendarInput.parseDateString(inputFromValue).getTime() : undefined,
56
- initialSelectedTo: dateTo ? coreComponentsCalendarInput.parseDateString(inputToValue).getTime() : undefined,
55
+ var period = shared$1.usePeriodWithReset({
56
+ initialSelectedFrom: dateFrom ? shared.parseDateString(inputFromValue).getTime() : undefined,
57
+ initialSelectedTo: dateTo ? shared.parseDateString(inputToValue).getTime() : undefined,
57
58
  });
58
- var validateInputFromValue = React.useCallback(function (value) { return coreComponentsCalendarInput.isValidInputValue(value, minDate, dateFrom || maxDate, offDays); }, [dateFrom, maxDate, minDate, offDays]);
59
- var validateInputToValue = React.useCallback(function (value) { return coreComponentsCalendarInput.isValidInputValue(value, dateFrom || minDate, maxDate, offDays); }, [dateFrom, minDate, maxDate, offDays]);
59
+ var validateInputFromValue = React.useCallback(function (value) { return shared.isValidInputValue(value, minDate, dateFrom || maxDate, offDays); }, [dateFrom, maxDate, minDate, offDays]);
60
+ var validateInputToValue = React.useCallback(function (value) { return shared.isValidInputValue(value, dateFrom || minDate, maxDate, offDays); }, [dateFrom, minDate, maxDate, offDays]);
60
61
  var _q = React.useState(coreComponentsDateInput.isCompleteDateInput(inputFromValue) && dateFrom === null), inputFromInvalid = _q[0], setInputFromInvalid = _q[1];
61
62
  var _r = React.useState(coreComponentsDateInput.isCompleteDateInput(inputToValue) && dateTo === null), inputToInvalid = _r[0], setInputToInvalid = _r[1];
62
63
  var hasValidateError = bothInvalid || inputFromInvalid || inputToInvalid;
@@ -101,10 +102,10 @@ var CalendarRangeStatic = function (_a) {
101
102
  setInputToValue('');
102
103
  }, []);
103
104
  React.useEffect(function () {
104
- setInputFromValue(period.selectedFrom ? coreComponentsCalendarInput.formatDate(period.selectedFrom) : '');
105
+ setInputFromValue(period.selectedFrom ? shared.formatDate(period.selectedFrom) : '');
105
106
  }, [period.selectedFrom]);
106
107
  React.useEffect(function () {
107
- setInputToValue(period.selectedTo ? coreComponentsCalendarInput.formatDate(period.selectedTo) : '');
108
+ setInputToValue(period.selectedTo ? shared.formatDate(period.selectedTo) : '');
108
109
  }, [period.selectedTo]);
109
110
  React.useEffect(function () {
110
111
  setInputFromValue(valueFrom);
@@ -146,7 +147,7 @@ var CalendarRangeStatic = function (_a) {
146
147
  // eslint-disable-next-line no-nested-ternary
147
148
  var inputDateTo = returnInvalidDates
148
149
  ? coreComponentsDateInput.isCompleteDateInput(inputToValue)
149
- ? coreComponentsCalendarInput.parseDateString(inputToValue).getTime()
150
+ ? shared.parseDateString(inputToValue).getTime()
150
151
  : null
151
152
  : dateTo;
152
153
  onDateToChange({
@@ -169,8 +170,8 @@ var CalendarRangeStatic = function (_a) {
169
170
  // eslint-disable-next-line react-hooks/exhaustive-deps
170
171
  }, [hasValidateError]);
171
172
  var rangeProps = hooks.useSelectionProps(period.selectedFrom, period.selectedTo, highlightedDate);
172
- var CalendarFromComponent = dateInputFromProps.Calendar || coreComponentsCalendar.Calendar;
173
- var CalendarToComponent = dateInputToProps.Calendar || coreComponentsCalendar.Calendar;
173
+ var CalendarFromComponent = dateInputFromProps.Calendar || desktop.CalendarDesktop;
174
+ var CalendarToComponent = dateInputToProps.Calendar || desktop.CalendarDesktop;
174
175
  var minMaxInSameMonth = minDate && maxDate && isSameMonth__default.default(minDate, maxDate);
175
176
  return (
176
177
  // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
@@ -0,0 +1,2 @@
1
+ export * from "./Component.desktop-2e2b2125";
2
+ export {};
@@ -0,0 +1,18 @@
1
+ import { FC, ReactNode } from 'react';
2
+ import { SelectorView } from "./typings-5684a67d";
3
+ type HeaderProps = {
4
+ /**
5
+ * Вид шапки — месяц и год или только месяц
6
+ */
7
+ view?: SelectorView;
8
+ /**
9
+ * Отображать тень? (нужна при прокрутке)
10
+ */
11
+ withShadow?: boolean;
12
+ /**
13
+ * Дочерние элементы.
14
+ */
15
+ children?: ReactNode;
16
+ };
17
+ declare const Header: FC<HeaderProps>;
18
+ export { HeaderProps, Header };
@@ -0,0 +1,24 @@
1
+ /// <reference types="react" />
2
+ import React from 'react';
3
+ import { ButtonHTMLAttributes } from "react";
4
+ type SelectButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {
5
+ /**
6
+ * Дополнительный класс
7
+ */
8
+ className?: string;
9
+ /**
10
+ * Вид кнопки
11
+ */
12
+ view?: 'default' | 'filled' | 'outlined' | 'selected';
13
+ };
14
+ declare const SelectButton: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
15
+ /**
16
+ * Дополнительный класс
17
+ */
18
+ className?: string | undefined;
19
+ /**
20
+ * Вид кнопки
21
+ */
22
+ view?: "default" | "outlined" | "filled" | "selected" | undefined;
23
+ } & React.RefAttributes<HTMLButtonElement>>;
24
+ export { SelectButtonProps, SelectButton };
@@ -0,0 +1,23 @@
1
+ /// <reference types="react" />
2
+ import { FC } from 'react';
3
+ import { Month } from "./typings-5684a67d";
4
+ type MonthsTableProps = {
5
+ /**
6
+ * Массив месяцев
7
+ */
8
+ months?: Month[];
9
+ /**
10
+ * Выбранный месяц
11
+ */
12
+ selectedMonth?: Date;
13
+ /**
14
+ * Доп пропсы для переданного месяца
15
+ */
16
+ getMonthProps: (day: Month) => Record<string, unknown>;
17
+ /**
18
+ * Должен ли календарь подстраиваться под ширину родителя.
19
+ */
20
+ responsive?: boolean;
21
+ };
22
+ declare const MonthsTable: FC<MonthsTableProps>;
23
+ export { MonthsTableProps, MonthsTable };
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import React from 'react';
3
+ import { AnchorButtonProps, NativeButtonProps } from "./typings-9211a437";
4
+ type ButtonDesktopProps = Partial<AnchorButtonProps | NativeButtonProps>;
5
+ declare const ButtonDesktop: React.ForwardRefExoticComponent<ButtonDesktopProps & React.RefAttributes<HTMLAnchorElement | HTMLButtonElement>>;
6
+ export { ButtonDesktopProps, ButtonDesktop };