@transferwise/components 0.0.0-experimental-bcea1dd → 0.0.0-experimental-1168b1c
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 +47 -8
- package/build/Calendar/Calendar.js.map +1 -1
- package/build/Calendar/Calendar.messages.js +3 -0
- package/build/Calendar/Calendar.messages.js.map +1 -1
- package/build/Calendar/Calendar.messages.mjs +3 -0
- package/build/Calendar/Calendar.messages.mjs.map +1 -1
- package/build/Calendar/Calendar.mjs +48 -9
- package/build/Calendar/Calendar.mjs.map +1 -1
- package/build/Calendar/DayCalendar/DayCalendar.js +4 -0
- package/build/Calendar/DayCalendar/DayCalendar.js.map +1 -1
- package/build/Calendar/DayCalendar/DayCalendar.mjs +4 -0
- package/build/Calendar/DayCalendar/DayCalendar.mjs.map +1 -1
- package/build/Calendar/DayCalendar/Table/DayCalendarTable.js +30 -18
- package/build/Calendar/DayCalendar/Table/DayCalendarTable.js.map +1 -1
- package/build/Calendar/DayCalendar/Table/DayCalendarTable.mjs +30 -18
- package/build/Calendar/DayCalendar/Table/DayCalendarTable.mjs.map +1 -1
- package/build/Calendar/MonthCalendar/Table/MonthCalendarTable.js +1 -1
- package/build/Calendar/MonthCalendar/Table/MonthCalendarTable.js.map +1 -1
- package/build/Calendar/MonthCalendar/Table/MonthCalendarTable.mjs +1 -1
- package/build/Calendar/MonthCalendar/Table/MonthCalendarTable.mjs.map +1 -1
- package/build/Calendar/{tableLink → TableLink}/TableLink.js +23 -11
- package/build/Calendar/TableLink/TableLink.js.map +1 -0
- package/build/Calendar/{tableLink → TableLink}/TableLink.mjs +23 -11
- package/build/Calendar/TableLink/TableLink.mjs.map +1 -0
- package/build/Calendar/YearCalendar/Table/YearCalendarTable.js +1 -1
- package/build/Calendar/YearCalendar/Table/YearCalendarTable.js.map +1 -1
- package/build/Calendar/YearCalendar/Table/YearCalendarTable.mjs +1 -1
- package/build/Calendar/YearCalendar/Table/YearCalendarTable.mjs.map +1 -1
- package/build/DateLookup/DateLookup.js +14 -4
- package/build/DateLookup/DateLookup.js.map +1 -1
- package/build/DateLookup/DateLookup.mjs +14 -4
- package/build/DateLookup/DateLookup.mjs.map +1 -1
- package/build/common/DateUtils/hasDisabledDatesInMonth/hasDisabledDatesInMonth.js +33 -0
- package/build/common/DateUtils/hasDisabledDatesInMonth/hasDisabledDatesInMonth.js.map +1 -0
- package/build/common/DateUtils/hasDisabledDatesInMonth/hasDisabledDatesInMonth.mjs +31 -0
- package/build/common/DateUtils/hasDisabledDatesInMonth/hasDisabledDatesInMonth.mjs.map +1 -0
- package/build/common/DateUtils/isDateDisabled/isDateDisabled.js +40 -0
- package/build/common/DateUtils/isDateDisabled/isDateDisabled.js.map +1 -0
- package/build/common/DateUtils/isDateDisabled/isDateDisabled.mjs +38 -0
- package/build/common/DateUtils/isDateDisabled/isDateDisabled.mjs.map +1 -0
- package/build/i18n/en.json +1 -0
- package/build/i18n/en.json.js +1 -0
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +1 -0
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/index.js +2 -4
- package/build/index.js.map +1 -1
- package/build/index.mjs +1 -2
- package/build/index.mjs.map +1 -1
- package/build/main.css +114 -76
- package/build/styles/Calendar/Calendar.css +104 -35
- package/build/styles/Calendar/TableLink/TableLink.css +109 -0
- package/build/styles/main.css +114 -76
- package/build/types/Body/Body.d.ts +2 -2
- package/build/types/Calendar/Calendar.d.ts +4 -2
- package/build/types/Calendar/Calendar.d.ts.map +1 -1
- package/build/types/Calendar/Calendar.messages.d.ts +5 -0
- package/build/types/Calendar/Calendar.messages.d.ts.map +1 -1
- package/build/types/Calendar/Calendar.types.d.ts +19 -0
- package/build/types/Calendar/Calendar.types.d.ts.map +1 -0
- package/build/types/Calendar/DayCalendar/DayCalendar.d.ts +4 -1
- package/build/types/Calendar/DayCalendar/DayCalendar.d.ts.map +1 -1
- package/build/types/Calendar/DayCalendar/Table/DayCalendarTable.d.ts +3 -0
- package/build/types/Calendar/DayCalendar/Table/DayCalendarTable.d.ts.map +1 -1
- package/build/types/Calendar/{tableLink → TableLink}/TableLink.d.ts +2 -1
- 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/Calendar/index.d.ts +1 -0
- package/build/types/Calendar/index.d.ts.map +1 -1
- package/build/types/DateLookup/DateLookup.d.ts +5 -2
- package/build/types/DateLookup/DateLookup.d.ts.map +1 -1
- package/build/types/DateLookup/index.d.ts +1 -0
- package/build/types/DateLookup/index.d.ts.map +1 -1
- package/build/types/IconButton/IconButton.d.ts +1 -1
- package/build/types/Title/Title.d.ts +2 -2
- package/build/types/Upload/Steps/UploadImageStep/UploadImageStep.d.ts +1 -1
- package/build/types/UploadInput/UploadItem/UploadItemLink.d.ts +1 -1
- package/build/types/common/DateUtils/hasDisabledDatesInMonth/hasDisabledDatesInMonth.d.ts +3 -0
- package/build/types/common/DateUtils/hasDisabledDatesInMonth/hasDisabledDatesInMonth.d.ts.map +1 -0
- package/build/types/common/DateUtils/index.d.ts +2 -0
- package/build/types/common/DateUtils/index.d.ts.map +1 -1
- package/build/types/common/DateUtils/isDateDisabled/isDateDisabled.d.ts +3 -0
- package/build/types/common/DateUtils/isDateDisabled/isDateDisabled.d.ts.map +1 -0
- package/build/types/index.d.ts +2 -4
- package/build/types/index.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts +2 -0
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/Calendar/Calendar.css +104 -35
- package/src/Calendar/Calendar.disabledDates.test.tsx +197 -0
- package/src/Calendar/Calendar.less +5 -35
- package/src/Calendar/Calendar.messages.ts +5 -0
- package/src/Calendar/Calendar.test.tsx +9 -9
- package/src/Calendar/Calendar.tsx +61 -9
- package/src/Calendar/Calendar.types.ts +22 -0
- package/src/Calendar/DayCalendar/DayCalendar.tsx +17 -1
- package/src/Calendar/DayCalendar/Table/DayCalendarTable.tsx +42 -26
- package/src/Calendar/MonthCalendar/Table/MonthCalendarTable.tsx +1 -1
- package/src/Calendar/TableLink/TableLink.css +109 -0
- package/src/Calendar/TableLink/TableLink.less +60 -0
- package/src/Calendar/{tableLink → TableLink}/TableLink.tsx +24 -14
- package/src/Calendar/YearCalendar/Table/YearCalendarTable.tsx +1 -1
- package/src/Calendar/_stories/Calendar.accessibility.docs.mdx +112 -0
- package/src/Calendar/_stories/Calendar.story.tsx +55 -1
- package/src/Calendar/index.ts +7 -0
- package/src/DateLookup/DateLookup.disabledDates.test.tsx +120 -0
- package/src/DateLookup/DateLookup.test.tsx +1 -1
- package/src/DateLookup/DateLookup.tsx +11 -4
- package/src/DateLookup/_stories/DateLookup.accessibility.docs.mdx +100 -0
- package/src/DateLookup/_stories/DateLookup.story.tsx +59 -1
- package/src/DateLookup/index.ts +6 -0
- package/src/common/DateUtils/hasDisabledDatesInMonth/hasDisabledDatesInMonth.test.ts +98 -0
- package/src/common/DateUtils/hasDisabledDatesInMonth/hasDisabledDatesInMonth.ts +45 -0
- package/src/common/DateUtils/index.ts +2 -0
- package/src/common/DateUtils/isDateDisabled/isDateDisabled.test.ts +159 -0
- package/src/common/DateUtils/isDateDisabled/isDateDisabled.ts +59 -0
- package/src/i18n/en.json +1 -0
- package/src/index.ts +2 -4
- package/src/main.css +114 -76
- package/src/main.less +0 -1
- package/build/Calendar/tableLink/TableLink.js.map +0 -1
- package/build/Calendar/tableLink/TableLink.mjs.map +0 -1
- package/build/Markup/Markup.js +0 -136
- package/build/Markup/Markup.js.map +0 -1
- package/build/Markup/Markup.mjs +0 -131
- package/build/Markup/Markup.mjs.map +0 -1
- package/build/Markup/constants.js +0 -36
- package/build/Markup/constants.js.map +0 -1
- package/build/Markup/constants.mjs +0 -29
- package/build/Markup/constants.mjs.map +0 -1
- package/build/Markup/utils/parseMarkup.js +0 -226
- package/build/Markup/utils/parseMarkup.js.map +0 -1
- package/build/Markup/utils/parseMarkup.mjs +0 -223
- package/build/Markup/utils/parseMarkup.mjs.map +0 -1
- package/build/Markup/utils/sanitise.js +0 -91
- package/build/Markup/utils/sanitise.js.map +0 -1
- package/build/Markup/utils/sanitise.mjs +0 -89
- package/build/Markup/utils/sanitise.mjs.map +0 -1
- package/build/styles/Markup/Markup.css +0 -28
- package/build/styles/Markup/_stories/Vulnerability/Vulnerability.css +0 -70
- package/build/types/Calendar/tableLink/TableLink.d.ts.map +0 -1
- package/build/types/Calendar/tableLink/index.d.ts.map +0 -1
- package/build/types/Markup/Markup.d.ts +0 -18
- package/build/types/Markup/Markup.d.ts.map +0 -1
- package/build/types/Markup/Markup.types.d.ts +0 -68
- package/build/types/Markup/Markup.types.d.ts.map +0 -1
- package/build/types/Markup/_stories/Vulnerability/Vulnerability.d.ts +0 -12
- package/build/types/Markup/_stories/Vulnerability/Vulnerability.d.ts.map +0 -1
- package/build/types/Markup/constants.d.ts +0 -20
- package/build/types/Markup/constants.d.ts.map +0 -1
- package/build/types/Markup/index.d.ts +0 -3
- package/build/types/Markup/index.d.ts.map +0 -1
- package/build/types/Markup/utils/parseMarkup.d.ts +0 -6
- package/build/types/Markup/utils/parseMarkup.d.ts.map +0 -1
- package/build/types/Markup/utils/sanitise.d.ts +0 -2
- package/build/types/Markup/utils/sanitise.d.ts.map +0 -1
- package/src/Markup/Markup.css +0 -28
- package/src/Markup/Markup.injection.test.tsx +0 -152
- package/src/Markup/Markup.less +0 -29
- package/src/Markup/Markup.test.tsx +0 -405
- package/src/Markup/Markup.tsx +0 -165
- package/src/Markup/Markup.types.ts +0 -53
- package/src/Markup/_stories/Markup.docs.mdx +0 -75
- package/src/Markup/_stories/Markup.security.docs.mdx +0 -256
- package/src/Markup/_stories/Markup.story.tsx +0 -227
- package/src/Markup/_stories/Vulnerability/Vulnerability.css +0 -70
- package/src/Markup/_stories/Vulnerability/Vulnerability.tsx +0 -30
- package/src/Markup/constants.ts +0 -41
- package/src/Markup/index.ts +0 -2
- package/src/Markup/utils/parseMarkup.test.ts +0 -658
- package/src/Markup/utils/parseMarkup.ts +0 -228
- package/src/Markup/utils/sanitise.test.ts +0 -375
- package/src/Markup/utils/sanitise.ts +0 -107
- /package/build/types/Calendar/{tableLink → TableLink}/index.d.ts +0 -0
- /package/src/Calendar/{tableLink → TableLink}/index.ts +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { DisabledRules } from '../../../Calendar/Calendar.types';
|
|
2
|
+
|
|
3
|
+
export function hasDisabledDatesInMonth(
|
|
4
|
+
month: number,
|
|
5
|
+
year: number,
|
|
6
|
+
disabledRules?: DisabledRules,
|
|
7
|
+
min?: Date | null,
|
|
8
|
+
max?: Date | null,
|
|
9
|
+
): boolean {
|
|
10
|
+
if (!disabledRules) return false;
|
|
11
|
+
|
|
12
|
+
if (disabledRules.weekdays?.length) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const monthStart = new Date(year, month, 1);
|
|
17
|
+
const monthEnd = new Date(year, month + 1, 0);
|
|
18
|
+
|
|
19
|
+
if (disabledRules.dates?.length) {
|
|
20
|
+
const hasDateInMonth = disabledRules.dates.some((date) => {
|
|
21
|
+
if (date.getFullYear() !== year || date.getMonth() !== month) return false;
|
|
22
|
+
if (min && date < min) return false;
|
|
23
|
+
if (max && date > max) return false;
|
|
24
|
+
return true;
|
|
25
|
+
});
|
|
26
|
+
if (hasDateInMonth) return true;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (disabledRules.ranges?.length) {
|
|
30
|
+
const hasOverlap = disabledRules.ranges.some((range) => {
|
|
31
|
+
const rangeStart = new Date(
|
|
32
|
+
range.start.getFullYear(),
|
|
33
|
+
range.start.getMonth(),
|
|
34
|
+
range.start.getDate(),
|
|
35
|
+
);
|
|
36
|
+
const rangeEnd = new Date(range.end.getFullYear(), range.end.getMonth(), range.end.getDate());
|
|
37
|
+
if (max && rangeStart > max) return false;
|
|
38
|
+
if (min && rangeEnd < min) return false;
|
|
39
|
+
return rangeStart <= monthEnd && rangeEnd >= monthStart;
|
|
40
|
+
});
|
|
41
|
+
if (hasOverlap) return true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
@@ -6,3 +6,5 @@ export { isDateValid } from './isDateValid/isDateValid';
|
|
|
6
6
|
export { isMonthAndYearFormat } from './isMonthAndYearFormat/isMonthAndYearFormat';
|
|
7
7
|
export { MDY, YMD } from './getFormatForLocale/getFormatForLocale';
|
|
8
8
|
export { returnDateView } from './getDateView/getDateView';
|
|
9
|
+
export { isDateDisabled } from './isDateDisabled/isDateDisabled';
|
|
10
|
+
export { hasDisabledDatesInMonth } from './hasDisabledDatesInMonth/hasDisabledDatesInMonth';
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { isDateDisabled } from './isDateDisabled';
|
|
2
|
+
import type { DisabledRules } from '../../../Calendar/Calendar.types';
|
|
3
|
+
|
|
4
|
+
describe('isDateDisabled', () => {
|
|
5
|
+
describe('when no rules provided', () => {
|
|
6
|
+
it('returns false when disabledRules is undefined', () => {
|
|
7
|
+
expect(isDateDisabled(new Date('2024-07-15'), undefined)).toBe(false);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('returns false when disabledRules has only reason', () => {
|
|
11
|
+
const rules: DisabledRules = { reason: 'some reason' };
|
|
12
|
+
expect(isDateDisabled(new Date('2024-07-15'), rules)).toBe(false);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
describe('weekdays', () => {
|
|
17
|
+
const rules: DisabledRules = {
|
|
18
|
+
weekdays: ['sat', 'sun'],
|
|
19
|
+
reason: 'Closed on weekends',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
it('returns true for a Saturday', () => {
|
|
23
|
+
// 2024-07-13 is a Saturday
|
|
24
|
+
expect(isDateDisabled(new Date(2024, 6, 13), rules)).toBe(true);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('returns true for a Sunday', () => {
|
|
28
|
+
// 2024-07-14 is a Sunday
|
|
29
|
+
expect(isDateDisabled(new Date(2024, 6, 14), rules)).toBe(true);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('returns false for a Monday', () => {
|
|
33
|
+
// 2024-07-15 is a Monday
|
|
34
|
+
expect(isDateDisabled(new Date(2024, 6, 15), rules)).toBe(false);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('returns false for a Friday', () => {
|
|
38
|
+
// 2024-07-12 is a Friday
|
|
39
|
+
expect(isDateDisabled(new Date(2024, 6, 12), rules)).toBe(false);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('handles single weekday rule', () => {
|
|
43
|
+
const singleDay: DisabledRules = { weekdays: ['wed'], reason: 'Closed' };
|
|
44
|
+
// 2024-07-17 is a Wednesday
|
|
45
|
+
expect(isDateDisabled(new Date(2024, 6, 17), singleDay)).toBe(true);
|
|
46
|
+
// 2024-07-18 is a Thursday
|
|
47
|
+
expect(isDateDisabled(new Date(2024, 6, 18), singleDay)).toBe(false);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe('specific dates', () => {
|
|
52
|
+
const rules: DisabledRules = {
|
|
53
|
+
dates: [new Date(2024, 6, 11), new Date(2025, 1, 12), new Date(2025, 4, 1)],
|
|
54
|
+
reason: 'Bank holidays',
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
it('returns true for a disabled date', () => {
|
|
58
|
+
expect(isDateDisabled(new Date(2024, 6, 11), rules)).toBe(true);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('returns false for a non-disabled date', () => {
|
|
62
|
+
expect(isDateDisabled(new Date(2024, 6, 12), rules)).toBe(false);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('compares date-only, ignoring time', () => {
|
|
66
|
+
const dateWithTime = new Date(2024, 6, 11, 14, 30, 0);
|
|
67
|
+
expect(isDateDisabled(dateWithTime, rules)).toBe(true);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('handles disabled dates that have non-zero time components', () => {
|
|
71
|
+
const rulesWithTime: DisabledRules = {
|
|
72
|
+
dates: [new Date(2024, 6, 11, 23, 59, 59)],
|
|
73
|
+
reason: 'Holiday',
|
|
74
|
+
};
|
|
75
|
+
expect(isDateDisabled(new Date(2024, 6, 11), rulesWithTime)).toBe(true);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('ranges', () => {
|
|
80
|
+
const rules: DisabledRules = {
|
|
81
|
+
ranges: [
|
|
82
|
+
{ start: new Date(2024, 2, 29), end: new Date(2024, 3, 3) },
|
|
83
|
+
{ start: new Date(2024, 11, 24), end: new Date(2024, 11, 26) },
|
|
84
|
+
],
|
|
85
|
+
reason: 'Scheduled maintenance',
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
it('returns true for start of range (inclusive)', () => {
|
|
89
|
+
expect(isDateDisabled(new Date(2024, 2, 29), rules)).toBe(true);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('returns true for end of range (inclusive)', () => {
|
|
93
|
+
expect(isDateDisabled(new Date(2024, 3, 3), rules)).toBe(true);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('returns true for date within range', () => {
|
|
97
|
+
expect(isDateDisabled(new Date(2024, 2, 31), rules)).toBe(true);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('returns false for date before range', () => {
|
|
101
|
+
expect(isDateDisabled(new Date(2024, 2, 28), rules)).toBe(false);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('returns false for date after range', () => {
|
|
105
|
+
expect(isDateDisabled(new Date(2024, 3, 4), rules)).toBe(false);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('handles second range', () => {
|
|
109
|
+
expect(isDateDisabled(new Date(2024, 11, 25), rules)).toBe(true);
|
|
110
|
+
expect(isDateDisabled(new Date(2024, 11, 27), rules)).toBe(false);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
describe('combined rules (additive)', () => {
|
|
115
|
+
const rules: DisabledRules = {
|
|
116
|
+
weekdays: ['sat', 'sun'],
|
|
117
|
+
dates: [new Date(2024, 6, 15)], // Monday
|
|
118
|
+
ranges: [{ start: new Date(2024, 6, 22), end: new Date(2024, 6, 24) }],
|
|
119
|
+
reason: 'Multiple rules',
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
it('disables by weekday', () => {
|
|
123
|
+
// 2024-07-13 is Saturday
|
|
124
|
+
expect(isDateDisabled(new Date(2024, 6, 13), rules)).toBe(true);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('disables by specific date', () => {
|
|
128
|
+
// 2024-07-15 is Monday but explicitly disabled
|
|
129
|
+
expect(isDateDisabled(new Date(2024, 6, 15), rules)).toBe(true);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('disables by range', () => {
|
|
133
|
+
// 2024-07-23 is Tuesday but in range
|
|
134
|
+
expect(isDateDisabled(new Date(2024, 6, 23), rules)).toBe(true);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('allows date not matching any rule', () => {
|
|
138
|
+
// 2024-07-16 is Tuesday, not in dates or ranges
|
|
139
|
+
expect(isDateDisabled(new Date(2024, 6, 16), rules)).toBe(false);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
describe('edge cases', () => {
|
|
144
|
+
it('handles empty weekdays array', () => {
|
|
145
|
+
const rules: DisabledRules = { weekdays: [], reason: 'Empty' };
|
|
146
|
+
expect(isDateDisabled(new Date(2024, 6, 13), rules)).toBe(false);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('handles empty dates array', () => {
|
|
150
|
+
const rules: DisabledRules = { dates: [], reason: 'Empty' };
|
|
151
|
+
expect(isDateDisabled(new Date(2024, 6, 13), rules)).toBe(false);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('handles empty ranges array', () => {
|
|
155
|
+
const rules: DisabledRules = { ranges: [], reason: 'Empty' };
|
|
156
|
+
expect(isDateDisabled(new Date(2024, 6, 13), rules)).toBe(false);
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { DisabledRules, WeekDayType } from '../../../Calendar/Calendar.types';
|
|
2
|
+
|
|
3
|
+
const DAY_INDEX_TO_WEEKDAY: Record<number, WeekDayType> = {
|
|
4
|
+
0: 'sun',
|
|
5
|
+
1: 'mon',
|
|
6
|
+
2: 'tue',
|
|
7
|
+
3: 'wed',
|
|
8
|
+
4: 'thu',
|
|
9
|
+
5: 'fri',
|
|
10
|
+
6: 'sat',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export function isDateDisabled(date: Date, disabledRules?: DisabledRules): boolean {
|
|
14
|
+
if (!disabledRules) return false;
|
|
15
|
+
|
|
16
|
+
if (disabledRules.weekdays?.length) {
|
|
17
|
+
const weekday = DAY_INDEX_TO_WEEKDAY[date.getDay()];
|
|
18
|
+
if (disabledRules.weekdays.includes(weekday)) return true;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (disabledRules.dates?.length) {
|
|
22
|
+
const year = date.getFullYear();
|
|
23
|
+
const month = date.getMonth();
|
|
24
|
+
const day = date.getDate();
|
|
25
|
+
if (
|
|
26
|
+
disabledRules.dates.some(
|
|
27
|
+
(disabledDate) =>
|
|
28
|
+
disabledDate.getFullYear() === year &&
|
|
29
|
+
disabledDate.getMonth() === month &&
|
|
30
|
+
disabledDate.getDate() === day,
|
|
31
|
+
)
|
|
32
|
+
) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (disabledRules.ranges?.length) {
|
|
38
|
+
const dateStart = new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime();
|
|
39
|
+
if (
|
|
40
|
+
disabledRules.ranges.some((range) => {
|
|
41
|
+
const rangeStart = new Date(
|
|
42
|
+
range.start.getFullYear(),
|
|
43
|
+
range.start.getMonth(),
|
|
44
|
+
range.start.getDate(),
|
|
45
|
+
).getTime();
|
|
46
|
+
const rangeEnd = new Date(
|
|
47
|
+
range.end.getFullYear(),
|
|
48
|
+
range.end.getMonth(),
|
|
49
|
+
range.end.getDate(),
|
|
50
|
+
).getTime();
|
|
51
|
+
return dateStart >= rangeStart && dateStart <= rangeEnd;
|
|
52
|
+
})
|
|
53
|
+
) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return false;
|
|
59
|
+
}
|
package/src/i18n/en.json
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"neptune.DateLookup.goTo20YearView": "Go to 20 year view",
|
|
13
13
|
"neptune.DateLookup.month": "month",
|
|
14
14
|
"neptune.DateLookup.next": "next",
|
|
15
|
+
"neptune.DateLookup.notAvailable": "not available",
|
|
15
16
|
"neptune.DateLookup.previous": "previous",
|
|
16
17
|
"neptune.DateLookup.selected": "selected",
|
|
17
18
|
"neptune.DateLookup.twentyYears": "20 years",
|
package/src/index.ts
CHANGED
|
@@ -25,6 +25,7 @@ export type {
|
|
|
25
25
|
ButtonProps as LegacyButtonProps,
|
|
26
26
|
AnchorElementProps,
|
|
27
27
|
} from './Button';
|
|
28
|
+
export type { CalendarProps } from './Calendar';
|
|
28
29
|
export type { CardProps } from './_deprecated/Card';
|
|
29
30
|
export type {
|
|
30
31
|
CarouselProps,
|
|
@@ -55,7 +56,6 @@ export type {
|
|
|
55
56
|
export type { BottomSheetProps } from './common/BottomSheet';
|
|
56
57
|
export type { DateInputProps } from './DateInput';
|
|
57
58
|
export type { DateLookupProps } from './DateLookup';
|
|
58
|
-
export type { CalendarProps } from './Calendar';
|
|
59
59
|
export type { DecisionProps } from './Decision';
|
|
60
60
|
export type {
|
|
61
61
|
DefinitionListProps,
|
|
@@ -91,7 +91,6 @@ export type { LabelProps, LabelOptionalProps, LabelDescriptionProps } from './La
|
|
|
91
91
|
export type { LegacyListItemProps } from './_deprecated/LegacyListItem';
|
|
92
92
|
export type { LoaderProps } from './Loader';
|
|
93
93
|
export type { MarkdownProps } from './Markdown';
|
|
94
|
-
export type { MarkupActionHandler, MarkupActions, MarkupNode, MarkupProps } from './Markup';
|
|
95
94
|
export type { ModalProps } from './Modal';
|
|
96
95
|
export type { MoneyProps } from './Money';
|
|
97
96
|
export type {
|
|
@@ -202,6 +201,7 @@ export { default as Badge, BadgeAssets } from './_deprecated/Badge';
|
|
|
202
201
|
export { default as Body } from './Body';
|
|
203
202
|
export { default as Button } from './Button';
|
|
204
203
|
export { default as IconButton } from './IconButton';
|
|
204
|
+
export { default as Calendar } from './Calendar';
|
|
205
205
|
export { default as Carousel } from './Carousel';
|
|
206
206
|
export { default as Card } from './_deprecated/Card';
|
|
207
207
|
export { default as Checkbox } from './Checkbox';
|
|
@@ -217,7 +217,6 @@ export { default as BaseCard } from './common/BaseCard';
|
|
|
217
217
|
export { default as CriticalCommsBanner } from './_deprecated/CriticalBanner';
|
|
218
218
|
export { default as DateInput } from './DateInput';
|
|
219
219
|
export { default as DateLookup } from './DateLookup';
|
|
220
|
-
export { default as Calendar } from './Calendar';
|
|
221
220
|
export { default as Decision } from './Decision';
|
|
222
221
|
export { default as DefinitionList } from './DefinitionList';
|
|
223
222
|
export { default as Dimmer } from './Dimmer';
|
|
@@ -250,7 +249,6 @@ export { default as LegacyListItem } from './_deprecated/LegacyListItem';
|
|
|
250
249
|
export { default as Loader } from './Loader';
|
|
251
250
|
export { default as Logo } from './Logo';
|
|
252
251
|
export { default as Markdown } from './Markdown';
|
|
253
|
-
export { default as Markup } from './Markup';
|
|
254
252
|
export { default as Modal } from './Modal';
|
|
255
253
|
export { default as Money } from './Money';
|
|
256
254
|
export { default as MoneyInput } from './MoneyInput';
|
package/src/main.css
CHANGED
|
@@ -27269,41 +27269,9 @@ a[data-toggle="tooltip"] {
|
|
|
27269
27269
|
pointer-events: auto;
|
|
27270
27270
|
}
|
|
27271
27271
|
|
|
27272
|
-
.
|
|
27273
|
-
|
|
27274
|
-
|
|
27275
|
-
table-layout: fixed;
|
|
27276
|
-
border: none;
|
|
27277
|
-
background-color: inherit;
|
|
27278
|
-
}
|
|
27279
|
-
|
|
27280
|
-
.tw-date-lookup-calendar thead {
|
|
27281
|
-
background-color: transparent;
|
|
27282
|
-
background-color: initial;
|
|
27283
|
-
}
|
|
27284
|
-
|
|
27285
|
-
.tw-date-lookup-calendar > tbody > tr > td.weekend button {
|
|
27286
|
-
color: #5d7079;
|
|
27287
|
-
color: var(--color-content-secondary);
|
|
27288
|
-
}
|
|
27289
|
-
|
|
27290
|
-
.tw-date-lookup-calendar > tbody > tr > td {
|
|
27291
|
-
border: none;
|
|
27292
|
-
padding: 4px;
|
|
27293
|
-
padding: var(--size-4);
|
|
27294
|
-
}
|
|
27295
|
-
|
|
27296
|
-
@media (max-width: 320px) {
|
|
27297
|
-
.tw-date-lookup-calendar > tbody > tr > td {
|
|
27298
|
-
padding: 0;
|
|
27299
|
-
}
|
|
27300
|
-
}
|
|
27301
|
-
|
|
27302
|
-
.tw-date-lookup-calendar > tbody > tr > td:has(.tw-date-lookup-day-option) {
|
|
27303
|
-
padding: 1px;
|
|
27304
|
-
}
|
|
27305
|
-
|
|
27306
|
-
.tw-date-lookup-calendar > tbody > tr > td button {
|
|
27272
|
+
.wds-Calendar__option--day,
|
|
27273
|
+
.wds-Calendar__option--month,
|
|
27274
|
+
.wds-Calendar__option--year {
|
|
27307
27275
|
width: 100%;
|
|
27308
27276
|
padding: 4px 0;
|
|
27309
27277
|
padding: var(--size-4) 0;
|
|
@@ -27320,12 +27288,83 @@ a[data-toggle="tooltip"] {
|
|
|
27320
27288
|
}
|
|
27321
27289
|
|
|
27322
27290
|
@media (max-width: 320px) {
|
|
27323
|
-
.
|
|
27291
|
+
.wds-Calendar__option--day,
|
|
27292
|
+
.wds-Calendar__option--month,
|
|
27293
|
+
.wds-Calendar__option--year {
|
|
27324
27294
|
padding: 0;
|
|
27325
27295
|
}
|
|
27326
27296
|
}
|
|
27327
27297
|
|
|
27328
|
-
.
|
|
27298
|
+
.wds-Calendar__option--day.disabled,
|
|
27299
|
+
.wds-Calendar__option--month.disabled,
|
|
27300
|
+
.wds-Calendar__option--year.disabled,
|
|
27301
|
+
.wds-Calendar__option--day[aria-disabled="true"],
|
|
27302
|
+
.wds-Calendar__option--month[aria-disabled="true"],
|
|
27303
|
+
.wds-Calendar__option--year[aria-disabled="true"] {
|
|
27304
|
+
--ring-outline-color: var(--color-sentiment-content-primary);
|
|
27305
|
+
color: #768e9c;
|
|
27306
|
+
color: var(--color-content-tertiary);
|
|
27307
|
+
cursor: not-allowed;
|
|
27308
|
+
}
|
|
27309
|
+
|
|
27310
|
+
.wds-Calendar__option--day.disabled:hover,
|
|
27311
|
+
.wds-Calendar__option--month.disabled:hover,
|
|
27312
|
+
.wds-Calendar__option--year.disabled:hover,
|
|
27313
|
+
.wds-Calendar__option--day[aria-disabled="true"]:hover,
|
|
27314
|
+
.wds-Calendar__option--month[aria-disabled="true"]:hover,
|
|
27315
|
+
.wds-Calendar__option--year[aria-disabled="true"]:hover,
|
|
27316
|
+
.wds-Calendar__option--day.disabled:focus,
|
|
27317
|
+
.wds-Calendar__option--month.disabled:focus,
|
|
27318
|
+
.wds-Calendar__option--year.disabled:focus,
|
|
27319
|
+
.wds-Calendar__option--day[aria-disabled="true"]:focus,
|
|
27320
|
+
.wds-Calendar__option--month[aria-disabled="true"]:focus,
|
|
27321
|
+
.wds-Calendar__option--year[aria-disabled="true"]:focus {
|
|
27322
|
+
background-color: var(--color-sentiment-background-surface);
|
|
27323
|
+
color: var(--color-sentiment-content-primary);
|
|
27324
|
+
filter: initial;
|
|
27325
|
+
opacity: 1;
|
|
27326
|
+
opacity: initial;
|
|
27327
|
+
}
|
|
27328
|
+
|
|
27329
|
+
.wds-Calendar__option--day.disabled.active,
|
|
27330
|
+
.wds-Calendar__option--month.disabled.active,
|
|
27331
|
+
.wds-Calendar__option--year.disabled.active,
|
|
27332
|
+
.wds-Calendar__option--day[aria-disabled="true"].active,
|
|
27333
|
+
.wds-Calendar__option--month[aria-disabled="true"].active,
|
|
27334
|
+
.wds-Calendar__option--year[aria-disabled="true"].active,
|
|
27335
|
+
.wds-Calendar__option--day.disabled.active:hover,
|
|
27336
|
+
.wds-Calendar__option--month.disabled.active:hover,
|
|
27337
|
+
.wds-Calendar__option--year.disabled.active:hover,
|
|
27338
|
+
.wds-Calendar__option--day[aria-disabled="true"].active:hover,
|
|
27339
|
+
.wds-Calendar__option--month[aria-disabled="true"].active:hover,
|
|
27340
|
+
.wds-Calendar__option--year[aria-disabled="true"].active:hover,
|
|
27341
|
+
.wds-Calendar__option--day.disabled.active:active,
|
|
27342
|
+
.wds-Calendar__option--month.disabled.active:active,
|
|
27343
|
+
.wds-Calendar__option--year.disabled.active:active,
|
|
27344
|
+
.wds-Calendar__option--day[aria-disabled="true"].active:active,
|
|
27345
|
+
.wds-Calendar__option--month[aria-disabled="true"].active:active,
|
|
27346
|
+
.wds-Calendar__option--year[aria-disabled="true"].active:active,
|
|
27347
|
+
.wds-Calendar__option--day.disabled.active:focus,
|
|
27348
|
+
.wds-Calendar__option--month.disabled.active:focus,
|
|
27349
|
+
.wds-Calendar__option--year.disabled.active:focus,
|
|
27350
|
+
.wds-Calendar__option--day[aria-disabled="true"].active:focus,
|
|
27351
|
+
.wds-Calendar__option--month[aria-disabled="true"].active:focus,
|
|
27352
|
+
.wds-Calendar__option--year[aria-disabled="true"].active:focus {
|
|
27353
|
+
background-color: var(--color-sentiment-interactive-primary);
|
|
27354
|
+
color: var(--color-sentiment-interactive-secondary);
|
|
27355
|
+
}
|
|
27356
|
+
|
|
27357
|
+
.wds-Calendar__option--day.disabled.today,
|
|
27358
|
+
.wds-Calendar__option--month.disabled.today,
|
|
27359
|
+
.wds-Calendar__option--year.disabled.today,
|
|
27360
|
+
.wds-Calendar__option--day[aria-disabled="true"].today,
|
|
27361
|
+
.wds-Calendar__option--month[aria-disabled="true"].today,
|
|
27362
|
+
.wds-Calendar__option--year[aria-disabled="true"].today {
|
|
27363
|
+
text-decoration-color: #768e9c;
|
|
27364
|
+
text-decoration-color: var(--color-content-tertiary);
|
|
27365
|
+
}
|
|
27366
|
+
|
|
27367
|
+
.wds-Calendar__option--day {
|
|
27329
27368
|
height: 40px;
|
|
27330
27369
|
height: var(--size-40);
|
|
27331
27370
|
border-radius: 9999px;
|
|
@@ -27340,19 +27379,53 @@ a[data-toggle="tooltip"] {
|
|
|
27340
27379
|
justify-content: center;
|
|
27341
27380
|
}
|
|
27342
27381
|
|
|
27343
|
-
.
|
|
27382
|
+
.wds-Calendar__option--day.today {
|
|
27344
27383
|
-webkit-text-decoration: underline;
|
|
27345
27384
|
text-decoration: underline;
|
|
27346
27385
|
text-decoration-thickness: 2px;
|
|
27347
27386
|
text-underline-offset: 4px;
|
|
27348
27387
|
}
|
|
27349
27388
|
|
|
27350
|
-
.tw-date-lookup-calendar
|
|
27351
|
-
|
|
27389
|
+
.tw-date-lookup-calendar {
|
|
27390
|
+
min-width: 300px;
|
|
27391
|
+
text-align: center;
|
|
27392
|
+
table-layout: fixed;
|
|
27393
|
+
border: none;
|
|
27394
|
+
background-color: inherit;
|
|
27395
|
+
}
|
|
27396
|
+
|
|
27397
|
+
.tw-date-lookup-calendar thead {
|
|
27398
|
+
background-color: transparent;
|
|
27399
|
+
background-color: initial;
|
|
27400
|
+
}
|
|
27401
|
+
|
|
27402
|
+
.tw-date-lookup-calendar > tbody > tr > td.weekend button {
|
|
27403
|
+
color: #5d7079;
|
|
27404
|
+
color: var(--color-content-secondary);
|
|
27405
|
+
}
|
|
27406
|
+
|
|
27407
|
+
.tw-date-lookup-calendar > tbody > tr > td {
|
|
27408
|
+
border: none;
|
|
27409
|
+
padding: 4px;
|
|
27410
|
+
padding: var(--size-4);
|
|
27411
|
+
}
|
|
27412
|
+
|
|
27413
|
+
@media (max-width: 320px) {
|
|
27414
|
+
.tw-date-lookup-calendar > tbody > tr > td {
|
|
27415
|
+
padding: 0;
|
|
27416
|
+
}
|
|
27417
|
+
}
|
|
27418
|
+
|
|
27419
|
+
.tw-date-lookup-calendar > tbody > tr > td:has(.wds-Calendar__option--day) {
|
|
27420
|
+
padding: 1px;
|
|
27421
|
+
}
|
|
27422
|
+
|
|
27423
|
+
.tw-date-lookup-calendar > tbody > tr > td:not(.disabled):not(:disabled) button.show-focus:not(.disabled):not([aria-disabled="true"]),
|
|
27424
|
+
.tw-date-lookup-calendar > tbody > tr > td:hover button:not(.disabled):not(:disabled):not([aria-disabled="true"]) {
|
|
27352
27425
|
background-color: var(--color-background-screen-hover);
|
|
27353
27426
|
}
|
|
27354
27427
|
|
|
27355
|
-
.tw-date-lookup-calendar > tbody > tr > td:not(.disabled):not(:disabled) button.active {
|
|
27428
|
+
.tw-date-lookup-calendar > tbody > tr > td:not(.disabled):not(:disabled) button.active:not([aria-disabled="true"]) {
|
|
27356
27429
|
background-color: var(--color-interactive-primary);
|
|
27357
27430
|
color: var(--color-interactive-contrast);
|
|
27358
27431
|
}
|
|
@@ -30887,41 +30960,6 @@ button.np-link {
|
|
|
30887
30960
|
height: var(--wds-logo-height);
|
|
30888
30961
|
}
|
|
30889
30962
|
|
|
30890
|
-
.wds-markup-emphasis {
|
|
30891
|
-
font-weight: 600;
|
|
30892
|
-
font-weight: var(--font-weight-semi-bold);
|
|
30893
|
-
font-style: normal;
|
|
30894
|
-
}
|
|
30895
|
-
|
|
30896
|
-
.wds-markup-emphasis--important {
|
|
30897
|
-
color: #37517e;
|
|
30898
|
-
color: var(--color-content-primary);
|
|
30899
|
-
}
|
|
30900
|
-
|
|
30901
|
-
.wds-markup-emphasis--positive {
|
|
30902
|
-
color: #008026;
|
|
30903
|
-
color: var(--color-content-positive);
|
|
30904
|
-
}
|
|
30905
|
-
|
|
30906
|
-
.wds-markup-emphasis--negative {
|
|
30907
|
-
color: #cf2929;
|
|
30908
|
-
color: var(--color-content-negative);
|
|
30909
|
-
}
|
|
30910
|
-
|
|
30911
|
-
.wds-markup-strong {
|
|
30912
|
-
font-weight: 600;
|
|
30913
|
-
font-weight: var(--font-weight-semi-bold);
|
|
30914
|
-
}
|
|
30915
|
-
|
|
30916
|
-
.wds-markup-strikethrough {
|
|
30917
|
-
-webkit-text-decoration: line-through;
|
|
30918
|
-
text-decoration: line-through;
|
|
30919
|
-
}
|
|
30920
|
-
|
|
30921
|
-
.wds-markup-paragraph {
|
|
30922
|
-
margin: 0;
|
|
30923
|
-
}
|
|
30924
|
-
|
|
30925
30963
|
.tw-modal--scrollable {
|
|
30926
30964
|
max-height: 100%;
|
|
30927
30965
|
/* mobile viewport bug fix */
|
package/src/main.less
CHANGED
|
@@ -56,7 +56,6 @@
|
|
|
56
56
|
@import "./Link/Link.less";
|
|
57
57
|
@import "./Loader/Loader.less";
|
|
58
58
|
@import "./Logo/Logo.less";
|
|
59
|
-
@import "./Markup/Markup.less";
|
|
60
59
|
@import "./Modal/Modal.less";
|
|
61
60
|
@import "./MoneyInput/MoneyInput.less";
|
|
62
61
|
@import "./ExpressiveMoneyInput/ExpressiveMoneyInput.less";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TableLink.js","sources":["../../../src/Calendar/tableLink/TableLink.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useEffect, useRef } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport messages from '../Calendar.messages';\n\ninterface TableLinkProps {\n item: number;\n type: 'day' | 'month' | 'year';\n title?: string;\n longTitle?: string;\n active: boolean;\n disabled: boolean;\n today: boolean;\n autofocus?: boolean;\n onClick: (item: number) => void;\n}\n\nconst TableLink = ({\n item,\n type,\n title,\n longTitle,\n active,\n disabled,\n today,\n autofocus,\n onClick,\n}: TableLinkProps) => {\n const buttonRef = useRef<HTMLButtonElement>(null);\n const intl = useIntl();\n\n useEffect(() => {\n if (autofocus) {\n setTimeout(() => {\n buttonRef.current?.focus();\n }, 0);\n }\n }, [autofocus]);\n\n const onCalendarClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n if (!disabled) {\n onClick(item);\n }\n };\n\n const calculateAriaLabel = () => {\n if (active) {\n return `${longTitle || title || ''}, ${intl.formatMessage(\n messages.selected,\n )} ${intl.formatMessage(messages[type])}`;\n }\n return longTitle || title;\n };\n\n return (\n <button\n ref={buttonRef}\n type=\"button\"\n className={clsx(\n `tw-date-lookup-${type}-option np-text-body-default-bold`,\n { active: !!active },\n { today: !!today },\n )}\n disabled={disabled}\n tabIndex={autofocus ? 0 : -1}\n aria-label={calculateAriaLabel()}\n aria-pressed={active}\n onClick={onCalendarClick}\n >\n {title || item}\n </button>\n );\n};\n\nexport default TableLink;\n"],"names":["TableLink","item","type","title","longTitle","active","disabled","today","autofocus","onClick","buttonRef","useRef","intl","useIntl","useEffect","setTimeout","current","focus","onCalendarClick","event","preventDefault","calculateAriaLabel","formatMessage","messages","selected","_jsx","ref","className","clsx","tabIndex","children"],"mappings":";;;;;;;;;;AAkBA,MAAMA,SAAS,GAAGA,CAAC;EACjBC,IAAI;EACJC,IAAI;EACJC,KAAK;EACLC,SAAS;EACTC,MAAM;EACNC,QAAQ;EACRC,KAAK;EACLC,SAAS;AACTC,EAAAA;AAAO,CACQ,KAAI;AACnB,EAAA,MAAMC,SAAS,GAAGC,YAAM,CAAoB,IAAI,CAAC;AACjD,EAAA,MAAMC,IAAI,GAAGC,iBAAO,EAAE;AAEtBC,EAAAA,eAAS,CAAC,MAAK;AACb,IAAA,IAAIN,SAAS,EAAE;AACbO,MAAAA,UAAU,CAAC,MAAK;AACdL,QAAAA,SAAS,CAACM,OAAO,EAAEC,KAAK,EAAE;MAC5B,CAAC,EAAE,CAAC,CAAC;AACP,IAAA;AACF,EAAA,CAAC,EAAE,CAACT,SAAS,CAAC,CAAC;EAEf,MAAMU,eAAe,GAAIC,KAA0C,IAAI;IACrEA,KAAK,CAACC,cAAc,EAAE;IACtB,IAAI,CAACd,QAAQ,EAAE;MACbG,OAAO,CAACR,IAAI,CAAC;AACf,IAAA;EACF,CAAC;EAED,MAAMoB,kBAAkB,GAAGA,MAAK;AAC9B,IAAA,IAAIhB,MAAM,EAAE;MACV,OAAO,CAAA,EAAGD,SAAS,IAAID,KAAK,IAAI,EAAE,CAAA,EAAA,EAAKS,IAAI,CAACU,aAAa,CACvDC,yBAAQ,CAACC,QAAQ,CAClB,CAAA,CAAA,EAAIZ,IAAI,CAACU,aAAa,CAACC,yBAAQ,CAACrB,IAAI,CAAC,CAAC,CAAA,CAAE;AAC3C,IAAA;IACA,OAAOE,SAAS,IAAID,KAAK;EAC3B,CAAC;AAED,EAAA,oBACEsB,cAAA,CAAA,QAAA,EAAA;AACEC,IAAAA,GAAG,EAAEhB,SAAU;AACfR,IAAAA,IAAI,EAAC,QAAQ;AACbyB,IAAAA,SAAS,EAAEC,SAAI,CACb,CAAA,eAAA,EAAkB1B,IAAI,mCAAmC,EACzD;MAAEG,MAAM,EAAE,CAAC,CAACA;AAAM,KAAE,EACpB;MAAEE,KAAK,EAAE,CAAC,CAACA;KAAO,CAClB;AACFD,IAAAA,QAAQ,EAAEA,QAAS;AACnBuB,IAAAA,QAAQ,EAAErB,SAAS,GAAG,CAAC,GAAG,EAAG;IAC7B,YAAA,EAAYa,kBAAkB,EAAG;AACjC,IAAA,cAAA,EAAchB,MAAO;AACrBI,IAAAA,OAAO,EAAES,eAAgB;IAAAY,QAAA,EAExB3B,KAAK,IAAIF;AAAI,GACR,CAAC;AAEb;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TableLink.mjs","sources":["../../../src/Calendar/tableLink/TableLink.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useEffect, useRef } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport messages from '../Calendar.messages';\n\ninterface TableLinkProps {\n item: number;\n type: 'day' | 'month' | 'year';\n title?: string;\n longTitle?: string;\n active: boolean;\n disabled: boolean;\n today: boolean;\n autofocus?: boolean;\n onClick: (item: number) => void;\n}\n\nconst TableLink = ({\n item,\n type,\n title,\n longTitle,\n active,\n disabled,\n today,\n autofocus,\n onClick,\n}: TableLinkProps) => {\n const buttonRef = useRef<HTMLButtonElement>(null);\n const intl = useIntl();\n\n useEffect(() => {\n if (autofocus) {\n setTimeout(() => {\n buttonRef.current?.focus();\n }, 0);\n }\n }, [autofocus]);\n\n const onCalendarClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n if (!disabled) {\n onClick(item);\n }\n };\n\n const calculateAriaLabel = () => {\n if (active) {\n return `${longTitle || title || ''}, ${intl.formatMessage(\n messages.selected,\n )} ${intl.formatMessage(messages[type])}`;\n }\n return longTitle || title;\n };\n\n return (\n <button\n ref={buttonRef}\n type=\"button\"\n className={clsx(\n `tw-date-lookup-${type}-option np-text-body-default-bold`,\n { active: !!active },\n { today: !!today },\n )}\n disabled={disabled}\n tabIndex={autofocus ? 0 : -1}\n aria-label={calculateAriaLabel()}\n aria-pressed={active}\n onClick={onCalendarClick}\n >\n {title || item}\n </button>\n );\n};\n\nexport default TableLink;\n"],"names":["TableLink","item","type","title","longTitle","active","disabled","today","autofocus","onClick","buttonRef","useRef","intl","useIntl","useEffect","setTimeout","current","focus","onCalendarClick","event","preventDefault","calculateAriaLabel","formatMessage","messages","selected","_jsx","ref","className","clsx","tabIndex","children"],"mappings":";;;;;;AAkBA,MAAMA,SAAS,GAAGA,CAAC;EACjBC,IAAI;EACJC,IAAI;EACJC,KAAK;EACLC,SAAS;EACTC,MAAM;EACNC,QAAQ;EACRC,KAAK;EACLC,SAAS;AACTC,EAAAA;AAAO,CACQ,KAAI;AACnB,EAAA,MAAMC,SAAS,GAAGC,MAAM,CAAoB,IAAI,CAAC;AACjD,EAAA,MAAMC,IAAI,GAAGC,OAAO,EAAE;AAEtBC,EAAAA,SAAS,CAAC,MAAK;AACb,IAAA,IAAIN,SAAS,EAAE;AACbO,MAAAA,UAAU,CAAC,MAAK;AACdL,QAAAA,SAAS,CAACM,OAAO,EAAEC,KAAK,EAAE;MAC5B,CAAC,EAAE,CAAC,CAAC;AACP,IAAA;AACF,EAAA,CAAC,EAAE,CAACT,SAAS,CAAC,CAAC;EAEf,MAAMU,eAAe,GAAIC,KAA0C,IAAI;IACrEA,KAAK,CAACC,cAAc,EAAE;IACtB,IAAI,CAACd,QAAQ,EAAE;MACbG,OAAO,CAACR,IAAI,CAAC;AACf,IAAA;EACF,CAAC;EAED,MAAMoB,kBAAkB,GAAGA,MAAK;AAC9B,IAAA,IAAIhB,MAAM,EAAE;MACV,OAAO,CAAA,EAAGD,SAAS,IAAID,KAAK,IAAI,EAAE,CAAA,EAAA,EAAKS,IAAI,CAACU,aAAa,CACvDC,QAAQ,CAACC,QAAQ,CAClB,CAAA,CAAA,EAAIZ,IAAI,CAACU,aAAa,CAACC,QAAQ,CAACrB,IAAI,CAAC,CAAC,CAAA,CAAE;AAC3C,IAAA;IACA,OAAOE,SAAS,IAAID,KAAK;EAC3B,CAAC;AAED,EAAA,oBACEsB,GAAA,CAAA,QAAA,EAAA;AACEC,IAAAA,GAAG,EAAEhB,SAAU;AACfR,IAAAA,IAAI,EAAC,QAAQ;AACbyB,IAAAA,SAAS,EAAEC,IAAI,CACb,CAAA,eAAA,EAAkB1B,IAAI,mCAAmC,EACzD;MAAEG,MAAM,EAAE,CAAC,CAACA;AAAM,KAAE,EACpB;MAAEE,KAAK,EAAE,CAAC,CAACA;KAAO,CAClB;AACFD,IAAAA,QAAQ,EAAEA,QAAS;AACnBuB,IAAAA,QAAQ,EAAErB,SAAS,GAAG,CAAC,GAAG,EAAG;IAC7B,YAAA,EAAYa,kBAAkB,EAAG;AACjC,IAAA,cAAA,EAAchB,MAAO;AACrBI,IAAAA,OAAO,EAAES,eAAgB;IAAAY,QAAA,EAExB3B,KAAK,IAAIF;AAAI,GACR,CAAC;AAEb;;;;"}
|