@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.
- package/Component.desktop.d.ts +4 -3
- package/Component.desktop.js +3 -2
- package/Component.mobile.d.ts +4 -3
- package/Component.mobile.js +3 -2
- package/Component.responsive.d.ts +10 -3
- package/Component.responsive.js +6 -5
- package/components/date-time-input/Component.d.ts +192 -0
- package/components/date-time-input/Component.js +148 -12
- package/components/date-time-input/index.css +6 -6
- package/components/date-time-input/index.d.ts +1 -1
- package/components/date-time-input/index.js +2 -1
- package/cssm/Component.desktop.d.ts +4 -3
- package/cssm/Component.desktop.js +3 -2
- package/cssm/Component.mobile.d.ts +4 -3
- package/cssm/Component.mobile.js +3 -2
- package/cssm/Component.responsive.d.ts +10 -3
- package/cssm/Component.responsive.js +6 -5
- package/cssm/components/date-time-input/Component.d.ts +192 -0
- package/cssm/components/date-time-input/Component.js +147 -13
- package/cssm/components/date-time-input/index.d.ts +1 -1
- package/cssm/components/date-time-input/index.js +2 -1
- package/cssm/desktop.js +2 -1
- package/cssm/index.js +4 -3
- package/cssm/mobile.js +3 -2
- package/cssm/responsive.js +4 -3
- package/desktop.js +2 -1
- package/esm/Component.desktop.d.ts +4 -3
- package/esm/Component.desktop.js +4 -3
- package/esm/Component.mobile.d.ts +4 -3
- package/esm/Component.mobile.js +4 -3
- package/esm/Component.responsive.d.ts +10 -3
- package/esm/Component.responsive.js +6 -5
- package/esm/components/date-time-input/Component.d.ts +192 -0
- package/esm/components/date-time-input/Component.js +145 -11
- package/esm/components/date-time-input/index.css +6 -6
- package/esm/components/date-time-input/index.d.ts +1 -1
- package/esm/components/date-time-input/index.js +2 -1
- package/esm/desktop.js +2 -1
- package/esm/index.js +4 -3
- package/esm/mobile.js +3 -2
- package/esm/responsive.js +4 -3
- package/index.js +4 -3
- package/mobile.js +3 -2
- package/modern/Component.desktop.d.ts +3 -2
- package/modern/Component.desktop.js +2 -2
- package/modern/Component.mobile.d.ts +3 -2
- package/modern/Component.mobile.js +2 -2
- package/modern/Component.responsive.d.ts +9 -2
- package/modern/Component.responsive.js +4 -4
- package/modern/components/date-time-input/Component.d.ts +1 -1
- package/modern/components/date-time-input/Component.js +1 -1
- package/modern/components/date-time-input/index.css +6 -6
- package/package.json +7 -6
- package/responsive.js +4 -3
- package/Component-45618e75.d.ts +0 -225
- package/Component-45618e75.js +0 -192
- package/cssm/Component-b91f18e8.d.ts +0 -225
- package/cssm/Component-b91f18e8.js +0 -191
- package/esm/Component-9d1d72a0.d.ts +0 -225
- package/esm/Component-9d1d72a0.js +0 -183
package/Component.desktop.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
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:
|
|
5
|
+
declare const DateTimeInputDesktop: React.ForwardRefExoticComponent<DateTimeInputDesktopProps & React.RefAttributes<HTMLInputElement>>;
|
|
5
6
|
export { DateTimeInputDesktopProps, DateTimeInputDesktop };
|
package/Component.desktop.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var tslib = require('tslib');
|
|
4
4
|
var React = require('react');
|
|
5
|
+
var components_dateTimeInput_Component = require('./components/date-time-input/Component.js');
|
|
5
6
|
require('react-merge-refs');
|
|
6
7
|
require('classnames');
|
|
7
8
|
require('@alfalab/core-components-calendar');
|
|
@@ -18,6 +19,6 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
18
19
|
|
|
19
20
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
20
21
|
|
|
21
|
-
var DateTimeInputDesktop = function (props) { return
|
|
22
|
+
var DateTimeInputDesktop = React.forwardRef(function (props, ref) { return React__default.default.createElement(components_dateTimeInput_Component.DateTimeInput, tslib.__assign({}, props, { ref: ref })); });
|
|
22
23
|
|
|
23
24
|
exports.DateTimeInputDesktop = DateTimeInputDesktop;
|
package/Component.mobile.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
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:
|
|
5
|
+
declare const DateTimeInputMobile: React.ForwardRefExoticComponent<DateTimeInputMobileProps & React.RefAttributes<HTMLInputElement>>;
|
|
5
6
|
export { DateTimeInputMobileProps, DateTimeInputMobile };
|
package/Component.mobile.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var tslib = require('tslib');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var coreComponentsCalendar = require('@alfalab/core-components-calendar');
|
|
6
|
+
var components_dateTimeInput_Component = require('./components/date-time-input/Component.js');
|
|
6
7
|
require('react-merge-refs');
|
|
7
8
|
require('classnames');
|
|
8
9
|
require('@alfalab/core-components-icon-button');
|
|
@@ -18,6 +19,6 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
18
19
|
|
|
19
20
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
20
21
|
|
|
21
|
-
var DateTimeInputMobile = function (props) { return
|
|
22
|
+
var DateTimeInputMobile = React.forwardRef(function (props, ref) { return React__default.default.createElement(components_dateTimeInput_Component.DateTimeInput, tslib.__assign({ Calendar: coreComponentsCalendar.CalendarMobile, view: 'mobile' }, props, { ref: ref })); });
|
|
22
23
|
|
|
23
24
|
exports.DateTimeInputMobile = DateTimeInputMobile;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
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:
|
|
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 };
|
package/Component.responsive.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var tslib = require('tslib');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var hooks = require('@alfalab/hooks');
|
|
6
6
|
var Component_desktop = require('./Component.desktop.js');
|
|
7
7
|
var Component_mobile = require('./Component.mobile.js');
|
|
8
|
+
require('./components/date-time-input/Component.js');
|
|
8
9
|
require('react-merge-refs');
|
|
9
10
|
require('classnames');
|
|
10
11
|
require('@alfalab/core-components-calendar');
|
|
@@ -20,13 +21,13 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
20
21
|
|
|
21
22
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
22
23
|
|
|
23
|
-
var DateTimeInputResponsive = function (_a) {
|
|
24
|
-
var _b = _a.breakpoint, breakpoint = _b === void 0 ? 1024 : _b, restProps =
|
|
24
|
+
var DateTimeInputResponsive = React.forwardRef(function (_a, ref) {
|
|
25
|
+
var _b = _a.breakpoint, breakpoint = _b === void 0 ? 1024 : _b, restProps = tslib.__rest(_a, ["breakpoint"]);
|
|
25
26
|
var view = hooks.useMedia([
|
|
26
27
|
['mobile', "(max-width: ".concat(breakpoint - 1, "px)")],
|
|
27
28
|
['desktop', "(min-width: ".concat(breakpoint, "px)")],
|
|
28
29
|
], 'desktop')[0];
|
|
29
|
-
return view === 'desktop' ? (React__default.default.createElement(Component_desktop.DateTimeInputDesktop,
|
|
30
|
-
};
|
|
30
|
+
return view === 'desktop' ? (React__default.default.createElement(Component_desktop.DateTimeInputDesktop, tslib.__assign({}, restProps, { ref: ref }))) : (React__default.default.createElement(Component_mobile.DateTimeInputMobile, tslib.__assign({}, restProps, { ref: ref })));
|
|
31
|
+
});
|
|
31
32
|
|
|
32
33
|
exports.DateTimeInputResponsive = DateTimeInputResponsive;
|
|
@@ -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,19 +1,155 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('react');
|
|
5
|
-
require('react-merge-refs');
|
|
6
|
-
require('classnames');
|
|
7
|
-
require('@alfalab/core-components-calendar');
|
|
8
|
-
require('@alfalab/core-components-icon-button');
|
|
9
|
-
require('@alfalab/core-components-input');
|
|
10
|
-
require('@alfalab/core-components-popover');
|
|
11
|
-
require('@alfalab/hooks');
|
|
12
|
-
require('@alfalab/icons-glyph/CalendarMIcon');
|
|
13
|
-
require('../../utils/format.js');
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var mergeRefs = require('react-merge-refs');
|
|
6
|
+
var cn = require('classnames');
|
|
7
|
+
var coreComponentsCalendar = require('@alfalab/core-components-calendar');
|
|
8
|
+
var coreComponentsIconButton = require('@alfalab/core-components-icon-button');
|
|
9
|
+
var coreComponentsInput = require('@alfalab/core-components-input');
|
|
10
|
+
var coreComponentsPopover = require('@alfalab/core-components-popover');
|
|
11
|
+
var hooks = require('@alfalab/hooks');
|
|
12
|
+
var CalendarMIcon = require('@alfalab/icons-glyph/CalendarMIcon');
|
|
13
|
+
var utils_format = require('../../utils/format.js');
|
|
14
14
|
require('date-fns/isValid');
|
|
15
15
|
require('date-fns/parse');
|
|
16
16
|
|
|
17
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
17
18
|
|
|
19
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
20
|
+
var mergeRefs__default = /*#__PURE__*/_interopDefaultCompat(mergeRefs);
|
|
21
|
+
var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
|
|
18
22
|
|
|
19
|
-
|
|
23
|
+
var styles = {"component":"date-time-input__component_aze2c","calendarContainer":"date-time-input__calendarContainer_aze2c","calendarResponsive":"date-time-input__calendarResponsive_aze2c","block":"date-time-input__block_aze2c"};
|
|
24
|
+
require('./index.css')
|
|
25
|
+
|
|
26
|
+
/* eslint-disable no-useless-escape, jsx-a11y/click-events-have-key-events */
|
|
27
|
+
var DateTimeInput = React__default.default.forwardRef(function (_a, ref) {
|
|
28
|
+
var _b, _c;
|
|
29
|
+
var _d;
|
|
30
|
+
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"]);
|
|
31
|
+
var inputRef = React.useRef(null);
|
|
32
|
+
var calendarRef = React.useRef(null);
|
|
33
|
+
var _q = React.useState(propValue || defaultValue), value = _q[0], setValue = _q[1];
|
|
34
|
+
var _r = React.useState(false), open = _r[0], setOpen = _r[1];
|
|
35
|
+
var calendarValue = value ? utils_format.getDateWithoutTime(value).getTime() : undefined;
|
|
36
|
+
var inputDisabled = disabled || readOnly;
|
|
37
|
+
var calendarResponsive = (_d = calendarProps === null || calendarProps === void 0 ? void 0 : calendarProps.responsive) !== null && _d !== void 0 ? _d : true;
|
|
38
|
+
React.useEffect(function () {
|
|
39
|
+
setOpen(defaultOpen);
|
|
40
|
+
}, [defaultOpen]);
|
|
41
|
+
hooks.useDidUpdateEffect(function () {
|
|
42
|
+
var newPropValue = propValue || '';
|
|
43
|
+
setValue(function (prevValue) { return (prevValue === propValue ? prevValue : newPropValue); });
|
|
44
|
+
}, [propValue]);
|
|
45
|
+
var checkInputValueIsValid = function (newInputValue) {
|
|
46
|
+
if (!newInputValue || error)
|
|
47
|
+
return false;
|
|
48
|
+
var dateValue = utils_format.getDateWithoutTime(newInputValue).getTime();
|
|
49
|
+
return (dateValue &&
|
|
50
|
+
coreComponentsCalendar.dateInLimits(dateValue, minDate, maxDate) &&
|
|
51
|
+
!offDays.includes(dateValue));
|
|
52
|
+
};
|
|
53
|
+
var setTimeToDate = function () {
|
|
54
|
+
setValue(function (prevValue) {
|
|
55
|
+
var dateWithTime = utils_format.addTimeToDate(prevValue);
|
|
56
|
+
if (dateWithTime !== prevValue && dateWithTime.length === utils_format.DATE_WITH_TIME_LENGTH) {
|
|
57
|
+
onComplete === null || onComplete === void 0 ? void 0 : onComplete(null, {
|
|
58
|
+
date: utils_format.getFullDateTime(dateWithTime),
|
|
59
|
+
value: dateWithTime,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return dateWithTime;
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
var handleInputWrapperFocus = function (event) {
|
|
66
|
+
if (view === 'desktop') {
|
|
67
|
+
if (picker) {
|
|
68
|
+
setOpen(true);
|
|
69
|
+
}
|
|
70
|
+
if (!open && event.target.tagName !== 'INPUT' && calendarRef.current) {
|
|
71
|
+
calendarRef.current.focus();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
var handleBlur = function (event) {
|
|
76
|
+
if (view === 'desktop') {
|
|
77
|
+
var target = (event.relatedTarget || document.activeElement);
|
|
78
|
+
if (calendarRef.current && calendarRef.current.contains(target) === false) {
|
|
79
|
+
setOpen(false);
|
|
80
|
+
setTimeToDate();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
var handleChange = function (event) {
|
|
85
|
+
var newValue = event.target.value;
|
|
86
|
+
if (newValue.length > utils_format.DATE_WITH_TIME_LENGTH)
|
|
87
|
+
return;
|
|
88
|
+
// Позволяем вводить только цифры, точки, запятую, двоеточие и пробел
|
|
89
|
+
if (/[^\d., :]/.test(newValue)) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
var dots = newValue.match(/\./g);
|
|
93
|
+
var colon = newValue.match(/:/g);
|
|
94
|
+
var comma = newValue.match(/,/g);
|
|
95
|
+
// Не даем вводить больше, чем 2 точки, 1 двоеточие и 1 запятую
|
|
96
|
+
if ((dots && dots.length > 2) ||
|
|
97
|
+
(colon && colon.length > 1) ||
|
|
98
|
+
(comma && comma.length > 1)) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
var formattedValue = utils_format.format(newValue);
|
|
102
|
+
var date = utils_format.getFullDateTime(formattedValue);
|
|
103
|
+
setValue(formattedValue);
|
|
104
|
+
if (onChange)
|
|
105
|
+
onChange(event, { date: date, value: formattedValue });
|
|
106
|
+
if (utils_format.isCompleteDateInput(formattedValue)) {
|
|
107
|
+
var valid = utils_format.isValid(formattedValue);
|
|
108
|
+
if (!valid)
|
|
109
|
+
return;
|
|
110
|
+
if (onComplete) {
|
|
111
|
+
onComplete(event, { date: date, value: formattedValue });
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
var handleMobileCalendarClose = function () {
|
|
116
|
+
setOpen(false);
|
|
117
|
+
setTimeToDate();
|
|
118
|
+
};
|
|
119
|
+
var handleClear = function () {
|
|
120
|
+
setValue('');
|
|
121
|
+
};
|
|
122
|
+
var handleCalendarChange = function (date) {
|
|
123
|
+
if (date) {
|
|
124
|
+
var newValue = utils_format.parseTimestampToDate(date);
|
|
125
|
+
setValue(newValue);
|
|
126
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(null, { date: utils_format.getFullDateTime(newValue), value: newValue });
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
var handleCalendarWrapperMouseDown = function (event) {
|
|
130
|
+
// Не дает инпуту терять фокус при выборе даты
|
|
131
|
+
event.preventDefault();
|
|
132
|
+
};
|
|
133
|
+
var handleIconButtonClick = function () {
|
|
134
|
+
if (!open)
|
|
135
|
+
setOpen(true);
|
|
136
|
+
if (view === 'desktop' && inputRef.current) {
|
|
137
|
+
inputRef.current.focus();
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
var renderCalendar = function () { return (
|
|
141
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
142
|
+
React__default.default.createElement("div", { onMouseDown: handleCalendarWrapperMouseDown },
|
|
143
|
+
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 })))); };
|
|
144
|
+
return (React__default.default.createElement("div", { className: cn__default.default(styles.component, className, (_b = {},
|
|
145
|
+
_b[styles.block] = block,
|
|
146
|
+
_b)), onFocus: inputDisabled ? undefined : handleInputWrapperFocus, onBlur: handleBlur },
|
|
147
|
+
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,
|
|
148
|
+
rightAddons,
|
|
149
|
+
picker && (React__default.default.createElement(coreComponentsIconButton.IconButton, { onClick: inputDisabled ? undefined : handleIconButtonClick, icon: CalendarMIcon.CalendarMIcon, size: 'xxs' }))) })),
|
|
150
|
+
picker && (React__default.default.createElement(coreComponentsPopover.Popover, { open: open, useAnchorWidth: useAnchorWidth, anchorElement: inputRef.current, popperClassName: cn__default.default(styles.calendarContainer, (_c = {},
|
|
151
|
+
_c[styles.calendarResponsive] = calendarResponsive,
|
|
152
|
+
_c)), className: popoverClassName, position: popoverPosition, offset: [0, 8], withTransition: false, preventFlip: preventFlip, zIndex: zIndexPopover }, renderCalendar()))));
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
exports.DateTimeInput = DateTimeInput;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: vk0lw */
|
|
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-time-
|
|
43
|
+
} .date-time-input__component_aze2c {
|
|
44
44
|
display: inline-block;
|
|
45
45
|
outline: none;
|
|
46
46
|
position: relative;
|
|
47
|
-
} .date-time-
|
|
47
|
+
} .date-time-input__calendarContainer_aze2c {
|
|
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-time-
|
|
51
|
+
} @media (max-width: 374px) { .date-time-input__calendarContainer_aze2c {
|
|
52
52
|
width: 100%;
|
|
53
53
|
min-width: 288px
|
|
54
54
|
}
|
|
55
|
-
} .date-time-
|
|
55
|
+
} .date-time-input__calendarResponsive_aze2c {
|
|
56
56
|
width: var(--calendar-width);
|
|
57
57
|
padding: 0 var(--gap-m);
|
|
58
|
-
} .date-time-
|
|
58
|
+
} .date-time-input__block_aze2c {
|
|
59
59
|
width: 100%;
|
|
60
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "
|
|
1
|
+
export * from "./Component";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { DateTimeInputProps } from "./components/date-time-input/Component";
|
|
3
4
|
type DateTimeInputDesktopProps = Omit<DateTimeInputProps, 'view'>;
|
|
4
|
-
declare const DateTimeInputDesktop:
|
|
5
|
+
declare const DateTimeInputDesktop: React.ForwardRefExoticComponent<DateTimeInputDesktopProps & React.RefAttributes<HTMLInputElement>>;
|
|
5
6
|
export { DateTimeInputDesktopProps, DateTimeInputDesktop };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var tslib = require('tslib');
|
|
4
4
|
var React = require('react');
|
|
5
|
+
var components_dateTimeInput_Component = require('./components/date-time-input/Component.js');
|
|
5
6
|
require('react-merge-refs');
|
|
6
7
|
require('classnames');
|
|
7
8
|
require('@alfalab/core-components-calendar/cssm');
|
|
@@ -19,6 +20,6 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
19
20
|
|
|
20
21
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
21
22
|
|
|
22
|
-
var DateTimeInputDesktop = function (props) { return
|
|
23
|
+
var DateTimeInputDesktop = React.forwardRef(function (props, ref) { return React__default.default.createElement(components_dateTimeInput_Component.DateTimeInput, tslib.__assign({}, props, { ref: ref })); });
|
|
23
24
|
|
|
24
25
|
exports.DateTimeInputDesktop = DateTimeInputDesktop;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
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:
|
|
5
|
+
declare const DateTimeInputMobile: React.ForwardRefExoticComponent<DateTimeInputMobileProps & React.RefAttributes<HTMLInputElement>>;
|
|
5
6
|
export { DateTimeInputMobileProps, DateTimeInputMobile };
|
package/cssm/Component.mobile.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var tslib = require('tslib');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var coreComponentsCalendar = require('@alfalab/core-components-calendar/cssm');
|
|
6
|
+
var components_dateTimeInput_Component = require('./components/date-time-input/Component.js');
|
|
6
7
|
require('react-merge-refs');
|
|
7
8
|
require('classnames');
|
|
8
9
|
require('@alfalab/core-components-icon-button/cssm');
|
|
@@ -19,6 +20,6 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
19
20
|
|
|
20
21
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
21
22
|
|
|
22
|
-
var DateTimeInputMobile = function (props) { return
|
|
23
|
+
var DateTimeInputMobile = React.forwardRef(function (props, ref) { return React__default.default.createElement(components_dateTimeInput_Component.DateTimeInput, tslib.__assign({ Calendar: coreComponentsCalendar.CalendarMobile, view: 'mobile' }, props, { ref: ref })); });
|
|
23
24
|
|
|
24
25
|
exports.DateTimeInputMobile = DateTimeInputMobile;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
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:
|
|
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,10 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var tslib = require('tslib');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var hooks = require('@alfalab/hooks');
|
|
6
6
|
var Component_desktop = require('./Component.desktop.js');
|
|
7
7
|
var Component_mobile = require('./Component.mobile.js');
|
|
8
|
+
require('./components/date-time-input/Component.js');
|
|
8
9
|
require('react-merge-refs');
|
|
9
10
|
require('classnames');
|
|
10
11
|
require('@alfalab/core-components-calendar/cssm');
|
|
@@ -21,13 +22,13 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
21
22
|
|
|
22
23
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
23
24
|
|
|
24
|
-
var DateTimeInputResponsive = function (_a) {
|
|
25
|
-
var _b = _a.breakpoint, breakpoint = _b === void 0 ? 1024 : _b, restProps =
|
|
25
|
+
var DateTimeInputResponsive = React.forwardRef(function (_a, ref) {
|
|
26
|
+
var _b = _a.breakpoint, breakpoint = _b === void 0 ? 1024 : _b, restProps = tslib.__rest(_a, ["breakpoint"]);
|
|
26
27
|
var view = hooks.useMedia([
|
|
27
28
|
['mobile', "(max-width: ".concat(breakpoint - 1, "px)")],
|
|
28
29
|
['desktop', "(min-width: ".concat(breakpoint, "px)")],
|
|
29
30
|
], 'desktop')[0];
|
|
30
|
-
return view === 'desktop' ? (React__default.default.createElement(Component_desktop.DateTimeInputDesktop,
|
|
31
|
-
};
|
|
31
|
+
return view === 'desktop' ? (React__default.default.createElement(Component_desktop.DateTimeInputDesktop, tslib.__assign({}, restProps, { ref: ref }))) : (React__default.default.createElement(Component_mobile.DateTimeInputMobile, tslib.__assign({}, restProps, { ref: ref })));
|
|
32
|
+
});
|
|
32
33
|
|
|
33
34
|
exports.DateTimeInputResponsive = DateTimeInputResponsive;
|