@atlaskit/datetime-picker 17.4.5 → 17.5.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.
Files changed (33) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/components/date-picker.js +614 -8
  3. package/dist/cjs/components/date-time-picker-class.js +2 -8
  4. package/dist/cjs/components/date-time-picker-fc.js +2 -8
  5. package/dist/es2019/components/date-picker.js +546 -6
  6. package/dist/es2019/components/date-time-picker-class.js +1 -5
  7. package/dist/es2019/components/date-time-picker-fc.js +1 -5
  8. package/dist/esm/components/date-picker.js +613 -8
  9. package/dist/esm/components/date-time-picker-class.js +1 -7
  10. package/dist/esm/components/date-time-picker-fc.js +1 -7
  11. package/dist/types/components/date-picker.d.ts +18 -3
  12. package/dist/types/components/date-time-picker-class.d.ts +10 -10
  13. package/dist/types/components/date-time-picker.d.ts +8 -8
  14. package/dist/types-ts4.5/components/date-picker.d.ts +18 -3
  15. package/dist/types-ts4.5/components/date-time-picker-class.d.ts +10 -10
  16. package/dist/types-ts4.5/components/date-time-picker.d.ts +8 -8
  17. package/package.json +1 -1
  18. package/dist/cjs/components/date-picker-class.js +0 -658
  19. package/dist/cjs/components/date-picker-fc.js +0 -622
  20. package/dist/es2019/components/date-picker-class.js +0 -623
  21. package/dist/es2019/components/date-picker-fc.compiled.css +0 -16
  22. package/dist/es2019/components/date-picker-fc.js +0 -547
  23. package/dist/esm/components/date-picker-class.compiled.css +0 -16
  24. package/dist/esm/components/date-picker-class.js +0 -652
  25. package/dist/esm/components/date-picker-fc.compiled.css +0 -16
  26. package/dist/esm/components/date-picker-fc.js +0 -614
  27. package/dist/types/components/date-picker-class.d.ts +0 -109
  28. package/dist/types/components/date-picker-fc.d.ts +0 -19
  29. package/dist/types-ts4.5/components/date-picker-class.d.ts +0 -109
  30. package/dist/types-ts4.5/components/date-picker-fc.d.ts +0 -19
  31. /package/dist/cjs/components/{date-picker-class.compiled.css → date-picker.compiled.css} +0 -0
  32. /package/dist/{cjs/components/date-picker-fc.compiled.css → es2019/components/date-picker.compiled.css} +0 -0
  33. /package/dist/{es2019/components/date-picker-class.compiled.css → esm/components/date-picker.compiled.css} +0 -0
@@ -1,652 +0,0 @@
1
- /* date-picker-class.tsx generated by @compiled/babel-plugin v0.38.1 */
2
- import _extends from "@babel/runtime/helpers/extends";
3
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
- import _createClass from "@babel/runtime/helpers/createClass";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- import _inherits from "@babel/runtime/helpers/inherits";
8
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
- import "./date-picker-class.compiled.css";
10
- import * as React from 'react';
11
- import { ax, ix } from "@compiled/react/runtime";
12
- 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; }
13
- 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; }
14
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
15
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
16
- /// <reference types="node" />
17
- import { Component, createRef } from 'react';
18
- import { isValid, parseISO } from 'date-fns';
19
- import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
20
- import { IconButton } from '@atlaskit/button/new';
21
- import { cx } from '@atlaskit/css';
22
- import { IdProvider } from '@atlaskit/ds-lib/use-id';
23
- import CalendarIcon from '@atlaskit/icon/core/calendar';
24
- import { createLocalizationProvider } from '@atlaskit/locale';
25
- import { Box } from '@atlaskit/primitives/compiled';
26
- import Select, { mergeStyles } from '@atlaskit/select';
27
- import { EmptyComponent } from '../internal';
28
- import { formatDate, getParsedISO, getPlaceholder, isDateDisabled, parseDate } from '../internal/date-picker-migration';
29
- import { IndicatorsContainer as _IndicatorsContainer } from '../internal/indicators-container';
30
- import { Menu } from '../internal/menu';
31
- import { getSafeCalendarValue, getShortISOString } from '../internal/parse-date';
32
- import { makeSingleValue } from '../internal/single-value';
33
- var packageName = "@atlaskit/datetime-picker";
34
- var packageVersion = "0.0.0-development";
35
- var datePickerDefaultProps = {
36
- defaultIsOpen: false,
37
- defaultValue: '',
38
- disabled: [],
39
- disabledDateFilter: function disabledDateFilter(_) {
40
- return false;
41
- },
42
- locale: 'en-US',
43
- // These disables are here for proper typing when used as defaults. They
44
- // should *not* use the `noop` function.
45
- /* eslint-disable @repo/internal/react/use-noop */
46
- onBlur: function onBlur(_event) {},
47
- onChange: function onChange(_value) {},
48
- onFocus: function onFocus(_event) {}
49
- /* eslint-enable @repo/internal/react/use-noop */
50
- // Not including a default prop for value as it will
51
- // Make the component a controlled component
52
- };
53
- var styles = {
54
- pickerContainerStyles: "_kqswh2mm",
55
- iconContainerStyles: "_v564vrg3 _1e0c1txw _4t3i1osq _kqswstnw _4cvr1h6o _i0dl1kw7 _syaz1rpy _152tze3t _rjxpze3t _30l3azsu",
56
- iconSpacingWithClearButtonStyles: "_12l2xy5q",
57
- iconSpacingWithoutClearButtonStyles: "_12l21b66",
58
- dropdownIndicatorStyles: "_1ul91k8s _1tke1k8s _1e0c1txw _4cvr1h6o _1bah1h6o"
59
- };
60
-
61
- // eslint-disable-next-line @repo/internal/react/no-class-components
62
- var DatePickerComponent = /*#__PURE__*/function (_Component) {
63
- function DatePickerComponent(props) {
64
- var _this$props$selectPro2;
65
- var _this;
66
- _classCallCheck(this, DatePickerComponent);
67
- _this = _callSuper(this, DatePickerComponent, [props]);
68
- _defineProperty(_this, "containerRef", null);
69
- _defineProperty(_this, "calendarRef", /*#__PURE__*/createRef());
70
- _defineProperty(_this, "calendarButtonRef", /*#__PURE__*/createRef());
71
- // All state needs to be accessed via this function so that the state is mapped from props
72
- // correctly to allow controlled/uncontrolled usage.
73
- _defineProperty(_this, "getValue", function () {
74
- var _this$props$value;
75
- return (_this$props$value = _this.props.value) !== null && _this$props$value !== void 0 ? _this$props$value : _this.state.value;
76
- });
77
- _defineProperty(_this, "getIsOpen", function () {
78
- var _this$props$isOpen;
79
- return (_this$props$isOpen = _this.props.isOpen) !== null && _this$props$isOpen !== void 0 ? _this$props$isOpen : _this.state.isOpen;
80
- });
81
- _defineProperty(_this, "onCalendarChange", function (_ref) {
82
- var iso = _ref.iso;
83
- _this.setState({
84
- calendarValue: getParsedISO({
85
- iso: iso
86
- })
87
- });
88
- });
89
- _defineProperty(_this, "onCalendarSelect", function (_ref2) {
90
- var iso = _ref2.iso;
91
- _this.setState({
92
- selectInputValue: '',
93
- isOpen: false,
94
- calendarValue: iso,
95
- value: iso,
96
- wasOpenedFromCalendarButton: false
97
- });
98
- _this.props.onChange(iso);
99
-
100
- // Yes, this is not ideal. The alternative is to be able to place a ref
101
- // on the inner input of Select itself, which would require a lot of
102
- // extra stuff in the Select component for only this one thing. While
103
- // this would be more "React-y", it doesn't seem to pose any other
104
- // benefits. Performance-wise, we are only searching within the
105
- // container, so it's quick.
106
- if (_this.state.wasOpenedFromCalendarButton) {
107
- var _this$calendarButtonR;
108
- (_this$calendarButtonR = _this.calendarButtonRef.current) === null || _this$calendarButtonR === void 0 || _this$calendarButtonR.focus();
109
- } else {
110
- var _this$containerRef;
111
- var innerCombobox = (_this$containerRef = _this.containerRef) === null || _this$containerRef === void 0 ? void 0 : _this$containerRef.querySelector('[role="combobox"]');
112
- innerCombobox === null || innerCombobox === void 0 || innerCombobox.focus();
113
- }
114
- _this.setState({
115
- isOpen: false
116
- });
117
- });
118
- _defineProperty(_this, "onInputClick", function () {
119
- if (!_this.props.isDisabled && !_this.getIsOpen()) {
120
- _this.setState({
121
- isOpen: true,
122
- wasOpenedFromCalendarButton: false
123
- });
124
- }
125
- });
126
- _defineProperty(_this, "onContainerBlur", function (event) {
127
- var _this$containerRef2;
128
- var newlyFocusedElement = event.relatedTarget;
129
- if (!((_this$containerRef2 = _this.containerRef) !== null && _this$containerRef2 !== void 0 && _this$containerRef2.contains(newlyFocusedElement))) {
130
- _this.setState({
131
- isOpen: false,
132
- shouldSetFocusOnCurrentDay: false,
133
- wasOpenedFromCalendarButton: false
134
- });
135
- _this.props.onBlur(event);
136
- }
137
- });
138
- _defineProperty(_this, "onContainerFocus", function () {
139
- _this.setState({
140
- shouldSetFocusOnCurrentDay: false
141
- });
142
- });
143
- _defineProperty(_this, "onSelectBlur", function (event) {
144
- var _this$containerRef3;
145
- var newlyFocusedElement = event.relatedTarget;
146
- if (_this.state.clearingFromIcon) {
147
- // Don't close menu if blurring after the user has clicked clear
148
- _this.setState({
149
- clearingFromIcon: false
150
- });
151
- } else if (!((_this$containerRef3 = _this.containerRef) !== null && _this$containerRef3 !== void 0 && _this$containerRef3.contains(newlyFocusedElement))) {
152
- // Don't close menu if focus is staying within the date picker's
153
- // container. Makes keyboard accessibility of calendar possible
154
- _this.setState({
155
- isOpen: false,
156
- isFocused: false,
157
- wasOpenedFromCalendarButton: false
158
- });
159
- }
160
- });
161
- _defineProperty(_this, "onSelectFocus", function (event) {
162
- var clearingFromIcon = _this.state.clearingFromIcon;
163
- var value = _this.getValue();
164
- if (clearingFromIcon) {
165
- // Don't open menu if focussing after the user has clicked clear
166
- _this.setState({
167
- clearingFromIcon: false
168
- });
169
- } else {
170
- _this.setState({
171
- // Don't open when focused into via keyboard if the calendar button is present
172
- isOpen: !_this.props.shouldShowCalendarButton,
173
- calendarValue: value,
174
- isFocused: true,
175
- wasOpenedFromCalendarButton: false
176
- });
177
- }
178
- _this.props.onFocus(event);
179
- });
180
- _defineProperty(_this, "onTextInput", function (event) {
181
- var inputValue = event.target.value;
182
- if (inputValue) {
183
- var parsed = parseDate(inputValue, {
184
- parseInputValue: _this.props.parseInputValue,
185
- dateFormat: _this.props.dateFormat,
186
- l10n: _this.state.l10n
187
- });
188
- // Only try to set the date if we have month & day
189
- if (parsed && isValid(parsed)) {
190
- // We format the parsed date to YYYY-MM-DD here because
191
- // this is the format expected by the @atlaskit/calendar component
192
- _this.setState({
193
- calendarValue: getShortISOString(parsed)
194
- });
195
- }
196
- }
197
- _this.setState({
198
- isOpen: true,
199
- wasOpenedFromCalendarButton: false
200
- });
201
- });
202
- _defineProperty(_this, "onInputKeyDown", function (event) {
203
- var calendarValue = _this.state.calendarValue;
204
- var value = _this.getValue();
205
- var keyPressed = event.key.toLowerCase();
206
-
207
- // If the input is focused and the calendar is not visible, handle space and enter clicks
208
- if (!_this.state.isOpen && (keyPressed === 'enter' || keyPressed === ' ')) {
209
- _this.setState({
210
- isOpen: true,
211
- wasOpenedFromCalendarButton: false
212
- });
213
- }
214
- switch (keyPressed) {
215
- case 'escape':
216
- // Yes, this is not ideal. The alternative is to be able to place a ref
217
- // on the inner input of Select itself, which would require a lot of
218
- // extra stuff in the Select component for only this one thing. While
219
- // this would be more "React-y", it doesn't seem to pose any other
220
- // benefits. Performance-wise, we are only searching within the
221
- // container, so it's quick.
222
- if (_this.state.wasOpenedFromCalendarButton) {
223
- var _this$calendarButtonR2;
224
- (_this$calendarButtonR2 = _this.calendarButtonRef.current) === null || _this$calendarButtonR2 === void 0 || _this$calendarButtonR2.focus();
225
- } else {
226
- var _this$containerRef4;
227
- var innerCombobox = (_this$containerRef4 = _this.containerRef) === null || _this$containerRef4 === void 0 ? void 0 : _this$containerRef4.querySelector('[role="combobox"]');
228
- innerCombobox === null || innerCombobox === void 0 || innerCombobox.focus();
229
- }
230
- _this.setState({
231
- isOpen: false,
232
- shouldSetFocusOnCurrentDay: false,
233
- wasOpenedFromCalendarButton: false
234
- });
235
- break;
236
- case 'backspace':
237
- case 'delete':
238
- {
239
- var inputCount = 0;
240
- if (value && event.target instanceof HTMLInputElement && event.target.value.length <= inputCount) {
241
- // If being cleared from keyboard, don't change behaviour
242
- _this.setState({
243
- clearingFromIcon: false,
244
- value: ''
245
- });
246
- }
247
- break;
248
- }
249
- case 'enter':
250
- if (!_this.state.isOpen) {
251
- return;
252
- }
253
- // Prevent form submission when a date is selected
254
- // using enter. See https://product-fabric.atlassian.net/browse/DSP-2501
255
- // for more details.
256
- event.preventDefault();
257
- if (!isDateDisabled(calendarValue, {
258
- disabled: _this.props.disabled
259
- })) {
260
- // Get a safe `calendarValue` in case the value exceeds the maximum
261
- // allowed by ISO 8601
262
- var safeCalendarValue = getSafeCalendarValue(calendarValue);
263
- var valueChanged = safeCalendarValue !== value;
264
- _this.setState({
265
- selectInputValue: '',
266
- isOpen: false,
267
- value: safeCalendarValue,
268
- calendarValue: safeCalendarValue,
269
- wasOpenedFromCalendarButton: false
270
- });
271
- if (valueChanged) {
272
- _this.props.onChange(safeCalendarValue);
273
- }
274
- }
275
- break;
276
- case 'arrowdown':
277
- case 'arrowup':
278
- if (!_this.state.shouldSetFocusOnCurrentDay) {
279
- _this.setState({
280
- isOpen: true,
281
- shouldSetFocusOnCurrentDay: true
282
- });
283
- }
284
- break;
285
- default:
286
- break;
287
- }
288
- });
289
- _defineProperty(_this, "onCalendarButtonKeyDown", function (e) {
290
- // Don't allow an arrow up or down to open the menu, since the input key
291
- // down handler is actually on the parent.
292
- if (e.type === 'keydown' && (e.key === 'ArrowDown' || e.key === 'ArrowUp')) {
293
- e.stopPropagation();
294
- }
295
- // We want to stop this from triggering other keydown events, particularly
296
- // for space and enter presses. Otherwise, it opens and then closes
297
- // immediately.
298
- if (e.type === 'keydown' && (e.key === ' ' || e.key === 'Enter')) {
299
- e.stopPropagation();
300
- _this.setState({
301
- isKeyDown: true,
302
- wasOpenedFromCalendarButton: true
303
- });
304
- }
305
- });
306
- // This event handler is triggered from both keydown and click. It's weird.
307
- _defineProperty(_this, "onCalendarButtonClick", function (e) {
308
- _this.setState({
309
- isOpen: !_this.state.isOpen,
310
- wasOpenedFromCalendarButton: true
311
- }, function () {
312
- var _this$calendarRef;
313
- // We don't want the focus to move if this is a click event
314
- if (!_this.state.isKeyDown) {
315
- return;
316
- }
317
- _this.setState({
318
- isKeyDown: false
319
- });
320
-
321
- // Focus on the first button within the calendar
322
- (_this$calendarRef = _this.calendarRef) === null || _this$calendarRef === void 0 || (_this$calendarRef = _this$calendarRef.current) === null || _this$calendarRef === void 0 || (_this$calendarRef = _this$calendarRef.querySelector('button')) === null || _this$calendarRef === void 0 || _this$calendarRef.focus();
323
- });
324
- e.stopPropagation();
325
- });
326
- _defineProperty(_this, "onClear", function () {
327
- var changedState = {
328
- value: '',
329
- calendarValue: _this.props.defaultValue || getShortISOString(new Date())
330
- };
331
- if (!_this.props.hideIcon) {
332
- changedState = _objectSpread(_objectSpread({}, changedState), {}, {
333
- clearingFromIcon: true
334
- });
335
- }
336
- _this.setState(changedState);
337
- _this.props.onChange('');
338
- });
339
- // `unknown` is used because `value` is unused so it does not matter.
340
- _defineProperty(_this, "onSelectChange", function (_value, action) {
341
- // Used for native clear event in React Select
342
- // Triggered when clicking ClearIndicator or backspace with no value
343
- if (action.action === 'clear') {
344
- _this.onClear();
345
- }
346
- });
347
- _defineProperty(_this, "handleSelectInputChange", function (selectInputValue, actionMeta) {
348
- var _this$props$selectPro;
349
- var onInputChange = (_this$props$selectPro = _this.props.selectProps) === null || _this$props$selectPro === void 0 ? void 0 : _this$props$selectPro.onInputChange;
350
- if (onInputChange) {
351
- onInputChange(selectInputValue, actionMeta);
352
- }
353
- _this.setState({
354
- selectInputValue: selectInputValue
355
- });
356
- });
357
- _defineProperty(_this, "getContainerRef", function (ref) {
358
- var oldRef = _this.containerRef;
359
- _this.containerRef = ref;
360
- // Cause a re-render if we're getting the container ref for the first time
361
- // as the layered menu requires it for dimension calculation
362
- if (oldRef == null && ref != null) {
363
- _this.forceUpdate();
364
- }
365
- });
366
- _this.state = {
367
- isKeyDown: false,
368
- isOpen: _this.props.defaultIsOpen,
369
- isFocused: false,
370
- clearingFromIcon: false,
371
- selectInputValue: ((_this$props$selectPro2 = _this.props.selectProps) === null || _this$props$selectPro2 === void 0 ? void 0 : _this$props$selectPro2.inputValue) || '',
372
- value: _this.props.value || _this.props.defaultValue,
373
- calendarValue: _this.props.value || _this.props.defaultValue || getShortISOString(new Date()),
374
- l10n: createLocalizationProvider(_this.props.locale),
375
- locale: _this.props.locale,
376
- shouldSetFocusOnCurrentDay: false,
377
- wasOpenedFromCalendarButton: false
378
- };
379
- return _this;
380
- }
381
- _inherits(DatePickerComponent, _Component);
382
- return _createClass(DatePickerComponent, [{
383
- key: "render",
384
- value: function render() {
385
- var _this2 = this;
386
- var _this$props = this.props,
387
- _this$props$appearanc = _this$props.appearance,
388
- appearance = _this$props$appearanc === void 0 ? 'default' : _this$props$appearanc,
389
- ariaDescribedBy = _this$props['aria-describedby'],
390
- _this$props$autoFocus = _this$props.autoFocus,
391
- autoFocus = _this$props$autoFocus === void 0 ? false : _this$props$autoFocus,
392
- _this$props$clearCont = _this$props.clearControlLabel,
393
- clearControlLabel = _this$props$clearCont === void 0 ? 'Clear' : _this$props$clearCont,
394
- _this$props$hideIcon = _this$props.hideIcon,
395
- hideIcon = _this$props$hideIcon === void 0 ? false : _this$props$hideIcon,
396
- _this$props$openCalen = _this$props.openCalendarLabel,
397
- openCalendarLabel = _this$props$openCalen === void 0 ? 'Open calendar' : _this$props$openCalen,
398
- disabled = _this$props.disabled,
399
- disabledDateFilter = _this$props.disabledDateFilter,
400
- _this$props$icon = _this$props.icon,
401
- Icon = _this$props$icon === void 0 ? CalendarIcon : _this$props$icon,
402
- _this$props$id = _this$props.id,
403
- id = _this$props$id === void 0 ? '' : _this$props$id,
404
- _this$props$innerProp = _this$props.innerProps,
405
- innerProps = _this$props$innerProp === void 0 ? {} : _this$props$innerProp,
406
- _this$props$inputLabe = _this$props.inputLabel,
407
- inputLabel = _this$props$inputLabe === void 0 ? 'Date picker' : _this$props$inputLabe,
408
- inputLabelId = _this$props.inputLabelId,
409
- _this$props$isDisable = _this$props.isDisabled,
410
- isDisabled = _this$props$isDisable === void 0 ? false : _this$props$isDisable,
411
- _this$props$isInvalid = _this$props.isInvalid,
412
- isInvalid = _this$props$isInvalid === void 0 ? false : _this$props$isInvalid,
413
- _this$props$isRequire = _this$props.isRequired,
414
- isRequired = _this$props$isRequire === void 0 ? false : _this$props$isRequire,
415
- _this$props$label = _this$props.label,
416
- label = _this$props$label === void 0 ? '' : _this$props$label,
417
- locale = _this$props.locale,
418
- maxDate = _this$props.maxDate,
419
- minDate = _this$props.minDate,
420
- _this$props$name = _this$props.name,
421
- name = _this$props$name === void 0 ? '' : _this$props$name,
422
- nextMonthLabel = _this$props.nextMonthLabel,
423
- previousMonthLabel = _this$props.previousMonthLabel,
424
- _this$props$selectPro3 = _this$props.selectProps,
425
- selectProps = _this$props$selectPro3 === void 0 ? {} : _this$props$selectPro3,
426
- shouldShowCalendarButton = _this$props.shouldShowCalendarButton,
427
- _this$props$spacing = _this$props.spacing,
428
- spacing = _this$props$spacing === void 0 ? 'default' : _this$props$spacing,
429
- testId = _this$props.testId,
430
- weekStartDay = _this$props.weekStartDay;
431
- var _this$state = this.state,
432
- calendarValue = _this$state.calendarValue,
433
- selectInputValue = _this$state.selectInputValue;
434
- var value = this.getValue();
435
- var actualSelectInputValue;
436
- actualSelectInputValue = selectInputValue;
437
- var menuIsOpen = this.getIsOpen() && !isDisabled;
438
- var showClearIndicator = Boolean((value || selectInputValue) && !hideIcon);
439
- var clearIndicator = function clearIndicator(props) {
440
- return /*#__PURE__*/React.createElement(Box, {
441
- xcss: styles.dropdownIndicatorStyles
442
- }, /*#__PURE__*/React.createElement(Icon, props));
443
- };
444
- var dropDownIcon = appearance === 'subtle' || hideIcon || showClearIndicator ? null : clearIndicator;
445
- var selectComponents = _objectSpread(_objectSpread(_objectSpread({
446
- DropdownIndicator: shouldShowCalendarButton ? EmptyComponent : dropDownIcon
447
- }, shouldShowCalendarButton ? {
448
- IndicatorsContainer: function IndicatorsContainer(props) {
449
- return /*#__PURE__*/React.createElement(_IndicatorsContainer, _extends({}, props, {
450
- showClearIndicator: showClearIndicator
451
- }));
452
- }
453
- } : {}), {}, {
454
- Menu: Menu
455
- }, !showClearIndicator && {
456
- ClearIndicator: EmptyComponent
457
- }), selectProps.components);
458
- var _selectProps$styles = selectProps.styles,
459
- selectStyles = _selectProps$styles === void 0 ? {} : _selectProps$styles;
460
- var disabledStyle = isDisabled ? {
461
- pointerEvents: 'none',
462
- color: "var(--ds-icon-disabled, inherit)"
463
- } : {};
464
- var calendarProps = {
465
- calendarContainerRef: this.containerRef,
466
- calendarDisabled: disabled,
467
- calendarDisabledDateFilter: disabledDateFilter,
468
- calendarMaxDate: maxDate,
469
- calendarMinDate: minDate,
470
- calendarRef: this.calendarRef,
471
- calendarValue: value && getShortISOString(parseISO(value)),
472
- calendarView: calendarValue,
473
- onCalendarChange: this.onCalendarChange,
474
- onCalendarSelect: this.onCalendarSelect,
475
- calendarLocale: locale,
476
- calendarWeekStartDay: weekStartDay,
477
- shouldSetFocusOnCurrentDay: this.state.shouldSetFocusOnCurrentDay,
478
- menuInnerWrapper: this.props.menuInnerWrapper
479
- };
480
-
481
- // @ts-ignore -- Argument of type 'StylesConfig<OptionType, false, GroupBase<OptionType>>' is not assignable to parameter of type 'StylesConfig<OptionType, boolean, GroupBase<OptionType>>'.
482
- var mergedStyles = mergeStyles(selectStyles, {
483
- control: function control(base) {
484
- return _objectSpread(_objectSpread({}, base), disabledStyle);
485
- },
486
- indicatorsContainer: function indicatorsContainer(base) {
487
- return _objectSpread(_objectSpread({}, base), {}, {
488
- paddingLeft: "var(--ds-space-025, 2px)",
489
- // ICON_PADDING = 2
490
- paddingRight: "var(--ds-space-075, 6px)" // 8 - ICON_PADDING = 6
491
- });
492
- }
493
- });
494
- var initialValue = value ? {
495
- label: formatDate(value, {
496
- formatDisplayLabel: this.props.formatDisplayLabel,
497
- dateFormat: this.props.dateFormat,
498
- l10n: this.state.l10n
499
- }),
500
- value: value
501
- } : null;
502
-
503
- // `label` takes precedence of the `inputLabel`
504
- var fullopenCalendarLabel = label || inputLabel ? "".concat(label || inputLabel, ", ").concat(openCalendarLabel) : openCalendarLabel;
505
- return /*#__PURE__*/React.createElement("div", _extends({}, innerProps, {
506
- // Since the onclick, onfocus are passed down, adding role="presentation" prevents typecheck errors.
507
- role: "presentation",
508
- onBlur: this.onContainerBlur,
509
- onFocus: this.onContainerFocus,
510
- onClick: this.onInputClick,
511
- onInput: this.onTextInput,
512
- onKeyDown: this.onInputKeyDown,
513
- ref: this.getContainerRef,
514
- "data-testid": testId && "".concat(testId, "--container"),
515
- className: ax([styles.pickerContainerStyles])
516
- }), /*#__PURE__*/React.createElement("input", {
517
- name: name,
518
- type: "hidden",
519
- value: value,
520
- "data-testid": testId && "".concat(testId, "--input")
521
- }), /*#__PURE__*/React.createElement(IdProvider, null, function (_ref3) {
522
- var valueId = _ref3.id;
523
- return /*#__PURE__*/React.createElement(Select, _extends({
524
- appearance: _this2.props.appearance,
525
- "aria-describedby": ariaDescribedBy ? "".concat(ariaDescribedBy, " ").concat(valueId) : valueId,
526
- label: label || undefined,
527
- autoFocus: autoFocus,
528
- clearControlLabel: clearControlLabel,
529
- closeMenuOnSelect: true,
530
- enableAnimation: false,
531
- inputId: id,
532
- inputValue: actualSelectInputValue,
533
- isDisabled: isDisabled,
534
- isRequired: isRequired,
535
- menuIsOpen: menuIsOpen,
536
- onBlur: _this2.onSelectBlur,
537
- onChange: _this2.onSelectChange,
538
- onFocus: _this2.onSelectFocus,
539
- onInputChange: _this2.handleSelectInputChange,
540
- placeholder: getPlaceholder({
541
- placeholder: _this2.props.placeholder,
542
- l10n: _this2.state.l10n
543
- })
544
- // @ts-ignore -- Argument of type 'StylesConfig<OptionType, false, GroupBase<OptionType>>' is not assignable to parameter of type 'StylesConfig<OptionType, boolean, GroupBase<OptionType>>'
545
- ,
546
- styles: mergedStyles,
547
- value: initialValue
548
- }, selectProps, {
549
- // For some reason, this and the below `styles` type error _only_ show
550
- // up when you alter some of the properties in the `selectComponents`
551
- // object. These errors are still present, and I suspect have always
552
- // been present, without changing the unrelated code. Ignoring as the
553
- // component still works as expected despite this error. And also
554
- // because the select refresh team may solve it later.
555
- components: _objectSpread(_objectSpread({}, selectComponents), {}, {
556
- SingleValue: makeSingleValue({
557
- id: valueId,
558
- lang: _this2.props.locale
559
- })
560
- })
561
- // These are below the spread because I don't know what is in
562
- // selectProps or not and what wil be overwritten
563
- ,
564
- isClearable: true,
565
- isInvalid: isInvalid,
566
- spacing: spacing,
567
- testId: testId
568
- // These aren't part of `Select`'s API, but we're using them here.
569
- // @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<...> & { ...; }>'.
570
- ,
571
- calendarContainerRef: calendarProps.calendarContainerRef,
572
- calendarDisabled: calendarProps.calendarDisabled,
573
- calendarDisabledDateFilter: calendarProps.calendarDisabledDateFilter,
574
- calendarLocale: calendarProps.calendarLocale,
575
- calendarMaxDate: calendarProps.calendarMaxDate,
576
- calendarMinDate: calendarProps.calendarMinDate,
577
- calendarRef: calendarProps.calendarRef,
578
- calendarValue: calendarProps.calendarValue,
579
- calendarView: calendarProps.calendarView,
580
- calendarWeekStartDay: calendarProps.calendarWeekStartDay,
581
- nextMonthLabel: nextMonthLabel,
582
- onCalendarChange: calendarProps.onCalendarChange,
583
- onCalendarSelect: calendarProps.onCalendarSelect,
584
- previousMonthLabel: previousMonthLabel,
585
- shouldSetFocusOnCurrentDay: calendarProps.shouldSetFocusOnCurrentDay,
586
- menuInnerWrapper: calendarProps.menuInnerWrapper
587
- }));
588
- }), shouldShowCalendarButton && !isDisabled ? /*#__PURE__*/React.createElement(IdProvider, {
589
- prefix: "open-calendar-label--"
590
- }, function (_ref4) {
591
- var openCalendarLabelId = _ref4.id;
592
- return /*#__PURE__*/React.createElement(Box, {
593
- xcss: cx(styles.iconContainerStyles, value && !hideIcon ? styles.iconSpacingWithClearButtonStyles : styles.iconSpacingWithoutClearButtonStyles)
594
- }, /*#__PURE__*/React.createElement(IconButton, {
595
- appearance: "subtle",
596
- label: !inputLabelId ? fullopenCalendarLabel : openCalendarLabel,
597
- "aria-labelledby": inputLabelId ? "".concat(inputLabelId, " ").concat(openCalendarLabelId) : undefined,
598
- id: openCalendarLabelId,
599
- icon: function icon(iconProps) {
600
- return /*#__PURE__*/React.createElement(CalendarIcon, _extends({}, iconProps, {
601
- color: "var(--ds-icon, #292A2E)"
602
- }));
603
- },
604
- onClick: _this2.onCalendarButtonClick,
605
- onKeyDown: _this2.onCalendarButtonKeyDown,
606
- ref: _this2.calendarButtonRef,
607
- testId: testId && "".concat(testId, "--open-calendar-button")
608
- }));
609
- }) : null);
610
- }
611
- }], [{
612
- key: "getDerivedStateFromProps",
613
- value: function getDerivedStateFromProps(nextProps, prevState) {
614
- if (nextProps.locale !== prevState.locale) {
615
- return {
616
- l10n: createLocalizationProvider(nextProps.locale),
617
- locale: nextProps.locale
618
- };
619
- } else {
620
- return null;
621
- }
622
- }
623
- }]);
624
- }(Component);
625
- _defineProperty(DatePickerComponent, "defaultProps", datePickerDefaultProps);
626
- export { DatePickerComponent as DatePickerWithoutAnalytics };
627
-
628
- /**
629
- * __Date picker__
630
- *
631
- * A date picker allows the user to select a particular date.
632
- *
633
- * - [Examples](https://atlassian.design/components/datetime-picker/date-picker/examples)
634
- * - [Code](https://atlassian.design/components/datetime-picker/date-picker/code)
635
- * - [Usage](https://atlassian.design/components/datetime-picker/date-picker/usage)
636
- */
637
- var DatePicker = withAnalyticsContext({
638
- componentName: 'datePicker',
639
- packageName: packageName,
640
- packageVersion: packageVersion
641
- })(withAnalyticsEvents({
642
- onChange: createAndFireEvent('atlaskit')({
643
- action: 'selectedDate',
644
- actionSubject: 'datePicker',
645
- attributes: {
646
- componentName: 'datePicker',
647
- packageName: packageName,
648
- packageVersion: packageVersion
649
- }
650
- })
651
- })(DatePickerComponent));
652
- export default DatePicker;
@@ -1,16 +0,0 @@
1
-
2
- ._v564vrg3{transition:color .15s}._12l21b66{margin-inline-end:var(--ds-space-050,4px)}
3
- ._12l2xy5q{margin-inline-end:var(--ds-space-400,2pc)}
4
- ._152tze3t{inset-block-start:var(--ds-space-0,0)}
5
- ._1bah1h6o{justify-content:center}
6
- ._1e0c1txw{display:flex}
7
- ._1tke1k8s{min-height:1.5rem}
8
- ._1ul91k8s{min-width:1.5rem}
9
- ._4cvr1h6o{align-items:center}
10
- ._4t3i1osq{height:100%}
11
- ._i0dl1kw7{flex-basis:inherit}
12
- ._kqswh2mm{position:relative}
13
- ._kqswstnw{position:absolute}
14
- ._rjxpze3t{inset-inline-end:var(--ds-space-0,0)}
15
- ._syaz1rpy{color:var(--ds-text-subtlest,#6b6e76)}
16
- ._30l3azsu:hover{color:var(--ds-text-subtle,#505258)}