@alfalab/core-components-date-time-input 2.2.0 → 3.0.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-27749cf7.d.ts → Component-1ff76732.d.ts} +4 -7
- package/{Component-27749cf7.js → Component-1ff76732.js} +36 -15
- package/Component.desktop.d.ts +1 -1
- package/Component.desktop.js +2 -1
- package/Component.mobile.d.ts +1 -1
- package/Component.mobile.js +2 -1
- package/Component.responsive.d.ts +1 -1
- package/Component.responsive.js +1 -1
- package/components/date-time-input/Component.js +2 -1
- package/components/date-time-input/index.css +8 -8
- package/components/date-time-input/index.d.ts +1 -1
- package/components/date-time-input/index.js +2 -1
- package/{esm/Component-e82a534f.d.ts → cssm/Component-b91f18e8.d.ts} +4 -7
- package/cssm/{Component-d6110aa7.js → Component-b91f18e8.js} +35 -14
- package/cssm/Component.desktop.d.ts +1 -1
- package/cssm/Component.desktop.js +2 -1
- package/cssm/Component.mobile.d.ts +1 -1
- package/cssm/Component.mobile.js +2 -1
- package/cssm/Component.responsive.d.ts +1 -1
- package/cssm/Component.responsive.js +1 -1
- package/cssm/components/date-time-input/Component.js +2 -1
- package/cssm/components/date-time-input/index.d.ts +1 -1
- package/cssm/components/date-time-input/index.js +2 -1
- package/cssm/components/date-time-input/index.module.css +2 -2
- package/cssm/desktop.js +2 -1
- package/cssm/index.d.ts +2 -1
- package/cssm/index.js +2 -2
- package/cssm/mobile.js +2 -1
- package/cssm/responsive.js +2 -2
- package/cssm/utils/format.d.ts +3 -2
- package/cssm/utils/format.js +7 -3
- package/cssm/utils/index.js +2 -1
- package/desktop.js +2 -1
- package/{cssm/Component-d6110aa7.d.ts → esm/Component-074b6874.d.ts} +4 -7
- package/esm/{Component-e82a534f.js → Component-074b6874.js} +37 -16
- package/esm/Component.desktop.d.ts +1 -1
- package/esm/Component.desktop.js +2 -1
- package/esm/Component.mobile.d.ts +1 -1
- package/esm/Component.mobile.js +2 -1
- package/esm/Component.responsive.d.ts +1 -1
- package/esm/Component.responsive.js +1 -1
- package/esm/components/date-time-input/Component.js +2 -1
- package/esm/components/date-time-input/index.css +8 -8
- 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.d.ts +2 -1
- package/esm/index.js +2 -2
- package/esm/mobile.js +2 -1
- package/esm/responsive.js +2 -2
- package/esm/utils/format.d.ts +3 -2
- package/esm/utils/format.js +6 -3
- package/esm/utils/index.js +1 -1
- package/index.d.ts +2 -1
- package/index.js +2 -2
- package/mobile.js +2 -1
- package/modern/Component.desktop.js +1 -0
- package/modern/Component.mobile.js +1 -0
- package/modern/components/date-time-input/Component.d.ts +4 -7
- package/modern/components/date-time-input/Component.js +37 -16
- package/modern/components/date-time-input/index.css +8 -8
- package/modern/components/date-time-input/index.js +1 -0
- package/modern/desktop.js +1 -0
- package/modern/index.d.ts +2 -1
- package/modern/mobile.js +1 -0
- package/modern/utils/format.d.ts +3 -2
- package/modern/utils/format.js +6 -3
- package/modern/utils/index.js +1 -1
- package/package.json +4 -3
- package/responsive.js +2 -2
- package/utils/format.d.ts +3 -2
- package/utils/format.js +7 -3
- package/utils/index.js +2 -1
package/cssm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var Component_responsive = require('./Component.responsive.js');
|
|
4
|
-
require('./Component-
|
|
4
|
+
require('./Component-b91f18e8.js');
|
|
5
5
|
require('react');
|
|
6
6
|
require('react-merge-refs');
|
|
7
7
|
require('classnames');
|
|
@@ -9,12 +9,12 @@ require('@alfalab/core-components-calendar/cssm');
|
|
|
9
9
|
require('@alfalab/core-components-icon-button/cssm');
|
|
10
10
|
require('@alfalab/core-components-input/cssm');
|
|
11
11
|
require('@alfalab/core-components-popover/cssm');
|
|
12
|
+
require('@alfalab/hooks');
|
|
12
13
|
require('@alfalab/icons-glyph/CalendarMIcon');
|
|
13
14
|
require('./utils/format.js');
|
|
14
15
|
require('date-fns/isValid');
|
|
15
16
|
require('date-fns/parse');
|
|
16
17
|
require('./components/date-time-input/index.module.css');
|
|
17
|
-
require('@alfalab/hooks');
|
|
18
18
|
require('./Component.desktop.js');
|
|
19
19
|
require('./Component.mobile.js');
|
|
20
20
|
|
package/cssm/mobile.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var Component_mobile = require('./Component.mobile.js');
|
|
4
|
-
require('./Component-
|
|
4
|
+
require('./Component-b91f18e8.js');
|
|
5
5
|
require('react');
|
|
6
6
|
require('react-merge-refs');
|
|
7
7
|
require('classnames');
|
|
@@ -9,6 +9,7 @@ require('@alfalab/core-components-calendar/cssm');
|
|
|
9
9
|
require('@alfalab/core-components-icon-button/cssm');
|
|
10
10
|
require('@alfalab/core-components-input/cssm');
|
|
11
11
|
require('@alfalab/core-components-popover/cssm');
|
|
12
|
+
require('@alfalab/hooks');
|
|
12
13
|
require('@alfalab/icons-glyph/CalendarMIcon');
|
|
13
14
|
require('./utils/format.js');
|
|
14
15
|
require('date-fns/isValid');
|
package/cssm/responsive.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var Component_responsive = require('./Component.responsive.js');
|
|
4
|
-
require('./Component-
|
|
4
|
+
require('./Component-b91f18e8.js');
|
|
5
5
|
require('react');
|
|
6
6
|
require('react-merge-refs');
|
|
7
7
|
require('classnames');
|
|
@@ -9,12 +9,12 @@ require('@alfalab/core-components-calendar/cssm');
|
|
|
9
9
|
require('@alfalab/core-components-icon-button/cssm');
|
|
10
10
|
require('@alfalab/core-components-input/cssm');
|
|
11
11
|
require('@alfalab/core-components-popover/cssm');
|
|
12
|
+
require('@alfalab/hooks');
|
|
12
13
|
require('@alfalab/icons-glyph/CalendarMIcon');
|
|
13
14
|
require('./utils/format.js');
|
|
14
15
|
require('date-fns/isValid');
|
|
15
16
|
require('date-fns/parse');
|
|
16
17
|
require('./components/date-time-input/index.module.css');
|
|
17
|
-
require('@alfalab/hooks');
|
|
18
18
|
require('./Component.desktop.js');
|
|
19
19
|
require('./Component.mobile.js');
|
|
20
20
|
|
package/cssm/utils/format.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
declare const DATE_FORMAT = "dd.MM.yyyy";
|
|
2
2
|
declare const DATE_MASK: (string | RegExp)[];
|
|
3
|
+
declare const DATE_WITH_TIME_LENGTH: number;
|
|
3
4
|
declare const isCompleteDateInput: (input: string) => boolean;
|
|
4
5
|
declare const parseDateString: (value: string, dateFormat?: string) => Date;
|
|
5
6
|
declare const isValidTimeFormat: (value: string) => boolean;
|
|
@@ -8,5 +9,5 @@ declare const format: (value: string) => string;
|
|
|
8
9
|
declare const parseTimestampToDate: (timestamp: number) => string;
|
|
9
10
|
declare const getDateWithoutTime: (value: string) => Date;
|
|
10
11
|
declare const getFullDateTime: (value: string) => Date;
|
|
11
|
-
declare const
|
|
12
|
-
export { DATE_FORMAT, DATE_MASK, isCompleteDateInput, parseDateString, isValidTimeFormat, isValid, format, parseTimestampToDate, getDateWithoutTime, getFullDateTime,
|
|
12
|
+
declare const addTimeToDate: (value: string) => string;
|
|
13
|
+
export { DATE_FORMAT, DATE_MASK, DATE_WITH_TIME_LENGTH, isCompleteDateInput, parseDateString, isValidTimeFormat, isValid, format, parseTimestampToDate, getDateWithoutTime, getFullDateTime, addTimeToDate };
|
package/cssm/utils/format.js
CHANGED
|
@@ -29,7 +29,8 @@ var DATE_MASK = [
|
|
|
29
29
|
/\d/,
|
|
30
30
|
/\d/,
|
|
31
31
|
];
|
|
32
|
-
var
|
|
32
|
+
var DATE_WITH_TIME_LENGTH = DATE_MASK.length;
|
|
33
|
+
var isCompleteDateInput = function (input) { return input.length === DATE_WITH_TIME_LENGTH; };
|
|
33
34
|
var parseDateString = function (value, dateFormat) {
|
|
34
35
|
if (dateFormat === void 0) { dateFormat = DATE_FORMAT; }
|
|
35
36
|
return parse__default.default(value, dateFormat, new Date());
|
|
@@ -123,9 +124,11 @@ var getFullDateTime = function (value) {
|
|
|
123
124
|
fullDate.setFullYear(Number(year), Number(month) - 1, Number(day));
|
|
124
125
|
fullDate.setHours(Number(hours) || 0);
|
|
125
126
|
fullDate.setMinutes(Number(mins) || 0);
|
|
127
|
+
fullDate.setSeconds(0);
|
|
128
|
+
fullDate.setMilliseconds(0);
|
|
126
129
|
return fullDate;
|
|
127
130
|
};
|
|
128
|
-
var
|
|
131
|
+
var addTimeToDate = function (value) {
|
|
129
132
|
if (value.length === 10 && dateFnsIsValid__default.default(parseDateString(value))) {
|
|
130
133
|
return "".concat(value, ", 00:00");
|
|
131
134
|
}
|
|
@@ -134,6 +137,8 @@ var setTimeToDate = function (value) {
|
|
|
134
137
|
|
|
135
138
|
exports.DATE_FORMAT = DATE_FORMAT;
|
|
136
139
|
exports.DATE_MASK = DATE_MASK;
|
|
140
|
+
exports.DATE_WITH_TIME_LENGTH = DATE_WITH_TIME_LENGTH;
|
|
141
|
+
exports.addTimeToDate = addTimeToDate;
|
|
137
142
|
exports.format = format;
|
|
138
143
|
exports.getDateWithoutTime = getDateWithoutTime;
|
|
139
144
|
exports.getFullDateTime = getFullDateTime;
|
|
@@ -142,4 +147,3 @@ exports.isValid = isValid;
|
|
|
142
147
|
exports.isValidTimeFormat = isValidTimeFormat;
|
|
143
148
|
exports.parseDateString = parseDateString;
|
|
144
149
|
exports.parseTimestampToDate = parseTimestampToDate;
|
|
145
|
-
exports.setTimeToDate = setTimeToDate;
|
package/cssm/utils/index.js
CHANGED
|
@@ -8,6 +8,8 @@ require('date-fns/parse');
|
|
|
8
8
|
|
|
9
9
|
exports.DATE_FORMAT = utils_format.DATE_FORMAT;
|
|
10
10
|
exports.DATE_MASK = utils_format.DATE_MASK;
|
|
11
|
+
exports.DATE_WITH_TIME_LENGTH = utils_format.DATE_WITH_TIME_LENGTH;
|
|
12
|
+
exports.addTimeToDate = utils_format.addTimeToDate;
|
|
11
13
|
exports.format = utils_format.format;
|
|
12
14
|
exports.getDateWithoutTime = utils_format.getDateWithoutTime;
|
|
13
15
|
exports.getFullDateTime = utils_format.getFullDateTime;
|
|
@@ -16,4 +18,3 @@ exports.isValid = utils_format.isValid;
|
|
|
16
18
|
exports.isValidTimeFormat = utils_format.isValidTimeFormat;
|
|
17
19
|
exports.parseDateString = utils_format.parseDateString;
|
|
18
20
|
exports.parseTimestampToDate = utils_format.parseTimestampToDate;
|
|
19
|
-
exports.setTimeToDate = utils_format.setTimeToDate;
|
package/desktop.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var Component_desktop = require('./Component.desktop.js');
|
|
4
|
-
require('./Component-
|
|
4
|
+
require('./Component-1ff76732.js');
|
|
5
5
|
require('react');
|
|
6
6
|
require('react-merge-refs');
|
|
7
7
|
require('classnames');
|
|
@@ -9,6 +9,7 @@ require('@alfalab/core-components-calendar');
|
|
|
9
9
|
require('@alfalab/core-components-icon-button');
|
|
10
10
|
require('@alfalab/core-components-input');
|
|
11
11
|
require('@alfalab/core-components-popover');
|
|
12
|
+
require('@alfalab/hooks');
|
|
12
13
|
require('@alfalab/icons-glyph/CalendarMIcon');
|
|
13
14
|
require('./utils/format.js');
|
|
14
15
|
require('date-fns/isValid');
|
|
@@ -57,14 +57,14 @@ type DateTimeInputProps = Omit<InputProps, 'onChange'> & {
|
|
|
57
57
|
/**
|
|
58
58
|
* Обработчик изменения значения
|
|
59
59
|
*/
|
|
60
|
-
onChange?: (event: ChangeEvent<HTMLInputElement
|
|
60
|
+
onChange?: (event: ChangeEvent<HTMLInputElement> | null, payload: {
|
|
61
61
|
date: Date;
|
|
62
62
|
value: string;
|
|
63
63
|
}) => void;
|
|
64
64
|
/**
|
|
65
65
|
* Обработчик окончания ввода
|
|
66
66
|
*/
|
|
67
|
-
onComplete?: (event: ChangeEvent<HTMLInputElement
|
|
67
|
+
onComplete?: (event: ChangeEvent<HTMLInputElement> | null, payload: {
|
|
68
68
|
date: Date;
|
|
69
69
|
value: string;
|
|
70
70
|
}) => void;
|
|
@@ -146,14 +146,14 @@ declare const DateTimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "o
|
|
|
146
146
|
/**
|
|
147
147
|
* Обработчик изменения значения
|
|
148
148
|
*/
|
|
149
|
-
onChange?: ((event: ChangeEvent<HTMLInputElement
|
|
149
|
+
onChange?: ((event: ChangeEvent<HTMLInputElement> | null, payload: {
|
|
150
150
|
date: Date;
|
|
151
151
|
value: string;
|
|
152
152
|
}) => void) | undefined;
|
|
153
153
|
/**
|
|
154
154
|
* Обработчик окончания ввода
|
|
155
155
|
*/
|
|
156
|
-
onComplete?: ((event: ChangeEvent<HTMLInputElement
|
|
156
|
+
onComplete?: ((event: ChangeEvent<HTMLInputElement> | null, payload: {
|
|
157
157
|
date: Date;
|
|
158
158
|
value: string;
|
|
159
159
|
}) => void) | undefined;
|
|
@@ -166,9 +166,6 @@ declare const DateTimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "o
|
|
|
166
166
|
*/
|
|
167
167
|
calendarProps?: (CalendarProps & Record<string, unknown>) | (CalendarProps & {
|
|
168
168
|
open: boolean;
|
|
169
|
-
/**
|
|
170
|
-
* Дополнительный класс для поповера
|
|
171
|
-
*/
|
|
172
169
|
title?: string | undefined;
|
|
173
170
|
onClose?: (() => void) | undefined;
|
|
174
171
|
yearsAmount?: number | undefined;
|
|
@@ -5,8 +5,9 @@ import { Calendar, dateInLimits } from '@alfalab/core-components-calendar/esm';
|
|
|
5
5
|
import { IconButton } from '@alfalab/core-components-icon-button/esm';
|
|
6
6
|
import { Input } from '@alfalab/core-components-input/esm';
|
|
7
7
|
import { Popover } from '@alfalab/core-components-popover/esm';
|
|
8
|
+
import { useDidUpdateEffect } from '@alfalab/hooks';
|
|
8
9
|
import { CalendarMIcon } from '@alfalab/icons-glyph/CalendarMIcon';
|
|
9
|
-
import { getDateWithoutTime,
|
|
10
|
+
import { getDateWithoutTime, DATE_WITH_TIME_LENGTH, format, getFullDateTime, isCompleteDateInput, isValid, addTimeToDate, parseTimestampToDate } from './utils/format.js';
|
|
10
11
|
|
|
11
12
|
/******************************************************************************
|
|
12
13
|
Copyright (c) Microsoft Corporation.
|
|
@@ -47,7 +48,7 @@ function __rest(s, e) {
|
|
|
47
48
|
return t;
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
var styles = {"component":"date-time-
|
|
51
|
+
var styles = {"component":"date-time-input__component_wum5f","calendarContainer":"date-time-input__calendarContainer_wum5f","calendarResponsive":"date-time-input__calendarResponsive_wum5f","block":"date-time-input__block_wum5f"};
|
|
51
52
|
require('./components/date-time-input/index.css')
|
|
52
53
|
|
|
53
54
|
/* eslint-disable no-useless-escape, jsx-a11y/click-events-have-key-events */
|
|
@@ -65,6 +66,10 @@ var DateTimeInput = React.forwardRef(function (_a, ref) {
|
|
|
65
66
|
useEffect(function () {
|
|
66
67
|
setOpen(defaultOpen);
|
|
67
68
|
}, [defaultOpen]);
|
|
69
|
+
useDidUpdateEffect(function () {
|
|
70
|
+
var newPropValue = propValue || '';
|
|
71
|
+
setValue(function (prevValue) { return (prevValue === propValue ? prevValue : newPropValue); });
|
|
72
|
+
}, [propValue]);
|
|
68
73
|
var checkInputValueIsValid = function (newInputValue) {
|
|
69
74
|
if (!newInputValue || error)
|
|
70
75
|
return false;
|
|
@@ -73,8 +78,23 @@ var DateTimeInput = React.forwardRef(function (_a, ref) {
|
|
|
73
78
|
dateInLimits(dateValue, minDate, maxDate) &&
|
|
74
79
|
!offDays.includes(dateValue));
|
|
75
80
|
};
|
|
81
|
+
var setTimeToDate = function () {
|
|
82
|
+
setValue(function (prevValue) {
|
|
83
|
+
var dateWithTime = addTimeToDate(prevValue);
|
|
84
|
+
if (dateWithTime !== prevValue && dateWithTime.length === DATE_WITH_TIME_LENGTH) {
|
|
85
|
+
onComplete === null || onComplete === void 0 ? void 0 : onComplete(null, {
|
|
86
|
+
date: getFullDateTime(dateWithTime),
|
|
87
|
+
value: dateWithTime,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return dateWithTime;
|
|
91
|
+
});
|
|
92
|
+
};
|
|
76
93
|
var handleInputWrapperFocus = function (event) {
|
|
77
94
|
if (view === 'desktop') {
|
|
95
|
+
if (picker) {
|
|
96
|
+
setOpen(true);
|
|
97
|
+
}
|
|
78
98
|
if (!open && event.target.tagName !== 'INPUT' && calendarRef.current) {
|
|
79
99
|
calendarRef.current.focus();
|
|
80
100
|
}
|
|
@@ -85,21 +105,21 @@ var DateTimeInput = React.forwardRef(function (_a, ref) {
|
|
|
85
105
|
var target = (event.relatedTarget || document.activeElement);
|
|
86
106
|
if (calendarRef.current && calendarRef.current.contains(target) === false) {
|
|
87
107
|
setOpen(false);
|
|
88
|
-
|
|
108
|
+
setTimeToDate();
|
|
89
109
|
}
|
|
90
110
|
}
|
|
91
111
|
};
|
|
92
112
|
var handleChange = function (event) {
|
|
93
113
|
var newValue = event.target.value;
|
|
94
|
-
if (newValue.length >
|
|
114
|
+
if (newValue.length > DATE_WITH_TIME_LENGTH)
|
|
95
115
|
return;
|
|
96
116
|
// Позволяем вводить только цифры, точки, запятую, двоеточие и пробел
|
|
97
|
-
if (/[^\d.,
|
|
117
|
+
if (/[^\d., :]/.test(newValue)) {
|
|
98
118
|
return;
|
|
99
119
|
}
|
|
100
120
|
var dots = newValue.match(/\./g);
|
|
101
|
-
var colon = newValue.match(
|
|
102
|
-
var comma = newValue.match(
|
|
121
|
+
var colon = newValue.match(/:/g);
|
|
122
|
+
var comma = newValue.match(/,/g);
|
|
103
123
|
// Не даем вводить больше, чем 2 точки, 1 двоеточие и 1 запятую
|
|
104
124
|
if ((dots && dots.length > 2) ||
|
|
105
125
|
(colon && colon.length > 1) ||
|
|
@@ -120,37 +140,38 @@ var DateTimeInput = React.forwardRef(function (_a, ref) {
|
|
|
120
140
|
}
|
|
121
141
|
}
|
|
122
142
|
};
|
|
123
|
-
var
|
|
143
|
+
var handleMobileCalendarClose = function () {
|
|
124
144
|
setOpen(false);
|
|
145
|
+
setTimeToDate();
|
|
125
146
|
};
|
|
126
147
|
var handleClear = function () {
|
|
127
148
|
setValue('');
|
|
128
149
|
};
|
|
129
150
|
var handleCalendarChange = function (date) {
|
|
130
151
|
if (date) {
|
|
131
|
-
|
|
152
|
+
var newValue = parseTimestampToDate(date);
|
|
153
|
+
setValue(newValue);
|
|
154
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(null, { date: getFullDateTime(newValue), value: newValue });
|
|
132
155
|
}
|
|
133
156
|
};
|
|
134
157
|
var handleCalendarWrapperMouseDown = function (event) {
|
|
135
158
|
// Не дает инпуту терять фокус при выборе даты
|
|
136
159
|
event.preventDefault();
|
|
137
160
|
};
|
|
138
|
-
var handleInputWrapperClick = function () {
|
|
139
|
-
if (view === 'desktop' && !open) {
|
|
140
|
-
setOpen(true);
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
161
|
var handleIconButtonClick = function () {
|
|
144
162
|
if (!open)
|
|
145
163
|
setOpen(true);
|
|
164
|
+
if (view === 'desktop' && inputRef.current) {
|
|
165
|
+
inputRef.current.focus();
|
|
166
|
+
}
|
|
146
167
|
};
|
|
147
168
|
var renderCalendar = function () { return (
|
|
148
169
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
149
170
|
React.createElement("div", { onMouseDown: handleCalendarWrapperMouseDown },
|
|
150
|
-
React.createElement(Calendar$1, __assign({}, calendarProps, { responsive: calendarResponsive, open: open, onClose:
|
|
171
|
+
React.createElement(Calendar$1, __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 })))); };
|
|
151
172
|
return (React.createElement("div", { className: cn(styles.component, className, (_b = {},
|
|
152
173
|
_b[styles.block] = block,
|
|
153
|
-
_b)),
|
|
174
|
+
_b)), onFocus: inputDisabled ? undefined : handleInputWrapperFocus, onBlur: handleBlur },
|
|
154
175
|
React.createElement(Input, __assign({}, restProps, { block: block, ref: mergeRefs([ref, inputRef]), value: value, onChange: handleChange, disabled: disabled, readOnly: readOnly, className: inputClassName, onClear: handleClear, error: error, rightAddons: React.createElement(React.Fragment, null,
|
|
155
176
|
rightAddons,
|
|
156
177
|
picker && (React.createElement(IconButton, { onClick: inputDisabled ? undefined : handleIconButtonClick, icon: CalendarMIcon, size: 'xxs' }))) })),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import { DateTimeInputProps } from "./Component-
|
|
2
|
+
import { DateTimeInputProps } from "./Component-074b6874";
|
|
3
3
|
type DateTimeInputDesktopProps = Omit<DateTimeInputProps, 'view'>;
|
|
4
4
|
declare const DateTimeInputDesktop: FC<DateTimeInputDesktopProps>;
|
|
5
5
|
export { DateTimeInputDesktopProps, DateTimeInputDesktop };
|
package/esm/Component.desktop.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DateTimeInput, _ as __assign } from './Component-
|
|
1
|
+
import { D as DateTimeInput, _ as __assign } from './Component-074b6874.js';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import 'react-merge-refs';
|
|
4
4
|
import 'classnames';
|
|
@@ -6,6 +6,7 @@ import '@alfalab/core-components-calendar/esm';
|
|
|
6
6
|
import '@alfalab/core-components-icon-button/esm';
|
|
7
7
|
import '@alfalab/core-components-input/esm';
|
|
8
8
|
import '@alfalab/core-components-popover/esm';
|
|
9
|
+
import '@alfalab/hooks';
|
|
9
10
|
import '@alfalab/icons-glyph/CalendarMIcon';
|
|
10
11
|
import './utils/format.js';
|
|
11
12
|
import 'date-fns/isValid';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import { DateTimeInputProps } from "./Component-
|
|
2
|
+
import { DateTimeInputProps } from "./Component-074b6874";
|
|
3
3
|
type DateTimeInputMobileProps = Omit<DateTimeInputProps, 'view'>;
|
|
4
4
|
declare const DateTimeInputMobile: FC<DateTimeInputMobileProps>;
|
|
5
5
|
export { DateTimeInputMobileProps, DateTimeInputMobile };
|
package/esm/Component.mobile.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DateTimeInput, _ as __assign } from './Component-
|
|
1
|
+
import { D as DateTimeInput, _ as __assign } from './Component-074b6874.js';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { CalendarMobile } from '@alfalab/core-components-calendar/esm';
|
|
4
4
|
import 'react-merge-refs';
|
|
@@ -6,6 +6,7 @@ import 'classnames';
|
|
|
6
6
|
import '@alfalab/core-components-icon-button/esm';
|
|
7
7
|
import '@alfalab/core-components-input/esm';
|
|
8
8
|
import '@alfalab/core-components-popover/esm';
|
|
9
|
+
import '@alfalab/hooks';
|
|
9
10
|
import '@alfalab/icons-glyph/CalendarMIcon';
|
|
10
11
|
import './utils/format.js';
|
|
11
12
|
import 'date-fns/isValid';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import { DateTimeInputProps } from "./Component-
|
|
2
|
+
import { DateTimeInputProps } from "./Component-074b6874";
|
|
3
3
|
type DateTimeInputResponsiveProps = Omit<DateTimeInputProps, 'view'> & {
|
|
4
4
|
/**
|
|
5
5
|
* Контрольная точка, с нее начинается desktop версия
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as __rest, _ as __assign } from './Component-
|
|
1
|
+
import { a as __rest, _ as __assign } from './Component-074b6874.js';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { useMedia } from '@alfalab/hooks';
|
|
4
4
|
import { DateTimeInputDesktop } from './Component.desktop.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { D as DateTimeInput } from '../../Component-
|
|
1
|
+
export { D as DateTimeInput } from '../../Component-074b6874.js';
|
|
2
2
|
import 'react';
|
|
3
3
|
import 'react-merge-refs';
|
|
4
4
|
import 'classnames';
|
|
@@ -6,6 +6,7 @@ import '@alfalab/core-components-calendar/esm';
|
|
|
6
6
|
import '@alfalab/core-components-icon-button/esm';
|
|
7
7
|
import '@alfalab/core-components-input/esm';
|
|
8
8
|
import '@alfalab/core-components-popover/esm';
|
|
9
|
+
import '@alfalab/hooks';
|
|
9
10
|
import '@alfalab/icons-glyph/CalendarMIcon';
|
|
10
11
|
import '../../utils/format.js';
|
|
11
12
|
import 'date-fns/isValid';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 9vegz */
|
|
2
2
|
:root {
|
|
3
3
|
|
|
4
4
|
/* Hard */
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
--gap-m: 16px;
|
|
12
12
|
}
|
|
13
13
|
:root {
|
|
14
|
-
--border-radius-
|
|
14
|
+
--border-radius-m: 8px;
|
|
15
15
|
}
|
|
16
16
|
:root {
|
|
17
17
|
--calendar-width: 344px;
|
|
@@ -37,28 +37,28 @@
|
|
|
37
37
|
/* marker */
|
|
38
38
|
}
|
|
39
39
|
:root {
|
|
40
|
-
--calendar-popover-border-radius:
|
|
40
|
+
--calendar-popover-border-radius: var(--border-radius-m);
|
|
41
41
|
}
|
|
42
|
-
.date-time-
|
|
42
|
+
.date-time-input__component_wum5f {
|
|
43
43
|
display: inline-block;
|
|
44
44
|
outline: none;
|
|
45
45
|
position: relative;
|
|
46
46
|
}
|
|
47
|
-
.date-time-
|
|
47
|
+
.date-time-input__calendarContainer_wum5f {
|
|
48
48
|
display: inline-block;
|
|
49
49
|
box-sizing: border-box;
|
|
50
50
|
border-radius: var(--calendar-popover-border-radius)
|
|
51
51
|
}
|
|
52
52
|
@media (max-width: 374px) {
|
|
53
|
-
.date-time-
|
|
53
|
+
.date-time-input__calendarContainer_wum5f {
|
|
54
54
|
width: 100%;
|
|
55
55
|
min-width: 288px
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
.date-time-
|
|
58
|
+
.date-time-input__calendarResponsive_wum5f {
|
|
59
59
|
width: var(--calendar-width);
|
|
60
60
|
padding: 0 var(--gap-m);
|
|
61
61
|
}
|
|
62
|
-
.date-time-
|
|
62
|
+
.date-time-input__block_wum5f {
|
|
63
63
|
width: 100%;
|
|
64
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "../../Component-
|
|
1
|
+
export * from "../../Component-074b6874";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { D as DateTimeInput } from '../../Component-
|
|
1
|
+
export { D as DateTimeInput } from '../../Component-074b6874.js';
|
|
2
2
|
import 'react';
|
|
3
3
|
import 'react-merge-refs';
|
|
4
4
|
import 'classnames';
|
|
@@ -6,6 +6,7 @@ import '@alfalab/core-components-calendar/esm';
|
|
|
6
6
|
import '@alfalab/core-components-icon-button/esm';
|
|
7
7
|
import '@alfalab/core-components-input/esm';
|
|
8
8
|
import '@alfalab/core-components-popover/esm';
|
|
9
|
+
import '@alfalab/hooks';
|
|
9
10
|
import '@alfalab/icons-glyph/CalendarMIcon';
|
|
10
11
|
import '../../utils/format.js';
|
|
11
12
|
import 'date-fns/isValid';
|
package/esm/desktop.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { DateTimeInputDesktop } from './Component.desktop.js';
|
|
2
|
-
import './Component-
|
|
2
|
+
import './Component-074b6874.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import 'react-merge-refs';
|
|
5
5
|
import 'classnames';
|
|
@@ -7,6 +7,7 @@ import '@alfalab/core-components-calendar/esm';
|
|
|
7
7
|
import '@alfalab/core-components-icon-button/esm';
|
|
8
8
|
import '@alfalab/core-components-input/esm';
|
|
9
9
|
import '@alfalab/core-components-popover/esm';
|
|
10
|
+
import '@alfalab/hooks';
|
|
10
11
|
import '@alfalab/icons-glyph/CalendarMIcon';
|
|
11
12
|
import './utils/format.js';
|
|
12
13
|
import 'date-fns/isValid';
|
package/esm/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { DateTimeInputResponsive as DateTimeInput
|
|
1
|
+
export { DateTimeInputResponsive as DateTimeInput } from "./responsive";
|
|
2
|
+
export type { DateTimeInputResponsiveProps as DateTimeInputProps } from "./responsive";
|
package/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { DateTimeInputResponsive as DateTimeInput } from './Component.responsive.js';
|
|
2
|
-
import './Component-
|
|
2
|
+
import './Component-074b6874.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import 'react-merge-refs';
|
|
5
5
|
import 'classnames';
|
|
@@ -7,10 +7,10 @@ import '@alfalab/core-components-calendar/esm';
|
|
|
7
7
|
import '@alfalab/core-components-icon-button/esm';
|
|
8
8
|
import '@alfalab/core-components-input/esm';
|
|
9
9
|
import '@alfalab/core-components-popover/esm';
|
|
10
|
+
import '@alfalab/hooks';
|
|
10
11
|
import '@alfalab/icons-glyph/CalendarMIcon';
|
|
11
12
|
import './utils/format.js';
|
|
12
13
|
import 'date-fns/isValid';
|
|
13
14
|
import 'date-fns/parse';
|
|
14
|
-
import '@alfalab/hooks';
|
|
15
15
|
import './Component.desktop.js';
|
|
16
16
|
import './Component.mobile.js';
|
package/esm/mobile.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { DateTimeInputMobile } from './Component.mobile.js';
|
|
2
|
-
import './Component-
|
|
2
|
+
import './Component-074b6874.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import 'react-merge-refs';
|
|
5
5
|
import 'classnames';
|
|
@@ -7,6 +7,7 @@ import '@alfalab/core-components-calendar/esm';
|
|
|
7
7
|
import '@alfalab/core-components-icon-button/esm';
|
|
8
8
|
import '@alfalab/core-components-input/esm';
|
|
9
9
|
import '@alfalab/core-components-popover/esm';
|
|
10
|
+
import '@alfalab/hooks';
|
|
10
11
|
import '@alfalab/icons-glyph/CalendarMIcon';
|
|
11
12
|
import './utils/format.js';
|
|
12
13
|
import 'date-fns/isValid';
|
package/esm/responsive.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { DateTimeInputResponsive } from './Component.responsive.js';
|
|
2
|
-
import './Component-
|
|
2
|
+
import './Component-074b6874.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import 'react-merge-refs';
|
|
5
5
|
import 'classnames';
|
|
@@ -7,10 +7,10 @@ import '@alfalab/core-components-calendar/esm';
|
|
|
7
7
|
import '@alfalab/core-components-icon-button/esm';
|
|
8
8
|
import '@alfalab/core-components-input/esm';
|
|
9
9
|
import '@alfalab/core-components-popover/esm';
|
|
10
|
+
import '@alfalab/hooks';
|
|
10
11
|
import '@alfalab/icons-glyph/CalendarMIcon';
|
|
11
12
|
import './utils/format.js';
|
|
12
13
|
import 'date-fns/isValid';
|
|
13
14
|
import 'date-fns/parse';
|
|
14
|
-
import '@alfalab/hooks';
|
|
15
15
|
import './Component.desktop.js';
|
|
16
16
|
import './Component.mobile.js';
|
package/esm/utils/format.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
declare const DATE_FORMAT = "dd.MM.yyyy";
|
|
2
2
|
declare const DATE_MASK: (string | RegExp)[];
|
|
3
|
+
declare const DATE_WITH_TIME_LENGTH: number;
|
|
3
4
|
declare const isCompleteDateInput: (input: string) => boolean;
|
|
4
5
|
declare const parseDateString: (value: string, dateFormat?: string) => Date;
|
|
5
6
|
declare const isValidTimeFormat: (value: string) => boolean;
|
|
@@ -8,5 +9,5 @@ declare const format: (value: string) => string;
|
|
|
8
9
|
declare const parseTimestampToDate: (timestamp: number) => string;
|
|
9
10
|
declare const getDateWithoutTime: (value: string) => Date;
|
|
10
11
|
declare const getFullDateTime: (value: string) => Date;
|
|
11
|
-
declare const
|
|
12
|
-
export { DATE_FORMAT, DATE_MASK, isCompleteDateInput, parseDateString, isValidTimeFormat, isValid, format, parseTimestampToDate, getDateWithoutTime, getFullDateTime,
|
|
12
|
+
declare const addTimeToDate: (value: string) => string;
|
|
13
|
+
export { DATE_FORMAT, DATE_MASK, DATE_WITH_TIME_LENGTH, isCompleteDateInput, parseDateString, isValidTimeFormat, isValid, format, parseTimestampToDate, getDateWithoutTime, getFullDateTime, addTimeToDate };
|
package/esm/utils/format.js
CHANGED
|
@@ -22,7 +22,8 @@ var DATE_MASK = [
|
|
|
22
22
|
/\d/,
|
|
23
23
|
/\d/,
|
|
24
24
|
];
|
|
25
|
-
var
|
|
25
|
+
var DATE_WITH_TIME_LENGTH = DATE_MASK.length;
|
|
26
|
+
var isCompleteDateInput = function (input) { return input.length === DATE_WITH_TIME_LENGTH; };
|
|
26
27
|
var parseDateString = function (value, dateFormat) {
|
|
27
28
|
if (dateFormat === void 0) { dateFormat = DATE_FORMAT; }
|
|
28
29
|
return parse(value, dateFormat, new Date());
|
|
@@ -116,13 +117,15 @@ var getFullDateTime = function (value) {
|
|
|
116
117
|
fullDate.setFullYear(Number(year), Number(month) - 1, Number(day));
|
|
117
118
|
fullDate.setHours(Number(hours) || 0);
|
|
118
119
|
fullDate.setMinutes(Number(mins) || 0);
|
|
120
|
+
fullDate.setSeconds(0);
|
|
121
|
+
fullDate.setMilliseconds(0);
|
|
119
122
|
return fullDate;
|
|
120
123
|
};
|
|
121
|
-
var
|
|
124
|
+
var addTimeToDate = function (value) {
|
|
122
125
|
if (value.length === 10 && dateFnsIsValid(parseDateString(value))) {
|
|
123
126
|
return "".concat(value, ", 00:00");
|
|
124
127
|
}
|
|
125
128
|
return value;
|
|
126
129
|
};
|
|
127
130
|
|
|
128
|
-
export { DATE_FORMAT, DATE_MASK, format, getDateWithoutTime, getFullDateTime, isCompleteDateInput, isValid, isValidTimeFormat, parseDateString, parseTimestampToDate
|
|
131
|
+
export { DATE_FORMAT, DATE_MASK, DATE_WITH_TIME_LENGTH, addTimeToDate, format, getDateWithoutTime, getFullDateTime, isCompleteDateInput, isValid, isValidTimeFormat, parseDateString, parseTimestampToDate };
|
package/esm/utils/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { DATE_FORMAT, DATE_MASK, format, getDateWithoutTime, getFullDateTime, isCompleteDateInput, isValid, isValidTimeFormat, parseDateString, parseTimestampToDate
|
|
1
|
+
export { DATE_FORMAT, DATE_MASK, DATE_WITH_TIME_LENGTH, addTimeToDate, format, getDateWithoutTime, getFullDateTime, isCompleteDateInput, isValid, isValidTimeFormat, parseDateString, parseTimestampToDate } from './format.js';
|
|
2
2
|
import 'date-fns/isValid';
|
|
3
3
|
import 'date-fns/parse';
|
package/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { DateTimeInputResponsive as DateTimeInput
|
|
1
|
+
export { DateTimeInputResponsive as DateTimeInput } from "./responsive";
|
|
2
|
+
export type { DateTimeInputResponsiveProps as DateTimeInputProps } from "./responsive";
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var Component_responsive = require('./Component.responsive.js');
|
|
4
|
-
require('./Component-
|
|
4
|
+
require('./Component-1ff76732.js');
|
|
5
5
|
require('react');
|
|
6
6
|
require('react-merge-refs');
|
|
7
7
|
require('classnames');
|
|
@@ -9,11 +9,11 @@ require('@alfalab/core-components-calendar');
|
|
|
9
9
|
require('@alfalab/core-components-icon-button');
|
|
10
10
|
require('@alfalab/core-components-input');
|
|
11
11
|
require('@alfalab/core-components-popover');
|
|
12
|
+
require('@alfalab/hooks');
|
|
12
13
|
require('@alfalab/icons-glyph/CalendarMIcon');
|
|
13
14
|
require('./utils/format.js');
|
|
14
15
|
require('date-fns/isValid');
|
|
15
16
|
require('date-fns/parse');
|
|
16
|
-
require('@alfalab/hooks');
|
|
17
17
|
require('./Component.desktop.js');
|
|
18
18
|
require('./Component.mobile.js');
|
|
19
19
|
|
package/mobile.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var Component_mobile = require('./Component.mobile.js');
|
|
4
|
-
require('./Component-
|
|
4
|
+
require('./Component-1ff76732.js');
|
|
5
5
|
require('react');
|
|
6
6
|
require('react-merge-refs');
|
|
7
7
|
require('classnames');
|
|
@@ -9,6 +9,7 @@ require('@alfalab/core-components-calendar');
|
|
|
9
9
|
require('@alfalab/core-components-icon-button');
|
|
10
10
|
require('@alfalab/core-components-input');
|
|
11
11
|
require('@alfalab/core-components-popover');
|
|
12
|
+
require('@alfalab/hooks');
|
|
12
13
|
require('@alfalab/icons-glyph/CalendarMIcon');
|
|
13
14
|
require('./utils/format.js');
|
|
14
15
|
require('date-fns/isValid');
|