@atlaskit/datetime-picker 14.0.2 → 14.0.4

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.
@@ -0,0 +1,85 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ /**
3
+ * Everything in this file is to smooth out the migration of the new date picker
4
+ * (https://product-fabric.atlassian.net/browse/DSP-20682). When that ticket is
5
+ * complete, all of these functions will ilkely be merged back into the date
6
+ * picker. Please do not pre-optimize and put these back into the date picker
7
+ * unless you are working on the DTP Refresh and you have a good reason to do
8
+ * so, thank you!
9
+ *
10
+ * All variables within the `di` objects are dependency injections. They should
11
+ * be read from within the component at the end of the day. But because we are
12
+ * extracting them, we have to inject them in every place manually. When we
13
+ * re-introduce them to the components, we can likely remove the `di` variables
14
+ * and instead use internal variables.
15
+ *
16
+ * If component _only_ has injected variables, it is fully internal and was
17
+ * broken out to be it's own function.
18
+ */
19
+
20
+ import { format, lastDayOfMonth, parseISO } from 'date-fns';
21
+ import { convertTokens } from './parse-tokens';
22
+ import { defaultDateFormat, padToTwo, placeholderDatetime } from './index';
23
+ export var isDateDisabled = function isDateDisabled(date, di) {
24
+ var disabled = di.disabled;
25
+ return disabled.indexOf(date) > -1;
26
+ };
27
+ export var getParsedISO = function getParsedISO(di) {
28
+ var iso = di.iso;
29
+ var _iso$split = iso.split('-'),
30
+ _iso$split2 = _slicedToArray(_iso$split, 3),
31
+ year = _iso$split2[0],
32
+ month = _iso$split2[1],
33
+ date = _iso$split2[2];
34
+ var newIso = iso;
35
+ var parsedDate = parseInt(date, 10);
36
+ var parsedMonth = parseInt(month, 10);
37
+ var parsedYear = parseInt(year, 10);
38
+ var lastDayInMonth = lastDayOfMonth(new Date(parsedYear, parsedMonth - 1) // This needs to be -1, because the Date constructor expects an index of the given month
39
+ ).getDate();
40
+ if (lastDayInMonth < parsedDate) {
41
+ newIso = "".concat(year, "-").concat(padToTwo(parsedMonth), "-").concat(padToTwo(lastDayInMonth));
42
+ } else {
43
+ newIso = "".concat(year, "-").concat(padToTwo(parsedMonth), "-").concat(padToTwo(parsedDate));
44
+ }
45
+ return newIso;
46
+ };
47
+
48
+ /**
49
+ * There are two props that can change how the date is parsed.
50
+ * The priority of props used is:
51
+ * 1. `parseInputValue`
52
+ * 2. `locale`
53
+ */
54
+ export var parseDate = function parseDate(date, di) {
55
+ var parseInputValue = di.parseInputValue,
56
+ dateFormat = di.dateFormat,
57
+ l10n = di.l10n;
58
+ if (parseInputValue) {
59
+ return parseInputValue(date, dateFormat || defaultDateFormat);
60
+ }
61
+ return l10n.parseDate(date);
62
+ };
63
+
64
+ /**
65
+ * There are multiple props that can change how the date is formatted.
66
+ * The priority of props used is:
67
+ * 1. `formatDisplayLabel`
68
+ * 2. `dateFormat`
69
+ * 3. `locale`
70
+ */
71
+ export var formatDate = function formatDate(value, di) {
72
+ var formatDisplayLabel = di.formatDisplayLabel,
73
+ dateFormat = di.dateFormat,
74
+ l10n = di.l10n;
75
+ if (formatDisplayLabel) {
76
+ return formatDisplayLabel(value, dateFormat || defaultDateFormat);
77
+ }
78
+ var date = parseISO(value);
79
+ return dateFormat ? format(date, convertTokens(dateFormat)) : l10n.formatDate(date);
80
+ };
81
+ export var getPlaceholder = function getPlaceholder(di) {
82
+ var placeholder = di.placeholder,
83
+ l10n = di.l10n;
84
+ return placeholder || l10n.formatDate(placeholderDatetime);
85
+ };
@@ -77,7 +77,6 @@ declare class DatePickerComponent extends Component<DatePickerProps, State> {
77
77
  } | null;
78
78
  getValue: () => string;
79
79
  getIsOpen: () => boolean;
80
- isDateDisabled: (date: string) => boolean;
81
80
  onCalendarChange: ({ iso }: {
82
81
  iso: string;
83
82
  }) => void;
@@ -95,22 +94,6 @@ declare class DatePickerComponent extends Component<DatePickerProps, State> {
95
94
  onSelectChange: (_value: unknown, action: ActionMeta) => void;
96
95
  handleSelectInputChange: (selectInputValue: string, actionMeta: InputActionMeta) => void;
97
96
  getContainerRef: (ref: HTMLElement | null) => void;
98
- /**
99
- * There are two props that can change how the date is parsed.
100
- * The priority of props used is:
101
- * 1. `parseInputValue`
102
- * 2. `locale`
103
- */
104
- parseDate: (date: string) => Date;
105
- /**
106
- * There are multiple props that can change how the date is formatted.
107
- * The priority of props used is:
108
- * 1. `formatDisplayLabel`
109
- * 2. `dateFormat`
110
- * 3. `locale`
111
- */
112
- formatDate: (value: string) => string;
113
- getPlaceholder: () => string;
114
97
  render(): jsx.JSX.Element;
115
98
  }
116
99
  export { DatePickerComponent as DatePickerWithoutAnalytics };
@@ -123,7 +106,7 @@ export { DatePickerComponent as DatePickerWithoutAnalytics };
123
106
  * - [Code](https://atlassian.design/components/datetime-picker/date-picker/code)
124
107
  * - [Usage](https://atlassian.design/components/datetime-picker/date-picker/usage)
125
108
  */
126
- declare const DatePicker: import("react").ForwardRefExoticComponent<Pick<Pick<Omit<DatePickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "testId" | "placeholder" | "aria-describedby" | "maxDate" | "minDate" | "nextMonthLabel" | "previousMonthLabel" | "weekStartDay" | "value" | "isOpen" | "parseInputValue" | "formatDisplayLabel" | "dateFormat"> & Partial<Pick<Omit<DatePickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "label" | "icon" | "disabled" | "appearance" | "selectProps" | "innerProps" | "isDisabled" | "defaultValue" | "id" | "onFocus" | "onBlur" | "onChange" | "disabledDateFilter" | "locale" | "autoFocus" | "name" | "spacing" | "isInvalid" | "defaultIsOpen" | "hideIcon">> & Partial<Pick<{
109
+ declare const DatePicker: import("react").ForwardRefExoticComponent<Pick<Pick<Omit<DatePickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "parseInputValue" | "dateFormat" | "formatDisplayLabel" | "placeholder" | "testId" | "aria-describedby" | "maxDate" | "minDate" | "nextMonthLabel" | "previousMonthLabel" | "weekStartDay" | "value" | "isOpen"> & Partial<Pick<Omit<DatePickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "disabled" | "label" | "icon" | "appearance" | "selectProps" | "innerProps" | "isDisabled" | "defaultValue" | "id" | "onFocus" | "onBlur" | "onChange" | "disabledDateFilter" | "locale" | "autoFocus" | "name" | "spacing" | "isInvalid" | "defaultIsOpen" | "hideIcon">> & Partial<Pick<{
127
110
  appearance: Appearance;
128
111
  autoFocus: boolean;
129
112
  defaultIsOpen: boolean;
@@ -144,5 +127,5 @@ declare const DatePicker: import("react").ForwardRefExoticComponent<Pick<Pick<Om
144
127
  selectProps: {};
145
128
  spacing: Spacing;
146
129
  locale: string;
147
- }, never>> & import("react").RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "testId" | "label" | "icon" | "disabled" | "appearance" | "selectProps" | "innerProps" | "isDisabled" | "key" | "defaultValue" | "id" | "placeholder" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "disabledDateFilter" | "maxDate" | "minDate" | "nextMonthLabel" | "previousMonthLabel" | "locale" | "analyticsContext" | "weekStartDay" | "value" | "autoFocus" | "name" | "spacing" | "isInvalid" | "defaultIsOpen" | "isOpen" | "parseInputValue" | "formatDisplayLabel" | "hideIcon" | "dateFormat"> & import("react").RefAttributes<any>>;
130
+ }, never>> & import("react").RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "disabled" | "parseInputValue" | "dateFormat" | "formatDisplayLabel" | "placeholder" | "testId" | "label" | "icon" | "appearance" | "selectProps" | "innerProps" | "isDisabled" | "key" | "defaultValue" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "disabledDateFilter" | "maxDate" | "minDate" | "nextMonthLabel" | "previousMonthLabel" | "locale" | "analyticsContext" | "weekStartDay" | "value" | "autoFocus" | "name" | "spacing" | "isInvalid" | "defaultIsOpen" | "isOpen" | "hideIcon"> & import("react").RefAttributes<any>>;
148
131
  export default DatePicker;
@@ -1,86 +1,5 @@
1
1
  import React from 'react';
2
- import { type ActionMeta, type OptionType, type ValueType } from '@atlaskit/select';
3
- import { type Appearance, type Spacing, type TimePickerBaseProps } from '../types';
4
- type TimePickerProps = typeof timePickerDefaultProps & TimePickerBaseProps;
5
- interface State {
6
- isOpen: boolean;
7
- /**
8
- * When being cleared from the icon the TimePicker is blurred.
9
- * This variable defines whether the default onMenuOpen or onMenuClose
10
- * events should behave as normal
11
- */
12
- clearingFromIcon: boolean;
13
- value: string;
14
- isFocused: boolean;
15
- }
16
- declare const timePickerDefaultProps: {
17
- appearance: Appearance;
18
- autoFocus: boolean;
19
- defaultIsOpen: boolean;
20
- defaultValue: string;
21
- hideIcon: boolean;
22
- id: string;
23
- innerProps: {};
24
- isDisabled: boolean;
25
- isInvalid: boolean;
26
- label: string;
27
- name: string;
28
- onBlur: (_event: React.FocusEvent<HTMLInputElement>) => void;
29
- onChange: (_value: string) => void;
30
- onFocus: (_event: React.FocusEvent<HTMLInputElement>) => void;
31
- parseInputValue: (time: string, _timeFormat: string) => string | Date;
32
- selectProps: {};
33
- spacing: Spacing;
34
- times: string[];
35
- timeIsEditable: boolean;
36
- locale: string;
37
- };
38
- declare class TimePickerComponent extends React.Component<TimePickerProps, State> {
39
- containerRef: HTMLElement | null;
40
- static defaultProps: {
41
- appearance: Appearance;
42
- autoFocus: boolean;
43
- defaultIsOpen: boolean;
44
- defaultValue: string;
45
- hideIcon: boolean;
46
- id: string;
47
- innerProps: {};
48
- isDisabled: boolean;
49
- isInvalid: boolean;
50
- label: string;
51
- name: string;
52
- onBlur: (_event: React.FocusEvent<HTMLInputElement>) => void;
53
- onChange: (_value: string) => void;
54
- onFocus: (_event: React.FocusEvent<HTMLInputElement>) => void;
55
- parseInputValue: (time: string, _timeFormat: string) => string | Date;
56
- selectProps: {};
57
- spacing: Spacing;
58
- times: string[];
59
- timeIsEditable: boolean;
60
- locale: string;
61
- };
62
- state: {
63
- isOpen: boolean;
64
- clearingFromIcon: boolean;
65
- value: string;
66
- isFocused: boolean;
67
- };
68
- getValue: () => string;
69
- getIsOpen: () => boolean;
70
- onChange: (newValue: ValueType<OptionType> | string, action?: ActionMeta<OptionType>) => void;
71
- /**
72
- * Only allow custom times if timeIsEditable prop is true
73
- */
74
- onCreateOption: (inputValue: string) => void;
75
- onMenuOpen: () => void;
76
- onMenuClose: () => void;
77
- setContainerRef: (ref: HTMLElement | null) => void;
78
- onBlur: (event: React.FocusEvent<HTMLElement>) => void;
79
- onFocus: (event: React.FocusEvent<HTMLElement>) => void;
80
- onSelectKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;
81
- render(): JSX.Element;
82
- }
83
- export { TimePickerComponent as TimePickerWithoutAnalytics };
2
+ import { type TimePickerBaseProps } from '../types';
84
3
  /**
85
4
  * __Time picker__
86
5
  *
@@ -90,26 +9,5 @@ export { TimePickerComponent as TimePickerWithoutAnalytics };
90
9
  * - [Code](https://atlassian.design/components/datetime-picker/time-picker/code)
91
10
  * - [Usage](https://atlassian.design/components/datetime-picker/time-picker/usage)
92
11
  */
93
- declare const TimePicker: React.ForwardRefExoticComponent<Pick<Pick<Omit<TimePickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "testId" | "placeholder" | "aria-describedby" | "value" | "isOpen" | "formatDisplayLabel" | "timeFormat"> & Partial<Pick<Omit<TimePickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "times" | "label" | "appearance" | "selectProps" | "innerProps" | "isDisabled" | "defaultValue" | "id" | "onFocus" | "onBlur" | "onChange" | "locale" | "autoFocus" | "name" | "spacing" | "isInvalid" | "defaultIsOpen" | "parseInputValue" | "hideIcon" | "timeIsEditable">> & Partial<Pick<{
94
- appearance: Appearance;
95
- autoFocus: boolean;
96
- defaultIsOpen: boolean;
97
- defaultValue: string;
98
- hideIcon: boolean;
99
- id: string;
100
- innerProps: {};
101
- isDisabled: boolean;
102
- isInvalid: boolean;
103
- label: string;
104
- name: string;
105
- onBlur: (_event: React.FocusEvent<HTMLInputElement>) => void;
106
- onChange: (_value: string) => void;
107
- onFocus: (_event: React.FocusEvent<HTMLInputElement>) => void;
108
- parseInputValue: (time: string, _timeFormat: string) => string | Date;
109
- selectProps: {};
110
- spacing: Spacing;
111
- times: string[];
112
- timeIsEditable: boolean;
113
- locale: string;
114
- }, never>> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "times" | "testId" | "label" | "appearance" | "selectProps" | "innerProps" | "isDisabled" | "key" | "defaultValue" | "id" | "placeholder" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "locale" | "analyticsContext" | "value" | "autoFocus" | "name" | "spacing" | "isInvalid" | "defaultIsOpen" | "isOpen" | "parseInputValue" | "formatDisplayLabel" | "hideIcon" | "timeIsEditable" | "timeFormat"> & React.RefAttributes<any>>;
12
+ declare const TimePicker: React.ForwardRefExoticComponent<Pick<TimePickerBaseProps, "times" | "parseInputValue" | "formatDisplayLabel" | "placeholder" | "testId" | "label" | "appearance" | "selectProps" | "innerProps" | "isDisabled" | "defaultValue" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "locale" | "analyticsContext" | "createAnalyticsEvent" | "value" | "autoFocus" | "name" | "spacing" | "isInvalid" | "defaultIsOpen" | "isOpen" | "hideIcon" | "timeIsEditable" | "timeFormat"> & React.RefAttributes<unknown>>;
115
13
  export default TimePicker;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Everything in this file is to smooth out the migration of the new date picker
3
+ * (https://product-fabric.atlassian.net/browse/DSP-20682). When that ticket is
4
+ * complete, all of these functions will ilkely be merged back into the date
5
+ * picker. Please do not pre-optimize and put these back into the date picker
6
+ * unless you are working on the DTP Refresh and you have a good reason to do
7
+ * so, thank you!
8
+ *
9
+ * All variables within the `di` objects are dependency injections. They should
10
+ * be read from within the component at the end of the day. But because we are
11
+ * extracting them, we have to inject them in every place manually. When we
12
+ * re-introduce them to the components, we can likely remove the `di` variables
13
+ * and instead use internal variables.
14
+ *
15
+ * If component _only_ has injected variables, it is fully internal and was
16
+ * broken out to be it's own function.
17
+ */
18
+ import { type LocalizationProvider } from '@atlaskit/locale';
19
+ export declare const isDateDisabled: (date: string, di: {
20
+ disabled: string[];
21
+ }) => boolean;
22
+ export declare const getParsedISO: (di: {
23
+ iso: string;
24
+ }) => string;
25
+ /**
26
+ * There are two props that can change how the date is parsed.
27
+ * The priority of props used is:
28
+ * 1. `parseInputValue`
29
+ * 2. `locale`
30
+ */
31
+ export declare const parseDate: (date: string, di: {
32
+ parseInputValue: ((date: string, dateFormat: string) => Date) | undefined;
33
+ dateFormat: string | undefined;
34
+ l10n: LocalizationProvider;
35
+ }) => Date;
36
+ /**
37
+ * There are multiple props that can change how the date is formatted.
38
+ * The priority of props used is:
39
+ * 1. `formatDisplayLabel`
40
+ * 2. `dateFormat`
41
+ * 3. `locale`
42
+ */
43
+ export declare const formatDate: (value: string, di: {
44
+ formatDisplayLabel: ((value: string, dateFormat: string) => string) | undefined;
45
+ dateFormat: string | undefined;
46
+ l10n: LocalizationProvider;
47
+ }) => string;
48
+ export declare const getPlaceholder: (di: {
49
+ placeholder: string | undefined;
50
+ l10n: LocalizationProvider;
51
+ }) => string;
@@ -206,6 +206,10 @@ export interface DatePickerBaseProps extends WithAnalyticsEventsProps, PickerSel
206
206
  weekStartDay?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
207
207
  }
208
208
  export interface TimePickerBaseProps extends WithAnalyticsEventsProps, PickerSelectProps {
209
+ /**
210
+ * Additional information to be included in the `context` of analytics events
211
+ */
212
+ analyticsContext?: Record<string, any>;
209
213
  /**
210
214
  * Set the appearance of the picker.
211
215
  * `subtle` will remove the borders, background, and icon.
@@ -77,7 +77,6 @@ declare class DatePickerComponent extends Component<DatePickerProps, State> {
77
77
  } | null;
78
78
  getValue: () => string;
79
79
  getIsOpen: () => boolean;
80
- isDateDisabled: (date: string) => boolean;
81
80
  onCalendarChange: ({ iso }: {
82
81
  iso: string;
83
82
  }) => void;
@@ -95,22 +94,6 @@ declare class DatePickerComponent extends Component<DatePickerProps, State> {
95
94
  onSelectChange: (_value: unknown, action: ActionMeta) => void;
96
95
  handleSelectInputChange: (selectInputValue: string, actionMeta: InputActionMeta) => void;
97
96
  getContainerRef: (ref: HTMLElement | null) => void;
98
- /**
99
- * There are two props that can change how the date is parsed.
100
- * The priority of props used is:
101
- * 1. `parseInputValue`
102
- * 2. `locale`
103
- */
104
- parseDate: (date: string) => Date;
105
- /**
106
- * There are multiple props that can change how the date is formatted.
107
- * The priority of props used is:
108
- * 1. `formatDisplayLabel`
109
- * 2. `dateFormat`
110
- * 3. `locale`
111
- */
112
- formatDate: (value: string) => string;
113
- getPlaceholder: () => string;
114
97
  render(): jsx.JSX.Element;
115
98
  }
116
99
  export { DatePickerComponent as DatePickerWithoutAnalytics };
@@ -123,7 +106,7 @@ export { DatePickerComponent as DatePickerWithoutAnalytics };
123
106
  * - [Code](https://atlassian.design/components/datetime-picker/date-picker/code)
124
107
  * - [Usage](https://atlassian.design/components/datetime-picker/date-picker/usage)
125
108
  */
126
- declare const DatePicker: import("react").ForwardRefExoticComponent<Pick<Pick<Omit<DatePickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "testId" | "placeholder" | "aria-describedby" | "maxDate" | "minDate" | "nextMonthLabel" | "previousMonthLabel" | "weekStartDay" | "value" | "isOpen" | "parseInputValue" | "formatDisplayLabel" | "dateFormat"> & Partial<Pick<Omit<DatePickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "label" | "icon" | "disabled" | "appearance" | "selectProps" | "innerProps" | "isDisabled" | "defaultValue" | "id" | "onFocus" | "onBlur" | "onChange" | "disabledDateFilter" | "locale" | "autoFocus" | "name" | "spacing" | "isInvalid" | "defaultIsOpen" | "hideIcon">> & Partial<Pick<{
109
+ declare const DatePicker: import("react").ForwardRefExoticComponent<Pick<Pick<Omit<DatePickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "parseInputValue" | "dateFormat" | "formatDisplayLabel" | "placeholder" | "testId" | "aria-describedby" | "maxDate" | "minDate" | "nextMonthLabel" | "previousMonthLabel" | "weekStartDay" | "value" | "isOpen"> & Partial<Pick<Omit<DatePickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "disabled" | "label" | "icon" | "appearance" | "selectProps" | "innerProps" | "isDisabled" | "defaultValue" | "id" | "onFocus" | "onBlur" | "onChange" | "disabledDateFilter" | "locale" | "autoFocus" | "name" | "spacing" | "isInvalid" | "defaultIsOpen" | "hideIcon">> & Partial<Pick<{
127
110
  appearance: Appearance;
128
111
  autoFocus: boolean;
129
112
  defaultIsOpen: boolean;
@@ -144,5 +127,5 @@ declare const DatePicker: import("react").ForwardRefExoticComponent<Pick<Pick<Om
144
127
  selectProps: {};
145
128
  spacing: Spacing;
146
129
  locale: string;
147
- }, never>> & import("react").RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "testId" | "label" | "icon" | "disabled" | "appearance" | "selectProps" | "innerProps" | "isDisabled" | "key" | "defaultValue" | "id" | "placeholder" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "disabledDateFilter" | "maxDate" | "minDate" | "nextMonthLabel" | "previousMonthLabel" | "locale" | "analyticsContext" | "weekStartDay" | "value" | "autoFocus" | "name" | "spacing" | "isInvalid" | "defaultIsOpen" | "isOpen" | "parseInputValue" | "formatDisplayLabel" | "hideIcon" | "dateFormat"> & import("react").RefAttributes<any>>;
130
+ }, never>> & import("react").RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "disabled" | "parseInputValue" | "dateFormat" | "formatDisplayLabel" | "placeholder" | "testId" | "label" | "icon" | "appearance" | "selectProps" | "innerProps" | "isDisabled" | "key" | "defaultValue" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "disabledDateFilter" | "maxDate" | "minDate" | "nextMonthLabel" | "previousMonthLabel" | "locale" | "analyticsContext" | "weekStartDay" | "value" | "autoFocus" | "name" | "spacing" | "isInvalid" | "defaultIsOpen" | "isOpen" | "hideIcon"> & import("react").RefAttributes<any>>;
148
131
  export default DatePicker;
@@ -1,86 +1,5 @@
1
1
  import React from 'react';
2
- import { type ActionMeta, type OptionType, type ValueType } from '@atlaskit/select';
3
- import { type Appearance, type Spacing, type TimePickerBaseProps } from '../types';
4
- type TimePickerProps = typeof timePickerDefaultProps & TimePickerBaseProps;
5
- interface State {
6
- isOpen: boolean;
7
- /**
8
- * When being cleared from the icon the TimePicker is blurred.
9
- * This variable defines whether the default onMenuOpen or onMenuClose
10
- * events should behave as normal
11
- */
12
- clearingFromIcon: boolean;
13
- value: string;
14
- isFocused: boolean;
15
- }
16
- declare const timePickerDefaultProps: {
17
- appearance: Appearance;
18
- autoFocus: boolean;
19
- defaultIsOpen: boolean;
20
- defaultValue: string;
21
- hideIcon: boolean;
22
- id: string;
23
- innerProps: {};
24
- isDisabled: boolean;
25
- isInvalid: boolean;
26
- label: string;
27
- name: string;
28
- onBlur: (_event: React.FocusEvent<HTMLInputElement>) => void;
29
- onChange: (_value: string) => void;
30
- onFocus: (_event: React.FocusEvent<HTMLInputElement>) => void;
31
- parseInputValue: (time: string, _timeFormat: string) => string | Date;
32
- selectProps: {};
33
- spacing: Spacing;
34
- times: string[];
35
- timeIsEditable: boolean;
36
- locale: string;
37
- };
38
- declare class TimePickerComponent extends React.Component<TimePickerProps, State> {
39
- containerRef: HTMLElement | null;
40
- static defaultProps: {
41
- appearance: Appearance;
42
- autoFocus: boolean;
43
- defaultIsOpen: boolean;
44
- defaultValue: string;
45
- hideIcon: boolean;
46
- id: string;
47
- innerProps: {};
48
- isDisabled: boolean;
49
- isInvalid: boolean;
50
- label: string;
51
- name: string;
52
- onBlur: (_event: React.FocusEvent<HTMLInputElement>) => void;
53
- onChange: (_value: string) => void;
54
- onFocus: (_event: React.FocusEvent<HTMLInputElement>) => void;
55
- parseInputValue: (time: string, _timeFormat: string) => string | Date;
56
- selectProps: {};
57
- spacing: Spacing;
58
- times: string[];
59
- timeIsEditable: boolean;
60
- locale: string;
61
- };
62
- state: {
63
- isOpen: boolean;
64
- clearingFromIcon: boolean;
65
- value: string;
66
- isFocused: boolean;
67
- };
68
- getValue: () => string;
69
- getIsOpen: () => boolean;
70
- onChange: (newValue: ValueType<OptionType> | string, action?: ActionMeta<OptionType>) => void;
71
- /**
72
- * Only allow custom times if timeIsEditable prop is true
73
- */
74
- onCreateOption: (inputValue: string) => void;
75
- onMenuOpen: () => void;
76
- onMenuClose: () => void;
77
- setContainerRef: (ref: HTMLElement | null) => void;
78
- onBlur: (event: React.FocusEvent<HTMLElement>) => void;
79
- onFocus: (event: React.FocusEvent<HTMLElement>) => void;
80
- onSelectKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;
81
- render(): JSX.Element;
82
- }
83
- export { TimePickerComponent as TimePickerWithoutAnalytics };
2
+ import { type TimePickerBaseProps } from '../types';
84
3
  /**
85
4
  * __Time picker__
86
5
  *
@@ -90,26 +9,5 @@ export { TimePickerComponent as TimePickerWithoutAnalytics };
90
9
  * - [Code](https://atlassian.design/components/datetime-picker/time-picker/code)
91
10
  * - [Usage](https://atlassian.design/components/datetime-picker/time-picker/usage)
92
11
  */
93
- declare const TimePicker: React.ForwardRefExoticComponent<Pick<Pick<Omit<TimePickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "testId" | "placeholder" | "aria-describedby" | "value" | "isOpen" | "formatDisplayLabel" | "timeFormat"> & Partial<Pick<Omit<TimePickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "times" | "label" | "appearance" | "selectProps" | "innerProps" | "isDisabled" | "defaultValue" | "id" | "onFocus" | "onBlur" | "onChange" | "locale" | "autoFocus" | "name" | "spacing" | "isInvalid" | "defaultIsOpen" | "parseInputValue" | "hideIcon" | "timeIsEditable">> & Partial<Pick<{
94
- appearance: Appearance;
95
- autoFocus: boolean;
96
- defaultIsOpen: boolean;
97
- defaultValue: string;
98
- hideIcon: boolean;
99
- id: string;
100
- innerProps: {};
101
- isDisabled: boolean;
102
- isInvalid: boolean;
103
- label: string;
104
- name: string;
105
- onBlur: (_event: React.FocusEvent<HTMLInputElement>) => void;
106
- onChange: (_value: string) => void;
107
- onFocus: (_event: React.FocusEvent<HTMLInputElement>) => void;
108
- parseInputValue: (time: string, _timeFormat: string) => string | Date;
109
- selectProps: {};
110
- spacing: Spacing;
111
- times: string[];
112
- timeIsEditable: boolean;
113
- locale: string;
114
- }, never>> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "times" | "testId" | "label" | "appearance" | "selectProps" | "innerProps" | "isDisabled" | "key" | "defaultValue" | "id" | "placeholder" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "locale" | "analyticsContext" | "value" | "autoFocus" | "name" | "spacing" | "isInvalid" | "defaultIsOpen" | "isOpen" | "parseInputValue" | "formatDisplayLabel" | "hideIcon" | "timeIsEditable" | "timeFormat"> & React.RefAttributes<any>>;
12
+ declare const TimePicker: React.ForwardRefExoticComponent<Pick<TimePickerBaseProps, "times" | "parseInputValue" | "formatDisplayLabel" | "placeholder" | "testId" | "label" | "appearance" | "selectProps" | "innerProps" | "isDisabled" | "defaultValue" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "locale" | "analyticsContext" | "createAnalyticsEvent" | "value" | "autoFocus" | "name" | "spacing" | "isInvalid" | "defaultIsOpen" | "isOpen" | "hideIcon" | "timeIsEditable" | "timeFormat"> & React.RefAttributes<unknown>>;
115
13
  export default TimePicker;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Everything in this file is to smooth out the migration of the new date picker
3
+ * (https://product-fabric.atlassian.net/browse/DSP-20682). When that ticket is
4
+ * complete, all of these functions will ilkely be merged back into the date
5
+ * picker. Please do not pre-optimize and put these back into the date picker
6
+ * unless you are working on the DTP Refresh and you have a good reason to do
7
+ * so, thank you!
8
+ *
9
+ * All variables within the `di` objects are dependency injections. They should
10
+ * be read from within the component at the end of the day. But because we are
11
+ * extracting them, we have to inject them in every place manually. When we
12
+ * re-introduce them to the components, we can likely remove the `di` variables
13
+ * and instead use internal variables.
14
+ *
15
+ * If component _only_ has injected variables, it is fully internal and was
16
+ * broken out to be it's own function.
17
+ */
18
+ import { type LocalizationProvider } from '@atlaskit/locale';
19
+ export declare const isDateDisabled: (date: string, di: {
20
+ disabled: string[];
21
+ }) => boolean;
22
+ export declare const getParsedISO: (di: {
23
+ iso: string;
24
+ }) => string;
25
+ /**
26
+ * There are two props that can change how the date is parsed.
27
+ * The priority of props used is:
28
+ * 1. `parseInputValue`
29
+ * 2. `locale`
30
+ */
31
+ export declare const parseDate: (date: string, di: {
32
+ parseInputValue: ((date: string, dateFormat: string) => Date) | undefined;
33
+ dateFormat: string | undefined;
34
+ l10n: LocalizationProvider;
35
+ }) => Date;
36
+ /**
37
+ * There are multiple props that can change how the date is formatted.
38
+ * The priority of props used is:
39
+ * 1. `formatDisplayLabel`
40
+ * 2. `dateFormat`
41
+ * 3. `locale`
42
+ */
43
+ export declare const formatDate: (value: string, di: {
44
+ formatDisplayLabel: ((value: string, dateFormat: string) => string) | undefined;
45
+ dateFormat: string | undefined;
46
+ l10n: LocalizationProvider;
47
+ }) => string;
48
+ export declare const getPlaceholder: (di: {
49
+ placeholder: string | undefined;
50
+ l10n: LocalizationProvider;
51
+ }) => string;
@@ -206,6 +206,10 @@ export interface DatePickerBaseProps extends WithAnalyticsEventsProps, PickerSel
206
206
  weekStartDay?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
207
207
  }
208
208
  export interface TimePickerBaseProps extends WithAnalyticsEventsProps, PickerSelectProps {
209
+ /**
210
+ * Additional information to be included in the `context` of analytics events
211
+ */
212
+ analyticsContext?: Record<string, any>;
209
213
  /**
210
214
  * Set the appearance of the picker.
211
215
  * `subtle` will remove the borders, background, and icon.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/datetime-picker",
3
- "version": "14.0.2",
3
+ "version": "14.0.4",
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/"
@@ -38,10 +38,10 @@
38
38
  "@atlaskit/analytics-next": "^10.1.0",
39
39
  "@atlaskit/calendar": "^15.0.0",
40
40
  "@atlaskit/ds-lib": "^2.5.0",
41
- "@atlaskit/icon": "^22.15.0",
41
+ "@atlaskit/icon": "^22.16.0",
42
42
  "@atlaskit/layering": "^0.4.0",
43
43
  "@atlaskit/locale": "^2.8.0",
44
- "@atlaskit/popper": "^6.2.0",
44
+ "@atlaskit/popper": "^6.3.0",
45
45
  "@atlaskit/select": "^17.15.0",
46
46
  "@atlaskit/theme": "^13.0.0",
47
47
  "@atlaskit/tokens": "^1.59.0",
@@ -61,12 +61,12 @@
61
61
  "@atlaskit/docs": "*",
62
62
  "@atlaskit/form": "^10.5.0",
63
63
  "@atlaskit/modal-dialog": "^12.15.0",
64
- "@atlaskit/popup": "^1.24.0",
64
+ "@atlaskit/popup": "^1.25.0",
65
65
  "@atlaskit/range": "^7.4.0",
66
66
  "@atlaskit/section-message": "^6.6.0",
67
67
  "@atlaskit/ssr": "*",
68
68
  "@atlaskit/textfield": "^6.5.0",
69
- "@atlaskit/toggle": "^13.3.0",
69
+ "@atlaskit/toggle": "^13.4.0",
70
70
  "@atlaskit/visual-regression": "*",
71
71
  "@atlassian/feature-flags-test-utils": "*",
72
72
  "@testing-library/react": "^12.1.5",