@atlaskit/datetime-picker 19.4.1 → 19.4.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 +15 -0
- package/codemods/14.0.0-remove-duplicate-and-unused-props.tsx +2 -2
- package/codemods/utils/create-remove-func-for.tsx +5 -3
- package/codemods/utils/remove-jsx-attribute-by-name.tsx +2 -1
- package/codemods/utils/remove-jsx-attribute-object-property-by-name.tsx +2 -2
- package/dist/cjs/components/date-picker.js +28 -16
- package/dist/cjs/components/date-time-picker.js +16 -4
- package/dist/cjs/components/time-picker.js +1 -1
- package/dist/es2019/components/date-picker.js +26 -16
- package/dist/es2019/components/date-time-picker.js +14 -4
- package/dist/es2019/components/time-picker.js +1 -1
- package/dist/esm/components/date-picker.js +28 -16
- package/dist/esm/components/date-time-picker.js +16 -4
- package/dist/esm/components/time-picker.js +1 -1
- package/package.json +9 -9
- package/codemods/utils/get-jsx-attribute-by-name.tsx +0 -15
- package/codemods/utils/get-jsx-attributes-by-name.tsx +0 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/datetime-picker
|
|
2
2
|
|
|
3
|
+
## 19.4.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`60b28ae0201d7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/60b28ae0201d7) -
|
|
8
|
+
Behind `platform-dst-top-layer`, focus returns to the opener when the menu closes with focus
|
|
9
|
+
inside it.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 19.4.2
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 19.4.1
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type API, type FileInfo, type JSCodeshift, type Options } from 'jscodeshift';
|
|
2
2
|
import { type Collection } from 'jscodeshift/src/Collection';
|
|
3
3
|
|
|
4
|
+
import { getJSXAttributeByName, getJSXAttributesByName } from '@atlaskit/codemod-utils/support';
|
|
5
|
+
|
|
4
6
|
import { addJSXAttributeToJSXElement } from './utils/add-jsx-attribute-to-jsx-element';
|
|
5
7
|
import {
|
|
6
8
|
dtpPropsToMoveIntoPickerProps,
|
|
@@ -9,8 +11,6 @@ import {
|
|
|
9
11
|
import { getImportDeclarationCollection } from './utils/get-import-declaration-collection';
|
|
10
12
|
import { getImportSpecifierCollection } from './utils/get-import-specifier-collection';
|
|
11
13
|
import { getImportSpecifierName } from './utils/get-import-specifier-name';
|
|
12
|
-
import { getJSXAttributeByName } from './utils/get-jsx-attribute-by-name';
|
|
13
|
-
import { getJSXAttributesByName } from './utils/get-jsx-attributes-by-name';
|
|
14
14
|
import { hasImportDeclaration } from './utils/has-import-declaration';
|
|
15
15
|
import { removeJSXAttributeByName } from './utils/remove-jsx-attribute-by-name';
|
|
16
16
|
import { removeJSXAttributeObjectPropertyByName } from './utils/remove-jsx-attribute-object-property-by-name';
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { type JSCodeshift } from 'jscodeshift';
|
|
2
2
|
import { type Collection } from 'jscodeshift/src/Collection';
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import {
|
|
5
|
+
addCommentToStartOfFile,
|
|
6
|
+
getJSXAttributesByName,
|
|
7
|
+
getNamedSpecifier,
|
|
8
|
+
} from '@atlaskit/codemod-utils/support';
|
|
7
9
|
|
|
8
10
|
export const createRemoveFuncFor: (
|
|
9
11
|
component: string,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ASTPath, type JSCodeshift, type JSXElement } from 'jscodeshift';
|
|
2
2
|
|
|
3
|
-
import { getJSXAttributeByName } from '
|
|
3
|
+
import { getJSXAttributeByName } from '@atlaskit/codemod-utils/support';
|
|
4
|
+
|
|
4
5
|
import { getJSXAttributes } from './get-jsx-attributes';
|
|
5
6
|
|
|
6
7
|
export const removeJSXAttributeByName: (
|
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
type StringLiteral,
|
|
7
7
|
} from 'jscodeshift';
|
|
8
8
|
|
|
9
|
-
import { getJSXAttributeByName } from '
|
|
10
|
-
|
|
9
|
+
import { getJSXAttributeByName, getJSXAttributesByName } from '@atlaskit/codemod-utils/support';
|
|
10
|
+
|
|
11
11
|
import { removeJSXAttributeByName } from './remove-jsx-attribute-by-name';
|
|
12
12
|
|
|
13
13
|
export const removeJSXAttributeObjectPropertyByName: (
|
|
@@ -47,7 +47,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
47
47
|
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; }
|
|
48
48
|
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; }
|
|
49
49
|
var packageName = "@atlaskit/datetime-picker";
|
|
50
|
-
var packageVersion = "19.4.
|
|
50
|
+
var packageVersion = "19.4.2";
|
|
51
51
|
var styles = {
|
|
52
52
|
pickerContainerStyle: "_kqswh2mm",
|
|
53
53
|
dropdownIndicatorStyles: "_1ul91k8s _1tke1k8s _1e0c1txw _4cvr1h6o _1bah1h6o",
|
|
@@ -76,7 +76,8 @@ var DatePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, _forwarded
|
|
|
76
76
|
// Track whether focus was caused by an active pointer gesture. Pointer-driven focus must defer
|
|
77
77
|
// opening a top-layer popover until click, while keyboard and programmatic focus can open it now.
|
|
78
78
|
var isPointerInteractionRef = (0, _react.useRef)(false);
|
|
79
|
-
|
|
79
|
+
// Top layer: set when Escape is left to Select, so `onMenuClose` resets the picker state.
|
|
80
|
+
var isEscapeCloseRef = (0, _react.useRef)(false);
|
|
80
81
|
var _props$appearance = props.appearance,
|
|
81
82
|
appearance = _props$appearance === void 0 ? 'default' : _props$appearance,
|
|
82
83
|
_props$autoFocus = props.autoFocus,
|
|
@@ -233,6 +234,12 @@ var DatePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, _forwarded
|
|
|
233
234
|
var getIsOpen = function getIsOpen() {
|
|
234
235
|
return isOpenProp !== null && isOpenProp !== void 0 ? isOpenProp : isOpen;
|
|
235
236
|
};
|
|
237
|
+
// Top layer: the calendar is closed but still mounted while Select's menu closes. The platform
|
|
238
|
+
// then returns focus, and Firefox first moves focus to `<body>` as the popover hides. Neither is
|
|
239
|
+
// the user leaving or arriving at the field.
|
|
240
|
+
var isCalendarClosing = function isCalendarClosing() {
|
|
241
|
+
return (0, _fg.fg)('platform-dst-top-layer') && !getIsOpen() && calendarRef.current !== null;
|
|
242
|
+
};
|
|
236
243
|
var onCalendarChange = function onCalendarChange(_ref2) {
|
|
237
244
|
var iso = _ref2.iso;
|
|
238
245
|
setCalendarValue((0, _getParsedIso.getParsedISO)({
|
|
@@ -248,8 +255,8 @@ var DatePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, _forwarded
|
|
|
248
255
|
setWasOpenedFromCalendarButton(false);
|
|
249
256
|
onChangePropWithAnalytics(iso);
|
|
250
257
|
|
|
251
|
-
//
|
|
252
|
-
//
|
|
258
|
+
// Top layer: no focus move here. Select hides its menu's popover, and the platform returns
|
|
259
|
+
// focus.
|
|
253
260
|
if (!(0, _fg.fg)('platform-dst-top-layer')) {
|
|
254
261
|
if (wasOpenedFromCalendarButton) {
|
|
255
262
|
var _calendarButtonRef$cu;
|
|
@@ -272,7 +279,10 @@ var DatePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, _forwarded
|
|
|
272
279
|
var _containerRef$current2;
|
|
273
280
|
var newlyFocusedElement = event.relatedTarget;
|
|
274
281
|
isPointerInteractionRef.current = false;
|
|
275
|
-
|
|
282
|
+
// A blur to nowhere while the calendar closes is part of the close. A blur to a real element
|
|
283
|
+
// is the user leaving the field.
|
|
284
|
+
var isClosingBlur = isCalendarClosing() && newlyFocusedElement === null;
|
|
285
|
+
if (!isClosingBlur && !(containerRef !== null && containerRef !== void 0 && (_containerRef$current2 = containerRef.current) !== null && _containerRef$current2 !== void 0 && _containerRef$current2.contains(newlyFocusedElement))) {
|
|
276
286
|
setIsOpen(false);
|
|
277
287
|
setShouldSetFocusOnCurrentDay(false);
|
|
278
288
|
setWasOpenedFromCalendarButton(false);
|
|
@@ -304,7 +314,11 @@ var DatePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, _forwarded
|
|
|
304
314
|
} else {
|
|
305
315
|
// Opening an auto popover during pointer focus allows the matching pointerup
|
|
306
316
|
// to immediately light-dismiss it. Let the subsequent click open it instead.
|
|
307
|
-
|
|
317
|
+
var isPointerFocus = (0, _fg.fg)('platform-dst-top-layer') && isPointerInteractionRef.current;
|
|
318
|
+
// Focus that returns while the calendar closes must not change the open state.
|
|
319
|
+
// `getIsOpen()` includes an `isOpen={false}` prop, so the calendar shows again when the prop
|
|
320
|
+
// is removed.
|
|
321
|
+
if (!isPointerFocus && !isCalendarClosing()) {
|
|
308
322
|
// Don't open when focused into via keyboard if the calendar button is present
|
|
309
323
|
setIsOpen(!shouldShowCalendarButton);
|
|
310
324
|
}
|
|
@@ -343,11 +357,10 @@ var DatePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, _forwarded
|
|
|
343
357
|
}
|
|
344
358
|
var shouldDeferEscapeHandling = event.key === 'Escape' && isTopLayerEnabled && getIsOpen();
|
|
345
359
|
if (shouldDeferEscapeHandling) {
|
|
346
|
-
var _containerRef$current4, _containerRef$current5;
|
|
347
360
|
// Select owns Escape cancellation and dismissal for its default top-layer popup.
|
|
348
|
-
// Defer DatePicker's
|
|
349
|
-
|
|
350
|
-
|
|
361
|
+
// Defer DatePicker's state cleanup until the menu has closed. No focus move here: Select
|
|
362
|
+
// hides its menu's popover, and the platform returns focus.
|
|
363
|
+
isEscapeCloseRef.current = !event.defaultPrevented;
|
|
351
364
|
return;
|
|
352
365
|
}
|
|
353
366
|
switch (keyPressed) {
|
|
@@ -357,8 +370,8 @@ var DatePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, _forwarded
|
|
|
357
370
|
var _calendarButtonRef$cu2;
|
|
358
371
|
(_calendarButtonRef$cu2 = calendarButtonRef.current) === null || _calendarButtonRef$cu2 === void 0 || _calendarButtonRef$cu2.focus();
|
|
359
372
|
} else {
|
|
360
|
-
var _containerRef$
|
|
361
|
-
var innerCombobox = containerRef === null || containerRef === void 0 || (_containerRef$
|
|
373
|
+
var _containerRef$current4;
|
|
374
|
+
var innerCombobox = containerRef === null || containerRef === void 0 || (_containerRef$current4 = containerRef.current) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.querySelector('[role="combobox"]');
|
|
362
375
|
innerCombobox === null || innerCombobox === void 0 || innerCombobox.focus();
|
|
363
376
|
}
|
|
364
377
|
setIsOpen(false);
|
|
@@ -414,10 +427,9 @@ var DatePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, _forwarded
|
|
|
414
427
|
};
|
|
415
428
|
var onMenuClose = function onMenuClose() {
|
|
416
429
|
var _selectProps$onMenuCl;
|
|
417
|
-
var
|
|
418
|
-
|
|
419
|
-
if ((0, _fg.fg)('platform-dst-top-layer') &&
|
|
420
|
-
focusTarget.focus();
|
|
430
|
+
var isEscapeClose = isEscapeCloseRef.current;
|
|
431
|
+
isEscapeCloseRef.current = false;
|
|
432
|
+
if ((0, _fg.fg)('platform-dst-top-layer') && isEscapeClose) {
|
|
421
433
|
setIsOpen(false);
|
|
422
434
|
setShouldSetFocusOnCurrentDay(false);
|
|
423
435
|
setWasOpenedFromCalendarButton(false);
|
|
@@ -35,7 +35,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
35
35
|
// for typing `process`
|
|
36
36
|
// oxlint-disable-next-line @atlassian/no-restricted-imports
|
|
37
37
|
var packageName = "@atlaskit/datetime-picker";
|
|
38
|
-
var packageVersion = "19.4.
|
|
38
|
+
var packageVersion = "19.4.2";
|
|
39
39
|
var analyticsAttributes = {
|
|
40
40
|
componentName: 'dateTimePicker',
|
|
41
41
|
packageName: packageName,
|
|
@@ -83,6 +83,9 @@ var getStyles = function getStyles(isInputMotionEnabled, roundedCorners) {
|
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
85
|
};
|
|
86
|
+
var hasExplicitZone = function hasExplicitZone(value) {
|
|
87
|
+
return value.endsWith('Z') || Math.max(value.lastIndexOf('+'), value.lastIndexOf('-')) > 15;
|
|
88
|
+
};
|
|
86
89
|
var parseDateTimeValueWithOffset = function parseDateTimeValueWithOffset(value) {
|
|
87
90
|
var parsed = (0, _dateFns.parseISO)(value);
|
|
88
91
|
var zoneStart = value.endsWith('Z') ? value.length - 1 : Math.max(value.lastIndexOf('+'), value.lastIndexOf('-'));
|
|
@@ -101,8 +104,7 @@ var parseDateTimeValueWithOffset = function parseDateTimeValueWithOffset(value)
|
|
|
101
104
|
};
|
|
102
105
|
var parseDateTimeValue = function parseDateTimeValue(value) {
|
|
103
106
|
if ((0, _fg.fg)('platform-dst-dtp-preserve-offset')) {
|
|
104
|
-
|
|
105
|
-
if (hasExplicitZone) {
|
|
107
|
+
if (hasExplicitZone(value)) {
|
|
106
108
|
return parseDateTimeValueWithOffset(value);
|
|
107
109
|
}
|
|
108
110
|
}
|
|
@@ -182,6 +184,7 @@ var DateTimePicker = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
182
184
|
isFocused = _useState2[0],
|
|
183
185
|
setIsFocused = _useState2[1];
|
|
184
186
|
var isInputMotionEnabled = (0, _fg.fg)('platform-dst-motion-uplift-input');
|
|
187
|
+
var isZoneExplicitRef = (0, _react.useRef)(false);
|
|
185
188
|
|
|
186
189
|
/**
|
|
187
190
|
* Defined inside the component so the reducer closes over `providedParseValue`
|
|
@@ -234,6 +237,7 @@ var DateTimePicker = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
234
237
|
var _useReducer = (0, _react.useReducer)(reducer, null, function () {
|
|
235
238
|
var _ref3;
|
|
236
239
|
var initialValue = (_ref3 = providedValue !== null && providedValue !== void 0 ? providedValue : defaultValue) !== null && _ref3 !== void 0 ? _ref3 : '';
|
|
240
|
+
isZoneExplicitRef.current = hasExplicitZone(initialValue);
|
|
237
241
|
var initialDate = (datePickerPropsWithSelectProps === null || datePickerPropsWithSelectProps === void 0 ? void 0 : datePickerPropsWithSelectProps.defaultValue) || '';
|
|
238
242
|
var initialTime = (timePickerPropsWithSelectProps === null || timePickerPropsWithSelectProps === void 0 ? void 0 : timePickerPropsWithSelectProps.defaultValue) || '';
|
|
239
243
|
if (!initialValue) {
|
|
@@ -275,6 +279,7 @@ var DateTimePicker = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
275
279
|
// `undefined` to the `value` prop will not clear the hidden input and will
|
|
276
280
|
// cause unexpected issues.
|
|
277
281
|
var hasReceivedProvidedValue = (0, _react.useRef)(providedValue !== undefined);
|
|
282
|
+
var lastEmittedValueRef = (0, _react.useRef)();
|
|
278
283
|
// We don't want to set the state on the first render, as it would
|
|
279
284
|
// needlessly be a duplicate.
|
|
280
285
|
var isFirstRender = (0, _react.useRef)(true);
|
|
@@ -285,12 +290,17 @@ var DateTimePicker = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
285
290
|
}
|
|
286
291
|
if (providedValue !== undefined) {
|
|
287
292
|
hasReceivedProvidedValue.current = true;
|
|
293
|
+
if (providedValue !== lastEmittedValueRef.current) {
|
|
294
|
+
isZoneExplicitRef.current = hasExplicitZone(providedValue);
|
|
295
|
+
}
|
|
288
296
|
dispatch({
|
|
289
297
|
type: 'SET_VALUE',
|
|
290
298
|
payload: providedValue
|
|
291
299
|
});
|
|
292
300
|
} else if (hasReceivedProvidedValue.current) {
|
|
293
301
|
hasReceivedProvidedValue.current = false;
|
|
302
|
+
isZoneExplicitRef.current = false;
|
|
303
|
+
lastEmittedValueRef.current = undefined;
|
|
294
304
|
dispatch({
|
|
295
305
|
type: 'SET_VALUE',
|
|
296
306
|
payload: ''
|
|
@@ -394,7 +404,8 @@ var DateTimePicker = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
394
404
|
providedZoneValue = _ref4.providedZoneValue;
|
|
395
405
|
if (providedDateValue && providedTimeValue) {
|
|
396
406
|
var isoValue = (0, _formatDateTimeZoneIntoIso.formatDateTimeZoneIntoIso)(providedDateValue, providedTimeValue, providedZoneValue);
|
|
397
|
-
var
|
|
407
|
+
var valueToParse = (0, _fg.fg)('platform-dst-dtp-preserve-offset') && !providedParseValue && !isZoneExplicitRef.current ? (0, _formatDateTimeZoneIntoIso.formatDateTimeZoneIntoIso)(providedDateValue, providedTimeValue, '') : isoValue;
|
|
408
|
+
var _parseValue = parseValue(valueToParse, providedDateValue, providedTimeValue, providedZoneValue),
|
|
398
409
|
parsedZone = _parseValue.zoneValue;
|
|
399
410
|
var valueWithValidZone = (0, _formatDateTimeZoneIntoIso.formatDateTimeZoneIntoIso)(providedDateValue, providedTimeValue, parsedZone);
|
|
400
411
|
dispatch({
|
|
@@ -406,6 +417,7 @@ var DateTimePicker = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
406
417
|
zoneValue: parsedZone
|
|
407
418
|
}
|
|
408
419
|
});
|
|
420
|
+
lastEmittedValueRef.current = valueWithValidZone;
|
|
409
421
|
onChangePropWithAnalytics(valueWithValidZone);
|
|
410
422
|
// If the date or time value was cleared when there is an existing datetime value, then clear the value.
|
|
411
423
|
} else if (dtState.value) {
|
|
@@ -38,7 +38,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
38
38
|
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; }
|
|
39
39
|
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; } // oxlint-disable-next-line @atlassian/no-restricted-imports
|
|
40
40
|
var packageName = "@atlaskit/datetime-picker";
|
|
41
|
-
var packageVersion = "19.4.
|
|
41
|
+
var packageVersion = "19.4.2";
|
|
42
42
|
var defaultTimeFormat = 'h:mma';
|
|
43
43
|
var menuStyles = {
|
|
44
44
|
/* Need to remove default absolute positioning as that causes issues with position fixed */
|
|
@@ -32,7 +32,7 @@ import { parseDate } from '../internal/parse-date';
|
|
|
32
32
|
import { PickerButtonContainer } from '../internal/picker-button-container';
|
|
33
33
|
import { makeSingleValue } from '../internal/single-value';
|
|
34
34
|
const packageName = "@atlaskit/datetime-picker";
|
|
35
|
-
const packageVersion = "19.4.
|
|
35
|
+
const packageVersion = "19.4.2";
|
|
36
36
|
const styles = {
|
|
37
37
|
pickerContainerStyle: "_kqswh2mm",
|
|
38
38
|
dropdownIndicatorStyles: "_1ul91k8s _1tke1k8s _1e0c1txw _4cvr1h6o _1bah1h6o",
|
|
@@ -61,7 +61,8 @@ const DatePicker = /*#__PURE__*/forwardRef((props, _forwardedRef) => {
|
|
|
61
61
|
// Track whether focus was caused by an active pointer gesture. Pointer-driven focus must defer
|
|
62
62
|
// opening a top-layer popover until click, while keyboard and programmatic focus can open it now.
|
|
63
63
|
const isPointerInteractionRef = useRef(false);
|
|
64
|
-
|
|
64
|
+
// Top layer: set when Escape is left to Select, so `onMenuClose` resets the picker state.
|
|
65
|
+
const isEscapeCloseRef = useRef(false);
|
|
65
66
|
const {
|
|
66
67
|
appearance = 'default',
|
|
67
68
|
autoFocus = false,
|
|
@@ -157,6 +158,10 @@ const DatePicker = /*#__PURE__*/forwardRef((props, _forwardedRef) => {
|
|
|
157
158
|
}, [isKeyDown, calendarRef, isOpen, wasOpenedFromCalendarButton]);
|
|
158
159
|
const getValue = () => propValue !== null && propValue !== void 0 ? propValue : value;
|
|
159
160
|
const getIsOpen = () => isOpenProp !== null && isOpenProp !== void 0 ? isOpenProp : isOpen;
|
|
161
|
+
// Top layer: the calendar is closed but still mounted while Select's menu closes. The platform
|
|
162
|
+
// then returns focus, and Firefox first moves focus to `<body>` as the popover hides. Neither is
|
|
163
|
+
// the user leaving or arriving at the field.
|
|
164
|
+
const isCalendarClosing = () => fg('platform-dst-top-layer') && !getIsOpen() && calendarRef.current !== null;
|
|
160
165
|
const onCalendarChange = ({
|
|
161
166
|
iso
|
|
162
167
|
}) => {
|
|
@@ -174,8 +179,8 @@ const DatePicker = /*#__PURE__*/forwardRef((props, _forwardedRef) => {
|
|
|
174
179
|
setWasOpenedFromCalendarButton(false);
|
|
175
180
|
onChangePropWithAnalytics(iso);
|
|
176
181
|
|
|
177
|
-
//
|
|
178
|
-
//
|
|
182
|
+
// Top layer: no focus move here. Select hides its menu's popover, and the platform returns
|
|
183
|
+
// focus.
|
|
179
184
|
if (!fg('platform-dst-top-layer')) {
|
|
180
185
|
if (wasOpenedFromCalendarButton) {
|
|
181
186
|
var _calendarButtonRef$cu;
|
|
@@ -198,7 +203,10 @@ const DatePicker = /*#__PURE__*/forwardRef((props, _forwardedRef) => {
|
|
|
198
203
|
var _containerRef$current2;
|
|
199
204
|
const newlyFocusedElement = event.relatedTarget;
|
|
200
205
|
isPointerInteractionRef.current = false;
|
|
201
|
-
|
|
206
|
+
// A blur to nowhere while the calendar closes is part of the close. A blur to a real element
|
|
207
|
+
// is the user leaving the field.
|
|
208
|
+
const isClosingBlur = isCalendarClosing() && newlyFocusedElement === null;
|
|
209
|
+
if (!isClosingBlur && !(containerRef !== null && containerRef !== void 0 && (_containerRef$current2 = containerRef.current) !== null && _containerRef$current2 !== void 0 && _containerRef$current2.contains(newlyFocusedElement))) {
|
|
202
210
|
setIsOpen(false);
|
|
203
211
|
setShouldSetFocusOnCurrentDay(false);
|
|
204
212
|
setWasOpenedFromCalendarButton(false);
|
|
@@ -230,7 +238,11 @@ const DatePicker = /*#__PURE__*/forwardRef((props, _forwardedRef) => {
|
|
|
230
238
|
} else {
|
|
231
239
|
// Opening an auto popover during pointer focus allows the matching pointerup
|
|
232
240
|
// to immediately light-dismiss it. Let the subsequent click open it instead.
|
|
233
|
-
|
|
241
|
+
const isPointerFocus = fg('platform-dst-top-layer') && isPointerInteractionRef.current;
|
|
242
|
+
// Focus that returns while the calendar closes must not change the open state.
|
|
243
|
+
// `getIsOpen()` includes an `isOpen={false}` prop, so the calendar shows again when the prop
|
|
244
|
+
// is removed.
|
|
245
|
+
if (!isPointerFocus && !isCalendarClosing()) {
|
|
234
246
|
// Don't open when focused into via keyboard if the calendar button is present
|
|
235
247
|
setIsOpen(!shouldShowCalendarButton);
|
|
236
248
|
}
|
|
@@ -269,11 +281,10 @@ const DatePicker = /*#__PURE__*/forwardRef((props, _forwardedRef) => {
|
|
|
269
281
|
}
|
|
270
282
|
const shouldDeferEscapeHandling = event.key === 'Escape' && isTopLayerEnabled && getIsOpen();
|
|
271
283
|
if (shouldDeferEscapeHandling) {
|
|
272
|
-
var _containerRef$current4, _containerRef$current5;
|
|
273
284
|
// Select owns Escape cancellation and dismissal for its default top-layer popup.
|
|
274
|
-
// Defer DatePicker's
|
|
275
|
-
|
|
276
|
-
|
|
285
|
+
// Defer DatePicker's state cleanup until the menu has closed. No focus move here: Select
|
|
286
|
+
// hides its menu's popover, and the platform returns focus.
|
|
287
|
+
isEscapeCloseRef.current = !event.defaultPrevented;
|
|
277
288
|
return;
|
|
278
289
|
}
|
|
279
290
|
switch (keyPressed) {
|
|
@@ -283,8 +294,8 @@ const DatePicker = /*#__PURE__*/forwardRef((props, _forwardedRef) => {
|
|
|
283
294
|
var _calendarButtonRef$cu2;
|
|
284
295
|
(_calendarButtonRef$cu2 = calendarButtonRef.current) === null || _calendarButtonRef$cu2 === void 0 ? void 0 : _calendarButtonRef$cu2.focus();
|
|
285
296
|
} else {
|
|
286
|
-
var _containerRef$
|
|
287
|
-
const innerCombobox = containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$
|
|
297
|
+
var _containerRef$current4;
|
|
298
|
+
const innerCombobox = containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current4 = containerRef.current) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.querySelector('[role="combobox"]');
|
|
288
299
|
innerCombobox === null || innerCombobox === void 0 ? void 0 : innerCombobox.focus();
|
|
289
300
|
}
|
|
290
301
|
setIsOpen(false);
|
|
@@ -340,10 +351,9 @@ const DatePicker = /*#__PURE__*/forwardRef((props, _forwardedRef) => {
|
|
|
340
351
|
};
|
|
341
352
|
const onMenuClose = () => {
|
|
342
353
|
var _selectProps$onMenuCl;
|
|
343
|
-
const
|
|
344
|
-
|
|
345
|
-
if (fg('platform-dst-top-layer') &&
|
|
346
|
-
focusTarget.focus();
|
|
354
|
+
const isEscapeClose = isEscapeCloseRef.current;
|
|
355
|
+
isEscapeCloseRef.current = false;
|
|
356
|
+
if (fg('platform-dst-top-layer') && isEscapeClose) {
|
|
347
357
|
setIsOpen(false);
|
|
348
358
|
setShouldSetFocusOnCurrentDay(false);
|
|
349
359
|
setWasOpenedFromCalendarButton(false);
|
|
@@ -22,7 +22,7 @@ import { convertTokens } from '../internal/parse-tokens';
|
|
|
22
22
|
import DatePicker from './date-picker';
|
|
23
23
|
import TimePicker from './time-picker';
|
|
24
24
|
const packageName = "@atlaskit/datetime-picker";
|
|
25
|
-
const packageVersion = "19.4.
|
|
25
|
+
const packageVersion = "19.4.2";
|
|
26
26
|
const analyticsAttributes = {
|
|
27
27
|
componentName: 'dateTimePicker',
|
|
28
28
|
packageName,
|
|
@@ -70,6 +70,7 @@ const getStyles = (isInputMotionEnabled, roundedCorners) => ({
|
|
|
70
70
|
}
|
|
71
71
|
})
|
|
72
72
|
});
|
|
73
|
+
const hasExplicitZone = value => value.endsWith('Z') || Math.max(value.lastIndexOf('+'), value.lastIndexOf('-')) > 15;
|
|
73
74
|
const parseDateTimeValueWithOffset = value => {
|
|
74
75
|
const parsed = parseISO(value);
|
|
75
76
|
const zoneStart = value.endsWith('Z') ? value.length - 1 : Math.max(value.lastIndexOf('+'), value.lastIndexOf('-'));
|
|
@@ -88,8 +89,7 @@ const parseDateTimeValueWithOffset = value => {
|
|
|
88
89
|
};
|
|
89
90
|
const parseDateTimeValue = value => {
|
|
90
91
|
if (fg('platform-dst-dtp-preserve-offset')) {
|
|
91
|
-
|
|
92
|
-
if (hasExplicitZone) {
|
|
92
|
+
if (hasExplicitZone(value)) {
|
|
93
93
|
return parseDateTimeValueWithOffset(value);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -154,6 +154,7 @@ const DateTimePicker = /*#__PURE__*/forwardRef(({
|
|
|
154
154
|
}, ref) => {
|
|
155
155
|
const [isFocused, setIsFocused] = useState(false);
|
|
156
156
|
const isInputMotionEnabled = fg('platform-dst-motion-uplift-input');
|
|
157
|
+
const isZoneExplicitRef = useRef(false);
|
|
157
158
|
|
|
158
159
|
/**
|
|
159
160
|
* Defined inside the component so the reducer closes over `providedParseValue`
|
|
@@ -208,6 +209,7 @@ const DateTimePicker = /*#__PURE__*/forwardRef(({
|
|
|
208
209
|
const [dtState, dispatch] = useReducer(reducer, null, () => {
|
|
209
210
|
var _ref;
|
|
210
211
|
const initialValue = (_ref = providedValue !== null && providedValue !== void 0 ? providedValue : defaultValue) !== null && _ref !== void 0 ? _ref : '';
|
|
212
|
+
isZoneExplicitRef.current = hasExplicitZone(initialValue);
|
|
211
213
|
const initialDate = (datePickerPropsWithSelectProps === null || datePickerPropsWithSelectProps === void 0 ? void 0 : datePickerPropsWithSelectProps.defaultValue) || '';
|
|
212
214
|
const initialTime = (timePickerPropsWithSelectProps === null || timePickerPropsWithSelectProps === void 0 ? void 0 : timePickerPropsWithSelectProps.defaultValue) || '';
|
|
213
215
|
if (!initialValue) {
|
|
@@ -248,6 +250,7 @@ const DateTimePicker = /*#__PURE__*/forwardRef(({
|
|
|
248
250
|
// `undefined` to the `value` prop will not clear the hidden input and will
|
|
249
251
|
// cause unexpected issues.
|
|
250
252
|
const hasReceivedProvidedValue = useRef(providedValue !== undefined);
|
|
253
|
+
const lastEmittedValueRef = useRef();
|
|
251
254
|
// We don't want to set the state on the first render, as it would
|
|
252
255
|
// needlessly be a duplicate.
|
|
253
256
|
const isFirstRender = useRef(true);
|
|
@@ -258,12 +261,17 @@ const DateTimePicker = /*#__PURE__*/forwardRef(({
|
|
|
258
261
|
}
|
|
259
262
|
if (providedValue !== undefined) {
|
|
260
263
|
hasReceivedProvidedValue.current = true;
|
|
264
|
+
if (providedValue !== lastEmittedValueRef.current) {
|
|
265
|
+
isZoneExplicitRef.current = hasExplicitZone(providedValue);
|
|
266
|
+
}
|
|
261
267
|
dispatch({
|
|
262
268
|
type: 'SET_VALUE',
|
|
263
269
|
payload: providedValue
|
|
264
270
|
});
|
|
265
271
|
} else if (hasReceivedProvidedValue.current) {
|
|
266
272
|
hasReceivedProvidedValue.current = false;
|
|
273
|
+
isZoneExplicitRef.current = false;
|
|
274
|
+
lastEmittedValueRef.current = undefined;
|
|
267
275
|
dispatch({
|
|
268
276
|
type: 'SET_VALUE',
|
|
269
277
|
payload: ''
|
|
@@ -369,9 +377,10 @@ const DateTimePicker = /*#__PURE__*/forwardRef(({
|
|
|
369
377
|
}) => {
|
|
370
378
|
if (providedDateValue && providedTimeValue) {
|
|
371
379
|
const isoValue = formatDateTimeZoneIntoIso(providedDateValue, providedTimeValue, providedZoneValue);
|
|
380
|
+
const valueToParse = fg('platform-dst-dtp-preserve-offset') && !providedParseValue && !isZoneExplicitRef.current ? formatDateTimeZoneIntoIso(providedDateValue, providedTimeValue, '') : isoValue;
|
|
372
381
|
const {
|
|
373
382
|
zoneValue: parsedZone
|
|
374
|
-
} = parseValue(
|
|
383
|
+
} = parseValue(valueToParse, providedDateValue, providedTimeValue, providedZoneValue);
|
|
375
384
|
const valueWithValidZone = formatDateTimeZoneIntoIso(providedDateValue, providedTimeValue, parsedZone);
|
|
376
385
|
dispatch({
|
|
377
386
|
type: 'APPLY',
|
|
@@ -382,6 +391,7 @@ const DateTimePicker = /*#__PURE__*/forwardRef(({
|
|
|
382
391
|
zoneValue: parsedZone
|
|
383
392
|
}
|
|
384
393
|
});
|
|
394
|
+
lastEmittedValueRef.current = valueWithValidZone;
|
|
385
395
|
onChangePropWithAnalytics(valueWithValidZone);
|
|
386
396
|
// If the date or time value was cleared when there is an existing datetime value, then clear the value.
|
|
387
397
|
} else if (dtState.value) {
|
|
@@ -25,7 +25,7 @@ import { PickerButtonContainer } from '../internal/picker-button-container';
|
|
|
25
25
|
import { placeholderDatetime } from '../internal/placeholder-date-time';
|
|
26
26
|
import { makeSingleValue } from '../internal/single-value';
|
|
27
27
|
const packageName = "@atlaskit/datetime-picker";
|
|
28
|
-
const packageVersion = "19.4.
|
|
28
|
+
const packageVersion = "19.4.2";
|
|
29
29
|
const defaultTimeFormat = 'h:mma';
|
|
30
30
|
const menuStyles = {
|
|
31
31
|
/* Need to remove default absolute positioning as that causes issues with position fixed */
|
|
@@ -40,7 +40,7 @@ import { parseDate } from '../internal/parse-date';
|
|
|
40
40
|
import { PickerButtonContainer } from '../internal/picker-button-container';
|
|
41
41
|
import { makeSingleValue } from '../internal/single-value';
|
|
42
42
|
var packageName = "@atlaskit/datetime-picker";
|
|
43
|
-
var packageVersion = "19.4.
|
|
43
|
+
var packageVersion = "19.4.2";
|
|
44
44
|
var styles = {
|
|
45
45
|
pickerContainerStyle: "_kqswh2mm",
|
|
46
46
|
dropdownIndicatorStyles: "_1ul91k8s _1tke1k8s _1e0c1txw _4cvr1h6o _1bah1h6o",
|
|
@@ -69,7 +69,8 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, _forwardedRef) {
|
|
|
69
69
|
// Track whether focus was caused by an active pointer gesture. Pointer-driven focus must defer
|
|
70
70
|
// opening a top-layer popover until click, while keyboard and programmatic focus can open it now.
|
|
71
71
|
var isPointerInteractionRef = useRef(false);
|
|
72
|
-
|
|
72
|
+
// Top layer: set when Escape is left to Select, so `onMenuClose` resets the picker state.
|
|
73
|
+
var isEscapeCloseRef = useRef(false);
|
|
73
74
|
var _props$appearance = props.appearance,
|
|
74
75
|
appearance = _props$appearance === void 0 ? 'default' : _props$appearance,
|
|
75
76
|
_props$autoFocus = props.autoFocus,
|
|
@@ -226,6 +227,12 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, _forwardedRef) {
|
|
|
226
227
|
var getIsOpen = function getIsOpen() {
|
|
227
228
|
return isOpenProp !== null && isOpenProp !== void 0 ? isOpenProp : isOpen;
|
|
228
229
|
};
|
|
230
|
+
// Top layer: the calendar is closed but still mounted while Select's menu closes. The platform
|
|
231
|
+
// then returns focus, and Firefox first moves focus to `<body>` as the popover hides. Neither is
|
|
232
|
+
// the user leaving or arriving at the field.
|
|
233
|
+
var isCalendarClosing = function isCalendarClosing() {
|
|
234
|
+
return fg('platform-dst-top-layer') && !getIsOpen() && calendarRef.current !== null;
|
|
235
|
+
};
|
|
229
236
|
var onCalendarChange = function onCalendarChange(_ref2) {
|
|
230
237
|
var iso = _ref2.iso;
|
|
231
238
|
setCalendarValue(getParsedISO({
|
|
@@ -241,8 +248,8 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, _forwardedRef) {
|
|
|
241
248
|
setWasOpenedFromCalendarButton(false);
|
|
242
249
|
onChangePropWithAnalytics(iso);
|
|
243
250
|
|
|
244
|
-
//
|
|
245
|
-
//
|
|
251
|
+
// Top layer: no focus move here. Select hides its menu's popover, and the platform returns
|
|
252
|
+
// focus.
|
|
246
253
|
if (!fg('platform-dst-top-layer')) {
|
|
247
254
|
if (wasOpenedFromCalendarButton) {
|
|
248
255
|
var _calendarButtonRef$cu;
|
|
@@ -265,7 +272,10 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, _forwardedRef) {
|
|
|
265
272
|
var _containerRef$current2;
|
|
266
273
|
var newlyFocusedElement = event.relatedTarget;
|
|
267
274
|
isPointerInteractionRef.current = false;
|
|
268
|
-
|
|
275
|
+
// A blur to nowhere while the calendar closes is part of the close. A blur to a real element
|
|
276
|
+
// is the user leaving the field.
|
|
277
|
+
var isClosingBlur = isCalendarClosing() && newlyFocusedElement === null;
|
|
278
|
+
if (!isClosingBlur && !(containerRef !== null && containerRef !== void 0 && (_containerRef$current2 = containerRef.current) !== null && _containerRef$current2 !== void 0 && _containerRef$current2.contains(newlyFocusedElement))) {
|
|
269
279
|
setIsOpen(false);
|
|
270
280
|
setShouldSetFocusOnCurrentDay(false);
|
|
271
281
|
setWasOpenedFromCalendarButton(false);
|
|
@@ -297,7 +307,11 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, _forwardedRef) {
|
|
|
297
307
|
} else {
|
|
298
308
|
// Opening an auto popover during pointer focus allows the matching pointerup
|
|
299
309
|
// to immediately light-dismiss it. Let the subsequent click open it instead.
|
|
300
|
-
|
|
310
|
+
var isPointerFocus = fg('platform-dst-top-layer') && isPointerInteractionRef.current;
|
|
311
|
+
// Focus that returns while the calendar closes must not change the open state.
|
|
312
|
+
// `getIsOpen()` includes an `isOpen={false}` prop, so the calendar shows again when the prop
|
|
313
|
+
// is removed.
|
|
314
|
+
if (!isPointerFocus && !isCalendarClosing()) {
|
|
301
315
|
// Don't open when focused into via keyboard if the calendar button is present
|
|
302
316
|
setIsOpen(!shouldShowCalendarButton);
|
|
303
317
|
}
|
|
@@ -336,11 +350,10 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, _forwardedRef) {
|
|
|
336
350
|
}
|
|
337
351
|
var shouldDeferEscapeHandling = event.key === 'Escape' && isTopLayerEnabled && getIsOpen();
|
|
338
352
|
if (shouldDeferEscapeHandling) {
|
|
339
|
-
var _containerRef$current4, _containerRef$current5;
|
|
340
353
|
// Select owns Escape cancellation and dismissal for its default top-layer popup.
|
|
341
|
-
// Defer DatePicker's
|
|
342
|
-
|
|
343
|
-
|
|
354
|
+
// Defer DatePicker's state cleanup until the menu has closed. No focus move here: Select
|
|
355
|
+
// hides its menu's popover, and the platform returns focus.
|
|
356
|
+
isEscapeCloseRef.current = !event.defaultPrevented;
|
|
344
357
|
return;
|
|
345
358
|
}
|
|
346
359
|
switch (keyPressed) {
|
|
@@ -350,8 +363,8 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, _forwardedRef) {
|
|
|
350
363
|
var _calendarButtonRef$cu2;
|
|
351
364
|
(_calendarButtonRef$cu2 = calendarButtonRef.current) === null || _calendarButtonRef$cu2 === void 0 || _calendarButtonRef$cu2.focus();
|
|
352
365
|
} else {
|
|
353
|
-
var _containerRef$
|
|
354
|
-
var innerCombobox = containerRef === null || containerRef === void 0 || (_containerRef$
|
|
366
|
+
var _containerRef$current4;
|
|
367
|
+
var innerCombobox = containerRef === null || containerRef === void 0 || (_containerRef$current4 = containerRef.current) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.querySelector('[role="combobox"]');
|
|
355
368
|
innerCombobox === null || innerCombobox === void 0 || innerCombobox.focus();
|
|
356
369
|
}
|
|
357
370
|
setIsOpen(false);
|
|
@@ -407,10 +420,9 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, _forwardedRef) {
|
|
|
407
420
|
};
|
|
408
421
|
var onMenuClose = function onMenuClose() {
|
|
409
422
|
var _selectProps$onMenuCl;
|
|
410
|
-
var
|
|
411
|
-
|
|
412
|
-
if (fg('platform-dst-top-layer') &&
|
|
413
|
-
focusTarget.focus();
|
|
423
|
+
var isEscapeClose = isEscapeCloseRef.current;
|
|
424
|
+
isEscapeCloseRef.current = false;
|
|
425
|
+
if (fg('platform-dst-top-layer') && isEscapeClose) {
|
|
414
426
|
setIsOpen(false);
|
|
415
427
|
setShouldSetFocusOnCurrentDay(false);
|
|
416
428
|
setWasOpenedFromCalendarButton(false);
|
|
@@ -29,7 +29,7 @@ import { convertTokens } from '../internal/parse-tokens';
|
|
|
29
29
|
import DatePicker from './date-picker';
|
|
30
30
|
import TimePicker from './time-picker';
|
|
31
31
|
var packageName = "@atlaskit/datetime-picker";
|
|
32
|
-
var packageVersion = "19.4.
|
|
32
|
+
var packageVersion = "19.4.2";
|
|
33
33
|
var analyticsAttributes = {
|
|
34
34
|
componentName: 'dateTimePicker',
|
|
35
35
|
packageName: packageName,
|
|
@@ -77,6 +77,9 @@ var getStyles = function getStyles(isInputMotionEnabled, roundedCorners) {
|
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
79
|
};
|
|
80
|
+
var hasExplicitZone = function hasExplicitZone(value) {
|
|
81
|
+
return value.endsWith('Z') || Math.max(value.lastIndexOf('+'), value.lastIndexOf('-')) > 15;
|
|
82
|
+
};
|
|
80
83
|
var parseDateTimeValueWithOffset = function parseDateTimeValueWithOffset(value) {
|
|
81
84
|
var parsed = parseISO(value);
|
|
82
85
|
var zoneStart = value.endsWith('Z') ? value.length - 1 : Math.max(value.lastIndexOf('+'), value.lastIndexOf('-'));
|
|
@@ -95,8 +98,7 @@ var parseDateTimeValueWithOffset = function parseDateTimeValueWithOffset(value)
|
|
|
95
98
|
};
|
|
96
99
|
var parseDateTimeValue = function parseDateTimeValue(value) {
|
|
97
100
|
if (fg('platform-dst-dtp-preserve-offset')) {
|
|
98
|
-
|
|
99
|
-
if (hasExplicitZone) {
|
|
101
|
+
if (hasExplicitZone(value)) {
|
|
100
102
|
return parseDateTimeValueWithOffset(value);
|
|
101
103
|
}
|
|
102
104
|
}
|
|
@@ -176,6 +178,7 @@ var DateTimePicker = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
176
178
|
isFocused = _useState2[0],
|
|
177
179
|
setIsFocused = _useState2[1];
|
|
178
180
|
var isInputMotionEnabled = fg('platform-dst-motion-uplift-input');
|
|
181
|
+
var isZoneExplicitRef = useRef(false);
|
|
179
182
|
|
|
180
183
|
/**
|
|
181
184
|
* Defined inside the component so the reducer closes over `providedParseValue`
|
|
@@ -228,6 +231,7 @@ var DateTimePicker = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
228
231
|
var _useReducer = useReducer(reducer, null, function () {
|
|
229
232
|
var _ref3;
|
|
230
233
|
var initialValue = (_ref3 = providedValue !== null && providedValue !== void 0 ? providedValue : defaultValue) !== null && _ref3 !== void 0 ? _ref3 : '';
|
|
234
|
+
isZoneExplicitRef.current = hasExplicitZone(initialValue);
|
|
231
235
|
var initialDate = (datePickerPropsWithSelectProps === null || datePickerPropsWithSelectProps === void 0 ? void 0 : datePickerPropsWithSelectProps.defaultValue) || '';
|
|
232
236
|
var initialTime = (timePickerPropsWithSelectProps === null || timePickerPropsWithSelectProps === void 0 ? void 0 : timePickerPropsWithSelectProps.defaultValue) || '';
|
|
233
237
|
if (!initialValue) {
|
|
@@ -269,6 +273,7 @@ var DateTimePicker = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
269
273
|
// `undefined` to the `value` prop will not clear the hidden input and will
|
|
270
274
|
// cause unexpected issues.
|
|
271
275
|
var hasReceivedProvidedValue = useRef(providedValue !== undefined);
|
|
276
|
+
var lastEmittedValueRef = useRef();
|
|
272
277
|
// We don't want to set the state on the first render, as it would
|
|
273
278
|
// needlessly be a duplicate.
|
|
274
279
|
var isFirstRender = useRef(true);
|
|
@@ -279,12 +284,17 @@ var DateTimePicker = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
279
284
|
}
|
|
280
285
|
if (providedValue !== undefined) {
|
|
281
286
|
hasReceivedProvidedValue.current = true;
|
|
287
|
+
if (providedValue !== lastEmittedValueRef.current) {
|
|
288
|
+
isZoneExplicitRef.current = hasExplicitZone(providedValue);
|
|
289
|
+
}
|
|
282
290
|
dispatch({
|
|
283
291
|
type: 'SET_VALUE',
|
|
284
292
|
payload: providedValue
|
|
285
293
|
});
|
|
286
294
|
} else if (hasReceivedProvidedValue.current) {
|
|
287
295
|
hasReceivedProvidedValue.current = false;
|
|
296
|
+
isZoneExplicitRef.current = false;
|
|
297
|
+
lastEmittedValueRef.current = undefined;
|
|
288
298
|
dispatch({
|
|
289
299
|
type: 'SET_VALUE',
|
|
290
300
|
payload: ''
|
|
@@ -388,7 +398,8 @@ var DateTimePicker = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
388
398
|
providedZoneValue = _ref4.providedZoneValue;
|
|
389
399
|
if (providedDateValue && providedTimeValue) {
|
|
390
400
|
var isoValue = formatDateTimeZoneIntoIso(providedDateValue, providedTimeValue, providedZoneValue);
|
|
391
|
-
var
|
|
401
|
+
var valueToParse = fg('platform-dst-dtp-preserve-offset') && !providedParseValue && !isZoneExplicitRef.current ? formatDateTimeZoneIntoIso(providedDateValue, providedTimeValue, '') : isoValue;
|
|
402
|
+
var _parseValue = parseValue(valueToParse, providedDateValue, providedTimeValue, providedZoneValue),
|
|
392
403
|
parsedZone = _parseValue.zoneValue;
|
|
393
404
|
var valueWithValidZone = formatDateTimeZoneIntoIso(providedDateValue, providedTimeValue, parsedZone);
|
|
394
405
|
dispatch({
|
|
@@ -400,6 +411,7 @@ var DateTimePicker = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
400
411
|
zoneValue: parsedZone
|
|
401
412
|
}
|
|
402
413
|
});
|
|
414
|
+
lastEmittedValueRef.current = valueWithValidZone;
|
|
403
415
|
onChangePropWithAnalytics(valueWithValidZone);
|
|
404
416
|
// If the date or time value was cleared when there is an existing datetime value, then clear the value.
|
|
405
417
|
} else if (dtState.value) {
|
|
@@ -31,7 +31,7 @@ import { PickerButtonContainer } from '../internal/picker-button-container';
|
|
|
31
31
|
import { placeholderDatetime } from '../internal/placeholder-date-time';
|
|
32
32
|
import { makeSingleValue } from '../internal/single-value';
|
|
33
33
|
var packageName = "@atlaskit/datetime-picker";
|
|
34
|
-
var packageVersion = "19.4.
|
|
34
|
+
var packageVersion = "19.4.2";
|
|
35
35
|
var defaultTimeFormat = 'h:mma';
|
|
36
36
|
var menuStyles = {
|
|
37
37
|
/* Need to remove default absolute positioning as that causes issues with position fixed */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/datetime-picker",
|
|
3
|
-
"version": "19.4.
|
|
3
|
+
"version": "19.4.3",
|
|
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,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@atlaskit/analytics-next": "^12.6.0",
|
|
38
|
-
"@atlaskit/button": "^25.
|
|
38
|
+
"@atlaskit/button": "^25.7.0",
|
|
39
39
|
"@atlaskit/calendar": "^19.5.0",
|
|
40
40
|
"@atlaskit/css": "^1.1.0",
|
|
41
41
|
"@atlaskit/ds-lib": "^8.0.0",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"@atlaskit/react-compiler-gating": "^0.2.0",
|
|
49
49
|
"@atlaskit/react-select": "^4.12.0",
|
|
50
50
|
"@atlaskit/select": "^23.1.0",
|
|
51
|
-
"@atlaskit/tokens": "^20.
|
|
52
|
-
"@atlaskit/top-layer": "^
|
|
51
|
+
"@atlaskit/tokens": "^20.9.0",
|
|
52
|
+
"@atlaskit/top-layer": "^7.1.0",
|
|
53
53
|
"@babel/runtime": "^7.0.0",
|
|
54
54
|
"@compiled/react": "^1.0.2",
|
|
55
55
|
"date-fns": "^2.17.0"
|
|
@@ -62,17 +62,17 @@
|
|
|
62
62
|
"@af/integration-testing": "workspace:^",
|
|
63
63
|
"@af/visual-regression": "workspace:^",
|
|
64
64
|
"@atlaskit/code": "^20.0.0",
|
|
65
|
-
"@atlaskit/codemod-utils": "^5.
|
|
65
|
+
"@atlaskit/codemod-utils": "^5.2.0",
|
|
66
66
|
"@atlaskit/docs": "^12.3.0",
|
|
67
|
-
"@atlaskit/form": "^18.
|
|
67
|
+
"@atlaskit/form": "^18.3.0",
|
|
68
68
|
"@atlaskit/heading": "^8.0.0",
|
|
69
69
|
"@atlaskit/link": "^5.1.0",
|
|
70
70
|
"@atlaskit/menu": "^11.0.0",
|
|
71
|
-
"@atlaskit/modal-dialog": "^17.
|
|
72
|
-
"@atlaskit/popup": "^10.
|
|
71
|
+
"@atlaskit/modal-dialog": "^17.2.0",
|
|
72
|
+
"@atlaskit/popup": "^10.2.0",
|
|
73
73
|
"@atlaskit/range": "^12.2.0",
|
|
74
74
|
"@atlaskit/section-message": "^10.2.0",
|
|
75
|
-
"@atlaskit/textfield": "^10.
|
|
75
|
+
"@atlaskit/textfield": "^10.3.0",
|
|
76
76
|
"@atlaskit/toggle": "^17.3.0",
|
|
77
77
|
"@atlassian/feature-flags-test-utils": "^1.3.0",
|
|
78
78
|
"@atlassian/ssr-tests": "workspace:^",
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type ASTPath, type JSCodeshift, type JSXAttribute, type JSXElement } from 'jscodeshift';
|
|
2
|
-
|
|
3
|
-
export const getJSXAttributeByName: (
|
|
4
|
-
j: JSCodeshift,
|
|
5
|
-
jsxElementPath: ASTPath<JSXElement>,
|
|
6
|
-
attributeName: string,
|
|
7
|
-
) => JSXAttribute | undefined = (
|
|
8
|
-
j: JSCodeshift,
|
|
9
|
-
jsxElementPath: ASTPath<JSXElement>,
|
|
10
|
-
attributeName: string,
|
|
11
|
-
): JSXAttribute | undefined => {
|
|
12
|
-
const attributes: JSXAttribute[] = j(jsxElementPath).find(j.JSXAttribute).nodes();
|
|
13
|
-
|
|
14
|
-
return attributes?.find((attr) => attr.name && attr.name.name === attributeName);
|
|
15
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type ASTPath, type JSCodeshift, type JSXAttribute, type JSXElement } from 'jscodeshift';
|
|
2
|
-
import { type Collection } from 'jscodeshift/src/Collection';
|
|
3
|
-
|
|
4
|
-
export function getJSXAttributesByName(
|
|
5
|
-
j: JSCodeshift,
|
|
6
|
-
jsxElementPath: ASTPath<JSXElement>,
|
|
7
|
-
attributeName: string,
|
|
8
|
-
): Collection<JSXAttribute> {
|
|
9
|
-
return j(jsxElementPath)
|
|
10
|
-
.find(j.JSXOpeningElement)
|
|
11
|
-
.find(j.JSXAttribute)
|
|
12
|
-
.filter((jsxAttributePath) =>
|
|
13
|
-
j(jsxAttributePath)
|
|
14
|
-
.find(j.JSXIdentifier)
|
|
15
|
-
.some((jsxIdentifierPath) => jsxIdentifierPath.node.name === attributeName),
|
|
16
|
-
);
|
|
17
|
-
}
|