@kaizen/components 1.77.4 → 1.78.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 (43) hide show
  1. package/dist/cjs/src/Calendar/CalendarRange/CalendarRange.cjs +12 -13
  2. package/dist/cjs/src/Calendar/CalendarRange/CalendarRange.module.scss.cjs +2 -3
  3. package/dist/cjs/src/Calendar/CalendarSingle/CalendarSingle.cjs +8 -8
  4. package/dist/cjs/src/Calendar/LegacyCalendarRange/LegacyCalendarRange.cjs +11 -12
  5. package/dist/cjs/src/Calendar/LegacyCalendarRange/LegacyCalendarRange.module.scss.cjs +0 -1
  6. package/dist/cjs/src/Calendar/baseCalendarClassNames.cjs +11 -13
  7. package/dist/cjs/src/Calendar/baseCalendarClassNames.module.scss.cjs +1 -2
  8. package/dist/cjs/src/Calendar/utils/setFocusInCalendar.cjs +7 -6
  9. package/dist/esm/src/Calendar/CalendarRange/CalendarRange.mjs +12 -13
  10. package/dist/esm/src/Calendar/CalendarRange/CalendarRange.module.scss.mjs +2 -3
  11. package/dist/esm/src/Calendar/CalendarSingle/CalendarSingle.mjs +8 -8
  12. package/dist/esm/src/Calendar/LegacyCalendarRange/LegacyCalendarRange.mjs +11 -12
  13. package/dist/esm/src/Calendar/LegacyCalendarRange/LegacyCalendarRange.module.scss.mjs +0 -1
  14. package/dist/esm/src/Calendar/baseCalendarClassNames.mjs +11 -13
  15. package/dist/esm/src/Calendar/baseCalendarClassNames.module.scss.mjs +1 -2
  16. package/dist/esm/src/Calendar/utils/setFocusInCalendar.mjs +7 -6
  17. package/dist/styles.css +25 -27
  18. package/dist/types/Calendar/CalendarRange/CalendarRange.d.ts +2 -2
  19. package/dist/types/Calendar/CalendarSingle/CalendarSingle.d.ts +2 -2
  20. package/dist/types/Calendar/LegacyCalendarRange/LegacyCalendarRange.d.ts +3 -2
  21. package/dist/types/Calendar/baseCalendarClassNames.d.ts +2 -2
  22. package/package.json +7 -7
  23. package/src/Calendar/CalendarRange/CalendarRange.module.scss +13 -13
  24. package/src/Calendar/CalendarRange/CalendarRange.tsx +15 -11
  25. package/src/Calendar/CalendarRange/_docs/CalendarRange.stickersheet.stories.tsx +2 -1
  26. package/src/Calendar/CalendarSingle/CalendarSingle.module.scss +1 -0
  27. package/src/Calendar/CalendarSingle/CalendarSingle.tsx +11 -6
  28. package/src/Calendar/CalendarSingle/_docs/CalendarSingle.stickersheet.stories.tsx +8 -3
  29. package/src/Calendar/LegacyCalendarRange/LegacyCalendarRange.module.scss +5 -4
  30. package/src/Calendar/LegacyCalendarRange/LegacyCalendarRange.tsx +15 -11
  31. package/src/Calendar/baseCalendarClassNames.module.scss +12 -19
  32. package/src/Calendar/baseCalendarClassNames.ts +13 -15
  33. package/src/Calendar/utils/isSelectingDayInCalendar.spec.tsx +2 -1
  34. package/src/Calendar/utils/setFocusInCalendar.spec.tsx +8 -4
  35. package/src/Calendar/utils/setFocusInCalendar.ts +10 -10
  36. package/src/DatePicker/DatePicker.spec.tsx +10 -9
  37. package/src/DatePicker/DatePicker.tsx +2 -2
  38. package/src/Filter/FilterBar/subcomponents/FilterBarDatePicker/FilterBarDatePicker.spec.tsx +4 -2
  39. package/src/Filter/FilterBar/subcomponents/FilterBarDateRangePicker/FilterBarDateRangePicker.spec.tsx +6 -2
  40. package/src/Filter/FilterDatePicker/FilterDatePicker.spec.tsx +3 -2
  41. package/src/Filter/FilterDatePicker/subcomponents/FilterDatePickerField/FilterDatePickerField.spec.tsx +8 -4
  42. package/src/Filter/FilterDateRangePicker/_docs/FilterDateRangePicker.stories.tsx +2 -2
  43. package/src/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/FilterDateRangePickerField.spec.tsx +14 -8
@@ -6,7 +6,7 @@ $cell-border-radius: 3px;
6
6
  .month {
7
7
  padding: 0 $spacing-sm;
8
8
 
9
- &:first-child {
9
+ &:nth-of-type(1) {
10
10
  padding-inline-start: 0;
11
11
  }
12
12
 
@@ -19,7 +19,7 @@ $cell-border-radius: 3px;
19
19
  position: relative;
20
20
  padding: 0 $spacing-md;
21
21
 
22
- &:not(:first-child) {
22
+ &:not(:nth-of-type(1)) {
23
23
  &::before {
24
24
  position: absolute;
25
25
  content: '';
@@ -28,7 +28,7 @@ $cell-border-radius: 3px;
28
28
  }
29
29
  }
30
30
 
31
- &:first-child {
31
+ &:nth-of-type(1) {
32
32
  padding-inline-start: 0;
33
33
  }
34
34
 
@@ -40,18 +40,10 @@ $cell-border-radius: 3px;
40
40
  .nav {
41
41
  position: absolute;
42
42
  display: flex;
43
- justify-content: flex-start;
43
+ justify-content: space-between;
44
44
  width: 100%;
45
45
  color: $color-purple-800;
46
-
47
- .captionEnd & {
48
- flex-direction: row-reverse;
49
- }
50
-
51
- .captionStart.captionEnd & {
52
- justify-content: space-between;
53
- flex-direction: row;
54
- }
46
+ top: -0.25rem;
55
47
  }
56
48
 
57
49
  .dayRangeStart,
@@ -63,4 +55,12 @@ $cell-border-radius: 3px;
63
55
  .dayRangeMiddle {
64
56
  background-color: $color-blue-100;
65
57
  color: $color-blue-500;
58
+
59
+ & [class*='_button_'] {
60
+ color: $color-blue-500;
61
+ }
62
+ }
63
+
64
+ .hidden {
65
+ background-color: transparent;
66
66
  }
@@ -1,6 +1,6 @@
1
1
  import React, { useEffect, useRef } from 'react'
2
2
  import { enAU } from 'date-fns/locale'
3
- import { DayPicker, type DayPickerRangeProps } from 'react-day-picker'
3
+ import { DayPicker, type PropsBase, type PropsRange } from 'react-day-picker'
4
4
  import { Icon } from '~components/__next__/Icon'
5
5
  import { type OverrideClassName } from '~components/types/OverrideClassName'
6
6
  import { baseCalendarClassNames } from '../baseCalendarClassNames'
@@ -13,7 +13,7 @@ export type CalendarRangeProps = {
13
13
  id?: string
14
14
  onMount?: (calendarElement: CalendarRangeElement) => void
15
15
  hasDivider?: boolean
16
- } & OverrideClassName<Omit<DayPickerRangeProps, 'mode'>>
16
+ } & OverrideClassName<Omit<PropsRange & Omit<PropsBase, 'mode'>, 'mode'>>
17
17
 
18
18
  export const CalendarRange = ({
19
19
  id,
@@ -36,16 +36,15 @@ export const CalendarRange = ({
36
36
  const selectedMonth = monthToShow && isInvalidDate(monthToShow) ? undefined : monthToShow
37
37
 
38
38
  /* eslint-disable camelcase */
39
- const classNames = {
39
+ const classNames: PropsBase['classNames'] = {
40
40
  ...baseCalendarClassNames,
41
41
  month: hasDivider ? styles.monthWithDivider : styles.month,
42
- caption_end: styles.captionEnd,
43
- caption_start: styles.captionStart,
44
42
  nav: styles.nav,
45
- day_range_start: styles.dayRangeStart,
46
- day_range_end: styles.dayRangeEnd,
47
- day_range_middle: styles.dayRangeMiddle,
48
- } satisfies DayPickerRangeProps['classNames']
43
+ range_start: styles.dayRangeStart,
44
+ range_end: styles.dayRangeEnd,
45
+ range_middle: styles.dayRangeMiddle,
46
+ hidden: styles.hidden,
47
+ }
49
48
  /* eslint-enable camelcase */
50
49
 
51
50
  return (
@@ -56,8 +55,13 @@ export const CalendarRange = ({
56
55
  defaultMonth={selectedMonth}
57
56
  classNames={classNames}
58
57
  components={{
59
- IconRight: () => <Icon name="arrow_forward" isPresentational shouldMirrorInRTL />,
60
- IconLeft: () => <Icon name="arrow_back" isPresentational shouldMirrorInRTL />,
58
+ Chevron: (props) => {
59
+ if (props.orientation === 'left') {
60
+ return <Icon name="arrow_back" isPresentational shouldMirrorInRTL />
61
+ }
62
+
63
+ return <Icon name="arrow_forward" isPresentational shouldMirrorInRTL />
64
+ },
61
65
  }}
62
66
  numberOfMonths={numberOfMonths}
63
67
  locale={locale}
@@ -89,7 +89,8 @@ const applyStickerSheetStyles = (canvasElement: HTMLElement): void => {
89
89
  ): HTMLElement => {
90
90
  const calendar = canvas.getByTestId(id)
91
91
  const month = within(calendar).getByRole('grid', { name: monthName })
92
- return within(month).getByRole('gridcell', { name: dayName })
92
+ const day = within(month).getByRole('gridcell', { name: dayName })
93
+ return within(day).getByRole('button')
93
94
  }
94
95
 
95
96
  const calendarsPseudoStates = [
@@ -6,6 +6,7 @@
6
6
  justify-content: space-between;
7
7
  width: 100%;
8
8
  color: $color-purple-800;
9
+ top: -0.25rem;
9
10
  }
10
11
 
11
12
  .navButtonNext {
@@ -1,6 +1,6 @@
1
1
  import React, { useEffect, useRef } from 'react'
2
2
  import { enAU } from 'date-fns/locale'
3
- import { DayPicker, type DayPickerSingleProps } from 'react-day-picker'
3
+ import { DayPicker, type PropsBase, type PropsSingle } from 'react-day-picker'
4
4
  import { Icon } from '~components/__next__/Icon'
5
5
  import { type OverrideClassName } from '~components/types/OverrideClassName'
6
6
  import { baseCalendarClassNames } from '../baseCalendarClassNames'
@@ -12,7 +12,7 @@ export type CalendarSingleElement = HTMLDivElement
12
12
  export type CalendarSingleProps = {
13
13
  id?: string
14
14
  onMount?: (calendarElement: CalendarSingleElement) => void
15
- } & OverrideClassName<Omit<DayPickerSingleProps, 'mode'>>
15
+ } & OverrideClassName<Omit<PropsSingle & Omit<PropsBase, 'mode'>, 'mode'>>
16
16
 
17
17
  export const CalendarSingle = ({
18
18
  id,
@@ -34,11 +34,11 @@ export const CalendarSingle = ({
34
34
  const selectedMonth = monthToShow && isInvalidDate(monthToShow) ? undefined : monthToShow
35
35
 
36
36
  /* eslint-disable camelcase */
37
- const classNames = {
37
+ const classNames: PropsBase['classNames'] = {
38
38
  ...baseCalendarClassNames,
39
39
  nav: styles.nav,
40
40
  nav_button_next: styles.navButtonNext,
41
- } satisfies DayPickerSingleProps['classNames']
41
+ }
42
42
  /* eslint-enable camelcase */
43
43
 
44
44
  return (
@@ -50,8 +50,13 @@ export const CalendarSingle = ({
50
50
  weekStartsOn={isValidWeekStartsOn(weekStartsOn) ? weekStartsOn : undefined}
51
51
  classNames={classNames}
52
52
  components={{
53
- IconRight: () => <Icon name="arrow_forward" isPresentational shouldMirrorInRTL />,
54
- IconLeft: () => <Icon name="arrow_back" isPresentational shouldMirrorInRTL />,
53
+ Chevron: (props) => {
54
+ if (props.orientation === 'left') {
55
+ return <Icon name="arrow_back" isPresentational shouldMirrorInRTL />
56
+ }
57
+
58
+ return <Icon name="arrow_forward" isPresentational shouldMirrorInRTL />
59
+ },
55
60
  }}
56
61
  locale={locale}
57
62
  {...restProps}
@@ -89,9 +89,14 @@ const StickerSheetTemplate: StickerSheetStory = {
89
89
  const applyStickerSheetStyles = (canvasElement: HTMLElement): void => {
90
90
  const canvas = within(canvasElement)
91
91
 
92
- const getElementWithinCalendar = (id: string, role: string, name: string): HTMLElement => {
92
+ const getElementWithinCalendar = (
93
+ id: string,
94
+ role: string,
95
+ name: string | RegExp,
96
+ ): HTMLElement => {
93
97
  const calendar = canvas.getByTestId(id)
94
- return within(calendar).getByRole(role, { name })
98
+ const day = within(calendar).getByRole(role, { name })
99
+ return role === 'button' ? day : within(day).getByRole('button')
95
100
  }
96
101
 
97
102
  const todayCalendarIds = [
@@ -118,7 +123,7 @@ const applyStickerSheetStyles = (canvasElement: HTMLElement): void => {
118
123
  {
119
124
  id: 'id--calendar-navigation',
120
125
  role: 'button',
121
- name: 'Go to previous month',
126
+ name: /Go to the previous month/i,
122
127
  },
123
128
  ]
124
129
 
@@ -6,10 +6,7 @@
6
6
  justify-content: space-between;
7
7
  width: 100%;
8
8
  color: $color-purple-800;
9
- }
10
-
11
- .navButtonNext {
12
- inset-inline-end: 0;
9
+ top: -0.25rem;
13
10
  }
14
11
 
15
12
  .dayRangeStart,
@@ -21,4 +18,8 @@
21
18
  .dayRangeMiddle {
22
19
  background-color: $color-blue-100;
23
20
  color: $color-blue-500;
21
+
22
+ & [class*='_button_'] {
23
+ color: $color-blue-500;
24
+ }
24
25
  }
@@ -3,9 +3,9 @@ import type { Locale } from 'date-fns'
3
3
  import {
4
4
  DayPicker,
5
5
  type DateRange,
6
- type DayClickEventHandler,
7
- type DayPickerRangeProps,
6
+ type DayEventHandler,
8
7
  type Matcher,
8
+ type PropsBase,
9
9
  } from 'react-day-picker'
10
10
  import { Icon } from '~components/__next__/Icon'
11
11
  import { baseCalendarClassNames } from '../baseCalendarClassNames'
@@ -22,7 +22,7 @@ export type LegacyCalendarRangeProps = {
22
22
  disabledDays?: Matcher[]
23
23
  selectedRange?: DateRange
24
24
  locale: Locale
25
- onDayChange: DayClickEventHandler
25
+ onDayChange: DayEventHandler<React.MouseEvent>
26
26
  }
27
27
 
28
28
  export const LegacyCalendarRange = ({
@@ -38,14 +38,13 @@ export const LegacyCalendarRange = ({
38
38
  const selectedMonth = monthToShow && isInvalidDate(monthToShow) ? undefined : monthToShow
39
39
 
40
40
  /* eslint-disable camelcase */
41
- const classNames = {
41
+ const classNames: PropsBase['classNames'] = {
42
42
  ...baseCalendarClassNames,
43
43
  nav: styles.nav,
44
- nav_button_next: styles.navButtonNext,
45
- day_range_start: styles.dayRangeStart,
46
- day_range_end: styles.dayRangeEnd,
47
- day_range_middle: styles.dayRangeMiddle,
48
- } satisfies DayPickerRangeProps['classNames']
44
+ range_start: styles.dayRangeStart,
45
+ range_end: styles.dayRangeEnd,
46
+ range_middle: styles.dayRangeMiddle,
47
+ }
49
48
  /* eslint-enable camelcase */
50
49
 
51
50
  return (
@@ -59,8 +58,13 @@ export const LegacyCalendarRange = ({
59
58
  onDayClick={onDayChange}
60
59
  classNames={classNames}
61
60
  components={{
62
- IconRight: () => <Icon name="arrow_forward" isPresentational shouldMirrorInRTL />,
63
- IconLeft: () => <Icon name="arrow_back" isPresentational shouldMirrorInRTL />,
61
+ Chevron: (props) => {
62
+ if (props.orientation === 'left') {
63
+ return <Icon name="arrow_back" isPresentational shouldMirrorInRTL />
64
+ }
65
+
66
+ return <Icon name="arrow_forward" isPresentational shouldMirrorInRTL />
67
+ },
64
68
  }}
65
69
  locale={locale}
66
70
  />
@@ -41,6 +41,7 @@ $rdp-cell-size: 40px;
41
41
 
42
42
  .root {
43
43
  display: inline-flex;
44
+ position: relative;
44
45
  }
45
46
 
46
47
  .months {
@@ -56,7 +57,6 @@ $rdp-cell-size: 40px;
56
57
  }
57
58
 
58
59
  .caption {
59
- position: relative;
60
60
  display: flex;
61
61
  align-items: center;
62
62
  justify-content: center;
@@ -166,12 +166,17 @@ $rdp-cell-size: 40px;
166
166
 
167
167
  .daySelected {
168
168
  background-color: $color-blue-500;
169
+ border-radius: $button-border-radius;
169
170
  color: $color-white;
170
171
 
171
- &:hover,
172
- &:focus-visible {
173
- background-color: $color-blue-400;
172
+ & .button {
174
173
  color: $color-white;
174
+
175
+ &:hover,
176
+ &:focus-visible {
177
+ background-color: $color-blue-400;
178
+ color: $color-white;
179
+ }
175
180
  }
176
181
  }
177
182
 
@@ -182,20 +187,8 @@ $rdp-cell-size: 40px;
182
187
  // https://github.com/gpbl/react-day-picker/issues/1449#issuecomment-1149942033
183
188
  background: none;
184
189
  pointer-events: none;
185
- color: rgba($color-purple-800-rgb, 0.3);
186
- }
187
190
 
188
- // We can't use <VisuallyHidden />, so copied the styles here.
189
- %visually-hidden {
190
- clip: rect(0 0 0 0);
191
- clip-path: inset(50%);
192
- height: 1px;
193
- overflow: hidden;
194
- position: absolute;
195
- white-space: nowrap;
196
- width: 1px;
197
- }
198
-
199
- .vHidden {
200
- @extend %visually-hidden;
191
+ & [class*='_button_'] {
192
+ color: rgba($color-purple-800-rgb, 0.3);
193
+ }
201
194
  }
@@ -1,22 +1,20 @@
1
1
  /* eslint-disable camelcase */
2
- import { type ClassNames } from 'react-day-picker'
2
+ import { type PropsBase } from 'react-day-picker'
3
3
  import styles from './baseCalendarClassNames.module.scss'
4
4
 
5
- export const baseCalendarClassNames: ClassNames = {
6
- vhidden: styles.vHidden,
5
+ export const baseCalendarClassNames: PropsBase['classNames'] = {
7
6
  root: styles.root,
8
7
  months: styles.months,
9
- button_reset: styles.buttonReset,
10
- button: styles.button,
11
- caption: styles.caption,
8
+ day_button: `${styles.buttonReset} ${styles.button} ${styles.day}`,
9
+ button_next: `${styles.buttonReset} ${styles.button} ${styles.navButton}`,
10
+ button_previous: `${styles.buttonReset} ${styles.button} ${styles.navButton}`,
11
+ day: styles.cell,
12
+ month_caption: styles.caption,
12
13
  caption_label: styles.captionLabel,
13
- nav_button: styles.navButton,
14
- table: styles.table,
15
- head_cell: styles.weekday,
16
- cell: styles.cell,
17
- day: styles.day,
18
- tbody: styles.tbody,
19
- day_selected: styles.daySelected,
20
- day_today: styles.dayToday,
21
- day_disabled: styles.dayDisabled,
14
+ month_grid: styles.table,
15
+ weekday: styles.weekday,
16
+ weeks: styles.tbody,
17
+ selected: styles.daySelected,
18
+ today: styles.dayToday,
19
+ disabled: styles.dayDisabled,
22
20
  }
@@ -8,7 +8,8 @@ describe('isSelectingDayInCalendar', () => {
8
8
  render(<CalendarSingle defaultMonth={new Date('2022-02-01')} />)
9
9
  const targetMonth = screen.getByRole('grid', { name: 'February 2022' })
10
10
  const targetDay = within(targetMonth).getByRole('gridcell', { name: '1' })
11
- expect(isSelectingDayInCalendar(targetDay)).toBe(true)
11
+ const targetBtn = within(targetDay).getByRole('button')
12
+ expect(isSelectingDayInCalendar(targetBtn)).toBe(true)
12
13
  })
13
14
 
14
15
  it('returns false when target is not a Calendar day', () => {
@@ -27,7 +27,8 @@ describe('setFocusInCalendar', () => {
27
27
  const targetDay = within(targetMonth).getByRole('gridcell', {
28
28
  name: todayDay,
29
29
  })
30
- expect(targetDay).toHaveFocus()
30
+ const targetBtn = within(targetDay).getByRole('button')
31
+ expect(targetBtn).toHaveFocus()
31
32
  })
32
33
 
33
34
  it('should focus on the selected day', () => {
@@ -35,7 +36,8 @@ describe('setFocusInCalendar', () => {
35
36
 
36
37
  const targetMonth = screen.getByRole('grid', { name: 'August 2022' })
37
38
  const targetDay = within(targetMonth).getByRole('gridcell', { name: '15' })
38
- expect(targetDay).toHaveFocus()
39
+ const targetBtn = within(targetDay).getByRole('button')
40
+ expect(targetBtn).toHaveFocus()
39
41
  })
40
42
 
41
43
  it('should focus on today when selected date is invalid', () => {
@@ -45,7 +47,8 @@ describe('setFocusInCalendar', () => {
45
47
  const targetDay = within(targetMonth).getByRole('gridcell', {
46
48
  name: todayDay,
47
49
  })
48
- expect(targetDay).toHaveFocus()
50
+ const targetBtn = within(targetDay).getByRole('button')
51
+ expect(targetBtn).toHaveFocus()
49
52
  })
50
53
 
51
54
  it('should focus on the first of the month when there is no selected day nor in the current month', () => {
@@ -53,6 +56,7 @@ describe('setFocusInCalendar', () => {
53
56
 
54
57
  const targetMonth = screen.getByRole('grid', { name: 'May 2022' })
55
58
  const targetDay = within(targetMonth).getByRole('gridcell', { name: '1' })
56
- expect(targetDay).toHaveFocus()
59
+ const targetBtn = within(targetDay).getByRole('button')
60
+ expect(targetBtn).toHaveFocus()
57
61
  })
58
62
  })
@@ -3,21 +3,21 @@ import { type CalendarSingleElement } from '../CalendarSingle'
3
3
  import calendarStyles from '../baseCalendarClassNames.module.scss'
4
4
  import { isInvalidDate } from './isInvalidDate'
5
5
 
6
- const isHTMLElement = (element: Element | undefined): element is HTMLElement =>
7
- element instanceof HTMLElement
8
-
9
6
  export const setFocusInCalendar = (
10
7
  calendarElement: CalendarSingleElement | CalendarRangeElement,
11
8
  selectedDay: Date | undefined,
12
9
  ): void => {
13
- const daySelectedOrToday = calendarElement.getElementsByClassName(
10
+ const dayClass =
14
11
  selectedDay && !isInvalidDate(selectedDay)
15
- ? calendarStyles.daySelected
16
- : calendarStyles.dayToday,
17
- )[0]
12
+ ? `.${calendarStyles.daySelected}`
13
+ : `.${calendarStyles.dayToday}`
14
+
15
+ let dayToFocus = calendarElement.querySelector(`${dayClass} button`)
18
16
 
19
- const dayToFocus =
20
- daySelectedOrToday ?? calendarElement.getElementsByClassName(calendarStyles.day)[0]
17
+ // RDP v9 puts the day class on the button inside the table cell whereas today and selected appear on the table cell
18
+ dayToFocus ??= calendarElement.querySelector(`.${calendarStyles.day}`)
21
19
 
22
- if (isHTMLElement(dayToFocus)) dayToFocus.focus()
20
+ if (dayToFocus instanceof HTMLElement) {
21
+ dayToFocus.focus()
22
+ }
23
23
  }
@@ -91,11 +91,8 @@ describe('<DatePicker />', () => {
91
91
  expect(screen.getByRole('dialog')).toBeVisible()
92
92
  })
93
93
 
94
+ // TODO: For some reason a single tab no longer jumps out of input to the button
94
95
  await user.tab()
95
- await waitFor(() => {
96
- expect(input).toHaveFocus()
97
- })
98
-
99
96
  await user.tab()
100
97
  await waitFor(() => {
101
98
  const calendarButton = screen.getByRole('button', { name: 'Choose date' })
@@ -105,7 +102,7 @@ describe('<DatePicker />', () => {
105
102
  await user.tab()
106
103
  await waitFor(() => {
107
104
  const arrowButton = screen.getByRole('button', {
108
- name: 'Go to previous month',
105
+ name: /Go to the previous month/i,
109
106
  })
110
107
  expect(arrowButton).toHaveFocus()
111
108
  })
@@ -168,7 +165,8 @@ describe('<DatePicker /> - Focus element', () => {
168
165
 
169
166
  const month = screen.getByRole('grid', { name: 'March 2022' })
170
167
  const dateToSelect = within(month).getByRole('gridcell', { name: '6' })
171
- await user.click(dateToSelect)
168
+ const dateToSelectButton = within(dateToSelect).getByRole('button')
169
+ await user.click(dateToSelectButton)
172
170
 
173
171
  const input = screen.getByLabelText('Input label', { selector: 'input' })
174
172
  expect(input).toHaveFocus()
@@ -192,7 +190,8 @@ describe('<DatePicker /> - Focus element', () => {
192
190
 
193
191
  const month = screen.getByRole('grid', { name: 'March 2022' })
194
192
  const selectedDate = within(month).getByRole('gridcell', { name: '1' })
195
- expect(selectedDate).toHaveFocus()
193
+ const selectedDateButton = within(selectedDate).getByRole('button')
194
+ expect(selectedDateButton).toHaveFocus()
196
195
  })
197
196
 
198
197
  it('returns focus to the input when the user escapes from the calendar', async () => {
@@ -233,7 +232,8 @@ describe('<DatePicker /> - Focus element', () => {
233
232
 
234
233
  const month = screen.getByRole('grid', { name: 'March 2022' })
235
234
  const selectedDate = within(month).getByRole('gridcell', { name: '1' })
236
- expect(selectedDate).toHaveFocus()
235
+ const selectedDateButton = within(selectedDate).getByRole('button')
236
+ expect(selectedDateButton).toHaveFocus()
237
237
  })
238
238
 
239
239
  it('returns focus to the calendar button when the user escapes from the calendar', async () => {
@@ -277,7 +277,8 @@ describe('<DatePicker /> - Focus element', () => {
277
277
 
278
278
  const month = screen.getByRole('grid', { name: 'March 2022' })
279
279
  const selectedDate = within(month).getByRole('gridcell', { name: '1' })
280
- expect(selectedDate).toHaveFocus()
280
+ const selectedDateButton = within(selectedDate).getByRole('button')
281
+ expect(selectedDateButton).toHaveFocus()
281
282
  })
282
283
 
283
284
  it('returns focus to the input when the user escapes from the calendar', async () => {
@@ -1,6 +1,6 @@
1
1
  import React, { useEffect, useId, useRef, useState, type RefObject } from 'react'
2
2
  import { useIntl } from '@cultureamp/i18n-react-intl'
3
- import { type DayClickEventHandler } from 'react-day-picker'
3
+ import { type DayEventHandler } from 'react-day-picker'
4
4
  import { FocusOn } from 'react-focus-on'
5
5
  import {
6
6
  CalendarSingle,
@@ -161,7 +161,7 @@ export const DatePicker = ({
161
161
  onDayChange(newDate)
162
162
  }
163
163
 
164
- const handleCalendarDayChange: DayClickEventHandler = (date) => {
164
+ const handleCalendarDayChange: DayEventHandler<React.MouseEvent> = (date) => {
165
165
  if (!isDisabledDate(date, disabledDays)) {
166
166
  const newInputValue =
167
167
  lastTrigger === 'calendarButton'
@@ -127,8 +127,9 @@ describe('<FilterBarDatePicker />', () => {
127
127
 
128
128
  const targetMonth = screen.getByRole('grid', { name: 'June 2023' })
129
129
  const targetDay = within(targetMonth).getByRole('gridcell', { name: '7' })
130
+ const targetBtn = within(targetDay).getByRole('button')
130
131
 
131
- await user.click(targetDay)
132
+ await user.click(targetBtn)
132
133
 
133
134
  await waitFor(() => {
134
135
  expect(screen.getByRole('button', { name: 'Drank : 7 Jun 2023' })).toBeInTheDocument()
@@ -148,7 +149,8 @@ describe('<FilterBarDatePicker />', () => {
148
149
 
149
150
  const targetMonth = screen.getByRole('grid', { name: 'June 2023' })
150
151
  const targetDay = within(targetMonth).getByRole('gridcell', { name: '7' })
151
- await user.click(targetDay)
152
+ const targetBtn = within(targetDay).getByRole('button')
153
+ await user.click(targetBtn)
152
154
 
153
155
  await waitFor(() => {
154
156
  expect(onChange.mock.calls).toEqual([[new Date('2023-06-07')]])
@@ -138,7 +138,9 @@ describe('<FilterBarDateRangePicker />', () => {
138
138
 
139
139
  const targetMonth = screen.getByRole('grid', { name: 'June 2022' })
140
140
  const targetDay = within(targetMonth).getByRole('gridcell', { name: '23' })
141
- await user.click(targetDay)
141
+ const targetBtn = within(targetDay).getByRole('button')
142
+
143
+ await user.click(targetBtn)
142
144
  await user.click(document.body) // Exit the focus lock
143
145
 
144
146
  await waitFor(() => {
@@ -170,7 +172,9 @@ describe('<FilterBarDateRangePicker />', () => {
170
172
 
171
173
  const targetMonth = screen.getByRole('grid', { name: 'June 2022' })
172
174
  const targetDay = within(targetMonth).getByRole('gridcell', { name: '23' })
173
- await user.click(targetDay)
175
+ const targetBtn = within(targetDay).getByRole('button')
176
+
177
+ await user.click(targetBtn)
174
178
 
175
179
  await waitFor(() => {
176
180
  expect(onChange).toHaveBeenCalledWith({
@@ -75,7 +75,8 @@ describe('<FilterDatePicker />', () => {
75
75
 
76
76
  const targetMonth = screen.getByRole('grid', { name: 'May 2022' })
77
77
  const targetDay = within(targetMonth).getByRole('gridcell', { name: '2' })
78
- await user.click(targetDay)
78
+ const targetBtn = within(targetDay).getByRole('button')
79
+ await user.click(targetBtn)
79
80
 
80
81
  await waitFor(() => {
81
82
  expect(dialog).not.toBeInTheDocument()
@@ -196,7 +197,7 @@ describe('<FilterDatePicker />', () => {
196
197
  })
197
198
 
198
199
  const navigateMonthsButton = getByRole('button', {
199
- name: 'Go to next month',
200
+ name: /Go to the next month/i,
200
201
  })
201
202
 
202
203
  await user.click(navigateMonthsButton)
@@ -191,7 +191,8 @@ describe('<FilterDatePickerField />', () => {
191
191
  const targetDay = within(targetMonth).getByRole('gridcell', {
192
192
  name: '15',
193
193
  })
194
- await user.click(targetDay)
194
+ const targetBtn = within(targetDay).getByRole('button')
195
+ await user.click(targetBtn)
195
196
 
196
197
  await waitFor(() => {
197
198
  expect(inputDateOnSubmit).toHaveBeenCalled()
@@ -210,7 +211,8 @@ describe('<FilterDatePickerField />', () => {
210
211
  name: '12',
211
212
  })
212
213
  expect(targetDay).not.toHaveAttribute('aria-selected')
213
- await user.click(targetDay)
214
+ const targetBtn = within(targetDay).getByRole('button')
215
+ await user.click(targetBtn)
214
216
 
215
217
  await waitFor(() => {
216
218
  expect(targetDay).toHaveAttribute('aria-selected', 'true')
@@ -229,7 +231,8 @@ describe('<FilterDatePickerField />', () => {
229
231
  const firstSelectedDay = within(targetMonth).getByRole('gridcell', {
230
232
  name: '15',
231
233
  })
232
- await user.click(firstSelectedDay)
234
+ const targetBtn = within(firstSelectedDay).getByRole('button')
235
+ await user.click(targetBtn)
233
236
 
234
237
  await waitFor(() => {
235
238
  expect(inputDate).toHaveValue('')
@@ -323,7 +326,8 @@ describe('<FilterDatePickerField />', () => {
323
326
  const targetDay = within(targetMonth).getByRole('gridcell', {
324
327
  name: '12',
325
328
  })
326
- await user.click(targetDay)
329
+ const targetBtn = within(targetDay).getByRole('button')
330
+ await user.click(targetBtn)
327
331
 
328
332
  await waitFor(() => {
329
333
  expect(dateErrorContainer).not.toBeInTheDocument()
@@ -454,8 +454,8 @@ export const OnSmallViewport: Story = {
454
454
 
455
455
  await step('Back and Forward arrow and both visible', async () => {
456
456
  await waitFor(() => {
457
- const prevMonth = canvas.getByLabelText('Go to previous month')
458
- const nextMonth = canvas.getByLabelText('Go to next month')
457
+ const prevMonth = canvas.getByLabelText(/Go to the previous month/i)
458
+ const nextMonth = canvas.getByLabelText(/Go to the next month/i)
459
459
 
460
460
  expect(prevMonth).toBeVisible()
461
461
  expect(nextMonth).toBeVisible()