@atlaskit/datetime-picker 17.7.0 → 17.8.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 +107 -0
- package/date-picker/package.json +17 -0
- package/date-time-picker/package.json +17 -0
- package/dist/cjs/components/date-picker.js +31 -27
- package/dist/cjs/components/date-time-picker-class.js +9 -9
- package/dist/cjs/components/date-time-picker-fc.js +5 -8
- package/dist/cjs/components/time-picker.js +14 -9
- package/dist/cjs/entry-points/date-picker.js +13 -0
- package/dist/cjs/entry-points/date-time-picker.js +13 -0
- package/dist/cjs/entry-points/time-picker.js +13 -0
- package/dist/cjs/entry-points/types.js +1 -0
- package/dist/cjs/internal/default-date-format.js +7 -0
- package/dist/cjs/internal/default-times.js +7 -0
- package/dist/cjs/internal/empty-component.js +12 -0
- package/dist/cjs/internal/fixed-layer-menu-top-layer.js +113 -0
- package/dist/cjs/internal/format-date-time-zone-into-iso.js +15 -0
- package/dist/cjs/internal/format-date.js +2 -2
- package/dist/cjs/internal/get-parsed-iso.js +3 -3
- package/dist/cjs/internal/get-placeholder.js +2 -2
- package/dist/cjs/internal/menu-top-layer.js +116 -0
- package/dist/cjs/internal/pad-two.js +9 -0
- package/dist/cjs/internal/parse-date.js +2 -2
- package/dist/cjs/internal/placeholder-date-time.js +9 -0
- package/dist/es2019/components/date-picker.js +29 -25
- package/dist/es2019/components/date-time-picker-class.js +6 -6
- package/dist/es2019/components/date-time-picker-fc.js +2 -5
- package/dist/es2019/components/time-picker.js +8 -3
- package/dist/es2019/entry-points/date-picker.js +1 -0
- package/dist/es2019/entry-points/date-time-picker.js +1 -0
- package/dist/es2019/entry-points/time-picker.js +1 -0
- package/dist/es2019/entry-points/types.js +0 -0
- package/dist/es2019/internal/default-date-format.js +1 -0
- package/dist/es2019/internal/default-times.js +1 -0
- package/dist/es2019/internal/empty-component.js +4 -0
- package/dist/es2019/internal/fixed-layer-menu-top-layer.js +103 -0
- package/dist/es2019/internal/format-date-time-zone-into-iso.js +9 -0
- package/dist/es2019/internal/format-date.js +1 -1
- package/dist/es2019/internal/get-parsed-iso.js +1 -1
- package/dist/es2019/internal/get-placeholder.js +1 -1
- package/dist/es2019/internal/menu-top-layer.js +111 -0
- package/dist/es2019/internal/pad-two.js +3 -0
- package/dist/es2019/internal/parse-date.js +1 -1
- package/dist/es2019/internal/placeholder-date-time.js +3 -0
- package/dist/esm/components/date-picker.js +29 -25
- package/dist/esm/components/date-time-picker-class.js +6 -6
- package/dist/esm/components/date-time-picker-fc.js +2 -5
- package/dist/esm/components/time-picker.js +8 -3
- package/dist/esm/entry-points/date-picker.js +1 -0
- package/dist/esm/entry-points/date-time-picker.js +1 -0
- package/dist/esm/entry-points/time-picker.js +1 -0
- package/dist/esm/entry-points/types.js +0 -0
- package/dist/esm/internal/default-date-format.js +1 -0
- package/dist/esm/internal/default-times.js +1 -0
- package/dist/esm/internal/empty-component.js +6 -0
- package/dist/esm/internal/fixed-layer-menu-top-layer.js +105 -0
- package/dist/esm/internal/format-date-time-zone-into-iso.js +9 -0
- package/dist/esm/internal/format-date.js +1 -1
- package/dist/esm/internal/get-parsed-iso.js +1 -1
- package/dist/esm/internal/get-placeholder.js +1 -1
- package/dist/esm/internal/menu-top-layer.js +107 -0
- package/dist/esm/internal/pad-two.js +3 -0
- package/dist/esm/internal/parse-date.js +1 -1
- package/dist/esm/internal/placeholder-date-time.js +3 -0
- package/dist/types/components/date-time-picker-class.d.ts +0 -2
- package/dist/types/components/date-time-picker-fc.d.ts +0 -2
- package/dist/types/entry-points/date-picker.d.ts +2 -0
- package/dist/types/entry-points/date-time-picker.d.ts +1 -0
- package/dist/types/entry-points/time-picker.d.ts +1 -0
- package/dist/types/entry-points/types.d.ts +1 -0
- package/dist/types/internal/default-date-format.d.ts +1 -0
- package/dist/types/internal/default-times.d.ts +1 -0
- package/dist/types/internal/empty-component.d.ts +4 -0
- package/dist/types/internal/fixed-layer-menu-top-layer.d.ts +12 -0
- package/dist/types/internal/format-date-time-zone-into-iso.d.ts +4 -0
- package/dist/types/internal/menu-top-layer.d.ts +16 -0
- package/dist/types/internal/pad-two.d.ts +1 -0
- package/dist/types/internal/placeholder-date-time.d.ts +1 -0
- package/dist/types-ts4.5/components/date-time-picker-class.d.ts +0 -2
- package/dist/types-ts4.5/components/date-time-picker-fc.d.ts +0 -2
- package/dist/types-ts4.5/entry-points/date-picker.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/date-time-picker.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/time-picker.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/types.d.ts +1 -0
- package/dist/types-ts4.5/internal/default-date-format.d.ts +1 -0
- package/dist/types-ts4.5/internal/default-times.d.ts +1 -0
- package/dist/types-ts4.5/internal/empty-component.d.ts +4 -0
- package/dist/types-ts4.5/internal/fixed-layer-menu-top-layer.d.ts +12 -0
- package/dist/types-ts4.5/internal/format-date-time-zone-into-iso.d.ts +4 -0
- package/dist/types-ts4.5/internal/menu-top-layer.d.ts +16 -0
- package/dist/types-ts4.5/internal/pad-two.d.ts +1 -0
- package/dist/types-ts4.5/internal/placeholder-date-time.d.ts +1 -0
- package/package.json +12 -8
- package/time-picker/package.json +17 -0
- package/types/package.json +5 -5
- package/dist/cjs/internal/index.js +0 -31
- package/dist/es2019/internal/index.js +0 -20
- package/dist/esm/internal/index.js +0 -22
- package/dist/types/internal/index.d.ts +0 -10
- package/dist/types-ts4.5/internal/index.d.ts +0 -10
- package/offerings.json +0 -98
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/* fixed-layer-menu-top-layer.tsx generated by @compiled/babel-plugin v0.39.1 */
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.FixedLayerMenuTopLayer = void 0;
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var React = _react;
|
|
12
|
+
var _runtime = require("@compiled/react/runtime");
|
|
13
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
14
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
15
|
+
var _select = require("@atlaskit/select");
|
|
16
|
+
var _animations = require("@atlaskit/top-layer/animations");
|
|
17
|
+
var _placementMap = require("@atlaskit/top-layer/placement-map");
|
|
18
|
+
var _popup = require("@atlaskit/top-layer/popup");
|
|
19
|
+
var _excluded = ["className", "clearValue", "cx", "getStyles", "getValue", "hasValue", "innerProps", "innerRef", "isLoading", "isMulti", "isRtl", "maxMenuHeight", "menuPlacement", "menuPosition", "menuShouldScrollIntoView", "minMenuHeight", "options", "placement", "selectOption", "selectProps", "setValue", "children"];
|
|
20
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
21
|
+
var animation = (0, _animations.slideAndFade)();
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Bottom-start placement: time options menu appears below and aligned to the
|
|
25
|
+
* start edge of the trigger (the select input).
|
|
26
|
+
*/
|
|
27
|
+
var popupPlacement = (0, _placementMap.fromLegacyPlacement)({
|
|
28
|
+
legacy: 'bottom-start'
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Top-layer version of the fixed layer menu used in the time picker.
|
|
33
|
+
*
|
|
34
|
+
* Uses `@atlaskit/top-layer/popup` (Popup.Content + Popup.Surface) so the
|
|
35
|
+
* time options list renders in the browser's top layer via the native Popover API
|
|
36
|
+
* and is positioned via CSS Anchor Positioning. This avoids overflow clipping,
|
|
37
|
+
* z-index wars, and portal-based layering.
|
|
38
|
+
*
|
|
39
|
+
* Gated behind the `platform-dst-top-layer` feature flag.
|
|
40
|
+
*/
|
|
41
|
+
var FixedLayerMenuTopLayer = exports.FixedLayerMenuTopLayer = function FixedLayerMenuTopLayer(_ref) {
|
|
42
|
+
var _selectProps$fixedLay, _selectProps$fixedLay2;
|
|
43
|
+
var className = _ref.className,
|
|
44
|
+
clearValue = _ref.clearValue,
|
|
45
|
+
cx = _ref.cx,
|
|
46
|
+
getStyles = _ref.getStyles,
|
|
47
|
+
getValue = _ref.getValue,
|
|
48
|
+
hasValue = _ref.hasValue,
|
|
49
|
+
innerProps = _ref.innerProps,
|
|
50
|
+
innerRef = _ref.innerRef,
|
|
51
|
+
isLoading = _ref.isLoading,
|
|
52
|
+
isMulti = _ref.isMulti,
|
|
53
|
+
isRtl = _ref.isRtl,
|
|
54
|
+
maxMenuHeight = _ref.maxMenuHeight,
|
|
55
|
+
menuPlacement = _ref.menuPlacement,
|
|
56
|
+
menuPosition = _ref.menuPosition,
|
|
57
|
+
menuShouldScrollIntoView = _ref.menuShouldScrollIntoView,
|
|
58
|
+
minMenuHeight = _ref.minMenuHeight,
|
|
59
|
+
options = _ref.options,
|
|
60
|
+
placement = _ref.placement,
|
|
61
|
+
selectOption = _ref.selectOption,
|
|
62
|
+
selectProps = _ref.selectProps,
|
|
63
|
+
setValue = _ref.setValue,
|
|
64
|
+
children = _ref.children,
|
|
65
|
+
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
66
|
+
// The select's container element is the anchor for the popup.
|
|
67
|
+
// @ts-ignore -- fixedLayerRef is a custom prop passed through selectProps
|
|
68
|
+
var triggerRef = (0, _react.useRef)((_selectProps$fixedLay = selectProps.fixedLayerRef) !== null && _selectProps$fixedLay !== void 0 ? _selectProps$fixedLay : null);
|
|
69
|
+
// @ts-ignore -- fixedLayerRef is a custom prop passed through selectProps
|
|
70
|
+
triggerRef.current = (_selectProps$fixedLay2 = selectProps.fixedLayerRef) !== null && _selectProps$fixedLay2 !== void 0 ? _selectProps$fixedLay2 : null;
|
|
71
|
+
return /*#__PURE__*/React.createElement(_popup.Popup.Content, {
|
|
72
|
+
role: "listbox",
|
|
73
|
+
isOpen: true
|
|
74
|
+
// `mode="manual"` opts out of the native popover light-dismiss
|
|
75
|
+
// (Esc / click-outside). react-select already owns those: opening
|
|
76
|
+
// the menu via a click on the input that lives outside the popover
|
|
77
|
+
// element triggers the browser's auto-dismiss as that very click
|
|
78
|
+
// bubbles, slamming the menu shut before the user sees it. With
|
|
79
|
+
// `manual`, react-select's existing onMenuClose / outside-click
|
|
80
|
+
// logic remains the single source of truth.
|
|
81
|
+
,
|
|
82
|
+
mode: "manual",
|
|
83
|
+
placement: popupPlacement,
|
|
84
|
+
triggerRef: triggerRef,
|
|
85
|
+
animate: animation
|
|
86
|
+
// @ts-ignore -- testId is a custom prop passed through selectProps
|
|
87
|
+
,
|
|
88
|
+
testId: selectProps.testId && "".concat(selectProps.testId, "--popup")
|
|
89
|
+
}, /*#__PURE__*/React.createElement(_popup.Popup.Surface, null, /*#__PURE__*/React.createElement(_select.components.Menu, (0, _extends2.default)({}, rest, {
|
|
90
|
+
// eslint-disable-next-line @atlaskit/design-system/no-unsafe-style-overrides, @atlaskit/ui-styling-standard/no-classname-prop
|
|
91
|
+
className: className,
|
|
92
|
+
clearValue: clearValue,
|
|
93
|
+
cx: cx,
|
|
94
|
+
getStyles: getStyles,
|
|
95
|
+
getValue: getValue,
|
|
96
|
+
hasValue: hasValue,
|
|
97
|
+
innerProps: innerProps,
|
|
98
|
+
innerRef: innerRef,
|
|
99
|
+
isLoading: isLoading,
|
|
100
|
+
isMulti: isMulti,
|
|
101
|
+
isRtl: isRtl,
|
|
102
|
+
maxMenuHeight: maxMenuHeight,
|
|
103
|
+
menuPlacement: menuPlacement,
|
|
104
|
+
menuPosition: menuPosition,
|
|
105
|
+
menuShouldScrollIntoView: false || menuShouldScrollIntoView,
|
|
106
|
+
minMenuHeight: minMenuHeight,
|
|
107
|
+
options: options,
|
|
108
|
+
placement: placement,
|
|
109
|
+
selectOption: selectOption,
|
|
110
|
+
selectProps: selectProps,
|
|
111
|
+
setValue: setValue
|
|
112
|
+
}), children)));
|
|
113
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.formatDateTimeZoneIntoIso = formatDateTimeZoneIntoIso;
|
|
7
|
+
/**
|
|
8
|
+
* Formats a date, time, and zone into a ISO string.
|
|
9
|
+
*/
|
|
10
|
+
function formatDateTimeZoneIntoIso(date, time, zone) {
|
|
11
|
+
// 12:00 => 12:00, 1:00 => 01:00
|
|
12
|
+
var needsLeadingZero = /^\d:/;
|
|
13
|
+
var sanitizedTime = needsLeadingZero.test(time) ? "0".concat(time) : time;
|
|
14
|
+
return "".concat(date, "T").concat(sanitizedTime).concat(zone);
|
|
15
|
+
}
|
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.formatDate = void 0;
|
|
7
7
|
var _dateFns = require("date-fns");
|
|
8
|
+
var _defaultDateFormat = require("./default-date-format");
|
|
8
9
|
var _parseTokens = require("./parse-tokens");
|
|
9
|
-
var _index = require("./index");
|
|
10
10
|
/**
|
|
11
11
|
* Everything in this file is to smooth out the migration of the new date picker
|
|
12
12
|
* (https://product-fabric.atlassian.net/browse/DSP-20682). When that ticket is
|
|
@@ -32,7 +32,7 @@ var formatDate = exports.formatDate = function formatDate(value, di) {
|
|
|
32
32
|
dateFormat = di.dateFormat,
|
|
33
33
|
l10n = di.l10n;
|
|
34
34
|
if (formatDisplayLabel) {
|
|
35
|
-
return formatDisplayLabel(value, dateFormat ||
|
|
35
|
+
return formatDisplayLabel(value, dateFormat || _defaultDateFormat.defaultDateFormat);
|
|
36
36
|
}
|
|
37
37
|
var date = (0, _dateFns.parseISO)(value);
|
|
38
38
|
return dateFormat ? (0, _dateFns.format)(date, (0, _parseTokens.convertTokens)(dateFormat)) : l10n.formatDate(date);
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.getParsedISO = void 0;
|
|
8
8
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
9
|
var _dateFns = require("date-fns");
|
|
10
|
-
var
|
|
10
|
+
var _padTwo = require("./pad-two");
|
|
11
11
|
/**
|
|
12
12
|
* Everything in this file is to smooth out the migration of the new date picker
|
|
13
13
|
* (https://product-fabric.atlassian.net/browse/DSP-20682). When that ticket is
|
|
@@ -42,9 +42,9 @@ var getParsedISO = exports.getParsedISO = function getParsedISO(di) {
|
|
|
42
42
|
var lastDayInMonth = (0, _dateFns.lastDayOfMonth)(new Date(parsedYear, parsedMonth - 1) // This needs to be -1, because the Date constructor expects an index of the given month
|
|
43
43
|
).getDate();
|
|
44
44
|
if (lastDayInMonth < parsedDate) {
|
|
45
|
-
newIso = "".concat(parsedYear, "-").concat((0,
|
|
45
|
+
newIso = "".concat(parsedYear, "-").concat((0, _padTwo.padToTwo)(parsedMonth), "-").concat((0, _padTwo.padToTwo)(lastDayInMonth));
|
|
46
46
|
} else {
|
|
47
|
-
newIso = "".concat(parsedYear, "-").concat((0,
|
|
47
|
+
newIso = "".concat(parsedYear, "-").concat((0, _padTwo.padToTwo)(parsedMonth), "-").concat((0, _padTwo.padToTwo)(parsedDate));
|
|
48
48
|
}
|
|
49
49
|
return newIso;
|
|
50
50
|
};
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getPlaceholder = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _placeholderDateTime = require("./placeholder-date-time");
|
|
8
8
|
/**
|
|
9
9
|
* Everything in this file is to smooth out the migration of the new date picker
|
|
10
10
|
* (https://product-fabric.atlassian.net/browse/DSP-20682). When that ticket is
|
|
@@ -28,5 +28,5 @@ var _index = require("./index");
|
|
|
28
28
|
var getPlaceholder = exports.getPlaceholder = function getPlaceholder(di) {
|
|
29
29
|
var placeholder = di.placeholder,
|
|
30
30
|
l10n = di.l10n;
|
|
31
|
-
return placeholder || l10n.formatDate(
|
|
31
|
+
return placeholder || l10n.formatDate(_placeholderDateTime.placeholderDatetime);
|
|
32
32
|
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/* menu-top-layer.tsx generated by @compiled/babel-plugin v0.39.1 */
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.MenuTopLayer = void 0;
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var React = _react;
|
|
12
|
+
var _runtime = require("@compiled/react/runtime");
|
|
13
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
14
|
+
var _dateFns = require("date-fns");
|
|
15
|
+
var _calendar = _interopRequireDefault(require("@atlaskit/calendar"));
|
|
16
|
+
var _animations = require("@atlaskit/top-layer/animations");
|
|
17
|
+
var _placementMap = require("@atlaskit/top-layer/placement-map");
|
|
18
|
+
var _popup = require("@atlaskit/top-layer/popup");
|
|
19
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
20
|
+
var animation = (0, _animations.slideAndFade)();
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Bottom-start placement: calendar appears below and aligned to the
|
|
24
|
+
* start edge of the trigger (the select input).
|
|
25
|
+
*/
|
|
26
|
+
var popupPlacement = (0, _placementMap.fromLegacyPlacement)({
|
|
27
|
+
legacy: 'bottom-start'
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @param isos A series of ISO dates.
|
|
32
|
+
* @returns The last valid date within the array of ISO strings.
|
|
33
|
+
*/
|
|
34
|
+
function getValidDate(isos) {
|
|
35
|
+
return isos.reduce(function (acc, iso) {
|
|
36
|
+
var date = (0, _dateFns.parseISO)(iso);
|
|
37
|
+
return (0, _dateFns.isValid)(date) ? {
|
|
38
|
+
day: date.getDate(),
|
|
39
|
+
month: date.getMonth() + 1,
|
|
40
|
+
year: date.getFullYear()
|
|
41
|
+
} : acc;
|
|
42
|
+
}, {});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Top-layer version of the date picker menu.
|
|
47
|
+
*
|
|
48
|
+
* Uses `@atlaskit/top-layer/popup` (Popup.Content + Popup.Surface) so the
|
|
49
|
+
* calendar renders in the browser's top layer via the native Popover API
|
|
50
|
+
* and is positioned via CSS Anchor Positioning. This avoids overflow clipping,
|
|
51
|
+
* z-index wars, and portal-based layering.
|
|
52
|
+
*
|
|
53
|
+
* Gated behind the `platform-dst-top-layer` feature flag.
|
|
54
|
+
*/
|
|
55
|
+
var MenuTopLayer = exports.MenuTopLayer = function MenuTopLayer(_ref) {
|
|
56
|
+
var _selectProps$calendar, _selectProps$calendar2;
|
|
57
|
+
var selectProps = _ref.selectProps,
|
|
58
|
+
innerProps = _ref.innerProps;
|
|
59
|
+
var calendarValue = selectProps.calendarValue,
|
|
60
|
+
calendarView = selectProps.calendarView,
|
|
61
|
+
MenuInnerWrapper = selectProps.menuInnerWrapper;
|
|
62
|
+
var _getValidDate = getValidDate([calendarValue, calendarView]),
|
|
63
|
+
day = _getValidDate.day,
|
|
64
|
+
month = _getValidDate.month,
|
|
65
|
+
year = _getValidDate.year;
|
|
66
|
+
|
|
67
|
+
// The select's container element is the anchor for the popup.
|
|
68
|
+
var triggerRef = (0, _react.useRef)((_selectProps$calendar = selectProps.calendarContainerRef) !== null && _selectProps$calendar !== void 0 ? _selectProps$calendar : null);
|
|
69
|
+
triggerRef.current = (_selectProps$calendar2 = selectProps.calendarContainerRef) !== null && _selectProps$calendar2 !== void 0 ? _selectProps$calendar2 : null;
|
|
70
|
+
var onMenuMouseDown = function onMenuMouseDown(event) {
|
|
71
|
+
if (event.button !== 0) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
event.stopPropagation();
|
|
75
|
+
event.preventDefault();
|
|
76
|
+
};
|
|
77
|
+
var Wrapper = typeof MenuInnerWrapper === 'function' ? MenuInnerWrapper : _react.Fragment;
|
|
78
|
+
return /*#__PURE__*/React.createElement(_popup.Popup.Content, {
|
|
79
|
+
role: "dialog",
|
|
80
|
+
label: "calendar",
|
|
81
|
+
isOpen: true
|
|
82
|
+
// `mode="manual"` opts out of native popover light-dismiss.
|
|
83
|
+
// react-select / DateTimePicker already own outside-click and
|
|
84
|
+
// Esc handling. Without this, the same click that opens the
|
|
85
|
+
// menu (which targets the select input outside the popover)
|
|
86
|
+
// also bubbles to the browser's auto-dismiss handler and
|
|
87
|
+
// immediately closes the popover.
|
|
88
|
+
,
|
|
89
|
+
mode: "manual",
|
|
90
|
+
placement: popupPlacement,
|
|
91
|
+
triggerRef: triggerRef,
|
|
92
|
+
animate: animation,
|
|
93
|
+
testId: selectProps.testId && "".concat(selectProps.testId, "--popup")
|
|
94
|
+
}, /*#__PURE__*/React.createElement(_popup.Popup.Surface, null, /*#__PURE__*/React.createElement("div", (0, _extends2.default)({}, innerProps, {
|
|
95
|
+
role: "presentation",
|
|
96
|
+
onMouseDown: onMenuMouseDown
|
|
97
|
+
}), /*#__PURE__*/React.createElement(Wrapper, null, /*#__PURE__*/React.createElement(_calendar.default, {
|
|
98
|
+
day: day,
|
|
99
|
+
month: month,
|
|
100
|
+
year: year,
|
|
101
|
+
disabled: selectProps.calendarDisabled,
|
|
102
|
+
disabledDateFilter: selectProps.calendarDisabledDateFilter,
|
|
103
|
+
minDate: selectProps.calendarMinDate,
|
|
104
|
+
maxDate: selectProps.calendarMaxDate,
|
|
105
|
+
nextMonthLabel: selectProps.nextMonthLabel,
|
|
106
|
+
onChange: selectProps.onCalendarChange,
|
|
107
|
+
onSelect: selectProps.onCalendarSelect,
|
|
108
|
+
previousMonthLabel: selectProps.previousMonthLabel,
|
|
109
|
+
ref: selectProps.calendarRef,
|
|
110
|
+
selected: [selectProps.calendarValue],
|
|
111
|
+
shouldSetFocusOnCurrentDay: selectProps.shouldSetFocusOnCurrentDay,
|
|
112
|
+
locale: selectProps.calendarLocale,
|
|
113
|
+
testId: selectProps.testId && "".concat(selectProps.testId, "--calendar"),
|
|
114
|
+
weekStartDay: selectProps.calendarWeekStartDay
|
|
115
|
+
})))));
|
|
116
|
+
};
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.parseDate = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _defaultDateFormat = require("./default-date-format");
|
|
8
8
|
/**
|
|
9
9
|
* Everything in this file is to smooth out the migration of the new date picker
|
|
10
10
|
* (https://product-fabric.atlassian.net/browse/DSP-20682). When that ticket is
|
|
@@ -34,7 +34,7 @@ var parseDate = exports.parseDate = function parseDate(date, di) {
|
|
|
34
34
|
dateFormat = di.dateFormat,
|
|
35
35
|
l10n = di.l10n;
|
|
36
36
|
if (parseInputValue) {
|
|
37
|
-
return parseInputValue(date, dateFormat ||
|
|
37
|
+
return parseInputValue(date, dateFormat || _defaultDateFormat.defaultDateFormat);
|
|
38
38
|
}
|
|
39
39
|
return l10n.parseDate(date);
|
|
40
40
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.placeholderDatetime = void 0;
|
|
7
|
+
// This date was chosen to clearly show date and time formats (day > 12)
|
|
8
|
+
// e.g. 18/02/1993 vs. 2/18/1993 and 1:00 PM vs 13:00
|
|
9
|
+
var placeholderDatetime = exports.placeholderDatetime = new Date(1993, 1, 18, 13);
|
|
@@ -15,9 +15,10 @@ import { cx } from '@atlaskit/css';
|
|
|
15
15
|
import { useId } from '@atlaskit/ds-lib/use-id';
|
|
16
16
|
import CalendarIcon from '@atlaskit/icon/core/calendar';
|
|
17
17
|
import { createLocalizationProvider } from '@atlaskit/locale';
|
|
18
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
18
19
|
import { Box } from '@atlaskit/primitives/compiled';
|
|
19
20
|
import Select, { mergeStyles } from '@atlaskit/select';
|
|
20
|
-
import { EmptyComponent } from '../internal';
|
|
21
|
+
import { EmptyComponent } from '../internal/empty-component';
|
|
21
22
|
import { formatDate } from '../internal/format-date';
|
|
22
23
|
import { getParsedISO } from '../internal/get-parsed-iso';
|
|
23
24
|
import { getPlaceholder } from '../internal/get-placeholder';
|
|
@@ -26,10 +27,11 @@ import { getShortISOString } from '../internal/get-short-iso-string';
|
|
|
26
27
|
import { IndicatorsContainer } from '../internal/indicators-container';
|
|
27
28
|
import { isDateDisabled } from '../internal/is-date-disabled';
|
|
28
29
|
import { Menu } from '../internal/menu';
|
|
30
|
+
import { MenuTopLayer } from '../internal/menu-top-layer';
|
|
29
31
|
import { parseDate } from '../internal/parse-date';
|
|
30
32
|
import { makeSingleValue } from '../internal/single-value';
|
|
31
33
|
const packageName = "@atlaskit/datetime-picker";
|
|
32
|
-
const packageVersion = "
|
|
34
|
+
const packageVersion = "17.8.0";
|
|
33
35
|
const styles = {
|
|
34
36
|
pickerContainerStyle: "_kqswh2mm",
|
|
35
37
|
dropdownIndicatorStyles: "_1ul91k8s _1tke1k8s _1e0c1txw _4cvr1h6o _1bah1h6o",
|
|
@@ -128,10 +130,14 @@ const DatePicker = /*#__PURE__*/forwardRef((props, _forwardedRef) => {
|
|
|
128
130
|
return;
|
|
129
131
|
}
|
|
130
132
|
if (isOpen && wasOpenedFromCalendarButton) {
|
|
131
|
-
var _calendarRef$current, _calendarRef$current$;
|
|
132
133
|
setIsKeyDown(false);
|
|
133
|
-
//
|
|
134
|
-
|
|
134
|
+
// When using top-layer, Popup.Content with role='dialog' automatically
|
|
135
|
+
// focuses the first focusable element — no manual focus needed.
|
|
136
|
+
if (!fg('platform-dst-top-layer')) {
|
|
137
|
+
var _calendarRef$current, _calendarRef$current$;
|
|
138
|
+
// Focus on the first button within the calendar
|
|
139
|
+
calendarRef === null || calendarRef === void 0 ? void 0 : (_calendarRef$current = calendarRef.current) === null || _calendarRef$current === void 0 ? void 0 : (_calendarRef$current$ = _calendarRef$current.querySelector('button')) === null || _calendarRef$current$ === void 0 ? void 0 : _calendarRef$current$.focus();
|
|
140
|
+
}
|
|
135
141
|
}
|
|
136
142
|
}, [isKeyDown, calendarRef, isOpen, wasOpenedFromCalendarButton]);
|
|
137
143
|
const getValue = () => propValue !== null && propValue !== void 0 ? propValue : value;
|
|
@@ -153,19 +159,17 @@ const DatePicker = /*#__PURE__*/forwardRef((props, _forwardedRef) => {
|
|
|
153
159
|
setWasOpenedFromCalendarButton(false);
|
|
154
160
|
onChangePropWithAnalytics(iso);
|
|
155
161
|
|
|
156
|
-
//
|
|
157
|
-
// on
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const innerCombobox = containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.querySelector('[role="combobox"]');
|
|
168
|
-
innerCombobox === null || innerCombobox === void 0 ? void 0 : innerCombobox.focus();
|
|
162
|
+
// When using top-layer, PopupContent handles focus restoration automatically
|
|
163
|
+
// on close based on the role. Only manually restore focus for the legacy path.
|
|
164
|
+
if (!fg('platform-dst-top-layer')) {
|
|
165
|
+
if (wasOpenedFromCalendarButton) {
|
|
166
|
+
var _calendarButtonRef$cu;
|
|
167
|
+
(_calendarButtonRef$cu = calendarButtonRef.current) === null || _calendarButtonRef$cu === void 0 ? void 0 : _calendarButtonRef$cu.focus();
|
|
168
|
+
} else {
|
|
169
|
+
var _containerRef$current;
|
|
170
|
+
const innerCombobox = containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.querySelector('[role="combobox"]');
|
|
171
|
+
innerCombobox === null || innerCombobox === void 0 ? void 0 : innerCombobox.focus();
|
|
172
|
+
}
|
|
169
173
|
}
|
|
170
174
|
setIsOpen(false);
|
|
171
175
|
};
|
|
@@ -245,12 +249,12 @@ const DatePicker = /*#__PURE__*/forwardRef((props, _forwardedRef) => {
|
|
|
245
249
|
}
|
|
246
250
|
switch (keyPressed) {
|
|
247
251
|
case 'escape':
|
|
248
|
-
//
|
|
249
|
-
//
|
|
250
|
-
//
|
|
251
|
-
//
|
|
252
|
-
//
|
|
253
|
-
//
|
|
252
|
+
// Restore focus on close. Both code paths handle this here:
|
|
253
|
+
// the legacy path because it has no built-in restoration, and
|
|
254
|
+
// the top-layer path because the menu uses `mode="manual"` to
|
|
255
|
+
// avoid the auto-popover light-dismiss closing the menu on the
|
|
256
|
+
// same click that opens it (see internal/menu-top-layer.tsx).
|
|
257
|
+
// `manual` mode disables the browser's native focus return.
|
|
254
258
|
if (wasOpenedFromCalendarButton) {
|
|
255
259
|
var _calendarButtonRef$cu2;
|
|
256
260
|
(_calendarButtonRef$cu2 = calendarButtonRef.current) === null || _calendarButtonRef$cu2 === void 0 ? void 0 : _calendarButtonRef$cu2.focus();
|
|
@@ -399,7 +403,7 @@ const DatePicker = /*#__PURE__*/forwardRef((props, _forwardedRef) => {
|
|
|
399
403
|
showClearIndicator: showClearIndicator
|
|
400
404
|
}))
|
|
401
405
|
} : {}),
|
|
402
|
-
Menu,
|
|
406
|
+
Menu: fg('platform-dst-top-layer') ? MenuTopLayer : Menu,
|
|
403
407
|
SingleValue,
|
|
404
408
|
...(!showClearIndicator && {
|
|
405
409
|
ClearIndicator: EmptyComponent
|
|
@@ -10,13 +10,13 @@ import { format, isValid, parseISO } from 'date-fns';
|
|
|
10
10
|
import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
11
11
|
import SelectClearIcon from '@atlaskit/icon/core/cross-circle';
|
|
12
12
|
import { mergeStyles } from '@atlaskit/select';
|
|
13
|
-
import { formatDateTimeZoneIntoIso } from '../internal';
|
|
14
13
|
import { DateTimePickerContainer } from '../internal/date-time-picker-container';
|
|
14
|
+
import { formatDateTimeZoneIntoIso } from '../internal/format-date-time-zone-into-iso';
|
|
15
15
|
import { convertTokens } from '../internal/parse-tokens';
|
|
16
16
|
import DatePicker from './date-picker';
|
|
17
17
|
import TimePicker from './time-picker';
|
|
18
18
|
const packageName = "@atlaskit/datetime-picker";
|
|
19
|
-
const packageVersion = "
|
|
19
|
+
const packageVersion = "17.8.0";
|
|
20
20
|
const compiledStyles = {
|
|
21
21
|
datePickerContainerStyles: "_i0dl1ssb _16jlkb7n _1o9zidpf",
|
|
22
22
|
timePickerContainerStyles: "_i0dl1ssb _16jlkb7n",
|
|
@@ -48,8 +48,6 @@ const dateTimePickerDefaultProps = {
|
|
|
48
48
|
// Not including a default prop for value as it will
|
|
49
49
|
// Make the component a controlled component
|
|
50
50
|
};
|
|
51
|
-
export const datePickerDefaultAriaLabel = 'Date';
|
|
52
|
-
export const timePickerDefaultAriaLabel = 'Time';
|
|
53
51
|
|
|
54
52
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
55
53
|
class DateTimePickerComponent extends React.Component {
|
|
@@ -233,14 +231,14 @@ class DateTimePickerComponent extends React.Component {
|
|
|
233
231
|
const timeValue = parsedValues === null || parsedValues === void 0 ? void 0 : parsedValues.timeValue;
|
|
234
232
|
const datePickerSelectProps = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.selectProps;
|
|
235
233
|
const datePickerAriaDescribedBy = datePickerProps['aria-describedby'] || ariaDescribedBy;
|
|
236
|
-
const datePickerLabel = datePickerProps.label ||
|
|
234
|
+
const datePickerLabel = datePickerProps.label || 'Date';
|
|
237
235
|
const mergedDatePickerSelectProps = {
|
|
238
236
|
...datePickerSelectProps,
|
|
239
237
|
styles: mergeStyles(styles, datePickerSelectProps === null || datePickerSelectProps === void 0 ? void 0 : datePickerSelectProps.styles)
|
|
240
238
|
};
|
|
241
239
|
const timePickerSelectProps = timePickerProps === null || timePickerProps === void 0 ? void 0 : timePickerProps.selectProps;
|
|
242
240
|
const timePickerAriaDescribedBy = timePickerProps['aria-describedby'] || ariaDescribedBy;
|
|
243
|
-
const timePickerLabel = timePickerProps.label ||
|
|
241
|
+
const timePickerLabel = timePickerProps.label || 'Time';
|
|
244
242
|
const mergedTimePickerSelectProps = {
|
|
245
243
|
...timePickerSelectProps,
|
|
246
244
|
styles: mergeStyles(styles, timePickerSelectProps === null || timePickerSelectProps === void 0 ? void 0 : timePickerSelectProps.styles)
|
|
@@ -370,4 +368,6 @@ const DateTimePicker = withAnalyticsContext({
|
|
|
370
368
|
}
|
|
371
369
|
})
|
|
372
370
|
})(DateTimePickerComponent));
|
|
371
|
+
|
|
372
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
373
373
|
export default DateTimePicker;
|
|
@@ -14,13 +14,13 @@ import { IconButton } from '@atlaskit/button/new';
|
|
|
14
14
|
import SelectClearIcon from '@atlaskit/icon/core/cross-circle';
|
|
15
15
|
import { Box, Inline } from '@atlaskit/primitives/compiled';
|
|
16
16
|
import { mergeStyles } from '@atlaskit/select';
|
|
17
|
-
import { formatDateTimeZoneIntoIso } from '../internal';
|
|
18
17
|
import { DateTimePickerContainer } from '../internal/date-time-picker-container';
|
|
18
|
+
import { formatDateTimeZoneIntoIso } from '../internal/format-date-time-zone-into-iso';
|
|
19
19
|
import { convertTokens } from '../internal/parse-tokens';
|
|
20
20
|
import DatePicker from './date-picker';
|
|
21
21
|
import TimePicker from './time-picker';
|
|
22
22
|
const packageName = "@atlaskit/datetime-picker";
|
|
23
|
-
const packageVersion = "
|
|
23
|
+
const packageVersion = "17.8.0";
|
|
24
24
|
const analyticsAttributes = {
|
|
25
25
|
componentName: 'dateTimePicker',
|
|
26
26
|
packageName,
|
|
@@ -59,9 +59,6 @@ const styles = {
|
|
|
59
59
|
* that the previous useState approach missed.
|
|
60
60
|
*/
|
|
61
61
|
|
|
62
|
-
export const datePickerDefaultAriaLabel = 'Date';
|
|
63
|
-
export const timePickerDefaultAriaLabel = 'Time';
|
|
64
|
-
|
|
65
62
|
/**
|
|
66
63
|
* __Date time picker__
|
|
67
64
|
*
|
|
@@ -6,14 +6,19 @@ import { format, isValid } from 'date-fns';
|
|
|
6
6
|
import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
|
|
7
7
|
import __noop from '@atlaskit/ds-lib/noop';
|
|
8
8
|
import { createLocalizationProvider } from '@atlaskit/locale';
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
10
|
import Select, { CreatableSelect, mergeStyles } from '@atlaskit/select';
|
|
10
|
-
import {
|
|
11
|
+
import { defaultTimes } from '../internal/default-times';
|
|
12
|
+
import { EmptyComponent } from '../internal/empty-component';
|
|
11
13
|
import { FixedLayerMenu } from '../internal/fixed-layer-menu';
|
|
14
|
+
import { FixedLayerMenuTopLayer } from '../internal/fixed-layer-menu-top-layer';
|
|
12
15
|
import parseTime from '../internal/parse-time';
|
|
13
16
|
import { convertTokens } from '../internal/parse-tokens';
|
|
17
|
+
import { placeholderDatetime } from '../internal/placeholder-date-time';
|
|
14
18
|
import { makeSingleValue } from '../internal/single-value';
|
|
15
19
|
const packageName = "@atlaskit/datetime-picker";
|
|
16
|
-
const packageVersion = "
|
|
20
|
+
const packageVersion = "17.8.0";
|
|
21
|
+
const defaultTimeFormat = 'h:mma';
|
|
17
22
|
const menuStyles = {
|
|
18
23
|
/* Need to remove default absolute positioning as that causes issues with position fixed */
|
|
19
24
|
position: 'static',
|
|
@@ -227,7 +232,7 @@ const TimePicker = /*#__PURE__*/forwardRef(({
|
|
|
227
232
|
});
|
|
228
233
|
const selectComponents = {
|
|
229
234
|
DropdownIndicator: EmptyComponent,
|
|
230
|
-
Menu: FixedLayerMenu,
|
|
235
|
+
Menu: fg('platform-dst-top-layer') ? FixedLayerMenuTopLayer : FixedLayerMenu,
|
|
231
236
|
SingleValue,
|
|
232
237
|
...(hideIcon && {
|
|
233
238
|
ClearIndicator: EmptyComponent
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '../components/date-picker';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '../components/date-time-picker';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '../components/time-picker';
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const defaultDateFormat = 'YYYY/MM/DD';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const defaultTimes = ['09:00', '09:30', '10:00', '10:30', '11:00', '11:30', '12:00', '12:30', '13:00', '13:30', '14:00', '14:30', '15:00', '15:30', '16:00', '16:30', '17:00', '17:30', '18:00'];
|