@atlaskit/datetime-picker 13.11.2 → 14.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 +19 -0
- package/codemods/14.0.0-remove-duplicate-and-unused-props.tsx +432 -0
- package/codemods/__tests__/next-remove-duplicate-and-unused-props.tsx +1225 -0
- package/codemods/utils/helpers.tsx +306 -0
- package/dist/cjs/components/date-picker.js +22 -24
- package/dist/cjs/components/date-time-picker.js +73 -68
- 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 +66 -72
- 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 +73 -68
- 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 +3 -6
- package/dist/types/components/time-picker.d.ts +2 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types.d.ts +43 -31
- package/dist/types-ts4.5/components/date-picker.d.ts +2 -12
- package/dist/types-ts4.5/components/date-time-picker.d.ts +3 -6
- package/dist/types-ts4.5/components/time-picker.d.ts +2 -1
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +43 -31
- package/package.json +6 -5
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.timePickerDefaultAriaLabel = exports.default = exports.datePickerDefaultAriaLabel = exports.DateTimePickerWithoutAnalytics = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
11
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
@@ -16,7 +16,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
16
16
|
var _react = _interopRequireDefault(require("react"));
|
|
17
17
|
var _react2 = require("@emotion/react");
|
|
18
18
|
var _dateFns = require("date-fns");
|
|
19
|
-
var _pick = _interopRequireDefault(require("lodash/pick"));
|
|
20
19
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
21
20
|
var _selectClear = _interopRequireDefault(require("@atlaskit/icon/glyph/select-clear"));
|
|
22
21
|
var _select = require("@atlaskit/select");
|
|
@@ -26,6 +25,8 @@ var _dateTimePickerContainer = require("../internal/date-time-picker-container")
|
|
|
26
25
|
var _parseTokens = require("../internal/parse-tokens");
|
|
27
26
|
var _datePicker = _interopRequireDefault(require("./date-picker"));
|
|
28
27
|
var _timePicker = _interopRequireDefault(require("./time-picker"));
|
|
28
|
+
var _excluded = ["selectProps"],
|
|
29
|
+
_excluded2 = ["selectProps"];
|
|
29
30
|
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); }; }
|
|
30
31
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
31
32
|
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; }
|
|
@@ -34,7 +35,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
34
35
|
* @jsx jsx
|
|
35
36
|
*/ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
36
37
|
var packageName = "@atlaskit/datetime-picker";
|
|
37
|
-
var packageVersion = "
|
|
38
|
+
var packageVersion = "14.0.0";
|
|
38
39
|
// Make DatePicker 50% the width of DateTimePicker
|
|
39
40
|
// If rendering an icon container, shrink the TimePicker
|
|
40
41
|
var datePickerContainerStyles = (0, _react2.css)({
|
|
@@ -98,8 +99,6 @@ var dateTimePickerDefaultProps = {
|
|
|
98
99
|
isInvalid: false,
|
|
99
100
|
datePickerProps: {},
|
|
100
101
|
timePickerProps: {},
|
|
101
|
-
datePickerSelectProps: {},
|
|
102
|
-
timePickerSelectProps: {},
|
|
103
102
|
times: _internal.defaultTimes,
|
|
104
103
|
spacing: 'default',
|
|
105
104
|
locale: 'en-US'
|
|
@@ -127,9 +126,12 @@ var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE
|
|
|
127
126
|
});
|
|
128
127
|
// All state needs to be accessed via this function so that the state is mapped from props
|
|
129
128
|
// correctly to allow controlled/uncontrolled usage.
|
|
130
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "
|
|
131
|
-
|
|
132
|
-
|
|
129
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getParsedValues", function () {
|
|
130
|
+
return _this.parseValue(_this.getValue(), _this.state.dateValue, _this.state.timeValue, _this.state.zoneValue);
|
|
131
|
+
});
|
|
132
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getValue", function () {
|
|
133
|
+
var _this$props$value;
|
|
134
|
+
return (_this$props$value = _this.props.value) !== null && _this$props$value !== void 0 ? _this$props$value : _this.state.value;
|
|
133
135
|
});
|
|
134
136
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onBlur", function (event) {
|
|
135
137
|
_this.setState({
|
|
@@ -144,20 +146,28 @@ var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE
|
|
|
144
146
|
_this.props.onFocus(event);
|
|
145
147
|
});
|
|
146
148
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onDateChange", function (dateValue) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
149
|
+
var parsedValues = _this.getParsedValues();
|
|
150
|
+
_this.onValueChange({
|
|
151
|
+
dateValue: dateValue,
|
|
152
|
+
timeValue: parsedValues.timeValue,
|
|
153
|
+
zoneValue: parsedValues.zoneValue
|
|
154
|
+
});
|
|
150
155
|
});
|
|
151
156
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onTimeChange", function (timeValue) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
157
|
+
var parsedValues = _this.getParsedValues();
|
|
158
|
+
_this.onValueChange({
|
|
159
|
+
dateValue: parsedValues.dateValue,
|
|
160
|
+
timeValue: timeValue,
|
|
161
|
+
zoneValue: parsedValues.zoneValue
|
|
162
|
+
});
|
|
155
163
|
});
|
|
156
164
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onClear", function () {
|
|
157
|
-
|
|
165
|
+
var parsedValues = _this.getParsedValues();
|
|
166
|
+
_this.onValueChange({
|
|
167
|
+
dateValue: '',
|
|
158
168
|
timeValue: '',
|
|
159
|
-
|
|
160
|
-
})
|
|
169
|
+
zoneValue: parsedValues.zoneValue
|
|
170
|
+
});
|
|
161
171
|
});
|
|
162
172
|
return _this;
|
|
163
173
|
}
|
|
@@ -165,7 +175,18 @@ var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE
|
|
|
165
175
|
key: "parseValue",
|
|
166
176
|
value: function parseValue(value, dateValue, timeValue, zoneValue) {
|
|
167
177
|
if (this.props.parseValue) {
|
|
168
|
-
|
|
178
|
+
var parsedFromFn = this.props.parseValue(value, dateValue, timeValue, zoneValue);
|
|
179
|
+
// This handles cases found in Jira where the parse function actually does
|
|
180
|
+
// nothing and returns undefined. The previous `getSafeState` function
|
|
181
|
+
// just spread the values over the state, but if it returned `undefined`,
|
|
182
|
+
// it would just rely on the previous state values. Considering this is
|
|
183
|
+
// what is input to this function anyway, this is a safe way to handle
|
|
184
|
+
// this, colocate the behavior, and not rely on `getSafeState`.
|
|
185
|
+
return parsedFromFn || {
|
|
186
|
+
dateValue: dateValue,
|
|
187
|
+
timeValue: timeValue,
|
|
188
|
+
zoneValue: zoneValue
|
|
189
|
+
};
|
|
169
190
|
}
|
|
170
191
|
var parsed = (0, _dateFns.parseISO)(value);
|
|
171
192
|
return (0, _dateFns.isValid)(parsed) ? {
|
|
@@ -199,7 +220,7 @@ var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE
|
|
|
199
220
|
});
|
|
200
221
|
this.props.onChange(valueWithValidZone);
|
|
201
222
|
// If the date or time value was cleared when there is an existing datetime value, then clear the value.
|
|
202
|
-
} else if (this.
|
|
223
|
+
} else if (this.getValue()) {
|
|
203
224
|
this.setState({
|
|
204
225
|
value: ''
|
|
205
226
|
});
|
|
@@ -213,9 +234,7 @@ var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE
|
|
|
213
234
|
ariaDescribedBy = _this$props['aria-describedby'],
|
|
214
235
|
appearance = _this$props.appearance,
|
|
215
236
|
autoFocus = _this$props.autoFocus,
|
|
216
|
-
|
|
217
|
-
datePickerProps = _this$props.datePickerProps,
|
|
218
|
-
datePickerSelectProps = _this$props.datePickerSelectProps,
|
|
237
|
+
datePickerPropsWithSelectProps = _this$props.datePickerProps,
|
|
219
238
|
id = _this$props.id,
|
|
220
239
|
innerProps = _this$props.innerProps,
|
|
221
240
|
isDisabled = _this$props.isDisabled,
|
|
@@ -224,29 +243,25 @@ var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE
|
|
|
224
243
|
name = _this$props.name,
|
|
225
244
|
spacing = _this$props.spacing,
|
|
226
245
|
testId = _this$props.testId,
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
var
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
var _datePickerSelectProp = datePickerSelectProps.styles,
|
|
238
|
-
datePickerStyles = _datePickerSelectProp === void 0 ? {} : _datePickerSelectProp;
|
|
239
|
-
var _timePickerSelectProp = timePickerSelectProps.styles,
|
|
240
|
-
timePickerStyles = _timePickerSelectProp === void 0 ? {} : _timePickerSelectProp;
|
|
246
|
+
timePickerPropsWithSelectProps = _this$props.timePickerProps;
|
|
247
|
+
var value = this.getValue();
|
|
248
|
+
var isFocused = this.state.isFocused;
|
|
249
|
+
var parsedValues = this.getParsedValues();
|
|
250
|
+
var dateValue = parsedValues === null || parsedValues === void 0 ? void 0 : parsedValues.dateValue;
|
|
251
|
+
var timeValue = parsedValues === null || parsedValues === void 0 ? void 0 : parsedValues.timeValue;
|
|
252
|
+
var datePickerSelectProps = datePickerPropsWithSelectProps.selectProps,
|
|
253
|
+
datePickerProps = (0, _objectWithoutProperties2.default)(datePickerPropsWithSelectProps, _excluded);
|
|
254
|
+
var datePickerAriaDescribedBy = datePickerProps['aria-describedby'] || ariaDescribedBy;
|
|
255
|
+
var datePickerLabel = datePickerProps.label || datePickerDefaultAriaLabel;
|
|
241
256
|
var mergedDatePickerSelectProps = _objectSpread(_objectSpread({}, datePickerSelectProps), {}, {
|
|
242
|
-
|
|
243
|
-
'aria-label': datePickerProps['label'] || datePickerSelectProps['aria-label'] || datePickerDefaultAriaLabel,
|
|
244
|
-
styles: (0, _select.mergeStyles)(styles, datePickerStyles)
|
|
257
|
+
styles: (0, _select.mergeStyles)(styles, datePickerSelectProps === null || datePickerSelectProps === void 0 ? void 0 : datePickerSelectProps.styles)
|
|
245
258
|
});
|
|
259
|
+
var timePickerSelectProps = timePickerPropsWithSelectProps.selectProps,
|
|
260
|
+
timePickerProps = (0, _objectWithoutProperties2.default)(timePickerPropsWithSelectProps, _excluded2);
|
|
261
|
+
var timePickerAriaDescribedBy = timePickerProps['aria-describedby'] || ariaDescribedBy;
|
|
262
|
+
var timePickerLabel = timePickerProps.label || timePickerDefaultAriaLabel;
|
|
246
263
|
var mergedTimePickerSelectProps = _objectSpread(_objectSpread({}, timePickerSelectProps), {}, {
|
|
247
|
-
|
|
248
|
-
'aria-label': timePickerProps['label'] || timePickerSelectProps['aria-label'] || timePickerDefaultAriaLabel,
|
|
249
|
-
styles: (0, _select.mergeStyles)(styles, timePickerStyles)
|
|
264
|
+
styles: (0, _select.mergeStyles)(styles, timePickerSelectProps === null || timePickerSelectProps === void 0 ? void 0 : timePickerSelectProps.styles)
|
|
250
265
|
});
|
|
251
266
|
|
|
252
267
|
// Render DateTimePicker's IconContainer when a value has been filled
|
|
@@ -266,10 +281,11 @@ var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE
|
|
|
266
281
|
"data-testid": testId && "".concat(testId, "--input")
|
|
267
282
|
}), (0, _react2.jsx)("div", {
|
|
268
283
|
css: datePickerContainerStyles
|
|
269
|
-
}, (0, _react2.jsx)(_datePicker.default,
|
|
284
|
+
}, (0, _react2.jsx)(_datePicker.default, {
|
|
270
285
|
appearance: appearance,
|
|
286
|
+
"aria-describedby": datePickerAriaDescribedBy,
|
|
271
287
|
autoFocus: datePickerProps.autoFocus || autoFocus,
|
|
272
|
-
dateFormat: datePickerProps.dateFormat
|
|
288
|
+
dateFormat: datePickerProps.dateFormat,
|
|
273
289
|
defaultIsOpen: datePickerProps.defaultIsOpen,
|
|
274
290
|
defaultValue: datePickerProps.defaultValue,
|
|
275
291
|
disabled: datePickerProps.disabled,
|
|
@@ -280,15 +296,9 @@ var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE
|
|
|
280
296
|
id: datePickerProps.id || id,
|
|
281
297
|
innerProps: datePickerProps.innerProps,
|
|
282
298
|
isDisabled: datePickerProps.isDisabled || isDisabled,
|
|
283
|
-
isInvalid: datePickerProps.isInvalid || isInvalid
|
|
284
|
-
|
|
285
|
-
|
|
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
|
-
} : {}, {
|
|
299
|
+
isInvalid: datePickerProps.isInvalid || isInvalid,
|
|
300
|
+
isOpen: datePickerProps.isOpen,
|
|
301
|
+
label: datePickerLabel,
|
|
292
302
|
locale: datePickerProps.locale || locale,
|
|
293
303
|
maxDate: datePickerProps.maxDate,
|
|
294
304
|
minDate: datePickerProps.minDate,
|
|
@@ -305,10 +315,11 @@ var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE
|
|
|
305
315
|
testId: testId && "".concat(testId, "--datepicker") || datePickerProps.testId,
|
|
306
316
|
value: dateValue,
|
|
307
317
|
weekStartDay: datePickerProps.weekStartDay
|
|
308
|
-
}))
|
|
318
|
+
})), (0, _react2.jsx)("div", {
|
|
309
319
|
css: timePickerContainerStyles
|
|
310
|
-
}, (0, _react2.jsx)(_timePicker.default,
|
|
320
|
+
}, (0, _react2.jsx)(_timePicker.default, {
|
|
311
321
|
appearance: timePickerProps.appearance || appearance,
|
|
322
|
+
"aria-describedby": timePickerAriaDescribedBy,
|
|
312
323
|
autoFocus: timePickerProps.autoFocus,
|
|
313
324
|
defaultIsOpen: timePickerProps.defaultIsOpen,
|
|
314
325
|
defaultValue: timePickerProps.defaultValue,
|
|
@@ -317,15 +328,9 @@ var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE
|
|
|
317
328
|
id: timePickerProps.id,
|
|
318
329
|
innerProps: timePickerProps.innerProps,
|
|
319
330
|
isDisabled: timePickerProps.isDisabled || isDisabled,
|
|
320
|
-
isInvalid: timePickerProps.isInvalid || isInvalid
|
|
321
|
-
|
|
322
|
-
|
|
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
|
-
} : {}, {
|
|
331
|
+
isInvalid: timePickerProps.isInvalid || isInvalid,
|
|
332
|
+
isOpen: timePickerProps.isOpen,
|
|
333
|
+
label: timePickerLabel,
|
|
329
334
|
locale: timePickerProps.locale || locale,
|
|
330
335
|
name: timePickerProps.name,
|
|
331
336
|
onBlur: timePickerProps.onBlur || this.onBlur,
|
|
@@ -336,11 +341,11 @@ var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE
|
|
|
336
341
|
selectProps: mergedTimePickerSelectProps,
|
|
337
342
|
spacing: timePickerProps.spacing || spacing,
|
|
338
343
|
testId: timePickerProps.testId || testId && "".concat(testId, "--timepicker"),
|
|
339
|
-
timeFormat: timePickerProps.timeFormat
|
|
340
|
-
timeIsEditable: timePickerProps.timeIsEditable
|
|
341
|
-
times: timePickerProps.times
|
|
344
|
+
timeFormat: timePickerProps.timeFormat,
|
|
345
|
+
timeIsEditable: timePickerProps.timeIsEditable,
|
|
346
|
+
times: timePickerProps.times,
|
|
342
347
|
value: timeValue
|
|
343
|
-
}))
|
|
348
|
+
})), isClearable && !isDisabled ? (0, _react2.jsx)("button", {
|
|
344
349
|
css: iconContainerStyles,
|
|
345
350
|
onClick: this.onClear,
|
|
346
351
|
"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 = "
|
|
38
|
+
var packageVersion = "14.0.0";
|
|
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 = "
|
|
22
|
+
const packageVersion = "14.0.0";
|
|
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({
|