@atlaskit/datetime-picker 19.3.1 → 19.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/dist/cjs/components/date-picker.js +1 -1
- package/dist/cjs/components/date-time-picker.js +1 -1
- package/dist/cjs/components/time-picker.js +13 -11
- package/dist/cjs/internal/is-valid.js +2 -2
- package/dist/cjs/internal/parse-time.js +180 -2
- package/dist/es2019/components/date-picker.js +1 -1
- package/dist/es2019/components/date-time-picker.js +1 -1
- package/dist/es2019/components/time-picker.js +11 -7
- package/dist/es2019/internal/is-valid.js +2 -2
- package/dist/es2019/internal/parse-time.js +135 -2
- package/dist/esm/components/date-picker.js +1 -1
- package/dist/esm/components/date-time-picker.js +1 -1
- package/dist/esm/components/time-picker.js +14 -12
- package/dist/esm/internal/is-valid.js +2 -2
- package/dist/esm/internal/parse-time.js +179 -2
- package/dist/types/internal/parse-time.d.ts +2 -1
- package/package.json +13 -9
- package/dist/cjs/internal/fixed-layer-menu-top-layer.js +0 -118
- package/dist/es2019/internal/fixed-layer-menu-top-layer.js +0 -109
- package/dist/esm/internal/fixed-layer-menu-top-layer.js +0 -111
- package/dist/types/internal/fixed-layer-menu-top-layer.d.ts +0 -12
|
@@ -8,7 +8,7 @@ import "./time-picker.compiled.css";
|
|
|
8
8
|
import { ax, ix } from "@compiled/react/runtime";
|
|
9
9
|
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; }
|
|
10
10
|
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) { _defineProperty(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; }
|
|
11
|
-
import React, { forwardRef, useCallback, useEffect, useId, useReducer, useState } from 'react';
|
|
11
|
+
import React, { forwardRef, useCallback, useEffect, useId, useMemo, useReducer, useState } from 'react';
|
|
12
12
|
|
|
13
13
|
// oxlint-disable-next-line @atlassian/no-restricted-imports
|
|
14
14
|
import { format, isValid } from 'date-fns';
|
|
@@ -16,6 +16,7 @@ import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next/usePlatfor
|
|
|
16
16
|
import IconButton from '@atlaskit/button/icon/button';
|
|
17
17
|
import __noop from '@atlaskit/ds-lib/noop';
|
|
18
18
|
import ClockIcon from '@atlaskit/icon/core/clock';
|
|
19
|
+
import { getTimeFormat } from '@atlaskit/locale/get-time-format';
|
|
19
20
|
import { createLocalizationProvider } from '@atlaskit/locale/localization-provider';
|
|
20
21
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
21
22
|
import { mergeStyles } from '@atlaskit/react-select/styles';
|
|
@@ -24,14 +25,13 @@ import Select from '@atlaskit/select/default';
|
|
|
24
25
|
import { defaultTimes } from '../internal/default-times';
|
|
25
26
|
import { EmptyComponent } from '../internal/empty-component';
|
|
26
27
|
import { FixedLayerMenu } from '../internal/fixed-layer-menu';
|
|
27
|
-
import { FixedLayerMenuTopLayer } from '../internal/fixed-layer-menu-top-layer';
|
|
28
28
|
import parseTime from '../internal/parse-time';
|
|
29
29
|
import { convertTokens } from '../internal/parse-tokens';
|
|
30
30
|
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.3.
|
|
34
|
+
var packageVersion = "19.3.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 */
|
|
@@ -99,10 +99,7 @@ var TimePicker = /*#__PURE__*/forwardRef(function (_ref2, _ref) {
|
|
|
99
99
|
providedOnChange = _ref2$onChange === void 0 ? __noop : _ref2$onChange,
|
|
100
100
|
_ref2$onFocus = _ref2.onFocus,
|
|
101
101
|
providedOnFocus = _ref2$onFocus === void 0 ? __noop : _ref2$onFocus,
|
|
102
|
-
|
|
103
|
-
parseInputValue = _ref2$parseInputValue === void 0 ? function (time, _timeFormat) {
|
|
104
|
-
return parseTime(time);
|
|
105
|
-
} : _ref2$parseInputValue,
|
|
102
|
+
parseInputValue = _ref2.parseInputValue,
|
|
106
103
|
placeholder = _ref2.placeholder,
|
|
107
104
|
_ref2$selectProps = _ref2.selectProps,
|
|
108
105
|
selectProps = _ref2$selectProps === void 0 ? {} : _ref2$selectProps,
|
|
@@ -147,6 +144,10 @@ var TimePicker = /*#__PURE__*/forwardRef(function (_ref2, _ref) {
|
|
|
147
144
|
_useState10 = _slicedToArray(_useState1, 2),
|
|
148
145
|
value = _useState10[0],
|
|
149
146
|
setValue = _useState10[1];
|
|
147
|
+
var l10n = createLocalizationProvider(locale);
|
|
148
|
+
var localeTimeFormat = useMemo(function () {
|
|
149
|
+
return fg('platform-dst-locale-aware-time-parsing') ? getTimeFormat(locale) : undefined;
|
|
150
|
+
}, [locale]);
|
|
150
151
|
|
|
151
152
|
// Hack to force update: https://legacy.reactjs.org/docs/hooks-faq.html#is-there-something-like-forceupdate
|
|
152
153
|
var _useReducer = useReducer(function (x) {
|
|
@@ -193,7 +194,7 @@ var TimePicker = /*#__PURE__*/forwardRef(function (_ref2, _ref) {
|
|
|
193
194
|
if (timeIsEditable) {
|
|
194
195
|
var sanitizedInput;
|
|
195
196
|
try {
|
|
196
|
-
sanitizedInput = parseInputValue(inputValue, timeFormat || defaultTimeFormat);
|
|
197
|
+
sanitizedInput = parseInputValue ? parseInputValue(inputValue, timeFormat || defaultTimeFormat) : parseTime(inputValue, localeTimeFormat);
|
|
197
198
|
} catch (_unused) {
|
|
198
199
|
return; // do nothing, the main validation should happen in the form
|
|
199
200
|
}
|
|
@@ -266,7 +267,6 @@ var TimePicker = /*#__PURE__*/forwardRef(function (_ref2, _ref) {
|
|
|
266
267
|
};
|
|
267
268
|
var ICON_PADDING = 2;
|
|
268
269
|
var GRID_SIZE = 8;
|
|
269
|
-
var l10n = createLocalizationProvider(locale);
|
|
270
270
|
var _selectProps$styles = selectProps.styles,
|
|
271
271
|
selectStyles = _selectProps$styles === void 0 ? {} : _selectProps$styles,
|
|
272
272
|
otherSelectProps = _objectWithoutProperties(selectProps, _excluded);
|
|
@@ -331,9 +331,11 @@ var TimePicker = /*#__PURE__*/forwardRef(function (_ref2, _ref) {
|
|
|
331
331
|
id: valueId,
|
|
332
332
|
lang: locale
|
|
333
333
|
});
|
|
334
|
-
var selectComponents = _objectSpread({
|
|
335
|
-
DropdownIndicator: EmptyComponent
|
|
336
|
-
|
|
334
|
+
var selectComponents = _objectSpread(_objectSpread({
|
|
335
|
+
DropdownIndicator: EmptyComponent
|
|
336
|
+
}, !fg('platform-dst-top-layer') && {
|
|
337
|
+
Menu: FixedLayerMenu
|
|
338
|
+
}), {}, {
|
|
337
339
|
SingleValue: SingleValue
|
|
338
340
|
}, hideIcon && {
|
|
339
341
|
ClearIndicator: EmptyComponent
|
|
@@ -2,12 +2,12 @@ export function isValid(timeString) {
|
|
|
2
2
|
/**
|
|
3
3
|
* Regex match for `12:34`, `12:34:56`, `1:23:56 p`, `1:23:56PM`, and a bit more…
|
|
4
4
|
*/
|
|
5
|
-
var time = timeString.trim().match(
|
|
5
|
+
var time = timeString.trim().match(/^([012]?[\d])(?:[:.]?([0-5][\d]))?(?:[:.]?([0-5][\d]))?\s*([ap](?:\s*\.?\s*m\.?)?)?$/i);
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Regex match for `1234`, `12:34`, `12.34`, `123456`, `12:34:56`, `12.34.56`
|
|
9
9
|
*/
|
|
10
|
-
var time24hr = timeString.trim().match(
|
|
10
|
+
var time24hr = timeString.trim().match(/^([012][\d])[:.]?([0-5][\d])([:.]?([0-5][\d]))?$/);
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Convert `2:34:56 pm` down to `23456`
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
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; }
|
|
4
|
+
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) { _defineProperty(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; }
|
|
1
5
|
import { convertTo24hrTime } from './convert-to24hr-time';
|
|
2
6
|
import { isValid } from './is-valid';
|
|
3
7
|
import { removeSpacer } from './remove-spacer';
|
|
@@ -9,8 +13,26 @@ function assignToDate(time) {
|
|
|
9
13
|
dateTime.setSeconds(time.seconds || 0, 0);
|
|
10
14
|
return dateTime;
|
|
11
15
|
}
|
|
12
|
-
|
|
16
|
+
function parseLegacyTime(time) {
|
|
17
|
+
var allowCompactTime = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
13
18
|
var trimmedTime = time.toString().trim();
|
|
19
|
+
var compactTime = allowCompactTime ? trimmedTime.match(/^\d{5}$/) : null;
|
|
20
|
+
if (compactTime) {
|
|
21
|
+
var normalizedTime = "0".concat(compactTime[0]);
|
|
22
|
+
var hour = Number(normalizedTime.slice(0, 2));
|
|
23
|
+
var minute = Number(normalizedTime.slice(2, 4));
|
|
24
|
+
var seconds = Number(normalizedTime.slice(4, 6));
|
|
25
|
+
if (minute <= 59 && seconds <= 59) {
|
|
26
|
+
return assignToDate({
|
|
27
|
+
hour: hour,
|
|
28
|
+
minute: minute,
|
|
29
|
+
seconds: seconds
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (/^\d{5}$/.test(trimmedTime)) {
|
|
34
|
+
throw RangeError('invalid time format');
|
|
35
|
+
}
|
|
14
36
|
if (!isValid(trimmedTime)) {
|
|
15
37
|
throw RangeError('invalid time format');
|
|
16
38
|
}
|
|
@@ -19,5 +41,160 @@ export default function parseTime(time) {
|
|
|
19
41
|
if (!time2) {
|
|
20
42
|
throw RangeError('invalid time format');
|
|
21
43
|
}
|
|
22
|
-
return assignToDate(time2)
|
|
44
|
+
return assignToDate(_objectSpread(_objectSpread({}, time2), {}, {
|
|
45
|
+
hour: time2.hour === 24 ? 0 : time2.hour
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
var escapeRegExp = function escapeRegExp(value) {
|
|
49
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
50
|
+
};
|
|
51
|
+
var normalizeDigits = function normalizeDigits(time, timeFormat) {
|
|
52
|
+
return Array.from(time, function (character) {
|
|
53
|
+
return timeFormat.digits[character] || character;
|
|
54
|
+
}).join('');
|
|
55
|
+
};
|
|
56
|
+
var isValidHourForCycle = function isValidHourForCycle(hour, hourCycle) {
|
|
57
|
+
return hourCycle === 'h11' ? hour <= 11 : hourCycle === 'h12' ? hour >= 1 && hour <= 12 : hour <= 24;
|
|
58
|
+
};
|
|
59
|
+
function parseExactLocalizedTime(time, timeFormat) {
|
|
60
|
+
if (!timeFormat.timeParts) {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
var dayPeriods = Object.entries(timeFormat.dayPeriods).filter(function (_ref) {
|
|
64
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
65
|
+
value = _ref2[1];
|
|
66
|
+
return value;
|
|
67
|
+
});
|
|
68
|
+
var groupTypes = [];
|
|
69
|
+
var patternParts = timeFormat.timeParts.map(function (part) {
|
|
70
|
+
if (part.type === 'hour' || part.type === 'minute' || part.type === 'second') {
|
|
71
|
+
groupTypes.push(part.type);
|
|
72
|
+
return part.type === 'hour' ? '(\\d{1,2})' : '(\\d{2})';
|
|
73
|
+
}
|
|
74
|
+
if (part.type === 'dayPeriod') {
|
|
75
|
+
if (dayPeriods.length === 0) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
groupTypes.push('dayPeriod');
|
|
79
|
+
return "(".concat(dayPeriods.map(function (_ref3) {
|
|
80
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
81
|
+
value = _ref4[1];
|
|
82
|
+
return escapeRegExp(value);
|
|
83
|
+
}).join('|'), ")");
|
|
84
|
+
}
|
|
85
|
+
if (part.type === 'literal') {
|
|
86
|
+
return escapeRegExp(part.value);
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
});
|
|
90
|
+
if (patternParts.some(function (part) {
|
|
91
|
+
return part === null;
|
|
92
|
+
})) {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
var match = time.match(new RegExp("^".concat(patternParts.join(''), "$"), 'u'));
|
|
96
|
+
if (!match) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
var values = Object.fromEntries(groupTypes.map(function (type, index) {
|
|
100
|
+
return [type, match[index + 1]];
|
|
101
|
+
}));
|
|
102
|
+
if (!values.hour || !values.minute) {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
var hour = Number(values.hour);
|
|
106
|
+
var minute = Number(values.minute);
|
|
107
|
+
var seconds = Number(values.second || '0');
|
|
108
|
+
if (minute > 59 || seconds > 59) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
if (values.dayPeriod) {
|
|
112
|
+
var _dayPeriods$find;
|
|
113
|
+
var period = (_dayPeriods$find = dayPeriods.find(function (_ref5) {
|
|
114
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
115
|
+
value = _ref6[1];
|
|
116
|
+
return value === values.dayPeriod;
|
|
117
|
+
})) === null || _dayPeriods$find === void 0 ? void 0 : _dayPeriods$find[0];
|
|
118
|
+
if (!period || !isValidHourForCycle(hour, timeFormat.hourCycle)) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
return assignToDate({
|
|
122
|
+
hour: period === 'pm' ? hour % 12 + 12 : hour % 12,
|
|
123
|
+
minute: minute,
|
|
124
|
+
seconds: seconds
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
if (hour > 24) {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
return assignToDate({
|
|
131
|
+
hour: hour === 24 ? 0 : hour,
|
|
132
|
+
minute: minute,
|
|
133
|
+
seconds: seconds
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function parseLocalizedTime(normalizedTime, timeFormat) {
|
|
137
|
+
var dayPeriods = Object.entries(timeFormat.dayPeriods).filter(function (_ref7) {
|
|
138
|
+
var _ref8 = _slicedToArray(_ref7, 2),
|
|
139
|
+
value = _ref8[1];
|
|
140
|
+
return value;
|
|
141
|
+
});
|
|
142
|
+
var markers = dayPeriods.filter(function (_ref9) {
|
|
143
|
+
var _ref0 = _slicedToArray(_ref9, 2),
|
|
144
|
+
value = _ref0[1];
|
|
145
|
+
return new RegExp(escapeRegExp(value), 'u').test(normalizedTime);
|
|
146
|
+
});
|
|
147
|
+
if (markers.length === 0) {
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
150
|
+
if (markers.length !== 1) {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
var _markers = _slicedToArray(markers, 1),
|
|
154
|
+
_markers$ = _slicedToArray(_markers[0], 2),
|
|
155
|
+
period = _markers$[0],
|
|
156
|
+
marker = _markers$[1];
|
|
157
|
+
var numericTime = normalizedTime.replace(new RegExp(escapeRegExp(marker), 'u'), '').trim();
|
|
158
|
+
var match = numericTime.match(/^(\d{1,2})(?:[:.](\d{2}))?(?:[:.](\d{2}))?$/);
|
|
159
|
+
if (!match) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
var _match = _slicedToArray(match, 4),
|
|
163
|
+
hourValue = _match[1],
|
|
164
|
+
_match$ = _match[2],
|
|
165
|
+
minuteValue = _match$ === void 0 ? '0' : _match$,
|
|
166
|
+
_match$2 = _match[3],
|
|
167
|
+
secondValue = _match$2 === void 0 ? '0' : _match$2;
|
|
168
|
+
var hour = Number(hourValue);
|
|
169
|
+
var minute = Number(minuteValue);
|
|
170
|
+
var seconds = Number(secondValue);
|
|
171
|
+
if (!isValidHourForCycle(hour, timeFormat.hourCycle) || minute > 59 || seconds > 59) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
return assignToDate({
|
|
175
|
+
hour: period === 'pm' ? hour % 12 + 12 : hour % 12,
|
|
176
|
+
minute: minute,
|
|
177
|
+
seconds: seconds
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
export default function parseTime(time, timeFormat) {
|
|
181
|
+
if (timeFormat) {
|
|
182
|
+
var normalizedTime = normalizeDigits(time, timeFormat);
|
|
183
|
+
var exactLocalizedTime = parseExactLocalizedTime(normalizedTime, timeFormat);
|
|
184
|
+
if (exactLocalizedTime instanceof Date) {
|
|
185
|
+
return exactLocalizedTime;
|
|
186
|
+
}
|
|
187
|
+
if (exactLocalizedTime === null) {
|
|
188
|
+
throw RangeError('invalid time format');
|
|
189
|
+
}
|
|
190
|
+
var localizedTime = parseLocalizedTime(normalizedTime, timeFormat);
|
|
191
|
+
if (localizedTime instanceof Date) {
|
|
192
|
+
return localizedTime;
|
|
193
|
+
}
|
|
194
|
+
if (localizedTime === null) {
|
|
195
|
+
throw RangeError('invalid time format');
|
|
196
|
+
}
|
|
197
|
+
return parseLegacyTime(normalizedTime, true);
|
|
198
|
+
}
|
|
199
|
+
return parseLegacyTime(time);
|
|
23
200
|
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { TimeFormat } from '@atlaskit/locale/get-time-format';
|
|
2
|
+
export default function parseTime(time: string, timeFormat?: TimeFormat): string | Date;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/datetime-picker",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.4.0",
|
|
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,21 +35,21 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@atlaskit/analytics-next": "^12.6.0",
|
|
38
|
-
"@atlaskit/button": "^25.
|
|
38
|
+
"@atlaskit/button": "^25.6.0",
|
|
39
39
|
"@atlaskit/calendar": "^19.5.0",
|
|
40
40
|
"@atlaskit/css": "^1.1.0",
|
|
41
41
|
"@atlaskit/ds-lib": "^8.0.0",
|
|
42
42
|
"@atlaskit/icon": "^38.0.0",
|
|
43
|
-
"@atlaskit/layering": "^6.
|
|
44
|
-
"@atlaskit/locale": "^5.
|
|
43
|
+
"@atlaskit/layering": "^6.1.0",
|
|
44
|
+
"@atlaskit/locale": "^5.5.0",
|
|
45
45
|
"@atlaskit/platform-feature-flags": "^2.2.0",
|
|
46
46
|
"@atlaskit/popper": "^9.4.0",
|
|
47
|
-
"@atlaskit/primitives": "^22.
|
|
47
|
+
"@atlaskit/primitives": "^22.6.0",
|
|
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": "^6.
|
|
51
|
+
"@atlaskit/tokens": "^20.7.0",
|
|
52
|
+
"@atlaskit/top-layer": "^6.6.0",
|
|
53
53
|
"@babel/runtime": "^7.0.0",
|
|
54
54
|
"@compiled/react": "^1.0.2",
|
|
55
55
|
"date-fns": "^2.17.0"
|
|
@@ -67,8 +67,9 @@
|
|
|
67
67
|
"@atlaskit/form": "^18.2.0",
|
|
68
68
|
"@atlaskit/heading": "^8.0.0",
|
|
69
69
|
"@atlaskit/link": "^5.1.0",
|
|
70
|
-
"@atlaskit/
|
|
71
|
-
"@atlaskit/
|
|
70
|
+
"@atlaskit/menu": "^11.0.0",
|
|
71
|
+
"@atlaskit/modal-dialog": "^17.1.0",
|
|
72
|
+
"@atlaskit/popup": "^10.0.0",
|
|
72
73
|
"@atlaskit/range": "^12.2.0",
|
|
73
74
|
"@atlaskit/section-message": "^10.2.0",
|
|
74
75
|
"@atlaskit/textfield": "^10.2.0",
|
|
@@ -94,6 +95,9 @@
|
|
|
94
95
|
"platform-dst-motion-uplift-input": {
|
|
95
96
|
"type": "boolean",
|
|
96
97
|
"referenceOnly": true
|
|
98
|
+
},
|
|
99
|
+
"platform-dst-locale-aware-time-parsing": {
|
|
100
|
+
"type": "boolean"
|
|
97
101
|
}
|
|
98
102
|
},
|
|
99
103
|
"homepage": "https://atlassian.design/components/datetime-picker/"
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
/* fixed-layer-menu-top-layer.tsx generated by @compiled/babel-plugin v3.0.2 */
|
|
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 _components = require("@atlaskit/react-select/components");
|
|
16
|
-
var _index = require("@atlaskit/top-layer/placement-map/index");
|
|
17
|
-
var _popoverSurface = require("@atlaskit/top-layer/popover-surface");
|
|
18
|
-
var _popover = require("@atlaskit/top-layer/popover/popover");
|
|
19
|
-
var _useAnchoredPopover = require("@atlaskit/top-layer/use-anchored-popover");
|
|
20
|
-
var _excluded = ["className", "clearValue", "cx", "getStyles", "getValue", "hasValue", "innerProps", "innerRef", "isLoading", "isMulti", "isRtl", "maxMenuHeight", "menuPlacement", "menuPosition", "menuShouldScrollIntoView", "minMenuHeight", "options", "placement", "selectOption", "selectProps", "setValue", "children"];
|
|
21
|
-
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); }
|
|
22
|
-
/**
|
|
23
|
-
* Bottom-start placement: time options menu appears below and aligned to the
|
|
24
|
-
* start edge of the trigger (the select input).
|
|
25
|
-
*/
|
|
26
|
-
var popupPlacement = (0, _index.fromLegacyPlacement)({
|
|
27
|
-
legacy: 'bottom-start'
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Top-layer version of the fixed layer menu used in the time picker.
|
|
32
|
-
*
|
|
33
|
-
* Uses `Popover` + `useAnchoredPopover` so the time options list renders
|
|
34
|
-
* in the browser's top layer via the native Popover API and is positioned
|
|
35
|
-
* via CSS Anchor Positioning. This avoids overflow clipping, z-index wars,
|
|
36
|
-
* and portal-based layering.
|
|
37
|
-
*
|
|
38
|
-
* Gated behind the `platform-dst-top-layer` feature flag.
|
|
39
|
-
*/
|
|
40
|
-
var FixedLayerMenuTopLayer = exports.FixedLayerMenuTopLayer = function FixedLayerMenuTopLayer(_ref) {
|
|
41
|
-
var _selectProps$fixedLay, _selectProps$fixedLay2;
|
|
42
|
-
var className = _ref.className,
|
|
43
|
-
clearValue = _ref.clearValue,
|
|
44
|
-
cx = _ref.cx,
|
|
45
|
-
getStyles = _ref.getStyles,
|
|
46
|
-
getValue = _ref.getValue,
|
|
47
|
-
hasValue = _ref.hasValue,
|
|
48
|
-
innerProps = _ref.innerProps,
|
|
49
|
-
innerRef = _ref.innerRef,
|
|
50
|
-
isLoading = _ref.isLoading,
|
|
51
|
-
isMulti = _ref.isMulti,
|
|
52
|
-
isRtl = _ref.isRtl,
|
|
53
|
-
maxMenuHeight = _ref.maxMenuHeight,
|
|
54
|
-
menuPlacement = _ref.menuPlacement,
|
|
55
|
-
menuPosition = _ref.menuPosition,
|
|
56
|
-
menuShouldScrollIntoView = _ref.menuShouldScrollIntoView,
|
|
57
|
-
minMenuHeight = _ref.minMenuHeight,
|
|
58
|
-
options = _ref.options,
|
|
59
|
-
placement = _ref.placement,
|
|
60
|
-
selectOption = _ref.selectOption,
|
|
61
|
-
selectProps = _ref.selectProps,
|
|
62
|
-
setValue = _ref.setValue,
|
|
63
|
-
children = _ref.children,
|
|
64
|
-
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
65
|
-
// The select's container element is the anchor for the popup.
|
|
66
|
-
var triggerRef = (0, _react.useRef)((_selectProps$fixedLay = selectProps.fixedLayerRef) !== null && _selectProps$fixedLay !== void 0 ? _selectProps$fixedLay : null);
|
|
67
|
-
triggerRef.current = (_selectProps$fixedLay2 = selectProps.fixedLayerRef) !== null && _selectProps$fixedLay2 !== void 0 ? _selectProps$fixedLay2 : null;
|
|
68
|
-
var popoverRef = (0, _react.useRef)(null);
|
|
69
|
-
(0, _useAnchoredPopover.useAnchoredPopover)({
|
|
70
|
-
anchorRef: triggerRef,
|
|
71
|
-
popoverRef: popoverRef,
|
|
72
|
-
placement: popupPlacement,
|
|
73
|
-
// The Popover is rendered with `isOpen` always true while this
|
|
74
|
-
// component is mounted (react-select conditionally mounts/unmounts
|
|
75
|
-
// the menu), so positioning is always active.
|
|
76
|
-
isOpen: true
|
|
77
|
-
});
|
|
78
|
-
return /*#__PURE__*/React.createElement(_popover.Popover, {
|
|
79
|
-
ref: popoverRef,
|
|
80
|
-
role: "listbox",
|
|
81
|
-
isOpen: true
|
|
82
|
-
// `mode="manual"` opts out of the native popover light-dismiss
|
|
83
|
-
// (Esc / click-outside). react-select already owns those: opening
|
|
84
|
-
// the menu via a click on the input that lives outside the popover
|
|
85
|
-
// element triggers the browser's auto-dismiss as that very click
|
|
86
|
-
// bubbles, slamming the menu shut before the user sees it. With
|
|
87
|
-
// `manual`, react-select's existing onMenuClose / outside-click
|
|
88
|
-
// logic remains the single source of truth.
|
|
89
|
-
,
|
|
90
|
-
mode: "manual",
|
|
91
|
-
placement: popupPlacement,
|
|
92
|
-
shouldAnimate: true,
|
|
93
|
-
testId: selectProps.testId && "".concat(selectProps.testId, "--popup")
|
|
94
|
-
}, /*#__PURE__*/React.createElement(_popoverSurface.PopoverSurface, null, /*#__PURE__*/React.createElement(_components.components.Menu, (0, _extends2.default)({}, rest, {
|
|
95
|
-
// eslint-disable-next-line @atlaskit/design-system/no-unsafe-style-overrides, @atlaskit/ui-styling-standard/no-classname-prop
|
|
96
|
-
className: className,
|
|
97
|
-
clearValue: clearValue,
|
|
98
|
-
cx: cx,
|
|
99
|
-
getStyles: getStyles,
|
|
100
|
-
getValue: getValue,
|
|
101
|
-
hasValue: hasValue,
|
|
102
|
-
innerProps: innerProps,
|
|
103
|
-
innerRef: innerRef,
|
|
104
|
-
isLoading: isLoading,
|
|
105
|
-
isMulti: isMulti,
|
|
106
|
-
isRtl: isRtl,
|
|
107
|
-
maxMenuHeight: maxMenuHeight,
|
|
108
|
-
menuPlacement: menuPlacement,
|
|
109
|
-
menuPosition: menuPosition,
|
|
110
|
-
menuShouldScrollIntoView: false || menuShouldScrollIntoView,
|
|
111
|
-
minMenuHeight: minMenuHeight,
|
|
112
|
-
options: options,
|
|
113
|
-
placement: placement,
|
|
114
|
-
selectOption: selectOption,
|
|
115
|
-
selectProps: selectProps,
|
|
116
|
-
setValue: setValue
|
|
117
|
-
}), children)));
|
|
118
|
-
};
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/* fixed-layer-menu-top-layer.tsx generated by @compiled/babel-plugin v3.0.2 */
|
|
2
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
-
import { useRef } from 'react';
|
|
6
|
-
import { components } from '@atlaskit/react-select/components';
|
|
7
|
-
import { fromLegacyPlacement } from '@atlaskit/top-layer/placement-map/index';
|
|
8
|
-
import { PopoverSurface } from '@atlaskit/top-layer/popover-surface';
|
|
9
|
-
import { Popover } from '@atlaskit/top-layer/popover/popover';
|
|
10
|
-
import { useAnchoredPopover } from '@atlaskit/top-layer/use-anchored-popover';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Bottom-start placement: time options menu appears below and aligned to the
|
|
14
|
-
* start edge of the trigger (the select input).
|
|
15
|
-
*/
|
|
16
|
-
const popupPlacement = fromLegacyPlacement({
|
|
17
|
-
legacy: 'bottom-start'
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Top-layer version of the fixed layer menu used in the time picker.
|
|
22
|
-
*
|
|
23
|
-
* Uses `Popover` + `useAnchoredPopover` so the time options list renders
|
|
24
|
-
* in the browser's top layer via the native Popover API and is positioned
|
|
25
|
-
* via CSS Anchor Positioning. This avoids overflow clipping, z-index wars,
|
|
26
|
-
* and portal-based layering.
|
|
27
|
-
*
|
|
28
|
-
* Gated behind the `platform-dst-top-layer` feature flag.
|
|
29
|
-
*/
|
|
30
|
-
export const FixedLayerMenuTopLayer = ({
|
|
31
|
-
className,
|
|
32
|
-
clearValue,
|
|
33
|
-
cx,
|
|
34
|
-
getStyles,
|
|
35
|
-
getValue,
|
|
36
|
-
hasValue,
|
|
37
|
-
innerProps,
|
|
38
|
-
innerRef,
|
|
39
|
-
isLoading,
|
|
40
|
-
isMulti,
|
|
41
|
-
isRtl,
|
|
42
|
-
maxMenuHeight,
|
|
43
|
-
menuPlacement,
|
|
44
|
-
menuPosition,
|
|
45
|
-
menuShouldScrollIntoView,
|
|
46
|
-
minMenuHeight,
|
|
47
|
-
options,
|
|
48
|
-
placement,
|
|
49
|
-
selectOption,
|
|
50
|
-
selectProps,
|
|
51
|
-
setValue,
|
|
52
|
-
children,
|
|
53
|
-
...rest
|
|
54
|
-
}) => {
|
|
55
|
-
var _selectProps$fixedLay, _selectProps$fixedLay2;
|
|
56
|
-
// The select's container element is the anchor for the popup.
|
|
57
|
-
const triggerRef = useRef((_selectProps$fixedLay = selectProps.fixedLayerRef) !== null && _selectProps$fixedLay !== void 0 ? _selectProps$fixedLay : null);
|
|
58
|
-
triggerRef.current = (_selectProps$fixedLay2 = selectProps.fixedLayerRef) !== null && _selectProps$fixedLay2 !== void 0 ? _selectProps$fixedLay2 : null;
|
|
59
|
-
const popoverRef = useRef(null);
|
|
60
|
-
useAnchoredPopover({
|
|
61
|
-
anchorRef: triggerRef,
|
|
62
|
-
popoverRef,
|
|
63
|
-
placement: popupPlacement,
|
|
64
|
-
// The Popover is rendered with `isOpen` always true while this
|
|
65
|
-
// component is mounted (react-select conditionally mounts/unmounts
|
|
66
|
-
// the menu), so positioning is always active.
|
|
67
|
-
isOpen: true
|
|
68
|
-
});
|
|
69
|
-
return /*#__PURE__*/React.createElement(Popover, {
|
|
70
|
-
ref: popoverRef,
|
|
71
|
-
role: "listbox",
|
|
72
|
-
isOpen: true
|
|
73
|
-
// `mode="manual"` opts out of the native popover light-dismiss
|
|
74
|
-
// (Esc / click-outside). react-select already owns those: opening
|
|
75
|
-
// the menu via a click on the input that lives outside the popover
|
|
76
|
-
// element triggers the browser's auto-dismiss as that very click
|
|
77
|
-
// bubbles, slamming the menu shut before the user sees it. With
|
|
78
|
-
// `manual`, react-select's existing onMenuClose / outside-click
|
|
79
|
-
// logic remains the single source of truth.
|
|
80
|
-
,
|
|
81
|
-
mode: "manual",
|
|
82
|
-
placement: popupPlacement,
|
|
83
|
-
shouldAnimate: true,
|
|
84
|
-
testId: selectProps.testId && `${selectProps.testId}--popup`
|
|
85
|
-
}, /*#__PURE__*/React.createElement(PopoverSurface, null, /*#__PURE__*/React.createElement(components.Menu, _extends({}, rest, {
|
|
86
|
-
// eslint-disable-next-line @atlaskit/design-system/no-unsafe-style-overrides, @atlaskit/ui-styling-standard/no-classname-prop
|
|
87
|
-
className: className,
|
|
88
|
-
clearValue: clearValue,
|
|
89
|
-
cx: cx,
|
|
90
|
-
getStyles: getStyles,
|
|
91
|
-
getValue: getValue,
|
|
92
|
-
hasValue: hasValue,
|
|
93
|
-
innerProps: innerProps,
|
|
94
|
-
innerRef: innerRef,
|
|
95
|
-
isLoading: isLoading,
|
|
96
|
-
isMulti: isMulti,
|
|
97
|
-
isRtl: isRtl,
|
|
98
|
-
maxMenuHeight: maxMenuHeight,
|
|
99
|
-
menuPlacement: menuPlacement,
|
|
100
|
-
menuPosition: menuPosition,
|
|
101
|
-
menuShouldScrollIntoView: false || menuShouldScrollIntoView,
|
|
102
|
-
minMenuHeight: minMenuHeight,
|
|
103
|
-
options: options,
|
|
104
|
-
placement: placement,
|
|
105
|
-
selectOption: selectOption,
|
|
106
|
-
selectProps: selectProps,
|
|
107
|
-
setValue: setValue
|
|
108
|
-
}), children)));
|
|
109
|
-
};
|