@alfalab/core-components-date-range-input 3.3.26 → 3.4.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/components/date-range-input/Component.js +1 -1
- package/components/date-range-input/index.css +7 -7
- package/esm/components/date-range-input/Component.js +1 -1
- package/esm/components/date-range-input/index.css +7 -7
- package/modern/components/date-range-input/Component.js +1 -1
- package/modern/components/date-range-input/index.css +7 -7
- package/moderncssm/Component.responsive.d.ts +17 -0
- package/moderncssm/Component.responsive.js +18 -0
- package/moderncssm/components/date-range-input/Component.d.ts +117 -0
- package/moderncssm/components/date-range-input/Component.js +206 -0
- package/moderncssm/components/date-range-input/index.d.ts +1 -0
- package/moderncssm/components/date-range-input/index.js +1 -0
- package/moderncssm/components/date-range-input/index.module.css +54 -0
- package/moderncssm/desktop/Component.desktop.d.ts +10 -0
- package/moderncssm/desktop/Component.desktop.js +12 -0
- package/moderncssm/desktop/index.d.ts +2 -0
- package/moderncssm/desktop/index.js +1 -0
- package/moderncssm/index.d.ts +3 -0
- package/moderncssm/index.js +1 -0
- package/moderncssm/mobile/Component.mobile.d.ts +10 -0
- package/moderncssm/mobile/Component.mobile.js +12 -0
- package/moderncssm/mobile/index.d.ts +2 -0
- package/moderncssm/mobile/index.js +1 -0
- package/moderncssm/utils/format.d.ts +8 -0
- package/moderncssm/utils/format.js +81 -0
- package/moderncssm/utils/index.d.ts +1 -0
- package/moderncssm/utils/index.js +1 -0
- package/package.json +7 -7
- package/src/components/date-range-input/index.module.css +1 -1
|
@@ -23,7 +23,7 @@ var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
|
|
|
23
23
|
var dateFnsIsValid__default = /*#__PURE__*/_interopDefaultCompat(dateFnsIsValid);
|
|
24
24
|
var startOfMonth__default = /*#__PURE__*/_interopDefaultCompat(startOfMonth);
|
|
25
25
|
|
|
26
|
-
var styles = {"component":"date-range-
|
|
26
|
+
var styles = {"component":"date-range-input__component_1g9ps","calendarContainer":"date-range-input__calendarContainer_1g9ps","calendarResponsive":"date-range-input__calendarResponsive_1g9ps","block":"date-range-input__block_1g9ps","calendarIcon":"date-range-input__calendarIcon_1g9ps"};
|
|
27
27
|
require('./index.css')
|
|
28
28
|
|
|
29
29
|
var DateRangeInput = React__default.default.forwardRef(function (_a, ref) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 1edyr */
|
|
2
2
|
:root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
3
3
|
} /* deprecated */ :root {
|
|
4
4
|
--color-light-neutral-300: #e7e8eb; /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
@@ -46,24 +46,24 @@
|
|
|
46
46
|
/* marker */
|
|
47
47
|
} :root {
|
|
48
48
|
--calendar-popover-border-radius: var(--border-radius-m);
|
|
49
|
-
} .date-range-
|
|
49
|
+
} .date-range-input__component_1g9ps {
|
|
50
50
|
display: inline-block;
|
|
51
51
|
outline: none;
|
|
52
52
|
position: relative;
|
|
53
|
-
} .date-range-
|
|
53
|
+
} .date-range-input__calendarContainer_1g9ps {
|
|
54
54
|
display: inline-block;
|
|
55
55
|
box-sizing: border-box;
|
|
56
56
|
border-radius: var(--calendar-popover-border-radius);
|
|
57
57
|
border: 1px solid var(--color-light-neutral-300)
|
|
58
|
-
} @media (max-width: 374px) { .date-range-
|
|
58
|
+
} @media (max-width: 374px) { .date-range-input__calendarContainer_1g9ps {
|
|
59
59
|
width: 100%;
|
|
60
60
|
min-width: 288px
|
|
61
61
|
}
|
|
62
|
-
} .date-range-
|
|
62
|
+
} .date-range-input__calendarResponsive_1g9ps {
|
|
63
63
|
width: var(--calendar-width);
|
|
64
|
-
} .date-range-
|
|
64
|
+
} .date-range-input__block_1g9ps {
|
|
65
65
|
width: 100%;
|
|
66
|
-
} .date-range-
|
|
66
|
+
} .date-range-input__calendarIcon_1g9ps {
|
|
67
67
|
margin-right: var(--gap-12-neg);
|
|
68
68
|
height: 100%;
|
|
69
69
|
}
|
|
@@ -11,7 +11,7 @@ import { useDidUpdateEffect } from '@alfalab/hooks';
|
|
|
11
11
|
import { CalendarMIcon } from '@alfalab/icons-glyph/CalendarMIcon';
|
|
12
12
|
import { parseTimestampToDate, DATE_FORMAT, format, parseDateString, DATE_MASK, isCompleteDateInput, isValid } from '../../utils/format.js';
|
|
13
13
|
|
|
14
|
-
var styles = {"component":"date-range-
|
|
14
|
+
var styles = {"component":"date-range-input__component_1g9ps","calendarContainer":"date-range-input__calendarContainer_1g9ps","calendarResponsive":"date-range-input__calendarResponsive_1g9ps","block":"date-range-input__block_1g9ps","calendarIcon":"date-range-input__calendarIcon_1g9ps"};
|
|
15
15
|
require('./index.css')
|
|
16
16
|
|
|
17
17
|
var DateRangeInput = React.forwardRef(function (_a, ref) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 1edyr */
|
|
2
2
|
:root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
3
3
|
} /* deprecated */ :root {
|
|
4
4
|
--color-light-neutral-300: #e7e8eb; /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
@@ -46,24 +46,24 @@
|
|
|
46
46
|
/* marker */
|
|
47
47
|
} :root {
|
|
48
48
|
--calendar-popover-border-radius: var(--border-radius-m);
|
|
49
|
-
} .date-range-
|
|
49
|
+
} .date-range-input__component_1g9ps {
|
|
50
50
|
display: inline-block;
|
|
51
51
|
outline: none;
|
|
52
52
|
position: relative;
|
|
53
|
-
} .date-range-
|
|
53
|
+
} .date-range-input__calendarContainer_1g9ps {
|
|
54
54
|
display: inline-block;
|
|
55
55
|
box-sizing: border-box;
|
|
56
56
|
border-radius: var(--calendar-popover-border-radius);
|
|
57
57
|
border: 1px solid var(--color-light-neutral-300)
|
|
58
|
-
} @media (max-width: 374px) { .date-range-
|
|
58
|
+
} @media (max-width: 374px) { .date-range-input__calendarContainer_1g9ps {
|
|
59
59
|
width: 100%;
|
|
60
60
|
min-width: 288px
|
|
61
61
|
}
|
|
62
|
-
} .date-range-
|
|
62
|
+
} .date-range-input__calendarResponsive_1g9ps {
|
|
63
63
|
width: var(--calendar-width);
|
|
64
|
-
} .date-range-
|
|
64
|
+
} .date-range-input__block_1g9ps {
|
|
65
65
|
width: 100%;
|
|
66
|
-
} .date-range-
|
|
66
|
+
} .date-range-input__calendarIcon_1g9ps {
|
|
67
67
|
margin-right: var(--gap-12-neg);
|
|
68
68
|
height: 100%;
|
|
69
69
|
}
|
|
@@ -10,7 +10,7 @@ import { useDidUpdateEffect } from '@alfalab/hooks';
|
|
|
10
10
|
import { CalendarMIcon } from '@alfalab/icons-glyph/CalendarMIcon';
|
|
11
11
|
import { parseTimestampToDate, DATE_FORMAT, format, parseDateString, DATE_MASK, isCompleteDateInput, isValid } from '../../utils/format.js';
|
|
12
12
|
|
|
13
|
-
const styles = {"component":"date-range-
|
|
13
|
+
const styles = {"component":"date-range-input__component_1g9ps","calendarContainer":"date-range-input__calendarContainer_1g9ps","calendarResponsive":"date-range-input__calendarResponsive_1g9ps","block":"date-range-input__block_1g9ps","calendarIcon":"date-range-input__calendarIcon_1g9ps"};
|
|
14
14
|
require('./index.css')
|
|
15
15
|
|
|
16
16
|
/* eslint-disable no-useless-escape, jsx-a11y/click-events-have-key-events */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 1edyr */
|
|
2
2
|
:root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
3
3
|
} /* deprecated */ :root {
|
|
4
4
|
--color-light-neutral-300: #e7e8eb; /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
@@ -46,24 +46,24 @@
|
|
|
46
46
|
/* marker */
|
|
47
47
|
} :root {
|
|
48
48
|
--calendar-popover-border-radius: var(--border-radius-m);
|
|
49
|
-
} .date-range-
|
|
49
|
+
} .date-range-input__component_1g9ps {
|
|
50
50
|
display: inline-block;
|
|
51
51
|
outline: none;
|
|
52
52
|
position: relative;
|
|
53
|
-
} .date-range-
|
|
53
|
+
} .date-range-input__calendarContainer_1g9ps {
|
|
54
54
|
display: inline-block;
|
|
55
55
|
box-sizing: border-box;
|
|
56
56
|
border-radius: var(--calendar-popover-border-radius);
|
|
57
57
|
border: 1px solid var(--color-light-neutral-300)
|
|
58
|
-
} @media (max-width: 374px) { .date-range-
|
|
58
|
+
} @media (max-width: 374px) { .date-range-input__calendarContainer_1g9ps {
|
|
59
59
|
width: 100%;
|
|
60
60
|
min-width: 288px
|
|
61
61
|
}
|
|
62
|
-
} .date-range-
|
|
62
|
+
} .date-range-input__calendarResponsive_1g9ps {
|
|
63
63
|
width: var(--calendar-width);
|
|
64
|
-
} .date-range-
|
|
64
|
+
} .date-range-input__block_1g9ps {
|
|
65
65
|
width: 100%;
|
|
66
|
-
} .date-range-
|
|
66
|
+
} .date-range-input__calendarIcon_1g9ps {
|
|
67
67
|
margin-right: var(--gap-12-neg);
|
|
68
68
|
height: 100%;
|
|
69
69
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ConditionalProps, DateRangeInputProps } from "./components/date-range-input/index";
|
|
4
|
+
type DateRangeInputResponsiveProps = Omit<DateRangeInputProps, 'view' | 'picker' | 'onClose' | 'InputComponent'> & ConditionalProps & {
|
|
5
|
+
/**
|
|
6
|
+
* Контрольная точка, с нее начинается desktop версия
|
|
7
|
+
* @default 1024
|
|
8
|
+
*/
|
|
9
|
+
breakpoint?: number;
|
|
10
|
+
};
|
|
11
|
+
type DateRangeInputMedia = 'desktop' | 'mobile';
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated
|
|
14
|
+
* use UniversalDateInput instead
|
|
15
|
+
*/
|
|
16
|
+
declare const DateRangeInputResponsive: React.ForwardRefExoticComponent<DateRangeInputResponsiveProps & React.RefAttributes<HTMLInputElement>>;
|
|
17
|
+
export { DateRangeInputResponsiveProps, DateRangeInputMedia, DateRangeInputResponsive };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { useMedia } from '@alfalab/hooks';
|
|
3
|
+
import { DateRangeInputDesktop } from './desktop/Component.desktop.js';
|
|
4
|
+
import { DateRangeInputMobile } from './mobile/Component.mobile.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated
|
|
8
|
+
* use UniversalDateInput instead
|
|
9
|
+
*/
|
|
10
|
+
const DateRangeInputResponsive = forwardRef(({ breakpoint = 1024, ...restProps }, ref) => {
|
|
11
|
+
const [view] = useMedia([
|
|
12
|
+
['mobile', `(max-width: ${breakpoint - 1}px)`],
|
|
13
|
+
['desktop', `(min-width: ${breakpoint}px)`],
|
|
14
|
+
], 'desktop');
|
|
15
|
+
return view === 'desktop' ? (React.createElement(DateRangeInputDesktop, { ...restProps, ref: ref })) : (React.createElement(DateRangeInputMobile, { ...restProps, ref: ref }));
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export { DateRangeInputResponsive };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ChangeEvent, ElementType } from "react";
|
|
4
|
+
import { CalendarDesktopProps } from "@alfalab/core-components-calendar/desktop";
|
|
5
|
+
import { CalendarMobileProps } from "@alfalab/core-components-calendar/mobile";
|
|
6
|
+
import { InputProps } from "@alfalab/core-components-input";
|
|
7
|
+
import { PopoverProps } from "@alfalab/core-components-popover";
|
|
8
|
+
type ConditionalProps = {
|
|
9
|
+
/**
|
|
10
|
+
* Обработчик изменения значения
|
|
11
|
+
*/
|
|
12
|
+
picker: true;
|
|
13
|
+
/**
|
|
14
|
+
* Обработчик закрытия календаря
|
|
15
|
+
*/
|
|
16
|
+
onClose?: () => void;
|
|
17
|
+
} | {
|
|
18
|
+
picker?: false;
|
|
19
|
+
onClose?: never;
|
|
20
|
+
};
|
|
21
|
+
type DateRangeInputProps = Omit<InputProps, 'onChange'> & ConditionalProps & {
|
|
22
|
+
/**
|
|
23
|
+
* Дополнительный класс
|
|
24
|
+
*/
|
|
25
|
+
className?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Дополнительный класс для инпута
|
|
28
|
+
*/
|
|
29
|
+
inputClassName?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Дополнительный класс для поповера
|
|
32
|
+
*/
|
|
33
|
+
popoverClassName?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Обработчик изменения значения
|
|
36
|
+
*/
|
|
37
|
+
onChange?: (payload: {
|
|
38
|
+
dateFrom?: Date;
|
|
39
|
+
dateTo?: Date;
|
|
40
|
+
value: string;
|
|
41
|
+
}, event?: ChangeEvent<HTMLInputElement>) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Обработчик окончания ввода
|
|
44
|
+
*/
|
|
45
|
+
onComplete?: (payload: {
|
|
46
|
+
dateFrom: Date;
|
|
47
|
+
dateTo: Date;
|
|
48
|
+
value: string;
|
|
49
|
+
}, event?: ChangeEvent<HTMLInputElement>) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Компонент календаря
|
|
52
|
+
*/
|
|
53
|
+
Calendar?: ElementType;
|
|
54
|
+
/**
|
|
55
|
+
* Доп. пропсы для календаря
|
|
56
|
+
*/
|
|
57
|
+
calendarProps?: (CalendarDesktopProps & Record<string, unknown>) | (CalendarMobileProps & Record<string, unknown>);
|
|
58
|
+
/**
|
|
59
|
+
* Месяц в календаре по умолчанию (timestamp)
|
|
60
|
+
*/
|
|
61
|
+
defaultMonth?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Минимальная дата, доступная для выбора (timestamp)
|
|
64
|
+
*/
|
|
65
|
+
minDate?: number;
|
|
66
|
+
/**
|
|
67
|
+
* Максимальная дата, доступная для выбора (timestamp)
|
|
68
|
+
*/
|
|
69
|
+
maxDate?: number;
|
|
70
|
+
/**
|
|
71
|
+
* Список событий
|
|
72
|
+
*/
|
|
73
|
+
events?: Array<Date | number>;
|
|
74
|
+
/**
|
|
75
|
+
* Список выходных
|
|
76
|
+
*/
|
|
77
|
+
offDays?: Array<Date | number>;
|
|
78
|
+
/**
|
|
79
|
+
* Состояние открытия по умолчанию
|
|
80
|
+
*/
|
|
81
|
+
defaultOpen?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Позиционирование поповера с календарем
|
|
84
|
+
*/
|
|
85
|
+
popoverPosition?: PopoverProps['position'];
|
|
86
|
+
/**
|
|
87
|
+
* z-index Popover
|
|
88
|
+
*/
|
|
89
|
+
zIndexPopover?: PopoverProps['zIndex'];
|
|
90
|
+
/**
|
|
91
|
+
* Запрещает поповеру менять свою позицию.
|
|
92
|
+
* Например, если места снизу недостаточно, то он все равно будет показан снизу
|
|
93
|
+
*/
|
|
94
|
+
preventFlip?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Календарь будет принимать ширину инпута
|
|
97
|
+
*/
|
|
98
|
+
useAnchorWidth?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Растягивает компонент на ширину контейнера
|
|
101
|
+
*/
|
|
102
|
+
block?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Отображение компонента в мобильном или десктопном виде
|
|
105
|
+
*/
|
|
106
|
+
view?: 'desktop' | 'mobile';
|
|
107
|
+
/**
|
|
108
|
+
* Компонент инпута
|
|
109
|
+
*/
|
|
110
|
+
InputComponent?: ElementType;
|
|
111
|
+
/**
|
|
112
|
+
* Запретить ввод с клавиатуры
|
|
113
|
+
*/
|
|
114
|
+
disableUserInput?: boolean;
|
|
115
|
+
};
|
|
116
|
+
declare const DateRangeInput: React.ForwardRefExoticComponent<DateRangeInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
117
|
+
export { ConditionalProps, DateRangeInputProps, DateRangeInput };
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import React, { useRef, useState, useEffect } from 'react';
|
|
2
|
+
import mergeRefs from 'react-merge-refs';
|
|
3
|
+
import cn from 'classnames';
|
|
4
|
+
import dateFnsIsValid from 'date-fns/isValid';
|
|
5
|
+
import startOfMonth from 'date-fns/startOfMonth';
|
|
6
|
+
import { usePeriod } from '@alfalab/core-components-calendar/moderncssm/shared';
|
|
7
|
+
import { IconButton } from '@alfalab/core-components-icon-button/moderncssm';
|
|
8
|
+
import { Popover } from '@alfalab/core-components-popover/moderncssm';
|
|
9
|
+
import { useDidUpdateEffect } from '@alfalab/hooks';
|
|
10
|
+
import { CalendarMIcon } from '@alfalab/icons-glyph/CalendarMIcon';
|
|
11
|
+
import { parseTimestampToDate, DATE_FORMAT, format, parseDateString, DATE_MASK, isCompleteDateInput, isValid } from '../../utils/format.js';
|
|
12
|
+
import styles from './index.module.css';
|
|
13
|
+
|
|
14
|
+
/* eslint-disable no-useless-escape, jsx-a11y/click-events-have-key-events */
|
|
15
|
+
const DateRangeInput = React.forwardRef(({ className, inputClassName, popoverClassName, disabled, readOnly, disableUserInput = false, picker, defaultValue = '', value: propValue, onChange, onComplete, onClose, rightAddons, useAnchorWidth, block, popoverPosition = 'bottom-start', zIndexPopover, preventFlip, InputComponent, Calendar, calendarProps = {}, defaultMonth, minDate = calendarProps.minDate, maxDate = calendarProps.maxDate, offDays = calendarProps.offDays || [], events = calendarProps.events || [], defaultOpen = false, view = 'desktop', ...restProps }, ref) => {
|
|
16
|
+
const inputRef = useRef(null);
|
|
17
|
+
const iconRef = useRef(null);
|
|
18
|
+
const calendarRef = useRef(null);
|
|
19
|
+
const [value, setValue] = useState(propValue || defaultValue);
|
|
20
|
+
const [open, setOpen] = useState(defaultOpen);
|
|
21
|
+
const inputDisabled = disabled || readOnly;
|
|
22
|
+
const calendarResponsive = calendarProps?.responsive ?? true;
|
|
23
|
+
const { selectedFrom, selectedTo, updatePeriod, resetPeriod, setStart, setEnd } = usePeriod({ onPeriodChange: handlePeriodChange });
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (value) {
|
|
26
|
+
setCalendarPeriod(getDates(value));
|
|
27
|
+
}
|
|
28
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29
|
+
}, []);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
setValue((prevValue) => {
|
|
32
|
+
if (selectedFrom && selectedTo) {
|
|
33
|
+
const from = parseTimestampToDate(selectedFrom);
|
|
34
|
+
const to = parseTimestampToDate(selectedTo);
|
|
35
|
+
return `${from} - ${to}`;
|
|
36
|
+
}
|
|
37
|
+
if (selectedFrom && prevValue.length < DATE_FORMAT.length) {
|
|
38
|
+
return parseTimestampToDate(selectedFrom);
|
|
39
|
+
}
|
|
40
|
+
return prevValue;
|
|
41
|
+
});
|
|
42
|
+
}, [selectedFrom, selectedTo]);
|
|
43
|
+
useDidUpdateEffect(() => {
|
|
44
|
+
const newPropValue = propValue || '';
|
|
45
|
+
setValue((prevValue) => {
|
|
46
|
+
if (prevValue === newPropValue) {
|
|
47
|
+
return prevValue;
|
|
48
|
+
}
|
|
49
|
+
const dates = getDates(newPropValue);
|
|
50
|
+
setCalendarPeriod(dates);
|
|
51
|
+
return dates.formattedValue;
|
|
52
|
+
});
|
|
53
|
+
}, [propValue]);
|
|
54
|
+
function getDates(val) {
|
|
55
|
+
const formattedValue = format(val);
|
|
56
|
+
const dateArr = formattedValue.split('-').map((v) => v.trim());
|
|
57
|
+
const dateFrom = dateArr[0] ? parseDateString(dateArr[0]) : undefined;
|
|
58
|
+
const dateTo = dateArr[1] ? parseDateString(dateArr[1]) : undefined;
|
|
59
|
+
return { formattedValue, dateFrom, dateTo, dateArr };
|
|
60
|
+
}
|
|
61
|
+
function setCalendarPeriod({ dateFrom, dateTo }) {
|
|
62
|
+
setStart(dateFrom?.getTime());
|
|
63
|
+
setEnd(dateTo?.getTime());
|
|
64
|
+
}
|
|
65
|
+
function handlePeriodChange(from, to) {
|
|
66
|
+
if (from && !to && value.length === DATE_MASK.length) {
|
|
67
|
+
setValue(parseTimestampToDate(from));
|
|
68
|
+
}
|
|
69
|
+
else if ((!from && !to && value.length === DATE_FORMAT.length) ||
|
|
70
|
+
(from === to && value.length === DATE_MASK.length)) {
|
|
71
|
+
setValue('');
|
|
72
|
+
}
|
|
73
|
+
const dateFrom = from ? new Date(from) : undefined;
|
|
74
|
+
const dateTo = to ? new Date(to) : undefined;
|
|
75
|
+
const newValue = [from, to].filter(Boolean)
|
|
76
|
+
.map((timestamp) => parseTimestampToDate(timestamp))
|
|
77
|
+
.join(' - ');
|
|
78
|
+
onChange?.({
|
|
79
|
+
dateFrom,
|
|
80
|
+
dateTo,
|
|
81
|
+
value: newValue,
|
|
82
|
+
});
|
|
83
|
+
if (dateFrom && dateTo) {
|
|
84
|
+
onComplete?.({
|
|
85
|
+
dateFrom,
|
|
86
|
+
dateTo,
|
|
87
|
+
value: newValue,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const handleInputWrapperFocus = (event) => {
|
|
92
|
+
if (view === 'desktop') {
|
|
93
|
+
if (picker) {
|
|
94
|
+
setOpen(true);
|
|
95
|
+
}
|
|
96
|
+
if (!open && event.target.tagName !== 'INPUT' && calendarRef.current) {
|
|
97
|
+
calendarRef.current.focus();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const handleBlur = (event) => {
|
|
102
|
+
if (view === 'desktop') {
|
|
103
|
+
const target = (event.relatedTarget || document.activeElement);
|
|
104
|
+
if (calendarRef.current?.contains(target) === false &&
|
|
105
|
+
inputRef.current?.contains(target) === false &&
|
|
106
|
+
iconRef.current?.contains(target) === false) {
|
|
107
|
+
setOpen(false);
|
|
108
|
+
if (onClose) {
|
|
109
|
+
onClose();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
// eslint-disable-next-line complexity
|
|
115
|
+
const handleChange = (event) => {
|
|
116
|
+
const { value: newValue } = event.target;
|
|
117
|
+
if (newValue.length > DATE_MASK.length)
|
|
118
|
+
return;
|
|
119
|
+
// Позволяем вводить только цифры, точки, дефис и пробелы
|
|
120
|
+
if (/[^\d. -]/.test(newValue)) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const dots = newValue.match(/\./g);
|
|
124
|
+
const hyphen = newValue.match(/\-/g);
|
|
125
|
+
// Не даем вводить больше, чем 4 точки и 1 дефис
|
|
126
|
+
if ((dots && dots.length > 4) || (hyphen && hyphen.length > 1)) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const { formattedValue, dateFrom, dateTo, dateArr } = getDates(newValue);
|
|
130
|
+
if (!dateFrom && !dateTo) {
|
|
131
|
+
resetPeriod();
|
|
132
|
+
}
|
|
133
|
+
else if (selectedFrom && formattedValue.length < DATE_FORMAT.length) {
|
|
134
|
+
setStart();
|
|
135
|
+
}
|
|
136
|
+
else if (selectedFrom && selectedTo) {
|
|
137
|
+
setEnd();
|
|
138
|
+
}
|
|
139
|
+
else if (dateFrom &&
|
|
140
|
+
dateFnsIsValid(dateFrom) &&
|
|
141
|
+
dateArr[0]?.length === DATE_FORMAT.length &&
|
|
142
|
+
dateFrom.getTime() !== selectedFrom) {
|
|
143
|
+
setStart(dateFrom.getTime());
|
|
144
|
+
}
|
|
145
|
+
else if (dateTo &&
|
|
146
|
+
dateFnsIsValid(dateTo) &&
|
|
147
|
+
dateArr[1]?.length === DATE_FORMAT.length &&
|
|
148
|
+
dateTo.getTime() !== selectedTo) {
|
|
149
|
+
setEnd(dateTo.getTime());
|
|
150
|
+
}
|
|
151
|
+
setValue(formattedValue);
|
|
152
|
+
onChange?.({ dateFrom, dateTo, value: formattedValue }, event);
|
|
153
|
+
if (isCompleteDateInput(formattedValue)) {
|
|
154
|
+
const valid = isValid(formattedValue, dateArr[0], dateArr[1]);
|
|
155
|
+
if (!valid)
|
|
156
|
+
return;
|
|
157
|
+
if (dateFrom && dateTo) {
|
|
158
|
+
onComplete?.({ dateFrom, dateTo, value: formattedValue }, event);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
const handleCalendarClose = () => {
|
|
163
|
+
if (view === 'mobile' && onClose) {
|
|
164
|
+
onClose();
|
|
165
|
+
}
|
|
166
|
+
setOpen(false);
|
|
167
|
+
};
|
|
168
|
+
const handleClear = () => {
|
|
169
|
+
setValue('');
|
|
170
|
+
resetPeriod();
|
|
171
|
+
};
|
|
172
|
+
const handleCalendarChange = (date) => {
|
|
173
|
+
updatePeriod(date);
|
|
174
|
+
};
|
|
175
|
+
const handleCalendarWrapperMouseDown = (event) => {
|
|
176
|
+
// Не дает инпуту терять фокус при выборе даты
|
|
177
|
+
event.preventDefault();
|
|
178
|
+
};
|
|
179
|
+
const handleIconButtonClick = () => {
|
|
180
|
+
if (!open)
|
|
181
|
+
setOpen(true);
|
|
182
|
+
if (view === 'desktop' && inputRef.current) {
|
|
183
|
+
inputRef.current.focus();
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
const renderCalendar = () => {
|
|
187
|
+
const activeMonth = (selectedTo && startOfMonth(selectedTo)) ||
|
|
188
|
+
(selectedFrom && startOfMonth(selectedFrom));
|
|
189
|
+
return Calendar ? (
|
|
190
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
191
|
+
React.createElement("div", { onMouseDown: handleCalendarWrapperMouseDown },
|
|
192
|
+
React.createElement(Calendar, { ...calendarProps, responsive: calendarResponsive, open: open, onClose: handleCalendarClose, ref: calendarRef, defaultMonth: activeMonth || defaultMonth, selectedFrom: selectedFrom, selectedTo: selectedTo, onChange: handleCalendarChange, minDate: minDate, maxDate: maxDate, offDays: offDays, events: events }))) : null;
|
|
193
|
+
};
|
|
194
|
+
return (React.createElement("div", { className: cn(styles.component, className, {
|
|
195
|
+
[styles.block]: block,
|
|
196
|
+
}), onFocus: inputDisabled ? undefined : handleInputWrapperFocus, onBlur: handleBlur },
|
|
197
|
+
InputComponent ? (React.createElement(InputComponent, { autoComplete: picker ? 'off' : undefined, ...restProps, block: block, ref: mergeRefs([ref, inputRef]), value: value, onChange: handleChange, disabled: disabled, readOnly: readOnly, className: inputClassName, onClear: handleClear, disableUserInput: disableUserInput, rightAddons: React.createElement(React.Fragment, null,
|
|
198
|
+
rightAddons,
|
|
199
|
+
picker && (React.createElement(IconButton, { className: styles.calendarIcon, ref: iconRef, onClick: inputDisabled ? undefined : handleIconButtonClick, icon: CalendarMIcon, size: 's' }))) })) : null,
|
|
200
|
+
picker &&
|
|
201
|
+
(view === 'desktop' ? (React.createElement(Popover, { open: open, useAnchorWidth: useAnchorWidth, anchorElement: inputRef.current, popperClassName: cn(styles.calendarContainer, {
|
|
202
|
+
[styles.calendarResponsive]: calendarResponsive,
|
|
203
|
+
}), className: popoverClassName, position: popoverPosition, offset: [0, 8], withTransition: false, preventFlip: preventFlip, zIndex: zIndexPopover }, renderCalendar())) : (renderCalendar()))));
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
export { DateRangeInput };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Component";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DateRangeInput } from './Component.js';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/* */
|
|
2
|
+
:root {
|
|
3
|
+
--calendar-width: 344px;
|
|
4
|
+
|
|
5
|
+
/* Кнопки выбора месяцев и годов */
|
|
6
|
+
|
|
7
|
+
/* Шапка */
|
|
8
|
+
|
|
9
|
+
/* День */
|
|
10
|
+
|
|
11
|
+
/* today */
|
|
12
|
+
|
|
13
|
+
/* highlighted */
|
|
14
|
+
|
|
15
|
+
/* holidays */
|
|
16
|
+
|
|
17
|
+
/* range */
|
|
18
|
+
|
|
19
|
+
/* selected */
|
|
20
|
+
|
|
21
|
+
/* disabled */
|
|
22
|
+
|
|
23
|
+
/* marker */
|
|
24
|
+
}
|
|
25
|
+
:root {
|
|
26
|
+
--calendar-popover-border-radius: var(--border-radius-m);
|
|
27
|
+
}
|
|
28
|
+
.component {
|
|
29
|
+
display: inline-block;
|
|
30
|
+
outline: none;
|
|
31
|
+
position: relative;
|
|
32
|
+
}
|
|
33
|
+
.calendarContainer {
|
|
34
|
+
display: inline-block;
|
|
35
|
+
box-sizing: border-box;
|
|
36
|
+
border-radius: var(--calendar-popover-border-radius);
|
|
37
|
+
border: 1px solid var(--color-light-neutral-300)
|
|
38
|
+
}
|
|
39
|
+
@media (max-width: 374px) {
|
|
40
|
+
.calendarContainer {
|
|
41
|
+
width: 100%;
|
|
42
|
+
min-width: 288px
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
.calendarResponsive {
|
|
46
|
+
width: var(--calendar-width);
|
|
47
|
+
}
|
|
48
|
+
.block {
|
|
49
|
+
width: 100%;
|
|
50
|
+
}
|
|
51
|
+
.calendarIcon {
|
|
52
|
+
margin-right: var(--gap-12-neg);
|
|
53
|
+
height: 100%;
|
|
54
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ConditionalProps, DateRangeInputProps } from "../components/date-range-input/index";
|
|
4
|
+
type DateRangeInputDesktopProps = Omit<DateRangeInputProps, 'view' | 'picker' | 'onClose' | 'InputComponent'> & ConditionalProps;
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated
|
|
7
|
+
* use UniversalDateInput instead
|
|
8
|
+
*/
|
|
9
|
+
declare const DateRangeInputDesktop: React.ForwardRefExoticComponent<DateRangeInputDesktopProps & React.RefAttributes<HTMLInputElement>>;
|
|
10
|
+
export { DateRangeInputDesktopProps, DateRangeInputDesktop };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { CalendarDesktop } from '@alfalab/core-components-calendar/moderncssm/desktop';
|
|
3
|
+
import { InputDesktop } from '@alfalab/core-components-input/moderncssm/desktop';
|
|
4
|
+
import { DateRangeInput } from '../components/date-range-input/Component.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated
|
|
8
|
+
* use UniversalDateInput instead
|
|
9
|
+
*/
|
|
10
|
+
const DateRangeInputDesktop = forwardRef((props, ref) => (React.createElement(DateRangeInput, { InputComponent: InputDesktop, Calendar: CalendarDesktop, ...props, ref: ref })));
|
|
11
|
+
|
|
12
|
+
export { DateRangeInputDesktop };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DateRangeInputDesktop } from './Component.desktop.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DateRangeInputResponsive as DateRangeInput } from './Component.responsive.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ConditionalProps, DateRangeInputProps } from "../components/date-range-input/index";
|
|
4
|
+
type DateRangeInputMobileProps = Omit<DateRangeInputProps, 'view' | 'picker' | 'onClose' | 'InputComponent'> & ConditionalProps;
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated
|
|
7
|
+
* use UniversalDateInput instead
|
|
8
|
+
*/
|
|
9
|
+
declare const DateRangeInputMobile: React.ForwardRefExoticComponent<DateRangeInputMobileProps & React.RefAttributes<HTMLInputElement>>;
|
|
10
|
+
export { DateRangeInputMobileProps, DateRangeInputMobile };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { CalendarMobile } from '@alfalab/core-components-calendar/moderncssm/mobile';
|
|
3
|
+
import { InputMobile } from '@alfalab/core-components-input/moderncssm/mobile';
|
|
4
|
+
import { DateRangeInput } from '../components/date-range-input/Component.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated
|
|
8
|
+
* use UniversalDateInput instead
|
|
9
|
+
*/
|
|
10
|
+
const DateRangeInputMobile = forwardRef((props, ref) => (React.createElement(DateRangeInput, { InputComponent: InputMobile, Calendar: CalendarMobile, view: 'mobile', ...props, ref: ref })));
|
|
11
|
+
|
|
12
|
+
export { DateRangeInputMobile };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DateRangeInputMobile } from './Component.mobile.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const DATE_FORMAT = "dd.MM.yyyy";
|
|
2
|
+
declare const DATE_MASK: (string | RegExp)[];
|
|
3
|
+
declare const isCompleteDateInput: (input: string) => boolean;
|
|
4
|
+
declare const parseDateString: (value: string, dateFormat?: string) => Date;
|
|
5
|
+
declare const isValid: (inputValue: string, dateFrom: string, dateTo: string) => boolean;
|
|
6
|
+
declare const format: (value: string) => string;
|
|
7
|
+
declare const parseTimestampToDate: (timestamp: number) => string;
|
|
8
|
+
export { DATE_FORMAT, DATE_MASK, isCompleteDateInput, parseDateString, isValid, format, parseTimestampToDate };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import dateFnsIsValid from 'date-fns/isValid';
|
|
2
|
+
import parse from 'date-fns/parse';
|
|
3
|
+
|
|
4
|
+
/* eslint-disable no-useless-escape */
|
|
5
|
+
const DATE_FORMAT = 'dd.MM.yyyy';
|
|
6
|
+
const DATE_MASK = [
|
|
7
|
+
/\d/,
|
|
8
|
+
/\d/,
|
|
9
|
+
'.',
|
|
10
|
+
/\d/,
|
|
11
|
+
/\d/,
|
|
12
|
+
'.',
|
|
13
|
+
/\d/,
|
|
14
|
+
/\d/,
|
|
15
|
+
/\d/,
|
|
16
|
+
/\d/,
|
|
17
|
+
' ',
|
|
18
|
+
'-',
|
|
19
|
+
' ',
|
|
20
|
+
/\d/,
|
|
21
|
+
/\d/,
|
|
22
|
+
'.',
|
|
23
|
+
/\d/,
|
|
24
|
+
/\d/,
|
|
25
|
+
'.',
|
|
26
|
+
/\d/,
|
|
27
|
+
/\d/,
|
|
28
|
+
/\d/,
|
|
29
|
+
/\d/,
|
|
30
|
+
];
|
|
31
|
+
const isCompleteDateInput = (input) => input.length === DATE_MASK.length;
|
|
32
|
+
const parseDateString = (value, dateFormat = DATE_FORMAT) => parse(value, dateFormat, new Date());
|
|
33
|
+
const isValid = (inputValue, dateFrom, dateTo) => !inputValue ||
|
|
34
|
+
(isCompleteDateInput(inputValue) &&
|
|
35
|
+
dateFnsIsValid(parseDateString(dateFrom)) &&
|
|
36
|
+
dateFnsIsValid(parseDateString(dateTo)));
|
|
37
|
+
const format = (value) => value
|
|
38
|
+
.replace(/^(\d\d)(\d)$/, '$1.$2') // 121 => 12.1
|
|
39
|
+
.replace(/^(\d\d)\.(\d\d)(\d)$/, '$1.$2.$3') // 12.122 => 12.12.2
|
|
40
|
+
.replace(/^(\d\d)\d\.(.*)/, '$1.$2') // 123.12.2005 => 12.12.2005
|
|
41
|
+
.replace(/^(\d\d\.\d\d)\d\.(.*)/, '$1.$2') // 12.123.2005 => 12.12.2005
|
|
42
|
+
.replace(/\.$/, '') // 12. => 12
|
|
43
|
+
.replace(/\ $/, '') // 1 2 => 12
|
|
44
|
+
.replace(/^(\d\d\.\d\d\.\d\d\d\d)(\d) - (\d.*)/, '$1 - $3') // 12.12.20051 - 12.12.200 => 12.12.2005 - 12.12.200
|
|
45
|
+
.replace(/^(\d\d\.\d\d\.\d\d\d\d) (\d)- (\d.*)/, '$1 - $3') // 12.12.2005 1- 12.12.200 => 12.12.2005 - 12.12.200
|
|
46
|
+
.replace(/^(\d\d\.\d\d\.\d\d\d\d) -(\d) (\d.*)/, '$1 - $3') // 12.12.2005 -1 12.12.200 => 12.12.2005 - 12.12.200
|
|
47
|
+
.replace(/^(\d\d\.\d\d\.\d\d\d\d) - (\d)(\d\d.\d\d.\d\d\d)/, '$1 - $3') // 12.12.2005 - 112.12.200 => 12.12.2005 - 12.12.200
|
|
48
|
+
.replace(/^(\d\d\.\d\d\.\d\d\d\d) - (\d)(\d\d.\d.\d\d\d\d)/, '$1 - $3') // 12.12.2005 - 112.1.2001 => 12.12.2005 - 12.1.2001
|
|
49
|
+
.replace(/^(\d\d\.\d\d)(\d\d\d\d)/, '$1.$2') // 12.122005 => 12.12.2005
|
|
50
|
+
.replace(/^(\d\d)(\d\d\.\d\d\d\d)/, '$1.$2') // 1212.2005 => 12.12.2005
|
|
51
|
+
.replace(/^(\d\d)(\d.*)/, '$1.$2') // 1212 => 12.12
|
|
52
|
+
.replace(/^(\d\d.\d\d)(\d.*)/, '$1.$2') // 12.122 => 12.12.2
|
|
53
|
+
.replace(/^(\d\d\.\d\d\.\d\d\d\d)(\d)/, '$1 - $2') // 12.12.20056 => 12.12.2005 - 6
|
|
54
|
+
.replace(/^(\d\d\.\d\d\.\d\d\d\d) - (\d\d)(\d)/, '$1 - $2.$3') // 12.12.2005 - 123 => 12.12.2005 - 12.3
|
|
55
|
+
.replace(/^(\d\d\.\d\d\.\d\d\d\d) - (\d\d).(\d\d)(\d)/, '$1 - $2.$3.$4') // 12.12.2005 - 12.123 => 12.12.2005 - 12.12.3
|
|
56
|
+
.replace(/^(\d\d\.\d\d\.\d\d\d\d)- (\d.*)/, '$1 - $2') // 12.12.2005- 12.12.2005 => 12.12.2005 - 12.12.2005
|
|
57
|
+
.replace(/^(\d\d\.\d\d\.\d\d\d\d) -(\d.*)/, '$1 - $2') // 12.12.2005 -12.12.2005 => 12.12.2005 - 12.12.2005
|
|
58
|
+
.replace(/^(\d\d\.\d\d\.\d\d\d\d) -/, '$1') // 12.12.2005 - => 12.12.2005
|
|
59
|
+
.replace(/^(\d\d\.\d\d\.\d\d\d\d) (\d.*)/, '$1 - $2') // 12.12.2005 12.12.2005 => 12.12.2005 - 12.12.2005
|
|
60
|
+
.replace(/^(\d\d\.\d\d\.\d\d\d\d) {2}(\d.*)/, '$1 - $2') // 12.12.2005 12.12.2005 => 12.12.2005 - 12.12.2005
|
|
61
|
+
.replace(/^(\d\d\.\d\d\.\d\d\d\d)-/, '$1') // 12.12.2005- => 12.12.2005
|
|
62
|
+
.replace(/^(\d\.\d\d\.\d\d\d\d)([0-9]*)/, '$1') // 1.12.2005123123 => 1.12.2005
|
|
63
|
+
.replace(/^(\d\d\.\d\.\d\d\d\d)([0-9]*)/, '$1') // 01.2.20055125125 => 01.2.2005
|
|
64
|
+
.replace(/^(\d)\.(\d\d)([0-9]*)\.(\d\d\d\d)/, '$1.$2.$4') // 1.123123.2005 => 1.12.2005
|
|
65
|
+
.replace(/^(\d\.\d\.\d\d\d\d)([0-9]*)/, '$1') // 1.2.20055125125 => 1.2.2005
|
|
66
|
+
.replace(/^()\.(\d)\.(\d\d\d\d)([0-9]*)/, '$1.$2.$3'); // .2.2005123123 => .2.2005
|
|
67
|
+
const parseTimestampToDate = (timestamp) => {
|
|
68
|
+
const date = new Date(timestamp);
|
|
69
|
+
const year = date.getFullYear();
|
|
70
|
+
let month = date.getMonth() + 1;
|
|
71
|
+
let day = date.getDate();
|
|
72
|
+
if (month < 10) {
|
|
73
|
+
month = `0${month}`;
|
|
74
|
+
}
|
|
75
|
+
if (day < 10) {
|
|
76
|
+
day = `0${day}`;
|
|
77
|
+
}
|
|
78
|
+
return `${day}.${month}.${year}`;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export { DATE_FORMAT, DATE_MASK, format, isCompleteDateInput, isValid, parseDateString, parseTimestampToDate };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./format";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DATE_FORMAT, DATE_MASK, format, isCompleteDateInput, isValid, parseDateString, parseTimestampToDate } from './format.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfalab/core-components-date-range-input",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
"react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@alfalab/core-components-input": "^15.0
|
|
19
|
-
"@alfalab/core-components-icon-button": "^6.
|
|
20
|
-
"@alfalab/core-components-calendar": "^7.
|
|
21
|
-
"@alfalab/core-components-popover": "^6.
|
|
18
|
+
"@alfalab/core-components-input": "^15.1.0",
|
|
19
|
+
"@alfalab/core-components-icon-button": "^6.8.0",
|
|
20
|
+
"@alfalab/core-components-calendar": "^7.11.0",
|
|
21
|
+
"@alfalab/core-components-popover": "^6.3.0",
|
|
22
22
|
"@alfalab/hooks": "^1.13.0",
|
|
23
23
|
"@alfalab/icons-glyph": "^2.139.0",
|
|
24
24
|
"classnames": "^2.3.1",
|
|
@@ -26,6 +26,6 @@
|
|
|
26
26
|
"react-merge-refs": "^1.1.0",
|
|
27
27
|
"tslib": "^2.4.0"
|
|
28
28
|
},
|
|
29
|
-
"themesVersion": "13.0
|
|
30
|
-
"varsVersion": "9.
|
|
29
|
+
"themesVersion": "13.1.0",
|
|
30
|
+
"varsVersion": "9.12.0"
|
|
31
31
|
}
|