@kaizen/components 1.77.4 → 1.78.1
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/Filter/FilterBar/subcomponents/FilterBarSelect/FilterBarSelect.cjs +1 -1
- 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/Filter/FilterBar/subcomponents/FilterBarSelect/FilterBarSelect.mjs +1 -1
- package/dist/styles.css +8658 -8661
- 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/package.json +33 -32
- package/src/Avatar/Avatar.module.css +1 -1
- package/src/Badge/Badge.module.css +3 -3
- 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/FilterBar/subcomponents/FilterBarSelect/FilterBarSelect.tsx +1 -1
- 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/Link/Link.module.css +2 -2
- package/src/Pagination/subcomponents/TruncateIndicator/TruncateIndicator.module.css +1 -1
- package/src/Popover/Popover.module.scss +1 -1
- package/src/Radio/RadioField/RadioField.module.scss +2 -3
- package/src/Table/Table.module.scss +2 -2
- package/src/TextArea/TextArea.module.css +7 -7
- package/src/Workflow/subcomponents/Footer/components/Root/FooterRoot.module.css +1 -1
- package/src/__next__/Button/Button.module.css +11 -11
- package/src/__next__/Select/subcomponents/SelectToggle/SelectToggle.module.scss +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type PropsBase, type PropsRange } from 'react-day-picker';
|
|
2
2
|
import { type OverrideClassName } from "../../types/OverrideClassName";
|
|
3
3
|
export type CalendarRangeElement = HTMLDivElement;
|
|
4
4
|
export type CalendarRangeProps = {
|
|
5
5
|
id?: string;
|
|
6
6
|
onMount?: (calendarElement: CalendarRangeElement) => void;
|
|
7
7
|
hasDivider?: boolean;
|
|
8
|
-
} & OverrideClassName<Omit<
|
|
8
|
+
} & OverrideClassName<Omit<PropsRange & Omit<PropsBase, 'mode'>, 'mode'>>;
|
|
9
9
|
export declare const CalendarRange: {
|
|
10
10
|
({ id, onMount, hasDivider, classNameOverride, selected, defaultMonth, numberOfMonths, locale, ...restProps }: CalendarRangeProps): JSX.Element;
|
|
11
11
|
displayName: string;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type PropsBase, type PropsSingle } from 'react-day-picker';
|
|
2
2
|
import { type OverrideClassName } from "../../types/OverrideClassName";
|
|
3
3
|
export type CalendarSingleElement = HTMLDivElement;
|
|
4
4
|
export type CalendarSingleProps = {
|
|
5
5
|
id?: string;
|
|
6
6
|
onMount?: (calendarElement: CalendarSingleElement) => void;
|
|
7
|
-
} & OverrideClassName<Omit<
|
|
7
|
+
} & OverrideClassName<Omit<PropsSingle & Omit<PropsBase, 'mode'>, 'mode'>>;
|
|
8
8
|
export declare const CalendarSingle: {
|
|
9
9
|
({ id, onMount, classNameOverride, selected, defaultMonth, weekStartsOn, locale, ...restProps }: CalendarSingleProps): JSX.Element;
|
|
10
10
|
displayName: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import type { Locale } from 'date-fns';
|
|
2
|
-
import { type DateRange, type
|
|
3
|
+
import { type DateRange, type DayEventHandler, type Matcher } from 'react-day-picker';
|
|
3
4
|
import { DayOfWeek } from '../enums';
|
|
4
5
|
export type LegacyCalendarRangeElement = HTMLDivElement;
|
|
5
6
|
export type LegacyCalendarRangeProps = {
|
|
@@ -9,7 +10,7 @@ export type LegacyCalendarRangeProps = {
|
|
|
9
10
|
disabledDays?: Matcher[];
|
|
10
11
|
selectedRange?: DateRange;
|
|
11
12
|
locale: Locale;
|
|
12
|
-
onDayChange:
|
|
13
|
+
onDayChange: DayEventHandler<React.MouseEvent>;
|
|
13
14
|
};
|
|
14
15
|
export declare const LegacyCalendarRange: {
|
|
15
16
|
({ classNameOverride, defaultMonth, weekStartsOn, disabledDays, selectedRange, locale, onDayChange, }: LegacyCalendarRangeProps): JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export declare const baseCalendarClassNames:
|
|
1
|
+
import { type PropsBase } from 'react-day-picker';
|
|
2
|
+
export declare const baseCalendarClassNames: PropsBase['classNames'];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaizen/components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.78.1",
|
|
4
4
|
"description": "Kaizen component library",
|
|
5
5
|
"author": "Geoffrey Chong <geoff.chong@cultureamp.com>",
|
|
6
6
|
"homepage": "https://cultureamp.design",
|
|
@@ -103,25 +103,25 @@
|
|
|
103
103
|
},
|
|
104
104
|
"dependencies": {
|
|
105
105
|
"@floating-ui/react-dom": "^2.1.2",
|
|
106
|
-
"@headlessui/react": "^2.2.
|
|
107
|
-
"@internationalized/date": "^3.8.
|
|
106
|
+
"@headlessui/react": "^2.2.4",
|
|
107
|
+
"@internationalized/date": "^3.8.1",
|
|
108
108
|
"@popperjs/core": "^2.11.8",
|
|
109
109
|
"@reach/tabs": "^0.18.0",
|
|
110
|
-
"@react-aria/button": "^3.13.
|
|
111
|
-
"@react-aria/datepicker": "^3.14.
|
|
112
|
-
"@react-aria/focus": "^3.20.
|
|
113
|
-
"@react-aria/i18n": "^3.12.
|
|
114
|
-
"@react-aria/listbox": "^3.14.
|
|
115
|
-
"@react-aria/menu": "^3.18.
|
|
116
|
-
"@react-aria/overlays": "^3.27.
|
|
117
|
-
"@react-aria/select": "^3.15.
|
|
118
|
-
"@react-aria/utils": "^3.
|
|
119
|
-
"@react-stately/collections": "^3.12.
|
|
120
|
-
"@react-stately/datepicker": "^3.14.
|
|
121
|
-
"@react-stately/list": "^3.12.
|
|
122
|
-
"@react-stately/menu": "^3.9.
|
|
123
|
-
"@react-stately/select": "^3.6.
|
|
124
|
-
"@react-types/shared": "^3.29.
|
|
110
|
+
"@react-aria/button": "^3.13.1",
|
|
111
|
+
"@react-aria/datepicker": "^3.14.3",
|
|
112
|
+
"@react-aria/focus": "^3.20.3",
|
|
113
|
+
"@react-aria/i18n": "^3.12.9",
|
|
114
|
+
"@react-aria/listbox": "^3.14.4",
|
|
115
|
+
"@react-aria/menu": "^3.18.3",
|
|
116
|
+
"@react-aria/overlays": "^3.27.1",
|
|
117
|
+
"@react-aria/select": "^3.15.5",
|
|
118
|
+
"@react-aria/utils": "^3.29.0",
|
|
119
|
+
"@react-stately/collections": "^3.12.4",
|
|
120
|
+
"@react-stately/datepicker": "^3.14.1",
|
|
121
|
+
"@react-stately/list": "^3.12.2",
|
|
122
|
+
"@react-stately/menu": "^3.9.4",
|
|
123
|
+
"@react-stately/select": "^3.6.13",
|
|
124
|
+
"@react-types/shared": "^3.29.1",
|
|
125
125
|
"classnames": "^2.5.1",
|
|
126
126
|
"date-fns": "^4.1.0",
|
|
127
127
|
"lodash.debounce": "^4.0.8",
|
|
@@ -136,11 +136,11 @@
|
|
|
136
136
|
"prosemirror-state": "^1.4.3",
|
|
137
137
|
"prosemirror-transform": "^1.10.4",
|
|
138
138
|
"prosemirror-utils": "^1.2.2",
|
|
139
|
-
"prosemirror-view": "^1.39.
|
|
139
|
+
"prosemirror-view": "^1.39.3",
|
|
140
140
|
"react-animate-height": "^3.2.3",
|
|
141
|
-
"react-aria": "^3.
|
|
142
|
-
"react-aria-components": "^1.
|
|
143
|
-
"react-day-picker": "
|
|
141
|
+
"react-aria": "^3.40.0",
|
|
142
|
+
"react-aria-components": "^1.9.0",
|
|
143
|
+
"react-day-picker": "9.6.7",
|
|
144
144
|
"react-focus-lock": "^2.13.6",
|
|
145
145
|
"react-focus-on": "^3.9.4",
|
|
146
146
|
"react-popper": "^2.3.0",
|
|
@@ -154,9 +154,9 @@
|
|
|
154
154
|
"react-day-picker": "Version locked until a11y gets fixed (https://github.com/gpbl/react-day-picker/pull/1708)"
|
|
155
155
|
},
|
|
156
156
|
"devDependencies": {
|
|
157
|
-
"@cultureamp/frontend-apis": "
|
|
158
|
-
"@cultureamp/i18n-react-intl": "^2.
|
|
159
|
-
"@cultureamp/package-bundler": "^2.3.
|
|
157
|
+
"@cultureamp/frontend-apis": "13.3.0",
|
|
158
|
+
"@cultureamp/i18n-react-intl": "^2.9.1",
|
|
159
|
+
"@cultureamp/package-bundler": "^2.3.2",
|
|
160
160
|
"@testing-library/dom": "^10.4.0",
|
|
161
161
|
"@types/jest-axe": "^3.5.9",
|
|
162
162
|
"@types/lodash.debounce": "^4.0.9",
|
|
@@ -174,9 +174,9 @@
|
|
|
174
174
|
"postcss-import": "^16.1.0",
|
|
175
175
|
"postcss-preset-env": "^10.1.6",
|
|
176
176
|
"postcss-scss": "^4.0.9",
|
|
177
|
-
"query-string": "^9.
|
|
178
|
-
"react": "^
|
|
179
|
-
"react-dom": "^
|
|
177
|
+
"query-string": "^9.2.0",
|
|
178
|
+
"react": "^19.0.0",
|
|
179
|
+
"react-dom": "^19.0.0",
|
|
180
180
|
"react-highlight": "^0.15.0",
|
|
181
181
|
"react-intl": "^7.1.11",
|
|
182
182
|
"rollup": "^4.40.2",
|
|
@@ -186,16 +186,17 @@
|
|
|
186
186
|
"tslib": "^2.8.1",
|
|
187
187
|
"ts-patch": "^3.3.0",
|
|
188
188
|
"tsx": "^4.19.4",
|
|
189
|
-
"@kaizen/design-tokens": "10.
|
|
189
|
+
"@kaizen/design-tokens": "10.10.0"
|
|
190
190
|
},
|
|
191
191
|
"devDependenciesComments": {
|
|
192
192
|
"sass": "Prevent deprecation warnings introduced in 1.80 as we plan to move away from sass",
|
|
193
|
-
"typescript": "Installed in root"
|
|
193
|
+
"typescript": "Installed in root",
|
|
194
|
+
"frontend-apis": "There's an unresolved dep with 13.4.0 and onwards with node/msw, so we are locking to 13.3.0 for this update."
|
|
194
195
|
},
|
|
195
196
|
"peerDependencies": {
|
|
196
197
|
"@cultureamp/i18n-react-intl": "^2.5.9",
|
|
197
|
-
"react": "^18.3.1",
|
|
198
|
-
"react-dom": "^18.3.1",
|
|
198
|
+
"react": "^18.3.1 || ^19.0.0",
|
|
199
|
+
"react-dom": "^18.3.1 || ^19.0.0",
|
|
199
200
|
"react-intl": "^6.6.8 || ^7.0.0",
|
|
200
201
|
"typescript": "5.x"
|
|
201
202
|
},
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
.reversed {
|
|
18
|
-
--badge-background-color:
|
|
18
|
+
--badge-background-color: rgb(var(--color-white-rgb), 0.1);
|
|
19
19
|
|
|
20
20
|
color: var(--color-white);
|
|
21
21
|
}
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
.dark {
|
|
53
|
-
--badge-background-color:
|
|
53
|
+
--badge-background-color: rgb(var(--color-purple-700-rgb), 0.1);
|
|
54
54
|
|
|
55
55
|
color: var(--color-purple-800);
|
|
56
56
|
}
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
.animationOn .badge.dark {
|
|
90
|
-
--badge-background-color:
|
|
90
|
+
--badge-background-color: rgb(var(--color-purple-700-rgb), 0.2);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
.animationOn .badge.active {
|
|
@@ -6,7 +6,7 @@ $cell-border-radius: 3px;
|
|
|
6
6
|
.month {
|
|
7
7
|
padding: 0 $spacing-sm;
|
|
8
8
|
|
|
9
|
-
&:
|
|
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(:
|
|
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
|
-
&:
|
|
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:
|
|
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
|
|
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<
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
60
|
-
|
|
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
|
-
|
|
92
|
+
const day = within(month).getByRole('gridcell', { name: dayName })
|
|
93
|
+
return within(day).getByRole('button')
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
const calendarsPseudoStates = [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react'
|
|
2
2
|
import { enAU } from 'date-fns/locale'
|
|
3
|
-
import { DayPicker, type
|
|
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<
|
|
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
|
-
}
|
|
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
|
-
|
|
54
|
-
|
|
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 = (
|
|
92
|
+
const getElementWithinCalendar = (
|
|
93
|
+
id: string,
|
|
94
|
+
role: string,
|
|
95
|
+
name: string | RegExp,
|
|
96
|
+
): HTMLElement => {
|
|
93
97
|
const calendar = canvas.getByTestId(id)
|
|
94
|
-
|
|
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:
|
|
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
|
|
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
|
})
|