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