@alfalab/core-components-calendar-input 8.2.8 → 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-60ae032f.d.ts +0 -249
- package/Component-60ae032f.js +0 -179
- package/cssm/Component-fde0c12c.d.ts +0 -249
- package/cssm/Component-fde0c12c.js +0 -178
- package/esm/Component-6e641637.d.ts +0 -249
- package/esm/Component-6e641637.js +0 -170
|
@@ -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,12 +1,135 @@
|
|
|
1
|
-
|
|
2
|
-
import 'react';
|
|
3
|
-
import 'react-merge-refs';
|
|
4
|
-
import 'classnames';
|
|
5
|
-
import '@alfalab/core-components-calendar/esm';
|
|
6
|
-
import '@alfalab/core-components-date-input/esm';
|
|
7
|
-
import '@alfalab/core-components-popover/esm';
|
|
8
|
-
import '@alfalab/icons-glyph/CalendarMIcon';
|
|
9
|
-
import '../../utils.js';
|
|
1
|
+
import { __rest, __assign } from 'tslib';
|
|
2
|
+
import React, { forwardRef, useState, useCallback, useRef, useEffect } from 'react';
|
|
3
|
+
import mergeRefs from 'react-merge-refs';
|
|
4
|
+
import cn from 'classnames';
|
|
5
|
+
import { dateInLimits, Calendar } from '@alfalab/core-components-calendar/esm';
|
|
6
|
+
import { parseDateString, isCompleteDateInput, formatDate, DateInput } from '@alfalab/core-components-date-input/esm';
|
|
7
|
+
import { Popover } from '@alfalab/core-components-popover/esm';
|
|
8
|
+
import { CalendarMIcon } from '@alfalab/icons-glyph/CalendarMIcon';
|
|
9
|
+
import { SUPPORTS_INPUT_TYPE_DATE } from '../../utils.js';
|
|
10
10
|
import 'date-fns/format';
|
|
11
11
|
import 'date-fns/isSameDay';
|
|
12
12
|
import 'date-fns/parse';
|
|
13
|
+
|
|
14
|
+
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"};
|
|
15
|
+
require('./index.css')
|
|
16
|
+
|
|
17
|
+
var CalendarInput = forwardRef(function (_a, ref) {
|
|
18
|
+
var _b, _c;
|
|
19
|
+
var _d;
|
|
20
|
+
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$1 = _s === void 0 ? 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 = __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"]);
|
|
21
|
+
var calendarResponsive = (_d = calendarProps === null || calendarProps === void 0 ? void 0 : calendarProps.responsive) !== null && _d !== void 0 ? _d : true;
|
|
22
|
+
var shouldRenderNative = SUPPORTS_INPUT_TYPE_DATE && mobileMode === 'native';
|
|
23
|
+
var shouldRenderOnlyInput = mobileMode === 'input';
|
|
24
|
+
var shouldRenderStatic = calendarPosition === 'static' && !shouldRenderOnlyInput;
|
|
25
|
+
var shouldRenderPopover = calendarPosition === 'popover' && !shouldRenderNative && !shouldRenderOnlyInput;
|
|
26
|
+
var _v = useState(false), open = _v[0], setOpen = _v[1];
|
|
27
|
+
var _w = useState(value || defaultValue), inputValue = _w[0], setInputValue = _w[1];
|
|
28
|
+
var calendarValue = inputValue ? parseDateString(inputValue).getTime() : undefined;
|
|
29
|
+
var checkInputValueIsValid = useCallback(function (newInputValue) {
|
|
30
|
+
if (!newInputValue)
|
|
31
|
+
return false;
|
|
32
|
+
var dateValue = parseDateString(newInputValue).getTime();
|
|
33
|
+
return !!(dateValue &&
|
|
34
|
+
isCompleteDateInput(newInputValue) &&
|
|
35
|
+
dateInLimits(dateValue, minDate, maxDate) &&
|
|
36
|
+
!offDays.includes(dateValue));
|
|
37
|
+
}, [maxDate, minDate, offDays]);
|
|
38
|
+
var inputDisabled = disabled || readOnly;
|
|
39
|
+
var inputWrapperRef = useRef(null);
|
|
40
|
+
var calendarRef = useRef(null);
|
|
41
|
+
var handleKeyDown = useCallback(function (event) {
|
|
42
|
+
if (event.target.tagName === 'INPUT' && event.key === 'Enter') {
|
|
43
|
+
setOpen(!open);
|
|
44
|
+
}
|
|
45
|
+
if (event.key === 'Escape') {
|
|
46
|
+
setOpen(false);
|
|
47
|
+
}
|
|
48
|
+
}, [open]);
|
|
49
|
+
var handleClick = useCallback(function () {
|
|
50
|
+
if (!open)
|
|
51
|
+
setOpen(true);
|
|
52
|
+
}, [open]);
|
|
53
|
+
var handleFocus = useCallback(function (event) {
|
|
54
|
+
if (view === 'desktop') {
|
|
55
|
+
setOpen(true);
|
|
56
|
+
if (!open && event.target.tagName !== 'INPUT' && calendarRef.current) {
|
|
57
|
+
calendarRef.current.focus();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}, [open, view]);
|
|
61
|
+
var handleBlur = useCallback(function (event) {
|
|
62
|
+
if (view === 'desktop') {
|
|
63
|
+
var target = (event.relatedTarget || document.activeElement);
|
|
64
|
+
if (calendarRef.current && calendarRef.current.contains(target) === false) {
|
|
65
|
+
setOpen(false);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}, [view]);
|
|
69
|
+
var handleInputKeyDown = useCallback(function (event) {
|
|
70
|
+
if (['ArrowDown', 'ArrowUp'].includes(event.key) && calendarRef.current) {
|
|
71
|
+
event.preventDefault();
|
|
72
|
+
calendarRef.current.focus();
|
|
73
|
+
}
|
|
74
|
+
if (onKeyDown)
|
|
75
|
+
onKeyDown(event);
|
|
76
|
+
}, [onKeyDown]);
|
|
77
|
+
var changeHandler = useCallback(function (event, newValue, newDate, initiator, shouldChange) {
|
|
78
|
+
if (initiator === void 0) { initiator = 'input'; }
|
|
79
|
+
if (shouldChange === void 0) { shouldChange = true; }
|
|
80
|
+
if (initiator === 'input' && event && onInputChange) {
|
|
81
|
+
onInputChange(event, { value: newValue, date: newDate });
|
|
82
|
+
}
|
|
83
|
+
if (initiator === 'calendar' && onCalendarChange) {
|
|
84
|
+
onCalendarChange(newDate.getTime());
|
|
85
|
+
}
|
|
86
|
+
setInputValue(newValue);
|
|
87
|
+
if (shouldChange) {
|
|
88
|
+
onChange(event, { date: newDate, value: newValue });
|
|
89
|
+
}
|
|
90
|
+
}, [onCalendarChange, onChange, onInputChange]);
|
|
91
|
+
var handleInputChange = useCallback(function (event, payload) {
|
|
92
|
+
changeHandler(event, payload.value, payload.date, 'input', !payload.value || checkInputValueIsValid(payload.value));
|
|
93
|
+
}, [changeHandler, checkInputValueIsValid]);
|
|
94
|
+
var handleCalendarChange = useCallback(function (date) {
|
|
95
|
+
if (date) {
|
|
96
|
+
changeHandler(null, formatDate(date), new Date(date), 'calendar');
|
|
97
|
+
}
|
|
98
|
+
if (view === 'desktop') {
|
|
99
|
+
setOpen(false);
|
|
100
|
+
}
|
|
101
|
+
}, [changeHandler, view]);
|
|
102
|
+
var handleCalendarWrapperMouseDown = useCallback(function (event) {
|
|
103
|
+
// Не дает инпуту терять фокус при выборе даты
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
}, []);
|
|
106
|
+
var handleCalendarClose = useCallback(function () {
|
|
107
|
+
setOpen(false);
|
|
108
|
+
}, []);
|
|
109
|
+
useEffect(function () {
|
|
110
|
+
setOpen(defaultOpen);
|
|
111
|
+
}, [defaultOpen]);
|
|
112
|
+
useEffect(function () {
|
|
113
|
+
if (typeof value !== 'undefined') {
|
|
114
|
+
setInputValue(value);
|
|
115
|
+
}
|
|
116
|
+
}, [value]);
|
|
117
|
+
var renderCalendar = function () { return (
|
|
118
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
119
|
+
React.createElement("div", { onMouseDown: handleCalendarWrapperMouseDown },
|
|
120
|
+
React.createElement(Calendar$1, __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 })))); };
|
|
121
|
+
return (
|
|
122
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
123
|
+
React.createElement("div", { className: cn(styles.component, className, (_b = {},
|
|
124
|
+
_b[styles.block] = block,
|
|
125
|
+
_b)), tabIndex: -1, onKeyDown: inputDisabled ? undefined : handleKeyDown, onClick: inputDisabled ? undefined : handleClick, onFocus: inputDisabled ? undefined : handleFocus, onBlur: handleBlur, "data-test-id": dataTestId },
|
|
126
|
+
React.createElement(DateInput, __assign({}, restProps, { ref: ref, wrapperRef: mergeRefs([wrapperRef, inputWrapperRef]), value: inputValue, defaultValue: defaultValue, disabled: disabled, readOnly: readOnly, mobileMode: mobileMode === 'native' ? 'native' : 'input', error: error, rightAddons: React.createElement(React.Fragment, null,
|
|
127
|
+
rightAddons,
|
|
128
|
+
shouldRenderPopover && (React.createElement(CalendarMIcon, { className: styles.calendarIcon }))), onKeyDown: handleInputKeyDown, onChange: handleInputChange, block: true })),
|
|
129
|
+
shouldRenderStatic && renderCalendar(),
|
|
130
|
+
shouldRenderPopover && (React.createElement(Popover, { open: open, useAnchorWidth: useAnchorWidth, anchorElement: inputWrapperRef.current, popperClassName: cn(styles.calendarContainer, (_c = {},
|
|
131
|
+
_c[styles.calendarResponsive] = calendarResponsive,
|
|
132
|
+
_c)), className: popoverClassName, position: popoverPosition, offset: [0, 4], withTransition: false, preventFlip: preventFlip, zIndex: zIndexPopover }, renderCalendar()))));
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
export { 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";
|
package/esm/desktop.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { CalendarInputDesktop } from './Component.desktop.js';
|
|
2
|
-
import '
|
|
2
|
+
import 'tslib';
|
|
3
3
|
import 'react';
|
|
4
|
+
import './components/calendar-input/Component.js';
|
|
4
5
|
import 'react-merge-refs';
|
|
5
6
|
import 'classnames';
|
|
6
7
|
import '@alfalab/core-components-calendar/esm';
|
package/esm/index.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
export { CalendarInputResponsive as CalendarInput } from './Component.responsive.js';
|
|
2
2
|
export { DATE_FORMAT, DATE_MASK, IS_BROWSER, NATIVE_DATE_FORMAT, SUPPORTS_INPUT_TYPE_DATE, formatDate, isInputDateSupported, isValidInputValue, parseDateString } from './utils.js';
|
|
3
|
-
import '
|
|
3
|
+
import 'tslib';
|
|
4
4
|
import 'react';
|
|
5
|
+
import '@alfalab/hooks';
|
|
6
|
+
import './Component.desktop.js';
|
|
7
|
+
import './components/calendar-input/Component.js';
|
|
5
8
|
import 'react-merge-refs';
|
|
6
9
|
import 'classnames';
|
|
7
10
|
import '@alfalab/core-components-calendar/esm';
|
|
8
11
|
import '@alfalab/core-components-date-input/esm';
|
|
9
12
|
import '@alfalab/core-components-popover/esm';
|
|
10
13
|
import '@alfalab/icons-glyph/CalendarMIcon';
|
|
11
|
-
import '@alfalab/hooks';
|
|
12
|
-
import './Component.desktop.js';
|
|
13
14
|
import 'date-fns/format';
|
|
14
15
|
import 'date-fns/isSameDay';
|
|
15
16
|
import 'date-fns/parse';
|
package/esm/mobile.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export { CalendarInputMobile } from './Component.mobile.js';
|
|
2
|
-
import '
|
|
2
|
+
import 'tslib';
|
|
3
3
|
import 'react';
|
|
4
|
+
import '@alfalab/core-components-calendar/esm';
|
|
5
|
+
import './components/calendar-input/Component.js';
|
|
4
6
|
import 'react-merge-refs';
|
|
5
7
|
import 'classnames';
|
|
6
|
-
import '@alfalab/core-components-calendar/esm';
|
|
7
8
|
import '@alfalab/core-components-date-input/esm';
|
|
8
9
|
import '@alfalab/core-components-popover/esm';
|
|
9
10
|
import '@alfalab/icons-glyph/CalendarMIcon';
|
package/esm/responsive.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export { CalendarInputResponsive } from './Component.responsive.js';
|
|
2
|
-
import '
|
|
2
|
+
import 'tslib';
|
|
3
3
|
import 'react';
|
|
4
|
+
import '@alfalab/hooks';
|
|
5
|
+
import './Component.desktop.js';
|
|
6
|
+
import './components/calendar-input/Component.js';
|
|
4
7
|
import 'react-merge-refs';
|
|
5
8
|
import 'classnames';
|
|
6
9
|
import '@alfalab/core-components-calendar/esm';
|
|
@@ -11,6 +14,4 @@ import './utils.js';
|
|
|
11
14
|
import 'date-fns/format';
|
|
12
15
|
import 'date-fns/isSameDay';
|
|
13
16
|
import 'date-fns/parse';
|
|
14
|
-
import '@alfalab/hooks';
|
|
15
|
-
import './Component.desktop.js';
|
|
16
17
|
import './Component.mobile.js';
|
package/index.js
CHANGED
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
var Component_responsive = require('./Component.responsive.js');
|
|
4
4
|
var utils = require('./utils.js');
|
|
5
|
-
require('
|
|
5
|
+
require('tslib');
|
|
6
6
|
require('react');
|
|
7
|
+
require('@alfalab/hooks');
|
|
8
|
+
require('./Component.desktop.js');
|
|
9
|
+
require('./components/calendar-input/Component.js');
|
|
7
10
|
require('react-merge-refs');
|
|
8
11
|
require('classnames');
|
|
9
12
|
require('@alfalab/core-components-calendar');
|
|
10
13
|
require('@alfalab/core-components-date-input');
|
|
11
14
|
require('@alfalab/core-components-popover');
|
|
12
15
|
require('@alfalab/icons-glyph/CalendarMIcon');
|
|
13
|
-
require('@alfalab/hooks');
|
|
14
|
-
require('./Component.desktop.js');
|
|
15
16
|
require('date-fns/format');
|
|
16
17
|
require('date-fns/isSameDay');
|
|
17
18
|
require('date-fns/parse');
|
package/mobile.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var Component_mobile = require('./Component.mobile.js');
|
|
4
|
-
require('
|
|
4
|
+
require('tslib');
|
|
5
5
|
require('react');
|
|
6
|
+
require('@alfalab/core-components-calendar');
|
|
7
|
+
require('./components/calendar-input/Component.js');
|
|
6
8
|
require('react-merge-refs');
|
|
7
9
|
require('classnames');
|
|
8
|
-
require('@alfalab/core-components-calendar');
|
|
9
10
|
require('@alfalab/core-components-date-input');
|
|
10
11
|
require('@alfalab/core-components-popover');
|
|
11
12
|
require('@alfalab/icons-glyph/CalendarMIcon');
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
2
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,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
2
|
import { CalendarInput } from './components/calendar-input/Component.js';
|
|
3
3
|
import 'react-merge-refs';
|
|
4
4
|
import 'classnames';
|
|
@@ -11,6 +11,6 @@ import 'date-fns/format';
|
|
|
11
11
|
import 'date-fns/isSameDay';
|
|
12
12
|
import 'date-fns/parse';
|
|
13
13
|
|
|
14
|
-
const CalendarInputDesktop = (props) =>
|
|
14
|
+
const CalendarInputDesktop = forwardRef((props, ref) => React.createElement(CalendarInput, { ...props, ref: ref }));
|
|
15
15
|
|
|
16
16
|
export { CalendarInputDesktop };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
2
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 };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
2
|
import { CalendarMobile } from '@alfalab/core-components-calendar/modern';
|
|
3
3
|
import { CalendarInput } from './components/calendar-input/Component.js';
|
|
4
4
|
import 'react-merge-refs';
|
|
@@ -11,6 +11,6 @@ import 'date-fns/format';
|
|
|
11
11
|
import 'date-fns/isSameDay';
|
|
12
12
|
import 'date-fns/parse';
|
|
13
13
|
|
|
14
|
-
const CalendarInputMobile = (props) =>
|
|
14
|
+
const CalendarInputMobile = forwardRef((props, ref) => React.createElement(CalendarInput, { Calendar: CalendarMobile, view: 'mobile', ...props, ref: ref }));
|
|
15
15
|
|
|
16
16
|
export { CalendarInputMobile };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
2
3
|
import { CalendarInputProps } from "./components/calendar-input/Component";
|
|
3
4
|
type CalendarInputResponsiveProps = Omit<CalendarInputProps, 'view'> & {
|
|
4
5
|
/**
|
|
@@ -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 };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
2
|
import { useMedia } from '@alfalab/hooks';
|
|
3
3
|
import { CalendarInputDesktop } from './Component.desktop.js';
|
|
4
4
|
import { CalendarInputMobile } from './Component.mobile.js';
|
|
@@ -14,12 +14,12 @@ import 'date-fns/format';
|
|
|
14
14
|
import 'date-fns/isSameDay';
|
|
15
15
|
import 'date-fns/parse';
|
|
16
16
|
|
|
17
|
-
const CalendarInputResponsive = ({ breakpoint = 1024, ...restProps }) => {
|
|
17
|
+
const CalendarInputResponsive = forwardRef(({ breakpoint = 1024, ...restProps }, ref) => {
|
|
18
18
|
const [view] = useMedia([
|
|
19
19
|
['mobile', `(max-width: ${breakpoint - 1}px)`],
|
|
20
20
|
['desktop', `(min-width: ${breakpoint}px)`],
|
|
21
21
|
], 'desktop');
|
|
22
|
-
return view === 'desktop' ? (React.createElement(CalendarInputDesktop, { ...restProps })) : (React.createElement(CalendarInputMobile, { ...restProps }));
|
|
23
|
-
};
|
|
22
|
+
return view === 'desktop' ? (React.createElement(CalendarInputDesktop, { ...restProps, ref: ref })) : (React.createElement(CalendarInputMobile, { ...restProps, ref: ref }));
|
|
23
|
+
});
|
|
24
24
|
|
|
25
25
|
export { CalendarInputResponsive };
|
|
@@ -10,7 +10,7 @@ import 'date-fns/format';
|
|
|
10
10
|
import 'date-fns/isSameDay';
|
|
11
11
|
import 'date-fns/parse';
|
|
12
12
|
|
|
13
|
-
const styles = {"component":"calendar-
|
|
13
|
+
const 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"};
|
|
14
14
|
require('./index.css')
|
|
15
15
|
|
|
16
16
|
const CalendarInput = forwardRef(({ block = false, className, inputClassName, popoverClassName, defaultOpen = false, defaultMonth, defaultValue = '', calendarPosition = 'popover', value, dataTestId, calendarProps = {}, minDate = calendarProps.minDate, maxDate = calendarProps.maxDate, offDays = calendarProps.offDays || [], events = calendarProps.events || [], preventFlip, mobileMode = 'popover', wrapperRef = null, disabled, onChange = () => null, onInputChange, onCalendarChange, onKeyDown, readOnly, Calendar: Calendar$1 = Calendar, popoverPosition = 'bottom-start', zIndexPopover, useAnchorWidth, rightAddons, error, view = 'desktop', ...restProps }, ref) => {
|