@alfalab/core-components-date-time-input 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Component.d.ts ADDED
@@ -0,0 +1,184 @@
1
+ /// <reference types="react" />
2
+ import React from 'react';
3
+ import { ChangeEvent, ElementType } from "react";
4
+ import { InputProps } from "@alfalab/core-components-input";
5
+ import { CalendarProps, CalendarMobileProps } from "@alfalab/core-components-calendar";
6
+ import { PopoverProps } from "@alfalab/core-components-popover";
7
+ type DateTimeInputProps = Omit<InputProps, 'onChange'> & {
8
+ /**
9
+ * Дополнительный класс
10
+ */
11
+ className?: string;
12
+ /**
13
+ * Дополнительный класс для инпута
14
+ */
15
+ inputClassName?: string;
16
+ /**
17
+ * Дополнительный класс для поповера
18
+ */
19
+ popoverClassName?: string;
20
+ /**
21
+ * Обработчик изменения значения
22
+ */
23
+ picker?: boolean;
24
+ /**
25
+ * Обработчик изменения значения
26
+ */
27
+ onChange?: (event: ChangeEvent<HTMLInputElement>, payload: {
28
+ date: Date;
29
+ value: string;
30
+ }) => void;
31
+ /**
32
+ * Обработчик окончания ввода
33
+ */
34
+ onComplete?: (event: ChangeEvent<HTMLInputElement>, payload: {
35
+ date: Date;
36
+ value: string;
37
+ }) => void;
38
+ /**
39
+ * Компонент календаря
40
+ */
41
+ Calendar?: ElementType<CalendarProps>;
42
+ /**
43
+ * Доп. пропсы для календаря
44
+ */
45
+ calendarProps?: (CalendarProps & Record<string, unknown>) | (CalendarMobileProps & Record<string, unknown>);
46
+ /**
47
+ * Месяц в календаре по умолчанию (timestamp)
48
+ */
49
+ defaultMonth?: number;
50
+ /**
51
+ * Минимальная дата, доступная для выбора (timestamp)
52
+ */
53
+ minDate?: number;
54
+ /**
55
+ * Максимальная дата, доступная для выбора (timestamp)
56
+ */
57
+ maxDate?: number;
58
+ /**
59
+ * Список событий
60
+ */
61
+ events?: Array<Date | number>;
62
+ /**
63
+ * Список выходных
64
+ */
65
+ offDays?: Array<Date | number>;
66
+ /**
67
+ * Состояние открытия по умолчанию
68
+ */
69
+ defaultOpen?: boolean;
70
+ /**
71
+ * Позиционирование поповера с календарем
72
+ */
73
+ popoverPosition?: PopoverProps['position'];
74
+ /**
75
+ * z-index Popover
76
+ */
77
+ zIndexPopover?: PopoverProps['zIndex'];
78
+ /**
79
+ * Запрещает поповеру менять свою позицию.
80
+ * Например, если места снизу недостаточно,то он все равно будет показан снизу
81
+ */
82
+ preventFlip?: boolean;
83
+ /**
84
+ * Календарь будет принимать ширину инпута
85
+ */
86
+ useAnchorWidth?: boolean;
87
+ /**
88
+ * Растягивает компонент на ширину контейнера
89
+ */
90
+ block?: boolean;
91
+ };
92
+ declare const DateTimeInput: React.ForwardRefExoticComponent<Pick<InputProps, "className" | "dataTestId" | "form" | "label" | "slot" | "style" | "title" | "pattern" | "leftAddons" | "rightAddons" | "size" | "block" | "colors" | "children" | "type" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "list" | "step" | "autoFocus" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "name" | "value" | "fieldClassName" | "labelClassName" | "addonsClassName" | "error" | "hint" | "labelView" | "bottomAddons" | "accept" | "alt" | "autoComplete" | "capture" | "checked" | "crossOrigin" | "height" | "max" | "maxLength" | "min" | "minLength" | "multiple" | "readOnly" | "required" | "src" | "width" | "clear" | "success" | "inputClassName" | "focusedClassName" | "filledClassName" | "onClear" | "wrapperRef"> & {
93
+ /**
94
+ * Дополнительный класс
95
+ */
96
+ className?: string | undefined;
97
+ /**
98
+ * Дополнительный класс для инпута
99
+ */
100
+ inputClassName?: string | undefined;
101
+ /**
102
+ * Дополнительный класс для поповера
103
+ */
104
+ popoverClassName?: string | undefined;
105
+ /**
106
+ * Обработчик изменения значения
107
+ */
108
+ picker?: boolean | undefined;
109
+ /**
110
+ * Обработчик изменения значения
111
+ */
112
+ onChange?: ((event: React.ChangeEvent<HTMLInputElement>, payload: {
113
+ date: Date;
114
+ value: string;
115
+ }) => void) | undefined;
116
+ /**
117
+ * Обработчик окончания ввода
118
+ */
119
+ onComplete?: ((event: React.ChangeEvent<HTMLInputElement>, payload: {
120
+ date: Date;
121
+ value: string;
122
+ }) => void) | undefined;
123
+ /**
124
+ * Компонент календаря
125
+ */
126
+ Calendar?: React.ComponentClass<CalendarProps, any> | React.FunctionComponent<CalendarProps> | undefined;
127
+ /**
128
+ * Доп. пропсы для календаря
129
+ */
130
+ calendarProps?: (CalendarProps & Record<string, unknown>) | (CalendarProps & {
131
+ open: boolean;
132
+ title?: string | undefined;
133
+ onClose?: (() => void) | undefined;
134
+ yearsAmount?: number | undefined;
135
+ hasHeader?: boolean | undefined;
136
+ allowSelectionFromEmptyRange?: boolean | undefined;
137
+ } & Record<string, unknown>) | undefined;
138
+ /**
139
+ * Месяц в календаре по умолчанию (timestamp)
140
+ */
141
+ defaultMonth?: number | undefined;
142
+ /**
143
+ * Минимальная дата, доступная для выбора (timestamp)
144
+ */
145
+ minDate?: number | undefined;
146
+ /**
147
+ * Максимальная дата, доступная для выбора (timestamp)
148
+ */
149
+ maxDate?: number | undefined;
150
+ /**
151
+ * Список событий
152
+ */
153
+ events?: (number | Date)[] | undefined;
154
+ /**
155
+ * Список выходных
156
+ */
157
+ offDays?: (number | Date)[] | undefined;
158
+ /**
159
+ * Состояние открытия по умолчанию
160
+ */
161
+ defaultOpen?: boolean | undefined;
162
+ /**
163
+ * Позиционирование поповера с календарем
164
+ */
165
+ popoverPosition?: "right" | "left" | "top" | "bottom" | "top-start" | "top-end" | "bottom-start" | "bottom-end" | "right-start" | "right-end" | "left-start" | "left-end" | undefined;
166
+ /**
167
+ * z-index Popover
168
+ */
169
+ zIndexPopover?: number | undefined;
170
+ /**
171
+ * Запрещает поповеру менять свою позицию.
172
+ * Например, если места снизу недостаточно,то он все равно будет показан снизу
173
+ */
174
+ preventFlip?: boolean | undefined;
175
+ /**
176
+ * Календарь будет принимать ширину инпута
177
+ */
178
+ useAnchorWidth?: boolean | undefined;
179
+ /**
180
+ * Растягивает компонент на ширину контейнера
181
+ */
182
+ block?: boolean | undefined;
183
+ } & React.RefAttributes<HTMLInputElement>>;
184
+ export { DateTimeInputProps, DateTimeInput };
package/Component.js ADDED
@@ -0,0 +1,180 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var cn = require('classnames');
7
+ var mergeRefs = require('react-merge-refs');
8
+ var hooks = require('@alfalab/hooks');
9
+ var coreComponentsInput = require('@alfalab/core-components-input');
10
+ var coreComponentsCalendar = require('@alfalab/core-components-calendar');
11
+ var coreComponentsPopover = require('@alfalab/core-components-popover');
12
+ var coreComponentsIconButton = require('@alfalab/core-components-icon-button');
13
+ var CalendarMIcon = require('@alfalab/icons-glyph/CalendarMIcon');
14
+ require('date-fns/parse');
15
+ require('date-fns/isValid');
16
+ var utils_format = require('./utils/format.js');
17
+
18
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19
+
20
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
21
+ var cn__default = /*#__PURE__*/_interopDefaultLegacy(cn);
22
+ var mergeRefs__default = /*#__PURE__*/_interopDefaultLegacy(mergeRefs);
23
+
24
+ /*! *****************************************************************************
25
+ Copyright (c) Microsoft Corporation.
26
+
27
+ Permission to use, copy, modify, and/or distribute this software for any
28
+ purpose with or without fee is hereby granted.
29
+
30
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
31
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
32
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
33
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
34
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
35
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
36
+ PERFORMANCE OF THIS SOFTWARE.
37
+ ***************************************************************************** */
38
+ var __assign = function () {
39
+ __assign = Object.assign || function __assign(t) {
40
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
41
+ s = arguments[i];
42
+ for (var p in s)
43
+ if (Object.prototype.hasOwnProperty.call(s, p))
44
+ t[p] = s[p];
45
+ }
46
+ return t;
47
+ };
48
+ return __assign.apply(this, arguments);
49
+ };
50
+ function __rest(s, e) {
51
+ var t = {};
52
+ for (var p in s)
53
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
54
+ t[p] = s[p];
55
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
56
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
57
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
58
+ t[p[i]] = s[p[i]];
59
+ }
60
+ return t;
61
+ }
62
+
63
+ var styles = {"component":"date-time-input__component_m484y","calendarContainer":"date-time-input__calendarContainer_m484y","calendarResponsive":"date-time-input__calendarResponsive_m484y","block":"date-time-input__block_m484y"};
64
+ require('./index.css')
65
+
66
+ /* eslint-disable no-useless-escape, jsx-a11y/click-events-have-key-events */
67
+ var DateTimeInput = React__default['default'].forwardRef(function (_a, ref) {
68
+ var _b, _c;
69
+ var _d;
70
+ 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, 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 = _g === void 0 ? coreComponentsCalendar.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, error = _a.error, restProps = __rest(_a, ["className", "inputClassName", "popoverClassName", "disabled", "readOnly", "picker", "defaultValue", "value", "onChange", "onComplete", "rightAddons", "useAnchorWidth", "block", "popoverPosition", "zIndexPopover", "preventFlip", "Calendar", "calendarProps", "defaultMonth", "minDate", "maxDate", "offDays", "events", "defaultOpen", "error"]);
71
+ var view = hooks.useMedia([
72
+ ['mobile', '(max-width: 1023px)'],
73
+ ['desktop', '(min-width: 1024px)'],
74
+ ], 'desktop')[0];
75
+ var inputRef = React.useRef(null);
76
+ var calendarRef = React.useRef(null);
77
+ var _p = React.useState(propValue || defaultValue), value = _p[0], setValue = _p[1];
78
+ var _q = React.useState(false), open = _q[0], setOpen = _q[1];
79
+ var calendarValue = value ? utils_format.getDateWithoutTime(value).getTime() : undefined;
80
+ var inputDisabled = disabled || readOnly;
81
+ var CalendarComponent = view === 'desktop' ? Calendar : coreComponentsCalendar.CalendarMobile;
82
+ var calendarResponsive = (_d = calendarProps === null || calendarProps === void 0 ? void 0 : calendarProps.responsive) !== null && _d !== void 0 ? _d : true;
83
+ React.useEffect(function () {
84
+ setOpen(defaultOpen);
85
+ }, [defaultOpen]);
86
+ var checkInputValueIsValid = function (newInputValue) {
87
+ if (!newInputValue || error)
88
+ return false;
89
+ var dateValue = utils_format.getDateWithoutTime(newInputValue).getTime();
90
+ return (dateValue &&
91
+ coreComponentsCalendar.dateInLimits(dateValue, minDate, maxDate) &&
92
+ !offDays.includes(dateValue));
93
+ };
94
+ var handleInputWrapperFocus = function (event) {
95
+ if (view === 'desktop') {
96
+ if (!open && event.target.tagName !== 'INPUT' && calendarRef.current) {
97
+ calendarRef.current.focus();
98
+ }
99
+ }
100
+ };
101
+ var handleBlur = function (event) {
102
+ if (view === 'desktop') {
103
+ var target = (event.relatedTarget || document.activeElement);
104
+ if (calendarRef.current && calendarRef.current.contains(target) === false) {
105
+ setOpen(false);
106
+ setValue(function (prevValue) { return utils_format.setTimeToDate(prevValue); });
107
+ }
108
+ }
109
+ };
110
+ var handleChange = function (event) {
111
+ var newValue = event.target.value;
112
+ if (newValue.length > utils_format.DATE_MASK.length)
113
+ return;
114
+ // Позволяем вводить только цифры, точки, запятую, двоеточие и пробел
115
+ if (/[^\d., :\d.]/.test(newValue)) {
116
+ return;
117
+ }
118
+ var dots = newValue.match(/\./g);
119
+ var colon = newValue.match(/\:/g);
120
+ var comma = newValue.match(/\,/g);
121
+ // Не даем вводить больше, чем 2 точки, 1 двоеточие и 1 запятую
122
+ if ((dots && dots.length > 2) ||
123
+ (colon && colon.length > 1) ||
124
+ (comma && comma.length > 1)) {
125
+ return;
126
+ }
127
+ var formattedValue = utils_format.format(newValue);
128
+ var date = utils_format.getFullDateTime(formattedValue);
129
+ setValue(formattedValue);
130
+ if (onChange)
131
+ onChange(event, { date: date, value: formattedValue });
132
+ if (utils_format.isCompleteDateInput(formattedValue)) {
133
+ var valid = utils_format.isValid(formattedValue);
134
+ if (!valid)
135
+ return;
136
+ if (onComplete) {
137
+ onComplete(event, { date: date, value: formattedValue });
138
+ }
139
+ }
140
+ };
141
+ var handleCalendarClose = function () {
142
+ setOpen(false);
143
+ };
144
+ var handleClear = function () {
145
+ setValue('');
146
+ };
147
+ var handleCalendarChange = function (date) {
148
+ if (date) {
149
+ setValue(utils_format.parseTimestampToDate(date));
150
+ }
151
+ };
152
+ var handleCalendarWrapperMouseDown = function (event) {
153
+ // Не дает инпуту терять фокус при выборе даты
154
+ event.preventDefault();
155
+ };
156
+ var handleInputWrapperClick = function () {
157
+ if (view === 'desktop' && !open) {
158
+ setOpen(true);
159
+ }
160
+ };
161
+ var handleIconButtonClick = function () {
162
+ if (!open)
163
+ setOpen(true);
164
+ };
165
+ var renderCalendar = function () { return (
166
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
167
+ React__default['default'].createElement("div", { onMouseDown: handleCalendarWrapperMouseDown },
168
+ React__default['default'].createElement(CalendarComponent, __assign({}, calendarProps, { responsive: calendarResponsive, open: open, onClose: handleCalendarClose, ref: calendarRef, defaultMonth: defaultMonth, value: checkInputValueIsValid(value) ? calendarValue : undefined, onChange: handleCalendarChange, minDate: minDate, maxDate: maxDate, offDays: offDays, events: events })))); };
169
+ return (React__default['default'].createElement("div", { className: cn__default['default'](styles.component, className, (_b = {},
170
+ _b[styles.block] = block,
171
+ _b)), onClick: inputDisabled ? undefined : handleInputWrapperClick, onFocus: inputDisabled ? undefined : handleInputWrapperFocus, onBlur: handleBlur },
172
+ React__default['default'].createElement(coreComponentsInput.Input, __assign({}, restProps, { block: block, ref: mergeRefs__default['default']([ref, inputRef]), value: value, onChange: handleChange, disabled: disabled, readOnly: readOnly, className: inputClassName, onClear: handleClear, error: error, rightAddons: React__default['default'].createElement(React__default['default'].Fragment, null,
173
+ rightAddons,
174
+ picker && (React__default['default'].createElement(coreComponentsIconButton.IconButton, { onClick: inputDisabled ? undefined : handleIconButtonClick, icon: CalendarMIcon.CalendarMIcon, size: 'xxs' }))) })),
175
+ picker && (React__default['default'].createElement(coreComponentsPopover.Popover, { open: open, useAnchorWidth: useAnchorWidth, anchorElement: inputRef.current, popperClassName: cn__default['default'](styles.calendarContainer, (_c = {},
176
+ _c[styles.calendarResponsive] = calendarResponsive,
177
+ _c)), className: popoverClassName, position: popoverPosition, offset: [0, 8], withTransition: false, preventFlip: preventFlip, zIndex: zIndexPopover }, renderCalendar()))));
178
+ });
179
+
180
+ exports.DateTimeInput = DateTimeInput;
@@ -0,0 +1,184 @@
1
+ /// <reference types="react" />
2
+ import React from 'react';
3
+ import { ChangeEvent, ElementType } from "react";
4
+ import { InputProps } from "@alfalab/core-components-input";
5
+ import { CalendarProps, CalendarMobileProps } from "@alfalab/core-components-calendar";
6
+ import { PopoverProps } from "@alfalab/core-components-popover";
7
+ type DateTimeInputProps = Omit<InputProps, 'onChange'> & {
8
+ /**
9
+ * Дополнительный класс
10
+ */
11
+ className?: string;
12
+ /**
13
+ * Дополнительный класс для инпута
14
+ */
15
+ inputClassName?: string;
16
+ /**
17
+ * Дополнительный класс для поповера
18
+ */
19
+ popoverClassName?: string;
20
+ /**
21
+ * Обработчик изменения значения
22
+ */
23
+ picker?: boolean;
24
+ /**
25
+ * Обработчик изменения значения
26
+ */
27
+ onChange?: (event: ChangeEvent<HTMLInputElement>, payload: {
28
+ date: Date;
29
+ value: string;
30
+ }) => void;
31
+ /**
32
+ * Обработчик окончания ввода
33
+ */
34
+ onComplete?: (event: ChangeEvent<HTMLInputElement>, payload: {
35
+ date: Date;
36
+ value: string;
37
+ }) => void;
38
+ /**
39
+ * Компонент календаря
40
+ */
41
+ Calendar?: ElementType<CalendarProps>;
42
+ /**
43
+ * Доп. пропсы для календаря
44
+ */
45
+ calendarProps?: (CalendarProps & Record<string, unknown>) | (CalendarMobileProps & Record<string, unknown>);
46
+ /**
47
+ * Месяц в календаре по умолчанию (timestamp)
48
+ */
49
+ defaultMonth?: number;
50
+ /**
51
+ * Минимальная дата, доступная для выбора (timestamp)
52
+ */
53
+ minDate?: number;
54
+ /**
55
+ * Максимальная дата, доступная для выбора (timestamp)
56
+ */
57
+ maxDate?: number;
58
+ /**
59
+ * Список событий
60
+ */
61
+ events?: Array<Date | number>;
62
+ /**
63
+ * Список выходных
64
+ */
65
+ offDays?: Array<Date | number>;
66
+ /**
67
+ * Состояние открытия по умолчанию
68
+ */
69
+ defaultOpen?: boolean;
70
+ /**
71
+ * Позиционирование поповера с календарем
72
+ */
73
+ popoverPosition?: PopoverProps['position'];
74
+ /**
75
+ * z-index Popover
76
+ */
77
+ zIndexPopover?: PopoverProps['zIndex'];
78
+ /**
79
+ * Запрещает поповеру менять свою позицию.
80
+ * Например, если места снизу недостаточно,то он все равно будет показан снизу
81
+ */
82
+ preventFlip?: boolean;
83
+ /**
84
+ * Календарь будет принимать ширину инпута
85
+ */
86
+ useAnchorWidth?: boolean;
87
+ /**
88
+ * Растягивает компонент на ширину контейнера
89
+ */
90
+ block?: boolean;
91
+ };
92
+ declare const DateTimeInput: React.ForwardRefExoticComponent<Pick<InputProps, "className" | "dataTestId" | "form" | "label" | "slot" | "style" | "title" | "pattern" | "leftAddons" | "rightAddons" | "size" | "block" | "colors" | "children" | "type" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "list" | "step" | "autoFocus" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "name" | "value" | "fieldClassName" | "labelClassName" | "addonsClassName" | "error" | "hint" | "labelView" | "bottomAddons" | "accept" | "alt" | "autoComplete" | "capture" | "checked" | "crossOrigin" | "height" | "max" | "maxLength" | "min" | "minLength" | "multiple" | "readOnly" | "required" | "src" | "width" | "clear" | "success" | "inputClassName" | "focusedClassName" | "filledClassName" | "onClear" | "wrapperRef"> & {
93
+ /**
94
+ * Дополнительный класс
95
+ */
96
+ className?: string | undefined;
97
+ /**
98
+ * Дополнительный класс для инпута
99
+ */
100
+ inputClassName?: string | undefined;
101
+ /**
102
+ * Дополнительный класс для поповера
103
+ */
104
+ popoverClassName?: string | undefined;
105
+ /**
106
+ * Обработчик изменения значения
107
+ */
108
+ picker?: boolean | undefined;
109
+ /**
110
+ * Обработчик изменения значения
111
+ */
112
+ onChange?: ((event: React.ChangeEvent<HTMLInputElement>, payload: {
113
+ date: Date;
114
+ value: string;
115
+ }) => void) | undefined;
116
+ /**
117
+ * Обработчик окончания ввода
118
+ */
119
+ onComplete?: ((event: React.ChangeEvent<HTMLInputElement>, payload: {
120
+ date: Date;
121
+ value: string;
122
+ }) => void) | undefined;
123
+ /**
124
+ * Компонент календаря
125
+ */
126
+ Calendar?: React.ComponentClass<CalendarProps, any> | React.FunctionComponent<CalendarProps> | undefined;
127
+ /**
128
+ * Доп. пропсы для календаря
129
+ */
130
+ calendarProps?: (CalendarProps & Record<string, unknown>) | (CalendarProps & {
131
+ open: boolean;
132
+ title?: string | undefined;
133
+ onClose?: (() => void) | undefined;
134
+ yearsAmount?: number | undefined;
135
+ hasHeader?: boolean | undefined;
136
+ allowSelectionFromEmptyRange?: boolean | undefined;
137
+ } & Record<string, unknown>) | undefined;
138
+ /**
139
+ * Месяц в календаре по умолчанию (timestamp)
140
+ */
141
+ defaultMonth?: number | undefined;
142
+ /**
143
+ * Минимальная дата, доступная для выбора (timestamp)
144
+ */
145
+ minDate?: number | undefined;
146
+ /**
147
+ * Максимальная дата, доступная для выбора (timestamp)
148
+ */
149
+ maxDate?: number | undefined;
150
+ /**
151
+ * Список событий
152
+ */
153
+ events?: (number | Date)[] | undefined;
154
+ /**
155
+ * Список выходных
156
+ */
157
+ offDays?: (number | Date)[] | undefined;
158
+ /**
159
+ * Состояние открытия по умолчанию
160
+ */
161
+ defaultOpen?: boolean | undefined;
162
+ /**
163
+ * Позиционирование поповера с календарем
164
+ */
165
+ popoverPosition?: "right" | "left" | "top" | "bottom" | "top-start" | "top-end" | "bottom-start" | "bottom-end" | "right-start" | "right-end" | "left-start" | "left-end" | undefined;
166
+ /**
167
+ * z-index Popover
168
+ */
169
+ zIndexPopover?: number | undefined;
170
+ /**
171
+ * Запрещает поповеру менять свою позицию.
172
+ * Например, если места снизу недостаточно,то он все равно будет показан снизу
173
+ */
174
+ preventFlip?: boolean | undefined;
175
+ /**
176
+ * Календарь будет принимать ширину инпута
177
+ */
178
+ useAnchorWidth?: boolean | undefined;
179
+ /**
180
+ * Растягивает компонент на ширину контейнера
181
+ */
182
+ block?: boolean | undefined;
183
+ } & React.RefAttributes<HTMLInputElement>>;
184
+ export { DateTimeInputProps, DateTimeInput };