@alfalab/core-components-date-time-input 2.1.2 → 2.1.3
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.js +9 -17
- package/cssm/Component.js +11 -20
- package/cssm/index.js +1 -3
- package/cssm/utils/format.js +7 -14
- package/cssm/utils/index.js +1 -3
- package/esm/Component.js +2 -2
- package/esm/index.css +6 -6
- package/esm/index.js +1 -1
- package/esm/utils/format.js +4 -4
- package/esm/utils/index.js +1 -1
- package/index.css +6 -6
- package/index.js +1 -3
- package/modern/Component.js +2 -2
- package/modern/index.css +6 -6
- package/modern/index.js +2 -2
- package/modern/utils/index.js +1 -1
- package/package.json +2 -2
- package/utils/format.js +7 -14
- package/utils/index.js +1 -3
package/Component.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var React = require('react');
|
|
6
4
|
var mergeRefs = require('react-merge-refs');
|
|
7
5
|
var cn = require('classnames');
|
|
@@ -11,15 +9,9 @@ var coreComponentsInput = require('@alfalab/core-components-input');
|
|
|
11
9
|
var coreComponentsPopover = require('@alfalab/core-components-popover');
|
|
12
10
|
var hooks = require('@alfalab/hooks');
|
|
13
11
|
var CalendarMIcon = require('@alfalab/icons-glyph/CalendarMIcon');
|
|
12
|
+
var utils_format = require('./utils/format.js');
|
|
14
13
|
require('date-fns/isValid');
|
|
15
14
|
require('date-fns/parse');
|
|
16
|
-
var utils_format = require('./utils/format.js');
|
|
17
|
-
|
|
18
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
19
|
-
|
|
20
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
21
|
-
var mergeRefs__default = /*#__PURE__*/_interopDefaultLegacy(mergeRefs);
|
|
22
|
-
var cn__default = /*#__PURE__*/_interopDefaultLegacy(cn);
|
|
23
15
|
|
|
24
16
|
/******************************************************************************
|
|
25
17
|
Copyright (c) Microsoft Corporation.
|
|
@@ -60,11 +52,11 @@ function __rest(s, e) {
|
|
|
60
52
|
return t;
|
|
61
53
|
}
|
|
62
54
|
|
|
63
|
-
var styles = {"component":"date-time-
|
|
55
|
+
var styles = {"component":"date-time-input__component_wwj6o","calendarContainer":"date-time-input__calendarContainer_wwj6o","calendarResponsive":"date-time-input__calendarResponsive_wwj6o","block":"date-time-input__block_wwj6o"};
|
|
64
56
|
require('./index.css')
|
|
65
57
|
|
|
66
58
|
/* eslint-disable no-useless-escape, jsx-a11y/click-events-have-key-events */
|
|
67
|
-
var DateTimeInput =
|
|
59
|
+
var DateTimeInput = React.forwardRef(function (_a, ref) {
|
|
68
60
|
var _b, _c;
|
|
69
61
|
var _d;
|
|
70
62
|
var className = _a.className, inputClassName = _a.inputClassName, popoverClassName = _a.popoverClassName, disabled = _a.disabled, readOnly = _a.readOnly, picker = _a.picker, _e = _a.defaultValue, defaultValue = _e === void 0 ? '' : _e, propValue = _a.value, onChange = _a.onChange, onComplete = _a.onComplete, rightAddons = _a.rightAddons, useAnchorWidth = _a.useAnchorWidth, block = _a.block, _f = _a.popoverPosition, popoverPosition = _f === void 0 ? 'bottom-start' : _f, zIndexPopover = _a.zIndexPopover, preventFlip = _a.preventFlip, _g = _a.Calendar, Calendar = _g === void 0 ? coreComponentsCalendar.Calendar : _g, _h = _a.calendarProps, calendarProps = _h === void 0 ? {} : _h, defaultMonth = _a.defaultMonth, _j = _a.minDate, minDate = _j === void 0 ? calendarProps.minDate : _j, _k = _a.maxDate, maxDate = _k === void 0 ? calendarProps.maxDate : _k, _l = _a.offDays, offDays = _l === void 0 ? calendarProps.offDays || [] : _l, _m = _a.events, events = _m === void 0 ? calendarProps.events || [] : _m, _o = _a.defaultOpen, defaultOpen = _o === void 0 ? false : _o, error = _a.error, restProps = __rest(_a, ["className", "inputClassName", "popoverClassName", "disabled", "readOnly", "picker", "defaultValue", "value", "onChange", "onComplete", "rightAddons", "useAnchorWidth", "block", "popoverPosition", "zIndexPopover", "preventFlip", "Calendar", "calendarProps", "defaultMonth", "minDate", "maxDate", "offDays", "events", "defaultOpen", "error"]);
|
|
@@ -164,15 +156,15 @@ var DateTimeInput = React__default['default'].forwardRef(function (_a, ref) {
|
|
|
164
156
|
};
|
|
165
157
|
var renderCalendar = function () { return (
|
|
166
158
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return (
|
|
159
|
+
React.createElement("div", { onMouseDown: handleCalendarWrapperMouseDown },
|
|
160
|
+
React.createElement(CalendarComponent, __assign({}, calendarProps, { responsive: calendarResponsive, open: open, onClose: handleCalendarClose, ref: calendarRef, defaultMonth: defaultMonth, value: checkInputValueIsValid(value) ? calendarValue : undefined, onChange: handleCalendarChange, minDate: minDate, maxDate: maxDate, offDays: offDays, events: events })))); };
|
|
161
|
+
return (React.createElement("div", { className: cn(styles.component, className, (_b = {},
|
|
170
162
|
_b[styles.block] = block,
|
|
171
163
|
_b)), onClick: inputDisabled ? undefined : handleInputWrapperClick, onFocus: inputDisabled ? undefined : handleInputWrapperFocus, onBlur: handleBlur },
|
|
172
|
-
|
|
164
|
+
React.createElement(coreComponentsInput.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,
|
|
173
165
|
rightAddons,
|
|
174
|
-
picker && (
|
|
175
|
-
picker && (
|
|
166
|
+
picker && (React.createElement(coreComponentsIconButton.IconButton, { onClick: inputDisabled ? undefined : handleIconButtonClick, icon: CalendarMIcon.CalendarMIcon, size: 'xxs' }))) })),
|
|
167
|
+
picker && (React.createElement(coreComponentsPopover.Popover, { open: open, useAnchorWidth: useAnchorWidth, anchorElement: inputRef.current, popperClassName: cn(styles.calendarContainer, (_c = {},
|
|
176
168
|
_c[styles.calendarResponsive] = calendarResponsive,
|
|
177
169
|
_c)), className: popoverClassName, position: popoverPosition, offset: [0, 8], withTransition: false, preventFlip: preventFlip, zIndex: zIndexPopover }, renderCalendar()))));
|
|
178
170
|
});
|
package/cssm/Component.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var React = require('react');
|
|
6
4
|
var mergeRefs = require('react-merge-refs');
|
|
7
5
|
var cn = require('classnames');
|
|
@@ -11,17 +9,10 @@ var coreComponentsInput = require('@alfalab/core-components-input/cssm');
|
|
|
11
9
|
var coreComponentsPopover = require('@alfalab/core-components-popover/cssm');
|
|
12
10
|
var hooks = require('@alfalab/hooks');
|
|
13
11
|
var CalendarMIcon = require('@alfalab/icons-glyph/CalendarMIcon');
|
|
14
|
-
require('date-fns/isValid');
|
|
15
|
-
require('date-fns/parse');
|
|
16
12
|
var utils_format = require('./utils/format.js');
|
|
17
13
|
var styles = require('./index.module.css');
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
22
|
-
var mergeRefs__default = /*#__PURE__*/_interopDefaultLegacy(mergeRefs);
|
|
23
|
-
var cn__default = /*#__PURE__*/_interopDefaultLegacy(cn);
|
|
24
|
-
var styles__default = /*#__PURE__*/_interopDefaultLegacy(styles);
|
|
14
|
+
require('date-fns/isValid');
|
|
15
|
+
require('date-fns/parse');
|
|
25
16
|
|
|
26
17
|
/******************************************************************************
|
|
27
18
|
Copyright (c) Microsoft Corporation.
|
|
@@ -63,7 +54,7 @@ function __rest(s, e) {
|
|
|
63
54
|
}
|
|
64
55
|
|
|
65
56
|
/* eslint-disable no-useless-escape, jsx-a11y/click-events-have-key-events */
|
|
66
|
-
var DateTimeInput =
|
|
57
|
+
var DateTimeInput = React.forwardRef(function (_a, ref) {
|
|
67
58
|
var _b, _c;
|
|
68
59
|
var _d;
|
|
69
60
|
var className = _a.className, inputClassName = _a.inputClassName, popoverClassName = _a.popoverClassName, disabled = _a.disabled, readOnly = _a.readOnly, picker = _a.picker, _e = _a.defaultValue, defaultValue = _e === void 0 ? '' : _e, propValue = _a.value, onChange = _a.onChange, onComplete = _a.onComplete, rightAddons = _a.rightAddons, useAnchorWidth = _a.useAnchorWidth, block = _a.block, _f = _a.popoverPosition, popoverPosition = _f === void 0 ? 'bottom-start' : _f, zIndexPopover = _a.zIndexPopover, preventFlip = _a.preventFlip, _g = _a.Calendar, Calendar = _g === void 0 ? coreComponentsCalendar.Calendar : _g, _h = _a.calendarProps, calendarProps = _h === void 0 ? {} : _h, defaultMonth = _a.defaultMonth, _j = _a.minDate, minDate = _j === void 0 ? calendarProps.minDate : _j, _k = _a.maxDate, maxDate = _k === void 0 ? calendarProps.maxDate : _k, _l = _a.offDays, offDays = _l === void 0 ? calendarProps.offDays || [] : _l, _m = _a.events, events = _m === void 0 ? calendarProps.events || [] : _m, _o = _a.defaultOpen, defaultOpen = _o === void 0 ? false : _o, error = _a.error, restProps = __rest(_a, ["className", "inputClassName", "popoverClassName", "disabled", "readOnly", "picker", "defaultValue", "value", "onChange", "onComplete", "rightAddons", "useAnchorWidth", "block", "popoverPosition", "zIndexPopover", "preventFlip", "Calendar", "calendarProps", "defaultMonth", "minDate", "maxDate", "offDays", "events", "defaultOpen", "error"]);
|
|
@@ -163,16 +154,16 @@ var DateTimeInput = React__default['default'].forwardRef(function (_a, ref) {
|
|
|
163
154
|
};
|
|
164
155
|
var renderCalendar = function () { return (
|
|
165
156
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
return (
|
|
169
|
-
_b[
|
|
157
|
+
React.createElement("div", { onMouseDown: handleCalendarWrapperMouseDown },
|
|
158
|
+
React.createElement(CalendarComponent, __assign({}, calendarProps, { responsive: calendarResponsive, open: open, onClose: handleCalendarClose, ref: calendarRef, defaultMonth: defaultMonth, value: checkInputValueIsValid(value) ? calendarValue : undefined, onChange: handleCalendarChange, minDate: minDate, maxDate: maxDate, offDays: offDays, events: events })))); };
|
|
159
|
+
return (React.createElement("div", { className: cn(styles.component, className, (_b = {},
|
|
160
|
+
_b[styles.block] = block,
|
|
170
161
|
_b)), onClick: inputDisabled ? undefined : handleInputWrapperClick, onFocus: inputDisabled ? undefined : handleInputWrapperFocus, onBlur: handleBlur },
|
|
171
|
-
|
|
162
|
+
React.createElement(coreComponentsInput.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,
|
|
172
163
|
rightAddons,
|
|
173
|
-
picker && (
|
|
174
|
-
picker && (
|
|
175
|
-
_c[
|
|
164
|
+
picker && (React.createElement(coreComponentsIconButton.IconButton, { onClick: inputDisabled ? undefined : handleIconButtonClick, icon: CalendarMIcon.CalendarMIcon, size: 'xxs' }))) })),
|
|
165
|
+
picker && (React.createElement(coreComponentsPopover.Popover, { open: open, useAnchorWidth: useAnchorWidth, anchorElement: inputRef.current, popperClassName: cn(styles.calendarContainer, (_c = {},
|
|
166
|
+
_c[styles.calendarResponsive] = calendarResponsive,
|
|
176
167
|
_c)), className: popoverClassName, position: popoverPosition, offset: [0, 8], withTransition: false, preventFlip: preventFlip, zIndex: zIndexPopover }, renderCalendar()))));
|
|
177
168
|
});
|
|
178
169
|
|
package/cssm/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var Component = require('./Component.js');
|
|
6
4
|
require('react');
|
|
7
5
|
require('react-merge-refs');
|
|
@@ -12,9 +10,9 @@ require('@alfalab/core-components-input/cssm');
|
|
|
12
10
|
require('@alfalab/core-components-popover/cssm');
|
|
13
11
|
require('@alfalab/hooks');
|
|
14
12
|
require('@alfalab/icons-glyph/CalendarMIcon');
|
|
13
|
+
require('./utils/format.js');
|
|
15
14
|
require('date-fns/isValid');
|
|
16
15
|
require('date-fns/parse');
|
|
17
|
-
require('./utils/format.js');
|
|
18
16
|
require('./index.module.css');
|
|
19
17
|
|
|
20
18
|
|
package/cssm/utils/format.js
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var dateFnsIsValid = require('date-fns/isValid');
|
|
6
4
|
var parse = require('date-fns/parse');
|
|
7
5
|
|
|
8
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
-
|
|
10
|
-
var dateFnsIsValid__default = /*#__PURE__*/_interopDefaultLegacy(dateFnsIsValid);
|
|
11
|
-
var parse__default = /*#__PURE__*/_interopDefaultLegacy(parse);
|
|
12
|
-
|
|
13
6
|
/* eslint-disable no-useless-escape */
|
|
14
7
|
var DATE_FORMAT = 'dd.MM.yyyy';
|
|
15
8
|
var DATE_MASK = [
|
|
@@ -34,7 +27,7 @@ var DATE_MASK = [
|
|
|
34
27
|
var isCompleteDateInput = function (input) { return input.length === DATE_MASK.length; };
|
|
35
28
|
var parseDateString = function (value, dateFormat) {
|
|
36
29
|
if (dateFormat === void 0) { dateFormat = DATE_FORMAT; }
|
|
37
|
-
return
|
|
30
|
+
return parse(value, dateFormat, new Date());
|
|
38
31
|
};
|
|
39
32
|
var isValidTimeFormat = function (value) {
|
|
40
33
|
var timeArr = value.split(':');
|
|
@@ -54,7 +47,7 @@ var isValid = function (inputValue) {
|
|
|
54
47
|
var time = inputValueArr[1];
|
|
55
48
|
return (!inputValue ||
|
|
56
49
|
(isCompleteDateInput(inputValue) &&
|
|
57
|
-
|
|
50
|
+
dateFnsIsValid(parseDateString(date)) &&
|
|
58
51
|
isValidTimeFormat(time)));
|
|
59
52
|
};
|
|
60
53
|
var format = function (value) {
|
|
@@ -84,12 +77,12 @@ var parseTimestampToDate = function (timestamp) {
|
|
|
84
77
|
var month = date.getMonth() + 1;
|
|
85
78
|
var day = date.getDate();
|
|
86
79
|
if (month < 10) {
|
|
87
|
-
month = "0"
|
|
80
|
+
month = "0".concat(month);
|
|
88
81
|
}
|
|
89
82
|
if (day < 10) {
|
|
90
|
-
day = "0"
|
|
83
|
+
day = "0".concat(day);
|
|
91
84
|
}
|
|
92
|
-
return day
|
|
85
|
+
return "".concat(day, ".").concat(month, ".").concat(year);
|
|
93
86
|
};
|
|
94
87
|
var getDateWithoutTime = function (value) {
|
|
95
88
|
var valueArr = value.split(', ');
|
|
@@ -128,8 +121,8 @@ var getFullDateTime = function (value) {
|
|
|
128
121
|
return fullDate;
|
|
129
122
|
};
|
|
130
123
|
var setTimeToDate = function (value) {
|
|
131
|
-
if (value.length === 10 &&
|
|
132
|
-
return value
|
|
124
|
+
if (value.length === 10 && dateFnsIsValid(parseDateString(value))) {
|
|
125
|
+
return "".concat(value, ", 00:00");
|
|
133
126
|
}
|
|
134
127
|
return value;
|
|
135
128
|
};
|
package/cssm/utils/index.js
CHANGED
package/esm/Component.js
CHANGED
|
@@ -7,9 +7,9 @@ import { Input } from '@alfalab/core-components-input/esm';
|
|
|
7
7
|
import { Popover } from '@alfalab/core-components-popover/esm';
|
|
8
8
|
import { useMedia } from '@alfalab/hooks';
|
|
9
9
|
import { CalendarMIcon } from '@alfalab/icons-glyph/CalendarMIcon';
|
|
10
|
+
import { getDateWithoutTime, setTimeToDate, DATE_MASK, format, getFullDateTime, isCompleteDateInput, isValid, parseTimestampToDate } from './utils/format.js';
|
|
10
11
|
import 'date-fns/isValid';
|
|
11
12
|
import 'date-fns/parse';
|
|
12
|
-
import { getDateWithoutTime, setTimeToDate, DATE_MASK, format, getFullDateTime, isCompleteDateInput, isValid, parseTimestampToDate } from './utils/format.js';
|
|
13
13
|
|
|
14
14
|
/******************************************************************************
|
|
15
15
|
Copyright (c) Microsoft Corporation.
|
|
@@ -50,7 +50,7 @@ function __rest(s, e) {
|
|
|
50
50
|
return t;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
var styles = {"component":"date-time-
|
|
53
|
+
var styles = {"component":"date-time-input__component_wwj6o","calendarContainer":"date-time-input__calendarContainer_wwj6o","calendarResponsive":"date-time-input__calendarResponsive_wwj6o","block":"date-time-input__block_wwj6o"};
|
|
54
54
|
require('./index.css')
|
|
55
55
|
|
|
56
56
|
/* eslint-disable no-useless-escape, jsx-a11y/click-events-have-key-events */
|
package/esm/index.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: c1or9 */
|
|
2
2
|
:root {
|
|
3
3
|
|
|
4
4
|
/* Hard */
|
|
@@ -39,26 +39,26 @@
|
|
|
39
39
|
:root {
|
|
40
40
|
--calendar-popover-border-radius: 0 0 var(--border-radius-s) var(--border-radius-s);
|
|
41
41
|
}
|
|
42
|
-
.date-time-
|
|
42
|
+
.date-time-input__component_wwj6o {
|
|
43
43
|
display: inline-block;
|
|
44
44
|
outline: none;
|
|
45
45
|
position: relative;
|
|
46
46
|
}
|
|
47
|
-
.date-time-
|
|
47
|
+
.date-time-input__calendarContainer_wwj6o {
|
|
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_wwj6o {
|
|
54
54
|
width: 100%;
|
|
55
55
|
min-width: 288px
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
.date-time-
|
|
58
|
+
.date-time-input__calendarResponsive_wwj6o {
|
|
59
59
|
width: var(--calendar-width);
|
|
60
60
|
padding: 0 var(--gap-m);
|
|
61
61
|
}
|
|
62
|
-
.date-time-
|
|
62
|
+
.date-time-input__block_wwj6o {
|
|
63
63
|
width: 100%;
|
|
64
64
|
}
|
package/esm/index.js
CHANGED
|
@@ -8,6 +8,6 @@ import '@alfalab/core-components-input/esm';
|
|
|
8
8
|
import '@alfalab/core-components-popover/esm';
|
|
9
9
|
import '@alfalab/hooks';
|
|
10
10
|
import '@alfalab/icons-glyph/CalendarMIcon';
|
|
11
|
+
import './utils/format.js';
|
|
11
12
|
import 'date-fns/isValid';
|
|
12
13
|
import 'date-fns/parse';
|
|
13
|
-
import './utils/format.js';
|
package/esm/utils/format.js
CHANGED
|
@@ -75,12 +75,12 @@ var parseTimestampToDate = function (timestamp) {
|
|
|
75
75
|
var month = date.getMonth() + 1;
|
|
76
76
|
var day = date.getDate();
|
|
77
77
|
if (month < 10) {
|
|
78
|
-
month = "0"
|
|
78
|
+
month = "0".concat(month);
|
|
79
79
|
}
|
|
80
80
|
if (day < 10) {
|
|
81
|
-
day = "0"
|
|
81
|
+
day = "0".concat(day);
|
|
82
82
|
}
|
|
83
|
-
return day
|
|
83
|
+
return "".concat(day, ".").concat(month, ".").concat(year);
|
|
84
84
|
};
|
|
85
85
|
var getDateWithoutTime = function (value) {
|
|
86
86
|
var valueArr = value.split(', ');
|
|
@@ -120,7 +120,7 @@ var getFullDateTime = function (value) {
|
|
|
120
120
|
};
|
|
121
121
|
var setTimeToDate = function (value) {
|
|
122
122
|
if (value.length === 10 && dateFnsIsValid(parseDateString(value))) {
|
|
123
|
-
return value
|
|
123
|
+
return "".concat(value, ", 00:00");
|
|
124
124
|
}
|
|
125
125
|
return value;
|
|
126
126
|
};
|
package/esm/utils/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
+
export { DATE_FORMAT, DATE_MASK, format, getDateWithoutTime, getFullDateTime, isCompleteDateInput, isValid, isValidTimeFormat, parseDateString, parseTimestampToDate, setTimeToDate } from './format.js';
|
|
1
2
|
import 'date-fns/isValid';
|
|
2
3
|
import 'date-fns/parse';
|
|
3
|
-
export { DATE_FORMAT, DATE_MASK, format, getDateWithoutTime, getFullDateTime, isCompleteDateInput, isValid, isValidTimeFormat, parseDateString, parseTimestampToDate, setTimeToDate } from './format.js';
|
package/index.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: c1or9 */
|
|
2
2
|
:root {
|
|
3
3
|
|
|
4
4
|
/* Hard */
|
|
@@ -39,26 +39,26 @@
|
|
|
39
39
|
:root {
|
|
40
40
|
--calendar-popover-border-radius: 0 0 var(--border-radius-s) var(--border-radius-s);
|
|
41
41
|
}
|
|
42
|
-
.date-time-
|
|
42
|
+
.date-time-input__component_wwj6o {
|
|
43
43
|
display: inline-block;
|
|
44
44
|
outline: none;
|
|
45
45
|
position: relative;
|
|
46
46
|
}
|
|
47
|
-
.date-time-
|
|
47
|
+
.date-time-input__calendarContainer_wwj6o {
|
|
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_wwj6o {
|
|
54
54
|
width: 100%;
|
|
55
55
|
min-width: 288px
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
.date-time-
|
|
58
|
+
.date-time-input__calendarResponsive_wwj6o {
|
|
59
59
|
width: var(--calendar-width);
|
|
60
60
|
padding: 0 var(--gap-m);
|
|
61
61
|
}
|
|
62
|
-
.date-time-
|
|
62
|
+
.date-time-input__block_wwj6o {
|
|
63
63
|
width: 100%;
|
|
64
64
|
}
|
package/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var Component = require('./Component.js');
|
|
6
4
|
require('react');
|
|
7
5
|
require('react-merge-refs');
|
|
@@ -12,9 +10,9 @@ require('@alfalab/core-components-input');
|
|
|
12
10
|
require('@alfalab/core-components-popover');
|
|
13
11
|
require('@alfalab/hooks');
|
|
14
12
|
require('@alfalab/icons-glyph/CalendarMIcon');
|
|
13
|
+
require('./utils/format.js');
|
|
15
14
|
require('date-fns/isValid');
|
|
16
15
|
require('date-fns/parse');
|
|
17
|
-
require('./utils/format.js');
|
|
18
16
|
|
|
19
17
|
|
|
20
18
|
|
package/modern/Component.js
CHANGED
|
@@ -7,11 +7,11 @@ import { Input } from '@alfalab/core-components-input/modern';
|
|
|
7
7
|
import { Popover } from '@alfalab/core-components-popover/modern';
|
|
8
8
|
import { useMedia } from '@alfalab/hooks';
|
|
9
9
|
import { CalendarMIcon } from '@alfalab/icons-glyph/CalendarMIcon';
|
|
10
|
+
import { getDateWithoutTime, setTimeToDate, DATE_MASK, format, getFullDateTime, isCompleteDateInput, isValid, parseTimestampToDate } from './utils/format.js';
|
|
10
11
|
import 'date-fns/isValid';
|
|
11
12
|
import 'date-fns/parse';
|
|
12
|
-
import { getDateWithoutTime, setTimeToDate, DATE_MASK, format, getFullDateTime, isCompleteDateInput, isValid, parseTimestampToDate } from './utils/format.js';
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
const styles = {"component":"date-time-input__component_wwj6o","calendarContainer":"date-time-input__calendarContainer_wwj6o","calendarResponsive":"date-time-input__calendarResponsive_wwj6o","block":"date-time-input__block_wwj6o"};
|
|
15
15
|
require('./index.css')
|
|
16
16
|
|
|
17
17
|
/* eslint-disable no-useless-escape, jsx-a11y/click-events-have-key-events */
|
package/modern/index.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: c1or9 */
|
|
2
2
|
:root {
|
|
3
3
|
|
|
4
4
|
/* Hard */
|
|
@@ -39,26 +39,26 @@
|
|
|
39
39
|
:root {
|
|
40
40
|
--calendar-popover-border-radius: 0 0 var(--border-radius-s) var(--border-radius-s);
|
|
41
41
|
}
|
|
42
|
-
.date-time-
|
|
42
|
+
.date-time-input__component_wwj6o {
|
|
43
43
|
display: inline-block;
|
|
44
44
|
outline: none;
|
|
45
45
|
position: relative;
|
|
46
46
|
}
|
|
47
|
-
.date-time-
|
|
47
|
+
.date-time-input__calendarContainer_wwj6o {
|
|
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_wwj6o {
|
|
54
54
|
width: 100%;
|
|
55
55
|
min-width: 288px
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
.date-time-
|
|
58
|
+
.date-time-input__calendarResponsive_wwj6o {
|
|
59
59
|
width: var(--calendar-width);
|
|
60
60
|
padding: 0 var(--gap-m);
|
|
61
61
|
}
|
|
62
|
-
.date-time-
|
|
62
|
+
.date-time-input__block_wwj6o {
|
|
63
63
|
width: 100%;
|
|
64
64
|
}
|
package/modern/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { DateTimeInput } from './Component.js';
|
|
1
2
|
import 'react';
|
|
2
3
|
import 'react-merge-refs';
|
|
3
4
|
import 'classnames';
|
|
@@ -7,7 +8,6 @@ import '@alfalab/core-components-input/modern';
|
|
|
7
8
|
import '@alfalab/core-components-popover/modern';
|
|
8
9
|
import '@alfalab/hooks';
|
|
9
10
|
import '@alfalab/icons-glyph/CalendarMIcon';
|
|
11
|
+
import './utils/format.js';
|
|
10
12
|
import 'date-fns/isValid';
|
|
11
13
|
import 'date-fns/parse';
|
|
12
|
-
import './utils/format.js';
|
|
13
|
-
export { DateTimeInput } from './Component.js';
|
package/modern/utils/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
+
export { DATE_FORMAT, DATE_MASK, format, getDateWithoutTime, getFullDateTime, isCompleteDateInput, isValid, isValidTimeFormat, parseDateString, parseTimestampToDate, setTimeToDate } from './format.js';
|
|
1
2
|
import 'date-fns/isValid';
|
|
2
3
|
import 'date-fns/parse';
|
|
3
|
-
export { DATE_FORMAT, DATE_MASK, format, getDateWithoutTime, getFullDateTime, isCompleteDateInput, isValid, isValidTimeFormat, parseDateString, parseTimestampToDate, setTimeToDate } from './format.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfalab/core-components-date-time-input",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@alfalab/core-components-calendar": "^6.1.
|
|
18
|
+
"@alfalab/core-components-calendar": "^6.1.15",
|
|
19
19
|
"@alfalab/core-components-input": "^11.1.0",
|
|
20
20
|
"@alfalab/core-components-icon-button": "^6.0.1",
|
|
21
21
|
"@alfalab/core-components-popover": "^6.0.4",
|
package/utils/format.js
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var dateFnsIsValid = require('date-fns/isValid');
|
|
6
4
|
var parse = require('date-fns/parse');
|
|
7
5
|
|
|
8
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
-
|
|
10
|
-
var dateFnsIsValid__default = /*#__PURE__*/_interopDefaultLegacy(dateFnsIsValid);
|
|
11
|
-
var parse__default = /*#__PURE__*/_interopDefaultLegacy(parse);
|
|
12
|
-
|
|
13
6
|
/* eslint-disable no-useless-escape */
|
|
14
7
|
var DATE_FORMAT = 'dd.MM.yyyy';
|
|
15
8
|
var DATE_MASK = [
|
|
@@ -34,7 +27,7 @@ var DATE_MASK = [
|
|
|
34
27
|
var isCompleteDateInput = function (input) { return input.length === DATE_MASK.length; };
|
|
35
28
|
var parseDateString = function (value, dateFormat) {
|
|
36
29
|
if (dateFormat === void 0) { dateFormat = DATE_FORMAT; }
|
|
37
|
-
return
|
|
30
|
+
return parse(value, dateFormat, new Date());
|
|
38
31
|
};
|
|
39
32
|
var isValidTimeFormat = function (value) {
|
|
40
33
|
var timeArr = value.split(':');
|
|
@@ -54,7 +47,7 @@ var isValid = function (inputValue) {
|
|
|
54
47
|
var time = inputValueArr[1];
|
|
55
48
|
return (!inputValue ||
|
|
56
49
|
(isCompleteDateInput(inputValue) &&
|
|
57
|
-
|
|
50
|
+
dateFnsIsValid(parseDateString(date)) &&
|
|
58
51
|
isValidTimeFormat(time)));
|
|
59
52
|
};
|
|
60
53
|
var format = function (value) {
|
|
@@ -84,12 +77,12 @@ var parseTimestampToDate = function (timestamp) {
|
|
|
84
77
|
var month = date.getMonth() + 1;
|
|
85
78
|
var day = date.getDate();
|
|
86
79
|
if (month < 10) {
|
|
87
|
-
month = "0"
|
|
80
|
+
month = "0".concat(month);
|
|
88
81
|
}
|
|
89
82
|
if (day < 10) {
|
|
90
|
-
day = "0"
|
|
83
|
+
day = "0".concat(day);
|
|
91
84
|
}
|
|
92
|
-
return day
|
|
85
|
+
return "".concat(day, ".").concat(month, ".").concat(year);
|
|
93
86
|
};
|
|
94
87
|
var getDateWithoutTime = function (value) {
|
|
95
88
|
var valueArr = value.split(', ');
|
|
@@ -128,8 +121,8 @@ var getFullDateTime = function (value) {
|
|
|
128
121
|
return fullDate;
|
|
129
122
|
};
|
|
130
123
|
var setTimeToDate = function (value) {
|
|
131
|
-
if (value.length === 10 &&
|
|
132
|
-
return value
|
|
124
|
+
if (value.length === 10 && dateFnsIsValid(parseDateString(value))) {
|
|
125
|
+
return "".concat(value, ", 00:00");
|
|
133
126
|
}
|
|
134
127
|
return value;
|
|
135
128
|
};
|
package/utils/index.js
CHANGED