@atlaskit/datetime-picker 17.6.4 → 17.7.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/CHANGELOG.md +13 -0
- package/dist/cjs/components/date-picker.js +16 -11
- package/dist/cjs/components/date-time-picker-fc.js +472 -8
- package/dist/cjs/internal/convert-to24hr-time.js +66 -0
- package/dist/cjs/internal/format-date.js +39 -0
- package/dist/cjs/internal/{date-picker-migration.js → get-parsed-iso.js} +1 -45
- package/dist/cjs/internal/get-placeholder.js +32 -0
- package/dist/cjs/internal/get-safe-calendar-value.js +18 -0
- package/dist/cjs/internal/get-short-iso-string.js +13 -0
- package/dist/cjs/internal/is-date-disabled.js +29 -0
- package/dist/cjs/internal/is-valid.js +39 -0
- package/dist/cjs/internal/parse-date.js +31 -20
- package/dist/cjs/internal/parse-time.js +6 -102
- package/dist/cjs/internal/remove-spacer.js +9 -0
- package/dist/es2019/components/date-picker.js +7 -2
- package/dist/es2019/components/date-time-picker-fc.js +454 -5
- package/dist/es2019/internal/convert-to24hr-time.js +60 -0
- package/dist/es2019/internal/format-date.js +34 -0
- package/dist/es2019/internal/{date-picker-migration.js → get-parsed-iso.js} +2 -54
- package/dist/es2019/internal/get-placeholder.js +28 -0
- package/dist/es2019/internal/get-safe-calendar-value.js +11 -0
- package/dist/es2019/internal/get-short-iso-string.js +6 -0
- package/dist/es2019/internal/is-date-disabled.js +25 -0
- package/dist/es2019/internal/is-valid.js +33 -0
- package/dist/es2019/internal/parse-date.js +33 -18
- package/dist/es2019/internal/parse-time.js +3 -96
- package/dist/es2019/internal/remove-spacer.js +3 -0
- package/dist/esm/components/date-picker.js +7 -2
- package/dist/esm/components/date-time-picker-fc.js +471 -7
- package/dist/esm/internal/convert-to24hr-time.js +60 -0
- package/dist/esm/internal/format-date.js +32 -0
- package/dist/esm/internal/{date-picker-migration.js → get-parsed-iso.js} +2 -46
- package/dist/esm/internal/get-placeholder.js +26 -0
- package/dist/esm/internal/get-safe-calendar-value.js +11 -0
- package/dist/esm/internal/get-short-iso-string.js +6 -0
- package/dist/esm/internal/is-date-disabled.js +23 -0
- package/dist/esm/internal/is-valid.js +33 -0
- package/dist/esm/internal/parse-date.js +31 -18
- package/dist/esm/internal/parse-time.js +3 -96
- package/dist/esm/internal/remove-spacer.js +3 -0
- package/dist/types/components/date-time-picker-fc.d.ts +6 -2
- package/dist/types/internal/convert-to24hr-time.d.ts +7 -0
- package/dist/types/internal/{date-picker-migration.d.ts → format-date.d.ts} +0 -28
- package/dist/types/internal/get-parsed-iso.d.ts +20 -0
- package/dist/types/internal/get-placeholder.d.ts +22 -0
- package/dist/types/internal/get-safe-calendar-value.d.ts +1 -0
- package/dist/types/internal/get-short-iso-string.d.ts +1 -0
- package/dist/types/internal/is-date-disabled.d.ts +20 -0
- package/dist/types/internal/is-valid.d.ts +1 -0
- package/dist/types/internal/parse-date.d.ts +26 -5
- package/dist/types/internal/parse-time.d.ts +0 -9
- package/dist/types/internal/remove-spacer.d.ts +1 -0
- package/dist/types-ts4.5/components/date-time-picker-fc.d.ts +6 -2
- package/dist/types-ts4.5/internal/convert-to24hr-time.d.ts +7 -0
- package/dist/types-ts4.5/internal/{date-picker-migration.d.ts → format-date.d.ts} +0 -28
- package/dist/types-ts4.5/internal/get-parsed-iso.d.ts +20 -0
- package/dist/types-ts4.5/internal/get-placeholder.d.ts +22 -0
- package/dist/types-ts4.5/internal/get-safe-calendar-value.d.ts +1 -0
- package/dist/types-ts4.5/internal/get-short-iso-string.d.ts +1 -0
- package/dist/types-ts4.5/internal/is-date-disabled.d.ts +20 -0
- package/dist/types-ts4.5/internal/is-valid.d.ts +1 -0
- package/dist/types-ts4.5/internal/parse-date.d.ts +26 -5
- package/dist/types-ts4.5/internal/parse-time.d.ts +0 -9
- package/dist/types-ts4.5/internal/remove-spacer.d.ts +1 -0
- package/package.json +10 -13
- package/dist/cjs/components/date-time-picker-fc-new.js +0 -479
- package/dist/cjs/components/date-time-picker-fc-old.js +0 -370
- package/dist/es2019/components/date-time-picker-fc-new.js +0 -456
- package/dist/es2019/components/date-time-picker-fc-old.compiled.css +0 -6
- package/dist/es2019/components/date-time-picker-fc-old.js +0 -336
- package/dist/esm/components/date-time-picker-fc-new.compiled.css +0 -6
- package/dist/esm/components/date-time-picker-fc-new.js +0 -473
- package/dist/esm/components/date-time-picker-fc-old.compiled.css +0 -6
- package/dist/esm/components/date-time-picker-fc-old.js +0 -364
- package/dist/types/components/date-time-picker-fc-new.d.ts +0 -6
- package/dist/types/components/date-time-picker-fc-old.d.ts +0 -6
- package/dist/types-ts4.5/components/date-time-picker-fc-new.d.ts +0 -6
- package/dist/types-ts4.5/components/date-time-picker-fc-old.d.ts +0 -6
- /package/dist/cjs/components/{date-time-picker-fc-new.compiled.css → date-time-picker-fc.compiled.css} +0 -0
- /package/dist/{cjs/components/date-time-picker-fc-old.compiled.css → es2019/components/date-time-picker-fc.compiled.css} +0 -0
- /package/dist/{es2019/components/date-time-picker-fc-new.compiled.css → esm/components/date-time-picker-fc.compiled.css} +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Everything in this file is to smooth out the migration of the new date picker
|
|
3
|
+
* (https://product-fabric.atlassian.net/browse/DSP-20682). When that ticket is
|
|
4
|
+
* complete, all of these functions will ilkely be merged back into the date
|
|
5
|
+
* picker. Please do not pre-optimize and put these back into the date picker
|
|
6
|
+
* unless you are working on the DTP Refresh and you have a good reason to do
|
|
7
|
+
* so, thank you!
|
|
8
|
+
*
|
|
9
|
+
* All variables within the `di` objects are dependency injections. They should
|
|
10
|
+
* be read from within the component at the end of the day. But because we are
|
|
11
|
+
* extracting them, we have to inject them in every place manually. When we
|
|
12
|
+
* re-introduce them to the components, we can likely remove the `di` variables
|
|
13
|
+
* and instead use internal variables.
|
|
14
|
+
*
|
|
15
|
+
* If component _only_ has injected variables, it is fully internal and was
|
|
16
|
+
* broken out to be it's own function.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
// oxlint-disable-next-line @atlassian/no-restricted-imports
|
|
20
|
+
export const isDateDisabled = (date, di) => {
|
|
21
|
+
const {
|
|
22
|
+
disabled
|
|
23
|
+
} = di;
|
|
24
|
+
return disabled.indexOf(date) > -1;
|
|
25
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export function isValid(timeString) {
|
|
2
|
+
/**
|
|
3
|
+
* Regex match for `12:34`, `12:34:56`, `1:23:56 p`, `1:23:56PM`, and a bit more…
|
|
4
|
+
*/
|
|
5
|
+
const time = timeString.trim().match(/([012]?[\d])(?::([0-5][\d]))?(?::([0-5][\d]))?\s*([ap]m?)?/i);
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Regex match for `1234`, `12:34`, `12.34`, `123456`, `12:34:56`, `12.34.56`
|
|
9
|
+
*/
|
|
10
|
+
const time24hr = timeString.trim().match(/([012][\d])[:.]?([0-5][\d])([:.]?([0-5][\d]))?/);
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Convert `2:34:56 pm` down to `23456`
|
|
14
|
+
*/
|
|
15
|
+
const num = timeString.replace(/[^0-9]/g, '');
|
|
16
|
+
const includesSeconds = time && time[1] !== undefined && time[2] !== undefined && time[3] !== undefined || time24hr && time24hr[1] !== undefined && time24hr[2] !== undefined && time24hr[4] !== undefined;
|
|
17
|
+
if (!time && !time24hr) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
if (time && !time[1]) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
if (num.length > 6) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
if (num.length > 4 && !includesSeconds) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
if (num.length === 2 && parseInt(num, 10) > 12) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
@@ -1,22 +1,37 @@
|
|
|
1
|
-
// oxlint-disable-next-line @atlassian/no-restricted-imports
|
|
2
|
-
import { format } from 'date-fns';
|
|
3
|
-
import { convertTokens } from './parse-tokens';
|
|
4
|
-
|
|
5
1
|
/**
|
|
6
|
-
*
|
|
2
|
+
* Everything in this file is to smooth out the migration of the new date picker
|
|
3
|
+
* (https://product-fabric.atlassian.net/browse/DSP-20682). When that ticket is
|
|
4
|
+
* complete, all of these functions will ilkely be merged back into the date
|
|
5
|
+
* picker. Please do not pre-optimize and put these back into the date picker
|
|
6
|
+
* unless you are working on the DTP Refresh and you have a good reason to do
|
|
7
|
+
* so, thank you!
|
|
8
|
+
*
|
|
9
|
+
* All variables within the `di` objects are dependency injections. They should
|
|
10
|
+
* be read from within the component at the end of the day. But because we are
|
|
11
|
+
* extracting them, we have to inject them in every place manually. When we
|
|
12
|
+
* re-introduce them to the components, we can likely remove the `di` variables
|
|
13
|
+
* and instead use internal variables.
|
|
7
14
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
15
|
+
* If component _only_ has injected variables, it is fully internal and was
|
|
16
|
+
* broken out to be it's own function.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { defaultDateFormat } from './index';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* There are two props that can change how the date is parsed.
|
|
23
|
+
* The priority of props used is:
|
|
24
|
+
* 1. `parseInputValue`
|
|
25
|
+
* 2. `locale`
|
|
10
26
|
*/
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return getShortISOString(new Date());
|
|
27
|
+
export const parseDate = (date, di) => {
|
|
28
|
+
const {
|
|
29
|
+
parseInputValue,
|
|
30
|
+
dateFormat,
|
|
31
|
+
l10n
|
|
32
|
+
} = di;
|
|
33
|
+
if (parseInputValue) {
|
|
34
|
+
return parseInputValue(date, dateFormat || defaultDateFormat);
|
|
20
35
|
}
|
|
21
|
-
return
|
|
22
|
-
}
|
|
36
|
+
return l10n.parseDate(date);
|
|
37
|
+
};
|
|
@@ -1,99 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
'02': '14',
|
|
5
|
-
'03': '15',
|
|
6
|
-
'04': '16',
|
|
7
|
-
'05': '17',
|
|
8
|
-
'06': '18',
|
|
9
|
-
'07': '19',
|
|
10
|
-
'08': '20',
|
|
11
|
-
'09': '21',
|
|
12
|
-
'10': '22',
|
|
13
|
-
'11': '23'
|
|
14
|
-
};
|
|
15
|
-
export function isValid(timeString) {
|
|
16
|
-
/**
|
|
17
|
-
* Regex match for `12:34`, `12:34:56`, `1:23:56 p`, `1:23:56PM`, and a bit more…
|
|
18
|
-
*/
|
|
19
|
-
const time = timeString.trim().match(/([012]?[\d])(?::([0-5][\d]))?(?::([0-5][\d]))?\s*([ap]m?)?/i);
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Regex match for `1234`, `12:34`, `12.34`, `123456`, `12:34:56`, `12.34.56`
|
|
23
|
-
*/
|
|
24
|
-
const time24hr = timeString.trim().match(/([012][\d])[:.]?([0-5][\d])([:.]?([0-5][\d]))?/);
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Convert `2:34:56 pm` down to `23456`
|
|
28
|
-
*/
|
|
29
|
-
const num = timeString.replace(/[^0-9]/g, '');
|
|
30
|
-
const includesSeconds = time && time[1] !== undefined && time[2] !== undefined && time[3] !== undefined || time24hr && time24hr[1] !== undefined && time24hr[2] !== undefined && time24hr[4] !== undefined;
|
|
31
|
-
if (!time && !time24hr) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
if (time && !time[1]) {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
if (num.length > 6) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
if (num.length > 4 && !includesSeconds) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
if (num.length === 2 && parseInt(num, 10) > 12) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
export function removeSpacer(time) {
|
|
49
|
-
return time.replace(/[:.]/g, '');
|
|
50
|
-
}
|
|
51
|
-
function formatSemi24(time) {
|
|
52
|
-
if (time.length === 1) {
|
|
53
|
-
return `0${time}00`;
|
|
54
|
-
}
|
|
55
|
-
if (time.length === 2) {
|
|
56
|
-
return `${time}00`;
|
|
57
|
-
}
|
|
58
|
-
if (time.length === 3 || time.length === 5) {
|
|
59
|
-
return `0${time}`;
|
|
60
|
-
}
|
|
61
|
-
return time;
|
|
62
|
-
}
|
|
63
|
-
function checkHour(hour, meridiem) {
|
|
64
|
-
if (hour > '24') {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
if (hour === '12' && meridiem === 'a') {
|
|
68
|
-
return '00';
|
|
69
|
-
}
|
|
70
|
-
if (hour < '12' && meridiem === 'p') {
|
|
71
|
-
return map24[hour];
|
|
72
|
-
}
|
|
73
|
-
return hour;
|
|
74
|
-
}
|
|
75
|
-
function checkMinuteSecond(value) {
|
|
76
|
-
if (value > '59') {
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
return value;
|
|
80
|
-
}
|
|
81
|
-
export function convertTo24hrTime(time) {
|
|
82
|
-
const timeArray = time.toLowerCase().split(/(p|a)/i);
|
|
83
|
-
const meridiem = timeArray[1];
|
|
84
|
-
const semi24 = formatSemi24(timeArray[0].trim());
|
|
85
|
-
const hour = checkHour(semi24.substring(0, 2), meridiem);
|
|
86
|
-
const minute = checkMinuteSecond(semi24.substring(2, 4));
|
|
87
|
-
const seconds = semi24.length === 6 && checkMinuteSecond(semi24.substring(4, 6));
|
|
88
|
-
if (!hour || !minute) {
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
return {
|
|
92
|
-
hour: parseInt(hour, 10),
|
|
93
|
-
minute: parseInt(minute, 10),
|
|
94
|
-
seconds: parseInt(seconds || '0', 10) || 0
|
|
95
|
-
};
|
|
96
|
-
}
|
|
1
|
+
import { convertTo24hrTime } from './convert-to24hr-time';
|
|
2
|
+
import { isValid } from './is-valid';
|
|
3
|
+
import { removeSpacer } from './remove-spacer';
|
|
97
4
|
function assignToDate(time) {
|
|
98
5
|
const dateTime = new Date();
|
|
99
6
|
dateTime.setHours(time.hour);
|
|
@@ -24,10 +24,15 @@ import { createLocalizationProvider } from '@atlaskit/locale';
|
|
|
24
24
|
import { Box } from '@atlaskit/primitives/compiled';
|
|
25
25
|
import Select, { mergeStyles } from '@atlaskit/select';
|
|
26
26
|
import { EmptyComponent } from '../internal';
|
|
27
|
-
import { formatDate
|
|
27
|
+
import { formatDate } from '../internal/format-date';
|
|
28
|
+
import { getParsedISO } from '../internal/get-parsed-iso';
|
|
29
|
+
import { getPlaceholder } from '../internal/get-placeholder';
|
|
30
|
+
import { getSafeCalendarValue } from '../internal/get-safe-calendar-value';
|
|
31
|
+
import { getShortISOString } from '../internal/get-short-iso-string';
|
|
28
32
|
import { IndicatorsContainer as _IndicatorsContainer } from '../internal/indicators-container';
|
|
33
|
+
import { isDateDisabled } from '../internal/is-date-disabled';
|
|
29
34
|
import { Menu } from '../internal/menu';
|
|
30
|
-
import {
|
|
35
|
+
import { parseDate } from '../internal/parse-date';
|
|
31
36
|
import { makeSingleValue } from '../internal/single-value';
|
|
32
37
|
var packageName = "@atlaskit/datetime-picker";
|
|
33
38
|
var packageVersion = "0.0.0-development";
|