@kaizen/components 1.77.3 → 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.
- package/dist/cjs/src/Calendar/CalendarRange/CalendarRange.cjs +12 -13
- package/dist/cjs/src/Calendar/CalendarRange/CalendarRange.module.scss.cjs +2 -3
- package/dist/cjs/src/Calendar/CalendarSingle/CalendarSingle.cjs +8 -8
- package/dist/cjs/src/Calendar/LegacyCalendarRange/LegacyCalendarRange.cjs +11 -12
- package/dist/cjs/src/Calendar/LegacyCalendarRange/LegacyCalendarRange.module.scss.cjs +0 -1
- package/dist/cjs/src/Calendar/baseCalendarClassNames.cjs +11 -13
- package/dist/cjs/src/Calendar/baseCalendarClassNames.module.scss.cjs +1 -2
- package/dist/cjs/src/Calendar/utils/setFocusInCalendar.cjs +7 -6
- package/dist/cjs/src/RichTextEditor/utils/schema/marks.cjs +6 -5
- package/dist/esm/src/Calendar/CalendarRange/CalendarRange.mjs +12 -13
- package/dist/esm/src/Calendar/CalendarRange/CalendarRange.module.scss.mjs +2 -3
- package/dist/esm/src/Calendar/CalendarSingle/CalendarSingle.mjs +8 -8
- package/dist/esm/src/Calendar/LegacyCalendarRange/LegacyCalendarRange.mjs +11 -12
- package/dist/esm/src/Calendar/LegacyCalendarRange/LegacyCalendarRange.module.scss.mjs +0 -1
- package/dist/esm/src/Calendar/baseCalendarClassNames.mjs +11 -13
- package/dist/esm/src/Calendar/baseCalendarClassNames.module.scss.mjs +1 -2
- package/dist/esm/src/Calendar/utils/setFocusInCalendar.mjs +7 -6
- package/dist/esm/src/RichTextEditor/utils/schema/marks.mjs +6 -5
- package/dist/styles.css +26 -28
- package/dist/types/Calendar/CalendarRange/CalendarRange.d.ts +2 -2
- package/dist/types/Calendar/CalendarSingle/CalendarSingle.d.ts +2 -2
- package/dist/types/Calendar/LegacyCalendarRange/LegacyCalendarRange.d.ts +3 -2
- package/dist/types/Calendar/baseCalendarClassNames.d.ts +2 -2
- package/dist/types/RichTextEditor/utils/schema/marks.d.ts +1 -1
- package/package.json +42 -42
- package/src/Calendar/CalendarRange/CalendarRange.module.scss +13 -13
- package/src/Calendar/CalendarRange/CalendarRange.tsx +15 -11
- package/src/Calendar/CalendarRange/_docs/CalendarRange.stickersheet.stories.tsx +2 -1
- package/src/Calendar/CalendarSingle/CalendarSingle.module.scss +1 -0
- package/src/Calendar/CalendarSingle/CalendarSingle.tsx +11 -6
- package/src/Calendar/CalendarSingle/_docs/CalendarSingle.stickersheet.stories.tsx +8 -3
- package/src/Calendar/LegacyCalendarRange/LegacyCalendarRange.module.scss +5 -4
- package/src/Calendar/LegacyCalendarRange/LegacyCalendarRange.tsx +15 -11
- package/src/Calendar/baseCalendarClassNames.module.scss +12 -19
- package/src/Calendar/baseCalendarClassNames.ts +13 -15
- package/src/Calendar/utils/isSelectingDayInCalendar.spec.tsx +2 -1
- package/src/Calendar/utils/setFocusInCalendar.spec.tsx +8 -4
- package/src/Calendar/utils/setFocusInCalendar.ts +10 -10
- package/src/DatePicker/DatePicker.spec.tsx +10 -9
- package/src/DatePicker/DatePicker.tsx +2 -2
- package/src/Filter/FilterBar/subcomponents/FilterBarDatePicker/FilterBarDatePicker.spec.tsx +4 -2
- package/src/Filter/FilterBar/subcomponents/FilterBarDateRangePicker/FilterBarDateRangePicker.spec.tsx +6 -2
- package/src/Filter/FilterDatePicker/FilterDatePicker.spec.tsx +3 -2
- package/src/Filter/FilterDatePicker/subcomponents/FilterDatePickerField/FilterDatePickerField.spec.tsx +8 -4
- package/src/Filter/FilterDateRangePicker/_docs/FilterDateRangePicker.stories.tsx +2 -2
- package/src/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/FilterDateRangePickerField.spec.tsx +14 -8
- package/src/RichTextEditor/utils/schema/marks.ts +9 -8
|
@@ -3,9 +3,9 @@ import type { Locale } from 'date-fns'
|
|
|
3
3
|
import {
|
|
4
4
|
DayPicker,
|
|
5
5
|
type DateRange,
|
|
6
|
-
type
|
|
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:
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
63
|
-
|
|
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
|
-
|
|
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
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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
|
|
2
|
+
import { type PropsBase } from 'react-day-picker'
|
|
3
3
|
import styles from './baseCalendarClassNames.module.scss'
|
|
4
4
|
|
|
5
|
-
export const baseCalendarClassNames:
|
|
6
|
-
vhidden: styles.vHidden,
|
|
5
|
+
export const baseCalendarClassNames: PropsBase['classNames'] = {
|
|
7
6
|
root: styles.root,
|
|
8
7
|
months: styles.months,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
10
|
+
const dayClass =
|
|
14
11
|
selectedDay && !isInvalidDate(selectedDay)
|
|
15
|
-
? calendarStyles.daySelected
|
|
16
|
-
: calendarStyles.dayToday
|
|
17
|
-
|
|
12
|
+
? `.${calendarStyles.daySelected}`
|
|
13
|
+
: `.${calendarStyles.dayToday}`
|
|
14
|
+
|
|
15
|
+
let dayToFocus = calendarElement.querySelector(`${dayClass} button`)
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
|
|
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 (
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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:
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
458
|
-
const nextMonth = canvas.getByLabelText(
|
|
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()
|
|
@@ -254,7 +254,9 @@ describe('<FilterDateRangePickerField />', () => {
|
|
|
254
254
|
name: '12',
|
|
255
255
|
})
|
|
256
256
|
expect(targetDay).not.toHaveAttribute('aria-selected')
|
|
257
|
-
|
|
257
|
+
|
|
258
|
+
const targetBtn = within(targetDay).getByRole('button')
|
|
259
|
+
await user.click(targetBtn)
|
|
258
260
|
|
|
259
261
|
await waitFor(() => {
|
|
260
262
|
expect(targetDay).toHaveAttribute('aria-selected', 'true')
|
|
@@ -281,7 +283,8 @@ describe('<FilterDateRangePickerField />', () => {
|
|
|
281
283
|
name: '23',
|
|
282
284
|
})
|
|
283
285
|
expect(targetDay).not.toHaveAttribute('aria-selected')
|
|
284
|
-
|
|
286
|
+
const targetBtn = within(targetDay).getByRole('button')
|
|
287
|
+
await user.click(targetBtn)
|
|
285
288
|
|
|
286
289
|
await waitFor(() => {
|
|
287
290
|
expect(targetDay).toHaveAttribute('aria-selected', 'true')
|
|
@@ -289,7 +292,7 @@ describe('<FilterDateRangePickerField />', () => {
|
|
|
289
292
|
})
|
|
290
293
|
})
|
|
291
294
|
|
|
292
|
-
it('
|
|
295
|
+
it('sets the range end date to match the start date when clicking on the start date with an active range', async () => {
|
|
293
296
|
render(
|
|
294
297
|
<FilterDateRangePickerFieldWrapper
|
|
295
298
|
selectedRange={{
|
|
@@ -302,18 +305,20 @@ describe('<FilterDateRangePickerField />', () => {
|
|
|
302
305
|
|
|
303
306
|
const inputStartDate = screen.getByLabelText('Date from')
|
|
304
307
|
const inputEndDate = screen.getByLabelText('Date to')
|
|
305
|
-
|
|
308
|
+
const startDate = '15 May 2022'
|
|
309
|
+
expect(inputStartDate).toHaveValue(startDate)
|
|
306
310
|
expect(inputEndDate).toHaveValue('22 May 2022')
|
|
307
311
|
|
|
308
312
|
const targetMonth = screen.getByRole('grid', { name: 'May 2022' })
|
|
309
313
|
const firstSelectedDay = within(targetMonth).getByRole('gridcell', {
|
|
310
314
|
name: '15',
|
|
311
315
|
})
|
|
312
|
-
|
|
316
|
+
const firstSelectedDayBtn = within(firstSelectedDay).getByRole('button')
|
|
317
|
+
await user.click(firstSelectedDayBtn)
|
|
313
318
|
|
|
314
319
|
await waitFor(() => {
|
|
315
|
-
expect(inputStartDate).toHaveValue(
|
|
316
|
-
expect(inputEndDate).toHaveValue(
|
|
320
|
+
expect(inputStartDate).toHaveValue(startDate)
|
|
321
|
+
expect(inputEndDate).toHaveValue(startDate)
|
|
317
322
|
})
|
|
318
323
|
})
|
|
319
324
|
})
|
|
@@ -634,7 +639,8 @@ describe('<FilterDateRangePickerField />', () => {
|
|
|
634
639
|
const targetDay = within(targetMonth).getByRole('gridcell', {
|
|
635
640
|
name: '12',
|
|
636
641
|
})
|
|
637
|
-
|
|
642
|
+
const targetBtn = within(targetDay).getByRole('button')
|
|
643
|
+
await user.click(targetBtn)
|
|
638
644
|
|
|
639
645
|
await waitFor(() => {
|
|
640
646
|
expect(dateEndErrorContainer).not.toBeInTheDocument()
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Mark, MarkSpec } from 'prosemirror-model'
|
|
2
2
|
import { marks as proseMarks } from 'prosemirror-schema-basic'
|
|
3
3
|
import { validateLink } from '../plugins/LinkManager/validation'
|
|
4
4
|
|
|
5
|
-
export const getMarks = (): MarkSpec => ({
|
|
5
|
+
export const getMarks = (): Record<string, MarkSpec> => ({
|
|
6
6
|
...proseMarks,
|
|
7
7
|
|
|
8
8
|
// An underline mark. Rendered as a `<u>` element. Has parse rules that also
|
|
@@ -26,18 +26,19 @@ export const getMarks = (): MarkSpec => ({
|
|
|
26
26
|
parseDOM: [
|
|
27
27
|
{
|
|
28
28
|
tag: 'a[href]',
|
|
29
|
-
getAttrs(dom:
|
|
29
|
+
getAttrs(dom: HTMLElement) {
|
|
30
|
+
const anchor = dom as HTMLAnchorElement
|
|
30
31
|
return {
|
|
31
|
-
href: getAttributeWithDefault(
|
|
32
|
-
target: getAttributeWithDefault(
|
|
33
|
-
rel: getAttributeWithDefault(
|
|
32
|
+
href: getAttributeWithDefault(anchor, 'href'),
|
|
33
|
+
target: getAttributeWithDefault(anchor, 'target'),
|
|
34
|
+
rel: getAttributeWithDefault(anchor, 'rel'),
|
|
34
35
|
_metadata: null,
|
|
35
36
|
}
|
|
36
37
|
},
|
|
37
38
|
},
|
|
38
39
|
],
|
|
39
|
-
toDOM(
|
|
40
|
-
const { href, target, rel } =
|
|
40
|
+
toDOM(mark: Mark) {
|
|
41
|
+
const { href, target, rel } = mark.attrs
|
|
41
42
|
const validationStatus = validateLink(href)
|
|
42
43
|
|
|
43
44
|
if (validationStatus.status === 'error') {
|