@transferwise/components 0.0.0-experimental-45502d0 → 0.0.0-experimental-bb03a6a
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/index.esm.js +59 -48
- package/build/index.esm.js.map +1 -1
- package/build/index.js +59 -48
- package/build/index.js.map +1 -1
- package/build/types/button/Button.d.ts +0 -1
- package/build/types/button/Button.d.ts.map +1 -1
- package/build/types/dateLookup/tableLink/TableLink.d.ts +16 -2
- package/build/types/dateLookup/tableLink/TableLink.d.ts.map +1 -1
- package/build/types/dateLookup/tableLink/index.d.ts +1 -1
- package/build/types/dateLookup/tableLink/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/button/Button.spec.js +0 -12
- package/src/button/Button.tsx +1 -3
- package/src/dateLookup/dayCalendar/table/DayCalendarTable.js +26 -0
- package/src/dateLookup/tableLink/TableLink.tsx +74 -0
- package/src/dateLookup/tableLink/TableLink.js +0 -70
- /package/src/dateLookup/tableLink/{index.js → index.ts} +0 -0
package/build/index.esm.js
CHANGED
|
@@ -2286,7 +2286,6 @@ const Button = /*#__PURE__*/forwardRef(({
|
|
|
2286
2286
|
priority = Priority.PRIMARY,
|
|
2287
2287
|
size = Size.MEDIUM,
|
|
2288
2288
|
type = ControlType.ACCENT,
|
|
2289
|
-
'aria-label': ariaLabel,
|
|
2290
2289
|
...rest
|
|
2291
2290
|
}, reference) => {
|
|
2292
2291
|
const intl = useIntl();
|
|
@@ -2336,7 +2335,7 @@ const Button = /*#__PURE__*/forwardRef(({
|
|
|
2336
2335
|
className: classes,
|
|
2337
2336
|
...props,
|
|
2338
2337
|
"aria-live": loading ? 'polite' : 'off',
|
|
2339
|
-
"aria-label": loading ? intl.formatMessage(messages$9.loadingAriaLabel) :
|
|
2338
|
+
"aria-label": loading ? intl.formatMessage(messages$9.loadingAriaLabel) : undefined,
|
|
2340
2339
|
children: [children, loading && /*#__PURE__*/jsx(ProcessIndicator$1, {
|
|
2341
2340
|
size: processIndicatorSize(),
|
|
2342
2341
|
className: "btn-loader"
|
|
@@ -3473,59 +3472,50 @@ function getStartOfDay(date) {
|
|
|
3473
3472
|
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
3474
3473
|
}
|
|
3475
3474
|
|
|
3476
|
-
|
|
3477
|
-
|
|
3475
|
+
const TableLink = ({
|
|
3476
|
+
item,
|
|
3477
|
+
type,
|
|
3478
|
+
title,
|
|
3479
|
+
longTitle,
|
|
3480
|
+
active,
|
|
3481
|
+
disabled,
|
|
3482
|
+
today,
|
|
3483
|
+
autofocus,
|
|
3484
|
+
onClick,
|
|
3485
|
+
intl: {
|
|
3486
|
+
formatMessage
|
|
3487
|
+
}
|
|
3488
|
+
}) => {
|
|
3489
|
+
const buttonRef = useRef(null);
|
|
3490
|
+
useEffect(() => {
|
|
3491
|
+
if (autofocus) {
|
|
3492
|
+
buttonRef.current?.focus();
|
|
3493
|
+
}
|
|
3494
|
+
}, []);
|
|
3495
|
+
const onCalendarClick = event => {
|
|
3478
3496
|
event.preventDefault();
|
|
3479
|
-
if (!
|
|
3480
|
-
|
|
3497
|
+
if (!disabled) {
|
|
3498
|
+
onClick(item);
|
|
3481
3499
|
}
|
|
3482
3500
|
};
|
|
3483
|
-
calculateAriaLabel = (
|
|
3501
|
+
const calculateAriaLabel = () => {
|
|
3484
3502
|
if (active) {
|
|
3485
|
-
return `${longTitle || title}, ${formatMessage(messages$5.selected)} ${formatMessage(messages$5[type])}`;
|
|
3503
|
+
return `${longTitle || title || ''}, ${formatMessage(messages$5.selected)} ${formatMessage(messages$5[type])}`;
|
|
3486
3504
|
}
|
|
3487
3505
|
return longTitle || title;
|
|
3488
3506
|
};
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
type,
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
} = this.props;
|
|
3502
|
-
return /*#__PURE__*/jsx(Fragment, {
|
|
3503
|
-
children: /*#__PURE__*/jsx("button", {
|
|
3504
|
-
type: "button",
|
|
3505
|
-
className: `tw-date-lookup-${type}-option ${active ? 'active' : ''} ${today ? 'today' : ''} np-text-body-default-bold`,
|
|
3506
|
-
disabled: disabled,
|
|
3507
|
-
"aria-label": this.calculateAriaLabel(longTitle, title, active, type, formatMessage),
|
|
3508
|
-
"aria-pressed": active,
|
|
3509
|
-
onClick: this.onClick,
|
|
3510
|
-
children: title || item
|
|
3511
|
-
})
|
|
3512
|
-
});
|
|
3513
|
-
}
|
|
3514
|
-
}
|
|
3515
|
-
TableLink.propTypes = {
|
|
3516
|
-
item: PropTypes.number.isRequired,
|
|
3517
|
-
// day (1-31), month (0-11) or year (2018 etc)
|
|
3518
|
-
type: PropTypes.oneOf(['day', 'month', 'year']).isRequired,
|
|
3519
|
-
title: PropTypes.string,
|
|
3520
|
-
longTitle: PropTypes.string,
|
|
3521
|
-
active: PropTypes.bool.isRequired,
|
|
3522
|
-
disabled: PropTypes.bool.isRequired,
|
|
3523
|
-
today: PropTypes.bool.isRequired,
|
|
3524
|
-
onClick: PropTypes.func.isRequired
|
|
3525
|
-
};
|
|
3526
|
-
TableLink.defaultProps = {
|
|
3527
|
-
title: null,
|
|
3528
|
-
longTitle: null
|
|
3507
|
+
return /*#__PURE__*/jsx(Fragment, {
|
|
3508
|
+
children: /*#__PURE__*/jsx("button", {
|
|
3509
|
+
ref: buttonRef,
|
|
3510
|
+
type: "button",
|
|
3511
|
+
className: `tw-date-lookup-${type}-option ${active ? 'active' : ''} ${today ? 'today' : ''} np-text-body-default-bold`,
|
|
3512
|
+
disabled: disabled,
|
|
3513
|
+
"aria-label": calculateAriaLabel(),
|
|
3514
|
+
"aria-pressed": active,
|
|
3515
|
+
onClick: onCalendarClick,
|
|
3516
|
+
children: title || item
|
|
3517
|
+
})
|
|
3518
|
+
});
|
|
3529
3519
|
};
|
|
3530
3520
|
var TableLink$1 = injectIntl(TableLink);
|
|
3531
3521
|
|
|
@@ -3598,6 +3588,25 @@ class DayCalendarTable extends PureComponent {
|
|
|
3598
3588
|
} = this.props;
|
|
3599
3589
|
return !!(selectedDate && +new Date(viewYear, viewMonth, day) === +selectedDate);
|
|
3600
3590
|
};
|
|
3591
|
+
getAutofocusDay = weeks => {
|
|
3592
|
+
let activeDay = null;
|
|
3593
|
+
let lowestNonDisabledDay = null;
|
|
3594
|
+
for (const week of weeks) {
|
|
3595
|
+
for (const day of week) {
|
|
3596
|
+
if (this.isActive(day)) {
|
|
3597
|
+
activeDay = day;
|
|
3598
|
+
break;
|
|
3599
|
+
}
|
|
3600
|
+
if (!this.isDisabled(day) && lowestNonDisabledDay === null) {
|
|
3601
|
+
lowestNonDisabledDay = day;
|
|
3602
|
+
}
|
|
3603
|
+
}
|
|
3604
|
+
if (activeDay !== null) {
|
|
3605
|
+
break;
|
|
3606
|
+
}
|
|
3607
|
+
}
|
|
3608
|
+
return activeDay || lowestNonDisabledDay;
|
|
3609
|
+
};
|
|
3601
3610
|
render() {
|
|
3602
3611
|
const {
|
|
3603
3612
|
viewMonth,
|
|
@@ -3607,6 +3616,7 @@ class DayCalendarTable extends PureComponent {
|
|
|
3607
3616
|
}
|
|
3608
3617
|
} = this.props;
|
|
3609
3618
|
const weeks = this.getTableStructure();
|
|
3619
|
+
let autoFocusDay = this.getAutofocusDay(weeks);
|
|
3610
3620
|
return /*#__PURE__*/jsxs("table", {
|
|
3611
3621
|
className: "table table-condensed table-bordered tw-date-lookup-calendar m-b-0",
|
|
3612
3622
|
children: [/*#__PURE__*/jsx("thead", {
|
|
@@ -3636,6 +3646,7 @@ class DayCalendarTable extends PureComponent {
|
|
|
3636
3646
|
item: day,
|
|
3637
3647
|
type: "day",
|
|
3638
3648
|
title: formatDate(new Date(viewYear, viewMonth, day), locale, SHORT_DAY_FORMAT),
|
|
3649
|
+
autofocus: day === autoFocusDay,
|
|
3639
3650
|
longTitle: formatDate(new Date(viewYear, viewMonth, day), locale),
|
|
3640
3651
|
active: this.isActive(day),
|
|
3641
3652
|
disabled: this.isDisabled(day),
|