@alfalab/core-components-date-range-input 2.2.7 → 2.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 +5 -4
- package/Component.desktop.js +4 -2
- package/Component.mobile.d.ts +5 -4
- package/Component.mobile.js +4 -2
- package/Component.responsive.d.ts +5 -4
- package/Component.responsive.js +7 -5
- package/components/date-range-input/Component.d.ts +108 -0
- package/components/date-range-input/Component.js +220 -13
- package/components/date-range-input/index.css +6 -6
- package/components/date-range-input/index.d.ts +1 -1
- package/components/date-range-input/index.js +3 -1
- package/cssm/Component.desktop.d.ts +5 -4
- package/cssm/Component.desktop.js +4 -2
- package/cssm/Component.mobile.d.ts +5 -4
- package/cssm/Component.mobile.js +4 -2
- package/cssm/Component.responsive.d.ts +5 -4
- package/cssm/Component.responsive.js +7 -5
- package/cssm/components/date-range-input/Component.d.ts +108 -0
- package/cssm/components/date-range-input/Component.js +219 -14
- package/cssm/components/date-range-input/index.d.ts +1 -1
- package/cssm/components/date-range-input/index.js +3 -1
- package/cssm/desktop.js +3 -1
- package/cssm/index.js +5 -3
- package/cssm/mobile.js +4 -2
- package/cssm/responsive.js +5 -3
- package/desktop.js +3 -1
- package/esm/Component.desktop.d.ts +5 -4
- package/esm/Component.desktop.js +5 -3
- package/esm/Component.mobile.d.ts +5 -4
- package/esm/Component.mobile.js +5 -3
- package/esm/Component.responsive.d.ts +5 -4
- package/esm/Component.responsive.js +7 -5
- package/esm/components/date-range-input/Component.d.ts +108 -0
- package/esm/components/date-range-input/Component.js +216 -12
- package/esm/components/date-range-input/index.css +6 -6
- package/esm/components/date-range-input/index.d.ts +1 -1
- package/esm/components/date-range-input/index.js +3 -1
- package/esm/desktop.js +3 -1
- package/esm/index.js +5 -3
- package/esm/mobile.js +4 -2
- package/esm/responsive.js +5 -3
- package/index.js +5 -3
- package/mobile.js +4 -2
- package/modern/Component.desktop.d.ts +5 -4
- package/modern/Component.desktop.js +3 -2
- package/modern/Component.mobile.d.ts +5 -4
- package/modern/Component.mobile.js +3 -2
- package/modern/Component.responsive.d.ts +5 -4
- package/modern/Component.responsive.js +5 -4
- package/modern/components/date-range-input/Component.d.ts +16 -104
- package/modern/components/date-range-input/Component.js +65 -28
- package/modern/components/date-range-input/index.css +6 -6
- package/modern/components/date-range-input/index.js +1 -0
- package/modern/desktop.js +1 -0
- package/modern/index.js +1 -0
- package/modern/mobile.js +1 -0
- package/modern/responsive.js +1 -0
- package/package.json +7 -6
- package/responsive.js +5 -3
- package/Component-156f85af.d.ts +0 -229
- package/Component-156f85af.js +0 -225
- package/cssm/Component-540e1474.d.ts +0 -229
- package/cssm/Component-540e1474.js +0 -224
- package/esm/Component-2c3bcbd6.d.ts +0 -229
- package/esm/Component-2c3bcbd6.js +0 -215
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ChangeEvent, ElementType } from "react";
|
|
4
|
+
import { CalendarMobileProps, CalendarProps } from "@alfalab/core-components-calendar";
|
|
5
|
+
import { InputProps } from "@alfalab/core-components-input";
|
|
6
|
+
import { PopoverProps } from "@alfalab/core-components-popover";
|
|
7
|
+
type ConditionalProps = {
|
|
8
|
+
/**
|
|
9
|
+
* Обработчик изменения значения
|
|
10
|
+
*/
|
|
11
|
+
picker: true;
|
|
12
|
+
/**
|
|
13
|
+
* Обработчик закрытия календаря
|
|
14
|
+
*/
|
|
15
|
+
onClose?: () => void;
|
|
16
|
+
} | {
|
|
17
|
+
picker?: false;
|
|
18
|
+
onClose?: never;
|
|
19
|
+
};
|
|
20
|
+
type DateRangeInputProps = Omit<InputProps, 'onChange'> & ConditionalProps & {
|
|
21
|
+
/**
|
|
22
|
+
* Дополнительный класс
|
|
23
|
+
*/
|
|
24
|
+
className?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Дополнительный класс для инпута
|
|
27
|
+
*/
|
|
28
|
+
inputClassName?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Дополнительный класс для поповера
|
|
31
|
+
*/
|
|
32
|
+
popoverClassName?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Обработчик изменения значения
|
|
35
|
+
*/
|
|
36
|
+
onChange?: (payload: {
|
|
37
|
+
dateFrom?: Date;
|
|
38
|
+
dateTo?: Date;
|
|
39
|
+
value: string;
|
|
40
|
+
}, event?: ChangeEvent<HTMLInputElement>) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Обработчик окончания ввода
|
|
43
|
+
*/
|
|
44
|
+
onComplete?: (payload: {
|
|
45
|
+
dateFrom: Date;
|
|
46
|
+
dateTo: Date;
|
|
47
|
+
value: string;
|
|
48
|
+
}, event?: ChangeEvent<HTMLInputElement>) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Компонент календаря
|
|
51
|
+
*/
|
|
52
|
+
Calendar?: ElementType;
|
|
53
|
+
/**
|
|
54
|
+
* Доп. пропсы для календаря
|
|
55
|
+
*/
|
|
56
|
+
calendarProps?: (CalendarProps & Record<string, unknown>) | (CalendarMobileProps & Record<string, unknown>);
|
|
57
|
+
/**
|
|
58
|
+
* Месяц в календаре по умолчанию (timestamp)
|
|
59
|
+
*/
|
|
60
|
+
defaultMonth?: number;
|
|
61
|
+
/**
|
|
62
|
+
* Минимальная дата, доступная для выбора (timestamp)
|
|
63
|
+
*/
|
|
64
|
+
minDate?: number;
|
|
65
|
+
/**
|
|
66
|
+
* Максимальная дата, доступная для выбора (timestamp)
|
|
67
|
+
*/
|
|
68
|
+
maxDate?: number;
|
|
69
|
+
/**
|
|
70
|
+
* Список событий
|
|
71
|
+
*/
|
|
72
|
+
events?: Array<Date | number>;
|
|
73
|
+
/**
|
|
74
|
+
* Список выходных
|
|
75
|
+
*/
|
|
76
|
+
offDays?: Array<Date | number>;
|
|
77
|
+
/**
|
|
78
|
+
* Состояние открытия по умолчанию
|
|
79
|
+
*/
|
|
80
|
+
defaultOpen?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Позиционирование поповера с календарем
|
|
83
|
+
*/
|
|
84
|
+
popoverPosition?: PopoverProps['position'];
|
|
85
|
+
/**
|
|
86
|
+
* z-index Popover
|
|
87
|
+
*/
|
|
88
|
+
zIndexPopover?: PopoverProps['zIndex'];
|
|
89
|
+
/**
|
|
90
|
+
* Запрещает поповеру менять свою позицию.
|
|
91
|
+
* Например, если места снизу недостаточно,то он все равно будет показан снизу
|
|
92
|
+
*/
|
|
93
|
+
preventFlip?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Календарь будет принимать ширину инпута
|
|
96
|
+
*/
|
|
97
|
+
useAnchorWidth?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Растягивает компонент на ширину контейнера
|
|
100
|
+
*/
|
|
101
|
+
block?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Отображение компонента в мобильном или десктопном виде
|
|
104
|
+
*/
|
|
105
|
+
view?: 'desktop' | 'mobile';
|
|
106
|
+
};
|
|
107
|
+
declare const DateRangeInput: React.ForwardRefExoticComponent<DateRangeInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
108
|
+
export { ConditionalProps, DateRangeInputProps, DateRangeInput };
|
|
@@ -1,13 +1,217 @@
|
|
|
1
|
-
|
|
2
|
-
import 'react';
|
|
3
|
-
import 'react-merge-refs';
|
|
4
|
-
import 'classnames';
|
|
5
|
-
import 'date-fns
|
|
6
|
-
import '
|
|
7
|
-
import '@alfalab/core-components-
|
|
8
|
-
import '@alfalab/core-components-
|
|
9
|
-
import '@alfalab/core-components-
|
|
10
|
-
import '@alfalab/
|
|
11
|
-
import '@alfalab/
|
|
12
|
-
import '
|
|
1
|
+
import { __rest, __assign } from 'tslib';
|
|
2
|
+
import React, { useRef, useState, useEffect } from 'react';
|
|
3
|
+
import mergeRefs from 'react-merge-refs';
|
|
4
|
+
import cn from 'classnames';
|
|
5
|
+
import { startOfMonth } from 'date-fns';
|
|
6
|
+
import dateFnsIsValid from 'date-fns/isValid';
|
|
7
|
+
import { usePeriod, Calendar } from '@alfalab/core-components-calendar/esm';
|
|
8
|
+
import { IconButton } from '@alfalab/core-components-icon-button/esm';
|
|
9
|
+
import { Input } from '@alfalab/core-components-input/esm';
|
|
10
|
+
import { Popover } from '@alfalab/core-components-popover/esm';
|
|
11
|
+
import { useDidUpdateEffect } from '@alfalab/hooks';
|
|
12
|
+
import { CalendarMIcon } from '@alfalab/icons-glyph/CalendarMIcon';
|
|
13
|
+
import { parseTimestampToDate, DATE_FORMAT, format, parseDateString, DATE_MASK, isCompleteDateInput, isValid } from '../../utils/format.js';
|
|
13
14
|
import 'date-fns/parse';
|
|
15
|
+
|
|
16
|
+
var styles = {"component":"date-range-input__component_1iuwu","calendarContainer":"date-range-input__calendarContainer_1iuwu","calendarResponsive":"date-range-input__calendarResponsive_1iuwu","block":"date-range-input__block_1iuwu"};
|
|
17
|
+
require('./index.css')
|
|
18
|
+
|
|
19
|
+
/* eslint-disable no-useless-escape, jsx-a11y/click-events-have-key-events */
|
|
20
|
+
var DateRangeInput = React.forwardRef(function (_a, ref) {
|
|
21
|
+
var _b, _c;
|
|
22
|
+
var _d;
|
|
23
|
+
var className = _a.className, inputClassName = _a.inputClassName, popoverClassName = _a.popoverClassName, disabled = _a.disabled, readOnly = _a.readOnly, picker = _a.picker, _e = _a.defaultValue, defaultValue = _e === void 0 ? '' : _e, propValue = _a.value, onChange = _a.onChange, onComplete = _a.onComplete, onClose = _a.onClose, rightAddons = _a.rightAddons, useAnchorWidth = _a.useAnchorWidth, block = _a.block, _f = _a.popoverPosition, popoverPosition = _f === void 0 ? 'bottom-start' : _f, zIndexPopover = _a.zIndexPopover, preventFlip = _a.preventFlip, _g = _a.Calendar, Calendar$1 = _g === void 0 ? Calendar : _g, _h = _a.calendarProps, calendarProps = _h === void 0 ? {} : _h, defaultMonth = _a.defaultMonth, _j = _a.minDate, minDate = _j === void 0 ? calendarProps.minDate : _j, _k = _a.maxDate, maxDate = _k === void 0 ? calendarProps.maxDate : _k, _l = _a.offDays, offDays = _l === void 0 ? calendarProps.offDays || [] : _l, _m = _a.events, events = _m === void 0 ? calendarProps.events || [] : _m, _o = _a.defaultOpen, defaultOpen = _o === void 0 ? false : _o, _p = _a.view, view = _p === void 0 ? 'desktop' : _p, restProps = __rest(_a, ["className", "inputClassName", "popoverClassName", "disabled", "readOnly", "picker", "defaultValue", "value", "onChange", "onComplete", "onClose", "rightAddons", "useAnchorWidth", "block", "popoverPosition", "zIndexPopover", "preventFlip", "Calendar", "calendarProps", "defaultMonth", "minDate", "maxDate", "offDays", "events", "defaultOpen", "view"]);
|
|
24
|
+
var inputRef = useRef(null);
|
|
25
|
+
var iconRef = useRef(null);
|
|
26
|
+
var calendarRef = useRef(null);
|
|
27
|
+
var _q = useState(propValue || defaultValue), value = _q[0], setValue = _q[1];
|
|
28
|
+
var _r = useState(defaultOpen), open = _r[0], setOpen = _r[1];
|
|
29
|
+
var inputDisabled = disabled || readOnly;
|
|
30
|
+
var calendarResponsive = (_d = calendarProps === null || calendarProps === void 0 ? void 0 : calendarProps.responsive) !== null && _d !== void 0 ? _d : true;
|
|
31
|
+
var _s = usePeriod({ onPeriodChange: handlePeriodChange }), selectedFrom = _s.selectedFrom, selectedTo = _s.selectedTo, updatePeriod = _s.updatePeriod, resetPeriod = _s.resetPeriod, setStart = _s.setStart, setEnd = _s.setEnd;
|
|
32
|
+
useEffect(function () {
|
|
33
|
+
if (value) {
|
|
34
|
+
setCalendarPeriod(getDates(value));
|
|
35
|
+
}
|
|
36
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
37
|
+
}, []);
|
|
38
|
+
useEffect(function () {
|
|
39
|
+
setValue(function (prevValue) {
|
|
40
|
+
if (selectedFrom && selectedTo) {
|
|
41
|
+
var from = parseTimestampToDate(selectedFrom);
|
|
42
|
+
var to = parseTimestampToDate(selectedTo);
|
|
43
|
+
return "".concat(from, " - ").concat(to);
|
|
44
|
+
}
|
|
45
|
+
if (selectedFrom && prevValue.length < DATE_FORMAT.length) {
|
|
46
|
+
return parseTimestampToDate(selectedFrom);
|
|
47
|
+
}
|
|
48
|
+
return prevValue;
|
|
49
|
+
});
|
|
50
|
+
}, [selectedFrom, selectedTo]);
|
|
51
|
+
useDidUpdateEffect(function () {
|
|
52
|
+
var newPropValue = propValue || '';
|
|
53
|
+
setValue(function (prevValue) {
|
|
54
|
+
if (prevValue === newPropValue) {
|
|
55
|
+
return prevValue;
|
|
56
|
+
}
|
|
57
|
+
var dates = getDates(newPropValue);
|
|
58
|
+
setCalendarPeriod(dates);
|
|
59
|
+
return dates.formattedValue;
|
|
60
|
+
});
|
|
61
|
+
}, [propValue]);
|
|
62
|
+
function getDates(val) {
|
|
63
|
+
var formattedValue = format(val);
|
|
64
|
+
var dateArr = formattedValue.split('-').map(function (v) { return v.trim(); });
|
|
65
|
+
var dateFrom = dateArr[0] ? parseDateString(dateArr[0]) : undefined;
|
|
66
|
+
var dateTo = dateArr[1] ? parseDateString(dateArr[1]) : undefined;
|
|
67
|
+
return { formattedValue: formattedValue, dateFrom: dateFrom, dateTo: dateTo, dateArr: dateArr };
|
|
68
|
+
}
|
|
69
|
+
function setCalendarPeriod(_a) {
|
|
70
|
+
var dateFrom = _a.dateFrom, dateTo = _a.dateTo;
|
|
71
|
+
setStart(dateFrom === null || dateFrom === void 0 ? void 0 : dateFrom.getTime());
|
|
72
|
+
setEnd(dateTo === null || dateTo === void 0 ? void 0 : dateTo.getTime());
|
|
73
|
+
}
|
|
74
|
+
function handlePeriodChange(selectedFrom, selectedTo) {
|
|
75
|
+
if (selectedFrom && !selectedTo && value.length === DATE_MASK.length) {
|
|
76
|
+
setValue(parseTimestampToDate(selectedFrom));
|
|
77
|
+
}
|
|
78
|
+
else if ((!selectedFrom && !selectedTo && value.length === DATE_FORMAT.length) ||
|
|
79
|
+
(selectedFrom === selectedTo && value.length === DATE_MASK.length)) {
|
|
80
|
+
setValue('');
|
|
81
|
+
}
|
|
82
|
+
var dateFrom = selectedFrom ? new Date(selectedFrom) : undefined;
|
|
83
|
+
var dateTo = selectedTo ? new Date(selectedTo) : undefined;
|
|
84
|
+
var newValue = [selectedFrom, selectedTo].filter(Boolean)
|
|
85
|
+
.map(function (timestamp) { return parseTimestampToDate(timestamp); })
|
|
86
|
+
.join(' - ');
|
|
87
|
+
onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
88
|
+
dateFrom: dateFrom,
|
|
89
|
+
dateTo: dateTo,
|
|
90
|
+
value: newValue,
|
|
91
|
+
});
|
|
92
|
+
if (dateFrom && dateTo) {
|
|
93
|
+
onComplete === null || onComplete === void 0 ? void 0 : onComplete({
|
|
94
|
+
dateFrom: dateFrom,
|
|
95
|
+
dateTo: dateTo,
|
|
96
|
+
value: newValue,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
var handleInputWrapperFocus = function (event) {
|
|
101
|
+
if (view === 'desktop') {
|
|
102
|
+
if (picker) {
|
|
103
|
+
setOpen(true);
|
|
104
|
+
}
|
|
105
|
+
if (!open && event.target.tagName !== 'INPUT' && calendarRef.current) {
|
|
106
|
+
calendarRef.current.focus();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
var handleBlur = function (event) {
|
|
111
|
+
var _a, _b, _c;
|
|
112
|
+
if (view === 'desktop') {
|
|
113
|
+
var target = (event.relatedTarget || document.activeElement);
|
|
114
|
+
if (((_a = calendarRef.current) === null || _a === void 0 ? void 0 : _a.contains(target)) === false &&
|
|
115
|
+
((_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.contains(target)) === false &&
|
|
116
|
+
((_c = iconRef.current) === null || _c === void 0 ? void 0 : _c.contains(target)) === false) {
|
|
117
|
+
setOpen(false);
|
|
118
|
+
if (onClose) {
|
|
119
|
+
onClose();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
var handleChange = function (event) {
|
|
125
|
+
var _a, _b;
|
|
126
|
+
var newValue = event.target.value;
|
|
127
|
+
if (newValue.length > DATE_MASK.length)
|
|
128
|
+
return;
|
|
129
|
+
// Позволяем вводить только цифры, точки, дефис и пробелы
|
|
130
|
+
if (/[^\d. -]/.test(newValue)) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
var dots = newValue.match(/\./g);
|
|
134
|
+
var hyphen = newValue.match(/\-/g);
|
|
135
|
+
// Не даем вводить больше, чем 4 точки и 1 дефис
|
|
136
|
+
if ((dots && dots.length > 4) || (hyphen && hyphen.length > 1)) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
var _c = getDates(newValue), formattedValue = _c.formattedValue, dateFrom = _c.dateFrom, dateTo = _c.dateTo, dateArr = _c.dateArr;
|
|
140
|
+
if (!dateFrom && !dateTo) {
|
|
141
|
+
resetPeriod();
|
|
142
|
+
}
|
|
143
|
+
else if (selectedFrom && formattedValue.length < DATE_FORMAT.length) {
|
|
144
|
+
setStart();
|
|
145
|
+
}
|
|
146
|
+
else if (selectedFrom && selectedTo) {
|
|
147
|
+
setEnd();
|
|
148
|
+
}
|
|
149
|
+
else if (dateFrom &&
|
|
150
|
+
dateFnsIsValid(dateFrom) &&
|
|
151
|
+
((_a = dateArr[0]) === null || _a === void 0 ? void 0 : _a.length) === DATE_FORMAT.length &&
|
|
152
|
+
dateFrom.getTime() !== selectedFrom) {
|
|
153
|
+
setStart(dateFrom.getTime());
|
|
154
|
+
}
|
|
155
|
+
else if (dateTo &&
|
|
156
|
+
dateFnsIsValid(dateTo) &&
|
|
157
|
+
((_b = dateArr[1]) === null || _b === void 0 ? void 0 : _b.length) === DATE_FORMAT.length &&
|
|
158
|
+
dateTo.getTime() !== selectedTo) {
|
|
159
|
+
setEnd(dateTo.getTime());
|
|
160
|
+
}
|
|
161
|
+
setValue(formattedValue);
|
|
162
|
+
onChange === null || onChange === void 0 ? void 0 : onChange({ dateFrom: dateFrom, dateTo: dateTo, value: formattedValue }, event);
|
|
163
|
+
if (isCompleteDateInput(formattedValue)) {
|
|
164
|
+
var valid = isValid(formattedValue, dateArr[0], dateArr[1]);
|
|
165
|
+
if (!valid)
|
|
166
|
+
return;
|
|
167
|
+
if (dateFrom && dateTo) {
|
|
168
|
+
onComplete === null || onComplete === void 0 ? void 0 : onComplete({ dateFrom: dateFrom, dateTo: dateTo, value: formattedValue }, event);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
var handleCalendarClose = function () {
|
|
173
|
+
if (view === 'mobile' && onClose) {
|
|
174
|
+
onClose();
|
|
175
|
+
}
|
|
176
|
+
setOpen(false);
|
|
177
|
+
};
|
|
178
|
+
var handleClear = function () {
|
|
179
|
+
setValue('');
|
|
180
|
+
resetPeriod();
|
|
181
|
+
};
|
|
182
|
+
var handleCalendarChange = function (date) {
|
|
183
|
+
if (date) {
|
|
184
|
+
updatePeriod(date);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
var handleCalendarWrapperMouseDown = function (event) {
|
|
188
|
+
// Не дает инпуту терять фокус при выборе даты
|
|
189
|
+
event.preventDefault();
|
|
190
|
+
};
|
|
191
|
+
var handleIconButtonClick = function () {
|
|
192
|
+
if (!open)
|
|
193
|
+
setOpen(true);
|
|
194
|
+
if (view === 'desktop' && inputRef.current) {
|
|
195
|
+
inputRef.current.focus();
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
var renderCalendar = function () {
|
|
199
|
+
var activeMonth = (selectedTo && startOfMonth(selectedTo)) ||
|
|
200
|
+
(selectedFrom && startOfMonth(selectedFrom));
|
|
201
|
+
return (
|
|
202
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
203
|
+
React.createElement("div", { onMouseDown: handleCalendarWrapperMouseDown },
|
|
204
|
+
React.createElement(Calendar$1, __assign({}, calendarProps, { responsive: calendarResponsive, open: open, onClose: handleCalendarClose, ref: calendarRef, defaultMonth: activeMonth || defaultMonth, selectedFrom: selectedFrom, selectedTo: selectedTo, onChange: handleCalendarChange, minDate: minDate, maxDate: maxDate, offDays: offDays, events: events }))));
|
|
205
|
+
};
|
|
206
|
+
return (React.createElement("div", { className: cn(styles.component, className, (_b = {},
|
|
207
|
+
_b[styles.block] = block,
|
|
208
|
+
_b)), onFocus: inputDisabled ? undefined : handleInputWrapperFocus, onBlur: handleBlur },
|
|
209
|
+
React.createElement(Input, __assign({}, restProps, { block: block, ref: mergeRefs([ref, inputRef]), value: value, onChange: handleChange, disabled: disabled, readOnly: readOnly, className: inputClassName, onClear: handleClear, rightAddons: React.createElement(React.Fragment, null,
|
|
210
|
+
rightAddons,
|
|
211
|
+
picker && (React.createElement(IconButton, { ref: iconRef, onClick: inputDisabled ? undefined : handleIconButtonClick, icon: CalendarMIcon, size: 'xxs' }))) })),
|
|
212
|
+
picker && (React.createElement(Popover, { open: open, useAnchorWidth: useAnchorWidth, anchorElement: inputRef.current, popperClassName: cn(styles.calendarContainer, (_c = {},
|
|
213
|
+
_c[styles.calendarResponsive] = calendarResponsive,
|
|
214
|
+
_c)), className: popoverClassName, position: popoverPosition, offset: [0, 8], withTransition: false, preventFlip: preventFlip, zIndex: zIndexPopover }, renderCalendar()))));
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
export { DateRangeInput };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 19sow */
|
|
2
2
|
:root {
|
|
3
3
|
} /* deprecated */ :root {
|
|
4
4
|
} :root {
|
|
@@ -40,21 +40,21 @@
|
|
|
40
40
|
/* marker */
|
|
41
41
|
} :root {
|
|
42
42
|
--calendar-popover-border-radius: var(--border-radius-m);
|
|
43
|
-
} .date-range-
|
|
43
|
+
} .date-range-input__component_1iuwu {
|
|
44
44
|
display: inline-block;
|
|
45
45
|
outline: none;
|
|
46
46
|
position: relative;
|
|
47
|
-
} .date-range-
|
|
47
|
+
} .date-range-input__calendarContainer_1iuwu {
|
|
48
48
|
display: inline-block;
|
|
49
49
|
box-sizing: border-box;
|
|
50
50
|
border-radius: var(--calendar-popover-border-radius)
|
|
51
|
-
} @media (max-width: 374px) { .date-range-
|
|
51
|
+
} @media (max-width: 374px) { .date-range-input__calendarContainer_1iuwu {
|
|
52
52
|
width: 100%;
|
|
53
53
|
min-width: 288px
|
|
54
54
|
}
|
|
55
|
-
} .date-range-
|
|
55
|
+
} .date-range-input__calendarResponsive_1iuwu {
|
|
56
56
|
width: var(--calendar-width);
|
|
57
57
|
padding: 0 var(--gap-m);
|
|
58
|
-
} .date-range-
|
|
58
|
+
} .date-range-input__block_1iuwu {
|
|
59
59
|
width: 100%;
|
|
60
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "
|
|
1
|
+
export * from "./Component";
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { DateRangeInput } from './Component.js';
|
|
2
|
+
import 'tslib';
|
|
2
3
|
import 'react';
|
|
3
4
|
import 'react-merge-refs';
|
|
4
5
|
import 'classnames';
|
|
6
|
+
import 'date-fns';
|
|
5
7
|
import 'date-fns/isValid';
|
|
6
8
|
import '@alfalab/core-components-calendar/esm';
|
|
7
9
|
import '@alfalab/core-components-icon-button/esm';
|
package/esm/desktop.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export { DateRangeInputDesktop } from './Component.desktop.js';
|
|
2
|
-
import '
|
|
2
|
+
import 'tslib';
|
|
3
3
|
import 'react';
|
|
4
|
+
import './components/date-range-input/Component.js';
|
|
4
5
|
import 'react-merge-refs';
|
|
5
6
|
import 'classnames';
|
|
7
|
+
import 'date-fns';
|
|
6
8
|
import 'date-fns/isValid';
|
|
7
9
|
import '@alfalab/core-components-calendar/esm';
|
|
8
10
|
import '@alfalab/core-components-icon-button/esm';
|
package/esm/index.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
export { DateRangeInputResponsive as DateRangeInput } 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/date-range-input/Component.js';
|
|
4
7
|
import 'react-merge-refs';
|
|
5
8
|
import 'classnames';
|
|
9
|
+
import 'date-fns';
|
|
6
10
|
import 'date-fns/isValid';
|
|
7
11
|
import '@alfalab/core-components-calendar/esm';
|
|
8
12
|
import '@alfalab/core-components-icon-button/esm';
|
|
9
13
|
import '@alfalab/core-components-input/esm';
|
|
10
14
|
import '@alfalab/core-components-popover/esm';
|
|
11
|
-
import '@alfalab/hooks';
|
|
12
15
|
import '@alfalab/icons-glyph/CalendarMIcon';
|
|
13
16
|
import './utils/format.js';
|
|
14
17
|
import 'date-fns/parse';
|
|
15
|
-
import './Component.desktop.js';
|
|
16
18
|
import './Component.mobile.js';
|
package/esm/mobile.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export { DateRangeInputMobile } from './Component.mobile.js';
|
|
2
|
-
import '
|
|
2
|
+
import 'tslib';
|
|
3
3
|
import 'react';
|
|
4
|
+
import '@alfalab/core-components-calendar/esm';
|
|
5
|
+
import './components/date-range-input/Component.js';
|
|
4
6
|
import 'react-merge-refs';
|
|
5
7
|
import 'classnames';
|
|
8
|
+
import 'date-fns';
|
|
6
9
|
import 'date-fns/isValid';
|
|
7
|
-
import '@alfalab/core-components-calendar/esm';
|
|
8
10
|
import '@alfalab/core-components-icon-button/esm';
|
|
9
11
|
import '@alfalab/core-components-input/esm';
|
|
10
12
|
import '@alfalab/core-components-popover/esm';
|
package/esm/responsive.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
export { DateRangeInputResponsive } 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/date-range-input/Component.js';
|
|
4
7
|
import 'react-merge-refs';
|
|
5
8
|
import 'classnames';
|
|
9
|
+
import 'date-fns';
|
|
6
10
|
import 'date-fns/isValid';
|
|
7
11
|
import '@alfalab/core-components-calendar/esm';
|
|
8
12
|
import '@alfalab/core-components-icon-button/esm';
|
|
9
13
|
import '@alfalab/core-components-input/esm';
|
|
10
14
|
import '@alfalab/core-components-popover/esm';
|
|
11
|
-
import '@alfalab/hooks';
|
|
12
15
|
import '@alfalab/icons-glyph/CalendarMIcon';
|
|
13
16
|
import './utils/format.js';
|
|
14
17
|
import 'date-fns/parse';
|
|
15
|
-
import './Component.desktop.js';
|
|
16
18
|
import './Component.mobile.js';
|
package/index.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var Component_responsive = require('./Component.responsive.js');
|
|
4
|
-
require('
|
|
4
|
+
require('tslib');
|
|
5
5
|
require('react');
|
|
6
|
+
require('@alfalab/hooks');
|
|
7
|
+
require('./Component.desktop.js');
|
|
8
|
+
require('./components/date-range-input/Component.js');
|
|
6
9
|
require('react-merge-refs');
|
|
7
10
|
require('classnames');
|
|
11
|
+
require('date-fns');
|
|
8
12
|
require('date-fns/isValid');
|
|
9
13
|
require('@alfalab/core-components-calendar');
|
|
10
14
|
require('@alfalab/core-components-icon-button');
|
|
11
15
|
require('@alfalab/core-components-input');
|
|
12
16
|
require('@alfalab/core-components-popover');
|
|
13
|
-
require('@alfalab/hooks');
|
|
14
17
|
require('@alfalab/icons-glyph/CalendarMIcon');
|
|
15
18
|
require('./utils/format.js');
|
|
16
19
|
require('date-fns/parse');
|
|
17
|
-
require('./Component.desktop.js');
|
|
18
20
|
require('./Component.mobile.js');
|
|
19
21
|
|
|
20
22
|
|
package/mobile.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
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/date-range-input/Component.js');
|
|
6
8
|
require('react-merge-refs');
|
|
7
9
|
require('classnames');
|
|
10
|
+
require('date-fns');
|
|
8
11
|
require('date-fns/isValid');
|
|
9
|
-
require('@alfalab/core-components-calendar');
|
|
10
12
|
require('@alfalab/core-components-icon-button');
|
|
11
13
|
require('@alfalab/core-components-input');
|
|
12
14
|
require('@alfalab/core-components-popover');
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { DateRangeInputProps, ConditionalProps } from "./components/date-range-input/Component";
|
|
4
|
+
type DateRangeInputDesktopProps = Omit<DateRangeInputProps, 'view' | 'picker' | 'onClose'> & ConditionalProps;
|
|
5
|
+
declare const DateRangeInputDesktop: React.ForwardRefExoticComponent<DateRangeInputDesktopProps & React.RefAttributes<HTMLInputElement>>;
|
|
5
6
|
export { DateRangeInputDesktopProps, DateRangeInputDesktop };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
2
|
import { DateRangeInput } from './components/date-range-input/Component.js';
|
|
3
3
|
import 'react-merge-refs';
|
|
4
4
|
import 'classnames';
|
|
5
|
+
import 'date-fns';
|
|
5
6
|
import 'date-fns/isValid';
|
|
6
7
|
import '@alfalab/core-components-calendar/modern';
|
|
7
8
|
import '@alfalab/core-components-icon-button/modern';
|
|
@@ -12,6 +13,6 @@ import '@alfalab/icons-glyph/CalendarMIcon';
|
|
|
12
13
|
import './utils/format.js';
|
|
13
14
|
import 'date-fns/parse';
|
|
14
15
|
|
|
15
|
-
const DateRangeInputDesktop = (props) =>
|
|
16
|
+
const DateRangeInputDesktop = forwardRef((props, ref) => React.createElement(DateRangeInput, { ...props, ref: ref }));
|
|
16
17
|
|
|
17
18
|
export { DateRangeInputDesktop };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { DateRangeInputProps, ConditionalProps } from "./components/date-range-input/Component";
|
|
4
|
+
type DateRangeInputMobileProps = Omit<DateRangeInputProps, 'view' | 'picker' | 'onClose'> & ConditionalProps;
|
|
5
|
+
declare const DateRangeInputMobile: React.ForwardRefExoticComponent<DateRangeInputMobileProps & React.RefAttributes<HTMLInputElement>>;
|
|
5
6
|
export { DateRangeInputMobileProps, DateRangeInputMobile };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
2
|
import { CalendarMobile } from '@alfalab/core-components-calendar/modern';
|
|
3
3
|
import { DateRangeInput } from './components/date-range-input/Component.js';
|
|
4
4
|
import 'react-merge-refs';
|
|
5
5
|
import 'classnames';
|
|
6
|
+
import 'date-fns';
|
|
6
7
|
import 'date-fns/isValid';
|
|
7
8
|
import '@alfalab/core-components-icon-button/modern';
|
|
8
9
|
import '@alfalab/core-components-input/modern';
|
|
@@ -12,6 +13,6 @@ import '@alfalab/icons-glyph/CalendarMIcon';
|
|
|
12
13
|
import './utils/format.js';
|
|
13
14
|
import 'date-fns/parse';
|
|
14
15
|
|
|
15
|
-
const DateRangeInputMobile = (props) =>
|
|
16
|
+
const DateRangeInputMobile = forwardRef((props, ref) => React.createElement(DateRangeInput, { Calendar: CalendarMobile, view: 'mobile', ...props, ref: ref }));
|
|
16
17
|
|
|
17
18
|
export { DateRangeInputMobile };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { DateRangeInputProps, ConditionalProps } from "./components/date-range-input/Component";
|
|
4
|
+
type DateRangeInputResponsiveProps = Omit<DateRangeInputProps, 'view' | 'picker' | 'onClose'> & ConditionalProps & {
|
|
4
5
|
/**
|
|
5
6
|
* Контрольная точка, с нее начинается desktop версия
|
|
6
7
|
* @default 1024
|
|
@@ -8,5 +9,5 @@ type DateRangeInputResponsiveProps = Omit<DateRangeInputProps, 'view'> & {
|
|
|
8
9
|
breakpoint?: number;
|
|
9
10
|
};
|
|
10
11
|
type DateRangeInputMedia = 'desktop' | 'mobile';
|
|
11
|
-
declare const DateRangeInputResponsive:
|
|
12
|
+
declare const DateRangeInputResponsive: React.ForwardRefExoticComponent<DateRangeInputResponsiveProps & React.RefAttributes<HTMLInputElement>>;
|
|
12
13
|
export { DateRangeInputResponsiveProps, DateRangeInputMedia, DateRangeInputResponsive };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
2
|
import { useMedia } from '@alfalab/hooks';
|
|
3
3
|
import { DateRangeInputDesktop } from './Component.desktop.js';
|
|
4
4
|
import { DateRangeInputMobile } from './Component.mobile.js';
|
|
5
5
|
import './components/date-range-input/Component.js';
|
|
6
6
|
import 'react-merge-refs';
|
|
7
7
|
import 'classnames';
|
|
8
|
+
import 'date-fns';
|
|
8
9
|
import 'date-fns/isValid';
|
|
9
10
|
import '@alfalab/core-components-calendar/modern';
|
|
10
11
|
import '@alfalab/core-components-icon-button/modern';
|
|
@@ -14,12 +15,12 @@ import '@alfalab/icons-glyph/CalendarMIcon';
|
|
|
14
15
|
import './utils/format.js';
|
|
15
16
|
import 'date-fns/parse';
|
|
16
17
|
|
|
17
|
-
const DateRangeInputResponsive = ({ breakpoint = 1024, ...restProps }) => {
|
|
18
|
+
const DateRangeInputResponsive = forwardRef(({ breakpoint = 1024, ...restProps }, ref) => {
|
|
18
19
|
const [view] = useMedia([
|
|
19
20
|
['mobile', `(max-width: ${breakpoint - 1}px)`],
|
|
20
21
|
['desktop', `(min-width: ${breakpoint}px)`],
|
|
21
22
|
], 'desktop');
|
|
22
|
-
return view === 'desktop' ? (React.createElement(DateRangeInputDesktop, { ...restProps })) : (React.createElement(DateRangeInputMobile, { ...restProps }));
|
|
23
|
-
};
|
|
23
|
+
return view === 'desktop' ? (React.createElement(DateRangeInputDesktop, { ...restProps, ref: ref })) : (React.createElement(DateRangeInputMobile, { ...restProps, ref: ref }));
|
|
24
|
+
});
|
|
24
25
|
|
|
25
26
|
export { DateRangeInputResponsive };
|