@transferwise/components 0.0.0-experimental-15273df → 0.0.0-experimental-d6d5b6e
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 +94 -16
- package/build/Calendar/Calendar.js.map +1 -1
- package/build/Calendar/Calendar.messages.js +12 -0
- package/build/Calendar/Calendar.messages.js.map +1 -1
- package/build/Calendar/Calendar.messages.mjs +12 -0
- package/build/Calendar/Calendar.messages.mjs.map +1 -1
- package/build/Calendar/Calendar.mjs +95 -17
- package/build/Calendar/Calendar.mjs.map +1 -1
- package/build/Calendar/DateHeader/DateHeader.js +5 -1
- package/build/Calendar/DateHeader/DateHeader.js.map +1 -1
- package/build/Calendar/DateHeader/DateHeader.mjs +5 -1
- package/build/Calendar/DateHeader/DateHeader.mjs.map +1 -1
- package/build/Calendar/DayCalendar/DayCalendar.js +14 -0
- package/build/Calendar/DayCalendar/DayCalendar.js.map +1 -1
- package/build/Calendar/DayCalendar/DayCalendar.mjs +14 -0
- package/build/Calendar/DayCalendar/DayCalendar.mjs.map +1 -1
- package/build/Calendar/DayCalendar/Table/DayCalendarTable.js +53 -19
- package/build/Calendar/DayCalendar/Table/DayCalendarTable.js.map +1 -1
- package/build/Calendar/DayCalendar/Table/DayCalendarTable.mjs +53 -19
- package/build/Calendar/DayCalendar/Table/DayCalendarTable.mjs.map +1 -1
- package/build/Calendar/MonthCalendar/MonthCalendar.js +6 -0
- package/build/Calendar/MonthCalendar/MonthCalendar.js.map +1 -1
- package/build/Calendar/MonthCalendar/MonthCalendar.mjs +6 -0
- package/build/Calendar/MonthCalendar/MonthCalendar.mjs.map +1 -1
- package/build/Calendar/MonthCalendar/Table/MonthCalendarTable.js +8 -3
- package/build/Calendar/MonthCalendar/Table/MonthCalendarTable.js.map +1 -1
- package/build/Calendar/MonthCalendar/Table/MonthCalendarTable.mjs +8 -3
- package/build/Calendar/MonthCalendar/Table/MonthCalendarTable.mjs.map +1 -1
- package/build/Calendar/{tableLink → TableLink}/TableLink.js +26 -11
- package/build/Calendar/TableLink/TableLink.js.map +1 -0
- package/build/Calendar/{tableLink → TableLink}/TableLink.mjs +26 -11
- package/build/Calendar/TableLink/TableLink.mjs.map +1 -0
- package/build/Calendar/YearCalendar/Table/YearCalendarTable.js +8 -3
- package/build/Calendar/YearCalendar/Table/YearCalendarTable.js.map +1 -1
- package/build/Calendar/YearCalendar/Table/YearCalendarTable.mjs +8 -3
- package/build/Calendar/YearCalendar/Table/YearCalendarTable.mjs.map +1 -1
- package/build/Calendar/YearCalendar/YearCalendar.js +7 -0
- package/build/Calendar/YearCalendar/YearCalendar.js.map +1 -1
- package/build/Calendar/YearCalendar/YearCalendar.mjs +7 -0
- package/build/Calendar/YearCalendar/YearCalendar.mjs.map +1 -1
- package/build/DateLookup/DateLookup.js +19 -9
- package/build/DateLookup/DateLookup.js.map +1 -1
- package/build/DateLookup/DateLookup.mjs +19 -9
- package/build/DateLookup/DateLookup.mjs.map +1 -1
- package/build/Sticky/Sticky.js +0 -1
- package/build/Sticky/Sticky.js.map +1 -1
- package/build/Sticky/Sticky.mjs +0 -1
- package/build/Sticky/Sticky.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 +4 -0
- package/build/i18n/en.json.js +4 -0
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +4 -0
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/index.js +2 -2
- package/build/index.mjs +1 -1
- package/build/main.css +123 -48
- package/build/styles/Calendar/Calendar.css +112 -37
- package/build/styles/Calendar/TableLink/TableLink.css +115 -0
- package/build/styles/main.css +123 -48
- package/build/types/Calendar/Calendar.d.ts +16 -3
- package/build/types/Calendar/Calendar.d.ts.map +1 -1
- package/build/types/Calendar/Calendar.messages.d.ts +20 -0
- package/build/types/Calendar/Calendar.messages.d.ts.map +1 -1
- package/build/types/Calendar/Calendar.types.d.ts +32 -0
- package/build/types/Calendar/Calendar.types.d.ts.map +1 -0
- package/build/types/Calendar/DateHeader/DateHeader.d.ts +2 -0
- package/build/types/Calendar/DateHeader/DateHeader.d.ts.map +1 -1
- package/build/types/Calendar/DayCalendar/DayCalendar.d.ts +5 -1
- package/build/types/Calendar/DayCalendar/DayCalendar.d.ts.map +1 -1
- package/build/types/Calendar/DayCalendar/Table/DayCalendarTable.d.ts +4 -0
- package/build/types/Calendar/DayCalendar/Table/DayCalendarTable.d.ts.map +1 -1
- package/build/types/Calendar/MonthCalendar/MonthCalendar.d.ts +1 -0
- package/build/types/Calendar/MonthCalendar/MonthCalendar.d.ts.map +1 -1
- package/build/types/Calendar/MonthCalendar/Table/MonthCalendarTable.d.ts +2 -1
- package/build/types/Calendar/MonthCalendar/Table/MonthCalendarTable.d.ts.map +1 -1
- package/build/types/Calendar/{tableLink → TableLink}/TableLink.d.ts +3 -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/YearCalendar/Table/YearCalendarTable.d.ts +2 -1
- package/build/types/Calendar/YearCalendar/Table/YearCalendarTable.d.ts.map +1 -1
- package/build/types/Calendar/YearCalendar/YearCalendar.d.ts +1 -0
- package/build/types/Calendar/YearCalendar/YearCalendar.d.ts.map +1 -1
- 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 +23 -4
- 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/Sticky/Sticky.d.ts.map +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 +3 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts +8 -0
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Calendar/Calendar.css +112 -37
- package/src/Calendar/Calendar.disabledDates.test.tsx +518 -0
- package/src/Calendar/Calendar.less +5 -35
- package/src/Calendar/Calendar.messages.ts +21 -0
- package/src/Calendar/Calendar.test.tsx +217 -28
- package/src/Calendar/Calendar.tsx +136 -19
- package/src/Calendar/Calendar.types.ts +35 -0
- package/src/Calendar/DateHeader/DateHeader.tsx +6 -0
- package/src/Calendar/DayCalendar/DayCalendar.tsx +33 -1
- package/src/Calendar/DayCalendar/Table/DayCalendarTable.tsx +62 -28
- package/src/Calendar/MonthCalendar/MonthCalendar.tsx +8 -0
- package/src/Calendar/MonthCalendar/Table/MonthCalendarTable.tsx +15 -3
- package/src/Calendar/TableLink/TableLink.css +115 -0
- package/src/Calendar/TableLink/TableLink.less +68 -0
- package/src/Calendar/{tableLink → TableLink}/TableLink.tsx +29 -14
- package/src/Calendar/YearCalendar/Table/YearCalendarTable.tsx +15 -3
- package/src/Calendar/YearCalendar/YearCalendar.tsx +9 -0
- package/src/Calendar/_stories/Calendar.accessibility.docs.mdx +118 -0
- package/src/Calendar/_stories/Calendar.story.tsx +138 -4
- package/src/Calendar/index.ts +7 -0
- package/src/DateLookup/DateLookup.disabledDates.test.tsx +293 -0
- package/src/DateLookup/DateLookup.test.tsx +34 -37
- package/src/DateLookup/DateLookup.tsx +36 -13
- package/src/DateLookup/_stories/DateLookup.accessibility.docs.mdx +108 -0
- package/src/DateLookup/_stories/DateLookup.story.tsx +124 -2
- package/src/DateLookup/index.ts +6 -0
- package/src/Sticky/Sticky.test.tsx +0 -1
- package/src/Sticky/Sticky.tsx +0 -1
- 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 +4 -0
- package/src/index.ts +3 -2
- package/src/main.css +123 -48
- 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/styles/Sticky/Sticky.css +0 -4
- package/build/types/Calendar/tableLink/TableLink.d.ts.map +0 -1
- package/build/types/Calendar/tableLink/index.d.ts.map +0 -1
- package/src/Sticky/Sticky.css +0 -4
- package/src/Sticky/Sticky.less +0 -6
- package/src/Sticky/_stories/Sticky.test.story.tsx +0 -177
- /package/build/types/Calendar/{tableLink → TableLink}/index.d.ts +0 -0
- /package/src/Calendar/{tableLink → TableLink}/index.ts +0 -0
|
@@ -110,24 +110,13 @@ describe('DateLookup', () => {
|
|
|
110
110
|
['{ArrowRight}', +1],
|
|
111
111
|
['{ArrowUp}', -7],
|
|
112
112
|
['{ArrowDown}', +7],
|
|
113
|
-
])("handles '%s' to step %d day(s)", async (text: string
|
|
113
|
+
])("handles '%s' to step %d day(s) without changing value", async (text: string) => {
|
|
114
114
|
const handleChange = jest.fn();
|
|
115
115
|
await setupAndOpenWithMouse({ onChange: handleChange });
|
|
116
116
|
|
|
117
|
-
expect(handleChange).not.toHaveBeenCalled();
|
|
118
|
-
|
|
119
117
|
await user.keyboard(text);
|
|
120
118
|
|
|
121
|
-
|
|
122
|
-
value.setDate(initialValue.getDate() + step);
|
|
123
|
-
expect(handleChange).toHaveBeenCalledWith(value);
|
|
124
|
-
|
|
125
|
-
await user.keyboard('{Escape}');
|
|
126
|
-
await act(async () => {
|
|
127
|
-
await jest.runOnlyPendingTimersAsync();
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
expect(handleChange).toHaveBeenCalledWith(initialValue);
|
|
119
|
+
expect(handleChange).not.toHaveBeenCalled();
|
|
131
120
|
});
|
|
132
121
|
});
|
|
133
122
|
|
|
@@ -137,7 +126,7 @@ describe('DateLookup', () => {
|
|
|
137
126
|
['{ArrowRight}', +1],
|
|
138
127
|
['{ArrowUp}', -4],
|
|
139
128
|
['{ArrowDown}', +4],
|
|
140
|
-
])("handles '%s' to step %d year(s)", async (text: string
|
|
129
|
+
])("handles '%s' to step %d year(s) without changing value", async (text: string) => {
|
|
141
130
|
const handleChange = jest.fn();
|
|
142
131
|
await setupAndOpenWithMouse({ onChange: handleChange });
|
|
143
132
|
|
|
@@ -146,20 +135,9 @@ describe('DateLookup', () => {
|
|
|
146
135
|
await jest.runOnlyPendingTimersAsync();
|
|
147
136
|
});
|
|
148
137
|
|
|
149
|
-
expect(handleChange).not.toHaveBeenCalled();
|
|
150
|
-
|
|
151
138
|
await user.keyboard(text);
|
|
152
139
|
|
|
153
|
-
|
|
154
|
-
value.setFullYear(initialValue.getFullYear() + step);
|
|
155
|
-
expect(handleChange).toHaveBeenCalledWith(value);
|
|
156
|
-
|
|
157
|
-
await user.keyboard('{Escape}');
|
|
158
|
-
await act(async () => {
|
|
159
|
-
await jest.runOnlyPendingTimersAsync();
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
expect(handleChange).toHaveBeenCalledWith(initialValue);
|
|
140
|
+
expect(handleChange).not.toHaveBeenCalled();
|
|
163
141
|
});
|
|
164
142
|
});
|
|
165
143
|
|
|
@@ -169,7 +147,7 @@ describe('DateLookup', () => {
|
|
|
169
147
|
['{ArrowRight}', +1],
|
|
170
148
|
['{ArrowUp}', -4],
|
|
171
149
|
['{ArrowDown}', +4],
|
|
172
|
-
])("handles '%s' to step %d month(s)", async (text: string
|
|
150
|
+
])("handles '%s' to step %d month(s) without changing value", async (text: string) => {
|
|
173
151
|
const handleChange = jest.fn();
|
|
174
152
|
await setupAndOpenWithMouse({ onChange: handleChange });
|
|
175
153
|
|
|
@@ -182,20 +160,39 @@ describe('DateLookup', () => {
|
|
|
182
160
|
await jest.runOnlyPendingTimersAsync();
|
|
183
161
|
});
|
|
184
162
|
|
|
163
|
+
await user.keyboard(text);
|
|
164
|
+
|
|
185
165
|
expect(handleChange).not.toHaveBeenCalled();
|
|
166
|
+
});
|
|
167
|
+
});
|
|
186
168
|
|
|
187
|
-
|
|
169
|
+
describe('focus vs selection separation', () => {
|
|
170
|
+
it('does not call onChange during arrow key navigation', async () => {
|
|
171
|
+
const handleChange = jest.fn();
|
|
172
|
+
render(<DateLookup value={new Date(2020, 0, 15)} onChange={handleChange} />);
|
|
188
173
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
expect(handleChange).
|
|
174
|
+
// Open the panel
|
|
175
|
+
await user.click(screen.getByRole('button'));
|
|
176
|
+
expect(handleChange).not.toHaveBeenCalled();
|
|
192
177
|
|
|
193
|
-
await user.keyboard('{
|
|
194
|
-
await act(async () => {
|
|
195
|
-
await jest.runOnlyPendingTimersAsync();
|
|
196
|
-
});
|
|
178
|
+
await user.keyboard('{ArrowRight}');
|
|
197
179
|
|
|
198
|
-
expect(handleChange).
|
|
180
|
+
expect(handleChange).not.toHaveBeenCalled();
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('calls onChange when Enter is pressed on a focused date', async () => {
|
|
184
|
+
const handleChange = jest.fn();
|
|
185
|
+
render(<DateLookup value={new Date(2020, 0, 15)} onChange={handleChange} />);
|
|
186
|
+
|
|
187
|
+
// Open the panel
|
|
188
|
+
await user.click(screen.getByRole('button'));
|
|
189
|
+
expect(handleChange).not.toHaveBeenCalled();
|
|
190
|
+
|
|
191
|
+
// Arrow to next date then confirm with Enter
|
|
192
|
+
await user.keyboard('{ArrowRight}');
|
|
193
|
+
await user.keyboard('{Enter}');
|
|
194
|
+
|
|
195
|
+
expect(handleChange).toHaveBeenCalledWith(new Date(2020, 0, 16));
|
|
199
196
|
});
|
|
200
197
|
});
|
|
201
198
|
});
|
|
@@ -229,7 +226,7 @@ describe('DateLookup (events)', () => {
|
|
|
229
226
|
const today = new Date();
|
|
230
227
|
const todayDateLabel = today.toLocaleDateString('en-GB', {
|
|
231
228
|
day: 'numeric',
|
|
232
|
-
month: '
|
|
229
|
+
month: 'long',
|
|
233
230
|
year: 'numeric',
|
|
234
231
|
});
|
|
235
232
|
const expectedHeaderText = today.toLocaleDateString('en-GB', {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { clsx } from 'clsx';
|
|
2
2
|
import { createRef, PureComponent, KeyboardEvent } from 'react';
|
|
3
3
|
import Calendar from '../Calendar';
|
|
4
|
+
import type { DateChangeMeta, DisabledRules, OnDateSelectParams } from '../Calendar/Calendar.types';
|
|
4
5
|
import {
|
|
5
6
|
Size,
|
|
6
7
|
MonthFormat,
|
|
@@ -15,19 +16,37 @@ import { OverlayIdProvider } from '../Provider/overlay/OverlayIdProvider';
|
|
|
15
16
|
import DateTrigger from './DateTrigger';
|
|
16
17
|
|
|
17
18
|
export interface DateLookupProps {
|
|
18
|
-
|
|
19
|
+
/** The currently selected date, or `null` for no selection. */
|
|
19
20
|
value: Date | null;
|
|
21
|
+
/** Called when an enabled date is confirmed. Receives `null` when the value is cleared. */
|
|
22
|
+
onChange: (date: Date | null) => void;
|
|
23
|
+
/** HTML `id` applied to the trigger button, used for label association. */
|
|
24
|
+
id?: string;
|
|
25
|
+
/** Earliest selectable date (inclusive). Dates before this are interactive but not selectable, and show a boundary prompt. */
|
|
20
26
|
min?: Date | null;
|
|
27
|
+
/** Latest selectable date (inclusive). Dates after this are interactive but not selectable, and show a boundary prompt. */
|
|
21
28
|
max?: Date | null;
|
|
29
|
+
/** Size of the trigger input. Defaults to `'md'`. */
|
|
22
30
|
size?: SizeSmall | SizeMedium | SizeLarge;
|
|
23
|
-
|
|
31
|
+
/** Label text rendered above the trigger input. */
|
|
24
32
|
label?: string;
|
|
33
|
+
/** ID of an external element that labels the trigger, for use inside custom label contexts. */
|
|
25
34
|
'aria-labelledby'?: string;
|
|
35
|
+
/** Placeholder text shown in the trigger when no date is selected. */
|
|
36
|
+
placeholder?: string;
|
|
37
|
+
/** Month name format in the calendar header. Defaults to `'long'` (e.g. "January"). */
|
|
26
38
|
monthFormat?: `${MonthFormat}`;
|
|
39
|
+
/** When `true`, the trigger and calendar are non-interactive. */
|
|
27
40
|
disabled?: boolean;
|
|
41
|
+
/** When `true`, a clear button is shown in the trigger to reset the value to `null`. */
|
|
28
42
|
clearable?: boolean;
|
|
29
|
-
|
|
43
|
+
/** Rules for disabling specific weekdays, individual dates, or date ranges. The required `reason` is shown in an inline prompt and linked to disabled cells via `aria-describedby` for screen reader accessibility. */
|
|
44
|
+
disabledRules?: DisabledRules;
|
|
45
|
+
/** Called whenever any date is focused or clicked, including disabled and out-of-range dates. `isEnabled` is `false` when the date is not selectable. */
|
|
46
|
+
onDateSelect?: (params: OnDateSelectParams) => void;
|
|
47
|
+
/** Called when the calendar panel opens. */
|
|
30
48
|
onFocus?: () => void;
|
|
49
|
+
/** Called when the calendar panel closes. */
|
|
31
50
|
onBlur?: () => void;
|
|
32
51
|
}
|
|
33
52
|
|
|
@@ -128,7 +147,14 @@ class DateLookup extends PureComponent<DateLookupPropsWithInputAttributes, DateL
|
|
|
128
147
|
}
|
|
129
148
|
};
|
|
130
149
|
|
|
131
|
-
handleDateChange = (date: Date | null) => {
|
|
150
|
+
handleDateChange = (date: Date | null, meta: DateChangeMeta) => {
|
|
151
|
+
const { onDateSelect } = this.props;
|
|
152
|
+
if (date && onDateSelect) {
|
|
153
|
+
onDateSelect({ date, isEnabled: meta.isEnabled });
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
handleDateSelect = (date: Date) => {
|
|
132
158
|
this.setState(
|
|
133
159
|
(state) => {
|
|
134
160
|
const originalDate = state.originalDate ?? this.props.value;
|
|
@@ -136,18 +162,14 @@ class DateLookup extends PureComponent<DateLookupPropsWithInputAttributes, DateL
|
|
|
136
162
|
},
|
|
137
163
|
() => {
|
|
138
164
|
this.props.onChange(date);
|
|
165
|
+
this.close();
|
|
166
|
+
this.focusOn('.btn');
|
|
139
167
|
},
|
|
140
168
|
);
|
|
141
169
|
};
|
|
142
170
|
|
|
143
|
-
handleDateSelect = (date: Date) => {
|
|
144
|
-
this.props.onChange(date);
|
|
145
|
-
this.close();
|
|
146
|
-
this.focusOn('.btn');
|
|
147
|
-
};
|
|
148
|
-
|
|
149
171
|
getCalendar = () => {
|
|
150
|
-
const { value, min, max, monthFormat, placeholder } = this.props;
|
|
172
|
+
const { value, min, max, monthFormat, placeholder, disabledRules } = this.props;
|
|
151
173
|
return (
|
|
152
174
|
<div className="p-a-1">
|
|
153
175
|
<Calendar
|
|
@@ -156,8 +178,9 @@ class DateLookup extends PureComponent<DateLookupPropsWithInputAttributes, DateL
|
|
|
156
178
|
max={max}
|
|
157
179
|
monthFormat={monthFormat}
|
|
158
180
|
placeholder={placeholder}
|
|
159
|
-
|
|
160
|
-
|
|
181
|
+
disabledRules={disabledRules}
|
|
182
|
+
onDateFocus={this.handleDateChange}
|
|
183
|
+
onChange={this.handleDateSelect}
|
|
161
184
|
/>
|
|
162
185
|
</div>
|
|
163
186
|
);
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Meta } from '@storybook/addon-docs/blocks';
|
|
2
|
+
|
|
3
|
+
<Meta title="Forms/DateLookup/Accessibility" />
|
|
4
|
+
|
|
5
|
+
# Accessibility
|
|
6
|
+
|
|
7
|
+
DateLookup wraps the Calendar component inside a dropdown panel. It provides full keyboard accessibility for opening, navigating, selecting, and dismissing dates.
|
|
8
|
+
|
|
9
|
+
## Keyboard Support
|
|
10
|
+
|
|
11
|
+
<table>
|
|
12
|
+
<thead>
|
|
13
|
+
<tr>
|
|
14
|
+
<th>Key</th>
|
|
15
|
+
<th>Context</th>
|
|
16
|
+
<th>Action</th>
|
|
17
|
+
</tr>
|
|
18
|
+
</thead>
|
|
19
|
+
<tbody>
|
|
20
|
+
<tr>
|
|
21
|
+
<td>
|
|
22
|
+
<code>ArrowLeft/Right/Up/Down</code>
|
|
23
|
+
</td>
|
|
24
|
+
<td>Trigger focused, panel closed</td>
|
|
25
|
+
<td>Opens the panel</td>
|
|
26
|
+
</tr>
|
|
27
|
+
<tr>
|
|
28
|
+
<td>
|
|
29
|
+
<code>ArrowLeft/Right/Up/Down</code>
|
|
30
|
+
</td>
|
|
31
|
+
<td>Panel open</td>
|
|
32
|
+
<td>Navigates between dates (see Calendar)</td>
|
|
33
|
+
</tr>
|
|
34
|
+
<tr>
|
|
35
|
+
<td>
|
|
36
|
+
<code>Enter</code> / <code>Space</code>
|
|
37
|
+
</td>
|
|
38
|
+
<td>Panel open, enabled date focused</td>
|
|
39
|
+
<td>Selects date, closes panel</td>
|
|
40
|
+
</tr>
|
|
41
|
+
<tr>
|
|
42
|
+
<td>
|
|
43
|
+
<code>Enter</code> / <code>Space</code>
|
|
44
|
+
</td>
|
|
45
|
+
<td>Panel open, disabled date focused</td>
|
|
46
|
+
<td>No action (panel stays open)</td>
|
|
47
|
+
</tr>
|
|
48
|
+
<tr>
|
|
49
|
+
<td>
|
|
50
|
+
<code>Escape</code>
|
|
51
|
+
</td>
|
|
52
|
+
<td>Panel open</td>
|
|
53
|
+
<td>Reverts to original value, closes panel</td>
|
|
54
|
+
</tr>
|
|
55
|
+
</tbody>
|
|
56
|
+
</table>
|
|
57
|
+
|
|
58
|
+
<br />
|
|
59
|
+
|
|
60
|
+
### Click Behaviour
|
|
61
|
+
|
|
62
|
+
- **Clicking an enabled date**: selects it, closes the panel, fires `onChange`
|
|
63
|
+
- **Clicking a disabled date**: does not select, panel stays open, focus remains in the calendar grid
|
|
64
|
+
|
|
65
|
+
## Screen Reader Announcements
|
|
66
|
+
|
|
67
|
+
DateLookup relies on the Calendar's built-in accessibility features for date announcements. See [Calendar
|
|
68
|
+
Accessibility](?path=/docs/forms-calendar-accessibility--docs) for details on how dates are labelled and described.
|
|
69
|
+
|
|
70
|
+
### Trigger Button
|
|
71
|
+
|
|
72
|
+
The trigger button announces the currently selected date (or placeholder text when no date is selected). It uses `aria-controls` to associate with the panel.
|
|
73
|
+
|
|
74
|
+
### Panel
|
|
75
|
+
|
|
76
|
+
The dropdown panel is rendered with `role="dialog"` and is connected to the trigger via `aria-controls`. When opened, focus moves into the calendar grid.
|
|
77
|
+
|
|
78
|
+
## Disabled Dates (via `disabledRules`)
|
|
79
|
+
|
|
80
|
+
When `disabledRules` is provided, disabled dates remain focusable and keyboard-navigable:
|
|
81
|
+
|
|
82
|
+
- `aria-disabled="true"` marks the cell as unavailable
|
|
83
|
+
- "not available" is appended to the aria-label
|
|
84
|
+
- `aria-describedby` links to the InlinePrompt reason text
|
|
85
|
+
- Keyboard navigation reaches disabled dates (they are not skipped)
|
|
86
|
+
- Clicking or pressing Enter on a disabled date does **not** close the panel
|
|
87
|
+
|
|
88
|
+
## Out-of-Range Dates (via `min`/`max`)
|
|
89
|
+
|
|
90
|
+
Dates outside `min`/`max` boundaries use the native HTML `disabled` attribute and are **non-interactive** — they cannot receive focus and are not reachable via keyboard. Arrow key navigation clamps at the boundary.
|
|
91
|
+
|
|
92
|
+
This distinction is intentional: `min`/`max` defines a hard boundary, while `disabledRules` marks dates that exist but are unavailable (users can discover them and understand why via the InlinePrompt).
|
|
93
|
+
|
|
94
|
+
### InlinePrompt
|
|
95
|
+
|
|
96
|
+
An InlinePrompt renders below the day grid inside the panel when the visible month contains disabled dates. It displays the configured `disabledRules.reason` text.
|
|
97
|
+
|
|
98
|
+
The prompt is linked to disabled cells via `aria-describedby`, so screen readers announce the reason when a disabled
|
|
99
|
+
date receives focus. See [Calendar Accessibility](?path=/docs/forms-calendar-accessibility--docs) for full details on
|
|
100
|
+
the prompt's announcement behaviour.
|
|
101
|
+
|
|
102
|
+
## Consumer Callbacks
|
|
103
|
+
|
|
104
|
+
The `onDateSelect` callback fires with `{ date, isEnabled }` whenever the user navigates to or clicks on any date. Consumers can use this to:
|
|
105
|
+
|
|
106
|
+
- Display a custom message explaining why a specific date is disabled
|
|
107
|
+
- Track which dates users attempt to select
|
|
108
|
+
- Provide alternative actions for disabled dates
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
2
|
import { StoryObj } from '@storybook/react-webpack5';
|
|
3
|
+
import { fn } from 'storybook/test';
|
|
4
|
+
import { action } from 'storybook/actions';
|
|
3
5
|
import {
|
|
4
6
|
createSandboxStory,
|
|
5
7
|
globalScope,
|
|
6
8
|
} from '../../../.storybook/components/sandbox/SandboxEditor';
|
|
9
|
+
import { storySourceWithoutNoise } from '../../../.storybook/helpers';
|
|
7
10
|
import { Size } from '../../common';
|
|
8
|
-
import DateLookup, { type DateLookupProps } from '..';
|
|
9
11
|
import Field from '../../Field';
|
|
12
|
+
import DateLookup, { type DateLookupProps } from '..';
|
|
10
13
|
|
|
11
14
|
export default {
|
|
12
15
|
component: DateLookup,
|
|
13
16
|
title: 'Forms/DateLookup',
|
|
17
|
+
args: {
|
|
18
|
+
onFocus: fn(),
|
|
19
|
+
onBlur: fn(),
|
|
20
|
+
},
|
|
14
21
|
argTypes: {
|
|
15
22
|
size: { control: 'select', options: [Size.SMALL, Size.MEDIUM, Size.LARGE] },
|
|
16
23
|
disabled: { control: 'boolean' },
|
|
@@ -34,7 +41,7 @@ thePast.setUTCDate(epoch.getUTCDate() - 10);
|
|
|
34
41
|
|
|
35
42
|
export const Sandbox = createSandboxStory({
|
|
36
43
|
code: `const App = () => {
|
|
37
|
-
const [value, setValue] = React.useState(new Date(
|
|
44
|
+
const [value, setValue] = React.useState(new Date(2024, 5, 14));
|
|
38
45
|
|
|
39
46
|
return (
|
|
40
47
|
<DateLookup
|
|
@@ -44,6 +51,11 @@ export const Sandbox = createSandboxStory({
|
|
|
44
51
|
placeholder="Choose date"
|
|
45
52
|
clearable
|
|
46
53
|
value={value}
|
|
54
|
+
disabledRules={{
|
|
55
|
+
weekdays: ['sat', 'sun'],
|
|
56
|
+
dates: [new Date(2024, 5, 19)],
|
|
57
|
+
reason: 'Weekends and holidays are unavailable.',
|
|
58
|
+
}}
|
|
47
59
|
onChange={(date) => setValue(date)}
|
|
48
60
|
/>
|
|
49
61
|
);
|
|
@@ -120,3 +132,113 @@ export const RightAligned: Story = {
|
|
|
120
132
|
);
|
|
121
133
|
},
|
|
122
134
|
};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Use `disabledRules` to disable specific weekdays, individual dates, or date ranges.
|
|
138
|
+
* Disabled dates remain focusable and keyboard-navigable — clicking or focusing one
|
|
139
|
+
* keeps the panel open, fires `onDateSelect` with `isEnabled: false`, and shows a
|
|
140
|
+
* negative inline prompt with the `reason` text. `min`/`max` out-of-range dates show
|
|
141
|
+
* a built-in boundary prompt (e.g. "Please select a date between 9 December 2024 and
|
|
142
|
+
* 22 January 2025.").
|
|
143
|
+
*
|
|
144
|
+
* The `reason` field is **required for accessibility**: it renders as an InlinePrompt
|
|
145
|
+
* below the grid and is linked to every disabled cell via `aria-describedby`, so screen
|
|
146
|
+
* reader users understand why a date is unavailable. For per-date reason customisation
|
|
147
|
+
* see [DisabledDatesWithDynamicReason](#disabled-dates-with-dynamic-reason).
|
|
148
|
+
*/
|
|
149
|
+
export const DisabledDates: Story = storySourceWithoutNoise({
|
|
150
|
+
args: {
|
|
151
|
+
size: Size.MEDIUM,
|
|
152
|
+
label: 'Select a date',
|
|
153
|
+
placeholder: 'Choose date',
|
|
154
|
+
monthFormat: 'long',
|
|
155
|
+
},
|
|
156
|
+
render: function Render(args: DateLookupProps) {
|
|
157
|
+
const min = new Date(2024, 11, 9);
|
|
158
|
+
const max = new Date(2025, 0, 22);
|
|
159
|
+
const bankHolidays = [new Date(2024, 11, 25), new Date(2024, 11, 26), new Date(2025, 0, 1)];
|
|
160
|
+
const [value, setValue] = useState<Date | null>(null);
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<DateLookup
|
|
164
|
+
{...args}
|
|
165
|
+
min={min}
|
|
166
|
+
max={max}
|
|
167
|
+
value={value}
|
|
168
|
+
disabledRules={{
|
|
169
|
+
weekdays: ['sat', 'sun'],
|
|
170
|
+
dates: bankHolidays,
|
|
171
|
+
ranges: [{ start: new Date(2024, 11, 23), end: new Date(2024, 11, 24) }],
|
|
172
|
+
reason: 'Some dates are unavailable for this service.',
|
|
173
|
+
}}
|
|
174
|
+
onChange={(date) => {
|
|
175
|
+
action('onChange')(date);
|
|
176
|
+
setValue(date);
|
|
177
|
+
}}
|
|
178
|
+
onDateSelect={({ date, isEnabled }) => {
|
|
179
|
+
action('onDateSelect')({ date, isEnabled });
|
|
180
|
+
}}
|
|
181
|
+
/>
|
|
182
|
+
);
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* When different disabled dates warrant different explanations, drive the `reason`
|
|
188
|
+
* dynamically from `onDateSelect`. The `isEnabled` flag tells you whether the focused
|
|
189
|
+
* date is selectable; from there you can look up the specific reason and update state.
|
|
190
|
+
*
|
|
191
|
+
* `min`/`max` out-of-range dates are handled automatically — the component shows a
|
|
192
|
+
* built-in prompt with the boundary dates, so `determineReason` only needs to cover
|
|
193
|
+
* rule-disabled dates.
|
|
194
|
+
*/
|
|
195
|
+
export const DisabledDatesWithDynamicReason: Story = storySourceWithoutNoise({
|
|
196
|
+
args: {
|
|
197
|
+
size: Size.MEDIUM,
|
|
198
|
+
label: 'Select a date',
|
|
199
|
+
placeholder: 'Choose date',
|
|
200
|
+
monthFormat: 'long',
|
|
201
|
+
},
|
|
202
|
+
render: function Render(args: DateLookupProps) {
|
|
203
|
+
const DEFAULT_REASON = 'Some dates are unavailable for this service.';
|
|
204
|
+
const min = new Date(2024, 11, 9);
|
|
205
|
+
const max = new Date(2025, 0, 22);
|
|
206
|
+
const bankHolidays = [new Date(2024, 11, 25), new Date(2024, 11, 26), new Date(2025, 0, 1)];
|
|
207
|
+
const [value, setValue] = useState<Date | null>(null);
|
|
208
|
+
const [reason, setReason] = useState(DEFAULT_REASON);
|
|
209
|
+
|
|
210
|
+
function determineReason(date: Date, isEnabled: boolean): string {
|
|
211
|
+
if (isEnabled) return DEFAULT_REASON;
|
|
212
|
+
if (bankHolidays.some((holiday) => holiday.toDateString() === date.toDateString())) {
|
|
213
|
+
return 'This date is a bank holiday.';
|
|
214
|
+
}
|
|
215
|
+
if (date.getDay() === 0 || date.getDay() === 6) {
|
|
216
|
+
return 'We do not operate on weekends.';
|
|
217
|
+
}
|
|
218
|
+
return 'This date is unavailable due to scheduled maintenance.';
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return (
|
|
222
|
+
<DateLookup
|
|
223
|
+
{...args}
|
|
224
|
+
min={min}
|
|
225
|
+
max={max}
|
|
226
|
+
value={value}
|
|
227
|
+
disabledRules={{
|
|
228
|
+
weekdays: ['sat', 'sun'],
|
|
229
|
+
dates: bankHolidays,
|
|
230
|
+
ranges: [{ start: new Date(2024, 11, 23), end: new Date(2024, 11, 24) }],
|
|
231
|
+
reason,
|
|
232
|
+
}}
|
|
233
|
+
onChange={(date) => {
|
|
234
|
+
action('onChange')(date);
|
|
235
|
+
setValue(date);
|
|
236
|
+
}}
|
|
237
|
+
onDateSelect={({ date, isEnabled }) => {
|
|
238
|
+
action('onDateSelect')({ date, isEnabled });
|
|
239
|
+
setReason(determineReason(date, isEnabled));
|
|
240
|
+
}}
|
|
241
|
+
/>
|
|
242
|
+
);
|
|
243
|
+
},
|
|
244
|
+
});
|
package/src/DateLookup/index.ts
CHANGED
|
@@ -21,7 +21,6 @@ describe('Sticky', () => {
|
|
|
21
21
|
|
|
22
22
|
test('renders with default props', () => {
|
|
23
23
|
expect(screen.getByTestId('test-sticky-panel')).toBeVisible();
|
|
24
|
-
expect(screen.getByTestId('test-sticky-panel')).toHaveClass('np-sticky');
|
|
25
24
|
expect(screen.getByTestId('test-sticky-panel')).toHaveClass('sliding-panel--open-bottom');
|
|
26
25
|
expect(screen.getByText('Test Content')).toBeInTheDocument();
|
|
27
26
|
});
|
package/src/Sticky/Sticky.tsx
CHANGED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { hasDisabledDatesInMonth } from './hasDisabledDatesInMonth';
|
|
2
|
+
import type { DisabledRules } from '../../../Calendar/Calendar.types';
|
|
3
|
+
|
|
4
|
+
describe('hasDisabledDatesInMonth', () => {
|
|
5
|
+
describe('weekdays', () => {
|
|
6
|
+
it('returns true when weekday rules exist (every month has all weekdays)', () => {
|
|
7
|
+
const rules: DisabledRules = { weekdays: ['sat', 'sun'], reason: 'Closed' };
|
|
8
|
+
expect(hasDisabledDatesInMonth(6, 2024, rules)).toBe(true);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('returns true for any month when weekday rules exist', () => {
|
|
12
|
+
const rules: DisabledRules = { weekdays: ['mon'], reason: 'Closed' };
|
|
13
|
+
expect(hasDisabledDatesInMonth(0, 2024, rules)).toBe(true);
|
|
14
|
+
expect(hasDisabledDatesInMonth(11, 2024, rules)).toBe(true);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('returns false when weekdays array is empty', () => {
|
|
18
|
+
const rules: DisabledRules = { weekdays: [], reason: 'None' };
|
|
19
|
+
expect(hasDisabledDatesInMonth(6, 2024, rules)).toBe(false);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe('specific dates', () => {
|
|
24
|
+
const rules: DisabledRules = {
|
|
25
|
+
dates: [new Date(2024, 6, 11), new Date(2024, 6, 25), new Date(2025, 0, 1)],
|
|
26
|
+
reason: 'Bank holidays',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
it('returns true when month contains a disabled date', () => {
|
|
30
|
+
expect(hasDisabledDatesInMonth(6, 2024, rules)).toBe(true);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('returns false when month has no disabled dates', () => {
|
|
34
|
+
expect(hasDisabledDatesInMonth(5, 2024, rules)).toBe(false);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('returns true for another year with disabled date', () => {
|
|
38
|
+
expect(hasDisabledDatesInMonth(0, 2025, rules)).toBe(true);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe('ranges', () => {
|
|
43
|
+
const rules: DisabledRules = {
|
|
44
|
+
ranges: [{ start: new Date(2024, 2, 29), end: new Date(2024, 3, 3) }],
|
|
45
|
+
reason: 'Maintenance',
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
it('returns true when range starts in the month', () => {
|
|
49
|
+
expect(hasDisabledDatesInMonth(2, 2024, rules)).toBe(true);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('returns true when range ends in the month', () => {
|
|
53
|
+
expect(hasDisabledDatesInMonth(3, 2024, rules)).toBe(true);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('returns true when range spans the entire month', () => {
|
|
57
|
+
const spanRules: DisabledRules = {
|
|
58
|
+
ranges: [{ start: new Date(2024, 0, 1), end: new Date(2024, 11, 31) }],
|
|
59
|
+
reason: 'Year-long',
|
|
60
|
+
};
|
|
61
|
+
expect(hasDisabledDatesInMonth(6, 2024, spanRules)).toBe(true);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('returns false when range does not overlap the month', () => {
|
|
65
|
+
expect(hasDisabledDatesInMonth(4, 2024, rules)).toBe(false);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe('min/max constraints', () => {
|
|
70
|
+
it('returns false when all disabled dates in month are outside min/max', () => {
|
|
71
|
+
const rules: DisabledRules = {
|
|
72
|
+
dates: [new Date(2024, 6, 1), new Date(2024, 6, 2)],
|
|
73
|
+
reason: 'Early',
|
|
74
|
+
};
|
|
75
|
+
const min = new Date(2024, 6, 10);
|
|
76
|
+
const max = new Date(2024, 6, 31);
|
|
77
|
+
expect(hasDisabledDatesInMonth(6, 2024, rules, min, max)).toBe(false);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('returns true when weekdays exist regardless of min/max', () => {
|
|
81
|
+
const rules: DisabledRules = { weekdays: ['sat'], reason: 'Closed' };
|
|
82
|
+
const min = new Date(2024, 6, 10);
|
|
83
|
+
const max = new Date(2024, 6, 20);
|
|
84
|
+
expect(hasDisabledDatesInMonth(6, 2024, rules, min, max)).toBe(true);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
describe('no rules', () => {
|
|
89
|
+
it('returns false when disabledRules is undefined', () => {
|
|
90
|
+
expect(hasDisabledDatesInMonth(6, 2024, undefined)).toBe(false);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('returns false when only reason is provided', () => {
|
|
94
|
+
const rules: DisabledRules = { reason: 'Reason only' };
|
|
95
|
+
expect(hasDisabledDatesInMonth(6, 2024, rules)).toBe(false);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
});
|
|
@@ -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';
|