@transferwise/components 46.156.0 → 46.157.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/Calendar/Calendar.constants.js +10 -0
- package/build/Calendar/Calendar.constants.js.map +1 -0
- package/build/Calendar/Calendar.constants.mjs +8 -0
- package/build/Calendar/Calendar.constants.mjs.map +1 -0
- package/build/Calendar/Calendar.js +121 -17
- 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 +122 -18
- 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 +20 -2
- package/build/Calendar/DayCalendar/DayCalendar.js.map +1 -1
- package/build/Calendar/DayCalendar/DayCalendar.mjs +20 -2
- package/build/Calendar/DayCalendar/DayCalendar.mjs.map +1 -1
- package/build/Calendar/DayCalendar/Table/DayCalendarTable.js +60 -19
- package/build/Calendar/DayCalendar/Table/DayCalendarTable.js.map +1 -1
- package/build/Calendar/DayCalendar/Table/DayCalendarTable.mjs +60 -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.js +95 -0
- package/build/Calendar/TableLink/TableLink.js.map +1 -0
- package/build/Calendar/TableLink/TableLink.mjs +91 -0
- 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/Calendar/_helpers/clampToDayViewBoundary/clampToDayViewBoundary.js +24 -0
- package/build/Calendar/_helpers/clampToDayViewBoundary/clampToDayViewBoundary.js.map +1 -0
- package/build/Calendar/_helpers/clampToDayViewBoundary/clampToDayViewBoundary.mjs +22 -0
- package/build/Calendar/_helpers/clampToDayViewBoundary/clampToDayViewBoundary.mjs.map +1 -0
- package/build/Calendar/_helpers/hasDisabledDatesInMonth/hasDisabledDatesInMonth.js +33 -0
- package/build/Calendar/_helpers/hasDisabledDatesInMonth/hasDisabledDatesInMonth.js.map +1 -0
- package/build/Calendar/_helpers/hasDisabledDatesInMonth/hasDisabledDatesInMonth.mjs +31 -0
- package/build/Calendar/_helpers/hasDisabledDatesInMonth/hasDisabledDatesInMonth.mjs.map +1 -0
- package/build/Calendar/_helpers/isDateDisabled/isDateDisabled.js +40 -0
- package/build/Calendar/_helpers/isDateDisabled/isDateDisabled.js.map +1 -0
- package/build/Calendar/_helpers/isDateDisabled/isDateDisabled.mjs +38 -0
- package/build/Calendar/_helpers/isDateDisabled/isDateDisabled.mjs.map +1 -0
- package/build/DateLookup/DateLookup.js +20 -9
- package/build/DateLookup/DateLookup.js.map +1 -1
- package/build/DateLookup/DateLookup.mjs +20 -9
- package/build/DateLookup/DateLookup.mjs.map +1 -1
- package/build/ExpressiveMoneyInput/CurrencySelector/CurrencySelector.js +3 -5
- package/build/ExpressiveMoneyInput/CurrencySelector/CurrencySelector.js.map +1 -1
- package/build/ExpressiveMoneyInput/CurrencySelector/CurrencySelector.mjs +3 -5
- package/build/ExpressiveMoneyInput/CurrencySelector/CurrencySelector.mjs.map +1 -1
- package/build/Inputs/SelectInput/TriggerButton/SelectInputTriggerButton.js.map +1 -1
- package/build/Inputs/SelectInput/TriggerButton/SelectInputTriggerButton.mjs.map +1 -1
- package/build/Typeahead/Typeahead.js +53 -27
- package/build/Typeahead/Typeahead.js.map +1 -1
- package/build/Typeahead/Typeahead.messages.js +3 -0
- package/build/Typeahead/Typeahead.messages.js.map +1 -1
- package/build/Typeahead/Typeahead.messages.mjs +3 -0
- package/build/Typeahead/Typeahead.messages.mjs.map +1 -1
- package/build/Typeahead/Typeahead.mjs +53 -27
- package/build/Typeahead/Typeahead.mjs.map +1 -1
- package/build/Typeahead/TypeaheadInput/TypeaheadInput.js +2 -2
- package/build/Typeahead/TypeaheadInput/TypeaheadInput.js.map +1 -1
- package/build/Typeahead/TypeaheadInput/TypeaheadInput.mjs +2 -2
- package/build/Typeahead/TypeaheadInput/TypeaheadInput.mjs.map +1 -1
- package/build/Typeahead/TypeaheadOption/TypeaheadOption.js +3 -1
- package/build/Typeahead/TypeaheadOption/TypeaheadOption.js.map +1 -1
- package/build/Typeahead/TypeaheadOption/TypeaheadOption.mjs +3 -1
- package/build/Typeahead/TypeaheadOption/TypeaheadOption.mjs.map +1 -1
- package/build/i18n/en.json +5 -0
- package/build/i18n/en.json.js +5 -0
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +5 -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 +147 -43
- package/build/styles/Calendar/Calendar.css +112 -37
- package/build/styles/Calendar/TableLink/TableLink.css +115 -0
- package/build/styles/Typeahead/Typeahead.css +14 -0
- package/build/styles/Typeahead/TypeaheadOption/TypeaheadOption.css +5 -0
- package/build/styles/main.css +147 -43
- package/build/types/Body/Body.d.ts +2 -2
- package/build/types/Calendar/Calendar.constants.d.ts +2 -0
- package/build/types/Calendar/Calendar.constants.d.ts.map +1 -0
- 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 +7 -1
- package/build/types/Calendar/DayCalendar/DayCalendar.d.ts.map +1 -1
- package/build/types/Calendar/DayCalendar/Table/DayCalendarTable.d.ts +6 -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 +5 -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/_helpers/clampToDayViewBoundary/clampToDayViewBoundary.d.ts +8 -0
- package/build/types/Calendar/_helpers/clampToDayViewBoundary/clampToDayViewBoundary.d.ts.map +1 -0
- package/build/types/Calendar/_helpers/hasDisabledDatesInMonth/hasDisabledDatesInMonth.d.ts +3 -0
- package/build/types/Calendar/_helpers/hasDisabledDatesInMonth/hasDisabledDatesInMonth.d.ts.map +1 -0
- package/build/types/Calendar/_helpers/index.d.ts +4 -0
- package/build/types/Calendar/_helpers/index.d.ts.map +1 -0
- package/build/types/Calendar/_helpers/isDateDisabled/isDateDisabled.d.ts +3 -0
- package/build/types/Calendar/_helpers/isDateDisabled/isDateDisabled.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 +24 -5
- 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/ExpressiveMoneyInput/CurrencySelector/CurrencySelector.d.ts +6 -4
- package/build/types/ExpressiveMoneyInput/CurrencySelector/CurrencySelector.d.ts.map +1 -1
- package/build/types/IconButton/IconButton.d.ts +1 -1
- package/build/types/Inputs/SelectInput/TriggerButton/SelectInputTriggerButton.d.ts +1 -1
- package/build/types/Inputs/SelectInput/TriggerButton/SelectInputTriggerButton.d.ts.map +1 -1
- package/build/types/MoneyInput/MoneyInput.d.ts +1 -1
- package/build/types/MoneyInput/MoneyInput.d.ts.map +1 -1
- package/build/types/Title/Title.d.ts +2 -2
- package/build/types/Typeahead/Typeahead.d.ts.map +1 -1
- package/build/types/Typeahead/Typeahead.messages.d.ts +5 -0
- package/build/types/Typeahead/Typeahead.messages.d.ts.map +1 -1
- package/build/types/Typeahead/TypeaheadInput/TypeaheadInput.d.ts.map +1 -1
- package/build/types/Typeahead/TypeaheadOption/TypeaheadOption.d.ts +1 -0
- package/build/types/Typeahead/TypeaheadOption/TypeaheadOption.d.ts.map +1 -1
- package/build/types/Upload/Steps/UploadImageStep/UploadImageStep.d.ts +1 -1
- package/build/types/UploadInput/UploadItem/UploadItemLink.d.ts +1 -1
- 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 +10 -0
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/Calendar/Calendar.constants.ts +5 -0
- package/src/Calendar/Calendar.css +112 -37
- package/src/Calendar/Calendar.disabledDates.test.tsx +610 -0
- package/src/Calendar/Calendar.less +5 -35
- package/src/Calendar/Calendar.messages.ts +21 -0
- package/src/Calendar/Calendar.test.tsx +342 -32
- package/src/Calendar/Calendar.tsx +169 -19
- package/src/Calendar/Calendar.types.ts +35 -0
- package/src/Calendar/DateHeader/DateHeader.tsx +6 -0
- package/src/Calendar/DayCalendar/DayCalendar.tsx +39 -1
- package/src/Calendar/DayCalendar/Table/DayCalendarTable.tsx +67 -27
- 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.tsx +117 -0
- package/src/Calendar/YearCalendar/Table/YearCalendarTable.tsx +15 -3
- package/src/Calendar/YearCalendar/YearCalendar.tsx +9 -0
- package/src/Calendar/_helpers/clampToDayViewBoundary/clampToDayViewBoundary.test.ts +90 -0
- package/src/Calendar/_helpers/clampToDayViewBoundary/clampToDayViewBoundary.ts +25 -0
- package/src/Calendar/_helpers/hasDisabledDatesInMonth/hasDisabledDatesInMonth.test.ts +98 -0
- package/src/Calendar/_helpers/hasDisabledDatesInMonth/hasDisabledDatesInMonth.ts +45 -0
- package/src/Calendar/_helpers/index.ts +3 -0
- package/src/Calendar/_helpers/isDateDisabled/isDateDisabled.test.ts +169 -0
- package/src/Calendar/_helpers/isDateDisabled/isDateDisabled.ts +59 -0
- package/src/Calendar/_stories/Calendar.accessibility.docs.mdx +118 -0
- package/src/Calendar/_stories/Calendar.story.tsx +144 -4
- package/src/Calendar/_stories/Calendar.test.story.tsx +114 -0
- package/src/Calendar/index.ts +7 -0
- package/src/DateLookup/DateLookup.disabledDates.test.tsx +312 -0
- package/src/DateLookup/DateLookup.test.tsx +34 -37
- package/src/DateLookup/DateLookup.tsx +37 -13
- package/src/DateLookup/_stories/DateLookup.accessibility.docs.mdx +108 -0
- package/src/DateLookup/_stories/DateLookup.story.tsx +126 -2
- package/src/DateLookup/index.ts +6 -0
- package/src/ExpressiveMoneyInput/CurrencySelector/CurrencySelector.tsx +12 -13
- package/src/Inputs/SelectInput/SelectInput.test.tsx +37 -0
- package/src/Inputs/SelectInput/TriggerButton/SelectInputTriggerButton.tsx +1 -1
- package/src/Typeahead/Typeahead.css +14 -0
- package/src/Typeahead/Typeahead.less +8 -0
- package/src/Typeahead/Typeahead.messages.ts +5 -0
- package/src/Typeahead/Typeahead.test.tsx +80 -3
- package/src/Typeahead/Typeahead.tsx +50 -27
- package/src/Typeahead/TypeaheadInput/TypeaheadInput.tsx +2 -6
- package/src/Typeahead/TypeaheadOption/TypeaheadOption.css +5 -0
- package/src/Typeahead/TypeaheadOption/TypeaheadOption.less +9 -0
- package/src/Typeahead/TypeaheadOption/TypeaheadOption.tsx +4 -2
- package/src/i18n/en.json +4 -0
- package/src/index.ts +3 -2
- package/src/main.css +147 -43
- package/build/Calendar/tableLink/TableLink.js +0 -61
- package/build/Calendar/tableLink/TableLink.js.map +0 -1
- package/build/Calendar/tableLink/TableLink.mjs +0 -57
- package/build/Calendar/tableLink/TableLink.mjs.map +0 -1
- package/build/types/Calendar/tableLink/TableLink.d.ts.map +0 -1
- package/build/types/Calendar/tableLink/index.d.ts.map +0 -1
- package/src/Calendar/tableLink/TableLink.tsx +0 -77
- /package/build/types/Calendar/{tableLink → TableLink}/index.d.ts +0 -0
- /package/src/Calendar/{tableLink → TableLink}/index.ts +0 -0
|
@@ -216,31 +216,15 @@ class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, Typea
|
|
|
216
216
|
};
|
|
217
217
|
|
|
218
218
|
handleOnKeyDown: React.KeyboardEventHandler<HTMLInputElement> = (event) => {
|
|
219
|
-
const { showSuggestions, allowNew, multiple, chipSeparators
|
|
220
|
-
const {
|
|
219
|
+
const { showSuggestions, allowNew, multiple, chipSeparators } = this.props;
|
|
220
|
+
const { query, selected } = this.state;
|
|
221
221
|
const chipsMode = !showSuggestions && allowNew && multiple;
|
|
222
222
|
|
|
223
223
|
if (chipsMode && ['Enter', 'Tab', ...chipSeparators].includes(event.key) && query.trim()) {
|
|
224
224
|
event.preventDefault();
|
|
225
225
|
this.selectItem({ label: query });
|
|
226
|
-
} else {
|
|
226
|
+
} else if (!this.handleOptionNavigation(event)) {
|
|
227
227
|
switch (event.key) {
|
|
228
|
-
case 'ArrowDown':
|
|
229
|
-
event.preventDefault();
|
|
230
|
-
this.moveFocusedOption(1);
|
|
231
|
-
break;
|
|
232
|
-
case 'ArrowUp':
|
|
233
|
-
event.preventDefault();
|
|
234
|
-
this.moveFocusedOption(-1);
|
|
235
|
-
break;
|
|
236
|
-
case 'Enter':
|
|
237
|
-
event.preventDefault();
|
|
238
|
-
if (keyboardFocusedOptionIndex != null && options[keyboardFocusedOptionIndex]) {
|
|
239
|
-
this.selectItem(options[keyboardFocusedOptionIndex]);
|
|
240
|
-
} else if (allowNew && query.trim()) {
|
|
241
|
-
this.selectItem({ label: query });
|
|
242
|
-
}
|
|
243
|
-
break;
|
|
244
228
|
case 'Backspace':
|
|
245
229
|
if (multiple && !query && selected.length > 0) {
|
|
246
230
|
this.updateSelectedValue(selected.slice(0, -1));
|
|
@@ -251,6 +235,36 @@ class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, Typea
|
|
|
251
235
|
}
|
|
252
236
|
}
|
|
253
237
|
};
|
|
238
|
+
|
|
239
|
+
handleOptionListKeyDown: React.KeyboardEventHandler<HTMLUListElement> = (event) => {
|
|
240
|
+
this.handleOptionNavigation(event);
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
handleOptionNavigation(event: React.KeyboardEvent<HTMLElement>) {
|
|
244
|
+
const { allowNew, options } = this.props;
|
|
245
|
+
const { keyboardFocusedOptionIndex, query } = this.state;
|
|
246
|
+
|
|
247
|
+
switch (event.key) {
|
|
248
|
+
case 'ArrowDown':
|
|
249
|
+
event.preventDefault();
|
|
250
|
+
this.moveFocusedOption(1);
|
|
251
|
+
return true;
|
|
252
|
+
case 'ArrowUp':
|
|
253
|
+
event.preventDefault();
|
|
254
|
+
this.moveFocusedOption(-1);
|
|
255
|
+
return true;
|
|
256
|
+
case 'Enter':
|
|
257
|
+
event.preventDefault();
|
|
258
|
+
if (keyboardFocusedOptionIndex != null && options[keyboardFocusedOptionIndex]) {
|
|
259
|
+
this.selectItem(options[keyboardFocusedOptionIndex]);
|
|
260
|
+
} else if (allowNew && query.trim()) {
|
|
261
|
+
this.selectItem({ label: query });
|
|
262
|
+
}
|
|
263
|
+
return true;
|
|
264
|
+
default:
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
254
268
|
moveFocusedOption(offset: number) {
|
|
255
269
|
this.setState((previousState) => {
|
|
256
270
|
const { keyboardFocusedOptionIndex } = previousState;
|
|
@@ -261,7 +275,7 @@ class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, Typea
|
|
|
261
275
|
}
|
|
262
276
|
const optionRef = this.optionRefs[index];
|
|
263
277
|
if (optionRef?.current) {
|
|
264
|
-
optionRef.current.
|
|
278
|
+
optionRef.current.scrollIntoView({ block: 'nearest' });
|
|
265
279
|
}
|
|
266
280
|
return {
|
|
267
281
|
keyboardFocusedOptionIndex: index,
|
|
@@ -269,6 +283,10 @@ class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, Typea
|
|
|
269
283
|
});
|
|
270
284
|
}
|
|
271
285
|
|
|
286
|
+
setFocusedOption = (index: number) => {
|
|
287
|
+
this.setState({ keyboardFocusedOptionIndex: index });
|
|
288
|
+
};
|
|
289
|
+
|
|
272
290
|
selectItem = (item: TypeaheadOption<T>) => {
|
|
273
291
|
const { multiple } = this.props;
|
|
274
292
|
let selected = [...this.state.selected];
|
|
@@ -423,12 +441,16 @@ class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, Typea
|
|
|
423
441
|
});
|
|
424
442
|
}
|
|
425
443
|
return (
|
|
426
|
-
<div
|
|
427
|
-
className={clsx('dropdown btn-group btn-block', { open: dropdownOpen })}
|
|
428
|
-
id={`menu-${id}`}
|
|
429
|
-
>
|
|
444
|
+
<div className={clsx('dropdown btn-group btn-block', { open: dropdownOpen })}>
|
|
430
445
|
{(!!optionsToRender.length || footer) && (
|
|
431
|
-
<ul
|
|
446
|
+
<ul
|
|
447
|
+
className="dropdown-menu"
|
|
448
|
+
id={`menu-${id}`}
|
|
449
|
+
role="listbox"
|
|
450
|
+
aria-label={this.props?.intl?.formatMessage(messages.suggestionsLabel)}
|
|
451
|
+
tabIndex={0}
|
|
452
|
+
onKeyDown={this.handleOptionListKeyDown}
|
|
453
|
+
>
|
|
432
454
|
{optionsToRender.map((option, idx) => {
|
|
433
455
|
const ref = React.createRef<HTMLLIElement>();
|
|
434
456
|
this.optionRefs[idx] = ref;
|
|
@@ -439,7 +461,8 @@ class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, Typea
|
|
|
439
461
|
query={query}
|
|
440
462
|
option={option}
|
|
441
463
|
selected={keyboardFocusedOptionIndex === idx}
|
|
442
|
-
id={
|
|
464
|
+
id={`${id}-${idx}`}
|
|
465
|
+
onMouseEnter={() => this.setFocusedOption(idx)}
|
|
443
466
|
onClick={(event) => {
|
|
444
467
|
this.onOptionSelected(event, option);
|
|
445
468
|
}}
|
|
@@ -554,7 +577,7 @@ class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, Typea
|
|
|
554
577
|
autoComplete={inputAutoComplete}
|
|
555
578
|
ariaActivedescendant={
|
|
556
579
|
keyboardFocusedOptionIndex !== null && options[keyboardFocusedOptionIndex]
|
|
557
|
-
? `option-${
|
|
580
|
+
? `option-${id}-${keyboardFocusedOptionIndex}`
|
|
558
581
|
: undefined
|
|
559
582
|
}
|
|
560
583
|
onChange={this.handleOnChange}
|
|
@@ -82,7 +82,7 @@ export default class TypeaheadInput<T> extends Component<
|
|
|
82
82
|
onFocus,
|
|
83
83
|
onPaste,
|
|
84
84
|
autoComplete,
|
|
85
|
-
ariaActivedescendant,
|
|
85
|
+
ariaActivedescendant,
|
|
86
86
|
} = this.props;
|
|
87
87
|
const { inputWidth } = this.state;
|
|
88
88
|
|
|
@@ -93,11 +93,7 @@ export default class TypeaheadInput<T> extends Component<
|
|
|
93
93
|
className={clsx(multiple && 'typeahead__input')}
|
|
94
94
|
name={name}
|
|
95
95
|
id={`input-${typeaheadId}`}
|
|
96
|
-
aria-activedescendant={
|
|
97
|
-
ariaActivedescendant
|
|
98
|
-
? `menu-${typeaheadId} ${ariaActivedescendant}`
|
|
99
|
-
: `menu-${typeaheadId}`
|
|
100
|
-
}
|
|
96
|
+
aria-activedescendant={ariaActivedescendant}
|
|
101
97
|
autoFocus={autoFocus}
|
|
102
98
|
placeholder={hasPlaceholder ? placeholder : ''}
|
|
103
99
|
aria-autocomplete="list"
|
|
@@ -7,3 +7,8 @@
|
|
|
7
7
|
border-radius: 10px;
|
|
8
8
|
border-radius: var(--radius-small);
|
|
9
9
|
}
|
|
10
|
+
.dropdown-menu > li.typeahead__option:not(.active):not(.selected) > .dropdown-item:not([disabled]):not(.disabled):hover,
|
|
11
|
+
.dropdown-menu > li.typeahead__option:not(.active):not(.selected) > .dropdown-item:not([disabled]):not(.disabled):focus,
|
|
12
|
+
.dropdown-menu > li.typeahead__option:not(.active):not(.selected) > .dropdown-item:not([disabled]):not(.disabled):active {
|
|
13
|
+
box-shadow: none;
|
|
14
|
+
}
|
|
@@ -8,12 +8,13 @@ export type TypeaheadOptionProps<T> = {
|
|
|
8
8
|
option: TypeaheadOption<T>;
|
|
9
9
|
selected?: boolean;
|
|
10
10
|
onClick?: React.MouseEventHandler;
|
|
11
|
+
onMouseEnter?: React.MouseEventHandler;
|
|
11
12
|
query?: string;
|
|
12
13
|
id?: string;
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
const Option = forwardRef<HTMLLIElement, TypeaheadOptionProps<any>>((props, ref) => {
|
|
16
|
-
const { option, selected = false, onClick = () => {}, query = '', id } = props;
|
|
17
|
+
const { option, selected = false, onClick = () => {}, onMouseEnter, query = '', id } = props;
|
|
17
18
|
const { label, note, secondary } = option;
|
|
18
19
|
|
|
19
20
|
return (
|
|
@@ -25,8 +26,9 @@ const Option = forwardRef<HTMLLIElement, TypeaheadOptionProps<any>>((props, ref)
|
|
|
25
26
|
className={clsx('typeahead__option tw-dropdown-item clickable', {
|
|
26
27
|
'tw-dropdown-item--focused': selected,
|
|
27
28
|
})}
|
|
29
|
+
onMouseEnter={onMouseEnter}
|
|
28
30
|
>
|
|
29
|
-
<a className="dropdown-item" href="#" tabIndex={
|
|
31
|
+
<a className="dropdown-item" href="#" tabIndex={-1} onClick={onClick}>
|
|
30
32
|
<Highlight value={label} query={query} />
|
|
31
33
|
{note && <span className="np-text-body-default m-l-1">{note}</span>}
|
|
32
34
|
{secondary && (
|
package/src/i18n/en.json
CHANGED
|
@@ -12,6 +12,10 @@
|
|
|
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",
|
|
16
|
+
"neptune.DateLookup.outOfRangeAfter": "Please enter {min} or a later date.",
|
|
17
|
+
"neptune.DateLookup.outOfRangeBefore": "Please enter {max} or an earlier date.",
|
|
18
|
+
"neptune.DateLookup.outOfRangeBetween": "Please select a date between {min} and {max}.",
|
|
15
19
|
"neptune.DateLookup.previous": "previous",
|
|
16
20
|
"neptune.DateLookup.selected": "selected",
|
|
17
21
|
"neptune.DateLookup.twentyYears": "20 years",
|
package/src/index.ts
CHANGED
|
@@ -26,6 +26,8 @@ export type {
|
|
|
26
26
|
AnchorElementProps,
|
|
27
27
|
} from './Button';
|
|
28
28
|
export type { BodyProps } from './Body';
|
|
29
|
+
export type { CalendarProps } from './Calendar';
|
|
30
|
+
export type { DisabledRules, WeekDayType, DisabledDateRange } from './Calendar';
|
|
29
31
|
export type { CardProps } from './_deprecated/Card';
|
|
30
32
|
export type {
|
|
31
33
|
CarouselProps,
|
|
@@ -56,7 +58,6 @@ export type {
|
|
|
56
58
|
export type { BottomSheetProps } from './common/BottomSheet';
|
|
57
59
|
export type { DateInputProps } from './DateInput';
|
|
58
60
|
export type { DateLookupProps } from './DateLookup';
|
|
59
|
-
export type { CalendarProps } from './Calendar';
|
|
60
61
|
export type { DecisionProps } from './Decision';
|
|
61
62
|
export type {
|
|
62
63
|
DefinitionListProps,
|
|
@@ -206,6 +207,7 @@ export { default as Badge, BadgeAssets } from './_deprecated/Badge';
|
|
|
206
207
|
export { default as Body } from './Body';
|
|
207
208
|
export { default as Button } from './Button';
|
|
208
209
|
export { default as IconButton } from './IconButton';
|
|
210
|
+
export { default as Calendar } from './Calendar';
|
|
209
211
|
export { default as Carousel } from './Carousel';
|
|
210
212
|
export { default as Card } from './_deprecated/Card';
|
|
211
213
|
export { default as Checkbox } from './Checkbox';
|
|
@@ -221,7 +223,6 @@ export { default as BaseCard } from './common/BaseCard';
|
|
|
221
223
|
export { default as CriticalCommsBanner } from './_deprecated/CriticalBanner';
|
|
222
224
|
export { default as DateInput } from './DateInput';
|
|
223
225
|
export { default as DateLookup } from './DateLookup';
|
|
224
|
-
export { default as Calendar } from './Calendar';
|
|
225
226
|
export { default as Decision } from './Decision';
|
|
226
227
|
export { default as DefinitionList } from './DefinitionList';
|
|
227
228
|
export { default as Dimmer } from './Dimmer';
|
package/src/main.css
CHANGED
|
@@ -27269,46 +27269,12 @@ 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;
|
|
27310
|
-
color: #0097c7;
|
|
27311
|
-
color: var(--color-content-accent);
|
|
27312
27278
|
border: transparent;
|
|
27313
27279
|
border-radius: 10px;
|
|
27314
27280
|
border-radius: var(--radius-small);
|
|
@@ -27320,12 +27286,92 @@ a[data-toggle="tooltip"] {
|
|
|
27320
27286
|
}
|
|
27321
27287
|
|
|
27322
27288
|
@media (max-width: 320px) {
|
|
27323
|
-
.
|
|
27289
|
+
.wds-Calendar__option--day,
|
|
27290
|
+
.wds-Calendar__option--month,
|
|
27291
|
+
.wds-Calendar__option--year {
|
|
27324
27292
|
padding: 0;
|
|
27325
27293
|
}
|
|
27326
27294
|
}
|
|
27327
27295
|
|
|
27328
|
-
.
|
|
27296
|
+
.wds-Calendar__option--day:focus,
|
|
27297
|
+
.wds-Calendar__option--month:focus,
|
|
27298
|
+
.wds-Calendar__option--year:focus {
|
|
27299
|
+
background-color: var(--color-background-screen-hover);
|
|
27300
|
+
}
|
|
27301
|
+
|
|
27302
|
+
.wds-Calendar__option--day.disabled,
|
|
27303
|
+
.wds-Calendar__option--month.disabled,
|
|
27304
|
+
.wds-Calendar__option--year.disabled,
|
|
27305
|
+
.wds-Calendar__option--day[aria-disabled="true"],
|
|
27306
|
+
.wds-Calendar__option--month[aria-disabled="true"],
|
|
27307
|
+
.wds-Calendar__option--year[aria-disabled="true"] {
|
|
27308
|
+
--ring-outline-color: var(--color-sentiment-content-primary);
|
|
27309
|
+
color: #768e9c;
|
|
27310
|
+
color: var(--color-content-tertiary);
|
|
27311
|
+
cursor: not-allowed;
|
|
27312
|
+
}
|
|
27313
|
+
|
|
27314
|
+
.wds-Calendar__option--day.disabled:hover,
|
|
27315
|
+
.wds-Calendar__option--month.disabled:hover,
|
|
27316
|
+
.wds-Calendar__option--year.disabled:hover,
|
|
27317
|
+
.wds-Calendar__option--day[aria-disabled="true"]:hover,
|
|
27318
|
+
.wds-Calendar__option--month[aria-disabled="true"]:hover,
|
|
27319
|
+
.wds-Calendar__option--year[aria-disabled="true"]:hover,
|
|
27320
|
+
.wds-Calendar__option--day.disabled:focus,
|
|
27321
|
+
.wds-Calendar__option--month.disabled:focus,
|
|
27322
|
+
.wds-Calendar__option--year.disabled:focus,
|
|
27323
|
+
.wds-Calendar__option--day[aria-disabled="true"]:focus,
|
|
27324
|
+
.wds-Calendar__option--month[aria-disabled="true"]:focus,
|
|
27325
|
+
.wds-Calendar__option--year[aria-disabled="true"]:focus {
|
|
27326
|
+
filter: initial;
|
|
27327
|
+
opacity: 1;
|
|
27328
|
+
opacity: initial;
|
|
27329
|
+
background-color: var(--color-sentiment-background-surface);
|
|
27330
|
+
color: var(--color-sentiment-content-primary);
|
|
27331
|
+
}
|
|
27332
|
+
|
|
27333
|
+
.wds-Calendar__option--day.disabled.active,
|
|
27334
|
+
.wds-Calendar__option--month.disabled.active,
|
|
27335
|
+
.wds-Calendar__option--year.disabled.active,
|
|
27336
|
+
.wds-Calendar__option--day[aria-disabled="true"].active,
|
|
27337
|
+
.wds-Calendar__option--month[aria-disabled="true"].active,
|
|
27338
|
+
.wds-Calendar__option--year[aria-disabled="true"].active,
|
|
27339
|
+
.wds-Calendar__option--day.disabled.active:hover,
|
|
27340
|
+
.wds-Calendar__option--month.disabled.active:hover,
|
|
27341
|
+
.wds-Calendar__option--year.disabled.active:hover,
|
|
27342
|
+
.wds-Calendar__option--day[aria-disabled="true"].active:hover,
|
|
27343
|
+
.wds-Calendar__option--month[aria-disabled="true"].active:hover,
|
|
27344
|
+
.wds-Calendar__option--year[aria-disabled="true"].active:hover,
|
|
27345
|
+
.wds-Calendar__option--day.disabled.active:active,
|
|
27346
|
+
.wds-Calendar__option--month.disabled.active:active,
|
|
27347
|
+
.wds-Calendar__option--year.disabled.active:active,
|
|
27348
|
+
.wds-Calendar__option--day[aria-disabled="true"].active:active,
|
|
27349
|
+
.wds-Calendar__option--month[aria-disabled="true"].active:active,
|
|
27350
|
+
.wds-Calendar__option--year[aria-disabled="true"].active:active,
|
|
27351
|
+
.wds-Calendar__option--day.disabled.active:focus,
|
|
27352
|
+
.wds-Calendar__option--month.disabled.active:focus,
|
|
27353
|
+
.wds-Calendar__option--year.disabled.active:focus,
|
|
27354
|
+
.wds-Calendar__option--day[aria-disabled="true"].active:focus,
|
|
27355
|
+
.wds-Calendar__option--month[aria-disabled="true"].active:focus,
|
|
27356
|
+
.wds-Calendar__option--year[aria-disabled="true"].active:focus {
|
|
27357
|
+
filter: initial;
|
|
27358
|
+
opacity: 1;
|
|
27359
|
+
opacity: initial;
|
|
27360
|
+
background-color: var(--color-sentiment-interactive-primary);
|
|
27361
|
+
color: var(--color-sentiment-interactive-secondary);
|
|
27362
|
+
}
|
|
27363
|
+
|
|
27364
|
+
.wds-Calendar__option--day.disabled.today,
|
|
27365
|
+
.wds-Calendar__option--month.disabled.today,
|
|
27366
|
+
.wds-Calendar__option--year.disabled.today,
|
|
27367
|
+
.wds-Calendar__option--day[aria-disabled="true"].today,
|
|
27368
|
+
.wds-Calendar__option--month[aria-disabled="true"].today,
|
|
27369
|
+
.wds-Calendar__option--year[aria-disabled="true"].today {
|
|
27370
|
+
text-decoration-color: #768e9c;
|
|
27371
|
+
text-decoration-color: var(--color-content-tertiary);
|
|
27372
|
+
}
|
|
27373
|
+
|
|
27374
|
+
.wds-Calendar__option--day {
|
|
27329
27375
|
height: 40px;
|
|
27330
27376
|
height: var(--size-40);
|
|
27331
27377
|
border-radius: 9999px;
|
|
@@ -27340,19 +27386,53 @@ a[data-toggle="tooltip"] {
|
|
|
27340
27386
|
justify-content: center;
|
|
27341
27387
|
}
|
|
27342
27388
|
|
|
27343
|
-
.
|
|
27389
|
+
.wds-Calendar__option--day.today {
|
|
27344
27390
|
-webkit-text-decoration: underline;
|
|
27345
27391
|
text-decoration: underline;
|
|
27346
27392
|
text-decoration-thickness: 2px;
|
|
27347
27393
|
text-underline-offset: 4px;
|
|
27348
27394
|
}
|
|
27349
27395
|
|
|
27350
|
-
.tw-date-lookup-calendar
|
|
27351
|
-
|
|
27396
|
+
.tw-date-lookup-calendar {
|
|
27397
|
+
min-width: 300px;
|
|
27398
|
+
text-align: center;
|
|
27399
|
+
table-layout: fixed;
|
|
27400
|
+
border: none;
|
|
27401
|
+
background-color: inherit;
|
|
27402
|
+
}
|
|
27403
|
+
|
|
27404
|
+
.tw-date-lookup-calendar thead {
|
|
27405
|
+
background-color: transparent;
|
|
27406
|
+
background-color: initial;
|
|
27407
|
+
}
|
|
27408
|
+
|
|
27409
|
+
.tw-date-lookup-calendar > tbody > tr > td.weekend button {
|
|
27410
|
+
color: #5d7079;
|
|
27411
|
+
color: var(--color-content-secondary);
|
|
27412
|
+
}
|
|
27413
|
+
|
|
27414
|
+
.tw-date-lookup-calendar > tbody > tr > td {
|
|
27415
|
+
border: none;
|
|
27416
|
+
padding: 4px;
|
|
27417
|
+
padding: var(--size-4);
|
|
27418
|
+
}
|
|
27419
|
+
|
|
27420
|
+
@media (max-width: 320px) {
|
|
27421
|
+
.tw-date-lookup-calendar > tbody > tr > td {
|
|
27422
|
+
padding: 0;
|
|
27423
|
+
}
|
|
27424
|
+
}
|
|
27425
|
+
|
|
27426
|
+
.tw-date-lookup-calendar > tbody > tr > td:has(.wds-Calendar__option--day) {
|
|
27427
|
+
padding: 1px;
|
|
27428
|
+
}
|
|
27429
|
+
|
|
27430
|
+
.tw-date-lookup-calendar > tbody > tr > td:not(.disabled):not(:disabled) button.show-focus:not(.disabled):not([aria-disabled="true"]),
|
|
27431
|
+
.tw-date-lookup-calendar > tbody > tr > td:hover button:not(.disabled):not(:disabled):not([aria-disabled="true"]) {
|
|
27352
27432
|
background-color: var(--color-background-screen-hover);
|
|
27353
27433
|
}
|
|
27354
27434
|
|
|
27355
|
-
.tw-date-lookup-calendar > tbody > tr > td:not(.disabled):not(:disabled) button.active {
|
|
27435
|
+
.tw-date-lookup-calendar > tbody > tr > td:not(.disabled):not(:disabled) button.active:not([aria-disabled="true"]) {
|
|
27356
27436
|
background-color: var(--color-interactive-primary);
|
|
27357
27437
|
color: var(--color-interactive-contrast);
|
|
27358
27438
|
}
|
|
@@ -34122,6 +34202,24 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
34122
34202
|
.typeahead .dropdown-menu {
|
|
34123
34203
|
max-width: 100%;
|
|
34124
34204
|
width: 100%;
|
|
34205
|
+
margin-top: 8px;
|
|
34206
|
+
margin-top: var(--size-8);
|
|
34207
|
+
scroll-padding-top: 8px;
|
|
34208
|
+
scroll-padding-top: var(--size-8);
|
|
34209
|
+
scroll-padding-bottom: 8px;
|
|
34210
|
+
scroll-padding-bottom: var(--size-8);
|
|
34211
|
+
--ring-outline-offset: calc(-1 * var(--ring-outline-width));
|
|
34212
|
+
}
|
|
34213
|
+
|
|
34214
|
+
.typeahead .dropdown-menu:focus {
|
|
34215
|
+
outline: none;
|
|
34216
|
+
}
|
|
34217
|
+
|
|
34218
|
+
.typeahead .dropdown-menu:focus-visible {
|
|
34219
|
+
outline: #37517e solid 2px;
|
|
34220
|
+
outline: var(--ring-outline-color) solid var(--ring-outline-width);
|
|
34221
|
+
outline-offset: 2px;
|
|
34222
|
+
outline-offset: var(--ring-outline-offset);
|
|
34125
34223
|
}
|
|
34126
34224
|
|
|
34127
34225
|
.np-theme-personal--forest-green .typeahead .dropdown-menu,
|
|
@@ -34348,6 +34446,12 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
34348
34446
|
border-radius: var(--radius-small);
|
|
34349
34447
|
}
|
|
34350
34448
|
|
|
34449
|
+
.dropdown-menu > li.typeahead__option:not(.active):not(.selected) > .dropdown-item:not([disabled]):not(.disabled):hover,
|
|
34450
|
+
.dropdown-menu > li.typeahead__option:not(.active):not(.selected) > .dropdown-item:not([disabled]):not(.disabled):focus,
|
|
34451
|
+
.dropdown-menu > li.typeahead__option:not(.active):not(.selected) > .dropdown-item:not([disabled]):not(.disabled):active {
|
|
34452
|
+
box-shadow: none;
|
|
34453
|
+
}
|
|
34454
|
+
|
|
34351
34455
|
.tw-droppable-lg {
|
|
34352
34456
|
min-height: 346px;
|
|
34353
34457
|
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var clsx = require('clsx');
|
|
6
|
-
var React = require('react');
|
|
7
|
-
var reactIntl = require('react-intl');
|
|
8
|
-
var Calendar_messages = require('../Calendar.messages.js');
|
|
9
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
10
|
-
|
|
11
|
-
const TableLink = ({
|
|
12
|
-
item,
|
|
13
|
-
type,
|
|
14
|
-
title,
|
|
15
|
-
longTitle,
|
|
16
|
-
active,
|
|
17
|
-
disabled,
|
|
18
|
-
today,
|
|
19
|
-
autofocus,
|
|
20
|
-
onClick
|
|
21
|
-
}) => {
|
|
22
|
-
const buttonRef = React.useRef(null);
|
|
23
|
-
const intl = reactIntl.useIntl();
|
|
24
|
-
React.useEffect(() => {
|
|
25
|
-
if (autofocus) {
|
|
26
|
-
setTimeout(() => {
|
|
27
|
-
buttonRef.current?.focus();
|
|
28
|
-
}, 0);
|
|
29
|
-
}
|
|
30
|
-
}, [autofocus]);
|
|
31
|
-
const onCalendarClick = event => {
|
|
32
|
-
event.preventDefault();
|
|
33
|
-
if (!disabled) {
|
|
34
|
-
onClick(item);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
const calculateAriaLabel = () => {
|
|
38
|
-
if (active) {
|
|
39
|
-
return `${longTitle || title || ''}, ${intl.formatMessage(Calendar_messages.default.selected)} ${intl.formatMessage(Calendar_messages.default[type])}`;
|
|
40
|
-
}
|
|
41
|
-
return longTitle || title;
|
|
42
|
-
};
|
|
43
|
-
return /*#__PURE__*/jsxRuntime.jsx("button", {
|
|
44
|
-
ref: buttonRef,
|
|
45
|
-
type: "button",
|
|
46
|
-
className: clsx.clsx(`tw-date-lookup-${type}-option np-text-body-default-bold`, {
|
|
47
|
-
active: !!active
|
|
48
|
-
}, {
|
|
49
|
-
today: !!today
|
|
50
|
-
}),
|
|
51
|
-
disabled: disabled,
|
|
52
|
-
tabIndex: autofocus ? 0 : -1,
|
|
53
|
-
"aria-label": calculateAriaLabel(),
|
|
54
|
-
"aria-pressed": active,
|
|
55
|
-
onClick: onCalendarClick,
|
|
56
|
-
children: title || item
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
exports.default = TableLink;
|
|
61
|
-
//# sourceMappingURL=TableLink.js.map
|
|
@@ -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,57 +0,0 @@
|
|
|
1
|
-
import { clsx } from 'clsx';
|
|
2
|
-
import { useRef, useEffect } from 'react';
|
|
3
|
-
import { useIntl } from 'react-intl';
|
|
4
|
-
import messages from '../Calendar.messages.mjs';
|
|
5
|
-
import { jsx } from 'react/jsx-runtime';
|
|
6
|
-
|
|
7
|
-
const TableLink = ({
|
|
8
|
-
item,
|
|
9
|
-
type,
|
|
10
|
-
title,
|
|
11
|
-
longTitle,
|
|
12
|
-
active,
|
|
13
|
-
disabled,
|
|
14
|
-
today,
|
|
15
|
-
autofocus,
|
|
16
|
-
onClick
|
|
17
|
-
}) => {
|
|
18
|
-
const buttonRef = useRef(null);
|
|
19
|
-
const intl = useIntl();
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
if (autofocus) {
|
|
22
|
-
setTimeout(() => {
|
|
23
|
-
buttonRef.current?.focus();
|
|
24
|
-
}, 0);
|
|
25
|
-
}
|
|
26
|
-
}, [autofocus]);
|
|
27
|
-
const onCalendarClick = event => {
|
|
28
|
-
event.preventDefault();
|
|
29
|
-
if (!disabled) {
|
|
30
|
-
onClick(item);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
const calculateAriaLabel = () => {
|
|
34
|
-
if (active) {
|
|
35
|
-
return `${longTitle || title || ''}, ${intl.formatMessage(messages.selected)} ${intl.formatMessage(messages[type])}`;
|
|
36
|
-
}
|
|
37
|
-
return longTitle || title;
|
|
38
|
-
};
|
|
39
|
-
return /*#__PURE__*/jsx("button", {
|
|
40
|
-
ref: buttonRef,
|
|
41
|
-
type: "button",
|
|
42
|
-
className: clsx(`tw-date-lookup-${type}-option np-text-body-default-bold`, {
|
|
43
|
-
active: !!active
|
|
44
|
-
}, {
|
|
45
|
-
today: !!today
|
|
46
|
-
}),
|
|
47
|
-
disabled: disabled,
|
|
48
|
-
tabIndex: autofocus ? 0 : -1,
|
|
49
|
-
"aria-label": calculateAriaLabel(),
|
|
50
|
-
"aria-pressed": active,
|
|
51
|
-
onClick: onCalendarClick,
|
|
52
|
-
children: title || item
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export { TableLink as default };
|
|
57
|
-
//# sourceMappingURL=TableLink.mjs.map
|
|
@@ -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;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TableLink.d.ts","sourceRoot":"","sources":["../../../../src/Calendar/tableLink/TableLink.tsx"],"names":[],"mappings":"AAMA,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AAED,QAAA,MAAM,SAAS,GAAI,gFAUhB,cAAc,gCA8ChB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Calendar/tableLink/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
|