@atlaskit/datetime-picker 13.11.2 → 13.11.3
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 +8 -0
- package/dist/cjs/components/date-picker.js +22 -24
- package/dist/cjs/components/date-time-picker.js +50 -44
- package/dist/cjs/components/time-picker.js +13 -11
- package/dist/es2019/components/date-picker.js +21 -22
- package/dist/es2019/components/date-time-picker.js +43 -47
- package/dist/es2019/components/time-picker.js +13 -14
- package/dist/esm/components/date-picker.js +22 -24
- package/dist/esm/components/date-time-picker.js +50 -44
- package/dist/esm/components/time-picker.js +13 -11
- package/dist/types/components/date-picker.d.ts +2 -12
- package/dist/types/components/date-time-picker.d.ts +2 -3
- package/dist/types/components/time-picker.d.ts +2 -1
- package/dist/types-ts4.5/components/date-picker.d.ts +2 -12
- package/dist/types-ts4.5/components/date-time-picker.d.ts +2 -3
- package/dist/types-ts4.5/components/time-picker.d.ts +2 -1
- package/package.json +4 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/datetime-picker
|
|
2
2
|
|
|
3
|
+
## 13.11.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#132041](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/132041)
|
|
8
|
+
[`ce77b41a18a18`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ce77b41a18a18) -
|
|
9
|
+
Refactoring internal state management within the pickers.
|
|
10
|
+
|
|
3
11
|
## 13.11.2
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -18,7 +18,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
18
18
|
var _react = require("react");
|
|
19
19
|
var _react2 = require("@emotion/react");
|
|
20
20
|
var _dateFns = require("date-fns");
|
|
21
|
-
var _pick = _interopRequireDefault(require("lodash/pick"));
|
|
22
21
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
23
22
|
var _calendar = _interopRequireDefault(require("@atlaskit/icon/glyph/calendar"));
|
|
24
23
|
var _locale = require("@atlaskit/locale");
|
|
@@ -38,7 +37,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
38
37
|
* @jsx jsx
|
|
39
38
|
*/ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
40
39
|
var packageName = "@atlaskit/datetime-picker";
|
|
41
|
-
var packageVersion = "13.11.
|
|
40
|
+
var packageVersion = "13.11.3";
|
|
42
41
|
var datePickerDefaultProps = {
|
|
43
42
|
appearance: 'default',
|
|
44
43
|
autoFocus: false,
|
|
@@ -80,8 +79,13 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
|
|
|
80
79
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "containerRef", null);
|
|
81
80
|
// All state needs to be accessed via this function so that the state is mapped from props
|
|
82
81
|
// correctly to allow controlled/uncontrolled usage.
|
|
83
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "
|
|
84
|
-
|
|
82
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getValue", function () {
|
|
83
|
+
var _this$props$value;
|
|
84
|
+
return (_this$props$value = _this.props.value) !== null && _this$props$value !== void 0 ? _this$props$value : _this.state.value;
|
|
85
|
+
});
|
|
86
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getIsOpen", function () {
|
|
87
|
+
var _this$props$isOpen;
|
|
88
|
+
return (_this$props$isOpen = _this.props.isOpen) !== null && _this$props$isOpen !== void 0 ? _this$props$isOpen : _this.state.isOpen;
|
|
85
89
|
});
|
|
86
90
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isDateDisabled", function (date) {
|
|
87
91
|
return _this.props.disabled.indexOf(date) > -1;
|
|
@@ -131,7 +135,7 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
|
|
|
131
135
|
});
|
|
132
136
|
});
|
|
133
137
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onInputClick", function () {
|
|
134
|
-
if (!_this.props.isDisabled && !_this.
|
|
138
|
+
if (!_this.props.isDisabled && !_this.getIsOpen()) {
|
|
135
139
|
_this.setState({
|
|
136
140
|
isOpen: true
|
|
137
141
|
});
|
|
@@ -156,7 +160,7 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
|
|
|
156
160
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onSelectBlur", function (event) {
|
|
157
161
|
var _this$containerRef3;
|
|
158
162
|
var newlyFocusedElement = event.relatedTarget;
|
|
159
|
-
if (_this.
|
|
163
|
+
if (_this.state.clearingFromIcon) {
|
|
160
164
|
// Don't close menu if blurring after the user has clicked clear
|
|
161
165
|
_this.setState({
|
|
162
166
|
clearingFromIcon: false
|
|
@@ -171,9 +175,8 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
|
|
|
171
175
|
}
|
|
172
176
|
});
|
|
173
177
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onSelectFocus", function (event) {
|
|
174
|
-
var
|
|
175
|
-
|
|
176
|
-
value = _this$getSafeState.value;
|
|
178
|
+
var clearingFromIcon = _this.state.clearingFromIcon;
|
|
179
|
+
var value = _this.getValue();
|
|
177
180
|
if (clearingFromIcon) {
|
|
178
181
|
// Don't open menu if focussing after the user has clicked clear
|
|
179
182
|
_this.setState({
|
|
@@ -207,9 +210,8 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
|
|
|
207
210
|
});
|
|
208
211
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onInputKeyDown", function (event) {
|
|
209
212
|
var _this$containerRef4;
|
|
210
|
-
var
|
|
211
|
-
|
|
212
|
-
calendarValue = _this$getSafeState2.calendarValue;
|
|
213
|
+
var calendarValue = _this.state.calendarValue;
|
|
214
|
+
var value = _this.getValue();
|
|
213
215
|
var keyPressed = event.key.toLowerCase();
|
|
214
216
|
|
|
215
217
|
// If the input is focused and the calendar is not visible, handle space and enter clicks
|
|
@@ -337,8 +339,7 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
|
|
|
337
339
|
if (parseInputValue) {
|
|
338
340
|
return parseInputValue(date, dateFormat || _internal.defaultDateFormat);
|
|
339
341
|
}
|
|
340
|
-
var
|
|
341
|
-
l10n = _this$getSafeState3.l10n;
|
|
342
|
+
var l10n = _this.state.l10n;
|
|
342
343
|
return l10n.parseDate(date);
|
|
343
344
|
});
|
|
344
345
|
/**
|
|
@@ -352,8 +353,7 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
|
|
|
352
353
|
var _this$props2 = _this.props,
|
|
353
354
|
formatDisplayLabel = _this$props2.formatDisplayLabel,
|
|
354
355
|
dateFormat = _this$props2.dateFormat;
|
|
355
|
-
var
|
|
356
|
-
l10n = _this$getSafeState4.l10n;
|
|
356
|
+
var l10n = _this.state.l10n;
|
|
357
357
|
if (formatDisplayLabel) {
|
|
358
358
|
return formatDisplayLabel(value, dateFormat || _internal.defaultDateFormat);
|
|
359
359
|
}
|
|
@@ -365,8 +365,7 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
|
|
|
365
365
|
if (placeholder) {
|
|
366
366
|
return placeholder;
|
|
367
367
|
}
|
|
368
|
-
var
|
|
369
|
-
l10n = _this$getSafeState5.l10n;
|
|
368
|
+
var l10n = _this.state.l10n;
|
|
370
369
|
return l10n.formatDate(_internal.placeholderDatetime);
|
|
371
370
|
});
|
|
372
371
|
_this.state = {
|
|
@@ -408,14 +407,13 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
|
|
|
408
407
|
locale = _this$props3.locale,
|
|
409
408
|
testId = _this$props3.testId,
|
|
410
409
|
weekStartDay = _this$props3.weekStartDay;
|
|
411
|
-
var _this$
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
selectInputValue = _this$getSafeState6.selectInputValue;
|
|
410
|
+
var _this$state = this.state,
|
|
411
|
+
calendarValue = _this$state.calendarValue,
|
|
412
|
+
selectInputValue = _this$state.selectInputValue;
|
|
413
|
+
var value = this.getValue();
|
|
416
414
|
var actualSelectInputValue;
|
|
417
415
|
actualSelectInputValue = selectInputValue;
|
|
418
|
-
var menuIsOpen =
|
|
416
|
+
var menuIsOpen = this.getIsOpen() && !isDisabled;
|
|
419
417
|
var showClearIndicator = Boolean((value || selectInputValue) && !hideIcon);
|
|
420
418
|
var dropDownIcon = appearance === 'subtle' || hideIcon || showClearIndicator ? null : icon;
|
|
421
419
|
var SingleValue = (0, _singleValue.makeSingleValue)({
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.timePickerDefaultAriaLabel = exports.default = exports.datePickerDefaultAriaLabel = exports.DateTimePickerWithoutAnalytics = void 0;
|
|
8
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
10
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
@@ -16,7 +15,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
16
15
|
var _react = _interopRequireDefault(require("react"));
|
|
17
16
|
var _react2 = require("@emotion/react");
|
|
18
17
|
var _dateFns = require("date-fns");
|
|
19
|
-
var _pick = _interopRequireDefault(require("lodash/pick"));
|
|
20
18
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
21
19
|
var _selectClear = _interopRequireDefault(require("@atlaskit/icon/glyph/select-clear"));
|
|
22
20
|
var _select = require("@atlaskit/select");
|
|
@@ -34,7 +32,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
34
32
|
* @jsx jsx
|
|
35
33
|
*/ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
36
34
|
var packageName = "@atlaskit/datetime-picker";
|
|
37
|
-
var packageVersion = "13.11.
|
|
35
|
+
var packageVersion = "13.11.3";
|
|
38
36
|
// Make DatePicker 50% the width of DateTimePicker
|
|
39
37
|
// If rendering an icon container, shrink the TimePicker
|
|
40
38
|
var datePickerContainerStyles = (0, _react2.css)({
|
|
@@ -127,9 +125,12 @@ var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE
|
|
|
127
125
|
});
|
|
128
126
|
// All state needs to be accessed via this function so that the state is mapped from props
|
|
129
127
|
// correctly to allow controlled/uncontrolled usage.
|
|
130
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "
|
|
131
|
-
|
|
132
|
-
|
|
128
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getParsedValues", function () {
|
|
129
|
+
return _this.parseValue(_this.getValue(), _this.state.dateValue, _this.state.timeValue, _this.state.zoneValue);
|
|
130
|
+
});
|
|
131
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getValue", function () {
|
|
132
|
+
var _this$props$value;
|
|
133
|
+
return (_this$props$value = _this.props.value) !== null && _this$props$value !== void 0 ? _this$props$value : _this.state.value;
|
|
133
134
|
});
|
|
134
135
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onBlur", function (event) {
|
|
135
136
|
_this.setState({
|
|
@@ -144,20 +145,28 @@ var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE
|
|
|
144
145
|
_this.props.onFocus(event);
|
|
145
146
|
});
|
|
146
147
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onDateChange", function (dateValue) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
var parsedValues = _this.getParsedValues();
|
|
149
|
+
_this.onValueChange({
|
|
150
|
+
dateValue: dateValue,
|
|
151
|
+
timeValue: parsedValues.timeValue,
|
|
152
|
+
zoneValue: parsedValues.zoneValue
|
|
153
|
+
});
|
|
150
154
|
});
|
|
151
155
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onTimeChange", function (timeValue) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
156
|
+
var parsedValues = _this.getParsedValues();
|
|
157
|
+
_this.onValueChange({
|
|
158
|
+
dateValue: parsedValues.dateValue,
|
|
159
|
+
timeValue: timeValue,
|
|
160
|
+
zoneValue: parsedValues.zoneValue
|
|
161
|
+
});
|
|
155
162
|
});
|
|
156
163
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onClear", function () {
|
|
157
|
-
|
|
164
|
+
var parsedValues = _this.getParsedValues();
|
|
165
|
+
_this.onValueChange({
|
|
166
|
+
dateValue: '',
|
|
158
167
|
timeValue: '',
|
|
159
|
-
|
|
160
|
-
})
|
|
168
|
+
zoneValue: parsedValues.zoneValue
|
|
169
|
+
});
|
|
161
170
|
});
|
|
162
171
|
return _this;
|
|
163
172
|
}
|
|
@@ -165,7 +174,18 @@ var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE
|
|
|
165
174
|
key: "parseValue",
|
|
166
175
|
value: function parseValue(value, dateValue, timeValue, zoneValue) {
|
|
167
176
|
if (this.props.parseValue) {
|
|
168
|
-
|
|
177
|
+
var parsedFromFn = this.props.parseValue(value, dateValue, timeValue, zoneValue);
|
|
178
|
+
// This handles cases found in Jira where the parse function actually does
|
|
179
|
+
// nothing and returns undefined. The previous `getSafeState` function
|
|
180
|
+
// just spread the values over the state, but if it returned `undefined`,
|
|
181
|
+
// it would just rely on the previous state values. Considering this is
|
|
182
|
+
// what is input to this function anyway, this is a safe way to handle
|
|
183
|
+
// this, colocate the behavior, and not rely on `getSafeState`.
|
|
184
|
+
return parsedFromFn || {
|
|
185
|
+
dateValue: dateValue,
|
|
186
|
+
timeValue: timeValue,
|
|
187
|
+
zoneValue: zoneValue
|
|
188
|
+
};
|
|
169
189
|
}
|
|
170
190
|
var parsed = (0, _dateFns.parseISO)(value);
|
|
171
191
|
return (0, _dateFns.isValid)(parsed) ? {
|
|
@@ -199,7 +219,7 @@ var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE
|
|
|
199
219
|
});
|
|
200
220
|
this.props.onChange(valueWithValidZone);
|
|
201
221
|
// If the date or time value was cleared when there is an existing datetime value, then clear the value.
|
|
202
|
-
} else if (this.
|
|
222
|
+
} else if (this.getValue()) {
|
|
203
223
|
this.setState({
|
|
204
224
|
value: ''
|
|
205
225
|
});
|
|
@@ -229,11 +249,11 @@ var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE
|
|
|
229
249
|
timePickerProps = _this$props.timePickerProps,
|
|
230
250
|
timePickerSelectProps = _this$props.timePickerSelectProps,
|
|
231
251
|
times = _this$props.times;
|
|
232
|
-
var
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
252
|
+
var value = this.getValue();
|
|
253
|
+
var isFocused = this.state.isFocused;
|
|
254
|
+
var parsedValues = this.getParsedValues();
|
|
255
|
+
var dateValue = parsedValues === null || parsedValues === void 0 ? void 0 : parsedValues.dateValue;
|
|
256
|
+
var timeValue = parsedValues === null || parsedValues === void 0 ? void 0 : parsedValues.timeValue;
|
|
237
257
|
var _datePickerSelectProp = datePickerSelectProps.styles,
|
|
238
258
|
datePickerStyles = _datePickerSelectProp === void 0 ? {} : _datePickerSelectProp;
|
|
239
259
|
var _timePickerSelectProp = timePickerSelectProps.styles,
|
|
@@ -266,7 +286,7 @@ var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE
|
|
|
266
286
|
"data-testid": testId && "".concat(testId, "--input")
|
|
267
287
|
}), (0, _react2.jsx)("div", {
|
|
268
288
|
css: datePickerContainerStyles
|
|
269
|
-
}, (0, _react2.jsx)(_datePicker.default,
|
|
289
|
+
}, (0, _react2.jsx)(_datePicker.default, {
|
|
270
290
|
appearance: appearance,
|
|
271
291
|
autoFocus: datePickerProps.autoFocus || autoFocus,
|
|
272
292
|
dateFormat: datePickerProps.dateFormat || dateFormat,
|
|
@@ -280,15 +300,8 @@ var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE
|
|
|
280
300
|
id: datePickerProps.id || id,
|
|
281
301
|
innerProps: datePickerProps.innerProps,
|
|
282
302
|
isDisabled: datePickerProps.isDisabled || isDisabled,
|
|
283
|
-
isInvalid: datePickerProps.isInvalid || isInvalid
|
|
284
|
-
|
|
285
|
-
// `isOpen={datePickerProps.isOpen}`, the date picker will set
|
|
286
|
-
// `isOpen` to `undefined` forever. I believe this has to do with
|
|
287
|
-
// the `getSafeState` function in the picker, since it overwrites
|
|
288
|
-
// state with values from the props.
|
|
289
|
-
}, datePickerProps.isOpen ? {
|
|
290
|
-
isOpen: datePickerProps.isOpen
|
|
291
|
-
} : {}, {
|
|
303
|
+
isInvalid: datePickerProps.isInvalid || isInvalid,
|
|
304
|
+
isOpen: datePickerProps.isOpen,
|
|
292
305
|
locale: datePickerProps.locale || locale,
|
|
293
306
|
maxDate: datePickerProps.maxDate,
|
|
294
307
|
minDate: datePickerProps.minDate,
|
|
@@ -305,9 +318,9 @@ var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE
|
|
|
305
318
|
testId: testId && "".concat(testId, "--datepicker") || datePickerProps.testId,
|
|
306
319
|
value: dateValue,
|
|
307
320
|
weekStartDay: datePickerProps.weekStartDay
|
|
308
|
-
}))
|
|
321
|
+
})), (0, _react2.jsx)("div", {
|
|
309
322
|
css: timePickerContainerStyles
|
|
310
|
-
}, (0, _react2.jsx)(_timePicker.default,
|
|
323
|
+
}, (0, _react2.jsx)(_timePicker.default, {
|
|
311
324
|
appearance: timePickerProps.appearance || appearance,
|
|
312
325
|
autoFocus: timePickerProps.autoFocus,
|
|
313
326
|
defaultIsOpen: timePickerProps.defaultIsOpen,
|
|
@@ -317,15 +330,8 @@ var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE
|
|
|
317
330
|
id: timePickerProps.id,
|
|
318
331
|
innerProps: timePickerProps.innerProps,
|
|
319
332
|
isDisabled: timePickerProps.isDisabled || isDisabled,
|
|
320
|
-
isInvalid: timePickerProps.isInvalid || isInvalid
|
|
321
|
-
|
|
322
|
-
// `isOpen={datePickerProps.isOpen}`, the date picker will set
|
|
323
|
-
// `isOpen` to `undefined` forever. I believe this has to do with
|
|
324
|
-
// the `getSafeState` function in the picker, since it overwrites
|
|
325
|
-
// state with values from the props.
|
|
326
|
-
}, timePickerProps.isOpen ? {
|
|
327
|
-
isOpen: timePickerProps.isOpen
|
|
328
|
-
} : {}, {
|
|
333
|
+
isInvalid: timePickerProps.isInvalid || isInvalid,
|
|
334
|
+
isOpen: timePickerProps.isOpen,
|
|
329
335
|
locale: timePickerProps.locale || locale,
|
|
330
336
|
name: timePickerProps.name,
|
|
331
337
|
onBlur: timePickerProps.onBlur || this.onBlur,
|
|
@@ -340,7 +346,7 @@ var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE
|
|
|
340
346
|
timeIsEditable: timePickerProps.timeIsEditable || timeIsEditable,
|
|
341
347
|
times: timePickerProps.times || times,
|
|
342
348
|
value: timeValue
|
|
343
|
-
}))
|
|
349
|
+
})), isClearable && !isDisabled ? (0, _react2.jsx)("button", {
|
|
344
350
|
css: iconContainerStyles,
|
|
345
351
|
onClick: this.onClear,
|
|
346
352
|
"data-testid": testId && "".concat(testId, "--icon--container"),
|
|
@@ -17,7 +17,6 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
|
|
|
17
17
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
18
18
|
var _react = _interopRequireDefault(require("react"));
|
|
19
19
|
var _dateFns = require("date-fns");
|
|
20
|
-
var _pick = _interopRequireDefault(require("lodash/pick"));
|
|
21
20
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
22
21
|
var _locale = require("@atlaskit/locale");
|
|
23
22
|
var _select = _interopRequireWildcard(require("@atlaskit/select"));
|
|
@@ -36,7 +35,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
36
35
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } // eslint-disable-next-line no-restricted-imports
|
|
37
36
|
// eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
|
|
38
37
|
var packageName = "@atlaskit/datetime-picker";
|
|
39
|
-
var packageVersion = "13.11.
|
|
38
|
+
var packageVersion = "13.11.3";
|
|
40
39
|
var menuStyles = {
|
|
41
40
|
/* Need to remove default absolute positioning as that causes issues with position fixed */
|
|
42
41
|
position: 'static',
|
|
@@ -94,8 +93,13 @@ var TimePickerComponent = exports.TimePickerWithoutAnalytics = /*#__PURE__*/func
|
|
|
94
93
|
});
|
|
95
94
|
// All state needs to be accessed via this function so that the state is mapped from props
|
|
96
95
|
// correctly to allow controlled/uncontrolled usage.
|
|
97
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "
|
|
98
|
-
|
|
96
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getValue", function () {
|
|
97
|
+
var _this$props$value;
|
|
98
|
+
return (_this$props$value = _this.props.value) !== null && _this$props$value !== void 0 ? _this$props$value : _this.state.value;
|
|
99
|
+
});
|
|
100
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getIsOpen", function () {
|
|
101
|
+
var _this$props$isOpen;
|
|
102
|
+
return (_this$props$isOpen = _this.props.isOpen) !== null && _this$props$isOpen !== void 0 ? _this$props$isOpen : _this.state.isOpen;
|
|
99
103
|
});
|
|
100
104
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onChange", function (newValue, action) {
|
|
101
105
|
var rawValue = newValue ? newValue.value || newValue : '';
|
|
@@ -138,7 +142,7 @@ var TimePickerComponent = exports.TimePickerWithoutAnalytics = /*#__PURE__*/func
|
|
|
138
142
|
});
|
|
139
143
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onMenuOpen", function () {
|
|
140
144
|
// Don't open menu after the user has clicked clear
|
|
141
|
-
if (_this.
|
|
145
|
+
if (_this.state.clearingFromIcon) {
|
|
142
146
|
_this.setState({
|
|
143
147
|
clearingFromIcon: false
|
|
144
148
|
});
|
|
@@ -150,7 +154,7 @@ var TimePickerComponent = exports.TimePickerWithoutAnalytics = /*#__PURE__*/func
|
|
|
150
154
|
});
|
|
151
155
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onMenuClose", function () {
|
|
152
156
|
// Don't close menu after the user has clicked clear
|
|
153
|
-
if (_this.
|
|
157
|
+
if (_this.state.clearingFromIcon) {
|
|
154
158
|
_this.setState({
|
|
155
159
|
clearingFromIcon: false
|
|
156
160
|
});
|
|
@@ -184,7 +188,7 @@ var TimePickerComponent = exports.TimePickerWithoutAnalytics = /*#__PURE__*/func
|
|
|
184
188
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onSelectKeyDown", function (event) {
|
|
185
189
|
var key = event.key;
|
|
186
190
|
var keyPressed = key.toLowerCase();
|
|
187
|
-
if (_this.
|
|
191
|
+
if (_this.state.clearingFromIcon && (keyPressed === 'backspace' || keyPressed === 'delete')) {
|
|
188
192
|
// If being cleared from keyboard, don't change behaviour
|
|
189
193
|
_this.setState({
|
|
190
194
|
clearingFromIcon: false
|
|
@@ -219,10 +223,8 @@ var TimePickerComponent = exports.TimePickerWithoutAnalytics = /*#__PURE__*/func
|
|
|
219
223
|
times = _this$props2.times;
|
|
220
224
|
var ICON_PADDING = 2;
|
|
221
225
|
var l10n = (0, _locale.createLocalizationProvider)(locale);
|
|
222
|
-
var
|
|
223
|
-
|
|
224
|
-
value = _this$getSafeState$va === void 0 ? '' : _this$getSafeState$va,
|
|
225
|
-
isOpen = _this$getSafeState.isOpen;
|
|
226
|
+
var value = this.getValue() || '';
|
|
227
|
+
var isOpen = this.getIsOpen();
|
|
226
228
|
var _selectProps$styles = selectProps.styles,
|
|
227
229
|
selectStyles = _selectProps$styles === void 0 ? {} : _selectProps$styles,
|
|
228
230
|
otherSelectProps = (0, _objectWithoutProperties2.default)(selectProps, _excluded);
|
|
@@ -9,7 +9,6 @@ import { Component } from 'react';
|
|
|
9
9
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
10
10
|
import { jsx } from '@emotion/react';
|
|
11
11
|
import { format, isValid, lastDayOfMonth, parseISO } from 'date-fns';
|
|
12
|
-
import pick from 'lodash/pick';
|
|
13
12
|
import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
14
13
|
import CalendarIcon from '@atlaskit/icon/glyph/calendar';
|
|
15
14
|
import { createLocalizationProvider } from '@atlaskit/locale';
|
|
@@ -20,7 +19,7 @@ import { getSafeCalendarValue, getShortISOString } from '../internal/parse-date'
|
|
|
20
19
|
import { convertTokens } from '../internal/parse-tokens';
|
|
21
20
|
import { makeSingleValue } from '../internal/single-value';
|
|
22
21
|
const packageName = "@atlaskit/datetime-picker";
|
|
23
|
-
const packageVersion = "13.11.
|
|
22
|
+
const packageVersion = "13.11.3";
|
|
24
23
|
const datePickerDefaultProps = {
|
|
25
24
|
appearance: 'default',
|
|
26
25
|
autoFocus: false,
|
|
@@ -56,12 +55,13 @@ class DatePickerComponent extends Component {
|
|
|
56
55
|
_defineProperty(this, "containerRef", null);
|
|
57
56
|
// All state needs to be accessed via this function so that the state is mapped from props
|
|
58
57
|
// correctly to allow controlled/uncontrolled usage.
|
|
59
|
-
_defineProperty(this, "
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
_defineProperty(this, "getValue", () => {
|
|
59
|
+
var _this$props$value;
|
|
60
|
+
return (_this$props$value = this.props.value) !== null && _this$props$value !== void 0 ? _this$props$value : this.state.value;
|
|
61
|
+
});
|
|
62
|
+
_defineProperty(this, "getIsOpen", () => {
|
|
63
|
+
var _this$props$isOpen;
|
|
64
|
+
return (_this$props$isOpen = this.props.isOpen) !== null && _this$props$isOpen !== void 0 ? _this$props$isOpen : this.state.isOpen;
|
|
65
65
|
});
|
|
66
66
|
_defineProperty(this, "isDateDisabled", date => {
|
|
67
67
|
return this.props.disabled.indexOf(date) > -1;
|
|
@@ -109,7 +109,7 @@ class DatePickerComponent extends Component {
|
|
|
109
109
|
});
|
|
110
110
|
});
|
|
111
111
|
_defineProperty(this, "onInputClick", () => {
|
|
112
|
-
if (!this.props.isDisabled && !this.
|
|
112
|
+
if (!this.props.isDisabled && !this.getIsOpen()) {
|
|
113
113
|
this.setState({
|
|
114
114
|
isOpen: true
|
|
115
115
|
});
|
|
@@ -134,7 +134,7 @@ class DatePickerComponent extends Component {
|
|
|
134
134
|
_defineProperty(this, "onSelectBlur", event => {
|
|
135
135
|
var _this$containerRef3;
|
|
136
136
|
const newlyFocusedElement = event.relatedTarget;
|
|
137
|
-
if (this.
|
|
137
|
+
if (this.state.clearingFromIcon) {
|
|
138
138
|
// Don't close menu if blurring after the user has clicked clear
|
|
139
139
|
this.setState({
|
|
140
140
|
clearingFromIcon: false
|
|
@@ -150,9 +150,9 @@ class DatePickerComponent extends Component {
|
|
|
150
150
|
});
|
|
151
151
|
_defineProperty(this, "onSelectFocus", event => {
|
|
152
152
|
const {
|
|
153
|
-
clearingFromIcon
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
clearingFromIcon
|
|
154
|
+
} = this.state;
|
|
155
|
+
const value = this.getValue();
|
|
156
156
|
if (clearingFromIcon) {
|
|
157
157
|
// Don't open menu if focussing after the user has clicked clear
|
|
158
158
|
this.setState({
|
|
@@ -187,9 +187,9 @@ class DatePickerComponent extends Component {
|
|
|
187
187
|
_defineProperty(this, "onInputKeyDown", event => {
|
|
188
188
|
var _this$containerRef4;
|
|
189
189
|
const {
|
|
190
|
-
value,
|
|
191
190
|
calendarValue
|
|
192
|
-
} = this.
|
|
191
|
+
} = this.state;
|
|
192
|
+
const value = this.getValue();
|
|
193
193
|
const keyPressed = event.key.toLowerCase();
|
|
194
194
|
|
|
195
195
|
// If the input is focused and the calendar is not visible, handle space and enter clicks
|
|
@@ -323,7 +323,7 @@ class DatePickerComponent extends Component {
|
|
|
323
323
|
}
|
|
324
324
|
const {
|
|
325
325
|
l10n
|
|
326
|
-
} = this.
|
|
326
|
+
} = this.state;
|
|
327
327
|
return l10n.parseDate(date);
|
|
328
328
|
});
|
|
329
329
|
/**
|
|
@@ -340,7 +340,7 @@ class DatePickerComponent extends Component {
|
|
|
340
340
|
} = this.props;
|
|
341
341
|
const {
|
|
342
342
|
l10n
|
|
343
|
-
} = this.
|
|
343
|
+
} = this.state;
|
|
344
344
|
if (formatDisplayLabel) {
|
|
345
345
|
return formatDisplayLabel(value, dateFormat || defaultDateFormat);
|
|
346
346
|
}
|
|
@@ -356,7 +356,7 @@ class DatePickerComponent extends Component {
|
|
|
356
356
|
}
|
|
357
357
|
const {
|
|
358
358
|
l10n
|
|
359
|
-
} = this.
|
|
359
|
+
} = this.state;
|
|
360
360
|
return l10n.formatDate(placeholderDatetime);
|
|
361
361
|
});
|
|
362
362
|
this.state = {
|
|
@@ -407,14 +407,13 @@ class DatePickerComponent extends Component {
|
|
|
407
407
|
weekStartDay
|
|
408
408
|
} = this.props;
|
|
409
409
|
const {
|
|
410
|
-
value,
|
|
411
410
|
calendarValue,
|
|
412
|
-
isOpen,
|
|
413
411
|
selectInputValue
|
|
414
|
-
} = this.
|
|
412
|
+
} = this.state;
|
|
413
|
+
const value = this.getValue();
|
|
415
414
|
let actualSelectInputValue;
|
|
416
415
|
actualSelectInputValue = selectInputValue;
|
|
417
|
-
const menuIsOpen =
|
|
416
|
+
const menuIsOpen = this.getIsOpen() && !isDisabled;
|
|
418
417
|
const showClearIndicator = Boolean((value || selectInputValue) && !hideIcon);
|
|
419
418
|
const dropDownIcon = appearance === 'subtle' || hideIcon || showClearIndicator ? null : icon;
|
|
420
419
|
const SingleValue = makeSingleValue({
|