@atlaskit/datetime-picker 12.10.5 → 13.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/cjs/components/date-picker.js +1 -1
- package/dist/cjs/components/date-time-picker.js +1 -1
- package/dist/cjs/components/time-picker.js +4 -2
- package/dist/cjs/internal/parse-time.js +30 -12
- package/dist/es2019/components/date-picker.js +1 -1
- package/dist/es2019/components/date-time-picker.js +1 -1
- package/dist/es2019/components/time-picker.js +4 -2
- package/dist/es2019/internal/parse-time.js +29 -11
- package/dist/esm/components/date-picker.js +1 -1
- package/dist/esm/components/date-time-picker.js +1 -1
- package/dist/esm/components/time-picker.js +4 -2
- package/dist/esm/internal/parse-time.js +29 -11
- package/dist/types/internal/parse-time.d.ts +9 -9
- package/dist/types-ts4.5/internal/parse-time.d.ts +9 -9
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/datetime-picker
|
|
2
2
|
|
|
3
|
+
## 13.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#43269](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/43269) [`c7ab5b9501c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c7ab5b9501c) - This fixes it so that `<TimePicker timeEditable timeFormat="hh:mm:ss">` will return seconds when the timeformat includes seconds whereas previously it would strictly return `HH:mm` and not account for the `timeFormat`. It is still not flexible and does not return time in your `timeFormat` to avoid causing unexpected breaking changes as that `HH:mm` format has been there for so long.
|
|
8
|
+
|
|
9
|
+
There's a theoretical risk that `HH:mm` formats are expected back when `HH:mm:ss` format are used and unsed improperly, but any typical parsing of datetime should handle this change perfectly fine, with zero breaking change expected.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 12.10.6
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 12.10.5
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -39,7 +39,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
39
39
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
40
40
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** @jsx jsx */
|
|
41
41
|
var packageName = "@atlaskit/datetime-picker";
|
|
42
|
-
var packageVersion = "
|
|
42
|
+
var packageVersion = "13.0.0";
|
|
43
43
|
function getValidDate(iso) {
|
|
44
44
|
var date = (0, _dateFns.parseISO)(iso);
|
|
45
45
|
return (0, _dateFns.isValid)(date) ? {
|
|
@@ -31,7 +31,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
31
31
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
32
32
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /** @jsx jsx */
|
|
33
33
|
var packageName = "@atlaskit/datetime-picker";
|
|
34
|
-
var packageVersion = "
|
|
34
|
+
var packageVersion = "13.0.0";
|
|
35
35
|
var isInvalidBorderStyles = (0, _react2.css)({
|
|
36
36
|
borderColor: "var(--ds-border-danger, ".concat(_colors.R400, ")")
|
|
37
37
|
});
|
|
@@ -37,7 +37,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
37
37
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
38
38
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
39
39
|
var packageName = "@atlaskit/datetime-picker";
|
|
40
|
-
var packageVersion = "
|
|
40
|
+
var packageVersion = "13.0.0";
|
|
41
41
|
var menuStyles = {
|
|
42
42
|
/* Need to remove default absolute positioning as that causes issues with position fixed */
|
|
43
43
|
position: 'static',
|
|
@@ -138,7 +138,9 @@ var TimePicker = exports.TimePickerWithoutAnalytics = /*#__PURE__*/function (_Re
|
|
|
138
138
|
return; // do nothing, the main validation should happen in the form
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
var
|
|
141
|
+
var includesSeconds = !!(_timeFormat2 && /[:.]?(s|ss)/.test(_timeFormat2));
|
|
142
|
+
var formatFormat = includesSeconds ? 'HH:mm:ss' : 'HH:mm';
|
|
143
|
+
var formattedValue = (0, _dateFns.format)(sanitizedInput, formatFormat) || '';
|
|
142
144
|
_this.setState({
|
|
143
145
|
value: formattedValue
|
|
144
146
|
});
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.assignToDate = assignToDate;
|
|
7
7
|
exports.checkHour = checkHour;
|
|
8
|
-
exports.
|
|
8
|
+
exports.checkMinuteSecond = checkMinuteSecond;
|
|
9
9
|
exports.convertTo24hrTime = convertTo24hrTime;
|
|
10
10
|
exports.default = _default;
|
|
11
11
|
exports.formatSemi24 = formatSemi24;
|
|
@@ -26,16 +26,31 @@ var map24 = {
|
|
|
26
26
|
'11': '23'
|
|
27
27
|
};
|
|
28
28
|
function isValid(timeString) {
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Regex match for `12:34`, `12:34:56`, `1:23:56 p`, `1:23:56PM`, and a bit more…
|
|
31
|
+
*/
|
|
32
|
+
var time = timeString.trim().match(/([012]?[\d])(?::([0-5][\d]))?(?::([0-5][\d]))?\s*([ap]m?)?/i);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Regex match for `1234`, `12:34`, `12.34`, `123456`, `12:34:56`, `12.34.56`
|
|
36
|
+
*/
|
|
37
|
+
var time24hr = timeString.trim().match(/([012][\d])[:.]?([0-5][\d])([:.]?([0-5][\d]))?/);
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Convert `2:34:56 pm` down to `23456`
|
|
41
|
+
*/
|
|
31
42
|
var num = timeString.replace(/[^0-9]/g, '');
|
|
43
|
+
var includesSeconds = time && time[1] !== undefined && time[2] !== undefined && time[3] !== undefined || time24hr && time24hr[1] !== undefined && time24hr[2] !== undefined && time24hr[4] !== undefined;
|
|
32
44
|
if (!time && !time24hr) {
|
|
33
45
|
return false;
|
|
34
46
|
}
|
|
35
47
|
if (time && !time[1]) {
|
|
36
48
|
return false;
|
|
37
49
|
}
|
|
38
|
-
if (num.length >
|
|
50
|
+
if (num.length > 6) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
if (num.length > 4 && !includesSeconds) {
|
|
39
54
|
return false;
|
|
40
55
|
}
|
|
41
56
|
if (num.length === 2 && parseInt(num, 10) > 12) {
|
|
@@ -44,7 +59,7 @@ function isValid(timeString) {
|
|
|
44
59
|
return true;
|
|
45
60
|
}
|
|
46
61
|
function removeSpacer(time) {
|
|
47
|
-
return time.replace(/[:.]
|
|
62
|
+
return time.replace(/[:.]/g, '');
|
|
48
63
|
}
|
|
49
64
|
function formatSemi24(time) {
|
|
50
65
|
if (time.length === 1) {
|
|
@@ -53,7 +68,7 @@ function formatSemi24(time) {
|
|
|
53
68
|
if (time.length === 2) {
|
|
54
69
|
return "".concat(time, "00");
|
|
55
70
|
}
|
|
56
|
-
if (time.length === 3) {
|
|
71
|
+
if (time.length === 3 || time.length === 5) {
|
|
57
72
|
return "0".concat(time);
|
|
58
73
|
}
|
|
59
74
|
return time;
|
|
@@ -70,31 +85,34 @@ function checkHour(hour, meridiem) {
|
|
|
70
85
|
}
|
|
71
86
|
return hour;
|
|
72
87
|
}
|
|
73
|
-
function
|
|
74
|
-
if (
|
|
88
|
+
function checkMinuteSecond(value) {
|
|
89
|
+
if (value > '59') {
|
|
75
90
|
return null;
|
|
76
91
|
}
|
|
77
|
-
return
|
|
92
|
+
return value;
|
|
78
93
|
}
|
|
79
94
|
function convertTo24hrTime(time) {
|
|
80
95
|
var timeArray = time.toLowerCase().split(/(p|a)/i);
|
|
81
96
|
var meridiem = timeArray[1];
|
|
82
97
|
var semi24 = formatSemi24(timeArray[0].trim());
|
|
83
98
|
var hour = checkHour(semi24.substring(0, 2), meridiem);
|
|
84
|
-
var minute =
|
|
99
|
+
var minute = checkMinuteSecond(semi24.substring(2, 4));
|
|
100
|
+
var seconds = semi24.length === 6 && checkMinuteSecond(semi24.substring(4, 6));
|
|
85
101
|
if (!hour || !minute) {
|
|
86
102
|
return null;
|
|
87
103
|
}
|
|
88
104
|
return {
|
|
89
105
|
hour: parseInt(hour, 10),
|
|
90
|
-
minute: parseInt(minute, 10)
|
|
106
|
+
minute: parseInt(minute, 10),
|
|
107
|
+
seconds: parseInt(seconds || '0', 10) || 0
|
|
91
108
|
};
|
|
92
109
|
}
|
|
93
110
|
function assignToDate(time) {
|
|
94
111
|
var dateTime = new Date();
|
|
95
112
|
dateTime.setHours(time.hour);
|
|
96
113
|
dateTime.setMinutes(time.minute);
|
|
97
|
-
|
|
114
|
+
// milliseconds is not supported
|
|
115
|
+
dateTime.setSeconds(time.seconds || 0, 0);
|
|
98
116
|
return dateTime;
|
|
99
117
|
}
|
|
100
118
|
function _default(time) {
|
|
@@ -19,7 +19,7 @@ import FixedLayer from '../internal/fixed-layer';
|
|
|
19
19
|
import { makeSingleValue } from '../internal/single-value';
|
|
20
20
|
import { convertTokens } from './utils';
|
|
21
21
|
const packageName = "@atlaskit/datetime-picker";
|
|
22
|
-
const packageVersion = "
|
|
22
|
+
const packageVersion = "13.0.0";
|
|
23
23
|
function getValidDate(iso) {
|
|
24
24
|
const date = parseISO(iso);
|
|
25
25
|
return isValid(date) ? {
|
|
@@ -15,7 +15,7 @@ import DatePicker from './date-picker';
|
|
|
15
15
|
import TimePicker from './time-picker';
|
|
16
16
|
import { convertTokens } from './utils';
|
|
17
17
|
const packageName = "@atlaskit/datetime-picker";
|
|
18
|
-
const packageVersion = "
|
|
18
|
+
const packageVersion = "13.0.0";
|
|
19
19
|
const isInvalidBorderStyles = css({
|
|
20
20
|
borderColor: `var(--ds-border-danger, ${R400})`
|
|
21
21
|
});
|
|
@@ -16,7 +16,7 @@ import parseTime from '../internal/parse-time';
|
|
|
16
16
|
import { makeSingleValue } from '../internal/single-value';
|
|
17
17
|
import { convertTokens } from './utils';
|
|
18
18
|
const packageName = "@atlaskit/datetime-picker";
|
|
19
|
-
const packageVersion = "
|
|
19
|
+
const packageVersion = "13.0.0";
|
|
20
20
|
const menuStyles = {
|
|
21
21
|
/* Need to remove default absolute positioning as that causes issues with position fixed */
|
|
22
22
|
position: 'static',
|
|
@@ -113,7 +113,9 @@ class TimePicker extends React.Component {
|
|
|
113
113
|
return; // do nothing, the main validation should happen in the form
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
const
|
|
116
|
+
const includesSeconds = !!(timeFormat && /[:.]?(s|ss)/.test(timeFormat));
|
|
117
|
+
const formatFormat = includesSeconds ? 'HH:mm:ss' : 'HH:mm';
|
|
118
|
+
const formattedValue = format(sanitizedInput, formatFormat) || '';
|
|
117
119
|
this.setState({
|
|
118
120
|
value: formattedValue
|
|
119
121
|
});
|
|
@@ -13,16 +13,31 @@ const map24 = {
|
|
|
13
13
|
'11': '23'
|
|
14
14
|
};
|
|
15
15
|
export function isValid(timeString) {
|
|
16
|
-
|
|
17
|
-
|
|
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
|
+
*/
|
|
18
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;
|
|
19
31
|
if (!time && !time24hr) {
|
|
20
32
|
return false;
|
|
21
33
|
}
|
|
22
34
|
if (time && !time[1]) {
|
|
23
35
|
return false;
|
|
24
36
|
}
|
|
25
|
-
if (num.length >
|
|
37
|
+
if (num.length > 6) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
if (num.length > 4 && !includesSeconds) {
|
|
26
41
|
return false;
|
|
27
42
|
}
|
|
28
43
|
if (num.length === 2 && parseInt(num, 10) > 12) {
|
|
@@ -31,7 +46,7 @@ export function isValid(timeString) {
|
|
|
31
46
|
return true;
|
|
32
47
|
}
|
|
33
48
|
export function removeSpacer(time) {
|
|
34
|
-
return time.replace(/[:.]
|
|
49
|
+
return time.replace(/[:.]/g, '');
|
|
35
50
|
}
|
|
36
51
|
export function formatSemi24(time) {
|
|
37
52
|
if (time.length === 1) {
|
|
@@ -40,7 +55,7 @@ export function formatSemi24(time) {
|
|
|
40
55
|
if (time.length === 2) {
|
|
41
56
|
return `${time}00`;
|
|
42
57
|
}
|
|
43
|
-
if (time.length === 3) {
|
|
58
|
+
if (time.length === 3 || time.length === 5) {
|
|
44
59
|
return `0${time}`;
|
|
45
60
|
}
|
|
46
61
|
return time;
|
|
@@ -57,31 +72,34 @@ export function checkHour(hour, meridiem) {
|
|
|
57
72
|
}
|
|
58
73
|
return hour;
|
|
59
74
|
}
|
|
60
|
-
export function
|
|
61
|
-
if (
|
|
75
|
+
export function checkMinuteSecond(value) {
|
|
76
|
+
if (value > '59') {
|
|
62
77
|
return null;
|
|
63
78
|
}
|
|
64
|
-
return
|
|
79
|
+
return value;
|
|
65
80
|
}
|
|
66
81
|
export function convertTo24hrTime(time) {
|
|
67
82
|
const timeArray = time.toLowerCase().split(/(p|a)/i);
|
|
68
83
|
const meridiem = timeArray[1];
|
|
69
84
|
const semi24 = formatSemi24(timeArray[0].trim());
|
|
70
85
|
const hour = checkHour(semi24.substring(0, 2), meridiem);
|
|
71
|
-
const minute =
|
|
86
|
+
const minute = checkMinuteSecond(semi24.substring(2, 4));
|
|
87
|
+
const seconds = semi24.length === 6 && checkMinuteSecond(semi24.substring(4, 6));
|
|
72
88
|
if (!hour || !minute) {
|
|
73
89
|
return null;
|
|
74
90
|
}
|
|
75
91
|
return {
|
|
76
92
|
hour: parseInt(hour, 10),
|
|
77
|
-
minute: parseInt(minute, 10)
|
|
93
|
+
minute: parseInt(minute, 10),
|
|
94
|
+
seconds: parseInt(seconds || '0', 10) || 0
|
|
78
95
|
};
|
|
79
96
|
}
|
|
80
97
|
export function assignToDate(time) {
|
|
81
98
|
const dateTime = new Date();
|
|
82
99
|
dateTime.setHours(time.hour);
|
|
83
100
|
dateTime.setMinutes(time.minute);
|
|
84
|
-
|
|
101
|
+
// milliseconds is not supported
|
|
102
|
+
dateTime.setSeconds(time.seconds || 0, 0);
|
|
85
103
|
return dateTime;
|
|
86
104
|
}
|
|
87
105
|
export default function (time) {
|
|
@@ -30,7 +30,7 @@ import FixedLayer from '../internal/fixed-layer';
|
|
|
30
30
|
import { makeSingleValue } from '../internal/single-value';
|
|
31
31
|
import { convertTokens } from './utils';
|
|
32
32
|
var packageName = "@atlaskit/datetime-picker";
|
|
33
|
-
var packageVersion = "
|
|
33
|
+
var packageVersion = "13.0.0";
|
|
34
34
|
function getValidDate(iso) {
|
|
35
35
|
var date = parseISO(iso);
|
|
36
36
|
return isValid(date) ? {
|
|
@@ -25,7 +25,7 @@ import DatePicker from './date-picker';
|
|
|
25
25
|
import TimePicker from './time-picker';
|
|
26
26
|
import { convertTokens } from './utils';
|
|
27
27
|
var packageName = "@atlaskit/datetime-picker";
|
|
28
|
-
var packageVersion = "
|
|
28
|
+
var packageVersion = "13.0.0";
|
|
29
29
|
var isInvalidBorderStyles = css({
|
|
30
30
|
borderColor: "var(--ds-border-danger, ".concat(R400, ")")
|
|
31
31
|
});
|
|
@@ -29,7 +29,7 @@ import parseTime from '../internal/parse-time';
|
|
|
29
29
|
import { makeSingleValue } from '../internal/single-value';
|
|
30
30
|
import { convertTokens } from './utils';
|
|
31
31
|
var packageName = "@atlaskit/datetime-picker";
|
|
32
|
-
var packageVersion = "
|
|
32
|
+
var packageVersion = "13.0.0";
|
|
33
33
|
var menuStyles = {
|
|
34
34
|
/* Need to remove default absolute positioning as that causes issues with position fixed */
|
|
35
35
|
position: 'static',
|
|
@@ -130,7 +130,9 @@ var TimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
130
130
|
return; // do nothing, the main validation should happen in the form
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
var
|
|
133
|
+
var includesSeconds = !!(_timeFormat2 && /[:.]?(s|ss)/.test(_timeFormat2));
|
|
134
|
+
var formatFormat = includesSeconds ? 'HH:mm:ss' : 'HH:mm';
|
|
135
|
+
var formattedValue = format(sanitizedInput, formatFormat) || '';
|
|
134
136
|
_this.setState({
|
|
135
137
|
value: formattedValue
|
|
136
138
|
});
|
|
@@ -13,16 +13,31 @@ var map24 = {
|
|
|
13
13
|
'11': '23'
|
|
14
14
|
};
|
|
15
15
|
export function isValid(timeString) {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Regex match for `12:34`, `12:34:56`, `1:23:56 p`, `1:23:56PM`, and a bit more…
|
|
18
|
+
*/
|
|
19
|
+
var 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
|
+
var time24hr = timeString.trim().match(/([012][\d])[:.]?([0-5][\d])([:.]?([0-5][\d]))?/);
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Convert `2:34:56 pm` down to `23456`
|
|
28
|
+
*/
|
|
18
29
|
var num = timeString.replace(/[^0-9]/g, '');
|
|
30
|
+
var includesSeconds = time && time[1] !== undefined && time[2] !== undefined && time[3] !== undefined || time24hr && time24hr[1] !== undefined && time24hr[2] !== undefined && time24hr[4] !== undefined;
|
|
19
31
|
if (!time && !time24hr) {
|
|
20
32
|
return false;
|
|
21
33
|
}
|
|
22
34
|
if (time && !time[1]) {
|
|
23
35
|
return false;
|
|
24
36
|
}
|
|
25
|
-
if (num.length >
|
|
37
|
+
if (num.length > 6) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
if (num.length > 4 && !includesSeconds) {
|
|
26
41
|
return false;
|
|
27
42
|
}
|
|
28
43
|
if (num.length === 2 && parseInt(num, 10) > 12) {
|
|
@@ -31,7 +46,7 @@ export function isValid(timeString) {
|
|
|
31
46
|
return true;
|
|
32
47
|
}
|
|
33
48
|
export function removeSpacer(time) {
|
|
34
|
-
return time.replace(/[:.]
|
|
49
|
+
return time.replace(/[:.]/g, '');
|
|
35
50
|
}
|
|
36
51
|
export function formatSemi24(time) {
|
|
37
52
|
if (time.length === 1) {
|
|
@@ -40,7 +55,7 @@ export function formatSemi24(time) {
|
|
|
40
55
|
if (time.length === 2) {
|
|
41
56
|
return "".concat(time, "00");
|
|
42
57
|
}
|
|
43
|
-
if (time.length === 3) {
|
|
58
|
+
if (time.length === 3 || time.length === 5) {
|
|
44
59
|
return "0".concat(time);
|
|
45
60
|
}
|
|
46
61
|
return time;
|
|
@@ -57,31 +72,34 @@ export function checkHour(hour, meridiem) {
|
|
|
57
72
|
}
|
|
58
73
|
return hour;
|
|
59
74
|
}
|
|
60
|
-
export function
|
|
61
|
-
if (
|
|
75
|
+
export function checkMinuteSecond(value) {
|
|
76
|
+
if (value > '59') {
|
|
62
77
|
return null;
|
|
63
78
|
}
|
|
64
|
-
return
|
|
79
|
+
return value;
|
|
65
80
|
}
|
|
66
81
|
export function convertTo24hrTime(time) {
|
|
67
82
|
var timeArray = time.toLowerCase().split(/(p|a)/i);
|
|
68
83
|
var meridiem = timeArray[1];
|
|
69
84
|
var semi24 = formatSemi24(timeArray[0].trim());
|
|
70
85
|
var hour = checkHour(semi24.substring(0, 2), meridiem);
|
|
71
|
-
var minute =
|
|
86
|
+
var minute = checkMinuteSecond(semi24.substring(2, 4));
|
|
87
|
+
var seconds = semi24.length === 6 && checkMinuteSecond(semi24.substring(4, 6));
|
|
72
88
|
if (!hour || !minute) {
|
|
73
89
|
return null;
|
|
74
90
|
}
|
|
75
91
|
return {
|
|
76
92
|
hour: parseInt(hour, 10),
|
|
77
|
-
minute: parseInt(minute, 10)
|
|
93
|
+
minute: parseInt(minute, 10),
|
|
94
|
+
seconds: parseInt(seconds || '0', 10) || 0
|
|
78
95
|
};
|
|
79
96
|
}
|
|
80
97
|
export function assignToDate(time) {
|
|
81
98
|
var dateTime = new Date();
|
|
82
99
|
dateTime.setHours(time.hour);
|
|
83
100
|
dateTime.setMinutes(time.minute);
|
|
84
|
-
|
|
101
|
+
// milliseconds is not supported
|
|
102
|
+
dateTime.setSeconds(time.seconds || 0, 0);
|
|
85
103
|
return dateTime;
|
|
86
104
|
}
|
|
87
105
|
export default function (time) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
type TimeObject = {
|
|
2
|
+
hour: number;
|
|
3
|
+
minute: number;
|
|
4
|
+
seconds: number;
|
|
5
|
+
};
|
|
1
6
|
export declare function isValid(timeString: string): boolean;
|
|
2
7
|
export declare function removeSpacer(time: string): string;
|
|
3
8
|
export declare function formatSemi24(time: string): string;
|
|
4
9
|
export declare function checkHour(hour: string, meridiem: string): string | null;
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function convertTo24hrTime(time: string):
|
|
7
|
-
|
|
8
|
-
minute: number;
|
|
9
|
-
} | null;
|
|
10
|
-
export declare function assignToDate(time: {
|
|
11
|
-
hour: number;
|
|
12
|
-
minute: number;
|
|
13
|
-
}): Date;
|
|
10
|
+
export declare function checkMinuteSecond(value: string): string | null;
|
|
11
|
+
export declare function convertTo24hrTime(time: string): TimeObject | null;
|
|
12
|
+
export declare function assignToDate(time: TimeObject): Date;
|
|
14
13
|
export default function (time: string): string | Date;
|
|
14
|
+
export {};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
type TimeObject = {
|
|
2
|
+
hour: number;
|
|
3
|
+
minute: number;
|
|
4
|
+
seconds: number;
|
|
5
|
+
};
|
|
1
6
|
export declare function isValid(timeString: string): boolean;
|
|
2
7
|
export declare function removeSpacer(time: string): string;
|
|
3
8
|
export declare function formatSemi24(time: string): string;
|
|
4
9
|
export declare function checkHour(hour: string, meridiem: string): string | null;
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function convertTo24hrTime(time: string):
|
|
7
|
-
|
|
8
|
-
minute: number;
|
|
9
|
-
} | null;
|
|
10
|
-
export declare function assignToDate(time: {
|
|
11
|
-
hour: number;
|
|
12
|
-
minute: number;
|
|
13
|
-
}): Date;
|
|
10
|
+
export declare function checkMinuteSecond(value: string): string | null;
|
|
11
|
+
export declare function convertTo24hrTime(time: string): TimeObject | null;
|
|
12
|
+
export declare function assignToDate(time: TimeObject): Date;
|
|
14
13
|
export default function (time: string): string | Date;
|
|
14
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/datetime-picker",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0",
|
|
4
4
|
"description": "A date time picker allows the user to select an associated date and time.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"@atlaskit/analytics-next": "^9.1.0",
|
|
36
36
|
"@atlaskit/calendar": "^14.0.0",
|
|
37
37
|
"@atlaskit/ds-lib": "^2.2.0",
|
|
38
|
-
"@atlaskit/icon": "^
|
|
38
|
+
"@atlaskit/icon": "^22.0.0",
|
|
39
39
|
"@atlaskit/layering": "^0.2.0",
|
|
40
40
|
"@atlaskit/locale": "^2.6.0",
|
|
41
41
|
"@atlaskit/platform-feature-flags": "^0.2.0",
|
|
42
42
|
"@atlaskit/popper": "^5.5.0",
|
|
43
|
-
"@atlaskit/select": "^
|
|
43
|
+
"@atlaskit/select": "^17.0.0",
|
|
44
44
|
"@atlaskit/theme": "^12.6.0",
|
|
45
45
|
"@atlaskit/tokens": "^1.28.0",
|
|
46
46
|
"@babel/runtime": "^7.0.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@af/accessibility-testing": "*",
|
|
57
|
-
"@atlaskit/button": "^16.
|
|
57
|
+
"@atlaskit/button": "^16.16.0",
|
|
58
58
|
"@atlaskit/docs": "*",
|
|
59
59
|
"@atlaskit/form": "^9.0.0",
|
|
60
60
|
"@atlaskit/modal-dialog": "^12.8.0",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"@atlaskit/section-message": "^6.4.0",
|
|
64
64
|
"@atlaskit/ssr": "*",
|
|
65
65
|
"@atlaskit/textfield": "^5.6.0",
|
|
66
|
-
"@atlaskit/toggle": "^
|
|
66
|
+
"@atlaskit/toggle": "^13.0.0",
|
|
67
67
|
"@atlaskit/visual-regression": "*",
|
|
68
68
|
"@atlaskit/webdriver-runner": "*",
|
|
69
69
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|