@alfalab/core-components-date-time-input 3.0.6 → 3.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/Component.desktop.d.ts +4 -3
  2. package/Component.desktop.js +3 -2
  3. package/Component.mobile.d.ts +4 -3
  4. package/Component.mobile.js +3 -2
  5. package/Component.responsive.d.ts +10 -3
  6. package/Component.responsive.js +6 -5
  7. package/components/date-time-input/Component.d.ts +192 -0
  8. package/components/date-time-input/Component.js +148 -12
  9. package/components/date-time-input/index.css +6 -6
  10. package/components/date-time-input/index.d.ts +1 -1
  11. package/components/date-time-input/index.js +2 -1
  12. package/cssm/Component.desktop.d.ts +4 -3
  13. package/cssm/Component.desktop.js +3 -2
  14. package/cssm/Component.mobile.d.ts +4 -3
  15. package/cssm/Component.mobile.js +3 -2
  16. package/cssm/Component.responsive.d.ts +10 -3
  17. package/cssm/Component.responsive.js +6 -5
  18. package/cssm/components/date-time-input/Component.d.ts +192 -0
  19. package/cssm/components/date-time-input/Component.js +147 -13
  20. package/cssm/components/date-time-input/index.d.ts +1 -1
  21. package/cssm/components/date-time-input/index.js +2 -1
  22. package/cssm/desktop.js +2 -1
  23. package/cssm/index.js +4 -3
  24. package/cssm/mobile.js +3 -2
  25. package/cssm/responsive.js +4 -3
  26. package/desktop.js +2 -1
  27. package/esm/Component.desktop.d.ts +4 -3
  28. package/esm/Component.desktop.js +4 -3
  29. package/esm/Component.mobile.d.ts +4 -3
  30. package/esm/Component.mobile.js +4 -3
  31. package/esm/Component.responsive.d.ts +10 -3
  32. package/esm/Component.responsive.js +6 -5
  33. package/esm/components/date-time-input/Component.d.ts +192 -0
  34. package/esm/components/date-time-input/Component.js +145 -11
  35. package/esm/components/date-time-input/index.css +6 -6
  36. package/esm/components/date-time-input/index.d.ts +1 -1
  37. package/esm/components/date-time-input/index.js +2 -1
  38. package/esm/desktop.js +2 -1
  39. package/esm/index.js +4 -3
  40. package/esm/mobile.js +3 -2
  41. package/esm/responsive.js +4 -3
  42. package/index.js +4 -3
  43. package/mobile.js +3 -2
  44. package/modern/Component.desktop.d.ts +3 -2
  45. package/modern/Component.desktop.js +2 -2
  46. package/modern/Component.mobile.d.ts +3 -2
  47. package/modern/Component.mobile.js +2 -2
  48. package/modern/Component.responsive.d.ts +9 -2
  49. package/modern/Component.responsive.js +4 -4
  50. package/modern/components/date-time-input/Component.d.ts +1 -1
  51. package/modern/components/date-time-input/Component.js +1 -1
  52. package/modern/components/date-time-input/index.css +6 -6
  53. package/package.json +7 -6
  54. package/responsive.js +4 -3
  55. package/Component-45618e75.d.ts +0 -225
  56. package/Component-45618e75.js +0 -192
  57. package/cssm/Component-b91f18e8.d.ts +0 -225
  58. package/cssm/Component-b91f18e8.js +0 -191
  59. package/esm/Component-9d1d72a0.d.ts +0 -225
  60. package/esm/Component-9d1d72a0.js +0 -183
@@ -0,0 +1,192 @@
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 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> | null, payload: {
28
+ date: Date;
29
+ value: string;
30
+ }) => void;
31
+ /**
32
+ * Обработчик окончания ввода
33
+ */
34
+ onComplete?: (event: ChangeEvent<HTMLInputElement> | null, payload: {
35
+ date: Date;
36
+ value: string;
37
+ }) => void;
38
+ /**
39
+ * Компонент календаря
40
+ */
41
+ Calendar?: ElementType;
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
+ * Отображение компонента в мобильном или десктопном виде
93
+ */
94
+ view?: 'desktop' | 'mobile';
95
+ };
96
+ declare const DateTimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
97
+ /**
98
+ * Дополнительный класс
99
+ */
100
+ className?: string | undefined;
101
+ /**
102
+ * Дополнительный класс для инпута
103
+ */
104
+ inputClassName?: string | undefined;
105
+ /**
106
+ * Дополнительный класс для поповера
107
+ */
108
+ popoverClassName?: string | undefined;
109
+ /**
110
+ * Обработчик изменения значения
111
+ */
112
+ picker?: boolean | undefined;
113
+ /**
114
+ * Обработчик изменения значения
115
+ */
116
+ onChange?: ((event: ChangeEvent<HTMLInputElement> | null, payload: {
117
+ date: Date;
118
+ value: string;
119
+ }) => void) | undefined;
120
+ /**
121
+ * Обработчик окончания ввода
122
+ */
123
+ onComplete?: ((event: ChangeEvent<HTMLInputElement> | null, payload: {
124
+ date: Date;
125
+ value: string;
126
+ }) => void) | undefined;
127
+ /**
128
+ * Компонент календаря
129
+ */
130
+ Calendar?: React.ElementType<any> | undefined;
131
+ /**
132
+ * Доп. пропсы для календаря
133
+ */
134
+ calendarProps?: (CalendarProps & Record<string, unknown>) | (CalendarProps & {
135
+ open: boolean;
136
+ title?: string | undefined;
137
+ onClose?: (() => void) | undefined;
138
+ yearsAmount?: number | undefined;
139
+ hasHeader?: boolean | undefined;
140
+ allowSelectionFromEmptyRange?: boolean | undefined;
141
+ } & Record<string, unknown>) | undefined;
142
+ /**
143
+ * Месяц в календаре по умолчанию (timestamp)
144
+ */
145
+ defaultMonth?: number | undefined;
146
+ /**
147
+ * Минимальная дата, доступная для выбора (timestamp)
148
+ */
149
+ minDate?: number | undefined;
150
+ /**
151
+ * Максимальная дата, доступная для выбора (timestamp)
152
+ */
153
+ maxDate?: number | undefined;
154
+ /**
155
+ * Список событий
156
+ */
157
+ events?: (number | Date)[] | undefined;
158
+ /**
159
+ * Список выходных
160
+ */
161
+ offDays?: (number | Date)[] | undefined;
162
+ /**
163
+ * Состояние открытия по умолчанию
164
+ */
165
+ defaultOpen?: boolean | undefined;
166
+ /**
167
+ * Позиционирование поповера с календарем
168
+ */
169
+ popoverPosition?: PopoverProps['position'];
170
+ /**
171
+ * z-index Popover
172
+ */
173
+ zIndexPopover?: PopoverProps['zIndex'];
174
+ /**
175
+ * Запрещает поповеру менять свою позицию.
176
+ * Например, если места снизу недостаточно,то он все равно будет показан снизу
177
+ */
178
+ preventFlip?: boolean | undefined;
179
+ /**
180
+ * Календарь будет принимать ширину инпута
181
+ */
182
+ useAnchorWidth?: boolean | undefined;
183
+ /**
184
+ * Растягивает компонент на ширину контейнера
185
+ */
186
+ block?: boolean | undefined;
187
+ /**
188
+ * Отображение компонента в мобильном или десктопном виде
189
+ */
190
+ view?: "mobile" | "desktop" | undefined;
191
+ } & React.RefAttributes<HTMLInputElement>>;
192
+ export { DateTimeInputProps, DateTimeInput };
@@ -1,20 +1,154 @@
1
1
  'use strict';
2
2
 
3
- var components_dateTimeInput_Component = require('../../Component-b91f18e8.js');
4
- require('react');
5
- require('react-merge-refs');
6
- require('classnames');
7
- require('@alfalab/core-components-calendar/cssm');
8
- require('@alfalab/core-components-icon-button/cssm');
9
- require('@alfalab/core-components-input/cssm');
10
- require('@alfalab/core-components-popover/cssm');
11
- require('@alfalab/hooks');
12
- require('@alfalab/icons-glyph/CalendarMIcon');
13
- require('../../utils/format.js');
14
- require('./index.module.css');
3
+ var tslib = require('tslib');
4
+ var React = require('react');
5
+ var mergeRefs = require('react-merge-refs');
6
+ var cn = require('classnames');
7
+ var coreComponentsCalendar = require('@alfalab/core-components-calendar/cssm');
8
+ var coreComponentsIconButton = require('@alfalab/core-components-icon-button/cssm');
9
+ var coreComponentsInput = require('@alfalab/core-components-input/cssm');
10
+ var coreComponentsPopover = require('@alfalab/core-components-popover/cssm');
11
+ var hooks = require('@alfalab/hooks');
12
+ var CalendarMIcon = require('@alfalab/icons-glyph/CalendarMIcon');
13
+ var utils_format = require('../../utils/format.js');
14
+ var styles = require('./index.module.css');
15
15
  require('date-fns/isValid');
16
16
  require('date-fns/parse');
17
17
 
18
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
18
19
 
20
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
21
+ var mergeRefs__default = /*#__PURE__*/_interopDefaultCompat(mergeRefs);
22
+ var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
23
+ var styles__default = /*#__PURE__*/_interopDefaultCompat(styles);
19
24
 
20
- exports.DateTimeInput = components_dateTimeInput_Component.DateTimeInput;
25
+ /* eslint-disable no-useless-escape, jsx-a11y/click-events-have-key-events */
26
+ var DateTimeInput = React__default.default.forwardRef(function (_a, ref) {
27
+ var _b, _c;
28
+ var _d;
29
+ 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, _p = _a.view, view = _p === void 0 ? 'desktop' : _p, restProps = tslib.__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", "view"]);
30
+ var inputRef = React.useRef(null);
31
+ var calendarRef = React.useRef(null);
32
+ var _q = React.useState(propValue || defaultValue), value = _q[0], setValue = _q[1];
33
+ var _r = React.useState(false), open = _r[0], setOpen = _r[1];
34
+ var calendarValue = value ? utils_format.getDateWithoutTime(value).getTime() : undefined;
35
+ var inputDisabled = disabled || readOnly;
36
+ var calendarResponsive = (_d = calendarProps === null || calendarProps === void 0 ? void 0 : calendarProps.responsive) !== null && _d !== void 0 ? _d : true;
37
+ React.useEffect(function () {
38
+ setOpen(defaultOpen);
39
+ }, [defaultOpen]);
40
+ hooks.useDidUpdateEffect(function () {
41
+ var newPropValue = propValue || '';
42
+ setValue(function (prevValue) { return (prevValue === propValue ? prevValue : newPropValue); });
43
+ }, [propValue]);
44
+ var checkInputValueIsValid = function (newInputValue) {
45
+ if (!newInputValue || error)
46
+ return false;
47
+ var dateValue = utils_format.getDateWithoutTime(newInputValue).getTime();
48
+ return (dateValue &&
49
+ coreComponentsCalendar.dateInLimits(dateValue, minDate, maxDate) &&
50
+ !offDays.includes(dateValue));
51
+ };
52
+ var setTimeToDate = function () {
53
+ setValue(function (prevValue) {
54
+ var dateWithTime = utils_format.addTimeToDate(prevValue);
55
+ if (dateWithTime !== prevValue && dateWithTime.length === utils_format.DATE_WITH_TIME_LENGTH) {
56
+ onComplete === null || onComplete === void 0 ? void 0 : onComplete(null, {
57
+ date: utils_format.getFullDateTime(dateWithTime),
58
+ value: dateWithTime,
59
+ });
60
+ }
61
+ return dateWithTime;
62
+ });
63
+ };
64
+ var handleInputWrapperFocus = function (event) {
65
+ if (view === 'desktop') {
66
+ if (picker) {
67
+ setOpen(true);
68
+ }
69
+ if (!open && event.target.tagName !== 'INPUT' && calendarRef.current) {
70
+ calendarRef.current.focus();
71
+ }
72
+ }
73
+ };
74
+ var handleBlur = function (event) {
75
+ if (view === 'desktop') {
76
+ var target = (event.relatedTarget || document.activeElement);
77
+ if (calendarRef.current && calendarRef.current.contains(target) === false) {
78
+ setOpen(false);
79
+ setTimeToDate();
80
+ }
81
+ }
82
+ };
83
+ var handleChange = function (event) {
84
+ var newValue = event.target.value;
85
+ if (newValue.length > utils_format.DATE_WITH_TIME_LENGTH)
86
+ return;
87
+ // Позволяем вводить только цифры, точки, запятую, двоеточие и пробел
88
+ if (/[^\d., :]/.test(newValue)) {
89
+ return;
90
+ }
91
+ var dots = newValue.match(/\./g);
92
+ var colon = newValue.match(/:/g);
93
+ var comma = newValue.match(/,/g);
94
+ // Не даем вводить больше, чем 2 точки, 1 двоеточие и 1 запятую
95
+ if ((dots && dots.length > 2) ||
96
+ (colon && colon.length > 1) ||
97
+ (comma && comma.length > 1)) {
98
+ return;
99
+ }
100
+ var formattedValue = utils_format.format(newValue);
101
+ var date = utils_format.getFullDateTime(formattedValue);
102
+ setValue(formattedValue);
103
+ if (onChange)
104
+ onChange(event, { date: date, value: formattedValue });
105
+ if (utils_format.isCompleteDateInput(formattedValue)) {
106
+ var valid = utils_format.isValid(formattedValue);
107
+ if (!valid)
108
+ return;
109
+ if (onComplete) {
110
+ onComplete(event, { date: date, value: formattedValue });
111
+ }
112
+ }
113
+ };
114
+ var handleMobileCalendarClose = function () {
115
+ setOpen(false);
116
+ setTimeToDate();
117
+ };
118
+ var handleClear = function () {
119
+ setValue('');
120
+ };
121
+ var handleCalendarChange = function (date) {
122
+ if (date) {
123
+ var newValue = utils_format.parseTimestampToDate(date);
124
+ setValue(newValue);
125
+ onChange === null || onChange === void 0 ? void 0 : onChange(null, { date: utils_format.getFullDateTime(newValue), value: newValue });
126
+ }
127
+ };
128
+ var handleCalendarWrapperMouseDown = function (event) {
129
+ // Не дает инпуту терять фокус при выборе даты
130
+ event.preventDefault();
131
+ };
132
+ var handleIconButtonClick = function () {
133
+ if (!open)
134
+ setOpen(true);
135
+ if (view === 'desktop' && inputRef.current) {
136
+ inputRef.current.focus();
137
+ }
138
+ };
139
+ var renderCalendar = function () { return (
140
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
141
+ React__default.default.createElement("div", { onMouseDown: handleCalendarWrapperMouseDown },
142
+ React__default.default.createElement(Calendar, tslib.__assign({}, calendarProps, { responsive: calendarResponsive, open: open, onClose: handleMobileCalendarClose, ref: calendarRef, defaultMonth: defaultMonth, value: checkInputValueIsValid(value) ? calendarValue : undefined, onChange: handleCalendarChange, minDate: minDate, maxDate: maxDate, offDays: offDays, events: events })))); };
143
+ return (React__default.default.createElement("div", { className: cn__default.default(styles__default.default.component, className, (_b = {},
144
+ _b[styles__default.default.block] = block,
145
+ _b)), onFocus: inputDisabled ? undefined : handleInputWrapperFocus, onBlur: handleBlur },
146
+ React__default.default.createElement(coreComponentsInput.Input, tslib.__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,
147
+ rightAddons,
148
+ picker && (React__default.default.createElement(coreComponentsIconButton.IconButton, { onClick: inputDisabled ? undefined : handleIconButtonClick, icon: CalendarMIcon.CalendarMIcon, size: 'xxs' }))) })),
149
+ picker && (React__default.default.createElement(coreComponentsPopover.Popover, { open: open, useAnchorWidth: useAnchorWidth, anchorElement: inputRef.current, popperClassName: cn__default.default(styles__default.default.calendarContainer, (_c = {},
150
+ _c[styles__default.default.calendarResponsive] = calendarResponsive,
151
+ _c)), className: popoverClassName, position: popoverPosition, offset: [0, 8], withTransition: false, preventFlip: preventFlip, zIndex: zIndexPopover }, renderCalendar()))));
152
+ });
153
+
154
+ exports.DateTimeInput = DateTimeInput;
@@ -1 +1 @@
1
- export * from "../../Component-b91f18e8";
1
+ export * from "./Component";
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var components_dateTimeInput_Component = require('../../Component-b91f18e8.js');
3
+ var components_dateTimeInput_Component = require('./Component.js');
4
+ require('tslib');
4
5
  require('react');
5
6
  require('react-merge-refs');
6
7
  require('classnames');
package/cssm/desktop.js CHANGED
@@ -1,8 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var Component_desktop = require('./Component.desktop.js');
4
- require('./Component-b91f18e8.js');
4
+ require('tslib');
5
5
  require('react');
6
+ require('./components/date-time-input/Component.js');
6
7
  require('react-merge-refs');
7
8
  require('classnames');
8
9
  require('@alfalab/core-components-calendar/cssm');
package/cssm/index.js CHANGED
@@ -1,21 +1,22 @@
1
1
  'use strict';
2
2
 
3
3
  var Component_responsive = require('./Component.responsive.js');
4
- require('./Component-b91f18e8.js');
4
+ require('tslib');
5
5
  require('react');
6
+ require('@alfalab/hooks');
7
+ require('./Component.desktop.js');
8
+ require('./components/date-time-input/Component.js');
6
9
  require('react-merge-refs');
7
10
  require('classnames');
8
11
  require('@alfalab/core-components-calendar/cssm');
9
12
  require('@alfalab/core-components-icon-button/cssm');
10
13
  require('@alfalab/core-components-input/cssm');
11
14
  require('@alfalab/core-components-popover/cssm');
12
- require('@alfalab/hooks');
13
15
  require('@alfalab/icons-glyph/CalendarMIcon');
14
16
  require('./utils/format.js');
15
17
  require('date-fns/isValid');
16
18
  require('date-fns/parse');
17
19
  require('./components/date-time-input/index.module.css');
18
- require('./Component.desktop.js');
19
20
  require('./Component.mobile.js');
20
21
 
21
22
 
package/cssm/mobile.js CHANGED
@@ -1,11 +1,12 @@
1
1
  'use strict';
2
2
 
3
3
  var Component_mobile = require('./Component.mobile.js');
4
- require('./Component-b91f18e8.js');
4
+ require('tslib');
5
5
  require('react');
6
+ require('@alfalab/core-components-calendar/cssm');
7
+ require('./components/date-time-input/Component.js');
6
8
  require('react-merge-refs');
7
9
  require('classnames');
8
- require('@alfalab/core-components-calendar/cssm');
9
10
  require('@alfalab/core-components-icon-button/cssm');
10
11
  require('@alfalab/core-components-input/cssm');
11
12
  require('@alfalab/core-components-popover/cssm');
@@ -1,21 +1,22 @@
1
1
  'use strict';
2
2
 
3
3
  var Component_responsive = require('./Component.responsive.js');
4
- require('./Component-b91f18e8.js');
4
+ require('tslib');
5
5
  require('react');
6
+ require('@alfalab/hooks');
7
+ require('./Component.desktop.js');
8
+ require('./components/date-time-input/Component.js');
6
9
  require('react-merge-refs');
7
10
  require('classnames');
8
11
  require('@alfalab/core-components-calendar/cssm');
9
12
  require('@alfalab/core-components-icon-button/cssm');
10
13
  require('@alfalab/core-components-input/cssm');
11
14
  require('@alfalab/core-components-popover/cssm');
12
- require('@alfalab/hooks');
13
15
  require('@alfalab/icons-glyph/CalendarMIcon');
14
16
  require('./utils/format.js');
15
17
  require('date-fns/isValid');
16
18
  require('date-fns/parse');
17
19
  require('./components/date-time-input/index.module.css');
18
- require('./Component.desktop.js');
19
20
  require('./Component.mobile.js');
20
21
 
21
22
 
package/desktop.js CHANGED
@@ -1,8 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var Component_desktop = require('./Component.desktop.js');
4
- require('./Component-45618e75.js');
4
+ require('tslib');
5
5
  require('react');
6
+ require('./components/date-time-input/Component.js');
6
7
  require('react-merge-refs');
7
8
  require('classnames');
8
9
  require('@alfalab/core-components-calendar');
@@ -1,5 +1,6 @@
1
- import { FC } from 'react';
2
- import { DateTimeInputProps } from "./Component-9d1d72a0";
1
+ /// <reference types="react" />
2
+ import React from 'react';
3
+ import { DateTimeInputProps } from "./components/date-time-input/Component";
3
4
  type DateTimeInputDesktopProps = Omit<DateTimeInputProps, 'view'>;
4
- declare const DateTimeInputDesktop: FC<DateTimeInputDesktopProps>;
5
+ declare const DateTimeInputDesktop: React.ForwardRefExoticComponent<DateTimeInputDesktopProps & React.RefAttributes<HTMLInputElement>>;
5
6
  export { DateTimeInputDesktopProps, DateTimeInputDesktop };
@@ -1,5 +1,6 @@
1
- import { D as DateTimeInput, _ as __assign } from './Component-9d1d72a0.js';
2
- import React from 'react';
1
+ import { __assign } from 'tslib';
2
+ import React, { forwardRef } from 'react';
3
+ import { DateTimeInput } from './components/date-time-input/Component.js';
3
4
  import 'react-merge-refs';
4
5
  import 'classnames';
5
6
  import '@alfalab/core-components-calendar/esm';
@@ -12,6 +13,6 @@ import './utils/format.js';
12
13
  import 'date-fns/isValid';
13
14
  import 'date-fns/parse';
14
15
 
15
- var DateTimeInputDesktop = function (props) { return (React.createElement(DateTimeInput, __assign({}, props))); };
16
+ var DateTimeInputDesktop = forwardRef(function (props, ref) { return React.createElement(DateTimeInput, __assign({}, props, { ref: ref })); });
16
17
 
17
18
  export { DateTimeInputDesktop };
@@ -1,5 +1,6 @@
1
- import { FC } from 'react';
2
- import { DateTimeInputProps } from "./Component-9d1d72a0";
1
+ /// <reference types="react" />
2
+ import React from 'react';
3
+ import { DateTimeInputProps } from "./components/date-time-input/Component";
3
4
  type DateTimeInputMobileProps = Omit<DateTimeInputProps, 'view'>;
4
- declare const DateTimeInputMobile: FC<DateTimeInputMobileProps>;
5
+ declare const DateTimeInputMobile: React.ForwardRefExoticComponent<DateTimeInputMobileProps & React.RefAttributes<HTMLInputElement>>;
5
6
  export { DateTimeInputMobileProps, DateTimeInputMobile };
@@ -1,6 +1,7 @@
1
- import { D as DateTimeInput, _ as __assign } from './Component-9d1d72a0.js';
2
- import React from 'react';
1
+ import { __assign } from 'tslib';
2
+ import React, { forwardRef } from 'react';
3
3
  import { CalendarMobile } from '@alfalab/core-components-calendar/esm';
4
+ import { DateTimeInput } from './components/date-time-input/Component.js';
4
5
  import 'react-merge-refs';
5
6
  import 'classnames';
6
7
  import '@alfalab/core-components-icon-button/esm';
@@ -12,6 +13,6 @@ import './utils/format.js';
12
13
  import 'date-fns/isValid';
13
14
  import 'date-fns/parse';
14
15
 
15
- var DateTimeInputMobile = function (props) { return (React.createElement(DateTimeInput, __assign({ Calendar: CalendarMobile, view: 'mobile' }, props))); };
16
+ var DateTimeInputMobile = forwardRef(function (props, ref) { return React.createElement(DateTimeInput, __assign({ Calendar: CalendarMobile, view: 'mobile' }, props, { ref: ref })); });
16
17
 
17
18
  export { DateTimeInputMobile };
@@ -1,5 +1,6 @@
1
- import { FC } from 'react';
2
- import { DateTimeInputProps } from "./Component-9d1d72a0";
1
+ /// <reference types="react" />
2
+ import React from 'react';
3
+ import { DateTimeInputProps } from "./components/date-time-input/Component";
3
4
  type DateTimeInputResponsiveProps = Omit<DateTimeInputProps, 'view'> & {
4
5
  /**
5
6
  * Контрольная точка, с нее начинается desktop версия
@@ -8,5 +9,11 @@ type DateTimeInputResponsiveProps = Omit<DateTimeInputProps, 'view'> & {
8
9
  breakpoint?: number;
9
10
  };
10
11
  type DateTimeInputMedia = 'desktop' | 'mobile';
11
- declare const DateTimeInputResponsive: FC<DateTimeInputResponsiveProps>;
12
+ declare const DateTimeInputResponsive: React.ForwardRefExoticComponent<Omit<DateTimeInputProps, "view"> & {
13
+ /**
14
+ * Контрольная точка, с нее начинается desktop версия
15
+ * @default 1024
16
+ */
17
+ breakpoint?: number | undefined;
18
+ } & React.RefAttributes<HTMLInputElement>>;
12
19
  export { DateTimeInputResponsiveProps, DateTimeInputMedia, DateTimeInputResponsive };
@@ -1,8 +1,9 @@
1
- import { a as __rest, _ as __assign } from './Component-9d1d72a0.js';
2
- import React from 'react';
1
+ import { __rest, __assign } from 'tslib';
2
+ import React, { forwardRef } from 'react';
3
3
  import { useMedia } from '@alfalab/hooks';
4
4
  import { DateTimeInputDesktop } from './Component.desktop.js';
5
5
  import { DateTimeInputMobile } from './Component.mobile.js';
6
+ import './components/date-time-input/Component.js';
6
7
  import 'react-merge-refs';
7
8
  import 'classnames';
8
9
  import '@alfalab/core-components-calendar/esm';
@@ -14,13 +15,13 @@ import './utils/format.js';
14
15
  import 'date-fns/isValid';
15
16
  import 'date-fns/parse';
16
17
 
17
- var DateTimeInputResponsive = function (_a) {
18
+ var DateTimeInputResponsive = forwardRef(function (_a, ref) {
18
19
  var _b = _a.breakpoint, breakpoint = _b === void 0 ? 1024 : _b, restProps = __rest(_a, ["breakpoint"]);
19
20
  var view = useMedia([
20
21
  ['mobile', "(max-width: ".concat(breakpoint - 1, "px)")],
21
22
  ['desktop', "(min-width: ".concat(breakpoint, "px)")],
22
23
  ], 'desktop')[0];
23
- return view === 'desktop' ? (React.createElement(DateTimeInputDesktop, __assign({}, restProps))) : (React.createElement(DateTimeInputMobile, __assign({}, restProps)));
24
- };
24
+ return view === 'desktop' ? (React.createElement(DateTimeInputDesktop, __assign({}, restProps, { ref: ref }))) : (React.createElement(DateTimeInputMobile, __assign({}, restProps, { ref: ref })));
25
+ });
25
26
 
26
27
  export { DateTimeInputResponsive };