@atlaskit/datetime-picker 18.3.1 → 18.4.1
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 +52 -0
- package/__tests__/playwright/top-layer-focus.spec.tsx +34 -37
- package/codemods/14.0.0-remove-duplicate-and-unused-props.tsx +0 -1
- package/dist/cjs/components/date-picker.js +38 -31
- package/dist/cjs/components/date-time-picker.js +6 -6
- package/dist/cjs/components/time-picker.js +15 -22
- package/dist/cjs/internal/date-time-picker-container.js +2 -2
- package/dist/cjs/internal/fixed-layer-menu-top-layer.js +3 -7
- package/dist/cjs/internal/fixed-layer-menu.js +4 -8
- package/dist/cjs/internal/fixed-layer.js +7 -5
- package/dist/cjs/internal/indicators-container.js +2 -2
- package/dist/cjs/internal/menu-top-layer.compiled.css +5 -0
- package/dist/cjs/internal/menu-top-layer.js +11 -51
- package/dist/cjs/internal/menu.js +3 -3
- package/dist/cjs/internal/single-value.js +3 -2
- package/dist/es2019/components/date-picker.js +31 -24
- package/dist/es2019/components/date-time-picker.js +3 -3
- package/dist/es2019/components/time-picker.js +10 -17
- package/dist/es2019/internal/date-time-picker-container.js +1 -1
- package/dist/es2019/internal/fixed-layer-menu-top-layer.js +2 -6
- package/dist/es2019/internal/fixed-layer-menu.js +3 -7
- package/dist/es2019/internal/fixed-layer.js +4 -2
- package/dist/es2019/internal/indicators-container.js +1 -1
- package/dist/es2019/internal/menu-top-layer.compiled.css +5 -0
- package/dist/es2019/internal/menu-top-layer.js +12 -53
- package/dist/es2019/internal/menu.js +2 -2
- package/dist/es2019/internal/single-value.js +2 -2
- package/dist/esm/components/date-picker.js +31 -24
- package/dist/esm/components/date-time-picker.js +3 -3
- package/dist/esm/components/time-picker.js +10 -17
- package/dist/esm/internal/date-time-picker-container.js +1 -1
- package/dist/esm/internal/fixed-layer-menu-top-layer.js +2 -6
- package/dist/esm/internal/fixed-layer-menu.js +3 -7
- package/dist/esm/internal/fixed-layer.js +4 -2
- package/dist/esm/internal/indicators-container.js +1 -1
- package/dist/esm/internal/menu-top-layer.compiled.css +5 -0
- package/dist/esm/internal/menu-top-layer.js +12 -53
- package/dist/esm/internal/menu.js +2 -2
- package/dist/esm/internal/single-value.js +2 -2
- package/dist/types/components/date-picker.d.ts +1 -1
- package/dist/types/internal/fixed-layer-menu-top-layer.d.ts +1 -1
- package/dist/types/internal/fixed-layer-menu.d.ts +1 -1
- package/dist/types/internal/format-date.d.ts +1 -1
- package/dist/types/internal/get-placeholder.d.ts +1 -1
- package/dist/types/internal/indicators-container.d.ts +1 -1
- package/dist/types/internal/menu-top-layer.d.ts +3 -5
- package/dist/types/internal/menu.d.ts +1 -1
- package/dist/types/internal/parse-date.d.ts +1 -1
- package/dist/types/internal/single-value.d.ts +1 -1
- package/dist/types/types.d.ts +2 -2
- package/package.json +22 -21
- package/datetime-picker.docs.tsx +0 -132
|
@@ -1,23 +1,11 @@
|
|
|
1
1
|
/* menu-top-layer.tsx generated by @compiled/babel-plugin v2.0.0 */
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
+
import "./menu-top-layer.compiled.css";
|
|
3
4
|
import * as React from 'react';
|
|
4
5
|
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
-
import { Fragment
|
|
6
|
+
import { Fragment } from 'react';
|
|
6
7
|
import { isValid, parseISO } from 'date-fns';
|
|
7
|
-
import Calendar from '@atlaskit/calendar';
|
|
8
|
-
import { fromLegacyPlacement } from '@atlaskit/top-layer/placement-map';
|
|
9
|
-
import { Popover } from '@atlaskit/top-layer/popover';
|
|
10
|
-
import { PopoverSurface } from '@atlaskit/top-layer/popover-surface';
|
|
11
|
-
import { useAnchorPosition } from '@atlaskit/top-layer/use-anchor-position';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Bottom-start placement: calendar appears below and aligned to the
|
|
15
|
-
* start edge of the trigger (the select input).
|
|
16
|
-
*/
|
|
17
|
-
const popupPlacement = fromLegacyPlacement({
|
|
18
|
-
legacy: 'bottom-start'
|
|
19
|
-
});
|
|
20
|
-
|
|
8
|
+
import Calendar from '@atlaskit/calendar/calendar';
|
|
21
9
|
/**
|
|
22
10
|
* @param isos A series of ISO dates.
|
|
23
11
|
* @returns The last valid date within the array of ISO strings.
|
|
@@ -32,14 +20,15 @@ function getValidDate(isos) {
|
|
|
32
20
|
} : acc;
|
|
33
21
|
}, {});
|
|
34
22
|
}
|
|
23
|
+
const styles = {
|
|
24
|
+
root: "_2rko1mok _1bsb1ris _bfhk1bhr _16qs130s _1pfhu2gc _6rthu2gc"
|
|
25
|
+
};
|
|
35
26
|
|
|
36
27
|
/**
|
|
37
28
|
* Top-layer version of the date picker menu.
|
|
38
29
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* CSS Anchor Positioning. This avoids overflow clipping, z-index wars,
|
|
42
|
-
* and portal-based layering.
|
|
30
|
+
* The surrounding react-select menu portal owns the native popover and
|
|
31
|
+
* positioning. This component only supplies the calendar dialog content.
|
|
43
32
|
*
|
|
44
33
|
* Gated behind the `platform-dst-top-layer` feature flag.
|
|
45
34
|
*/
|
|
@@ -47,7 +36,6 @@ export const MenuTopLayer = ({
|
|
|
47
36
|
selectProps,
|
|
48
37
|
innerProps
|
|
49
38
|
}) => {
|
|
50
|
-
var _selectProps$calendar, _selectProps$calendar2;
|
|
51
39
|
const {
|
|
52
40
|
calendarValue,
|
|
53
41
|
calendarView,
|
|
@@ -58,20 +46,6 @@ export const MenuTopLayer = ({
|
|
|
58
46
|
month,
|
|
59
47
|
year
|
|
60
48
|
} = getValidDate([calendarValue, calendarView]);
|
|
61
|
-
|
|
62
|
-
// The select's container element is the anchor for the popup.
|
|
63
|
-
const triggerRef = useRef((_selectProps$calendar = selectProps.calendarContainerRef) !== null && _selectProps$calendar !== void 0 ? _selectProps$calendar : null);
|
|
64
|
-
triggerRef.current = (_selectProps$calendar2 = selectProps.calendarContainerRef) !== null && _selectProps$calendar2 !== void 0 ? _selectProps$calendar2 : null;
|
|
65
|
-
const popoverRef = useRef(null);
|
|
66
|
-
useAnchorPosition({
|
|
67
|
-
anchorRef: triggerRef,
|
|
68
|
-
popoverRef,
|
|
69
|
-
placement: popupPlacement,
|
|
70
|
-
// The Popover is rendered with `isOpen` always true while this
|
|
71
|
-
// component is mounted (react-select conditionally mounts/unmounts
|
|
72
|
-
// the menu), so positioning is always active.
|
|
73
|
-
isOpen: true
|
|
74
|
-
});
|
|
75
49
|
const onMenuMouseDown = event => {
|
|
76
50
|
if (event.button !== 0) {
|
|
77
51
|
return;
|
|
@@ -80,25 +54,10 @@ export const MenuTopLayer = ({
|
|
|
80
54
|
event.preventDefault();
|
|
81
55
|
};
|
|
82
56
|
const Wrapper = typeof MenuInnerWrapper === 'function' ? MenuInnerWrapper : Fragment;
|
|
83
|
-
return /*#__PURE__*/React.createElement(
|
|
84
|
-
|
|
85
|
-
role: "dialog",
|
|
86
|
-
label: "calendar",
|
|
87
|
-
isOpen: true
|
|
88
|
-
// `mode="manual"` opts out of native popover light-dismiss.
|
|
89
|
-
// react-select / DateTimePicker already own outside-click and
|
|
90
|
-
// Esc handling. Without this, the same click that opens the
|
|
91
|
-
// menu (which targets the select input outside the popover)
|
|
92
|
-
// also bubbles to the browser's auto-dismiss handler and
|
|
93
|
-
// immediately closes the popover.
|
|
94
|
-
,
|
|
95
|
-
mode: "manual",
|
|
96
|
-
placement: popupPlacement,
|
|
97
|
-
shouldAnimate: true,
|
|
98
|
-
testId: selectProps.testId && `${selectProps.testId}--popup`
|
|
99
|
-
}, /*#__PURE__*/React.createElement(PopoverSurface, null, /*#__PURE__*/React.createElement("div", _extends({}, innerProps, {
|
|
57
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, innerProps, {
|
|
58
|
+
onMouseDown: onMenuMouseDown,
|
|
100
59
|
role: "presentation",
|
|
101
|
-
|
|
60
|
+
className: ax([styles.root])
|
|
102
61
|
}), /*#__PURE__*/React.createElement(Wrapper, null, /*#__PURE__*/React.createElement(Calendar, {
|
|
103
62
|
day: day,
|
|
104
63
|
month: month,
|
|
@@ -117,5 +76,5 @@ export const MenuTopLayer = ({
|
|
|
117
76
|
locale: selectProps.calendarLocale,
|
|
118
77
|
testId: selectProps.testId && `${selectProps.testId}--calendar`,
|
|
119
78
|
weekStartDay: selectProps.calendarWeekStartDay
|
|
120
|
-
})))
|
|
79
|
+
})));
|
|
121
80
|
};
|
|
@@ -7,9 +7,9 @@ import { Fragment } from 'react';
|
|
|
7
7
|
|
|
8
8
|
// oxlint-disable-next-line @atlassian/no-restricted-imports
|
|
9
9
|
import { isValid, parseISO } from 'date-fns';
|
|
10
|
-
import Calendar from '@atlaskit/calendar';
|
|
10
|
+
import Calendar from '@atlaskit/calendar/calendar';
|
|
11
11
|
import { Layering } from '@atlaskit/layering/layering';
|
|
12
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
13
13
|
import FixedLayer from '../internal/fixed-layer';
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { components } from '@atlaskit/select';
|
|
4
|
-
|
|
3
|
+
import { components } from '@atlaskit/react-select/components';
|
|
5
4
|
/**
|
|
6
5
|
* This creates a functional component that `react-select` will use to make the
|
|
7
6
|
* SingleValue part of the different pickers.
|
|
8
7
|
*/
|
|
9
8
|
export const makeSingleValue =
|
|
10
9
|
// TODO: Make ID required
|
|
10
|
+
|
|
11
11
|
({
|
|
12
12
|
id,
|
|
13
13
|
lang
|
|
@@ -15,15 +15,16 @@ import { forwardRef, useCallback, useEffect, useReducer, useRef, useState } from
|
|
|
15
15
|
|
|
16
16
|
// oxlint-disable-next-line @atlassian/no-restricted-imports
|
|
17
17
|
import { isValid, parseISO } from 'date-fns';
|
|
18
|
-
import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
|
|
18
|
+
import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next/usePlatformLeafEventHandler';
|
|
19
19
|
import { IconButton } from '@atlaskit/button/new';
|
|
20
20
|
import { cx } from '@atlaskit/css';
|
|
21
21
|
import { useId } from '@atlaskit/ds-lib/use-id';
|
|
22
22
|
import CalendarIcon from '@atlaskit/icon/core/calendar';
|
|
23
|
-
import { createLocalizationProvider } from '@atlaskit/locale';
|
|
24
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
23
|
+
import { createLocalizationProvider } from '@atlaskit/locale/localization-provider';
|
|
24
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
25
25
|
import { Box } from '@atlaskit/primitives/compiled';
|
|
26
|
-
import Select
|
|
26
|
+
import Select from '@atlaskit/select/default';
|
|
27
|
+
import { mergeStyles } from '@atlaskit/react-select/styles';
|
|
27
28
|
import { EmptyComponent } from '../internal/empty-component';
|
|
28
29
|
import { formatDate } from '../internal/format-date';
|
|
29
30
|
import { getParsedISO } from '../internal/get-parsed-iso';
|
|
@@ -37,7 +38,7 @@ import { MenuTopLayer } from '../internal/menu-top-layer';
|
|
|
37
38
|
import { parseDate } from '../internal/parse-date';
|
|
38
39
|
import { makeSingleValue } from '../internal/single-value';
|
|
39
40
|
var packageName = "@atlaskit/datetime-picker";
|
|
40
|
-
var packageVersion = "18.
|
|
41
|
+
var packageVersion = "18.4.0";
|
|
41
42
|
var styles = {
|
|
42
43
|
pickerContainerStyle: "_kqswh2mm",
|
|
43
44
|
dropdownIndicatorStyles: "_1ul91k8s _1tke1k8s _1e0c1txw _4cvr1h6o _1bah1h6o",
|
|
@@ -64,6 +65,7 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, _forwardedRef) {
|
|
|
64
65
|
var containerRef = useRef(null);
|
|
65
66
|
var calendarRef = useRef(null);
|
|
66
67
|
var calendarButtonRef = useRef(null);
|
|
68
|
+
var isPointerInteractionRef = useRef(false);
|
|
67
69
|
var _props$appearance = props.appearance,
|
|
68
70
|
appearance = _props$appearance === void 0 ? 'default' : _props$appearance,
|
|
69
71
|
_props$autoFocus = props.autoFocus,
|
|
@@ -189,19 +191,15 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, _forwardedRef) {
|
|
|
189
191
|
setLocale(propLocale);
|
|
190
192
|
}
|
|
191
193
|
useEffect(function () {
|
|
192
|
-
//
|
|
194
|
+
// Only move focus when the dedicated calendar button opened the menu.
|
|
193
195
|
if (!isKeyDown) {
|
|
194
196
|
return;
|
|
195
197
|
}
|
|
196
198
|
if (isOpen && wasOpenedFromCalendarButton) {
|
|
199
|
+
var _calendarRef$current;
|
|
197
200
|
setIsKeyDown(false);
|
|
198
|
-
//
|
|
199
|
-
|
|
200
|
-
if (!fg('platform-dst-top-layer')) {
|
|
201
|
-
var _calendarRef$current;
|
|
202
|
-
// Focus on the first button within the calendar
|
|
203
|
-
calendarRef === null || calendarRef === void 0 || (_calendarRef$current = calendarRef.current) === null || _calendarRef$current === void 0 || (_calendarRef$current = _calendarRef$current.querySelector('button')) === null || _calendarRef$current === void 0 || _calendarRef$current.focus();
|
|
204
|
-
}
|
|
201
|
+
// Focus on the first button within the calendar
|
|
202
|
+
calendarRef === null || calendarRef === void 0 || (_calendarRef$current = calendarRef.current) === null || _calendarRef$current === void 0 || (_calendarRef$current = _calendarRef$current.querySelector('button')) === null || _calendarRef$current === void 0 || _calendarRef$current.focus();
|
|
205
203
|
}
|
|
206
204
|
}, [isKeyDown, calendarRef, isOpen, wasOpenedFromCalendarButton]);
|
|
207
205
|
var getValue = function getValue() {
|
|
@@ -248,6 +246,7 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, _forwardedRef) {
|
|
|
248
246
|
var onContainerBlur = function onContainerBlur(event) {
|
|
249
247
|
var _containerRef$current2;
|
|
250
248
|
var newlyFocusedElement = event.relatedTarget;
|
|
249
|
+
isPointerInteractionRef.current = false;
|
|
251
250
|
if (!(containerRef !== null && containerRef !== void 0 && (_containerRef$current2 = containerRef.current) !== null && _containerRef$current2 !== void 0 && _containerRef$current2.contains(newlyFocusedElement))) {
|
|
252
251
|
setIsOpen(false);
|
|
253
252
|
setShouldSetFocusOnCurrentDay(false);
|
|
@@ -278,8 +277,12 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, _forwardedRef) {
|
|
|
278
277
|
// Don't open menu if focussing after the user has clicked clear
|
|
279
278
|
setClearingFromIcon(false);
|
|
280
279
|
} else {
|
|
281
|
-
//
|
|
282
|
-
|
|
280
|
+
// Opening an auto popover during pointer focus allows the matching pointerup
|
|
281
|
+
// to immediately light-dismiss it. Let the subsequent click open it instead.
|
|
282
|
+
if (!fg('platform-dst-top-layer') || !isPointerInteractionRef.current) {
|
|
283
|
+
// Don't open when focused into via keyboard if the calendar button is present
|
|
284
|
+
setIsOpen(!shouldShowCalendarButton);
|
|
285
|
+
}
|
|
283
286
|
setCalendarValue(value);
|
|
284
287
|
setIsFocused(true);
|
|
285
288
|
setWasOpenedFromCalendarButton(false);
|
|
@@ -315,12 +318,7 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, _forwardedRef) {
|
|
|
315
318
|
}
|
|
316
319
|
switch (keyPressed) {
|
|
317
320
|
case 'escape':
|
|
318
|
-
// Restore focus
|
|
319
|
-
// the legacy path because it has no built-in restoration, and
|
|
320
|
-
// the top-layer path because the menu uses `mode="manual"` to
|
|
321
|
-
// avoid the auto-popover light-dismiss closing the menu on the
|
|
322
|
-
// same click that opens it (see internal/menu-top-layer.tsx).
|
|
323
|
-
// `manual` mode disables the browser's native focus return.
|
|
321
|
+
// Restore focus because it may have moved from the input into the calendar.
|
|
324
322
|
if (wasOpenedFromCalendarButton) {
|
|
325
323
|
var _calendarButtonRef$cu2;
|
|
326
324
|
(_calendarButtonRef$cu2 = calendarButtonRef.current) === null || _calendarButtonRef$cu2 === void 0 || _calendarButtonRef$cu2.focus();
|
|
@@ -398,6 +396,9 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, _forwardedRef) {
|
|
|
398
396
|
|
|
399
397
|
// This event handler is triggered from both keydown and click. It's weird.
|
|
400
398
|
var onCalendarButtonClick = function onCalendarButtonClick(e) {
|
|
399
|
+
if (!getIsOpen() && fg('platform-dst-top-layer')) {
|
|
400
|
+
setIsKeyDown(true);
|
|
401
|
+
}
|
|
401
402
|
setIsOpen(function (isOpen) {
|
|
402
403
|
if (isOpen) {
|
|
403
404
|
var _props$selectProps2, _props$selectProps2$o;
|
|
@@ -501,8 +502,6 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, _forwardedRef) {
|
|
|
501
502
|
*/
|
|
502
503
|
menuInnerWrapper: props === null || props === void 0 ? void 0 : props.menuInnerWrapper
|
|
503
504
|
};
|
|
504
|
-
|
|
505
|
-
// @ts-ignore -- Argument of type 'StylesConfig<OptionType, false, GroupBase<OptionType>>' is not assignable to parameter of type 'StylesConfig<OptionType, boolean, GroupBase<OptionType>>'.
|
|
506
505
|
var mergedStyles = mergeStyles(selectStyles, {
|
|
507
506
|
control: function control(base) {
|
|
508
507
|
return _objectSpread(_objectSpread({}, base), disabledStyle);
|
|
@@ -530,10 +529,19 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, _forwardedRef) {
|
|
|
530
529
|
return /*#__PURE__*/React.createElement("div", _extends({}, innerProps, {
|
|
531
530
|
"data-testid": testId && "".concat(testId, "--container"),
|
|
532
531
|
onBlur: onContainerBlur,
|
|
532
|
+
onClickCapture: function onClickCapture() {
|
|
533
|
+
isPointerInteractionRef.current = false;
|
|
534
|
+
},
|
|
533
535
|
onFocus: onContainerFocus,
|
|
534
536
|
onClick: onInputClick,
|
|
535
537
|
onInput: onTextInput,
|
|
536
538
|
onKeyDown: onInputKeyDown,
|
|
539
|
+
onPointerCancelCapture: function onPointerCancelCapture() {
|
|
540
|
+
isPointerInteractionRef.current = false;
|
|
541
|
+
},
|
|
542
|
+
onPointerDownCapture: function onPointerDownCapture() {
|
|
543
|
+
isPointerInteractionRef.current = true;
|
|
544
|
+
},
|
|
537
545
|
ref: getContainerRef
|
|
538
546
|
// Since the onclick, onfocus are passed down, adding role="presentation" prevents typecheck errors.
|
|
539
547
|
,
|
|
@@ -586,7 +594,6 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, _forwardedRef) {
|
|
|
586
594
|
spacing: spacing,
|
|
587
595
|
testId: testId
|
|
588
596
|
// These aren't part of `Select`'s API, but we're using them here.
|
|
589
|
-
// @ts-ignore -- Property 'calendarContainerRef' does not exist on type 'IntrinsicAttributes & LibraryManagedAttributes<(<Option extends unknown = OptionType, IsMulti extends boolean = false>(props: AtlaskitSelectProps<Option, IsMulti> & { ...; }) => Element), AtlaskitSelectProps<...> & { ...; }>'.
|
|
590
597
|
,
|
|
591
598
|
calendarContainerRef: calendarProps.calendarContainerRef,
|
|
592
599
|
calendarDisabled: calendarProps.calendarDisabled,
|
|
@@ -16,18 +16,18 @@ import React, { forwardRef, useCallback, useEffect, useReducer, useRef, useState
|
|
|
16
16
|
|
|
17
17
|
// oxlint-disable-next-line @atlassian/no-restricted-imports
|
|
18
18
|
import { format, isValid, parseISO } from 'date-fns';
|
|
19
|
-
import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
|
|
19
|
+
import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next/usePlatformLeafEventHandler';
|
|
20
20
|
import { IconButton } from '@atlaskit/button/new';
|
|
21
21
|
import SelectClearIcon from '@atlaskit/icon/core/cross-circle';
|
|
22
22
|
import { Box, Inline } from '@atlaskit/primitives/compiled';
|
|
23
|
-
import { mergeStyles } from '@atlaskit/select';
|
|
23
|
+
import { mergeStyles } from '@atlaskit/react-select/styles';
|
|
24
24
|
import { DateTimePickerContainer } from '../internal/date-time-picker-container';
|
|
25
25
|
import { formatDateTimeZoneIntoIso } from '../internal/format-date-time-zone-into-iso';
|
|
26
26
|
import { convertTokens } from '../internal/parse-tokens';
|
|
27
27
|
import DatePicker from './date-picker';
|
|
28
28
|
import TimePicker from './time-picker';
|
|
29
29
|
var packageName = "@atlaskit/datetime-picker";
|
|
30
|
-
var packageVersion = "18.
|
|
30
|
+
var packageVersion = "18.4.0";
|
|
31
31
|
var analyticsAttributes = {
|
|
32
32
|
componentName: 'dateTimePicker',
|
|
33
33
|
packageName: packageName,
|
|
@@ -9,11 +9,13 @@ import React, { forwardRef, useCallback, useEffect, useReducer, useState } from
|
|
|
9
9
|
|
|
10
10
|
// oxlint-disable-next-line @atlassian/no-restricted-imports
|
|
11
11
|
import { format, isValid } from 'date-fns';
|
|
12
|
-
import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
|
|
12
|
+
import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next/usePlatformLeafEventHandler';
|
|
13
13
|
import __noop from '@atlaskit/ds-lib/noop';
|
|
14
|
-
import { createLocalizationProvider } from '@atlaskit/locale';
|
|
15
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
|
-
import Select
|
|
14
|
+
import { createLocalizationProvider } from '@atlaskit/locale/localization-provider';
|
|
15
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
16
|
+
import Select from '@atlaskit/select/default';
|
|
17
|
+
import CreatableSelect from '@atlaskit/select/creatable-select';
|
|
18
|
+
import { mergeStyles } from '@atlaskit/react-select/styles';
|
|
17
19
|
import { defaultTimes } from '../internal/default-times';
|
|
18
20
|
import { EmptyComponent } from '../internal/empty-component';
|
|
19
21
|
import { FixedLayerMenu } from '../internal/fixed-layer-menu';
|
|
@@ -23,7 +25,7 @@ import { convertTokens } from '../internal/parse-tokens';
|
|
|
23
25
|
import { placeholderDatetime } from '../internal/placeholder-date-time';
|
|
24
26
|
import { makeSingleValue } from '../internal/single-value';
|
|
25
27
|
var packageName = "@atlaskit/datetime-picker";
|
|
26
|
-
var packageVersion = "18.
|
|
28
|
+
var packageVersion = "18.4.0";
|
|
27
29
|
var defaultTimeFormat = 'h:mma';
|
|
28
30
|
var menuStyles = {
|
|
29
31
|
/* Need to remove default absolute positioning as that causes issues with position fixed */
|
|
@@ -282,8 +284,6 @@ var TimePicker = /*#__PURE__*/forwardRef(function (_ref2, _ref) {
|
|
|
282
284
|
ClearIndicator: EmptyComponent
|
|
283
285
|
});
|
|
284
286
|
var renderIconContainer = Boolean(!hideIcon && value);
|
|
285
|
-
|
|
286
|
-
// @ts-ignore -- Argument of type 'StylesConfig<OptionType, false, GroupBase<OptionType>>' is not assignable to parameter of type 'StylesConfig<OptionType, boolean, GroupBase<OptionType>>'.
|
|
287
287
|
var mergedStyles = mergeStyles(selectStyles, {
|
|
288
288
|
control: function control(base) {
|
|
289
289
|
return _objectSpread({}, base);
|
|
@@ -316,9 +316,7 @@ var TimePicker = /*#__PURE__*/forwardRef(function (_ref2, _ref) {
|
|
|
316
316
|
"aria-label": label || undefined,
|
|
317
317
|
appearance: appearance,
|
|
318
318
|
autoFocus: autoFocus,
|
|
319
|
-
clearControlLabel: clearControlLabel
|
|
320
|
-
// @ts-ignore - Type mismatch with components - workaround for help-center local consumption
|
|
321
|
-
,
|
|
319
|
+
clearControlLabel: clearControlLabel,
|
|
322
320
|
components: selectComponents,
|
|
323
321
|
inputId: id,
|
|
324
322
|
isClearable: true,
|
|
@@ -328,22 +326,17 @@ var TimePicker = /*#__PURE__*/forwardRef(function (_ref2, _ref) {
|
|
|
328
326
|
menuPlacement: "auto",
|
|
329
327
|
openMenuOnFocus: true,
|
|
330
328
|
onBlur: onBlur,
|
|
331
|
-
onCreateOption: onCreateOption
|
|
332
|
-
// @ts-ignore - Type mismatch with onChange handler - workaround for help-center local consumption
|
|
333
|
-
,
|
|
329
|
+
onCreateOption: onCreateOption,
|
|
334
330
|
onChange: onChange,
|
|
335
331
|
options: options,
|
|
336
332
|
onFocus: onFocus,
|
|
337
333
|
onMenuOpen: onMenuOpen,
|
|
338
334
|
onMenuClose: onMenuClose,
|
|
339
|
-
placeholder: placeholder || l10n.formatTime(placeholderDatetime)
|
|
340
|
-
// @ts-ignore - Type mismatch with styles config - workaround for help-center local consumption
|
|
341
|
-
,
|
|
335
|
+
placeholder: placeholder || l10n.formatTime(placeholderDatetime),
|
|
342
336
|
styles: mergedStyles,
|
|
343
337
|
value: initialValue,
|
|
344
338
|
spacing: spacing
|
|
345
339
|
// We need this to get things to work, even though it's not supported.
|
|
346
|
-
// @ts-ignore
|
|
347
340
|
,
|
|
348
341
|
fixedLayerRef: containerRef,
|
|
349
342
|
isInvalid: isInvalid,
|
|
@@ -4,7 +4,7 @@ import "./date-time-picker-container.compiled.css";
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { ax, ix } from "@compiled/react/runtime";
|
|
6
6
|
import { forwardRef } from 'react';
|
|
7
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
8
8
|
var isInvalidBorderStyles = null;
|
|
9
9
|
var isFocusedBorderStyles = null;
|
|
10
10
|
var isFocusedStyles = null;
|
|
@@ -5,7 +5,7 @@ var _excluded = ["className", "clearValue", "cx", "getStyles", "getValue", "hasV
|
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import { ax, ix } from "@compiled/react/runtime";
|
|
7
7
|
import { useRef } from 'react';
|
|
8
|
-
import { components } from '@atlaskit/select';
|
|
8
|
+
import { components } from '@atlaskit/react-select/components';
|
|
9
9
|
import { fromLegacyPlacement } from '@atlaskit/top-layer/placement-map';
|
|
10
10
|
import { Popover } from '@atlaskit/top-layer/popover';
|
|
11
11
|
import { PopoverSurface } from '@atlaskit/top-layer/popover-surface';
|
|
@@ -55,9 +55,7 @@ var FixedLayerMenuTopLayer = function FixedLayerMenuTopLayer(_ref) {
|
|
|
55
55
|
children = _ref.children,
|
|
56
56
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
57
57
|
// The select's container element is the anchor for the popup.
|
|
58
|
-
// @ts-ignore -- fixedLayerRef is a custom prop passed through selectProps
|
|
59
58
|
var triggerRef = useRef((_selectProps$fixedLay = selectProps.fixedLayerRef) !== null && _selectProps$fixedLay !== void 0 ? _selectProps$fixedLay : null);
|
|
60
|
-
// @ts-ignore -- fixedLayerRef is a custom prop passed through selectProps
|
|
61
59
|
triggerRef.current = (_selectProps$fixedLay2 = selectProps.fixedLayerRef) !== null && _selectProps$fixedLay2 !== void 0 ? _selectProps$fixedLay2 : null;
|
|
62
60
|
var popoverRef = useRef(null);
|
|
63
61
|
useAnchorPosition({
|
|
@@ -83,9 +81,7 @@ var FixedLayerMenuTopLayer = function FixedLayerMenuTopLayer(_ref) {
|
|
|
83
81
|
,
|
|
84
82
|
mode: "manual",
|
|
85
83
|
placement: popupPlacement,
|
|
86
|
-
shouldAnimate: true
|
|
87
|
-
// @ts-ignore -- testId is a custom prop passed through selectProps
|
|
88
|
-
,
|
|
84
|
+
shouldAnimate: true,
|
|
89
85
|
testId: selectProps.testId && "".concat(selectProps.testId, "--popup")
|
|
90
86
|
}, /*#__PURE__*/React.createElement(PopoverSurface, null, /*#__PURE__*/React.createElement(components.Menu, _extends({}, rest, {
|
|
91
87
|
// eslint-disable-next-line @atlaskit/design-system/no-unsafe-style-overrides, @atlaskit/ui-styling-standard/no-classname-prop
|
|
@@ -4,7 +4,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
|
|
|
4
4
|
var _excluded = ["className", "clearValue", "cx", "getStyles", "getValue", "hasValue", "innerProps", "innerRef", "isLoading", "isMulti", "isRtl", "maxMenuHeight", "menuPlacement", "menuPosition", "menuShouldScrollIntoView", "minMenuHeight", "options", "placement", "selectOption", "selectProps", "setValue", "children"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import { ax, ix } from "@compiled/react/runtime";
|
|
7
|
-
import { components } from '@atlaskit/select';
|
|
7
|
+
import { components } from '@atlaskit/react-select/components';
|
|
8
8
|
import FixedLayer from '../internal/fixed-layer';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -35,9 +35,7 @@ var FixedLayerMenu = function FixedLayerMenu(_ref) {
|
|
|
35
35
|
children = _ref.children,
|
|
36
36
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
37
37
|
return /*#__PURE__*/React.createElement(FixedLayer, {
|
|
38
|
-
inputValue: selectProps.inputValue
|
|
39
|
-
//@ts-ignore react-select unsupported props
|
|
40
|
-
,
|
|
38
|
+
inputValue: selectProps.inputValue,
|
|
41
39
|
containerRef: selectProps.fixedLayerRef,
|
|
42
40
|
content: /*#__PURE__*/React.createElement(components.Menu, _extends({}, rest, {
|
|
43
41
|
// eslint-disable-next-line @atlaskit/design-system/no-unsafe-style-overrides, @atlaskit/ui-styling-standard/no-classname-prop
|
|
@@ -62,9 +60,7 @@ var FixedLayerMenu = function FixedLayerMenu(_ref) {
|
|
|
62
60
|
selectOption: selectOption,
|
|
63
61
|
selectProps: selectProps,
|
|
64
62
|
setValue: setValue
|
|
65
|
-
}), children)
|
|
66
|
-
//@ts-ignore react-select unsupported props
|
|
67
|
-
,
|
|
63
|
+
}), children),
|
|
68
64
|
testId: selectProps.testId
|
|
69
65
|
});
|
|
70
66
|
};
|
|
@@ -11,8 +11,10 @@ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstruct
|
|
|
11
11
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
12
12
|
import React from 'react';
|
|
13
13
|
import noop from '@atlaskit/ds-lib/noop';
|
|
14
|
-
import { sizes } from '@atlaskit/icon';
|
|
15
|
-
import { Manager
|
|
14
|
+
import { sizes } from '@atlaskit/icon/constants/default';
|
|
15
|
+
import { Manager } from '@atlaskit/popper/manager';
|
|
16
|
+
import { Popper } from '@atlaskit/popper/main';
|
|
17
|
+
import { Reference } from '@atlaskit/popper/reference';
|
|
16
18
|
var styles = {
|
|
17
19
|
root: "_bfhk1j28 _kqswstnw _152tze3t",
|
|
18
20
|
popperStyles: "_1pbyowjs"
|
|
@@ -4,7 +4,7 @@ var _excluded = ["showClearIndicator"];
|
|
|
4
4
|
import "./indicators-container.compiled.css";
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import { ax, ix } from "@compiled/react/runtime";
|
|
7
|
-
import { components } from '@atlaskit/select';
|
|
7
|
+
import { components } from '@atlaskit/react-select/components';
|
|
8
8
|
var styles = {
|
|
9
9
|
calendarButtonInclusionStyles: "_ahbqxy5q",
|
|
10
10
|
calendarButtonOnlyInclusionStyles: "_ahbq1ejb"
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
._2rko1mok{border-radius:var(--ds-radius-large,8px)}._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
|
|
2
|
+
._1bsb1ris{width:max-content}
|
|
3
|
+
._1pfhu2gc{margin-block-start:var(--ds-space-100,8px)}
|
|
4
|
+
._6rthu2gc{margin-block-end:var(--ds-space-100,8px)}
|
|
5
|
+
._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
|
|
@@ -1,23 +1,11 @@
|
|
|
1
1
|
/* menu-top-layer.tsx generated by @compiled/babel-plugin v2.0.0 */
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
+
import "./menu-top-layer.compiled.css";
|
|
3
4
|
import * as React from 'react';
|
|
4
5
|
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
-
import { Fragment
|
|
6
|
+
import { Fragment } from 'react';
|
|
6
7
|
import { isValid, parseISO } from 'date-fns';
|
|
7
|
-
import Calendar from '@atlaskit/calendar';
|
|
8
|
-
import { fromLegacyPlacement } from '@atlaskit/top-layer/placement-map';
|
|
9
|
-
import { Popover } from '@atlaskit/top-layer/popover';
|
|
10
|
-
import { PopoverSurface } from '@atlaskit/top-layer/popover-surface';
|
|
11
|
-
import { useAnchorPosition } from '@atlaskit/top-layer/use-anchor-position';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Bottom-start placement: calendar appears below and aligned to the
|
|
15
|
-
* start edge of the trigger (the select input).
|
|
16
|
-
*/
|
|
17
|
-
var popupPlacement = fromLegacyPlacement({
|
|
18
|
-
legacy: 'bottom-start'
|
|
19
|
-
});
|
|
20
|
-
|
|
8
|
+
import Calendar from '@atlaskit/calendar/calendar';
|
|
21
9
|
/**
|
|
22
10
|
* @param isos A series of ISO dates.
|
|
23
11
|
* @returns The last valid date within the array of ISO strings.
|
|
@@ -32,19 +20,19 @@ function getValidDate(isos) {
|
|
|
32
20
|
} : acc;
|
|
33
21
|
}, {});
|
|
34
22
|
}
|
|
23
|
+
var styles = {
|
|
24
|
+
root: "_2rko1mok _1bsb1ris _bfhk1bhr _16qs130s _1pfhu2gc _6rthu2gc"
|
|
25
|
+
};
|
|
35
26
|
|
|
36
27
|
/**
|
|
37
28
|
* Top-layer version of the date picker menu.
|
|
38
29
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* CSS Anchor Positioning. This avoids overflow clipping, z-index wars,
|
|
42
|
-
* and portal-based layering.
|
|
30
|
+
* The surrounding react-select menu portal owns the native popover and
|
|
31
|
+
* positioning. This component only supplies the calendar dialog content.
|
|
43
32
|
*
|
|
44
33
|
* Gated behind the `platform-dst-top-layer` feature flag.
|
|
45
34
|
*/
|
|
46
35
|
export var MenuTopLayer = function MenuTopLayer(_ref) {
|
|
47
|
-
var _selectProps$calendar, _selectProps$calendar2;
|
|
48
36
|
var selectProps = _ref.selectProps,
|
|
49
37
|
innerProps = _ref.innerProps;
|
|
50
38
|
var calendarValue = selectProps.calendarValue,
|
|
@@ -54,20 +42,6 @@ export var MenuTopLayer = function MenuTopLayer(_ref) {
|
|
|
54
42
|
day = _getValidDate.day,
|
|
55
43
|
month = _getValidDate.month,
|
|
56
44
|
year = _getValidDate.year;
|
|
57
|
-
|
|
58
|
-
// The select's container element is the anchor for the popup.
|
|
59
|
-
var triggerRef = useRef((_selectProps$calendar = selectProps.calendarContainerRef) !== null && _selectProps$calendar !== void 0 ? _selectProps$calendar : null);
|
|
60
|
-
triggerRef.current = (_selectProps$calendar2 = selectProps.calendarContainerRef) !== null && _selectProps$calendar2 !== void 0 ? _selectProps$calendar2 : null;
|
|
61
|
-
var popoverRef = useRef(null);
|
|
62
|
-
useAnchorPosition({
|
|
63
|
-
anchorRef: triggerRef,
|
|
64
|
-
popoverRef: popoverRef,
|
|
65
|
-
placement: popupPlacement,
|
|
66
|
-
// The Popover is rendered with `isOpen` always true while this
|
|
67
|
-
// component is mounted (react-select conditionally mounts/unmounts
|
|
68
|
-
// the menu), so positioning is always active.
|
|
69
|
-
isOpen: true
|
|
70
|
-
});
|
|
71
45
|
var onMenuMouseDown = function onMenuMouseDown(event) {
|
|
72
46
|
if (event.button !== 0) {
|
|
73
47
|
return;
|
|
@@ -76,25 +50,10 @@ export var MenuTopLayer = function MenuTopLayer(_ref) {
|
|
|
76
50
|
event.preventDefault();
|
|
77
51
|
};
|
|
78
52
|
var Wrapper = typeof MenuInnerWrapper === 'function' ? MenuInnerWrapper : Fragment;
|
|
79
|
-
return /*#__PURE__*/React.createElement(
|
|
80
|
-
|
|
81
|
-
role: "dialog",
|
|
82
|
-
label: "calendar",
|
|
83
|
-
isOpen: true
|
|
84
|
-
// `mode="manual"` opts out of native popover light-dismiss.
|
|
85
|
-
// react-select / DateTimePicker already own outside-click and
|
|
86
|
-
// Esc handling. Without this, the same click that opens the
|
|
87
|
-
// menu (which targets the select input outside the popover)
|
|
88
|
-
// also bubbles to the browser's auto-dismiss handler and
|
|
89
|
-
// immediately closes the popover.
|
|
90
|
-
,
|
|
91
|
-
mode: "manual",
|
|
92
|
-
placement: popupPlacement,
|
|
93
|
-
shouldAnimate: true,
|
|
94
|
-
testId: selectProps.testId && "".concat(selectProps.testId, "--popup")
|
|
95
|
-
}, /*#__PURE__*/React.createElement(PopoverSurface, null, /*#__PURE__*/React.createElement("div", _extends({}, innerProps, {
|
|
53
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, innerProps, {
|
|
54
|
+
onMouseDown: onMenuMouseDown,
|
|
96
55
|
role: "presentation",
|
|
97
|
-
|
|
56
|
+
className: ax([styles.root])
|
|
98
57
|
}), /*#__PURE__*/React.createElement(Wrapper, null, /*#__PURE__*/React.createElement(Calendar, {
|
|
99
58
|
day: day,
|
|
100
59
|
month: month,
|
|
@@ -113,5 +72,5 @@ export var MenuTopLayer = function MenuTopLayer(_ref) {
|
|
|
113
72
|
locale: selectProps.calendarLocale,
|
|
114
73
|
testId: selectProps.testId && "".concat(selectProps.testId, "--calendar"),
|
|
115
74
|
weekStartDay: selectProps.calendarWeekStartDay
|
|
116
|
-
})))
|
|
75
|
+
})));
|
|
117
76
|
};
|
|
@@ -7,9 +7,9 @@ import { Fragment } from 'react';
|
|
|
7
7
|
|
|
8
8
|
// oxlint-disable-next-line @atlassian/no-restricted-imports
|
|
9
9
|
import { isValid, parseISO } from 'date-fns';
|
|
10
|
-
import Calendar from '@atlaskit/calendar';
|
|
10
|
+
import Calendar from '@atlaskit/calendar/calendar';
|
|
11
11
|
import { Layering } from '@atlaskit/layering/layering';
|
|
12
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
13
13
|
import FixedLayer from '../internal/fixed-layer';
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -2,14 +2,14 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
var _excluded = ["children", "className", "clearValue", "cx", "data", "getStyles", "getValue", "hasValue", "isDisabled", "isMulti", "isRtl", "options", "selectOption", "selectProps", "setValue"];
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import { components } from '@atlaskit/select';
|
|
6
|
-
|
|
5
|
+
import { components } from '@atlaskit/react-select/components';
|
|
7
6
|
/**
|
|
8
7
|
* This creates a functional component that `react-select` will use to make the
|
|
9
8
|
* SingleValue part of the different pickers.
|
|
10
9
|
*/
|
|
11
10
|
export var makeSingleValue =
|
|
12
11
|
// TODO: Make ID required
|
|
12
|
+
|
|
13
13
|
function makeSingleValue(_ref) {
|
|
14
14
|
var id = _ref.id,
|
|
15
15
|
lang = _ref.lang;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { DropdownIndicatorProps, OptionType } from '@atlaskit/select/types';
|
|
2
2
|
import { type DatePickerBaseProps, type DateTimePickerSelectProps } from '../types';
|
|
3
3
|
export type DatePickerProps = DatePickerBaseProps & {
|
|
4
4
|
icon?: React.ComponentType<DropdownIndicatorProps<OptionType>>;
|