@transferwise/components 0.0.0-experimental-3e282e9 → 0.0.0-experimental-65e51cb
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 +70 -134
- package/build/index.esm.js.map +1 -1
- package/build/index.js +70 -134
- package/build/index.js.map +1 -1
- package/build/main.css +1 -1
- package/build/styles/dateLookup/DateLookup.css +1 -1
- package/build/styles/main.css +1 -1
- package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
- package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts +1 -1
- package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts.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/build/types/dateLookup/yearCalendar/table/YearCalendarTable.d.ts.map +1 -1
- package/build/types/info/Info.d.ts +6 -2
- package/build/types/info/Info.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/dateLookup/DateLookup.css +1 -1
- package/src/dateLookup/DateLookup.js +0 -3
- package/src/dateLookup/DateLookup.less +47 -57
- package/src/dateLookup/DateLookup.story.js +5 -7
- package/src/dateLookup/dayCalendar/table/DayCalendarTable.js +1 -35
- package/src/dateLookup/monthCalendar/table/MonthCalendarTable.js +20 -43
- package/src/dateLookup/tableLink/TableLink.js +70 -0
- package/src/dateLookup/yearCalendar/table/YearCalendarTable.js +11 -39
- package/src/info/Info.tsx +6 -1
- package/src/main.css +1 -1
- package/src/dateLookup/tableLink/TableLink.tsx +0 -77
- /package/src/dateLookup/tableLink/{index.ts → index.js} +0 -0
package/build/index.js
CHANGED
|
@@ -3609,53 +3609,59 @@ function getStartOfDay(date) {
|
|
|
3609
3609
|
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
3610
3610
|
}
|
|
3611
3611
|
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
type,
|
|
3615
|
-
title,
|
|
3616
|
-
longTitle,
|
|
3617
|
-
active,
|
|
3618
|
-
disabled,
|
|
3619
|
-
today,
|
|
3620
|
-
autofocus,
|
|
3621
|
-
onClick,
|
|
3622
|
-
intl: {
|
|
3623
|
-
formatMessage
|
|
3624
|
-
}
|
|
3625
|
-
}) => {
|
|
3626
|
-
const buttonRef = React.useRef(null);
|
|
3627
|
-
React.useEffect(() => {
|
|
3628
|
-
if (autofocus) {
|
|
3629
|
-
setTimeout(() => {
|
|
3630
|
-
buttonRef.current?.focus();
|
|
3631
|
-
}, 0);
|
|
3632
|
-
}
|
|
3633
|
-
}, [autofocus]);
|
|
3634
|
-
const onCalendarClick = event => {
|
|
3612
|
+
class TableLink extends React.PureComponent {
|
|
3613
|
+
onClick = event => {
|
|
3635
3614
|
event.preventDefault();
|
|
3636
|
-
if (!disabled) {
|
|
3637
|
-
onClick(item);
|
|
3615
|
+
if (!this.props.disabled) {
|
|
3616
|
+
this.props.onClick(this.props.item);
|
|
3638
3617
|
}
|
|
3639
3618
|
};
|
|
3640
|
-
|
|
3619
|
+
calculateAriaLabel = (longTitle, title, active, type, formatMessage) => {
|
|
3641
3620
|
if (active) {
|
|
3642
|
-
return `${longTitle || title
|
|
3621
|
+
return `${longTitle || title}, ${formatMessage(messages$6.selected)} ${formatMessage(messages$6[type])}`;
|
|
3643
3622
|
}
|
|
3644
3623
|
return longTitle || title;
|
|
3645
3624
|
};
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
type
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3625
|
+
render() {
|
|
3626
|
+
const {
|
|
3627
|
+
item,
|
|
3628
|
+
type,
|
|
3629
|
+
title,
|
|
3630
|
+
longTitle,
|
|
3631
|
+
active,
|
|
3632
|
+
disabled,
|
|
3633
|
+
today,
|
|
3634
|
+
intl: {
|
|
3635
|
+
formatMessage
|
|
3636
|
+
}
|
|
3637
|
+
} = this.props;
|
|
3638
|
+
return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
3639
|
+
children: /*#__PURE__*/jsxRuntime.jsx("button", {
|
|
3640
|
+
type: "button",
|
|
3641
|
+
className: `tw-date-lookup-${type}-option ${active ? 'active' : ''} ${today ? 'today' : ''} np-text-body-default-bold`,
|
|
3642
|
+
disabled: disabled,
|
|
3643
|
+
"aria-label": this.calculateAriaLabel(longTitle, title, active, type, formatMessage),
|
|
3644
|
+
"aria-pressed": active,
|
|
3645
|
+
onClick: this.onClick,
|
|
3646
|
+
children: title || item
|
|
3647
|
+
})
|
|
3648
|
+
});
|
|
3649
|
+
}
|
|
3650
|
+
}
|
|
3651
|
+
TableLink.propTypes = {
|
|
3652
|
+
item: PropTypes__default.default.number.isRequired,
|
|
3653
|
+
// day (1-31), month (0-11) or year (2018 etc)
|
|
3654
|
+
type: PropTypes__default.default.oneOf(['day', 'month', 'year']).isRequired,
|
|
3655
|
+
title: PropTypes__default.default.string,
|
|
3656
|
+
longTitle: PropTypes__default.default.string,
|
|
3657
|
+
active: PropTypes__default.default.bool.isRequired,
|
|
3658
|
+
disabled: PropTypes__default.default.bool.isRequired,
|
|
3659
|
+
today: PropTypes__default.default.bool.isRequired,
|
|
3660
|
+
onClick: PropTypes__default.default.func.isRequired
|
|
3661
|
+
};
|
|
3662
|
+
TableLink.defaultProps = {
|
|
3663
|
+
title: null,
|
|
3664
|
+
longTitle: null
|
|
3659
3665
|
};
|
|
3660
3666
|
var TableLink$1 = reactIntl.injectIntl(TableLink);
|
|
3661
3667
|
|
|
@@ -3728,32 +3734,6 @@ class DayCalendarTable extends React.PureComponent {
|
|
|
3728
3734
|
} = this.props;
|
|
3729
3735
|
return !!(selectedDate && +new Date(viewYear, viewMonth, day) === +selectedDate);
|
|
3730
3736
|
};
|
|
3731
|
-
isToday = (day, viewMonth, viewYear) => {
|
|
3732
|
-
return +getStartOfDay(new Date()) === +new Date(viewYear, viewMonth, day);
|
|
3733
|
-
};
|
|
3734
|
-
getAutofocusDay = (weeks, viewMonth, viewYear) => {
|
|
3735
|
-
let activeDay = null;
|
|
3736
|
-
let today = null;
|
|
3737
|
-
let lowestNonDisabledDay = null;
|
|
3738
|
-
for (const week of weeks) {
|
|
3739
|
-
for (const day of week) {
|
|
3740
|
-
if (this.isActive(day)) {
|
|
3741
|
-
activeDay = day;
|
|
3742
|
-
break;
|
|
3743
|
-
}
|
|
3744
|
-
if (this.isToday(day, viewMonth, viewYear)) {
|
|
3745
|
-
today = day;
|
|
3746
|
-
}
|
|
3747
|
-
if (day && !this.isDisabled(day) && lowestNonDisabledDay === null) {
|
|
3748
|
-
lowestNonDisabledDay = day;
|
|
3749
|
-
}
|
|
3750
|
-
}
|
|
3751
|
-
if (activeDay !== null) {
|
|
3752
|
-
break;
|
|
3753
|
-
}
|
|
3754
|
-
}
|
|
3755
|
-
return activeDay || today || lowestNonDisabledDay;
|
|
3756
|
-
};
|
|
3757
3737
|
render() {
|
|
3758
3738
|
const {
|
|
3759
3739
|
viewMonth,
|
|
@@ -3763,7 +3743,6 @@ class DayCalendarTable extends React.PureComponent {
|
|
|
3763
3743
|
}
|
|
3764
3744
|
} = this.props;
|
|
3765
3745
|
const weeks = this.getTableStructure();
|
|
3766
|
-
let autoFocusDay = this.getAutofocusDay(weeks, viewMonth, viewYear);
|
|
3767
3746
|
return /*#__PURE__*/jsxRuntime.jsxs("table", {
|
|
3768
3747
|
className: "table table-condensed table-bordered tw-date-lookup-calendar m-b-0",
|
|
3769
3748
|
children: [/*#__PURE__*/jsxRuntime.jsx("thead", {
|
|
@@ -3793,11 +3772,10 @@ class DayCalendarTable extends React.PureComponent {
|
|
|
3793
3772
|
item: day,
|
|
3794
3773
|
type: "day",
|
|
3795
3774
|
title: formatting.formatDate(new Date(viewYear, viewMonth, day), locale, SHORT_DAY_FORMAT),
|
|
3796
|
-
autofocus: day === autoFocusDay,
|
|
3797
3775
|
longTitle: formatting.formatDate(new Date(viewYear, viewMonth, day), locale),
|
|
3798
3776
|
active: this.isActive(day),
|
|
3799
3777
|
disabled: this.isDisabled(day),
|
|
3800
|
-
today:
|
|
3778
|
+
today: +getStartOfDay(new Date()) === +new Date(viewYear, viewMonth, day),
|
|
3801
3779
|
onClick: this.selectDay
|
|
3802
3780
|
})
|
|
3803
3781
|
}, dayIndex))
|
|
@@ -3898,11 +3876,11 @@ var DayCalendar$1 = reactIntl.injectIntl(DayCalendar);
|
|
|
3898
3876
|
|
|
3899
3877
|
const ROWS$1 = 3;
|
|
3900
3878
|
const COLS$1 = 4;
|
|
3901
|
-
const
|
|
3879
|
+
const MONTH_ONLY_FORMAY = {
|
|
3902
3880
|
month: 'short'
|
|
3903
3881
|
};
|
|
3904
3882
|
const MonthCalendarTable = ({
|
|
3905
|
-
selectedDate,
|
|
3883
|
+
selectedDate: selected,
|
|
3906
3884
|
min,
|
|
3907
3885
|
max,
|
|
3908
3886
|
viewYear,
|
|
@@ -3912,39 +3890,19 @@ const MonthCalendarTable = ({
|
|
|
3912
3890
|
const {
|
|
3913
3891
|
locale
|
|
3914
3892
|
} = reactIntl.useIntl();
|
|
3915
|
-
const getLink = month => {
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
onClick: onSelect
|
|
3925
|
-
});
|
|
3926
|
-
};
|
|
3893
|
+
const getLink = month => /*#__PURE__*/jsxRuntime.jsx(TableLink$1, {
|
|
3894
|
+
item: month,
|
|
3895
|
+
type: "month",
|
|
3896
|
+
title: formatting.formatDate(new Date(viewYear, month), locale, MONTH_ONLY_FORMAY),
|
|
3897
|
+
active: !!(selected && month === selected.getMonth() && viewYear === selected.getFullYear()),
|
|
3898
|
+
disabled: isDisabled(month),
|
|
3899
|
+
today: viewYear === new Date().getFullYear() && month === new Date().getMonth(),
|
|
3900
|
+
onClick: onSelect
|
|
3901
|
+
});
|
|
3927
3902
|
const isDisabled = month => {
|
|
3928
3903
|
const date = new Date(viewYear, month);
|
|
3929
3904
|
return !!(min && date < new Date(min.getFullYear(), min.getMonth()) || max && date > new Date(max.getFullYear(), max.getMonth()));
|
|
3930
3905
|
};
|
|
3931
|
-
const months = [...new Array(ROWS$1 * COLS$1)].map((_, index) => index);
|
|
3932
|
-
const autofocusMonth = (() => {
|
|
3933
|
-
let activeMonth = null;
|
|
3934
|
-
let lowestNonDisabledMonth = null;
|
|
3935
|
-
for (const month of months) {
|
|
3936
|
-
if (selectedDate && month === selectedDate.getMonth()) {
|
|
3937
|
-
activeMonth = month;
|
|
3938
|
-
}
|
|
3939
|
-
if (!isDisabled(month) && lowestNonDisabledMonth === null) {
|
|
3940
|
-
lowestNonDisabledMonth = month;
|
|
3941
|
-
}
|
|
3942
|
-
if (activeMonth !== null) {
|
|
3943
|
-
break;
|
|
3944
|
-
}
|
|
3945
|
-
}
|
|
3946
|
-
return activeMonth || lowestNonDisabledMonth;
|
|
3947
|
-
})();
|
|
3948
3906
|
return /*#__PURE__*/jsxRuntime.jsxs("table", {
|
|
3949
3907
|
className: "table table-condensed table-bordered tw-date-lookup-calendar np-text-body-default-bold m-b-0",
|
|
3950
3908
|
children: [/*#__PURE__*/jsxRuntime.jsx("thead", {
|
|
@@ -4063,38 +4021,15 @@ const YearCalendarTable = ({
|
|
|
4063
4021
|
locale
|
|
4064
4022
|
} = reactIntl.useIntl();
|
|
4065
4023
|
const startYear = viewYear - viewYear % 20;
|
|
4066
|
-
const getLink = year => {
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
onClick: onSelect
|
|
4076
|
-
});
|
|
4077
|
-
};
|
|
4078
|
-
const isDisabled = year => {
|
|
4079
|
-
return !!(min && year < min.getFullYear() || max && year > max.getFullYear());
|
|
4080
|
-
};
|
|
4081
|
-
const years = [...new Array(ROWS * COLS)].map((_, index) => startYear + index);
|
|
4082
|
-
const autofocusYear = (() => {
|
|
4083
|
-
let activeYear = null;
|
|
4084
|
-
let lowestNonDisabledYear = null;
|
|
4085
|
-
for (const year of years) {
|
|
4086
|
-
if (selectedDate && year === selectedDate.getFullYear()) {
|
|
4087
|
-
activeYear = year;
|
|
4088
|
-
}
|
|
4089
|
-
if (!isDisabled(year) && lowestNonDisabledYear === null) {
|
|
4090
|
-
lowestNonDisabledYear = year;
|
|
4091
|
-
}
|
|
4092
|
-
if (activeYear !== null) {
|
|
4093
|
-
break;
|
|
4094
|
-
}
|
|
4095
|
-
}
|
|
4096
|
-
return activeYear || lowestNonDisabledYear;
|
|
4097
|
-
})();
|
|
4024
|
+
const getLink = year => /*#__PURE__*/jsxRuntime.jsx(TableLink$1, {
|
|
4025
|
+
item: year,
|
|
4026
|
+
type: "year",
|
|
4027
|
+
title: formatting.formatDate(new Date(year, 0), locale, YEAR_ONLY_FORMAT),
|
|
4028
|
+
active: !!(selectedDate && year === selectedDate.getFullYear()),
|
|
4029
|
+
disabled: !!(min && year < min.getFullYear() || max && year > max.getFullYear()),
|
|
4030
|
+
today: year === new Date().getFullYear(),
|
|
4031
|
+
onClick: onSelect
|
|
4032
|
+
});
|
|
4098
4033
|
return /*#__PURE__*/jsxRuntime.jsxs("table", {
|
|
4099
4034
|
className: "table table-condensed table-bordered tw-date-lookup-calendar m-b-0",
|
|
4100
4035
|
children: [/*#__PURE__*/jsxRuntime.jsx("thead", {
|
|
@@ -6195,7 +6130,8 @@ const Info = ({
|
|
|
6195
6130
|
presentation = exports.InfoPresentation.POPOVER,
|
|
6196
6131
|
size = exports.Size.SMALL,
|
|
6197
6132
|
title = undefined,
|
|
6198
|
-
'aria-label': ariaLabel
|
|
6133
|
+
'aria-label': ariaLabel,
|
|
6134
|
+
preferredPlacement = exports.Position.BOTTOM
|
|
6199
6135
|
}) => {
|
|
6200
6136
|
const [open, setOpen] = React.useState(false);
|
|
6201
6137
|
const isModal = presentation === exports.InfoPresentation.MODAL;
|
|
@@ -6230,7 +6166,7 @@ const Info = ({
|
|
|
6230
6166
|
})]
|
|
6231
6167
|
}) : /*#__PURE__*/jsxRuntime.jsx(Popover$2, {
|
|
6232
6168
|
content: content,
|
|
6233
|
-
preferredPlacement:
|
|
6169
|
+
preferredPlacement: preferredPlacement,
|
|
6234
6170
|
title: title,
|
|
6235
6171
|
children: /*#__PURE__*/jsxRuntime.jsx("button", {
|
|
6236
6172
|
type: "button",
|