@alfalab/core-components-calendar-input 8.2.7 → 8.2.9
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.desktop.d.ts +4 -3
- package/Component.desktop.js +3 -2
- package/Component.mobile.d.ts +4 -3
- package/Component.mobile.js +3 -2
- package/Component.responsive.d.ts +10 -3
- package/Component.responsive.js +6 -5
- package/components/calendar-input/Component.d.ts +216 -0
- package/components/calendar-input/Component.js +135 -10
- package/components/calendar-input/index.css +11 -11
- package/components/calendar-input/index.d.ts +1 -1
- package/components/calendar-input/index.js +2 -1
- package/cssm/Component.desktop.d.ts +4 -3
- package/cssm/Component.desktop.js +3 -2
- package/cssm/Component.mobile.d.ts +4 -3
- package/cssm/Component.mobile.js +3 -2
- package/cssm/Component.responsive.d.ts +10 -3
- package/cssm/Component.responsive.js +6 -5
- package/cssm/components/calendar-input/Component.d.ts +216 -0
- package/cssm/components/calendar-input/Component.js +134 -11
- package/cssm/components/calendar-input/index.d.ts +1 -1
- package/cssm/components/calendar-input/index.js +2 -1
- package/cssm/desktop.js +2 -1
- package/cssm/index.js +4 -3
- package/cssm/mobile.js +3 -2
- package/cssm/responsive.js +4 -3
- package/desktop.js +2 -1
- package/esm/Component.desktop.d.ts +4 -3
- package/esm/Component.desktop.js +4 -3
- package/esm/Component.mobile.d.ts +4 -3
- package/esm/Component.mobile.js +4 -3
- package/esm/Component.responsive.d.ts +10 -3
- package/esm/Component.responsive.js +6 -5
- package/esm/components/calendar-input/Component.d.ts +216 -0
- package/esm/components/calendar-input/Component.js +132 -9
- package/esm/components/calendar-input/index.css +11 -11
- package/esm/components/calendar-input/index.d.ts +1 -1
- package/esm/components/calendar-input/index.js +2 -1
- package/esm/desktop.js +2 -1
- package/esm/index.js +4 -3
- package/esm/mobile.js +3 -2
- package/esm/responsive.js +4 -3
- package/index.js +4 -3
- package/mobile.js +3 -2
- package/modern/Component.desktop.d.ts +3 -2
- package/modern/Component.desktop.js +2 -2
- package/modern/Component.mobile.d.ts +3 -2
- package/modern/Component.mobile.js +2 -2
- package/modern/Component.responsive.d.ts +9 -2
- package/modern/Component.responsive.js +4 -4
- package/modern/components/calendar-input/Component.js +1 -1
- package/modern/components/calendar-input/index.css +11 -11
- package/package.json +6 -5
- package/responsive.js +4 -3
- package/Component-e779a21c.d.ts +0 -249
- package/Component-e779a21c.js +0 -179
- package/cssm/Component-fde0c12c.d.ts +0 -249
- package/cssm/Component-fde0c12c.js +0 -178
- package/esm/Component-e2c1f213.d.ts +0 -249
- package/esm/Component-e2c1f213.js +0 -170
package/Component.desktop.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { CalendarInputProps } from "./components/calendar-input/Component";
|
|
3
4
|
type CalendarInputDesktopProps = Omit<CalendarInputProps, 'view'>;
|
|
4
|
-
declare const CalendarInputDesktop:
|
|
5
|
+
declare const CalendarInputDesktop: React.ForwardRefExoticComponent<CalendarInputDesktopProps & React.RefAttributes<HTMLInputElement>>;
|
|
5
6
|
export { CalendarInputDesktopProps, CalendarInputDesktop };
|
package/Component.desktop.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var tslib = require('tslib');
|
|
4
4
|
var React = require('react');
|
|
5
|
+
var components_calendarInput_Component = require('./components/calendar-input/Component.js');
|
|
5
6
|
require('react-merge-refs');
|
|
6
7
|
require('classnames');
|
|
7
8
|
require('@alfalab/core-components-calendar');
|
|
@@ -17,6 +18,6 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
17
18
|
|
|
18
19
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
19
20
|
|
|
20
|
-
var CalendarInputDesktop = function (props) { return
|
|
21
|
+
var CalendarInputDesktop = React.forwardRef(function (props, ref) { return React__default.default.createElement(components_calendarInput_Component.CalendarInput, tslib.__assign({}, props, { ref: ref })); });
|
|
21
22
|
|
|
22
23
|
exports.CalendarInputDesktop = CalendarInputDesktop;
|
package/Component.mobile.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { CalendarInputProps } from "./components/calendar-input/Component";
|
|
3
4
|
type CalendarInputMobileProps = Omit<CalendarInputProps, 'view'>;
|
|
4
|
-
declare const CalendarInputMobile:
|
|
5
|
+
declare const CalendarInputMobile: React.ForwardRefExoticComponent<CalendarInputMobileProps & React.RefAttributes<HTMLInputElement>>;
|
|
5
6
|
export { CalendarInputMobileProps, CalendarInputMobile };
|
package/Component.mobile.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var tslib = require('tslib');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var coreComponentsCalendar = require('@alfalab/core-components-calendar');
|
|
6
|
+
var components_calendarInput_Component = require('./components/calendar-input/Component.js');
|
|
6
7
|
require('react-merge-refs');
|
|
7
8
|
require('classnames');
|
|
8
9
|
require('@alfalab/core-components-date-input');
|
|
@@ -17,6 +18,6 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
17
18
|
|
|
18
19
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
19
20
|
|
|
20
|
-
var CalendarInputMobile = function (props) { return
|
|
21
|
+
var CalendarInputMobile = React.forwardRef(function (props, ref) { return React__default.default.createElement(components_calendarInput_Component.CalendarInput, tslib.__assign({ Calendar: coreComponentsCalendar.CalendarMobile, view: 'mobile' }, props, { ref: ref })); });
|
|
21
22
|
|
|
22
23
|
exports.CalendarInputMobile = CalendarInputMobile;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { CalendarInputProps } from "./components/calendar-input/Component";
|
|
3
4
|
type CalendarInputResponsiveProps = Omit<CalendarInputProps, 'view'> & {
|
|
4
5
|
/**
|
|
5
6
|
* Контрольная точка, с нее начинается desktop версия
|
|
@@ -8,5 +9,11 @@ type CalendarInputResponsiveProps = Omit<CalendarInputProps, 'view'> & {
|
|
|
8
9
|
breakpoint?: number;
|
|
9
10
|
};
|
|
10
11
|
type CalendarInputMedia = 'desktop' | 'mobile';
|
|
11
|
-
declare const CalendarInputResponsive:
|
|
12
|
+
declare const CalendarInputResponsive: React.ForwardRefExoticComponent<Omit<CalendarInputProps, "view"> & {
|
|
13
|
+
/**
|
|
14
|
+
* Контрольная точка, с нее начинается desktop версия
|
|
15
|
+
* @default 1024
|
|
16
|
+
*/
|
|
17
|
+
breakpoint?: number | undefined;
|
|
18
|
+
} & React.RefAttributes<HTMLInputElement>>;
|
|
12
19
|
export { CalendarInputResponsiveProps, CalendarInputMedia, CalendarInputResponsive };
|
package/Component.responsive.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var tslib = require('tslib');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var hooks = require('@alfalab/hooks');
|
|
6
6
|
var Component_desktop = require('./Component.desktop.js');
|
|
7
7
|
var Component_mobile = require('./Component.mobile.js');
|
|
8
|
+
require('./components/calendar-input/Component.js');
|
|
8
9
|
require('react-merge-refs');
|
|
9
10
|
require('classnames');
|
|
10
11
|
require('@alfalab/core-components-calendar');
|
|
@@ -20,13 +21,13 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
20
21
|
|
|
21
22
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
22
23
|
|
|
23
|
-
var CalendarInputResponsive = function (_a) {
|
|
24
|
-
var _b = _a.breakpoint, breakpoint = _b === void 0 ? 1024 : _b, restProps =
|
|
24
|
+
var CalendarInputResponsive = React.forwardRef(function (_a, ref) {
|
|
25
|
+
var _b = _a.breakpoint, breakpoint = _b === void 0 ? 1024 : _b, restProps = tslib.__rest(_a, ["breakpoint"]);
|
|
25
26
|
var view = hooks.useMedia([
|
|
26
27
|
['mobile', "(max-width: ".concat(breakpoint - 1, "px)")],
|
|
27
28
|
['desktop', "(min-width: ".concat(breakpoint, "px)")],
|
|
28
29
|
], 'desktop')[0];
|
|
29
|
-
return view === 'desktop' ? (React__default.default.createElement(Component_desktop.CalendarInputDesktop,
|
|
30
|
-
};
|
|
30
|
+
return view === 'desktop' ? (React__default.default.createElement(Component_desktop.CalendarInputDesktop, tslib.__assign({}, restProps, { ref: ref }))) : (React__default.default.createElement(Component_mobile.CalendarInputMobile, tslib.__assign({}, restProps, { ref: ref })));
|
|
31
|
+
});
|
|
31
32
|
|
|
32
33
|
exports.CalendarInputResponsive = CalendarInputResponsive;
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ChangeEvent, ElementType, MouseEvent } from "react";
|
|
4
|
+
import { CalendarMobileProps, CalendarProps } from "@alfalab/core-components-calendar";
|
|
5
|
+
import { DateInputProps } from "@alfalab/core-components-date-input";
|
|
6
|
+
import { PopoverProps } from "@alfalab/core-components-popover";
|
|
7
|
+
type CalendarInputProps = Omit<DateInputProps, 'onChange' | 'mobileMode'> & {
|
|
8
|
+
/**
|
|
9
|
+
* Дополнительный класс
|
|
10
|
+
*/
|
|
11
|
+
className?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Дополнительный класс для инпута
|
|
14
|
+
*/
|
|
15
|
+
inputClassName?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Дополнительный класс для поповера
|
|
18
|
+
*/
|
|
19
|
+
popoverClassName?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Доп. пропсы для календаря
|
|
22
|
+
*/
|
|
23
|
+
calendarProps?: (CalendarProps & Record<string, unknown>) | (CalendarMobileProps & Record<string, unknown>);
|
|
24
|
+
/**
|
|
25
|
+
* Значение инпута (используется и для календаря)
|
|
26
|
+
*/
|
|
27
|
+
value?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Начальное значение инпута
|
|
30
|
+
*/
|
|
31
|
+
defaultValue?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Состояние открытия по умолчанию
|
|
34
|
+
*/
|
|
35
|
+
defaultOpen?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Месяц в календаре по умолчанию (timestamp)
|
|
38
|
+
*/
|
|
39
|
+
defaultMonth?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Минимальная дата, доступная для выбора (timestamp)
|
|
42
|
+
*/
|
|
43
|
+
minDate?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Максимальная дата, доступная для выбора (timestamp)
|
|
46
|
+
*/
|
|
47
|
+
maxDate?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Список событий
|
|
50
|
+
*/
|
|
51
|
+
events?: Array<Date | number>;
|
|
52
|
+
/**
|
|
53
|
+
* Список выходных
|
|
54
|
+
*/
|
|
55
|
+
offDays?: Array<Date | number>;
|
|
56
|
+
/**
|
|
57
|
+
* Определяет, как рендерить календарь — в поповере или снизу инпута
|
|
58
|
+
*/
|
|
59
|
+
calendarPosition?: 'static' | 'popover';
|
|
60
|
+
/**
|
|
61
|
+
* Запрещает поповеру менять свою позицию.
|
|
62
|
+
* Например, если места снизу недостаточно,то он все равно будет показан снизу
|
|
63
|
+
*/
|
|
64
|
+
preventFlip?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Управление нативным режимом на мобильных устройствах
|
|
67
|
+
*/
|
|
68
|
+
mobileMode?: 'native' | 'popover' | 'input';
|
|
69
|
+
/**
|
|
70
|
+
* Компонент календаря
|
|
71
|
+
*/
|
|
72
|
+
Calendar?: ElementType;
|
|
73
|
+
/**
|
|
74
|
+
* Обработчик изменения значения
|
|
75
|
+
*/
|
|
76
|
+
onChange?: (event: ChangeEvent<HTMLInputElement> | MouseEvent<HTMLButtonElement> | null, payload: {
|
|
77
|
+
date: Date;
|
|
78
|
+
value: string;
|
|
79
|
+
}) => void;
|
|
80
|
+
/**
|
|
81
|
+
* Обработчик ввода в инпут
|
|
82
|
+
*/
|
|
83
|
+
onInputChange?: (event: ChangeEvent<HTMLInputElement>, payload: {
|
|
84
|
+
value: string;
|
|
85
|
+
date: Date;
|
|
86
|
+
}) => void;
|
|
87
|
+
/**
|
|
88
|
+
* Обработчик изменения календаря
|
|
89
|
+
*/
|
|
90
|
+
onCalendarChange?: CalendarProps['onChange'];
|
|
91
|
+
/**
|
|
92
|
+
* Позиционирование поповера с календарем
|
|
93
|
+
*/
|
|
94
|
+
popoverPosition?: PopoverProps['position'];
|
|
95
|
+
/**
|
|
96
|
+
* z-index Popover
|
|
97
|
+
*/
|
|
98
|
+
zIndexPopover?: PopoverProps['zIndex'];
|
|
99
|
+
/**
|
|
100
|
+
* Календарь будет принимать ширину инпута
|
|
101
|
+
*/
|
|
102
|
+
useAnchorWidth?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Отображение компонента в мобильном или десктопном виде
|
|
105
|
+
*/
|
|
106
|
+
view?: 'desktop' | 'mobile';
|
|
107
|
+
};
|
|
108
|
+
declare const CalendarInput: React.ForwardRefExoticComponent<Omit<DateInputProps, "onChange" | "mobileMode"> & {
|
|
109
|
+
/**
|
|
110
|
+
* Дополнительный класс
|
|
111
|
+
*/
|
|
112
|
+
className?: string | undefined;
|
|
113
|
+
/**
|
|
114
|
+
* Дополнительный класс для инпута
|
|
115
|
+
*/
|
|
116
|
+
inputClassName?: string | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* Дополнительный класс для поповера
|
|
119
|
+
*/
|
|
120
|
+
popoverClassName?: string | undefined;
|
|
121
|
+
/**
|
|
122
|
+
* Доп. пропсы для календаря
|
|
123
|
+
*/
|
|
124
|
+
calendarProps?: (CalendarProps & Record<string, unknown>) | (CalendarProps & {
|
|
125
|
+
open: boolean;
|
|
126
|
+
title?: string | undefined;
|
|
127
|
+
onClose?: (() => void) | undefined;
|
|
128
|
+
yearsAmount?: number | undefined;
|
|
129
|
+
hasHeader?: boolean | undefined;
|
|
130
|
+
allowSelectionFromEmptyRange?: boolean | undefined;
|
|
131
|
+
} & Record<string, unknown>) | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* Значение инпута (используется и для календаря)
|
|
134
|
+
*/
|
|
135
|
+
value?: string | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* Начальное значение инпута
|
|
138
|
+
*/
|
|
139
|
+
defaultValue?: string | undefined;
|
|
140
|
+
/**
|
|
141
|
+
* Состояние открытия по умолчанию
|
|
142
|
+
*/
|
|
143
|
+
defaultOpen?: boolean | undefined;
|
|
144
|
+
/**
|
|
145
|
+
* Месяц в календаре по умолчанию (timestamp)
|
|
146
|
+
*/
|
|
147
|
+
defaultMonth?: number | undefined;
|
|
148
|
+
/**
|
|
149
|
+
* Минимальная дата, доступная для выбора (timestamp)
|
|
150
|
+
*/
|
|
151
|
+
minDate?: number | undefined;
|
|
152
|
+
/**
|
|
153
|
+
* Максимальная дата, доступная для выбора (timestamp)
|
|
154
|
+
*/
|
|
155
|
+
maxDate?: number | undefined;
|
|
156
|
+
/**
|
|
157
|
+
* Список событий
|
|
158
|
+
*/
|
|
159
|
+
events?: (number | Date)[] | undefined;
|
|
160
|
+
/**
|
|
161
|
+
* Список выходных
|
|
162
|
+
*/
|
|
163
|
+
offDays?: (number | Date)[] | undefined;
|
|
164
|
+
/**
|
|
165
|
+
* Определяет, как рендерить календарь — в поповере или снизу инпута
|
|
166
|
+
*/
|
|
167
|
+
calendarPosition?: "static" | "popover" | undefined;
|
|
168
|
+
/**
|
|
169
|
+
* Запрещает поповеру менять свою позицию.
|
|
170
|
+
* Например, если места снизу недостаточно,то он все равно будет показан снизу
|
|
171
|
+
*/
|
|
172
|
+
preventFlip?: boolean | undefined;
|
|
173
|
+
/**
|
|
174
|
+
* Управление нативным режимом на мобильных устройствах
|
|
175
|
+
*/
|
|
176
|
+
mobileMode?: "input" | "native" | "popover" | undefined;
|
|
177
|
+
/**
|
|
178
|
+
* Компонент календаря
|
|
179
|
+
*/
|
|
180
|
+
Calendar?: React.ElementType<any> | undefined;
|
|
181
|
+
/**
|
|
182
|
+
* Обработчик изменения значения
|
|
183
|
+
*/
|
|
184
|
+
onChange?: ((event: ChangeEvent<HTMLInputElement> | MouseEvent<HTMLButtonElement> | null, payload: {
|
|
185
|
+
date: Date;
|
|
186
|
+
value: string;
|
|
187
|
+
}) => void) | undefined;
|
|
188
|
+
/**
|
|
189
|
+
* Обработчик ввода в инпут
|
|
190
|
+
*/
|
|
191
|
+
onInputChange?: ((event: ChangeEvent<HTMLInputElement>, payload: {
|
|
192
|
+
value: string;
|
|
193
|
+
date: Date;
|
|
194
|
+
}) => void) | undefined;
|
|
195
|
+
/**
|
|
196
|
+
* Обработчик изменения календаря
|
|
197
|
+
*/
|
|
198
|
+
onCalendarChange?: CalendarProps['onChange'];
|
|
199
|
+
/**
|
|
200
|
+
* Позиционирование поповера с календарем
|
|
201
|
+
*/
|
|
202
|
+
popoverPosition?: PopoverProps['position'];
|
|
203
|
+
/**
|
|
204
|
+
* z-index Popover
|
|
205
|
+
*/
|
|
206
|
+
zIndexPopover?: PopoverProps['zIndex'];
|
|
207
|
+
/**
|
|
208
|
+
* Календарь будет принимать ширину инпута
|
|
209
|
+
*/
|
|
210
|
+
useAnchorWidth?: boolean | undefined;
|
|
211
|
+
/**
|
|
212
|
+
* Отображение компонента в мобильном или десктопном виде
|
|
213
|
+
*/
|
|
214
|
+
view?: "desktop" | "mobile" | undefined;
|
|
215
|
+
} & React.RefAttributes<HTMLInputElement>>;
|
|
216
|
+
export { CalendarInputProps, CalendarInput };
|
|
@@ -1,18 +1,143 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('react');
|
|
5
|
-
require('react-merge-refs');
|
|
6
|
-
require('classnames');
|
|
7
|
-
require('@alfalab/core-components-calendar');
|
|
8
|
-
require('@alfalab/core-components-date-input');
|
|
9
|
-
require('@alfalab/core-components-popover');
|
|
10
|
-
require('@alfalab/icons-glyph/CalendarMIcon');
|
|
11
|
-
require('../../utils.js');
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var mergeRefs = require('react-merge-refs');
|
|
6
|
+
var cn = require('classnames');
|
|
7
|
+
var coreComponentsCalendar = require('@alfalab/core-components-calendar');
|
|
8
|
+
var coreComponentsDateInput = require('@alfalab/core-components-date-input');
|
|
9
|
+
var coreComponentsPopover = require('@alfalab/core-components-popover');
|
|
10
|
+
var CalendarMIcon = require('@alfalab/icons-glyph/CalendarMIcon');
|
|
11
|
+
var utils = require('../../utils.js');
|
|
12
12
|
require('date-fns/format');
|
|
13
13
|
require('date-fns/isSameDay');
|
|
14
14
|
require('date-fns/parse');
|
|
15
15
|
|
|
16
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
16
17
|
|
|
18
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
19
|
+
var mergeRefs__default = /*#__PURE__*/_interopDefaultCompat(mergeRefs);
|
|
20
|
+
var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
|
|
17
21
|
|
|
18
|
-
|
|
22
|
+
var styles = {"component":"calendar-input__component_1wl7e","block":"calendar-input__block_1wl7e","calendarContainer":"calendar-input__calendarContainer_1wl7e","calendarResponsive":"calendar-input__calendarResponsive_1wl7e","calendarIcon":"calendar-input__calendarIcon_1wl7e","nativeInput":"calendar-input__nativeInput_1wl7e"};
|
|
23
|
+
require('./index.css')
|
|
24
|
+
|
|
25
|
+
var CalendarInput = React.forwardRef(function (_a, ref) {
|
|
26
|
+
var _b, _c;
|
|
27
|
+
var _d;
|
|
28
|
+
var _e = _a.block, block = _e === void 0 ? false : _e, className = _a.className; _a.inputClassName; var popoverClassName = _a.popoverClassName, _f = _a.defaultOpen, defaultOpen = _f === void 0 ? false : _f, defaultMonth = _a.defaultMonth, _g = _a.defaultValue, defaultValue = _g === void 0 ? '' : _g, _h = _a.calendarPosition, calendarPosition = _h === void 0 ? 'popover' : _h, value = _a.value, dataTestId = _a.dataTestId, _j = _a.calendarProps, calendarProps = _j === void 0 ? {} : _j, _k = _a.minDate, minDate = _k === void 0 ? calendarProps.minDate : _k, _l = _a.maxDate, maxDate = _l === void 0 ? calendarProps.maxDate : _l, _m = _a.offDays, offDays = _m === void 0 ? calendarProps.offDays || [] : _m, _o = _a.events, events = _o === void 0 ? calendarProps.events || [] : _o, preventFlip = _a.preventFlip, _p = _a.mobileMode, mobileMode = _p === void 0 ? 'popover' : _p, _q = _a.wrapperRef, wrapperRef = _q === void 0 ? null : _q, disabled = _a.disabled, _r = _a.onChange, onChange = _r === void 0 ? function () { return null; } : _r, onInputChange = _a.onInputChange, onCalendarChange = _a.onCalendarChange, onKeyDown = _a.onKeyDown, readOnly = _a.readOnly, _s = _a.Calendar, Calendar = _s === void 0 ? coreComponentsCalendar.Calendar : _s, _t = _a.popoverPosition, popoverPosition = _t === void 0 ? 'bottom-start' : _t, zIndexPopover = _a.zIndexPopover, useAnchorWidth = _a.useAnchorWidth, rightAddons = _a.rightAddons, error = _a.error, _u = _a.view, view = _u === void 0 ? 'desktop' : _u, restProps = tslib.__rest(_a, ["block", "className", "inputClassName", "popoverClassName", "defaultOpen", "defaultMonth", "defaultValue", "calendarPosition", "value", "dataTestId", "calendarProps", "minDate", "maxDate", "offDays", "events", "preventFlip", "mobileMode", "wrapperRef", "disabled", "onChange", "onInputChange", "onCalendarChange", "onKeyDown", "readOnly", "Calendar", "popoverPosition", "zIndexPopover", "useAnchorWidth", "rightAddons", "error", "view"]);
|
|
29
|
+
var calendarResponsive = (_d = calendarProps === null || calendarProps === void 0 ? void 0 : calendarProps.responsive) !== null && _d !== void 0 ? _d : true;
|
|
30
|
+
var shouldRenderNative = utils.SUPPORTS_INPUT_TYPE_DATE && mobileMode === 'native';
|
|
31
|
+
var shouldRenderOnlyInput = mobileMode === 'input';
|
|
32
|
+
var shouldRenderStatic = calendarPosition === 'static' && !shouldRenderOnlyInput;
|
|
33
|
+
var shouldRenderPopover = calendarPosition === 'popover' && !shouldRenderNative && !shouldRenderOnlyInput;
|
|
34
|
+
var _v = React.useState(false), open = _v[0], setOpen = _v[1];
|
|
35
|
+
var _w = React.useState(value || defaultValue), inputValue = _w[0], setInputValue = _w[1];
|
|
36
|
+
var calendarValue = inputValue ? coreComponentsDateInput.parseDateString(inputValue).getTime() : undefined;
|
|
37
|
+
var checkInputValueIsValid = React.useCallback(function (newInputValue) {
|
|
38
|
+
if (!newInputValue)
|
|
39
|
+
return false;
|
|
40
|
+
var dateValue = coreComponentsDateInput.parseDateString(newInputValue).getTime();
|
|
41
|
+
return !!(dateValue &&
|
|
42
|
+
coreComponentsDateInput.isCompleteDateInput(newInputValue) &&
|
|
43
|
+
coreComponentsCalendar.dateInLimits(dateValue, minDate, maxDate) &&
|
|
44
|
+
!offDays.includes(dateValue));
|
|
45
|
+
}, [maxDate, minDate, offDays]);
|
|
46
|
+
var inputDisabled = disabled || readOnly;
|
|
47
|
+
var inputWrapperRef = React.useRef(null);
|
|
48
|
+
var calendarRef = React.useRef(null);
|
|
49
|
+
var handleKeyDown = React.useCallback(function (event) {
|
|
50
|
+
if (event.target.tagName === 'INPUT' && event.key === 'Enter') {
|
|
51
|
+
setOpen(!open);
|
|
52
|
+
}
|
|
53
|
+
if (event.key === 'Escape') {
|
|
54
|
+
setOpen(false);
|
|
55
|
+
}
|
|
56
|
+
}, [open]);
|
|
57
|
+
var handleClick = React.useCallback(function () {
|
|
58
|
+
if (!open)
|
|
59
|
+
setOpen(true);
|
|
60
|
+
}, [open]);
|
|
61
|
+
var handleFocus = React.useCallback(function (event) {
|
|
62
|
+
if (view === 'desktop') {
|
|
63
|
+
setOpen(true);
|
|
64
|
+
if (!open && event.target.tagName !== 'INPUT' && calendarRef.current) {
|
|
65
|
+
calendarRef.current.focus();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}, [open, view]);
|
|
69
|
+
var handleBlur = React.useCallback(function (event) {
|
|
70
|
+
if (view === 'desktop') {
|
|
71
|
+
var target = (event.relatedTarget || document.activeElement);
|
|
72
|
+
if (calendarRef.current && calendarRef.current.contains(target) === false) {
|
|
73
|
+
setOpen(false);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}, [view]);
|
|
77
|
+
var handleInputKeyDown = React.useCallback(function (event) {
|
|
78
|
+
if (['ArrowDown', 'ArrowUp'].includes(event.key) && calendarRef.current) {
|
|
79
|
+
event.preventDefault();
|
|
80
|
+
calendarRef.current.focus();
|
|
81
|
+
}
|
|
82
|
+
if (onKeyDown)
|
|
83
|
+
onKeyDown(event);
|
|
84
|
+
}, [onKeyDown]);
|
|
85
|
+
var changeHandler = React.useCallback(function (event, newValue, newDate, initiator, shouldChange) {
|
|
86
|
+
if (initiator === void 0) { initiator = 'input'; }
|
|
87
|
+
if (shouldChange === void 0) { shouldChange = true; }
|
|
88
|
+
if (initiator === 'input' && event && onInputChange) {
|
|
89
|
+
onInputChange(event, { value: newValue, date: newDate });
|
|
90
|
+
}
|
|
91
|
+
if (initiator === 'calendar' && onCalendarChange) {
|
|
92
|
+
onCalendarChange(newDate.getTime());
|
|
93
|
+
}
|
|
94
|
+
setInputValue(newValue);
|
|
95
|
+
if (shouldChange) {
|
|
96
|
+
onChange(event, { date: newDate, value: newValue });
|
|
97
|
+
}
|
|
98
|
+
}, [onCalendarChange, onChange, onInputChange]);
|
|
99
|
+
var handleInputChange = React.useCallback(function (event, payload) {
|
|
100
|
+
changeHandler(event, payload.value, payload.date, 'input', !payload.value || checkInputValueIsValid(payload.value));
|
|
101
|
+
}, [changeHandler, checkInputValueIsValid]);
|
|
102
|
+
var handleCalendarChange = React.useCallback(function (date) {
|
|
103
|
+
if (date) {
|
|
104
|
+
changeHandler(null, coreComponentsDateInput.formatDate(date), new Date(date), 'calendar');
|
|
105
|
+
}
|
|
106
|
+
if (view === 'desktop') {
|
|
107
|
+
setOpen(false);
|
|
108
|
+
}
|
|
109
|
+
}, [changeHandler, view]);
|
|
110
|
+
var handleCalendarWrapperMouseDown = React.useCallback(function (event) {
|
|
111
|
+
// Не дает инпуту терять фокус при выборе даты
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
}, []);
|
|
114
|
+
var handleCalendarClose = React.useCallback(function () {
|
|
115
|
+
setOpen(false);
|
|
116
|
+
}, []);
|
|
117
|
+
React.useEffect(function () {
|
|
118
|
+
setOpen(defaultOpen);
|
|
119
|
+
}, [defaultOpen]);
|
|
120
|
+
React.useEffect(function () {
|
|
121
|
+
if (typeof value !== 'undefined') {
|
|
122
|
+
setInputValue(value);
|
|
123
|
+
}
|
|
124
|
+
}, [value]);
|
|
125
|
+
var renderCalendar = function () { return (
|
|
126
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
127
|
+
React__default.default.createElement("div", { onMouseDown: handleCalendarWrapperMouseDown },
|
|
128
|
+
React__default.default.createElement(Calendar, tslib.__assign({}, calendarProps, { responsive: calendarResponsive, open: open, onClose: handleCalendarClose, ref: calendarRef, defaultMonth: defaultMonth, value: checkInputValueIsValid(inputValue) ? calendarValue : undefined, onChange: handleCalendarChange, minDate: minDate, maxDate: maxDate, offDays: offDays, events: events })))); };
|
|
129
|
+
return (
|
|
130
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
131
|
+
React__default.default.createElement("div", { className: cn__default.default(styles.component, className, (_b = {},
|
|
132
|
+
_b[styles.block] = block,
|
|
133
|
+
_b)), tabIndex: -1, onKeyDown: inputDisabled ? undefined : handleKeyDown, onClick: inputDisabled ? undefined : handleClick, onFocus: inputDisabled ? undefined : handleFocus, onBlur: handleBlur, "data-test-id": dataTestId },
|
|
134
|
+
React__default.default.createElement(coreComponentsDateInput.DateInput, tslib.__assign({}, restProps, { ref: ref, wrapperRef: mergeRefs__default.default([wrapperRef, inputWrapperRef]), value: inputValue, defaultValue: defaultValue, disabled: disabled, readOnly: readOnly, mobileMode: mobileMode === 'native' ? 'native' : 'input', error: error, rightAddons: React__default.default.createElement(React__default.default.Fragment, null,
|
|
135
|
+
rightAddons,
|
|
136
|
+
shouldRenderPopover && (React__default.default.createElement(CalendarMIcon.CalendarMIcon, { className: styles.calendarIcon }))), onKeyDown: handleInputKeyDown, onChange: handleInputChange, block: true })),
|
|
137
|
+
shouldRenderStatic && renderCalendar(),
|
|
138
|
+
shouldRenderPopover && (React__default.default.createElement(coreComponentsPopover.Popover, { open: open, useAnchorWidth: useAnchorWidth, anchorElement: inputWrapperRef.current, popperClassName: cn__default.default(styles.calendarContainer, (_c = {},
|
|
139
|
+
_c[styles.calendarResponsive] = calendarResponsive,
|
|
140
|
+
_c)), className: popoverClassName, position: popoverPosition, offset: [0, 4], withTransition: false, preventFlip: preventFlip, zIndex: zIndexPopover }, renderCalendar()))));
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
exports.CalendarInput = CalendarInput;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 1csm0 */
|
|
2
2
|
:root {
|
|
3
3
|
} /* deprecated */ :root {
|
|
4
4
|
--color-light-graphic-primary: #0b1f35;
|
|
@@ -43,31 +43,31 @@
|
|
|
43
43
|
} :root {
|
|
44
44
|
--calendar-input-icon-color: var(--color-light-graphic-primary);
|
|
45
45
|
--calendar-input-popover-border-radius: var(--border-radius-m);
|
|
46
|
-
} .calendar-
|
|
46
|
+
} .calendar-input__component_1wl7e {
|
|
47
47
|
display: inline-block;
|
|
48
48
|
outline: none;
|
|
49
49
|
position: relative;
|
|
50
|
-
} .calendar-
|
|
50
|
+
} .calendar-input__block_1wl7e {
|
|
51
51
|
width: 100%;
|
|
52
|
-
} .calendar-
|
|
52
|
+
} .calendar-input__calendarContainer_1wl7e {
|
|
53
53
|
display: inline-block;
|
|
54
54
|
box-sizing: border-box;
|
|
55
55
|
border-radius: var(--calendar-input-popover-border-radius)
|
|
56
|
-
} @media (max-width: 374px) { .calendar-
|
|
56
|
+
} @media (max-width: 374px) { .calendar-input__calendarContainer_1wl7e {
|
|
57
57
|
width: 100%;
|
|
58
58
|
min-width: 288px
|
|
59
59
|
}
|
|
60
|
-
} .calendar-
|
|
60
|
+
} .calendar-input__calendarResponsive_1wl7e {
|
|
61
61
|
width: var(--calendar-width);
|
|
62
62
|
padding: 0 var(--gap-m);
|
|
63
|
-
} .calendar-
|
|
63
|
+
} .calendar-input__calendarIcon_1wl7e {
|
|
64
64
|
width: 24px;
|
|
65
65
|
height: 24px;
|
|
66
66
|
display: block;
|
|
67
67
|
color: var(--calendar-input-icon-color)
|
|
68
|
-
} .calendar-
|
|
68
|
+
} .calendar-input__calendarIcon_1wl7e:not(:only-child) {
|
|
69
69
|
margin-right: var(--gap-2xs);
|
|
70
|
-
} .calendar-
|
|
70
|
+
} .calendar-input__nativeInput_1wl7e {
|
|
71
71
|
opacity: 0;
|
|
72
72
|
position: absolute;
|
|
73
73
|
top: 0;
|
|
@@ -77,8 +77,8 @@
|
|
|
77
77
|
-webkit-appearance: none;
|
|
78
78
|
appearance: none;
|
|
79
79
|
z-index: 1
|
|
80
|
-
} .calendar-
|
|
80
|
+
} .calendar-input__nativeInput_1wl7e::-webkit-calendar-picker-indicator {
|
|
81
81
|
display: none;
|
|
82
|
-
} .calendar-
|
|
82
|
+
} .calendar-input__nativeInput_1wl7e::-webkit-inner-spin-button {
|
|
83
83
|
display: none;
|
|
84
84
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "
|
|
1
|
+
export * from "./Component";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { CalendarInputProps } from "./components/calendar-input/Component";
|
|
3
4
|
type CalendarInputDesktopProps = Omit<CalendarInputProps, 'view'>;
|
|
4
|
-
declare const CalendarInputDesktop:
|
|
5
|
+
declare const CalendarInputDesktop: React.ForwardRefExoticComponent<CalendarInputDesktopProps & React.RefAttributes<HTMLInputElement>>;
|
|
5
6
|
export { CalendarInputDesktopProps, CalendarInputDesktop };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var tslib = require('tslib');
|
|
4
4
|
var React = require('react');
|
|
5
|
+
var components_calendarInput_Component = require('./components/calendar-input/Component.js');
|
|
5
6
|
require('react-merge-refs');
|
|
6
7
|
require('classnames');
|
|
7
8
|
require('@alfalab/core-components-calendar/cssm');
|
|
@@ -18,6 +19,6 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
18
19
|
|
|
19
20
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
20
21
|
|
|
21
|
-
var CalendarInputDesktop = function (props) { return
|
|
22
|
+
var CalendarInputDesktop = React.forwardRef(function (props, ref) { return React__default.default.createElement(components_calendarInput_Component.CalendarInput, tslib.__assign({}, props, { ref: ref })); });
|
|
22
23
|
|
|
23
24
|
exports.CalendarInputDesktop = CalendarInputDesktop;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { CalendarInputProps } from "./components/calendar-input/Component";
|
|
3
4
|
type CalendarInputMobileProps = Omit<CalendarInputProps, 'view'>;
|
|
4
|
-
declare const CalendarInputMobile:
|
|
5
|
+
declare const CalendarInputMobile: React.ForwardRefExoticComponent<CalendarInputMobileProps & React.RefAttributes<HTMLInputElement>>;
|
|
5
6
|
export { CalendarInputMobileProps, CalendarInputMobile };
|
package/cssm/Component.mobile.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var tslib = require('tslib');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var coreComponentsCalendar = require('@alfalab/core-components-calendar/cssm');
|
|
6
|
+
var components_calendarInput_Component = require('./components/calendar-input/Component.js');
|
|
6
7
|
require('react-merge-refs');
|
|
7
8
|
require('classnames');
|
|
8
9
|
require('@alfalab/core-components-date-input/cssm');
|
|
@@ -18,6 +19,6 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
18
19
|
|
|
19
20
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
20
21
|
|
|
21
|
-
var CalendarInputMobile = function (props) { return
|
|
22
|
+
var CalendarInputMobile = React.forwardRef(function (props, ref) { return React__default.default.createElement(components_calendarInput_Component.CalendarInput, tslib.__assign({ Calendar: coreComponentsCalendar.CalendarMobile, view: 'mobile' }, props, { ref: ref })); });
|
|
22
23
|
|
|
23
24
|
exports.CalendarInputMobile = CalendarInputMobile;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { CalendarInputProps } from "./components/calendar-input/Component";
|
|
3
4
|
type CalendarInputResponsiveProps = Omit<CalendarInputProps, 'view'> & {
|
|
4
5
|
/**
|
|
5
6
|
* Контрольная точка, с нее начинается desktop версия
|
|
@@ -8,5 +9,11 @@ type CalendarInputResponsiveProps = Omit<CalendarInputProps, 'view'> & {
|
|
|
8
9
|
breakpoint?: number;
|
|
9
10
|
};
|
|
10
11
|
type CalendarInputMedia = 'desktop' | 'mobile';
|
|
11
|
-
declare const CalendarInputResponsive:
|
|
12
|
+
declare const CalendarInputResponsive: React.ForwardRefExoticComponent<Omit<CalendarInputProps, "view"> & {
|
|
13
|
+
/**
|
|
14
|
+
* Контрольная точка, с нее начинается desktop версия
|
|
15
|
+
* @default 1024
|
|
16
|
+
*/
|
|
17
|
+
breakpoint?: number | undefined;
|
|
18
|
+
} & React.RefAttributes<HTMLInputElement>>;
|
|
12
19
|
export { CalendarInputResponsiveProps, CalendarInputMedia, CalendarInputResponsive };
|