@atlaskit/datetime-picker 15.1.4 → 15.3.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.
@@ -122,6 +122,10 @@ export interface DatePickerBaseProps extends WithAnalyticsEventsProps, PickerSel
122
122
  * Set if the picker is open.
123
123
  */
124
124
  isOpen?: boolean;
125
+ /**
126
+ * Sets the aria-required passed down to the combobox in the select component.
127
+ */
128
+ isRequired?: boolean;
125
129
  /**
126
130
  * The name of the field.
127
131
  */
@@ -142,6 +146,37 @@ export interface DatePickerBaseProps extends WithAnalyticsEventsProps, PickerSel
142
146
  * Called when the field is focused.
143
147
  */
144
148
  onFocus?: React.FocusEventHandler<HTMLInputElement>;
149
+ /**
150
+ * The name of the input, used when `shouldShowCalendarButton` is true. See `shouldShowCalendarButton` description for more details.
151
+ *
152
+ * @default 'Date picker'
153
+ */
154
+ inputLabel?: string;
155
+ /**
156
+ * The ID of the label for the input, used when `shouldShowCalendarButton` is
157
+ * true. See `shouldShowCalendarButton` description for more details.
158
+ */
159
+ inputLabelId?: string;
160
+ /**
161
+ * The label associated with the button to open the calendar, rendered via the
162
+ * `shouldShowCalendarButton` prop. If a `label` prop is provided, this
163
+ * calendar button label will be prefixed by the value of `label`. If no
164
+ * `label` prop is provided, this prefix should be manually added. For
165
+ * example,
166
+ *
167
+ * ```tsx
168
+ * <label id="label" htmlFor="datepicker">Desired Appointment Date</label>
169
+ * <DatePicker
170
+ * id="datepicker"
171
+ * shouldShowCalendarButton
172
+ * inputLabel="Desired Appointment Date"
173
+ * openCalendarLabel="open calendar"
174
+ * />
175
+ * ```
176
+ *
177
+ * @default 'open calendar'
178
+ */
179
+ openCalendarLabel?: string;
145
180
  /**
146
181
  * A function for parsing input characters and transforming them into a Date object.
147
182
  * By default parses the date string based off the locale.
@@ -155,6 +190,17 @@ export interface DatePickerBaseProps extends WithAnalyticsEventsProps, PickerSel
155
190
  * The aria-label attribute associated with the previous-month arrow.
156
191
  */
157
192
  previousMonthLabel?: string;
193
+ /**
194
+ * Provides a functional calendar button that opens the calendar picker that
195
+ * lives on the right side of the date picker.
196
+ *
197
+ * The accessible name for this button is caculated using either the `label`,
198
+ * `inputLabel`, or `inputLabelId` props, along with the `openCalendarLabel`
199
+ * prop.
200
+ *
201
+ * @default false
202
+ */
203
+ shouldShowCalendarButton?: boolean;
158
204
  /**
159
205
  * The spacing for the select control.
160
206
  *
@@ -257,6 +303,10 @@ export interface TimePickerBaseProps extends WithAnalyticsEventsProps, PickerSel
257
303
  * Set if the dropdown is open. Will be `false` if not provided.
258
304
  */
259
305
  isOpen?: boolean;
306
+ /**
307
+ * Sets the aria-required passed down to the combobox in the select component.
308
+ */
309
+ isRequired?: boolean;
260
310
  /**
261
311
  * Accessible name for the Time Picker Select, rendered as `aria-label`. This will override any other method of providing a label.
262
312
  */
@@ -369,6 +419,10 @@ export interface DateTimePickerBaseProps extends WithAnalyticsEventsProps {
369
419
  * Set if the field is disabled.
370
420
  */
371
421
  isDisabled?: boolean;
422
+ /**
423
+ * Sets the aria-required passed down to the combobox in the select component.
424
+ */
425
+ isRequired?: boolean;
372
426
  /**
373
427
  * The name of the field.
374
428
  */
@@ -9,6 +9,7 @@ import { type ActionMeta, type InputActionMeta } from '@atlaskit/select';
9
9
  import { type DatePickerBaseProps } from '../types';
10
10
  type DatePickerProps = typeof datePickerDefaultProps & DatePickerBaseProps;
11
11
  interface State {
12
+ isKeyDown: boolean;
12
13
  isOpen: boolean;
13
14
  /**
14
15
  * When being cleared from the icon the DatePicker is blurred.
@@ -23,6 +24,7 @@ interface State {
23
24
  l10n: LocalizationProvider;
24
25
  locale: string;
25
26
  shouldSetFocusOnCurrentDay: boolean;
27
+ wasOpenedFromCalendarButton: boolean;
26
28
  }
27
29
  declare const datePickerDefaultProps: {
28
30
  defaultIsOpen: boolean;
@@ -46,6 +48,8 @@ declare class DatePickerComponent extends Component<DatePickerProps, State> {
46
48
  onFocus: (_event: import("react").FocusEvent<HTMLInputElement>) => void;
47
49
  };
48
50
  containerRef: HTMLElement | null;
51
+ calendarRef: React.RefObject<HTMLDivElement | null>;
52
+ calendarButtonRef: React.RefObject<HTMLButtonElement>;
49
53
  constructor(props: any);
50
54
  static getDerivedStateFromProps(nextProps: Readonly<DatePickerProps>, prevState: State): {
51
55
  l10n: LocalizationProvider;
@@ -66,6 +70,8 @@ declare class DatePickerComponent extends Component<DatePickerProps, State> {
66
70
  onSelectFocus: (event: React.FocusEvent<HTMLInputElement>) => void;
67
71
  onTextInput: (event: React.ChangeEvent<HTMLInputElement>) => void;
68
72
  onInputKeyDown: (event: React.KeyboardEvent<HTMLElement>) => void;
73
+ onCalendarButtonKeyDown: (e: React.KeyboardEvent<HTMLButtonElement>) => void;
74
+ onCalendarButtonClick: (e: React.MouseEvent<HTMLButtonElement>) => void;
69
75
  onClear: () => void;
70
76
  onSelectChange: (_value: unknown, action: ActionMeta) => void;
71
77
  handleSelectInputChange: (selectInputValue: string, actionMeta: InputActionMeta) => void;
@@ -82,7 +88,7 @@ export { DatePickerComponent as DatePickerWithoutAnalytics };
82
88
  * - [Code](https://atlassian.design/components/datetime-picker/date-picker/code)
83
89
  * - [Usage](https://atlassian.design/components/datetime-picker/date-picker/usage)
84
90
  */
85
- declare const DatePicker: import("react").ForwardRefExoticComponent<Pick<Pick<Omit<DatePickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "parseInputValue" | "dateFormat" | "formatDisplayLabel" | "placeholder" | "testId" | "label" | "icon" | "appearance" | "selectProps" | "innerProps" | "isDisabled" | "id" | "aria-describedby" | "maxDate" | "minDate" | "nextMonthLabel" | "previousMonthLabel" | "weekStartDay" | "value" | "autoFocus" | "isInvalid" | "name" | "spacing" | "isOpen" | "hideIcon"> & Partial<Pick<Omit<DatePickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "disabled" | "defaultValue" | "onFocus" | "onBlur" | "onChange" | "disabledDateFilter" | "locale" | "defaultIsOpen">> & Partial<Pick<{
91
+ declare const DatePicker: import("react").ForwardRefExoticComponent<Pick<Pick<Omit<{
86
92
  defaultIsOpen: boolean;
87
93
  defaultValue: string;
88
94
  disabled: string[];
@@ -91,5 +97,23 @@ declare const DatePicker: import("react").ForwardRefExoticComponent<Pick<Pick<Om
91
97
  onBlur: (_event: React.FocusEvent<HTMLInputElement>) => void;
92
98
  onChange: (_value: string) => void;
93
99
  onFocus: (_event: React.FocusEvent<HTMLInputElement>) => void;
94
- }, 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" | "isInvalid" | "name" | "spacing" | "defaultIsOpen" | "isOpen" | "hideIcon"> & import("react").RefAttributes<any>>;
100
+ } & DatePickerBaseProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "parseInputValue" | "dateFormat" | "formatDisplayLabel" | "placeholder" | "testId" | "label" | "icon" | "appearance" | "selectProps" | "innerProps" | "isDisabled" | "id" | "aria-describedby" | "maxDate" | "minDate" | "nextMonthLabel" | "previousMonthLabel" | "weekStartDay" | "value" | "autoFocus" | "isInvalid" | "isRequired" | "name" | "spacing" | "isOpen" | "inputLabel" | "inputLabelId" | "openCalendarLabel" | "shouldShowCalendarButton" | "hideIcon"> & Partial<Pick<Omit<{
101
+ defaultIsOpen: boolean;
102
+ defaultValue: string;
103
+ disabled: string[];
104
+ disabledDateFilter: (_: string) => boolean;
105
+ locale: string;
106
+ onBlur: (_event: React.FocusEvent<HTMLInputElement>) => void;
107
+ onChange: (_value: string) => void;
108
+ onFocus: (_event: React.FocusEvent<HTMLInputElement>) => void;
109
+ } & DatePickerBaseProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "disabled" | "defaultValue" | "onFocus" | "onBlur" | "onChange" | "disabledDateFilter" | "locale" | "defaultIsOpen">> & Partial<Pick<{
110
+ defaultIsOpen: boolean;
111
+ defaultValue: string;
112
+ disabled: string[];
113
+ disabledDateFilter: (_: string) => boolean;
114
+ locale: string;
115
+ onBlur: (_event: React.FocusEvent<HTMLInputElement>) => void;
116
+ onChange: (_value: string) => void;
117
+ onFocus: (_event: React.FocusEvent<HTMLInputElement>) => void;
118
+ }, 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" | "isInvalid" | "isRequired" | "name" | "spacing" | "defaultIsOpen" | "isOpen" | "inputLabel" | "inputLabelId" | "openCalendarLabel" | "shouldShowCalendarButton" | "hideIcon"> & import("react").RefAttributes<any>>;
95
119
  export default DatePicker;
@@ -52,5 +52,5 @@ export { DateTimePickerComponent as DateTimePickerWithoutAnalytics };
52
52
  * - [Code](https://atlassian.design/components/datetime-picker/code)
53
53
  * - [Usage](https://atlassian.design/components/datetime-picker/usage)
54
54
  */
55
- declare const DateTimePicker: React.ForwardRefExoticComponent<Pick<Pick<Pick<Omit<DateTimePickerBaseProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, never> & Partial<Pick<Omit<DateTimePickerBaseProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "testId" | "appearance" | "innerProps" | "isDisabled" | "defaultValue" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "locale" | "value" | "autoFocus" | "isInvalid" | "name" | "spacing" | "clearControlLabel" | "datePickerProps" | "timePickerProps" | "parseValue">> & Partial<Pick<DateTimePickerBaseProps, "ref" | "createAnalyticsEvent">>, "testId" | "appearance" | "innerProps" | "isDisabled" | "defaultValue" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "locale" | "createAnalyticsEvent" | "value" | "autoFocus" | "isInvalid" | "name" | "spacing" | "clearControlLabel" | "datePickerProps" | "timePickerProps" | "parseValue"> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "testId" | "appearance" | "innerProps" | "isDisabled" | "key" | "defaultValue" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "locale" | "analyticsContext" | "createAnalyticsEvent" | "value" | "autoFocus" | "isInvalid" | "name" | "spacing" | "clearControlLabel" | "datePickerProps" | "timePickerProps" | "parseValue"> & React.RefAttributes<any>>;
55
+ declare const DateTimePicker: React.ForwardRefExoticComponent<Pick<Pick<Pick<Omit<DateTimePickerBaseProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, never> & Partial<Pick<Omit<DateTimePickerBaseProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "testId" | "appearance" | "innerProps" | "isDisabled" | "defaultValue" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "locale" | "value" | "autoFocus" | "isInvalid" | "isRequired" | "name" | "spacing" | "clearControlLabel" | "datePickerProps" | "timePickerProps" | "parseValue">> & Partial<Pick<DateTimePickerBaseProps, "ref" | "createAnalyticsEvent">>, "testId" | "appearance" | "innerProps" | "isDisabled" | "defaultValue" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "locale" | "createAnalyticsEvent" | "value" | "autoFocus" | "isInvalid" | "isRequired" | "name" | "spacing" | "clearControlLabel" | "datePickerProps" | "timePickerProps" | "parseValue"> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "testId" | "appearance" | "innerProps" | "isDisabled" | "key" | "defaultValue" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "locale" | "analyticsContext" | "createAnalyticsEvent" | "value" | "autoFocus" | "isInvalid" | "isRequired" | "name" | "spacing" | "clearControlLabel" | "datePickerProps" | "timePickerProps" | "parseValue"> & React.RefAttributes<any>>;
56
56
  export default DateTimePicker;
@@ -9,5 +9,5 @@ import { type TimePickerBaseProps } from '../types';
9
9
  * - [Code](https://atlassian.design/components/datetime-picker/time-picker/code)
10
10
  * - [Usage](https://atlassian.design/components/datetime-picker/time-picker/usage)
11
11
  */
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" | "createAnalyticsEvent" | "value" | "autoFocus" | "isInvalid" | "name" | "spacing" | "defaultIsOpen" | "isOpen" | "hideIcon" | "timeIsEditable" | "timeFormat"> & React.RefAttributes<unknown>>;
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" | "createAnalyticsEvent" | "value" | "autoFocus" | "isInvalid" | "isRequired" | "name" | "spacing" | "defaultIsOpen" | "isOpen" | "hideIcon" | "timeIsEditable" | "timeFormat"> & React.RefAttributes<unknown>>;
13
13
  export default TimePicker;
@@ -122,6 +122,10 @@ export interface DatePickerBaseProps extends WithAnalyticsEventsProps, PickerSel
122
122
  * Set if the picker is open.
123
123
  */
124
124
  isOpen?: boolean;
125
+ /**
126
+ * Sets the aria-required passed down to the combobox in the select component.
127
+ */
128
+ isRequired?: boolean;
125
129
  /**
126
130
  * The name of the field.
127
131
  */
@@ -142,6 +146,37 @@ export interface DatePickerBaseProps extends WithAnalyticsEventsProps, PickerSel
142
146
  * Called when the field is focused.
143
147
  */
144
148
  onFocus?: React.FocusEventHandler<HTMLInputElement>;
149
+ /**
150
+ * The name of the input, used when `shouldShowCalendarButton` is true. See `shouldShowCalendarButton` description for more details.
151
+ *
152
+ * @default 'Date picker'
153
+ */
154
+ inputLabel?: string;
155
+ /**
156
+ * The ID of the label for the input, used when `shouldShowCalendarButton` is
157
+ * true. See `shouldShowCalendarButton` description for more details.
158
+ */
159
+ inputLabelId?: string;
160
+ /**
161
+ * The label associated with the button to open the calendar, rendered via the
162
+ * `shouldShowCalendarButton` prop. If a `label` prop is provided, this
163
+ * calendar button label will be prefixed by the value of `label`. If no
164
+ * `label` prop is provided, this prefix should be manually added. For
165
+ * example,
166
+ *
167
+ * ```tsx
168
+ * <label id="label" htmlFor="datepicker">Desired Appointment Date</label>
169
+ * <DatePicker
170
+ * id="datepicker"
171
+ * shouldShowCalendarButton
172
+ * inputLabel="Desired Appointment Date"
173
+ * openCalendarLabel="open calendar"
174
+ * />
175
+ * ```
176
+ *
177
+ * @default 'open calendar'
178
+ */
179
+ openCalendarLabel?: string;
145
180
  /**
146
181
  * A function for parsing input characters and transforming them into a Date object.
147
182
  * By default parses the date string based off the locale.
@@ -155,6 +190,17 @@ export interface DatePickerBaseProps extends WithAnalyticsEventsProps, PickerSel
155
190
  * The aria-label attribute associated with the previous-month arrow.
156
191
  */
157
192
  previousMonthLabel?: string;
193
+ /**
194
+ * Provides a functional calendar button that opens the calendar picker that
195
+ * lives on the right side of the date picker.
196
+ *
197
+ * The accessible name for this button is caculated using either the `label`,
198
+ * `inputLabel`, or `inputLabelId` props, along with the `openCalendarLabel`
199
+ * prop.
200
+ *
201
+ * @default false
202
+ */
203
+ shouldShowCalendarButton?: boolean;
158
204
  /**
159
205
  * The spacing for the select control.
160
206
  *
@@ -257,6 +303,10 @@ export interface TimePickerBaseProps extends WithAnalyticsEventsProps, PickerSel
257
303
  * Set if the dropdown is open. Will be `false` if not provided.
258
304
  */
259
305
  isOpen?: boolean;
306
+ /**
307
+ * Sets the aria-required passed down to the combobox in the select component.
308
+ */
309
+ isRequired?: boolean;
260
310
  /**
261
311
  * Accessible name for the Time Picker Select, rendered as `aria-label`. This will override any other method of providing a label.
262
312
  */
@@ -369,6 +419,10 @@ export interface DateTimePickerBaseProps extends WithAnalyticsEventsProps {
369
419
  * Set if the field is disabled.
370
420
  */
371
421
  isDisabled?: boolean;
422
+ /**
423
+ * Sets the aria-required passed down to the combobox in the select component.
424
+ */
425
+ isRequired?: boolean;
372
426
  /**
373
427
  * The name of the field.
374
428
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/datetime-picker",
3
- "version": "15.1.4",
3
+ "version": "15.3.0",
4
4
  "description": "A date time picker allows the user to select an associated date and time.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -38,16 +38,18 @@
38
38
  "@atlaskit/analytics-next": "^10.1.0",
39
39
  "@atlaskit/calendar": "^15.0.0",
40
40
  "@atlaskit/ds-lib": "^3.0.0",
41
- "@atlaskit/icon": "^22.20.0",
41
+ "@atlaskit/icon": "^22.22.0",
42
42
  "@atlaskit/layering": "^0.5.0",
43
43
  "@atlaskit/locale": "^2.8.0",
44
44
  "@atlaskit/popper": "^6.3.0",
45
- "@atlaskit/select": "^18.0.0",
45
+ "@atlaskit/primitives": "^12.2.0",
46
+ "@atlaskit/select": "^18.1.0",
46
47
  "@atlaskit/theme": "^13.0.0",
47
48
  "@atlaskit/tokens": "^2.0.0",
48
49
  "@babel/runtime": "^7.0.0",
49
50
  "@emotion/react": "^11.7.1",
50
- "date-fns": "^2.17.0"
51
+ "date-fns": "^2.17.0",
52
+ "react-uid": "^2.2.0"
51
53
  },
52
54
  "peerDependencies": {
53
55
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0"