@transferwise/components 46.144.1 → 46.145.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/build/calendar/Calendar.js +159 -0
- package/build/calendar/Calendar.js.map +1 -0
- package/build/{dateLookup/DateLookup.messages.js → calendar/Calendar.messages.js} +1 -1
- package/build/calendar/Calendar.messages.js.map +1 -0
- package/build/{dateLookup/DateLookup.messages.mjs → calendar/Calendar.messages.mjs} +1 -1
- package/build/calendar/Calendar.messages.mjs.map +1 -0
- package/build/calendar/Calendar.mjs +155 -0
- package/build/calendar/Calendar.mjs.map +1 -0
- package/build/{dateLookup → calendar}/dateHeader/DateHeader.js +4 -4
- package/build/calendar/dateHeader/DateHeader.js.map +1 -0
- package/build/{dateLookup → calendar}/dateHeader/DateHeader.mjs +1 -1
- package/build/calendar/dateHeader/DateHeader.mjs.map +1 -0
- package/build/{dateLookup → calendar}/dayCalendar/DayCalendar.js +2 -2
- package/build/calendar/dayCalendar/DayCalendar.js.map +1 -0
- package/build/{dateLookup → calendar}/dayCalendar/DayCalendar.mjs +1 -1
- package/build/calendar/dayCalendar/DayCalendar.mjs.map +1 -0
- package/build/calendar/dayCalendar/table/DayCalendarTable.js.map +1 -0
- package/build/calendar/dayCalendar/table/DayCalendarTable.mjs.map +1 -0
- package/build/calendar/getFocusableTime/getFocusableTime.js.map +1 -0
- package/build/calendar/getFocusableTime/getFocusableTime.mjs.map +1 -0
- package/build/calendar/getStartOfDay/getStartOfDay.js.map +1 -0
- package/build/calendar/getStartOfDay/getStartOfDay.mjs.map +1 -0
- package/build/{dateLookup → calendar}/monthCalendar/MonthCalendar.js +2 -2
- package/build/calendar/monthCalendar/MonthCalendar.js.map +1 -0
- package/build/{dateLookup → calendar}/monthCalendar/MonthCalendar.mjs +1 -1
- package/build/calendar/monthCalendar/MonthCalendar.mjs.map +1 -0
- package/build/calendar/monthCalendar/table/MonthCalendarTable.js.map +1 -0
- package/build/calendar/monthCalendar/table/MonthCalendarTable.mjs.map +1 -0
- package/build/{dateLookup → calendar}/tableLink/TableLink.js +2 -2
- package/build/calendar/tableLink/TableLink.js.map +1 -0
- package/build/{dateLookup → calendar}/tableLink/TableLink.mjs +1 -1
- package/build/calendar/tableLink/TableLink.mjs.map +1 -0
- package/build/{dateLookup → calendar}/yearCalendar/YearCalendar.js +2 -2
- package/build/calendar/yearCalendar/YearCalendar.js.map +1 -0
- package/build/{dateLookup → calendar}/yearCalendar/YearCalendar.mjs +1 -1
- package/build/calendar/yearCalendar/YearCalendar.mjs.map +1 -0
- package/build/calendar/yearCalendar/table/YearCalendarTable.js.map +1 -0
- package/build/calendar/yearCalendar/table/YearCalendarTable.mjs.map +1 -0
- package/build/dateLookup/DateLookup.js +28 -168
- package/build/dateLookup/DateLookup.js.map +1 -1
- package/build/dateLookup/DateLookup.mjs +29 -169
- package/build/dateLookup/DateLookup.mjs.map +1 -1
- package/build/index.js +2 -0
- package/build/index.js.map +1 -1
- package/build/index.mjs +1 -0
- package/build/index.mjs.map +1 -1
- package/build/main.css +97 -106
- package/build/styles/calendar/Calendar.css +83 -0
- package/build/styles/dateLookup/DateLookup.css +0 -90
- package/build/styles/main.css +97 -106
- package/build/types/calendar/Calendar.d.ts +13 -0
- package/build/types/calendar/Calendar.d.ts.map +1 -0
- package/build/types/{dateLookup/DateLookup.messages.d.ts → calendar/Calendar.messages.d.ts} +1 -1
- package/build/types/calendar/Calendar.messages.d.ts.map +1 -0
- package/build/types/calendar/dateHeader/DateHeader.d.ts.map +1 -0
- package/build/types/calendar/dateHeader/index.d.ts.map +1 -0
- package/build/types/calendar/dayCalendar/DayCalendar.d.ts.map +1 -0
- package/build/types/calendar/dayCalendar/index.d.ts.map +1 -0
- package/build/types/calendar/dayCalendar/table/DayCalendarTable.d.ts.map +1 -0
- package/build/types/calendar/dayCalendar/table/index.d.ts.map +1 -0
- package/build/types/calendar/getFocusableTime/getFocusableTime.d.ts.map +1 -0
- package/build/types/calendar/getStartOfDay/getStartOfDay.d.ts.map +1 -0
- package/build/types/calendar/getStartOfDay/index.d.ts.map +1 -0
- package/build/types/calendar/index.d.ts +3 -0
- package/build/types/calendar/index.d.ts.map +1 -0
- package/build/types/{dateLookup → calendar}/monthCalendar/MonthCalendar.d.ts +1 -1
- package/build/types/calendar/monthCalendar/MonthCalendar.d.ts.map +1 -0
- package/build/types/calendar/monthCalendar/index.d.ts.map +1 -0
- package/build/types/{dateLookup → calendar}/monthCalendar/table/MonthCalendarTable.d.ts +1 -1
- package/build/types/calendar/monthCalendar/table/MonthCalendarTable.d.ts.map +1 -0
- package/build/types/calendar/monthCalendar/table/index.d.ts.map +1 -0
- package/build/types/calendar/tableLink/TableLink.d.ts.map +1 -0
- package/build/types/calendar/tableLink/index.d.ts.map +1 -0
- package/build/types/{dateLookup → calendar}/yearCalendar/YearCalendar.d.ts +1 -1
- package/build/types/calendar/yearCalendar/YearCalendar.d.ts.map +1 -0
- package/build/types/calendar/yearCalendar/index.d.ts.map +1 -0
- package/build/types/{dateLookup → calendar}/yearCalendar/table/YearCalendarTable.d.ts +1 -1
- package/build/types/calendar/yearCalendar/table/YearCalendarTable.d.ts.map +1 -0
- package/build/types/calendar/yearCalendar/table/index.d.ts.map +1 -0
- package/build/types/dateLookup/DateLookup.d.ts +2 -26
- package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -0
- package/build/types/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/calendar/Calendar.css +83 -0
- package/src/calendar/Calendar.less +79 -0
- package/src/calendar/Calendar.story.tsx +92 -0
- package/src/calendar/Calendar.test.tsx +138 -0
- package/src/calendar/Calendar.tsx +165 -0
- package/src/{dateLookup → calendar}/dateHeader/DateHeader.tsx +1 -1
- package/src/{dateLookup → calendar}/dayCalendar/DayCalendar.tsx +1 -1
- package/src/calendar/index.ts +2 -0
- package/src/{dateLookup → calendar}/monthCalendar/MonthCalendar.tsx +2 -2
- package/src/{dateLookup → calendar}/monthCalendar/table/MonthCalendarTable.tsx +1 -1
- package/src/{dateLookup → calendar}/tableLink/TableLink.tsx +1 -1
- package/src/{dateLookup → calendar}/yearCalendar/YearCalendar.tsx +2 -2
- package/src/{dateLookup → calendar}/yearCalendar/table/YearCalendarTable.tsx +1 -1
- package/src/dateLookup/DateLookup.css +0 -90
- package/src/dateLookup/DateLookup.less +0 -91
- package/src/dateLookup/DateLookup.test.tsx +0 -124
- package/src/dateLookup/DateLookup.tsx +31 -161
- package/src/index.ts +2 -0
- package/src/main.css +97 -106
- package/src/main.less +1 -0
- package/build/dateLookup/DateLookup.messages.js.map +0 -1
- package/build/dateLookup/DateLookup.messages.mjs.map +0 -1
- package/build/dateLookup/dateHeader/DateHeader.js.map +0 -1
- package/build/dateLookup/dateHeader/DateHeader.mjs.map +0 -1
- package/build/dateLookup/dayCalendar/DayCalendar.js.map +0 -1
- package/build/dateLookup/dayCalendar/DayCalendar.mjs.map +0 -1
- package/build/dateLookup/dayCalendar/table/DayCalendarTable.js.map +0 -1
- package/build/dateLookup/dayCalendar/table/DayCalendarTable.mjs.map +0 -1
- package/build/dateLookup/getFocusableTime/getFocusableTime.js.map +0 -1
- package/build/dateLookup/getFocusableTime/getFocusableTime.mjs.map +0 -1
- package/build/dateLookup/getStartOfDay/getStartOfDay.js.map +0 -1
- package/build/dateLookup/getStartOfDay/getStartOfDay.mjs.map +0 -1
- package/build/dateLookup/monthCalendar/MonthCalendar.js.map +0 -1
- package/build/dateLookup/monthCalendar/MonthCalendar.mjs.map +0 -1
- package/build/dateLookup/monthCalendar/table/MonthCalendarTable.js.map +0 -1
- package/build/dateLookup/monthCalendar/table/MonthCalendarTable.mjs.map +0 -1
- package/build/dateLookup/tableLink/TableLink.js.map +0 -1
- package/build/dateLookup/tableLink/TableLink.mjs.map +0 -1
- package/build/dateLookup/yearCalendar/YearCalendar.js.map +0 -1
- package/build/dateLookup/yearCalendar/YearCalendar.mjs.map +0 -1
- package/build/dateLookup/yearCalendar/table/YearCalendarTable.js.map +0 -1
- package/build/dateLookup/yearCalendar/table/YearCalendarTable.mjs.map +0 -1
- package/build/types/dateLookup/DateLookup.messages.d.ts.map +0 -1
- package/build/types/dateLookup/dateHeader/DateHeader.d.ts.map +0 -1
- package/build/types/dateLookup/dateHeader/index.d.ts.map +0 -1
- package/build/types/dateLookup/dayCalendar/DayCalendar.d.ts.map +0 -1
- package/build/types/dateLookup/dayCalendar/index.d.ts.map +0 -1
- package/build/types/dateLookup/dayCalendar/table/DayCalendarTable.d.ts.map +0 -1
- package/build/types/dateLookup/dayCalendar/table/index.d.ts.map +0 -1
- package/build/types/dateLookup/getFocusableTime/getFocusableTime.d.ts.map +0 -1
- package/build/types/dateLookup/getStartOfDay/getStartOfDay.d.ts.map +0 -1
- package/build/types/dateLookup/getStartOfDay/index.d.ts.map +0 -1
- package/build/types/dateLookup/monthCalendar/MonthCalendar.d.ts.map +0 -1
- package/build/types/dateLookup/monthCalendar/index.d.ts.map +0 -1
- package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts.map +0 -1
- package/build/types/dateLookup/monthCalendar/table/index.d.ts.map +0 -1
- package/build/types/dateLookup/tableLink/TableLink.d.ts.map +0 -1
- package/build/types/dateLookup/tableLink/index.d.ts.map +0 -1
- package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts.map +0 -1
- package/build/types/dateLookup/yearCalendar/index.d.ts.map +0 -1
- package/build/types/dateLookup/yearCalendar/table/YearCalendarTable.d.ts.map +0 -1
- package/build/types/dateLookup/yearCalendar/table/index.d.ts.map +0 -1
- /package/build/{dateLookup → calendar}/dayCalendar/table/DayCalendarTable.js +0 -0
- /package/build/{dateLookup → calendar}/dayCalendar/table/DayCalendarTable.mjs +0 -0
- /package/build/{dateLookup → calendar}/getFocusableTime/getFocusableTime.js +0 -0
- /package/build/{dateLookup → calendar}/getFocusableTime/getFocusableTime.mjs +0 -0
- /package/build/{dateLookup → calendar}/getStartOfDay/getStartOfDay.js +0 -0
- /package/build/{dateLookup → calendar}/getStartOfDay/getStartOfDay.mjs +0 -0
- /package/build/{dateLookup → calendar}/monthCalendar/table/MonthCalendarTable.js +0 -0
- /package/build/{dateLookup → calendar}/monthCalendar/table/MonthCalendarTable.mjs +0 -0
- /package/build/{dateLookup → calendar}/yearCalendar/table/YearCalendarTable.js +0 -0
- /package/build/{dateLookup → calendar}/yearCalendar/table/YearCalendarTable.mjs +0 -0
- /package/build/types/{dateLookup → calendar}/dateHeader/DateHeader.d.ts +0 -0
- /package/build/types/{dateLookup → calendar}/dateHeader/index.d.ts +0 -0
- /package/build/types/{dateLookup → calendar}/dayCalendar/DayCalendar.d.ts +0 -0
- /package/build/types/{dateLookup → calendar}/dayCalendar/index.d.ts +0 -0
- /package/build/types/{dateLookup → calendar}/dayCalendar/table/DayCalendarTable.d.ts +0 -0
- /package/build/types/{dateLookup → calendar}/dayCalendar/table/index.d.ts +0 -0
- /package/build/types/{dateLookup → calendar}/getFocusableTime/getFocusableTime.d.ts +0 -0
- /package/build/types/{dateLookup → calendar}/getStartOfDay/getStartOfDay.d.ts +0 -0
- /package/build/types/{dateLookup → calendar}/getStartOfDay/index.d.ts +0 -0
- /package/build/types/{dateLookup → calendar}/monthCalendar/index.d.ts +0 -0
- /package/build/types/{dateLookup → calendar}/monthCalendar/table/index.d.ts +0 -0
- /package/build/types/{dateLookup → calendar}/tableLink/TableLink.d.ts +0 -0
- /package/build/types/{dateLookup → calendar}/tableLink/index.d.ts +0 -0
- /package/build/types/{dateLookup → calendar}/yearCalendar/index.d.ts +0 -0
- /package/build/types/{dateLookup → calendar}/yearCalendar/table/index.d.ts +0 -0
- /package/src/{dateLookup/DateLookup.messages.ts → calendar/Calendar.messages.ts} +0 -0
- /package/src/{dateLookup → calendar}/dateHeader/index.ts +0 -0
- /package/src/{dateLookup → calendar}/dayCalendar/index.ts +0 -0
- /package/src/{dateLookup → calendar}/dayCalendar/table/DayCalendarTable.tsx +0 -0
- /package/src/{dateLookup → calendar}/dayCalendar/table/index.ts +0 -0
- /package/src/{dateLookup → calendar}/getFocusableTime/getFocusable.test.ts +0 -0
- /package/src/{dateLookup → calendar}/getFocusableTime/getFocusableTime.tsx +0 -0
- /package/src/{dateLookup → calendar}/getStartOfDay/getStartOfDay.test.js +0 -0
- /package/src/{dateLookup → calendar}/getStartOfDay/getStartOfDay.tsx +0 -0
- /package/src/{dateLookup → calendar}/getStartOfDay/index.ts +0 -0
- /package/src/{dateLookup → calendar}/monthCalendar/index.ts +0 -0
- /package/src/{dateLookup → calendar}/monthCalendar/table/index.ts +0 -0
- /package/src/{dateLookup → calendar}/tableLink/index.ts +0 -0
- /package/src/{dateLookup → calendar}/yearCalendar/index.ts +0 -0
- /package/src/{dateLookup → calendar}/yearCalendar/table/index.ts +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PureComponent } from 'react';
|
|
2
2
|
import { injectIntl, WrappedComponentProps } from 'react-intl';
|
|
3
3
|
|
|
4
|
-
import messages from '../
|
|
4
|
+
import messages from '../Calendar.messages';
|
|
5
5
|
import DateHeader from '../dateHeader';
|
|
6
6
|
|
|
7
7
|
import YearCalendarTable from './table';
|
|
@@ -11,7 +11,7 @@ interface YearCalendarProps extends WrappedComponentProps {
|
|
|
11
11
|
min: Date | null;
|
|
12
12
|
max: Date | null;
|
|
13
13
|
viewYear: number;
|
|
14
|
-
placeholder
|
|
14
|
+
placeholder?: string;
|
|
15
15
|
onSelect: () => void;
|
|
16
16
|
onViewDateUpdate: (date: { year: number }) => void;
|
|
17
17
|
}
|
|
@@ -1,93 +1,3 @@
|
|
|
1
1
|
.tw-date-lookup-menu {
|
|
2
2
|
width: 400px;
|
|
3
3
|
}
|
|
4
|
-
.tw-date-lookup-calendar {
|
|
5
|
-
min-width: 300px;
|
|
6
|
-
text-align: center;
|
|
7
|
-
table-layout: fixed;
|
|
8
|
-
background-color: inherit;
|
|
9
|
-
}
|
|
10
|
-
.tw-date-lookup-calendar > tbody > tr > td.weekend button {
|
|
11
|
-
color: #5d7079;
|
|
12
|
-
color: var(--color-content-secondary);
|
|
13
|
-
}
|
|
14
|
-
.tw-date-lookup-calendar > tbody > tr > td {
|
|
15
|
-
padding: 4px;
|
|
16
|
-
padding: var(--size-4);
|
|
17
|
-
}
|
|
18
|
-
@media (max-width: 320px) {
|
|
19
|
-
.tw-date-lookup-calendar > tbody > tr > td {
|
|
20
|
-
padding: 0;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
.tw-date-lookup-calendar > tbody > tr > td:has(.tw-date-lookup-day-option) {
|
|
24
|
-
padding: 1px;
|
|
25
|
-
}
|
|
26
|
-
.tw-date-lookup-calendar > tbody > tr > td button {
|
|
27
|
-
width: 100%;
|
|
28
|
-
padding: 4px 0;
|
|
29
|
-
padding: var(--size-4) 0;
|
|
30
|
-
color: #0097c7;
|
|
31
|
-
color: var(--color-content-accent);
|
|
32
|
-
border: transparent;
|
|
33
|
-
border-radius: 10px;
|
|
34
|
-
border-radius: var(--radius-small);
|
|
35
|
-
background-color: transparent;
|
|
36
|
-
font-weight: 600;
|
|
37
|
-
font-weight: var(--font-weight-semi-bold);
|
|
38
|
-
color: #37517e;
|
|
39
|
-
color: var(--color-content-primary);
|
|
40
|
-
}
|
|
41
|
-
@media (max-width: 320px) {
|
|
42
|
-
.tw-date-lookup-calendar > tbody > tr > td button {
|
|
43
|
-
padding: 0;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
.tw-date-lookup-calendar > tbody > tr > td button.tw-date-lookup-day-option {
|
|
47
|
-
height: 40px;
|
|
48
|
-
height: var(--size-40);
|
|
49
|
-
border-radius: 9999px;
|
|
50
|
-
border-radius: var(--radius-full);
|
|
51
|
-
line-height: 40px;
|
|
52
|
-
line-height: var(--size-40);
|
|
53
|
-
width: 40px;
|
|
54
|
-
width: var(--size-40);
|
|
55
|
-
padding: 0;
|
|
56
|
-
display: inline-flex;
|
|
57
|
-
align-items: center;
|
|
58
|
-
justify-content: center;
|
|
59
|
-
}
|
|
60
|
-
.tw-date-lookup-calendar > tbody > tr > td button.tw-date-lookup-day-option.today {
|
|
61
|
-
-webkit-text-decoration: underline;
|
|
62
|
-
text-decoration: underline;
|
|
63
|
-
text-decoration-thickness: 2px;
|
|
64
|
-
text-underline-offset: 4px;
|
|
65
|
-
}
|
|
66
|
-
.tw-date-lookup-calendar > tbody > tr > td:not(.disabled):not(:disabled) button.show-focus,
|
|
67
|
-
.tw-date-lookup-calendar > tbody > tr > td:hover button:not(.disabled):not(:disabled) {
|
|
68
|
-
background-color: var(--color-background-screen-hover);
|
|
69
|
-
}
|
|
70
|
-
.tw-date-lookup-calendar > tbody > tr > td:not(.disabled):not(:disabled) button.active {
|
|
71
|
-
background-color: var(--color-interactive-primary);
|
|
72
|
-
color: var(--color-interactive-contrast);
|
|
73
|
-
}
|
|
74
|
-
.tw-date-lookup-calendar abbr {
|
|
75
|
-
-webkit-text-decoration: none;
|
|
76
|
-
text-decoration: none;
|
|
77
|
-
}
|
|
78
|
-
.tw-date-lookup-header-current-container {
|
|
79
|
-
display: inline;
|
|
80
|
-
}
|
|
81
|
-
.np-theme-personal.tw-date-lookup-menu .table-bordered,
|
|
82
|
-
.np-theme-personal .tw-date-lookup-menu .table-bordered {
|
|
83
|
-
border: none;
|
|
84
|
-
}
|
|
85
|
-
.np-theme-personal.tw-date-lookup-menu thead,
|
|
86
|
-
.np-theme-personal .tw-date-lookup-menu thead {
|
|
87
|
-
background-color: transparent;
|
|
88
|
-
background-color: initial;
|
|
89
|
-
}
|
|
90
|
-
.np-theme-personal.tw-date-lookup-menu td,
|
|
91
|
-
.np-theme-personal .tw-date-lookup-menu td {
|
|
92
|
-
border: none;
|
|
93
|
-
}
|
|
@@ -1,94 +1,3 @@
|
|
|
1
|
-
@import (reference) "./../styles/variables/neptune-tokens.less";
|
|
2
|
-
|
|
3
1
|
.tw-date-lookup-menu {
|
|
4
2
|
width: 400px;
|
|
5
3
|
}
|
|
6
|
-
|
|
7
|
-
.tw-date-lookup-calendar {
|
|
8
|
-
min-width: 300px;
|
|
9
|
-
text-align: center;
|
|
10
|
-
table-layout: fixed;
|
|
11
|
-
|
|
12
|
-
> tbody > tr > td.weekend button {
|
|
13
|
-
color: var(--color-content-secondary);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
> tbody > tr > td {
|
|
17
|
-
padding: var(--size-4);
|
|
18
|
-
@media (--screen-400-zoom) {
|
|
19
|
-
padding: 0;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
&:has(.tw-date-lookup-day-option) {
|
|
23
|
-
padding: 1px;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
button {
|
|
27
|
-
width: 100%;
|
|
28
|
-
padding: var(--size-4) 0;
|
|
29
|
-
@media (--screen-400-zoom) {
|
|
30
|
-
padding: 0;
|
|
31
|
-
}
|
|
32
|
-
color: var(--color-content-accent);
|
|
33
|
-
border: transparent;
|
|
34
|
-
border-radius: var(--radius-small);
|
|
35
|
-
background-color: transparent;
|
|
36
|
-
font-weight: var(--font-weight-semi-bold);
|
|
37
|
-
color: var(--color-content-primary);
|
|
38
|
-
|
|
39
|
-
&.tw-date-lookup-day-option {
|
|
40
|
-
height: var(--size-40);
|
|
41
|
-
border-radius: var(--radius-full);
|
|
42
|
-
line-height: var(--size-40);
|
|
43
|
-
width: var(--size-40);
|
|
44
|
-
padding: 0;
|
|
45
|
-
display: inline-flex;
|
|
46
|
-
align-items: center;
|
|
47
|
-
justify-content: center;
|
|
48
|
-
|
|
49
|
-
&.today {
|
|
50
|
-
text-decoration: underline;
|
|
51
|
-
text-decoration-thickness: 2px;
|
|
52
|
-
text-underline-offset: 4px;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
&:not(.disabled, :disabled) button.show-focus,
|
|
58
|
-
&:hover button:not(.disabled, :disabled) {
|
|
59
|
-
background-color: var(--color-background-screen-hover);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
&:not(.disabled, :disabled) button.active {
|
|
63
|
-
background-color: var(--color-interactive-primary);
|
|
64
|
-
color: var(--color-interactive-contrast);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
abbr {
|
|
69
|
-
text-decoration: none;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
background-color: inherit;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.tw-date-lookup-header-current-container {
|
|
76
|
-
display: inline;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.np-theme-personal {
|
|
80
|
-
&.tw-date-lookup-menu,
|
|
81
|
-
.tw-date-lookup-menu {
|
|
82
|
-
.table-bordered {
|
|
83
|
-
border: none;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
thead {
|
|
87
|
-
background-color: unset;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
td {
|
|
91
|
-
border: none;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
@@ -198,28 +198,6 @@ describe('DateLookup', () => {
|
|
|
198
198
|
expect(handleChange).toHaveBeenCalledWith(initialValue);
|
|
199
199
|
});
|
|
200
200
|
});
|
|
201
|
-
|
|
202
|
-
it('limits min value', async () => {
|
|
203
|
-
const min = new Date(initialValue);
|
|
204
|
-
min.setDate(min.getDate() - 1);
|
|
205
|
-
const handleChange = jest.fn();
|
|
206
|
-
await setupAndOpenWithMouse({ min, onChange: handleChange });
|
|
207
|
-
|
|
208
|
-
await user.keyboard('{ArrowLeft}{ArrowLeft}');
|
|
209
|
-
|
|
210
|
-
expect(handleChange).toHaveBeenCalledWith(min);
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
it('limits max value', async () => {
|
|
214
|
-
const max = new Date(initialValue);
|
|
215
|
-
max.setDate(max.getDate() + 1);
|
|
216
|
-
const handleChange = jest.fn();
|
|
217
|
-
await setupAndOpenWithMouse({ max, onChange: handleChange });
|
|
218
|
-
|
|
219
|
-
await user.keyboard('{ArrowRight}{ArrowRight}');
|
|
220
|
-
|
|
221
|
-
expect(handleChange).toHaveBeenCalledWith(max);
|
|
222
|
-
});
|
|
223
201
|
});
|
|
224
202
|
|
|
225
203
|
describe('DateLookup propTypes', () => {
|
|
@@ -296,75 +274,6 @@ describe('DateLookup (events)', () => {
|
|
|
296
274
|
);
|
|
297
275
|
};
|
|
298
276
|
|
|
299
|
-
it('switches to years', async () => {
|
|
300
|
-
const view = await setup();
|
|
301
|
-
await openDateLookup();
|
|
302
|
-
await clickDateButton();
|
|
303
|
-
|
|
304
|
-
expect(getActiveYearButton(view)).toHaveFocus();
|
|
305
|
-
|
|
306
|
-
await closeDateLookup(view);
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
it('has aria-label for 20 years', async () => {
|
|
310
|
-
const view = await setup();
|
|
311
|
-
await openDateLookup();
|
|
312
|
-
await clickDateButton();
|
|
313
|
-
|
|
314
|
-
expect(getButtonByAriaLabel('next 20 years')).toBeInTheDocument();
|
|
315
|
-
expect(getButtonByAriaLabel('previous 20 years')).toBeInTheDocument();
|
|
316
|
-
|
|
317
|
-
await closeDateLookup(view);
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
it('switches to months', async () => {
|
|
321
|
-
const view = await setup();
|
|
322
|
-
await openDateLookup();
|
|
323
|
-
await clickDateButton();
|
|
324
|
-
await userEvent.click(getActiveYearButton(view));
|
|
325
|
-
|
|
326
|
-
expect(getActiveMonthButton(view)).toHaveFocus();
|
|
327
|
-
|
|
328
|
-
await closeDateLookup(view);
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
it('has aria label for year', async () => {
|
|
332
|
-
const view = await setup();
|
|
333
|
-
await openDateLookup();
|
|
334
|
-
await clickDateButton();
|
|
335
|
-
await userEvent.click(getActiveYearButton(view));
|
|
336
|
-
|
|
337
|
-
expect(getButtonByAriaLabel('next year')).toBeInTheDocument();
|
|
338
|
-
expect(getButtonByAriaLabel('previous year')).toBeInTheDocument();
|
|
339
|
-
|
|
340
|
-
await closeDateLookup(view);
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
it('switches to days', async () => {
|
|
344
|
-
const view = await setup();
|
|
345
|
-
await openDateLookup();
|
|
346
|
-
await clickDateButton();
|
|
347
|
-
await userEvent.click(getActiveYearButton(view));
|
|
348
|
-
await userEvent.click(getActiveMonthButton(view));
|
|
349
|
-
|
|
350
|
-
expect(getActiveDayButton(view)).toHaveFocus();
|
|
351
|
-
|
|
352
|
-
await closeDateLookup(view);
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
it('has aria label for month', async () => {
|
|
356
|
-
const view = await setup();
|
|
357
|
-
await openDateLookup();
|
|
358
|
-
await clickDateButton();
|
|
359
|
-
await userEvent.click(getActiveYearButton(view));
|
|
360
|
-
await userEvent.click(getActiveMonthButton(view));
|
|
361
|
-
|
|
362
|
-
expect(getButtonByAriaLabel('next month')).toBeInTheDocument();
|
|
363
|
-
expect(getButtonByAriaLabel('previous month')).toBeInTheDocument();
|
|
364
|
-
|
|
365
|
-
await closeDateLookup(view);
|
|
366
|
-
});
|
|
367
|
-
|
|
368
277
|
it('has aria label on selected date', async () => {
|
|
369
278
|
const view = await setup();
|
|
370
279
|
await openDateLookup();
|
|
@@ -440,44 +349,11 @@ describe('DateLookup (events)', () => {
|
|
|
440
349
|
});
|
|
441
350
|
};
|
|
442
351
|
|
|
443
|
-
const getDateButton = () => {
|
|
444
|
-
return screen.getByRole('button', {
|
|
445
|
-
name: /Go to 20 year view/i,
|
|
446
|
-
});
|
|
447
|
-
};
|
|
448
|
-
|
|
449
352
|
const openDateLookup = async () => userEvent.click(getOpenButton(labelProp));
|
|
450
353
|
|
|
451
|
-
const clickDateButton = async () => userEvent.click(getDateButton());
|
|
452
|
-
|
|
453
354
|
// Close dateLookup and removes events attached to documents.
|
|
454
355
|
const closeDateLookup = async (view: RenderResult) => userEvent.click(view.container);
|
|
455
356
|
|
|
456
357
|
// @ts-expect-error getClearButton returns node
|
|
457
358
|
const clickClearButton = async (view: RenderResult) => userEvent.click(getClearButton(view));
|
|
458
|
-
|
|
459
|
-
const getActiveYearButton = (view: RenderResult) => {
|
|
460
|
-
return screen.getByRole('button', {
|
|
461
|
-
name: /selected year/i,
|
|
462
|
-
pressed: true,
|
|
463
|
-
});
|
|
464
|
-
};
|
|
465
|
-
|
|
466
|
-
const getActiveMonthButton = (view: RenderResult) => {
|
|
467
|
-
return screen.getByRole('button', {
|
|
468
|
-
name: /selected month/i,
|
|
469
|
-
pressed: true,
|
|
470
|
-
});
|
|
471
|
-
};
|
|
472
|
-
|
|
473
|
-
const getActiveDayButton = (view: RenderResult) => {
|
|
474
|
-
return screen.getByRole('button', {
|
|
475
|
-
name: /selected day/i,
|
|
476
|
-
pressed: true,
|
|
477
|
-
});
|
|
478
|
-
};
|
|
479
|
-
|
|
480
|
-
const getButtonByAriaLabel = (ariaLabel: string) => {
|
|
481
|
-
return screen.getByRole('button', { name: ariaLabel });
|
|
482
|
-
};
|
|
483
359
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { clsx } from 'clsx';
|
|
2
2
|
import { createRef, PureComponent, KeyboardEvent } from 'react';
|
|
3
|
-
import
|
|
4
|
-
|
|
3
|
+
import Calendar from '../calendar';
|
|
5
4
|
import {
|
|
6
5
|
Size,
|
|
7
6
|
MonthFormat,
|
|
@@ -10,15 +9,10 @@ import {
|
|
|
10
9
|
type SizeMedium,
|
|
11
10
|
type SizeLarge,
|
|
12
11
|
} from '../common';
|
|
13
|
-
import { isWithinRange, moveToWithinRange, returnDateView } from '../common/dateUtils';
|
|
14
12
|
import ResponsivePanel from '../common/responsivePanel';
|
|
15
13
|
import { WithInputAttributesProps, withInputAttributes } from '../inputs/contexts';
|
|
16
14
|
import { OverlayIdProvider } from '../provider/overlay/OverlayIdProvider';
|
|
17
15
|
import DateTrigger from './dateTrigger';
|
|
18
|
-
import DayCalendar from './dayCalendar';
|
|
19
|
-
import { getStartOfDay } from './getStartOfDay';
|
|
20
|
-
import MonthCalendar from './monthCalendar';
|
|
21
|
-
import YearCalendar from './yearCalendar';
|
|
22
16
|
|
|
23
17
|
export interface DateLookupProps {
|
|
24
18
|
id?: string;
|
|
@@ -40,15 +34,8 @@ export interface DateLookupProps {
|
|
|
40
34
|
type DateLookupPropsWithInputAttributes = DateLookupProps & Partial<WithInputAttributesProps>;
|
|
41
35
|
|
|
42
36
|
interface DateLookupState {
|
|
43
|
-
selectedDate: Date | null;
|
|
44
37
|
originalDate: Date | null;
|
|
45
|
-
min: Date | null;
|
|
46
|
-
max: Date | null;
|
|
47
|
-
viewMonth: number;
|
|
48
|
-
viewYear: number;
|
|
49
38
|
open: boolean;
|
|
50
|
-
mode: 'day' | 'month' | 'year';
|
|
51
|
-
isMobile: boolean;
|
|
52
39
|
}
|
|
53
40
|
|
|
54
41
|
class DateLookup extends PureComponent<DateLookupPropsWithInputAttributes, DateLookupState> {
|
|
@@ -68,64 +55,25 @@ class DateLookup extends PureComponent<DateLookupPropsWithInputAttributes, DateL
|
|
|
68
55
|
} satisfies Partial<DateLookupPropsWithInputAttributes>;
|
|
69
56
|
|
|
70
57
|
element = createRef<HTMLDivElement>();
|
|
71
|
-
dropdown = createRef<HTMLDivElement>();
|
|
72
58
|
|
|
73
59
|
constructor(props: DateLookup['props']) {
|
|
74
60
|
super(props);
|
|
75
|
-
const dateView = returnDateView(props.value, props.min, props.max);
|
|
76
61
|
this.state = {
|
|
77
|
-
selectedDate: getStartOfDay(props.value),
|
|
78
62
|
originalDate: null,
|
|
79
|
-
min: getStartOfDay(props.min),
|
|
80
|
-
max: getStartOfDay(props.max),
|
|
81
|
-
viewMonth: dateView.getMonth(),
|
|
82
|
-
viewYear: dateView.getFullYear(),
|
|
83
63
|
open: false,
|
|
84
|
-
mode: 'day',
|
|
85
|
-
isMobile: false,
|
|
86
64
|
};
|
|
87
65
|
}
|
|
88
66
|
|
|
89
|
-
static getDerivedStateFromProps(props: DateLookup['props'], state: DateLookupState) {
|
|
90
|
-
const propsSelected = getStartOfDay(props.value);
|
|
91
|
-
const propsMin = getStartOfDay(props.min);
|
|
92
|
-
const propsMax = getStartOfDay(props.max);
|
|
93
|
-
const hasSelectedChanged = state.selectedDate?.getTime() !== propsSelected?.getTime();
|
|
94
|
-
const hasMinChanged = state.min?.getTime() !== propsMin?.getTime();
|
|
95
|
-
const hasMaxChanged = state.max?.getTime() !== propsMax?.getTime();
|
|
96
|
-
if (hasSelectedChanged || hasMinChanged || hasMaxChanged) {
|
|
97
|
-
const selectedDate = hasSelectedChanged ? propsSelected : state.selectedDate;
|
|
98
|
-
const min = hasMinChanged ? propsMin : state.min;
|
|
99
|
-
const max = hasMaxChanged ? propsMax : state.max;
|
|
100
|
-
if (selectedDate && !isWithinRange(selectedDate, min, max)) {
|
|
101
|
-
props.onChange(moveToWithinRange(selectedDate, min, max));
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
const viewDateThatIsWithinRange: Date = returnDateView(selectedDate, min, max);
|
|
105
|
-
const viewMonth = viewDateThatIsWithinRange.getMonth();
|
|
106
|
-
const viewYear = viewDateThatIsWithinRange.getFullYear();
|
|
107
|
-
return { selectedDate, min, max, viewMonth, viewYear };
|
|
108
|
-
}
|
|
109
|
-
return null;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
67
|
componentDidUpdate(previousProps: DateLookupPropsWithInputAttributes) {
|
|
113
68
|
if (this.props.value?.getTime() !== previousProps.value?.getTime() && this.state.open) {
|
|
114
69
|
this.focusOn('.active');
|
|
115
70
|
}
|
|
116
|
-
const mediaQuery = window.matchMedia(`(max-width: ${Breakpoint.SMALL}px)`);
|
|
117
|
-
this.setState({ isMobile: mediaQuery.matches });
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
componentWillUnmount() {
|
|
121
|
-
// Prevents memory leak by cleaning state.
|
|
122
|
-
this.setState = () => {};
|
|
123
71
|
}
|
|
124
72
|
|
|
125
73
|
open = () => {
|
|
126
74
|
const { onFocus } = this.props;
|
|
127
75
|
|
|
128
|
-
this.setState({ open: true
|
|
76
|
+
this.setState({ open: true });
|
|
129
77
|
if (onFocus) {
|
|
130
78
|
onFocus();
|
|
131
79
|
}
|
|
@@ -151,36 +99,13 @@ class DateLookup extends PureComponent<DateLookupPropsWithInputAttributes, DateL
|
|
|
151
99
|
const { open, originalDate } = this.state;
|
|
152
100
|
switch (event.key) {
|
|
153
101
|
case 'ArrowLeft':
|
|
154
|
-
if (open) {
|
|
155
|
-
this.adjustDate(-1, -1, -1);
|
|
156
|
-
} else {
|
|
157
|
-
this.open();
|
|
158
|
-
}
|
|
159
|
-
event.preventDefault();
|
|
160
|
-
break;
|
|
161
102
|
case 'ArrowUp':
|
|
162
|
-
if (open) {
|
|
163
|
-
this.adjustDate(-7, -4, -4);
|
|
164
|
-
} else {
|
|
165
|
-
this.open();
|
|
166
|
-
}
|
|
167
|
-
event.preventDefault();
|
|
168
|
-
break;
|
|
169
103
|
case 'ArrowRight':
|
|
170
|
-
if (open) {
|
|
171
|
-
this.adjustDate(1, 1, 1);
|
|
172
|
-
} else {
|
|
173
|
-
this.open();
|
|
174
|
-
}
|
|
175
|
-
event.preventDefault();
|
|
176
|
-
break;
|
|
177
104
|
case 'ArrowDown':
|
|
178
|
-
if (open) {
|
|
179
|
-
this.adjustDate(7, 4, 4);
|
|
180
|
-
} else {
|
|
105
|
+
if (!open) {
|
|
181
106
|
this.open();
|
|
107
|
+
event.preventDefault();
|
|
182
108
|
}
|
|
183
|
-
event.preventDefault();
|
|
184
109
|
break;
|
|
185
110
|
case 'Escape':
|
|
186
111
|
if (originalDate !== null) {
|
|
@@ -194,27 +119,6 @@ class DateLookup extends PureComponent<DateLookupPropsWithInputAttributes, DateL
|
|
|
194
119
|
}
|
|
195
120
|
};
|
|
196
121
|
|
|
197
|
-
adjustDate = (daysToAdd: number, monthsToAdd: number, yearsToAdd: number) => {
|
|
198
|
-
const { selectedDate, min, max, mode, originalDate } = this.state;
|
|
199
|
-
if (originalDate === null) {
|
|
200
|
-
this.setState({ originalDate: selectedDate });
|
|
201
|
-
}
|
|
202
|
-
let date: Date | null;
|
|
203
|
-
if (selectedDate) {
|
|
204
|
-
date = new Date(
|
|
205
|
-
mode === 'year' ? selectedDate.getFullYear() + yearsToAdd : selectedDate.getFullYear(),
|
|
206
|
-
mode === 'month' ? selectedDate.getMonth() + monthsToAdd : selectedDate.getMonth(),
|
|
207
|
-
mode === 'day' ? selectedDate.getDate() + daysToAdd : selectedDate.getDate(),
|
|
208
|
-
);
|
|
209
|
-
} else {
|
|
210
|
-
date = getStartOfDay(new Date());
|
|
211
|
-
}
|
|
212
|
-
date &&= moveToWithinRange(date, min, max);
|
|
213
|
-
if (date?.getTime() !== selectedDate?.getTime()) {
|
|
214
|
-
this.props.onChange(date);
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
|
|
218
122
|
focusOn = (preferredElement: string, fallbackElement?: string) => {
|
|
219
123
|
const element = this.element.current?.querySelector(preferredElement) as HTMLElement | null;
|
|
220
124
|
if (element) {
|
|
@@ -224,71 +128,37 @@ class DateLookup extends PureComponent<DateLookupPropsWithInputAttributes, DateL
|
|
|
224
128
|
}
|
|
225
129
|
};
|
|
226
130
|
|
|
227
|
-
|
|
228
|
-
this.setState(
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
switchToYears = () => this.switchMode('year');
|
|
238
|
-
|
|
239
|
-
handleSelectedDateUpdate = (selectedDate: Date) => {
|
|
240
|
-
this.setState({ selectedDate }, () => {
|
|
241
|
-
this.props.onChange(selectedDate);
|
|
242
|
-
this.close();
|
|
243
|
-
this.focusOn('.btn');
|
|
244
|
-
});
|
|
131
|
+
handleDateChange = (date: Date | null) => {
|
|
132
|
+
this.setState(
|
|
133
|
+
(state) => {
|
|
134
|
+
const originalDate = state.originalDate ?? this.props.value;
|
|
135
|
+
return { originalDate };
|
|
136
|
+
},
|
|
137
|
+
() => {
|
|
138
|
+
this.props.onChange(date);
|
|
139
|
+
},
|
|
140
|
+
);
|
|
245
141
|
};
|
|
246
142
|
|
|
247
|
-
|
|
248
|
-
this.
|
|
143
|
+
handleDateSelect = (date: Date) => {
|
|
144
|
+
this.props.onChange(date);
|
|
145
|
+
this.close();
|
|
146
|
+
this.focusOn('.btn');
|
|
249
147
|
};
|
|
250
148
|
|
|
251
149
|
getCalendar = () => {
|
|
252
|
-
const {
|
|
253
|
-
const { placeholder, monthFormat } = this.props;
|
|
150
|
+
const { value, min, max, monthFormat, placeholder } = this.props;
|
|
254
151
|
return (
|
|
255
|
-
<div className=
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
onLabelClick={this.switchToYears}
|
|
266
|
-
onViewDateUpdate={this.handleViewDateUpdate}
|
|
267
|
-
/>
|
|
268
|
-
)}
|
|
269
|
-
{mode === 'month' && (
|
|
270
|
-
<MonthCalendar
|
|
271
|
-
selectedDate={selectedDate}
|
|
272
|
-
min={min}
|
|
273
|
-
max={max}
|
|
274
|
-
viewYear={viewYear}
|
|
275
|
-
placeholder={placeholder}
|
|
276
|
-
onSelect={this.switchToDays}
|
|
277
|
-
onLabelClick={this.switchToYears}
|
|
278
|
-
onViewDateUpdate={this.handleViewDateUpdate}
|
|
279
|
-
/>
|
|
280
|
-
)}
|
|
281
|
-
{mode === 'year' && (
|
|
282
|
-
<YearCalendar
|
|
283
|
-
selectedDate={selectedDate}
|
|
284
|
-
min={min}
|
|
285
|
-
max={max}
|
|
286
|
-
viewYear={viewYear}
|
|
287
|
-
placeholder={placeholder}
|
|
288
|
-
onSelect={this.switchToMonths}
|
|
289
|
-
onViewDateUpdate={this.handleViewDateUpdate}
|
|
290
|
-
/>
|
|
291
|
-
)}
|
|
152
|
+
<div className="p-a-1">
|
|
153
|
+
<Calendar
|
|
154
|
+
value={value}
|
|
155
|
+
min={min}
|
|
156
|
+
max={max}
|
|
157
|
+
monthFormat={monthFormat}
|
|
158
|
+
placeholder={placeholder}
|
|
159
|
+
onChange={this.handleDateChange}
|
|
160
|
+
onSelect={this.handleDateSelect}
|
|
161
|
+
/>
|
|
292
162
|
</div>
|
|
293
163
|
);
|
|
294
164
|
};
|
|
@@ -299,7 +169,7 @@ class DateLookup extends PureComponent<DateLookupPropsWithInputAttributes, DateL
|
|
|
299
169
|
};
|
|
300
170
|
|
|
301
171
|
render() {
|
|
302
|
-
const {
|
|
172
|
+
const { open } = this.state;
|
|
303
173
|
|
|
304
174
|
const {
|
|
305
175
|
inputAttributes,
|
|
@@ -329,7 +199,7 @@ class DateLookup extends PureComponent<DateLookupPropsWithInputAttributes, DateL
|
|
|
329
199
|
<DateTrigger
|
|
330
200
|
id={id}
|
|
331
201
|
ariaLabelledBy={ariaLabelledBy}
|
|
332
|
-
selectedDate={
|
|
202
|
+
selectedDate={value}
|
|
333
203
|
size={size}
|
|
334
204
|
placeholder={placeholder}
|
|
335
205
|
label={label}
|
package/src/index.ts
CHANGED
|
@@ -29,6 +29,7 @@ export type {
|
|
|
29
29
|
export type { BottomSheetProps } from './common/bottomSheet';
|
|
30
30
|
export type { DateInputProps } from './dateInput';
|
|
31
31
|
export type { DateLookupProps } from './dateLookup';
|
|
32
|
+
export type { CalendarProps } from './calendar';
|
|
32
33
|
export type { DecisionProps } from './decision/Decision';
|
|
33
34
|
export type { DefinitionListProps, DefinitionListDefinition } from './definitionList';
|
|
34
35
|
export type { DimmerProps } from './dimmer';
|
|
@@ -163,6 +164,7 @@ export { default as CriticalCommsBanner } from './criticalBanner';
|
|
|
163
164
|
export type { CriticalCommsBannerProps } from './criticalBanner';
|
|
164
165
|
export { default as DateInput } from './dateInput';
|
|
165
166
|
export { default as DateLookup } from './dateLookup';
|
|
167
|
+
export { default as Calendar } from './calendar';
|
|
166
168
|
export { default as Decision } from './decision';
|
|
167
169
|
export { default as DefinitionList } from './definitionList';
|
|
168
170
|
export { default as Dimmer } from './dimmer';
|