@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.js
CHANGED
|
@@ -2369,7 +2369,7 @@ const Button = /*#__PURE__*/React.forwardRef(({
|
|
|
2369
2369
|
className: classes,
|
|
2370
2370
|
...props,
|
|
2371
2371
|
"aria-live": loading ? 'polite' : 'off',
|
|
2372
|
-
"aria-label": loading ? intl.formatMessage(messages$9.loadingAriaLabel) :
|
|
2372
|
+
"aria-label": loading ? intl.formatMessage(messages$9.loadingAriaLabel) : rest['aria-label'],
|
|
2373
2373
|
children: [children, loading && /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator$1, {
|
|
2374
2374
|
size: processIndicatorSize(),
|
|
2375
2375
|
className: "btn-loader"
|
|
@@ -3506,50 +3506,59 @@ function getStartOfDay(date) {
|
|
|
3506
3506
|
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
3507
3507
|
}
|
|
3508
3508
|
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
type,
|
|
3512
|
-
title,
|
|
3513
|
-
longTitle,
|
|
3514
|
-
active,
|
|
3515
|
-
disabled,
|
|
3516
|
-
today,
|
|
3517
|
-
autofocus,
|
|
3518
|
-
onClick,
|
|
3519
|
-
intl: {
|
|
3520
|
-
formatMessage
|
|
3521
|
-
}
|
|
3522
|
-
}) => {
|
|
3523
|
-
const buttonRef = React.useRef(null);
|
|
3524
|
-
React.useEffect(() => {
|
|
3525
|
-
if (autofocus) {
|
|
3526
|
-
buttonRef.current?.focus();
|
|
3527
|
-
}
|
|
3528
|
-
}, []);
|
|
3529
|
-
const onCalendarClick = event => {
|
|
3509
|
+
class TableLink extends React.PureComponent {
|
|
3510
|
+
onClick = event => {
|
|
3530
3511
|
event.preventDefault();
|
|
3531
|
-
if (!disabled) {
|
|
3532
|
-
onClick(item);
|
|
3512
|
+
if (!this.props.disabled) {
|
|
3513
|
+
this.props.onClick(this.props.item);
|
|
3533
3514
|
}
|
|
3534
3515
|
};
|
|
3535
|
-
|
|
3516
|
+
calculateAriaLabel = (longTitle, title, active, type, formatMessage) => {
|
|
3536
3517
|
if (active) {
|
|
3537
|
-
return `${longTitle || title
|
|
3518
|
+
return `${longTitle || title}, ${formatMessage(messages$5.selected)} ${formatMessage(messages$5[type])}`;
|
|
3538
3519
|
}
|
|
3539
3520
|
return longTitle || title;
|
|
3540
3521
|
};
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
type
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3522
|
+
render() {
|
|
3523
|
+
const {
|
|
3524
|
+
item,
|
|
3525
|
+
type,
|
|
3526
|
+
title,
|
|
3527
|
+
longTitle,
|
|
3528
|
+
active,
|
|
3529
|
+
disabled,
|
|
3530
|
+
today,
|
|
3531
|
+
intl: {
|
|
3532
|
+
formatMessage
|
|
3533
|
+
}
|
|
3534
|
+
} = this.props;
|
|
3535
|
+
return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
3536
|
+
children: /*#__PURE__*/jsxRuntime.jsx("button", {
|
|
3537
|
+
type: "button",
|
|
3538
|
+
className: `tw-date-lookup-${type}-option ${active ? 'active' : ''} ${today ? 'today' : ''} np-text-body-default-bold`,
|
|
3539
|
+
disabled: disabled,
|
|
3540
|
+
"aria-label": this.calculateAriaLabel(longTitle, title, active, type, formatMessage),
|
|
3541
|
+
"aria-pressed": active,
|
|
3542
|
+
onClick: this.onClick,
|
|
3543
|
+
children: title || item
|
|
3544
|
+
})
|
|
3545
|
+
});
|
|
3546
|
+
}
|
|
3547
|
+
}
|
|
3548
|
+
TableLink.propTypes = {
|
|
3549
|
+
item: PropTypes__default.default.number.isRequired,
|
|
3550
|
+
// day (1-31), month (0-11) or year (2018 etc)
|
|
3551
|
+
type: PropTypes__default.default.oneOf(['day', 'month', 'year']).isRequired,
|
|
3552
|
+
title: PropTypes__default.default.string,
|
|
3553
|
+
longTitle: PropTypes__default.default.string,
|
|
3554
|
+
active: PropTypes__default.default.bool.isRequired,
|
|
3555
|
+
disabled: PropTypes__default.default.bool.isRequired,
|
|
3556
|
+
today: PropTypes__default.default.bool.isRequired,
|
|
3557
|
+
onClick: PropTypes__default.default.func.isRequired
|
|
3558
|
+
};
|
|
3559
|
+
TableLink.defaultProps = {
|
|
3560
|
+
title: null,
|
|
3561
|
+
longTitle: null
|
|
3553
3562
|
};
|
|
3554
3563
|
var TableLink$1 = reactIntl.injectIntl(TableLink);
|
|
3555
3564
|
|
|
@@ -3622,25 +3631,6 @@ class DayCalendarTable extends React.PureComponent {
|
|
|
3622
3631
|
} = this.props;
|
|
3623
3632
|
return !!(selectedDate && +new Date(viewYear, viewMonth, day) === +selectedDate);
|
|
3624
3633
|
};
|
|
3625
|
-
getAutofocusDay = weeks => {
|
|
3626
|
-
let activeDay = null;
|
|
3627
|
-
let lowestNonDisabledDay = null;
|
|
3628
|
-
for (const week of weeks) {
|
|
3629
|
-
for (const day of week) {
|
|
3630
|
-
if (this.isActive(day)) {
|
|
3631
|
-
activeDay = day;
|
|
3632
|
-
break;
|
|
3633
|
-
}
|
|
3634
|
-
if (!this.isDisabled(day) && lowestNonDisabledDay === null) {
|
|
3635
|
-
lowestNonDisabledDay = day;
|
|
3636
|
-
}
|
|
3637
|
-
}
|
|
3638
|
-
if (activeDay !== null) {
|
|
3639
|
-
break;
|
|
3640
|
-
}
|
|
3641
|
-
}
|
|
3642
|
-
return activeDay || lowestNonDisabledDay;
|
|
3643
|
-
};
|
|
3644
3634
|
render() {
|
|
3645
3635
|
const {
|
|
3646
3636
|
viewMonth,
|
|
@@ -3650,7 +3640,6 @@ class DayCalendarTable extends React.PureComponent {
|
|
|
3650
3640
|
}
|
|
3651
3641
|
} = this.props;
|
|
3652
3642
|
const weeks = this.getTableStructure();
|
|
3653
|
-
let autoFocusDay = this.getAutofocusDay(weeks);
|
|
3654
3643
|
return /*#__PURE__*/jsxRuntime.jsxs("table", {
|
|
3655
3644
|
className: "table table-condensed table-bordered tw-date-lookup-calendar m-b-0",
|
|
3656
3645
|
children: [/*#__PURE__*/jsxRuntime.jsx("thead", {
|
|
@@ -3680,7 +3669,6 @@ class DayCalendarTable extends React.PureComponent {
|
|
|
3680
3669
|
item: day,
|
|
3681
3670
|
type: "day",
|
|
3682
3671
|
title: formatting.formatDate(new Date(viewYear, viewMonth, day), locale, SHORT_DAY_FORMAT),
|
|
3683
|
-
autofocus: day === autoFocusDay,
|
|
3684
3672
|
longTitle: formatting.formatDate(new Date(viewYear, viewMonth, day), locale),
|
|
3685
3673
|
active: this.isActive(day),
|
|
3686
3674
|
disabled: this.isDisabled(day),
|