@atlaskit/datetime-picker 14.0.2 → 14.0.4
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 +17 -0
- package/dist/cjs/components/date-picker.js +45 -92
- package/dist/cjs/components/date-time-picker.js +1 -1
- package/dist/cjs/components/time-picker.js +284 -312
- package/dist/cjs/internal/date-picker-migration.js +92 -0
- package/dist/es2019/components/date-picker.js +24 -76
- package/dist/es2019/components/date-time-picker.js +1 -1
- package/dist/es2019/components/time-picker.js +246 -297
- package/dist/es2019/internal/date-picker-migration.js +90 -0
- package/dist/esm/components/date-picker.js +47 -94
- package/dist/esm/components/date-time-picker.js +1 -1
- package/dist/esm/components/time-picker.js +283 -313
- package/dist/esm/internal/date-picker-migration.js +85 -0
- package/dist/types/components/date-picker.d.ts +2 -19
- package/dist/types/components/time-picker.d.ts +2 -104
- package/dist/types/internal/date-picker-migration.d.ts +51 -0
- package/dist/types/types.d.ts +4 -0
- package/dist/types-ts4.5/components/date-picker.d.ts +2 -19
- package/dist/types-ts4.5/components/time-picker.d.ts +2 -104
- package/dist/types-ts4.5/internal/date-picker-migration.d.ts +51 -0
- package/dist/types-ts4.5/types.d.ts +4 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/datetime-picker
|
|
2
2
|
|
|
3
|
+
## 14.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#137180](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/137180)
|
|
8
|
+
[`a12a34f29c819`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a12a34f29c819) -
|
|
9
|
+
Refactor internal functions.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 14.0.3
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#137357](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/137357)
|
|
17
|
+
[`023251c8a0af7`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/023251c8a0af7) -
|
|
18
|
+
Converting the time picker from a class component into a functional component.
|
|
19
|
+
|
|
3
20
|
## 14.0.2
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = exports.DatePickerWithoutAnalytics = void 0;
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
12
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
@@ -23,9 +22,9 @@ var _calendar = _interopRequireDefault(require("@atlaskit/icon/glyph/calendar"))
|
|
|
23
22
|
var _locale = require("@atlaskit/locale");
|
|
24
23
|
var _select = _interopRequireWildcard(require("@atlaskit/select"));
|
|
25
24
|
var _internal = require("../internal");
|
|
25
|
+
var _datePickerMigration = require("../internal/date-picker-migration");
|
|
26
26
|
var _menu = require("../internal/menu");
|
|
27
27
|
var _parseDate = require("../internal/parse-date");
|
|
28
|
-
var _parseTokens = require("../internal/parse-tokens");
|
|
29
28
|
var _singleValue = require("../internal/single-value");
|
|
30
29
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
31
30
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -37,7 +36,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
37
36
|
* @jsx jsx
|
|
38
37
|
*/ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
39
38
|
var packageName = "@atlaskit/datetime-picker";
|
|
40
|
-
var packageVersion = "14.0.
|
|
39
|
+
var packageVersion = "14.0.4";
|
|
41
40
|
var datePickerDefaultProps = {
|
|
42
41
|
appearance: 'default',
|
|
43
42
|
autoFocus: false,
|
|
@@ -86,29 +85,12 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
|
|
|
86
85
|
var _this$props$isOpen;
|
|
87
86
|
return (_this$props$isOpen = _this.props.isOpen) !== null && _this$props$isOpen !== void 0 ? _this$props$isOpen : _this.state.isOpen;
|
|
88
87
|
});
|
|
89
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isDateDisabled", function (date) {
|
|
90
|
-
return _this.props.disabled.indexOf(date) > -1;
|
|
91
|
-
});
|
|
92
88
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onCalendarChange", function (_ref) {
|
|
93
89
|
var iso = _ref.iso;
|
|
94
|
-
var _iso$split = iso.split('-'),
|
|
95
|
-
_iso$split2 = (0, _slicedToArray2.default)(_iso$split, 3),
|
|
96
|
-
year = _iso$split2[0],
|
|
97
|
-
month = _iso$split2[1],
|
|
98
|
-
date = _iso$split2[2];
|
|
99
|
-
var newIso = iso;
|
|
100
|
-
var parsedDate = parseInt(date, 10);
|
|
101
|
-
var parsedMonth = parseInt(month, 10);
|
|
102
|
-
var parsedYear = parseInt(year, 10);
|
|
103
|
-
var lastDayInMonth = (0, _dateFns.lastDayOfMonth)(new Date(parsedYear, parsedMonth - 1) // This needs to be -1, because the Date constructor expects an index of the given month
|
|
104
|
-
).getDate();
|
|
105
|
-
if (lastDayInMonth < parsedDate) {
|
|
106
|
-
newIso = "".concat(year, "-").concat((0, _internal.padToTwo)(parsedMonth), "-").concat((0, _internal.padToTwo)(lastDayInMonth));
|
|
107
|
-
} else {
|
|
108
|
-
newIso = "".concat(year, "-").concat((0, _internal.padToTwo)(parsedMonth), "-").concat((0, _internal.padToTwo)(parsedDate));
|
|
109
|
-
}
|
|
110
90
|
_this.setState({
|
|
111
|
-
calendarValue:
|
|
91
|
+
calendarValue: (0, _datePickerMigration.getParsedISO)({
|
|
92
|
+
iso: iso
|
|
93
|
+
})
|
|
112
94
|
});
|
|
113
95
|
});
|
|
114
96
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onCalendarSelect", function (_ref2) {
|
|
@@ -193,7 +175,11 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
|
|
|
193
175
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onTextInput", function (event) {
|
|
194
176
|
var inputValue = event.target.value;
|
|
195
177
|
if (inputValue) {
|
|
196
|
-
var parsed =
|
|
178
|
+
var parsed = (0, _datePickerMigration.parseDate)(inputValue, {
|
|
179
|
+
parseInputValue: _this.props.parseInputValue,
|
|
180
|
+
dateFormat: _this.props.dateFormat,
|
|
181
|
+
l10n: _this.state.l10n
|
|
182
|
+
});
|
|
197
183
|
// Only try to set the date if we have month & day
|
|
198
184
|
if (parsed && (0, _dateFns.isValid)(parsed)) {
|
|
199
185
|
// We format the parsed date to YYYY-MM-DD here because
|
|
@@ -255,7 +241,9 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
|
|
|
255
241
|
// using enter. See https://product-fabric.atlassian.net/browse/DSP-2501
|
|
256
242
|
// for more details.
|
|
257
243
|
event.preventDefault();
|
|
258
|
-
if (!
|
|
244
|
+
if (!(0, _datePickerMigration.isDateDisabled)(calendarValue, {
|
|
245
|
+
disabled: _this.props.disabled
|
|
246
|
+
})) {
|
|
259
247
|
// Get a safe `calendarValue` in case the value exceeds the maximum
|
|
260
248
|
// allowed by ISO 8601
|
|
261
249
|
var safeCalendarValue = (0, _parseDate.getSafeCalendarValue)(calendarValue);
|
|
@@ -322,48 +310,6 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
|
|
|
322
310
|
_this.forceUpdate();
|
|
323
311
|
}
|
|
324
312
|
});
|
|
325
|
-
/**
|
|
326
|
-
* There are two props that can change how the date is parsed.
|
|
327
|
-
* The priority of props used is:
|
|
328
|
-
* 1. `parseInputValue`
|
|
329
|
-
* 2. `locale`
|
|
330
|
-
*/
|
|
331
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "parseDate", function (date) {
|
|
332
|
-
var _this$props = _this.props,
|
|
333
|
-
parseInputValue = _this$props.parseInputValue,
|
|
334
|
-
dateFormat = _this$props.dateFormat;
|
|
335
|
-
if (parseInputValue) {
|
|
336
|
-
return parseInputValue(date, dateFormat || _internal.defaultDateFormat);
|
|
337
|
-
}
|
|
338
|
-
var l10n = _this.state.l10n;
|
|
339
|
-
return l10n.parseDate(date);
|
|
340
|
-
});
|
|
341
|
-
/**
|
|
342
|
-
* There are multiple props that can change how the date is formatted.
|
|
343
|
-
* The priority of props used is:
|
|
344
|
-
* 1. `formatDisplayLabel`
|
|
345
|
-
* 2. `dateFormat`
|
|
346
|
-
* 3. `locale`
|
|
347
|
-
*/
|
|
348
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "formatDate", function (value) {
|
|
349
|
-
var _this$props2 = _this.props,
|
|
350
|
-
formatDisplayLabel = _this$props2.formatDisplayLabel,
|
|
351
|
-
dateFormat = _this$props2.dateFormat;
|
|
352
|
-
var l10n = _this.state.l10n;
|
|
353
|
-
if (formatDisplayLabel) {
|
|
354
|
-
return formatDisplayLabel(value, dateFormat || _internal.defaultDateFormat);
|
|
355
|
-
}
|
|
356
|
-
var date = (0, _dateFns.parseISO)(value);
|
|
357
|
-
return dateFormat ? (0, _dateFns.format)(date, (0, _parseTokens.convertTokens)(dateFormat)) : l10n.formatDate(date);
|
|
358
|
-
});
|
|
359
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getPlaceholder", function () {
|
|
360
|
-
var placeholder = _this.props.placeholder;
|
|
361
|
-
if (placeholder) {
|
|
362
|
-
return placeholder;
|
|
363
|
-
}
|
|
364
|
-
var l10n = _this.state.l10n;
|
|
365
|
-
return l10n.formatDate(_internal.placeholderDatetime);
|
|
366
|
-
});
|
|
367
313
|
_this.state = {
|
|
368
314
|
isOpen: _this.props.defaultIsOpen,
|
|
369
315
|
isFocused: false,
|
|
@@ -380,29 +326,29 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
|
|
|
380
326
|
(0, _createClass2.default)(DatePickerComponent, [{
|
|
381
327
|
key: "render",
|
|
382
328
|
value: function render() {
|
|
383
|
-
var _this$
|
|
384
|
-
appearance = _this$
|
|
385
|
-
ariaDescribedBy = _this$
|
|
386
|
-
autoFocus = _this$
|
|
387
|
-
disabled = _this$
|
|
388
|
-
hideIcon = _this$
|
|
389
|
-
icon = _this$
|
|
390
|
-
id = _this$
|
|
391
|
-
innerProps = _this$
|
|
392
|
-
isDisabled = _this$
|
|
393
|
-
disabledDateFilter = _this$
|
|
394
|
-
maxDate = _this$
|
|
395
|
-
minDate = _this$
|
|
396
|
-
isInvalid = _this$
|
|
397
|
-
label = _this$
|
|
398
|
-
name = _this$
|
|
399
|
-
nextMonthLabel = _this$
|
|
400
|
-
previousMonthLabel = _this$
|
|
401
|
-
selectProps = _this$
|
|
402
|
-
spacing = _this$
|
|
403
|
-
locale = _this$
|
|
404
|
-
testId = _this$
|
|
405
|
-
weekStartDay = _this$
|
|
329
|
+
var _this$props = this.props,
|
|
330
|
+
appearance = _this$props.appearance,
|
|
331
|
+
ariaDescribedBy = _this$props['aria-describedby'],
|
|
332
|
+
autoFocus = _this$props.autoFocus,
|
|
333
|
+
disabled = _this$props.disabled,
|
|
334
|
+
hideIcon = _this$props.hideIcon,
|
|
335
|
+
icon = _this$props.icon,
|
|
336
|
+
id = _this$props.id,
|
|
337
|
+
innerProps = _this$props.innerProps,
|
|
338
|
+
isDisabled = _this$props.isDisabled,
|
|
339
|
+
disabledDateFilter = _this$props.disabledDateFilter,
|
|
340
|
+
maxDate = _this$props.maxDate,
|
|
341
|
+
minDate = _this$props.minDate,
|
|
342
|
+
isInvalid = _this$props.isInvalid,
|
|
343
|
+
label = _this$props.label,
|
|
344
|
+
name = _this$props.name,
|
|
345
|
+
nextMonthLabel = _this$props.nextMonthLabel,
|
|
346
|
+
previousMonthLabel = _this$props.previousMonthLabel,
|
|
347
|
+
selectProps = _this$props.selectProps,
|
|
348
|
+
spacing = _this$props.spacing,
|
|
349
|
+
locale = _this$props.locale,
|
|
350
|
+
testId = _this$props.testId,
|
|
351
|
+
weekStartDay = _this$props.weekStartDay;
|
|
406
352
|
var _this$state = this.state,
|
|
407
353
|
calendarValue = _this$state.calendarValue,
|
|
408
354
|
selectInputValue = _this$state.selectInputValue;
|
|
@@ -455,7 +401,11 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
|
|
|
455
401
|
}
|
|
456
402
|
});
|
|
457
403
|
var initialValue = value ? {
|
|
458
|
-
label:
|
|
404
|
+
label: (0, _datePickerMigration.formatDate)(value, {
|
|
405
|
+
formatDisplayLabel: this.props.formatDisplayLabel,
|
|
406
|
+
dateFormat: this.props.dateFormat,
|
|
407
|
+
l10n: this.state.l10n
|
|
408
|
+
}),
|
|
459
409
|
value: value
|
|
460
410
|
} : null;
|
|
461
411
|
return (
|
|
@@ -491,7 +441,10 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
|
|
|
491
441
|
onChange: this.onSelectChange,
|
|
492
442
|
onFocus: this.onSelectFocus,
|
|
493
443
|
onInputChange: this.handleSelectInputChange,
|
|
494
|
-
placeholder:
|
|
444
|
+
placeholder: (0, _datePickerMigration.getPlaceholder)({
|
|
445
|
+
placeholder: this.props.placeholder,
|
|
446
|
+
l10n: this.state.l10n
|
|
447
|
+
}),
|
|
495
448
|
styles: mergedStyles,
|
|
496
449
|
value: initialValue
|
|
497
450
|
}, selectProps, {
|
|
@@ -35,7 +35,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
35
35
|
* @jsx jsx
|
|
36
36
|
*/ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
37
37
|
var packageName = "@atlaskit/datetime-picker";
|
|
38
|
-
var packageVersion = "14.0.
|
|
38
|
+
var packageVersion = "14.0.4";
|
|
39
39
|
// Make DatePicker 50% the width of DateTimePicker
|
|
40
40
|
// If rendering an icon container, shrink the TimePicker
|
|
41
41
|
var datePickerContainerStyles = (0, _react2.css)({
|