@atlaskit/datetime-picker 16.2.3 → 17.0.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 +18 -0
- package/dist/cjs/components/date-picker-class.compiled.css +16 -0
- package/dist/cjs/components/date-picker-class.js +118 -144
- package/dist/cjs/components/date-picker-fc.compiled.css +16 -0
- package/dist/cjs/components/date-picker-fc.js +115 -142
- package/dist/cjs/components/date-time-picker-class.compiled.css +19 -0
- package/dist/cjs/components/date-time-picker-class.js +22 -47
- package/dist/cjs/components/date-time-picker-fc.compiled.css +6 -0
- package/dist/cjs/components/date-time-picker-fc.js +22 -27
- package/dist/cjs/components/time-picker.js +1 -1
- package/dist/cjs/internal/date-time-picker-container.compiled.css +21 -0
- package/dist/cjs/internal/date-time-picker-container.js +26 -71
- package/dist/cjs/internal/fixed-layer-menu.js +8 -8
- package/dist/cjs/internal/fixed-layer.compiled.css +4 -0
- package/dist/cjs/internal/fixed-layer.js +14 -13
- package/dist/cjs/internal/indicators-container.compiled.css +2 -0
- package/dist/cjs/internal/indicators-container.js +14 -15
- package/dist/cjs/internal/menu.compiled.css +6 -0
- package/dist/cjs/internal/menu.js +15 -32
- package/dist/es2019/components/date-picker-class.compiled.css +16 -0
- package/dist/es2019/components/date-picker-class.js +113 -142
- package/dist/es2019/components/date-picker-fc.compiled.css +16 -0
- package/dist/es2019/components/date-picker-fc.js +112 -140
- package/dist/es2019/components/date-time-picker-class.compiled.css +19 -0
- package/dist/es2019/components/date-time-picker-class.js +21 -49
- package/dist/es2019/components/date-time-picker-fc.compiled.css +6 -0
- package/dist/es2019/components/date-time-picker-fc.js +19 -24
- package/dist/es2019/components/time-picker.js +1 -1
- package/dist/es2019/internal/date-time-picker-container.compiled.css +21 -0
- package/dist/es2019/internal/date-time-picker-container.js +18 -69
- package/dist/es2019/internal/fixed-layer-menu.js +5 -8
- package/dist/es2019/internal/fixed-layer.compiled.css +4 -0
- package/dist/es2019/internal/fixed-layer.js +13 -12
- package/dist/es2019/internal/indicators-container.compiled.css +2 -0
- package/dist/es2019/internal/indicators-container.js +11 -16
- package/dist/es2019/internal/menu.compiled.css +6 -0
- package/dist/es2019/internal/menu.js +11 -30
- package/dist/esm/components/date-picker-class.compiled.css +16 -0
- package/dist/esm/components/date-picker-class.js +116 -145
- package/dist/esm/components/date-picker-fc.compiled.css +16 -0
- package/dist/esm/components/date-picker-fc.js +114 -142
- package/dist/esm/components/date-time-picker-class.compiled.css +19 -0
- package/dist/esm/components/date-time-picker-class.js +21 -49
- package/dist/esm/components/date-time-picker-fc.compiled.css +6 -0
- package/dist/esm/components/date-time-picker-fc.js +19 -24
- package/dist/esm/components/time-picker.js +1 -1
- package/dist/esm/internal/date-time-picker-container.compiled.css +21 -0
- package/dist/esm/internal/date-time-picker-container.js +22 -69
- package/dist/esm/internal/fixed-layer-menu.js +5 -8
- package/dist/esm/internal/fixed-layer.compiled.css +4 -0
- package/dist/esm/internal/fixed-layer.js +13 -13
- package/dist/esm/internal/indicators-container.compiled.css +2 -0
- package/dist/esm/internal/indicators-container.js +11 -16
- package/dist/esm/internal/menu.compiled.css +6 -0
- package/dist/esm/internal/menu.js +11 -30
- package/dist/types/components/date-picker-class.d.ts +2 -3
- package/dist/types/components/date-picker.d.ts +1 -1
- package/dist/types/components/date-time-picker-class.d.ts +4 -5
- package/dist/types/components/date-time-picker.d.ts +3 -3
- package/dist/types/internal/date-time-picker-container.d.ts +4 -0
- package/dist/types/internal/fixed-layer-menu.d.ts +2 -6
- package/dist/types/internal/fixed-layer.d.ts +5 -1
- package/dist/types/internal/indicators-container.d.ts +2 -2
- package/dist/types/internal/menu.d.ts +6 -2
- package/dist/types-ts4.5/components/date-picker-class.d.ts +2 -3
- package/dist/types-ts4.5/components/date-picker.d.ts +1 -1
- package/dist/types-ts4.5/components/date-time-picker-class.d.ts +4 -5
- package/dist/types-ts4.5/components/date-time-picker.d.ts +3 -3
- package/dist/types-ts4.5/internal/date-time-picker-container.d.ts +4 -0
- package/dist/types-ts4.5/internal/fixed-layer-menu.d.ts +2 -6
- package/dist/types-ts4.5/internal/fixed-layer.d.ts +5 -1
- package/dist/types-ts4.5/internal/indicators-container.d.ts +2 -2
- package/dist/types-ts4.5/internal/menu.d.ts +6 -2
- package/package.json +10 -10
|
@@ -1,21 +1,19 @@
|
|
|
1
|
+
/* date-picker-class.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
1
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
*/
|
|
4
|
+
import "./date-picker-class.compiled.css";
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
7
7
|
import { Component, createRef } from 'react';
|
|
8
|
-
|
|
9
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
10
|
-
import { css, jsx } from '@emotion/react';
|
|
11
8
|
import { isValid, parseISO } from 'date-fns';
|
|
12
9
|
import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
13
10
|
import { IconButton } from '@atlaskit/button/new';
|
|
11
|
+
import { cx } from '@atlaskit/css';
|
|
14
12
|
import { IdProvider } from '@atlaskit/ds-lib/use-id';
|
|
15
13
|
import CalendarIcon from '@atlaskit/icon/core/migration/calendar';
|
|
16
14
|
import { createLocalizationProvider } from '@atlaskit/locale';
|
|
17
15
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
18
|
-
import { Box
|
|
16
|
+
import { Box } from '@atlaskit/primitives/compiled';
|
|
19
17
|
import Select, { mergeStyles } from '@atlaskit/select';
|
|
20
18
|
import { EmptyComponent } from '../internal';
|
|
21
19
|
import { formatDate, getParsedISO, getPlaceholder, isDateDisabled, parseDate } from '../internal/date-picker-migration';
|
|
@@ -24,14 +22,7 @@ import { Menu } from '../internal/menu';
|
|
|
24
22
|
import { getSafeCalendarValue, getShortISOString } from '../internal/parse-date';
|
|
25
23
|
import { makeSingleValue } from '../internal/single-value';
|
|
26
24
|
const packageName = "@atlaskit/datetime-picker";
|
|
27
|
-
const packageVersion = "
|
|
28
|
-
const dropdownIndicatorStyles = xcss({
|
|
29
|
-
minWidth: "var(--ds-space-300, 24px)",
|
|
30
|
-
minHeight: "var(--ds-space-300, 24px)",
|
|
31
|
-
display: 'flex',
|
|
32
|
-
alignItems: 'center',
|
|
33
|
-
justifyContent: 'center'
|
|
34
|
-
});
|
|
25
|
+
const packageVersion = "17.0.0";
|
|
35
26
|
const datePickerDefaultProps = {
|
|
36
27
|
defaultIsOpen: false,
|
|
37
28
|
defaultValue: '',
|
|
@@ -48,29 +39,13 @@ const datePickerDefaultProps = {
|
|
|
48
39
|
// Not including a default prop for value as it will
|
|
49
40
|
// Make the component a controlled component
|
|
50
41
|
};
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
alignItems: 'center',
|
|
59
|
-
flexBasis: 'inherit',
|
|
60
|
-
color: 'color.text.subtlest',
|
|
61
|
-
insetBlockStart: 'space.0',
|
|
62
|
-
insetInlineEnd: 'space.0',
|
|
63
|
-
transition: `color 150ms`,
|
|
64
|
-
':hover': {
|
|
65
|
-
color: 'color.text.subtle'
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
const iconSpacingWithClearButtonStyles = xcss({
|
|
69
|
-
marginInlineEnd: 'space.400'
|
|
70
|
-
});
|
|
71
|
-
const iconSpacingWithoutClearButtonStyles = xcss({
|
|
72
|
-
marginInlineEnd: 'space.050'
|
|
73
|
-
});
|
|
42
|
+
const styles = {
|
|
43
|
+
pickerContainerStyles: "_kqswh2mm",
|
|
44
|
+
iconContainerStyles: "_v564vrg3 _1e0c1txw _4t3i1osq _kqswstnw _4cvr1h6o _i0dl1kw7 _syaz131l _152tze3t _rjxpze3t _30l31gjq",
|
|
45
|
+
iconSpacingWithClearButtonStyles: "_12l2xy5q",
|
|
46
|
+
iconSpacingWithoutClearButtonStyles: "_12l21b66",
|
|
47
|
+
dropdownIndicatorStyles: "_1ul91k8s _1tke1k8s _1e0c1txw _4cvr1h6o _1bah1h6o"
|
|
48
|
+
};
|
|
74
49
|
|
|
75
50
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
76
51
|
class DatePickerComponent extends Component {
|
|
@@ -448,11 +423,11 @@ class DatePickerComponent extends Component {
|
|
|
448
423
|
const showClearIndicator = Boolean((value || selectInputValue) && !hideIcon);
|
|
449
424
|
let clearIndicator = Icon;
|
|
450
425
|
|
|
451
|
-
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
426
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning, @atlaskit/platform/ensure-feature-flag-prefix
|
|
452
427
|
if (fg('platform-visual-refresh-icons')) {
|
|
453
|
-
clearIndicator = props =>
|
|
454
|
-
xcss: dropdownIndicatorStyles
|
|
455
|
-
},
|
|
428
|
+
clearIndicator = props => /*#__PURE__*/React.createElement(Box, {
|
|
429
|
+
xcss: styles.dropdownIndicatorStyles
|
|
430
|
+
}, /*#__PURE__*/React.createElement(Icon, props));
|
|
456
431
|
}
|
|
457
432
|
const dropDownIcon = appearance === 'subtle' || hideIcon || showClearIndicator ? null : clearIndicator;
|
|
458
433
|
const SingleValue = makeSingleValue({
|
|
@@ -463,7 +438,7 @@ class DatePickerComponent extends Component {
|
|
|
463
438
|
// Only use this new container component if the calendar button is shown.
|
|
464
439
|
// Otherwise, it throws errors downstream for some reason
|
|
465
440
|
...(shouldShowCalendarButton ? {
|
|
466
|
-
IndicatorsContainer: props =>
|
|
441
|
+
IndicatorsContainer: props => /*#__PURE__*/React.createElement(IndicatorsContainer, _extends({}, props, {
|
|
467
442
|
showClearIndicator: showClearIndicator
|
|
468
443
|
}))
|
|
469
444
|
} : {}),
|
|
@@ -521,104 +496,100 @@ class DatePickerComponent extends Component {
|
|
|
521
496
|
|
|
522
497
|
// `label` takes precedence of the `inputLabel`
|
|
523
498
|
const fullopenCalendarLabel = label || inputLabel ? `${label || inputLabel}, ${openCalendarLabel}` : openCalendarLabel;
|
|
524
|
-
return (
|
|
525
|
-
//
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
"
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
ref: this.calendarButtonRef,
|
|
619
|
-
testId: testId && `${testId}--open-calendar-button`
|
|
620
|
-
}))) : null)
|
|
621
|
-
);
|
|
499
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, innerProps, {
|
|
500
|
+
// Since the onclick, onfocus are passed down, adding role="presentation" prevents typecheck errors.
|
|
501
|
+
role: "presentation",
|
|
502
|
+
onBlur: this.onContainerBlur,
|
|
503
|
+
onFocus: this.onContainerFocus,
|
|
504
|
+
onClick: this.onInputClick,
|
|
505
|
+
onInput: this.onTextInput,
|
|
506
|
+
onKeyDown: this.onInputKeyDown,
|
|
507
|
+
ref: this.getContainerRef,
|
|
508
|
+
"data-testid": testId && `${testId}--container`,
|
|
509
|
+
className: ax([styles.pickerContainerStyles])
|
|
510
|
+
}), /*#__PURE__*/React.createElement("input", {
|
|
511
|
+
name: name,
|
|
512
|
+
type: "hidden",
|
|
513
|
+
value: value,
|
|
514
|
+
"data-testid": testId && `${testId}--input`
|
|
515
|
+
}), /*#__PURE__*/React.createElement(Select, _extends({
|
|
516
|
+
appearance: this.props.appearance,
|
|
517
|
+
"aria-describedby": ariaDescribedBy,
|
|
518
|
+
label: label || undefined
|
|
519
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
520
|
+
,
|
|
521
|
+
autoFocus: autoFocus,
|
|
522
|
+
clearControlLabel: clearControlLabel,
|
|
523
|
+
closeMenuOnSelect: true
|
|
524
|
+
// FOr some reason, this and the below `styles` type error _only_ show
|
|
525
|
+
// up when you alter some of the properties in the `selectComponents`
|
|
526
|
+
// object. These errors are still present, and I suspect have always
|
|
527
|
+
// been present, without changing the unrelated code. Ignoring as the
|
|
528
|
+
// component still works as expected despite this error. And also
|
|
529
|
+
// because the select refresh team may solve it later.
|
|
530
|
+
,
|
|
531
|
+
components: selectComponents,
|
|
532
|
+
enableAnimation: false,
|
|
533
|
+
inputId: id,
|
|
534
|
+
inputValue: actualSelectInputValue,
|
|
535
|
+
isDisabled: isDisabled,
|
|
536
|
+
isRequired: isRequired,
|
|
537
|
+
menuIsOpen: menuIsOpen,
|
|
538
|
+
onBlur: this.onSelectBlur,
|
|
539
|
+
onChange: this.onSelectChange,
|
|
540
|
+
onFocus: this.onSelectFocus,
|
|
541
|
+
onInputChange: this.handleSelectInputChange,
|
|
542
|
+
placeholder: getPlaceholder({
|
|
543
|
+
placeholder: this.props.placeholder,
|
|
544
|
+
l10n: this.state.l10n
|
|
545
|
+
}),
|
|
546
|
+
styles: mergedStyles,
|
|
547
|
+
value: initialValue
|
|
548
|
+
}, selectProps, {
|
|
549
|
+
// These are below the spread because I don't know what is in
|
|
550
|
+
// selectProps or not and what wil be overwritten
|
|
551
|
+
isClearable: true,
|
|
552
|
+
isInvalid: isInvalid,
|
|
553
|
+
spacing: spacing,
|
|
554
|
+
testId: testId
|
|
555
|
+
// These aren't part of `Select`'s API, but we're using them here.
|
|
556
|
+
// @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<...> & { ...; }>'.
|
|
557
|
+
,
|
|
558
|
+
calendarContainerRef: calendarProps.calendarContainerRef,
|
|
559
|
+
calendarDisabled: calendarProps.calendarDisabled,
|
|
560
|
+
calendarDisabledDateFilter: calendarProps.calendarDisabledDateFilter,
|
|
561
|
+
calendarLocale: calendarProps.calendarLocale,
|
|
562
|
+
calendarMaxDate: calendarProps.calendarMaxDate,
|
|
563
|
+
calendarMinDate: calendarProps.calendarMinDate,
|
|
564
|
+
calendarRef: calendarProps.calendarRef,
|
|
565
|
+
calendarValue: calendarProps.calendarValue,
|
|
566
|
+
calendarView: calendarProps.calendarView,
|
|
567
|
+
calendarWeekStartDay: calendarProps.calendarWeekStartDay,
|
|
568
|
+
nextMonthLabel: nextMonthLabel,
|
|
569
|
+
onCalendarChange: calendarProps.onCalendarChange,
|
|
570
|
+
onCalendarSelect: calendarProps.onCalendarSelect,
|
|
571
|
+
previousMonthLabel: previousMonthLabel,
|
|
572
|
+
shouldSetFocusOnCurrentDay: calendarProps.shouldSetFocusOnCurrentDay,
|
|
573
|
+
menuInnerWrapper: calendarProps.menuInnerWrapper
|
|
574
|
+
})), shouldShowCalendarButton && !isDisabled ? /*#__PURE__*/React.createElement(IdProvider, {
|
|
575
|
+
prefix: "open-calendar-label--"
|
|
576
|
+
}, ({
|
|
577
|
+
id: openCalendarLabelId
|
|
578
|
+
}) => /*#__PURE__*/React.createElement(Box, {
|
|
579
|
+
xcss: cx(styles.iconContainerStyles, value && !hideIcon ? styles.iconSpacingWithClearButtonStyles : styles.iconSpacingWithoutClearButtonStyles)
|
|
580
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
581
|
+
appearance: "subtle",
|
|
582
|
+
label: !inputLabelId ? fullopenCalendarLabel : openCalendarLabel,
|
|
583
|
+
"aria-labelledby": inputLabelId ? `${inputLabelId} ${openCalendarLabelId}` : undefined,
|
|
584
|
+
id: openCalendarLabelId,
|
|
585
|
+
icon: iconProps => /*#__PURE__*/React.createElement(CalendarIcon, _extends({}, iconProps, {
|
|
586
|
+
color: "var(--ds-icon, #44546F)"
|
|
587
|
+
})),
|
|
588
|
+
onClick: this.onCalendarButtonClick,
|
|
589
|
+
onKeyDown: this.onCalendarButtonKeyDown,
|
|
590
|
+
ref: this.calendarButtonRef,
|
|
591
|
+
testId: testId && `${testId}--open-calendar-button`
|
|
592
|
+
}))) : null);
|
|
622
593
|
}
|
|
623
594
|
}
|
|
624
595
|
_defineProperty(DatePickerComponent, "defaultProps", datePickerDefaultProps);
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
._syaz131l{color:var(--ds-text-subtlest,#626f86)}
|
|
16
|
+
._30l31gjq:hover{color:var(--ds-text-subtle,#44546f)}
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
+
/* date-picker-fc.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
1
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
*/
|
|
3
|
+
import "./date-picker-fc.compiled.css";
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
6
6
|
import { forwardRef, useCallback, useEffect, useReducer, useRef, useState } from 'react';
|
|
7
|
-
|
|
8
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
9
|
-
import { css, jsx } from '@emotion/react';
|
|
10
7
|
import { isValid, parseISO } from 'date-fns';
|
|
11
8
|
import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
|
|
12
9
|
import { IconButton } from '@atlaskit/button/new';
|
|
10
|
+
import { cx } from '@atlaskit/css';
|
|
13
11
|
import { useId } from '@atlaskit/ds-lib/use-id';
|
|
14
12
|
import CalendarIcon from '@atlaskit/icon/core/migration/calendar';
|
|
15
13
|
import { createLocalizationProvider } from '@atlaskit/locale';
|
|
16
14
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
17
|
-
import { Box
|
|
15
|
+
import { Box } from '@atlaskit/primitives/compiled';
|
|
18
16
|
import Select, { mergeStyles } from '@atlaskit/select';
|
|
19
17
|
import { EmptyComponent } from '../internal';
|
|
20
18
|
import { formatDate, getParsedISO, getPlaceholder, isDateDisabled, parseDate } from '../internal/date-picker-migration';
|
|
@@ -23,42 +21,19 @@ import { Menu } from '../internal/menu';
|
|
|
23
21
|
import { getSafeCalendarValue, getShortISOString } from '../internal/parse-date';
|
|
24
22
|
import { makeSingleValue } from '../internal/single-value';
|
|
25
23
|
const packageName = "@atlaskit/datetime-picker";
|
|
26
|
-
const packageVersion = "
|
|
24
|
+
const packageVersion = "17.0.0";
|
|
25
|
+
const styles = {
|
|
26
|
+
pickerContainerStyle: "_kqswh2mm",
|
|
27
|
+
dropdownIndicatorStyles: "_1ul91k8s _1tke1k8s _1e0c1txw _4cvr1h6o _1bah1h6o",
|
|
28
|
+
iconContainerStyles: "_v564vrg3 _1e0c1txw _4t3i1osq _kqswstnw _4cvr1h6o _i0dl1kw7 _syaz131l _152tze3t _rjxpze3t _30l31gjq",
|
|
29
|
+
iconSpacingWithClearButtonStyles: "_12l2xy5q",
|
|
30
|
+
iconSpacingWithoutClearButtonStyles: "_12l21b66"
|
|
31
|
+
};
|
|
27
32
|
const analyticsAttributes = {
|
|
28
33
|
componentName: 'datePicker',
|
|
29
34
|
packageName,
|
|
30
35
|
packageVersion
|
|
31
36
|
};
|
|
32
|
-
const pickerContainerStyles = css({
|
|
33
|
-
position: 'relative'
|
|
34
|
-
});
|
|
35
|
-
const dropdownIndicatorStyles = xcss({
|
|
36
|
-
minWidth: "var(--ds-space-300, 24px)",
|
|
37
|
-
minHeight: "var(--ds-space-300, 24px)",
|
|
38
|
-
display: 'flex',
|
|
39
|
-
alignItems: 'center',
|
|
40
|
-
justifyContent: 'center'
|
|
41
|
-
});
|
|
42
|
-
const iconContainerStyles = xcss({
|
|
43
|
-
display: 'flex',
|
|
44
|
-
height: '100%',
|
|
45
|
-
position: 'absolute',
|
|
46
|
-
alignItems: 'center',
|
|
47
|
-
flexBasis: 'inherit',
|
|
48
|
-
color: 'color.text.subtlest',
|
|
49
|
-
insetBlockStart: 'space.0',
|
|
50
|
-
insetInlineEnd: 'space.0',
|
|
51
|
-
transition: `color 150ms`,
|
|
52
|
-
':hover': {
|
|
53
|
-
color: 'color.text.subtle'
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
const iconSpacingWithClearButtonStyles = xcss({
|
|
57
|
-
marginInlineEnd: 'space.400'
|
|
58
|
-
});
|
|
59
|
-
const iconSpacingWithoutClearButtonStyles = xcss({
|
|
60
|
-
marginInlineEnd: 'space.050'
|
|
61
|
-
});
|
|
62
37
|
|
|
63
38
|
/**
|
|
64
39
|
* __Date picker__
|
|
@@ -392,9 +367,9 @@ const DatePicker = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
392
367
|
|
|
393
368
|
// eslint-disable-next-line @atlaskit/platform/no-preconditioning, @atlaskit/platform/ensure-feature-flag-prefix
|
|
394
369
|
if (fg('platform-visual-refresh-icons')) {
|
|
395
|
-
clearIndicator = props =>
|
|
396
|
-
xcss: dropdownIndicatorStyles
|
|
397
|
-
},
|
|
370
|
+
clearIndicator = props => /*#__PURE__*/React.createElement(Box, {
|
|
371
|
+
xcss: styles.dropdownIndicatorStyles
|
|
372
|
+
}, /*#__PURE__*/React.createElement(Icon, props));
|
|
398
373
|
}
|
|
399
374
|
const dropDownIcon = appearance === 'subtle' || hideIcon || showClearIndicator ? null : clearIndicator;
|
|
400
375
|
const SingleValue = makeSingleValue({
|
|
@@ -405,7 +380,7 @@ const DatePicker = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
405
380
|
// Only use this new container component if the calendar button is shown.
|
|
406
381
|
// Otherwise, it throws errors downstream for some reason
|
|
407
382
|
...(shouldShowCalendarButton ? {
|
|
408
|
-
IndicatorsContainer: props =>
|
|
383
|
+
IndicatorsContainer: props => /*#__PURE__*/React.createElement(IndicatorsContainer, _extends({}, props, {
|
|
409
384
|
showClearIndicator: showClearIndicator
|
|
410
385
|
}))
|
|
411
386
|
} : {}),
|
|
@@ -468,102 +443,99 @@ const DatePicker = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
468
443
|
// `label` takes precedence of the `inputLabel`
|
|
469
444
|
const fullopenCalendarLabel = label || inputLabel ? `${label || inputLabel}, ${openCalendarLabel}` : openCalendarLabel;
|
|
470
445
|
const openCalendarLabelId = `open-calendar-label--${useId()}`;
|
|
471
|
-
return (
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
testId: testId && `${testId}--open-calendar-button`
|
|
566
|
-
})) : null)
|
|
567
|
-
);
|
|
446
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, innerProps, {
|
|
447
|
+
"data-testid": testId && `${testId}--container`,
|
|
448
|
+
onBlur: onContainerBlur,
|
|
449
|
+
onFocus: onContainerFocus,
|
|
450
|
+
onClick: onInputClick,
|
|
451
|
+
onInput: onTextInput,
|
|
452
|
+
onKeyDown: onInputKeyDown,
|
|
453
|
+
ref: getContainerRef
|
|
454
|
+
// Since the onclick, onfocus are passed down, adding role="presentation" prevents typecheck errors.
|
|
455
|
+
,
|
|
456
|
+
role: "presentation",
|
|
457
|
+
className: ax([styles.pickerContainerStyle])
|
|
458
|
+
}), /*#__PURE__*/React.createElement("input", {
|
|
459
|
+
name: name,
|
|
460
|
+
type: "hidden",
|
|
461
|
+
value: getterValue,
|
|
462
|
+
"data-testid": testId && `${testId}--input`
|
|
463
|
+
}), /*#__PURE__*/React.createElement(Select, _extends({
|
|
464
|
+
appearance: appearance,
|
|
465
|
+
"aria-describedby": ariaDescribedBy,
|
|
466
|
+
label: label || undefined
|
|
467
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
468
|
+
,
|
|
469
|
+
autoFocus: autoFocus,
|
|
470
|
+
clearControlLabel: clearControlLabel,
|
|
471
|
+
closeMenuOnSelect: true
|
|
472
|
+
// For some reason, this and the below `styles` type error _only_ show
|
|
473
|
+
// up when you alter some of the properties in the `selectComponents`
|
|
474
|
+
// object. These errors are still present, and I suspect have always
|
|
475
|
+
// been present, without changing the unrelated code. Ignoring as the
|
|
476
|
+
// component still works as expected despite this error. And also
|
|
477
|
+
// because the select refresh team may solve it later.
|
|
478
|
+
,
|
|
479
|
+
components: selectComponents,
|
|
480
|
+
enableAnimation: false,
|
|
481
|
+
inputId: id,
|
|
482
|
+
inputValue: actualSelectInputValue,
|
|
483
|
+
isDisabled: isDisabled,
|
|
484
|
+
isRequired: isRequired,
|
|
485
|
+
menuIsOpen: menuIsOpen,
|
|
486
|
+
onBlur: onSelectBlur,
|
|
487
|
+
onChange: onSelectChange,
|
|
488
|
+
onFocus: onSelectFocus,
|
|
489
|
+
onInputChange: handleSelectInputChange,
|
|
490
|
+
placeholder: getPlaceholder({
|
|
491
|
+
placeholder: placeholder,
|
|
492
|
+
l10n: l10n
|
|
493
|
+
})
|
|
494
|
+
// eslint-disable-next-line @atlaskit/design-system/no-unsafe-style-overrides
|
|
495
|
+
,
|
|
496
|
+
styles: mergedStyles,
|
|
497
|
+
value: initialValue
|
|
498
|
+
}, selectProps, {
|
|
499
|
+
// These are below the spread because I don't know what is in
|
|
500
|
+
// selectProps or not and what wil be overwritten
|
|
501
|
+
isClearable: true,
|
|
502
|
+
isInvalid: isInvalid,
|
|
503
|
+
spacing: spacing,
|
|
504
|
+
testId: testId
|
|
505
|
+
// These aren't part of `Select`'s API, but we're using them here.
|
|
506
|
+
// @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<...> & { ...; }>'.
|
|
507
|
+
,
|
|
508
|
+
calendarContainerRef: calendarProps.calendarContainerRef,
|
|
509
|
+
calendarDisabled: calendarProps.calendarDisabled,
|
|
510
|
+
calendarDisabledDateFilter: calendarProps.calendarDisabledDateFilter,
|
|
511
|
+
calendarLocale: calendarProps.calendarLocale,
|
|
512
|
+
calendarMaxDate: calendarProps.calendarMaxDate,
|
|
513
|
+
calendarMinDate: calendarProps.calendarMinDate,
|
|
514
|
+
calendarRef: calendarProps.calendarRef,
|
|
515
|
+
calendarValue: calendarProps.calendarValue,
|
|
516
|
+
calendarView: calendarProps.calendarView,
|
|
517
|
+
calendarWeekStartDay: calendarProps.calendarWeekStartDay,
|
|
518
|
+
nextMonthLabel: nextMonthLabel,
|
|
519
|
+
onCalendarChange: calendarProps.onCalendarChange,
|
|
520
|
+
onCalendarSelect: calendarProps.onCalendarSelect,
|
|
521
|
+
previousMonthLabel: previousMonthLabel,
|
|
522
|
+
shouldSetFocusOnCurrentDay: calendarProps.shouldSetFocusOnCurrentDay,
|
|
523
|
+
menuInnerWrapper: calendarProps.menuInnerWrapper
|
|
524
|
+
})), shouldShowCalendarButton && !isDisabled ? /*#__PURE__*/React.createElement(Box, {
|
|
525
|
+
xcss: cx(styles.iconContainerStyles, value && !hideIcon ? styles.iconSpacingWithClearButtonStyles : styles.iconSpacingWithoutClearButtonStyles)
|
|
526
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
527
|
+
appearance: "subtle",
|
|
528
|
+
label: !inputLabelId ? fullopenCalendarLabel : openCalendarLabel,
|
|
529
|
+
"aria-labelledby": inputLabelId ? `${inputLabelId} ${openCalendarLabelId}` : undefined,
|
|
530
|
+
id: openCalendarLabelId,
|
|
531
|
+
icon: iconProps => /*#__PURE__*/React.createElement(CalendarIcon, _extends({}, iconProps, {
|
|
532
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
533
|
+
color: "var(--ds-icon, #44546F)"
|
|
534
|
+
})),
|
|
535
|
+
onClick: onCalendarButtonClick,
|
|
536
|
+
onKeyDown: onCalendarButtonKeyDown,
|
|
537
|
+
ref: calendarButtonRef,
|
|
538
|
+
testId: testId && `${testId}--open-calendar-button`
|
|
539
|
+
})) : null);
|
|
568
540
|
});
|
|
569
541
|
export default DatePicker;
|