@atlaskit/datetime-picker 17.6.5 → 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.
Files changed (87) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/components/date-picker.js +17 -12
  3. package/dist/cjs/components/date-time-picker-class.js +1 -1
  4. package/dist/cjs/components/date-time-picker-fc.js +472 -8
  5. package/dist/cjs/components/time-picker.js +1 -1
  6. package/dist/cjs/internal/convert-to24hr-time.js +66 -0
  7. package/dist/cjs/internal/format-date.js +39 -0
  8. package/dist/cjs/internal/{date-picker-migration.js → get-parsed-iso.js} +1 -45
  9. package/dist/cjs/internal/get-placeholder.js +32 -0
  10. package/dist/cjs/internal/get-safe-calendar-value.js +18 -0
  11. package/dist/cjs/internal/get-short-iso-string.js +13 -0
  12. package/dist/cjs/internal/is-date-disabled.js +29 -0
  13. package/dist/cjs/internal/is-valid.js +39 -0
  14. package/dist/cjs/internal/parse-date.js +31 -20
  15. package/dist/cjs/internal/parse-time.js +6 -102
  16. package/dist/cjs/internal/remove-spacer.js +9 -0
  17. package/dist/es2019/components/date-picker.js +8 -3
  18. package/dist/es2019/components/date-time-picker-class.js +1 -1
  19. package/dist/es2019/components/date-time-picker-fc.js +454 -5
  20. package/dist/es2019/components/time-picker.js +1 -1
  21. package/dist/es2019/internal/convert-to24hr-time.js +60 -0
  22. package/dist/es2019/internal/format-date.js +34 -0
  23. package/dist/es2019/internal/{date-picker-migration.js → get-parsed-iso.js} +2 -54
  24. package/dist/es2019/internal/get-placeholder.js +28 -0
  25. package/dist/es2019/internal/get-safe-calendar-value.js +11 -0
  26. package/dist/es2019/internal/get-short-iso-string.js +6 -0
  27. package/dist/es2019/internal/is-date-disabled.js +25 -0
  28. package/dist/es2019/internal/is-valid.js +33 -0
  29. package/dist/es2019/internal/parse-date.js +33 -18
  30. package/dist/es2019/internal/parse-time.js +3 -96
  31. package/dist/es2019/internal/remove-spacer.js +3 -0
  32. package/dist/esm/components/date-picker.js +8 -3
  33. package/dist/esm/components/date-time-picker-class.js +1 -1
  34. package/dist/esm/components/date-time-picker-fc.js +471 -7
  35. package/dist/esm/components/time-picker.js +1 -1
  36. package/dist/esm/internal/convert-to24hr-time.js +60 -0
  37. package/dist/esm/internal/format-date.js +32 -0
  38. package/dist/esm/internal/{date-picker-migration.js → get-parsed-iso.js} +2 -46
  39. package/dist/esm/internal/get-placeholder.js +26 -0
  40. package/dist/esm/internal/get-safe-calendar-value.js +11 -0
  41. package/dist/esm/internal/get-short-iso-string.js +6 -0
  42. package/dist/esm/internal/is-date-disabled.js +23 -0
  43. package/dist/esm/internal/is-valid.js +33 -0
  44. package/dist/esm/internal/parse-date.js +31 -18
  45. package/dist/esm/internal/parse-time.js +3 -96
  46. package/dist/esm/internal/remove-spacer.js +3 -0
  47. package/dist/types/components/date-time-picker-fc.d.ts +6 -2
  48. package/dist/types/internal/convert-to24hr-time.d.ts +7 -0
  49. package/dist/types/internal/{date-picker-migration.d.ts → format-date.d.ts} +0 -28
  50. package/dist/types/internal/get-parsed-iso.d.ts +20 -0
  51. package/dist/types/internal/get-placeholder.d.ts +22 -0
  52. package/dist/types/internal/get-safe-calendar-value.d.ts +1 -0
  53. package/dist/types/internal/get-short-iso-string.d.ts +1 -0
  54. package/dist/types/internal/is-date-disabled.d.ts +20 -0
  55. package/dist/types/internal/is-valid.d.ts +1 -0
  56. package/dist/types/internal/parse-date.d.ts +26 -5
  57. package/dist/types/internal/parse-time.d.ts +0 -9
  58. package/dist/types/internal/remove-spacer.d.ts +1 -0
  59. package/dist/types-ts4.5/components/date-time-picker-fc.d.ts +6 -2
  60. package/dist/types-ts4.5/internal/convert-to24hr-time.d.ts +7 -0
  61. package/dist/types-ts4.5/internal/{date-picker-migration.d.ts → format-date.d.ts} +0 -28
  62. package/dist/types-ts4.5/internal/get-parsed-iso.d.ts +20 -0
  63. package/dist/types-ts4.5/internal/get-placeholder.d.ts +22 -0
  64. package/dist/types-ts4.5/internal/get-safe-calendar-value.d.ts +1 -0
  65. package/dist/types-ts4.5/internal/get-short-iso-string.d.ts +1 -0
  66. package/dist/types-ts4.5/internal/is-date-disabled.d.ts +20 -0
  67. package/dist/types-ts4.5/internal/is-valid.d.ts +1 -0
  68. package/dist/types-ts4.5/internal/parse-date.d.ts +26 -5
  69. package/dist/types-ts4.5/internal/parse-time.d.ts +0 -9
  70. package/dist/types-ts4.5/internal/remove-spacer.d.ts +1 -0
  71. package/package.json +8 -11
  72. package/dist/cjs/components/date-time-picker-fc-new.js +0 -479
  73. package/dist/cjs/components/date-time-picker-fc-old.js +0 -370
  74. package/dist/es2019/components/date-time-picker-fc-new.js +0 -456
  75. package/dist/es2019/components/date-time-picker-fc-old.compiled.css +0 -6
  76. package/dist/es2019/components/date-time-picker-fc-old.js +0 -336
  77. package/dist/esm/components/date-time-picker-fc-new.compiled.css +0 -6
  78. package/dist/esm/components/date-time-picker-fc-new.js +0 -473
  79. package/dist/esm/components/date-time-picker-fc-old.compiled.css +0 -6
  80. package/dist/esm/components/date-time-picker-fc-old.js +0 -364
  81. package/dist/types/components/date-time-picker-fc-new.d.ts +0 -6
  82. package/dist/types/components/date-time-picker-fc-old.d.ts +0 -6
  83. package/dist/types-ts4.5/components/date-time-picker-fc-new.d.ts +0 -6
  84. package/dist/types-ts4.5/components/date-time-picker-fc-old.d.ts +0 -6
  85. /package/dist/cjs/components/{date-time-picker-fc-new.compiled.css → date-time-picker-fc.compiled.css} +0 -0
  86. /package/dist/{cjs/components/date-time-picker-fc-old.compiled.css → es2019/components/date-time-picker-fc.compiled.css} +0 -0
  87. /package/dist/{es2019/components/date-time-picker-fc-new.compiled.css → esm/components/date-time-picker-fc.compiled.css} +0 -0
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.convertTo24hrTime = convertTo24hrTime;
7
+ var map24 = {
8
+ '12': '12',
9
+ '01': '13',
10
+ '02': '14',
11
+ '03': '15',
12
+ '04': '16',
13
+ '05': '17',
14
+ '06': '18',
15
+ '07': '19',
16
+ '08': '20',
17
+ '09': '21',
18
+ '10': '22',
19
+ '11': '23'
20
+ };
21
+ function formatSemi24(time) {
22
+ if (time.length === 1) {
23
+ return "0".concat(time, "00");
24
+ }
25
+ if (time.length === 2) {
26
+ return "".concat(time, "00");
27
+ }
28
+ if (time.length === 3 || time.length === 5) {
29
+ return "0".concat(time);
30
+ }
31
+ return time;
32
+ }
33
+ function checkHour(hour, meridiem) {
34
+ if (hour > '24') {
35
+ return null;
36
+ }
37
+ if (hour === '12' && meridiem === 'a') {
38
+ return '00';
39
+ }
40
+ if (hour < '12' && meridiem === 'p') {
41
+ return map24[hour];
42
+ }
43
+ return hour;
44
+ }
45
+ function checkMinuteSecond(value) {
46
+ if (value > '59') {
47
+ return null;
48
+ }
49
+ return value;
50
+ }
51
+ function convertTo24hrTime(time) {
52
+ var timeArray = time.toLowerCase().split(/(p|a)/i);
53
+ var meridiem = timeArray[1];
54
+ var semi24 = formatSemi24(timeArray[0].trim());
55
+ var hour = checkHour(semi24.substring(0, 2), meridiem);
56
+ var minute = checkMinuteSecond(semi24.substring(2, 4));
57
+ var seconds = semi24.length === 6 && checkMinuteSecond(semi24.substring(4, 6));
58
+ if (!hour || !minute) {
59
+ return null;
60
+ }
61
+ return {
62
+ hour: parseInt(hour, 10),
63
+ minute: parseInt(minute, 10),
64
+ seconds: parseInt(seconds || '0', 10) || 0
65
+ };
66
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.formatDate = void 0;
7
+ var _dateFns = require("date-fns");
8
+ var _parseTokens = require("./parse-tokens");
9
+ var _index = require("./index");
10
+ /**
11
+ * Everything in this file is to smooth out the migration of the new date picker
12
+ * (https://product-fabric.atlassian.net/browse/DSP-20682). When that ticket is
13
+ * complete, all of these functions will ilkely be merged back into the date
14
+ * picker. Please do not pre-optimize and put these back into the date picker
15
+ * unless you are working on the DTP Refresh and you have a good reason to do
16
+ * so, thank you!
17
+ *
18
+ * All variables within the `di` objects are dependency injections. They should
19
+ * be read from within the component at the end of the day. But because we are
20
+ * extracting them, we have to inject them in every place manually. When we
21
+ * re-introduce them to the components, we can likely remove the `di` variables
22
+ * and instead use internal variables.
23
+ *
24
+ * If component _only_ has injected variables, it is fully internal and was
25
+ * broken out to be it's own function.
26
+ */
27
+
28
+ // oxlint-disable-next-line @atlassian/no-restricted-imports
29
+
30
+ var formatDate = exports.formatDate = function formatDate(value, di) {
31
+ var formatDisplayLabel = di.formatDisplayLabel,
32
+ dateFormat = di.dateFormat,
33
+ l10n = di.l10n;
34
+ if (formatDisplayLabel) {
35
+ return formatDisplayLabel(value, dateFormat || _index.defaultDateFormat);
36
+ }
37
+ var date = (0, _dateFns.parseISO)(value);
38
+ return dateFormat ? (0, _dateFns.format)(date, (0, _parseTokens.convertTokens)(dateFormat)) : l10n.formatDate(date);
39
+ };
@@ -4,10 +4,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.parseDate = exports.isDateDisabled = exports.getPlaceholder = exports.getParsedISO = exports.formatDate = void 0;
7
+ exports.getParsedISO = void 0;
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
9
  var _dateFns = require("date-fns");
10
- var _parseTokens = require("./parse-tokens");
11
10
  var _index = require("./index");
12
11
  /**
13
12
  * Everything in this file is to smooth out the migration of the new date picker
@@ -29,10 +28,6 @@ var _index = require("./index");
29
28
 
30
29
  // oxlint-disable-next-line @atlassian/no-restricted-imports
31
30
 
32
- var isDateDisabled = exports.isDateDisabled = function isDateDisabled(date, di) {
33
- var disabled = di.disabled;
34
- return disabled.indexOf(date) > -1;
35
- };
36
31
  var getParsedISO = exports.getParsedISO = function getParsedISO(di) {
37
32
  var iso = di.iso;
38
33
  var _iso$split = iso.split('-'),
@@ -52,43 +47,4 @@ var getParsedISO = exports.getParsedISO = function getParsedISO(di) {
52
47
  newIso = "".concat(parsedYear, "-").concat((0, _index.padToTwo)(parsedMonth), "-").concat((0, _index.padToTwo)(parsedDate));
53
48
  }
54
49
  return newIso;
55
- };
56
-
57
- /**
58
- * There are two props that can change how the date is parsed.
59
- * The priority of props used is:
60
- * 1. `parseInputValue`
61
- * 2. `locale`
62
- */
63
- var parseDate = exports.parseDate = function parseDate(date, di) {
64
- var parseInputValue = di.parseInputValue,
65
- dateFormat = di.dateFormat,
66
- l10n = di.l10n;
67
- if (parseInputValue) {
68
- return parseInputValue(date, dateFormat || _index.defaultDateFormat);
69
- }
70
- return l10n.parseDate(date);
71
- };
72
-
73
- /**
74
- * There are multiple props that can change how the date is formatted.
75
- * The priority of props used is:
76
- * 1. `formatDisplayLabel`
77
- * 2. `dateFormat`
78
- * 3. `locale`
79
- */
80
- var formatDate = exports.formatDate = function formatDate(value, di) {
81
- var formatDisplayLabel = di.formatDisplayLabel,
82
- dateFormat = di.dateFormat,
83
- l10n = di.l10n;
84
- if (formatDisplayLabel) {
85
- return formatDisplayLabel(value, dateFormat || _index.defaultDateFormat);
86
- }
87
- var date = (0, _dateFns.parseISO)(value);
88
- return dateFormat ? (0, _dateFns.format)(date, (0, _parseTokens.convertTokens)(dateFormat)) : l10n.formatDate(date);
89
- };
90
- var getPlaceholder = exports.getPlaceholder = function getPlaceholder(di) {
91
- var placeholder = di.placeholder,
92
- l10n = di.l10n;
93
- return placeholder || l10n.formatDate(_index.placeholderDatetime);
94
50
  };
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getPlaceholder = void 0;
7
+ var _index = require("./index");
8
+ /**
9
+ * Everything in this file is to smooth out the migration of the new date picker
10
+ * (https://product-fabric.atlassian.net/browse/DSP-20682). When that ticket is
11
+ * complete, all of these functions will ilkely be merged back into the date
12
+ * picker. Please do not pre-optimize and put these back into the date picker
13
+ * unless you are working on the DTP Refresh and you have a good reason to do
14
+ * so, thank you!
15
+ *
16
+ * All variables within the `di` objects are dependency injections. They should
17
+ * be read from within the component at the end of the day. But because we are
18
+ * extracting them, we have to inject them in every place manually. When we
19
+ * re-introduce them to the components, we can likely remove the `di` variables
20
+ * and instead use internal variables.
21
+ *
22
+ * If component _only_ has injected variables, it is fully internal and was
23
+ * broken out to be it's own function.
24
+ */
25
+
26
+ // oxlint-disable-next-line @atlassian/no-restricted-imports
27
+
28
+ var getPlaceholder = exports.getPlaceholder = function getPlaceholder(di) {
29
+ var placeholder = di.placeholder,
30
+ l10n = di.l10n;
31
+ return placeholder || l10n.formatDate(_index.placeholderDatetime);
32
+ };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getSafeCalendarValue = getSafeCalendarValue;
7
+ var _getShortIsoString = require("./get-short-iso-string");
8
+ // oxlint-disable-next-line @atlassian/no-restricted-imports
9
+
10
+ function getSafeCalendarValue(calendarValue) {
11
+ // If `calendarValue` has a year that is greater than 9999, default to
12
+ // today's date
13
+ var yearIsOverLimit = calendarValue.match(/^\d{5,}/);
14
+ if (yearIsOverLimit) {
15
+ return (0, _getShortIsoString.getShortISOString)(new Date());
16
+ }
17
+ return calendarValue;
18
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getShortISOString = getShortISOString;
7
+ var _dateFns = require("date-fns");
8
+ var _parseTokens = require("./parse-tokens");
9
+ // oxlint-disable-next-line @atlassian/no-restricted-imports
10
+
11
+ function getShortISOString(date) {
12
+ return (0, _dateFns.format)(date, (0, _parseTokens.convertTokens)('YYYY-MM-DD'));
13
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isDateDisabled = void 0;
7
+ /**
8
+ * Everything in this file is to smooth out the migration of the new date picker
9
+ * (https://product-fabric.atlassian.net/browse/DSP-20682). When that ticket is
10
+ * complete, all of these functions will ilkely be merged back into the date
11
+ * picker. Please do not pre-optimize and put these back into the date picker
12
+ * unless you are working on the DTP Refresh and you have a good reason to do
13
+ * so, thank you!
14
+ *
15
+ * All variables within the `di` objects are dependency injections. They should
16
+ * be read from within the component at the end of the day. But because we are
17
+ * extracting them, we have to inject them in every place manually. When we
18
+ * re-introduce them to the components, we can likely remove the `di` variables
19
+ * and instead use internal variables.
20
+ *
21
+ * If component _only_ has injected variables, it is fully internal and was
22
+ * broken out to be it's own function.
23
+ */
24
+
25
+ // oxlint-disable-next-line @atlassian/no-restricted-imports
26
+ var isDateDisabled = exports.isDateDisabled = function isDateDisabled(date, di) {
27
+ var disabled = di.disabled;
28
+ return disabled.indexOf(date) > -1;
29
+ };
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isValid = isValid;
7
+ function isValid(timeString) {
8
+ /**
9
+ * Regex match for `12:34`, `12:34:56`, `1:23:56 p`, `1:23:56PM`, and a bit more…
10
+ */
11
+ var time = timeString.trim().match(/([012]?[\d])(?::([0-5][\d]))?(?::([0-5][\d]))?\s*([ap]m?)?/i);
12
+
13
+ /**
14
+ * Regex match for `1234`, `12:34`, `12.34`, `123456`, `12:34:56`, `12.34.56`
15
+ */
16
+ var time24hr = timeString.trim().match(/([012][\d])[:.]?([0-5][\d])([:.]?([0-5][\d]))?/);
17
+
18
+ /**
19
+ * Convert `2:34:56 pm` down to `23456`
20
+ */
21
+ var num = timeString.replace(/[^0-9]/g, '');
22
+ var includesSeconds = time && time[1] !== undefined && time[2] !== undefined && time[3] !== undefined || time24hr && time24hr[1] !== undefined && time24hr[2] !== undefined && time24hr[4] !== undefined;
23
+ if (!time && !time24hr) {
24
+ return false;
25
+ }
26
+ if (time && !time[1]) {
27
+ return false;
28
+ }
29
+ if (num.length > 6) {
30
+ return false;
31
+ }
32
+ if (num.length > 4 && !includesSeconds) {
33
+ return false;
34
+ }
35
+ if (num.length === 2 && parseInt(num, 10) > 12) {
36
+ return false;
37
+ }
38
+ return true;
39
+ }
@@ -3,27 +3,38 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getSafeCalendarValue = getSafeCalendarValue;
7
- exports.getShortISOString = getShortISOString;
8
- var _dateFns = require("date-fns");
9
- var _parseTokens = require("./parse-tokens");
10
- // oxlint-disable-next-line @atlassian/no-restricted-imports
11
-
6
+ exports.parseDate = void 0;
7
+ var _index = require("./index");
12
8
  /**
13
- * Converts a Date object into an ISO date, formatted `YYYY-MM-DD`.
9
+ * Everything in this file is to smooth out the migration of the new date picker
10
+ * (https://product-fabric.atlassian.net/browse/DSP-20682). When that ticket is
11
+ * complete, all of these functions will ilkely be merged back into the date
12
+ * picker. Please do not pre-optimize and put these back into the date picker
13
+ * unless you are working on the DTP Refresh and you have a good reason to do
14
+ * so, thank you!
15
+ *
16
+ * All variables within the `di` objects are dependency injections. They should
17
+ * be read from within the component at the end of the day. But because we are
18
+ * extracting them, we have to inject them in every place manually. When we
19
+ * re-introduce them to the components, we can likely remove the `di` variables
20
+ * and instead use internal variables.
14
21
  *
15
- * @param date The date to convert.
16
- * @returns An ISO date (`YYYY-MM-DD`).
22
+ * If component _only_ has injected variables, it is fully internal and was
23
+ * broken out to be it's own function.
24
+ */
25
+
26
+ /**
27
+ * There are two props that can change how the date is parsed.
28
+ * The priority of props used is:
29
+ * 1. `parseInputValue`
30
+ * 2. `locale`
17
31
  */
18
- function getShortISOString(date) {
19
- return (0, _dateFns.format)(date, (0, _parseTokens.convertTokens)('YYYY-MM-DD'));
20
- }
21
- function getSafeCalendarValue(calendarValue) {
22
- // If `calendarValue` has a year that is greater than 9999, default to
23
- // today's date
24
- var yearIsOverLimit = calendarValue.match(/^\d{5,}/);
25
- if (yearIsOverLimit) {
26
- return getShortISOString(new Date());
32
+ var parseDate = exports.parseDate = function parseDate(date, di) {
33
+ var parseInputValue = di.parseInputValue,
34
+ dateFormat = di.dateFormat,
35
+ l10n = di.l10n;
36
+ if (parseInputValue) {
37
+ return parseInputValue(date, dateFormat || _index.defaultDateFormat);
27
38
  }
28
- return calendarValue;
29
- }
39
+ return l10n.parseDate(date);
40
+ };
@@ -3,106 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.convertTo24hrTime = convertTo24hrTime;
7
6
  exports.default = parseTime;
8
- exports.isValid = isValid;
9
- exports.removeSpacer = removeSpacer;
10
- var map24 = {
11
- '12': '12',
12
- '01': '13',
13
- '02': '14',
14
- '03': '15',
15
- '04': '16',
16
- '05': '17',
17
- '06': '18',
18
- '07': '19',
19
- '08': '20',
20
- '09': '21',
21
- '10': '22',
22
- '11': '23'
23
- };
24
- function isValid(timeString) {
25
- /**
26
- * Regex match for `12:34`, `12:34:56`, `1:23:56 p`, `1:23:56PM`, and a bit more…
27
- */
28
- var time = timeString.trim().match(/([012]?[\d])(?::([0-5][\d]))?(?::([0-5][\d]))?\s*([ap]m?)?/i);
29
-
30
- /**
31
- * Regex match for `1234`, `12:34`, `12.34`, `123456`, `12:34:56`, `12.34.56`
32
- */
33
- var time24hr = timeString.trim().match(/([012][\d])[:.]?([0-5][\d])([:.]?([0-5][\d]))?/);
34
-
35
- /**
36
- * Convert `2:34:56 pm` down to `23456`
37
- */
38
- var num = timeString.replace(/[^0-9]/g, '');
39
- var includesSeconds = time && time[1] !== undefined && time[2] !== undefined && time[3] !== undefined || time24hr && time24hr[1] !== undefined && time24hr[2] !== undefined && time24hr[4] !== undefined;
40
- if (!time && !time24hr) {
41
- return false;
42
- }
43
- if (time && !time[1]) {
44
- return false;
45
- }
46
- if (num.length > 6) {
47
- return false;
48
- }
49
- if (num.length > 4 && !includesSeconds) {
50
- return false;
51
- }
52
- if (num.length === 2 && parseInt(num, 10) > 12) {
53
- return false;
54
- }
55
- return true;
56
- }
57
- function removeSpacer(time) {
58
- return time.replace(/[:.]/g, '');
59
- }
60
- function formatSemi24(time) {
61
- if (time.length === 1) {
62
- return "0".concat(time, "00");
63
- }
64
- if (time.length === 2) {
65
- return "".concat(time, "00");
66
- }
67
- if (time.length === 3 || time.length === 5) {
68
- return "0".concat(time);
69
- }
70
- return time;
71
- }
72
- function checkHour(hour, meridiem) {
73
- if (hour > '24') {
74
- return null;
75
- }
76
- if (hour === '12' && meridiem === 'a') {
77
- return '00';
78
- }
79
- if (hour < '12' && meridiem === 'p') {
80
- return map24[hour];
81
- }
82
- return hour;
83
- }
84
- function checkMinuteSecond(value) {
85
- if (value > '59') {
86
- return null;
87
- }
88
- return value;
89
- }
90
- function convertTo24hrTime(time) {
91
- var timeArray = time.toLowerCase().split(/(p|a)/i);
92
- var meridiem = timeArray[1];
93
- var semi24 = formatSemi24(timeArray[0].trim());
94
- var hour = checkHour(semi24.substring(0, 2), meridiem);
95
- var minute = checkMinuteSecond(semi24.substring(2, 4));
96
- var seconds = semi24.length === 6 && checkMinuteSecond(semi24.substring(4, 6));
97
- if (!hour || !minute) {
98
- return null;
99
- }
100
- return {
101
- hour: parseInt(hour, 10),
102
- minute: parseInt(minute, 10),
103
- seconds: parseInt(seconds || '0', 10) || 0
104
- };
105
- }
7
+ var _convertTo24hrTime = require("./convert-to24hr-time");
8
+ var _isValid = require("./is-valid");
9
+ var _removeSpacer = require("./remove-spacer");
106
10
  function assignToDate(time) {
107
11
  var dateTime = new Date();
108
12
  dateTime.setHours(time.hour);
@@ -113,11 +17,11 @@ function assignToDate(time) {
113
17
  }
114
18
  function parseTime(time) {
115
19
  var trimmedTime = time.toString().trim();
116
- if (!isValid(trimmedTime)) {
20
+ if (!(0, _isValid.isValid)(trimmedTime)) {
117
21
  throw RangeError('invalid time format');
118
22
  }
119
- var time1 = removeSpacer(trimmedTime);
120
- var time2 = convertTo24hrTime(time1);
23
+ var time1 = (0, _removeSpacer.removeSpacer)(trimmedTime);
24
+ var time2 = (0, _convertTo24hrTime.convertTo24hrTime)(time1);
121
25
  if (!time2) {
122
26
  throw RangeError('invalid time format');
123
27
  }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.removeSpacer = removeSpacer;
7
+ function removeSpacer(time) {
8
+ return time.replace(/[:.]/g, '');
9
+ }
@@ -18,13 +18,18 @@ import { createLocalizationProvider } from '@atlaskit/locale';
18
18
  import { Box } from '@atlaskit/primitives/compiled';
19
19
  import Select, { mergeStyles } from '@atlaskit/select';
20
20
  import { EmptyComponent } from '../internal';
21
- import { formatDate, getParsedISO, getPlaceholder, isDateDisabled, parseDate } from '../internal/date-picker-migration';
21
+ import { formatDate } from '../internal/format-date';
22
+ import { getParsedISO } from '../internal/get-parsed-iso';
23
+ import { getPlaceholder } from '../internal/get-placeholder';
24
+ import { getSafeCalendarValue } from '../internal/get-safe-calendar-value';
25
+ import { getShortISOString } from '../internal/get-short-iso-string';
22
26
  import { IndicatorsContainer } from '../internal/indicators-container';
27
+ import { isDateDisabled } from '../internal/is-date-disabled';
23
28
  import { Menu } from '../internal/menu';
24
- import { getSafeCalendarValue, getShortISOString } from '../internal/parse-date';
29
+ import { parseDate } from '../internal/parse-date';
25
30
  import { makeSingleValue } from '../internal/single-value';
26
31
  const packageName = "@atlaskit/datetime-picker";
27
- const packageVersion = "17.6.5";
32
+ const packageVersion = "0.0.0-development";
28
33
  const styles = {
29
34
  pickerContainerStyle: "_kqswh2mm",
30
35
  dropdownIndicatorStyles: "_1ul91k8s _1tke1k8s _1e0c1txw _4cvr1h6o _1bah1h6o",
@@ -16,7 +16,7 @@ import { convertTokens } from '../internal/parse-tokens';
16
16
  import DatePicker from './date-picker';
17
17
  import TimePicker from './time-picker';
18
18
  const packageName = "@atlaskit/datetime-picker";
19
- const packageVersion = "17.6.5";
19
+ const packageVersion = "0.0.0-development";
20
20
  const compiledStyles = {
21
21
  datePickerContainerStyles: "_i0dl1ssb _16jlkb7n _1o9zidpf",
22
22
  timePickerContainerStyles: "_i0dl1ssb _16jlkb7n",