@transferwise/components 46.27.0 → 46.28.0
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/i18n/th.json +2 -2
- package/build/index.js +327 -630
- package/build/index.js.map +1 -1
- package/build/index.mjs +328 -631
- package/build/index.mjs.map +1 -1
- package/build/types/alert/Alert.d.ts +47 -58
- package/build/types/alert/Alert.d.ts.map +1 -1
- package/build/types/alert/index.d.ts +2 -1
- package/build/types/alert/index.d.ts.map +1 -1
- package/build/types/button/Button.d.ts +7 -9
- package/build/types/button/Button.d.ts.map +1 -1
- package/build/types/common/dateUtils/isWithinRange/isWithinRange.d.ts +1 -1
- package/build/types/common/dateUtils/isWithinRange/isWithinRange.d.ts.map +1 -1
- package/build/types/common/dateUtils/moveToWithinRange/moveToWithinRange.d.ts +1 -1
- package/build/types/common/dateUtils/moveToWithinRange/moveToWithinRange.d.ts.map +1 -1
- package/build/types/common/propsValues/sentiment.d.ts +0 -1
- package/build/types/common/propsValues/sentiment.d.ts.map +1 -1
- package/build/types/dateLookup/DateLookup.d.ts +75 -28
- package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
- package/build/types/dateLookup/DateLookup.messages.d.ts +42 -63
- package/build/types/dateLookup/DateLookup.messages.d.ts.map +1 -1
- package/build/types/dateLookup/dateHeader/DateHeader.d.ts +9 -22
- package/build/types/dateLookup/dateHeader/DateHeader.d.ts.map +1 -1
- package/build/types/dateLookup/dateHeader/index.d.ts +1 -1
- package/build/types/dateLookup/dateHeader/index.d.ts.map +1 -1
- package/build/types/dateLookup/dateTrigger/DateTrigger.d.ts +13 -31
- package/build/types/dateLookup/dateTrigger/DateTrigger.d.ts.map +1 -1
- package/build/types/dateLookup/dateTrigger/index.d.ts +1 -1
- package/build/types/dateLookup/dateTrigger/index.d.ts.map +1 -1
- package/build/types/dateLookup/dayCalendar/DayCalendar.d.ts +19 -2
- package/build/types/dateLookup/dayCalendar/DayCalendar.d.ts.map +1 -1
- package/build/types/dateLookup/dayCalendar/index.d.ts +1 -1
- package/build/types/dateLookup/dayCalendar/index.d.ts.map +1 -1
- package/build/types/dateLookup/dayCalendar/table/DayCalendarTable.d.ts +12 -2
- package/build/types/dateLookup/dayCalendar/table/DayCalendarTable.d.ts.map +1 -1
- package/build/types/dateLookup/dayCalendar/table/index.d.ts +1 -1
- package/build/types/dateLookup/dayCalendar/table/index.d.ts.map +1 -1
- package/build/types/dateLookup/getStartOfDay/getStartOfDay.d.ts +1 -1
- package/build/types/dateLookup/getStartOfDay/getStartOfDay.d.ts.map +1 -1
- package/build/types/dateLookup/getStartOfDay/index.d.ts +1 -1
- package/build/types/dateLookup/getStartOfDay/index.d.ts.map +1 -1
- package/build/types/dateLookup/index.d.ts +2 -1
- package/build/types/dateLookup/index.d.ts.map +1 -1
- package/build/types/dateLookup/monthCalendar/MonthCalendar.d.ts +17 -2
- package/build/types/dateLookup/monthCalendar/MonthCalendar.d.ts.map +1 -1
- package/build/types/dateLookup/monthCalendar/index.d.ts +1 -1
- package/build/types/dateLookup/monthCalendar/index.d.ts.map +1 -1
- package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts +10 -26
- package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts.map +1 -1
- package/build/types/dateLookup/monthCalendar/table/index.d.ts +1 -1
- package/build/types/dateLookup/monthCalendar/table/index.d.ts.map +1 -1
- package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts +15 -2
- package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts.map +1 -1
- package/build/types/dateLookup/yearCalendar/index.d.ts +1 -1
- package/build/types/dateLookup/yearCalendar/index.d.ts.map +1 -1
- package/build/types/dateLookup/yearCalendar/table/YearCalendarTable.d.ts +10 -26
- package/build/types/dateLookup/yearCalendar/table/YearCalendarTable.d.ts.map +1 -1
- package/build/types/dateLookup/yearCalendar/table/index.d.ts +1 -1
- package/build/types/dateLookup/yearCalendar/table/index.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/inlineAlert/InlineAlert.d.ts +2 -4
- package/build/types/inlineAlert/InlineAlert.d.ts.map +1 -1
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/build/types/inputs/_BottomSheet.d.ts.map +1 -1
- package/build/types/inputs/_Popover.d.ts.map +1 -1
- package/build/types/statusIcon/StatusIcon.d.ts +1 -1
- package/build/types/statusIcon/StatusIcon.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/alert/{Alert.spec.js → Alert.spec.tsx} +43 -40
- package/src/alert/Alert.story.tsx +1 -2
- package/src/alert/Alert.tsx +218 -0
- package/src/alert/index.ts +2 -0
- package/src/button/Button.tsx +6 -10
- package/src/common/dateUtils/isWithinRange/isWithinRange.spec.ts +21 -0
- package/src/common/dateUtils/isWithinRange/isWithinRange.ts +2 -2
- package/src/common/dateUtils/moveToWithinRange/moveToWithinRange.ts +8 -4
- package/src/common/propsValues/sentiment.ts +0 -10
- package/src/dateLookup/DateLookup.state.spec.js +7 -0
- package/src/dateLookup/{DateLookup.story.js → DateLookup.story.tsx} +13 -14
- package/src/dateLookup/DateLookup.tests.story.tsx +70 -0
- package/src/dateLookup/{DateLookup.js → DateLookup.tsx} +115 -81
- package/src/dateLookup/dateHeader/{DateHeader.js → DateHeader.tsx} +15 -15
- package/src/dateLookup/dateTrigger/DateTrigger.spec.js +0 -22
- package/src/dateLookup/dateTrigger/{DateTrigger.js → DateTrigger.tsx} +15 -32
- package/src/dateLookup/dayCalendar/{DayCalendar.js → DayCalendar.tsx} +14 -21
- package/src/dateLookup/dayCalendar/table/{DayCalendarTable.js → DayCalendarTable.tsx} +26 -37
- package/src/dateLookup/getStartOfDay/{getStartOfDay.js → getStartOfDay.tsx} +1 -1
- package/src/dateLookup/index.ts +2 -0
- package/src/dateLookup/monthCalendar/{MonthCalendar.js → MonthCalendar.tsx} +19 -22
- package/src/dateLookup/monthCalendar/table/{MonthCalendarTable.js → MonthCalendarTable.tsx} +31 -30
- package/src/dateLookup/yearCalendar/{YearCalendar.js → YearCalendar.tsx} +18 -21
- package/src/dateLookup/yearCalendar/table/{YearCalendarTable.js → YearCalendarTable.tsx} +26 -28
- package/src/i18n/th.json +2 -2
- package/src/index.ts +2 -1
- package/src/inlineAlert/InlineAlert.spec.tsx +0 -7
- package/src/inlineAlert/InlineAlert.tsx +19 -47
- package/src/inputs/InputGroup.tsx +3 -3
- package/src/inputs/SelectInput.tsx +1 -0
- package/src/inputs/_BottomSheet.tsx +44 -54
- package/src/inputs/_Popover.tsx +20 -23
- package/src/statusIcon/StatusIcon.tsx +14 -14
- package/build/types/alert/withArrow/alertArrowPositions.d.ts +0 -9
- package/build/types/alert/withArrow/alertArrowPositions.d.ts.map +0 -1
- package/build/types/alert/withArrow/index.d.ts +0 -3
- package/build/types/alert/withArrow/index.d.ts.map +0 -1
- package/build/types/alert/withArrow/withArrow.d.ts +0 -11
- package/build/types/alert/withArrow/withArrow.d.ts.map +0 -1
- package/src/alert/Alert.js +0 -196
- package/src/alert/index.js +0 -1
- package/src/alert/withArrow/alertArrowPositions.ts +0 -9
- package/src/alert/withArrow/index.js +0 -2
- package/src/alert/withArrow/withArrow.js +0 -50
- package/src/alert/withArrow/withArrow.spec.js +0 -51
- package/src/dateLookup/index.js +0 -1
- /package/src/dateLookup/{DateLookup.messages.js → DateLookup.messages.ts} +0 -0
- /package/src/dateLookup/dateHeader/{index.js → index.ts} +0 -0
- /package/src/dateLookup/dateTrigger/{index.js → index.ts} +0 -0
- /package/src/dateLookup/dayCalendar/{index.js → index.ts} +0 -0
- /package/src/dateLookup/dayCalendar/table/{index.js → index.ts} +0 -0
- /package/src/dateLookup/getStartOfDay/{index.js → index.ts} +0 -0
- /package/src/dateLookup/monthCalendar/{index.js → index.ts} +0 -0
- /package/src/dateLookup/monthCalendar/table/{index.js → index.ts} +0 -0
- /package/src/dateLookup/yearCalendar/{index.js → index.ts} +0 -0
- /package/src/dateLookup/yearCalendar/table/{index.js → index.ts} +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// getStartOfDay(new Date('1995-01-01')) in Los Angeles returns 31 Dec 1994, but in
|
|
3
3
|
// in Singapore it is 1 Jan 1995.
|
|
4
4
|
// You might want to use/implement `getUTCStartOfDay` if you want it to be 1995 in any timezone
|
|
5
|
-
export function getStartOfDay(date) {
|
|
5
|
+
export function getStartOfDay(date: Date | null) {
|
|
6
6
|
if (!date) {
|
|
7
7
|
return null;
|
|
8
8
|
}
|
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import { formatDate } from '@transferwise/formatting';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
2
|
import { PureComponent } from 'react';
|
|
4
|
-
import { injectIntl } from 'react-intl';
|
|
3
|
+
import { injectIntl, WrappedComponentProps } from 'react-intl';
|
|
5
4
|
|
|
6
5
|
import messages from '../DateLookup.messages';
|
|
7
6
|
import DateHeader from '../dateHeader';
|
|
8
7
|
|
|
9
8
|
import MonthCalendarTable from './table';
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
interface MonthCalendarProps extends WrappedComponentProps {
|
|
11
|
+
selectedDate: Date | null;
|
|
12
|
+
min: Date | null;
|
|
13
|
+
max: Date | null;
|
|
14
|
+
viewYear: number;
|
|
15
|
+
placeholder: string;
|
|
16
|
+
onSelect: () => void;
|
|
17
|
+
onLabelClick: () => void;
|
|
18
|
+
onViewDateUpdate: (date: { year?: number; month?: number }) => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
class MonthCalendar extends PureComponent<MonthCalendarProps> {
|
|
22
|
+
onMonthSelect = (month: number) => {
|
|
13
23
|
this.props.onViewDateUpdate({ month });
|
|
14
24
|
this.props.onSelect();
|
|
15
25
|
};
|
|
@@ -42,7 +52,11 @@ class MonthCalendar extends PureComponent {
|
|
|
42
52
|
onNextClick={this.selectNextYear}
|
|
43
53
|
/>
|
|
44
54
|
<MonthCalendarTable
|
|
45
|
-
{
|
|
55
|
+
selectedDate={selectedDate}
|
|
56
|
+
min={min}
|
|
57
|
+
max={max}
|
|
58
|
+
viewYear={viewYear}
|
|
59
|
+
placeholder={placeholder}
|
|
46
60
|
onSelect={this.onMonthSelect}
|
|
47
61
|
/>
|
|
48
62
|
</>
|
|
@@ -50,21 +64,4 @@ class MonthCalendar extends PureComponent {
|
|
|
50
64
|
}
|
|
51
65
|
}
|
|
52
66
|
|
|
53
|
-
MonthCalendar.propTypes = {
|
|
54
|
-
selectedDate: PropTypes.instanceOf(Date),
|
|
55
|
-
min: PropTypes.instanceOf(Date),
|
|
56
|
-
max: PropTypes.instanceOf(Date),
|
|
57
|
-
viewYear: PropTypes.number.isRequired,
|
|
58
|
-
placeholder: PropTypes.string.isRequired,
|
|
59
|
-
onSelect: PropTypes.func.isRequired,
|
|
60
|
-
onLabelClick: PropTypes.func.isRequired,
|
|
61
|
-
onViewDateUpdate: PropTypes.func.isRequired,
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
MonthCalendar.defaultProps = {
|
|
65
|
-
selectedDate: null,
|
|
66
|
-
min: null,
|
|
67
|
-
max: null,
|
|
68
|
-
};
|
|
69
|
-
|
|
70
67
|
export default injectIntl(MonthCalendar);
|
|
@@ -1,17 +1,33 @@
|
|
|
1
1
|
import { formatDate } from '@transferwise/formatting';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
2
|
import { useIntl } from 'react-intl';
|
|
4
3
|
|
|
5
4
|
import { getFocusableTime } from '../../getFocusableTime/getFocusableTime';
|
|
6
5
|
import TableLink from '../../tableLink';
|
|
7
6
|
|
|
7
|
+
interface MonthCalendarTableProps {
|
|
8
|
+
selectedDate: Date | null;
|
|
9
|
+
min: Date | null;
|
|
10
|
+
max: Date | null;
|
|
11
|
+
viewYear: number;
|
|
12
|
+
placeholder: string;
|
|
13
|
+
onSelect: (date: number) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
const ROWS = 3;
|
|
9
17
|
const COLS = 4;
|
|
10
|
-
const MONTH_ONLY_FORMAT = { month: 'short' };
|
|
18
|
+
const MONTH_ONLY_FORMAT: Intl.DateTimeFormatOptions = { month: 'short' };
|
|
11
19
|
|
|
12
|
-
const MonthCalendarTable = ({
|
|
20
|
+
const MonthCalendarTable = ({
|
|
21
|
+
selectedDate,
|
|
22
|
+
min,
|
|
23
|
+
max,
|
|
24
|
+
viewYear,
|
|
25
|
+
placeholder,
|
|
26
|
+
onSelect,
|
|
27
|
+
}: MonthCalendarTableProps) => {
|
|
13
28
|
const { locale } = useIntl();
|
|
14
|
-
|
|
29
|
+
|
|
30
|
+
const getLink = (month: number) => {
|
|
15
31
|
return (
|
|
16
32
|
<TableLink
|
|
17
33
|
item={month}
|
|
@@ -26,17 +42,19 @@ const MonthCalendarTable = ({ selectedDate, min, max, viewYear, placeholder, onS
|
|
|
26
42
|
);
|
|
27
43
|
};
|
|
28
44
|
|
|
29
|
-
const isActive = (month) => {
|
|
30
|
-
return (
|
|
31
|
-
selectedDate &&
|
|
45
|
+
const isActive = (month: number) => {
|
|
46
|
+
return !!(
|
|
47
|
+
selectedDate &&
|
|
48
|
+
month === selectedDate.getMonth() &&
|
|
49
|
+
viewYear === selectedDate.getFullYear()
|
|
32
50
|
);
|
|
33
51
|
};
|
|
34
52
|
|
|
35
|
-
const isThisMonth = (month) => {
|
|
53
|
+
const isThisMonth = (month: number) => {
|
|
36
54
|
return viewYear === new Date().getFullYear() && month === new Date().getMonth();
|
|
37
55
|
};
|
|
38
56
|
|
|
39
|
-
const isDisabled = (month) => {
|
|
57
|
+
const isDisabled = (month: number) => {
|
|
40
58
|
const date = new Date(viewYear, month);
|
|
41
59
|
return !!(
|
|
42
60
|
(min && date < new Date(min.getFullYear(), min.getMonth())) ||
|
|
@@ -45,7 +63,7 @@ const MonthCalendarTable = ({ selectedDate, min, max, viewYear, placeholder, onS
|
|
|
45
63
|
};
|
|
46
64
|
|
|
47
65
|
const autofocusMonth = (() => {
|
|
48
|
-
const months =
|
|
66
|
+
const months = Array.from({ length: ROWS * COLS }, (_, index) => index);
|
|
49
67
|
return getFocusableTime({ isActive, isNow: isThisMonth, isDisabled, timeSpan: months });
|
|
50
68
|
})();
|
|
51
69
|
|
|
@@ -53,37 +71,20 @@ const MonthCalendarTable = ({ selectedDate, min, max, viewYear, placeholder, onS
|
|
|
53
71
|
<table className="table table-condensed table-bordered tw-date-lookup-calendar np-text-body-default-bold m-b-0">
|
|
54
72
|
<thead className="sr-only">
|
|
55
73
|
<tr>
|
|
56
|
-
<th colSpan=
|
|
74
|
+
<th colSpan={COLS}>{placeholder}</th>
|
|
57
75
|
</tr>
|
|
58
76
|
</thead>
|
|
59
77
|
<tbody>
|
|
60
|
-
{
|
|
61
|
-
{[...new Array(ROWS)].map((row, rowIndex) => (
|
|
78
|
+
{Array.from({ length: ROWS }, (_, rowIndex) => (
|
|
62
79
|
<tr key={rowIndex}>
|
|
63
|
-
{
|
|
80
|
+
{Array.from({ length: COLS }, (_, colIndex) => (
|
|
64
81
|
<td key={colIndex}>{getLink(rowIndex * COLS + colIndex)}</td>
|
|
65
82
|
))}
|
|
66
83
|
</tr>
|
|
67
84
|
))}
|
|
68
|
-
{/* eslint-enable react/no-array-index-key */}
|
|
69
85
|
</tbody>
|
|
70
86
|
</table>
|
|
71
87
|
);
|
|
72
88
|
};
|
|
73
89
|
|
|
74
|
-
MonthCalendarTable.propTypes = {
|
|
75
|
-
selectedDate: PropTypes.instanceOf(Date),
|
|
76
|
-
min: PropTypes.instanceOf(Date),
|
|
77
|
-
max: PropTypes.instanceOf(Date),
|
|
78
|
-
viewYear: PropTypes.number.isRequired,
|
|
79
|
-
placeholder: PropTypes.string.isRequired,
|
|
80
|
-
onSelect: PropTypes.func.isRequired,
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
MonthCalendarTable.defaultProps = {
|
|
84
|
-
selectedDate: null,
|
|
85
|
-
min: null,
|
|
86
|
-
max: null,
|
|
87
|
-
};
|
|
88
|
-
|
|
89
90
|
export default MonthCalendarTable;
|
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
1
|
import { PureComponent } from 'react';
|
|
3
|
-
import { injectIntl } from 'react-intl';
|
|
2
|
+
import { injectIntl, WrappedComponentProps } from 'react-intl';
|
|
4
3
|
|
|
5
4
|
import messages from '../DateLookup.messages';
|
|
6
5
|
import DateHeader from '../dateHeader';
|
|
7
6
|
|
|
8
7
|
import YearCalendarTable from './table';
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
interface YearCalendarProps extends WrappedComponentProps {
|
|
10
|
+
selectedDate: Date | null;
|
|
11
|
+
min: Date | null;
|
|
12
|
+
max: Date | null;
|
|
13
|
+
viewYear: number;
|
|
14
|
+
placeholder: string;
|
|
15
|
+
onSelect: () => void;
|
|
16
|
+
onViewDateUpdate: (date: { year: number }) => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
class YearCalendar extends PureComponent<YearCalendarProps> {
|
|
20
|
+
onYearSelect = (year: number) => {
|
|
12
21
|
this.props.onViewDateUpdate({ year });
|
|
13
22
|
this.props.onSelect();
|
|
14
23
|
};
|
|
@@ -38,7 +47,11 @@ class YearCalendar extends PureComponent {
|
|
|
38
47
|
onNextClick={this.selectNextYears}
|
|
39
48
|
/>
|
|
40
49
|
<YearCalendarTable
|
|
41
|
-
{
|
|
50
|
+
selectedDate={selectedDate}
|
|
51
|
+
min={min}
|
|
52
|
+
max={max}
|
|
53
|
+
viewYear={viewYear}
|
|
54
|
+
placeholder={placeholder}
|
|
42
55
|
onSelect={this.onYearSelect}
|
|
43
56
|
/>
|
|
44
57
|
</>
|
|
@@ -46,20 +59,4 @@ class YearCalendar extends PureComponent {
|
|
|
46
59
|
}
|
|
47
60
|
}
|
|
48
61
|
|
|
49
|
-
YearCalendar.propTypes = {
|
|
50
|
-
selectedDate: PropTypes.instanceOf(Date),
|
|
51
|
-
min: PropTypes.instanceOf(Date),
|
|
52
|
-
max: PropTypes.instanceOf(Date),
|
|
53
|
-
viewYear: PropTypes.number.isRequired,
|
|
54
|
-
placeholder: PropTypes.string.isRequired,
|
|
55
|
-
onSelect: PropTypes.func.isRequired,
|
|
56
|
-
onViewDateUpdate: PropTypes.func.isRequired,
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
YearCalendar.defaultProps = {
|
|
60
|
-
selectedDate: null,
|
|
61
|
-
min: null,
|
|
62
|
-
max: null,
|
|
63
|
-
};
|
|
64
|
-
|
|
65
62
|
export default injectIntl(YearCalendar);
|
|
@@ -1,18 +1,33 @@
|
|
|
1
1
|
import { formatDate } from '@transferwise/formatting';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
2
|
import { useIntl } from 'react-intl';
|
|
4
3
|
|
|
5
4
|
import { getFocusableTime } from '../../getFocusableTime/getFocusableTime';
|
|
6
5
|
import TableLink from '../../tableLink';
|
|
7
6
|
|
|
7
|
+
interface YearCalendarTableProps {
|
|
8
|
+
selectedDate: Date | null;
|
|
9
|
+
min: Date | null;
|
|
10
|
+
max: Date | null;
|
|
11
|
+
viewYear: number;
|
|
12
|
+
placeholder: string;
|
|
13
|
+
onSelect: (year: number) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
const ROWS = 5;
|
|
9
17
|
const COLS = 4;
|
|
10
|
-
const YEAR_ONLY_FORMAT = { year: 'numeric' };
|
|
18
|
+
const YEAR_ONLY_FORMAT: Intl.DateTimeFormatOptions = { year: 'numeric' };
|
|
11
19
|
|
|
12
|
-
const YearCalendarTable = ({
|
|
20
|
+
const YearCalendarTable = ({
|
|
21
|
+
selectedDate,
|
|
22
|
+
min,
|
|
23
|
+
max,
|
|
24
|
+
viewYear,
|
|
25
|
+
placeholder,
|
|
26
|
+
onSelect,
|
|
27
|
+
}: YearCalendarTableProps) => {
|
|
13
28
|
const { locale } = useIntl();
|
|
14
29
|
const startYear = viewYear - (viewYear % 20);
|
|
15
|
-
const getLink = (year) => {
|
|
30
|
+
const getLink = (year: number) => {
|
|
16
31
|
return (
|
|
17
32
|
<TableLink
|
|
18
33
|
item={year}
|
|
@@ -27,20 +42,20 @@ const YearCalendarTable = ({ selectedDate, min, max, viewYear, placeholder, onSe
|
|
|
27
42
|
);
|
|
28
43
|
};
|
|
29
44
|
|
|
30
|
-
const isActive = (year) => {
|
|
45
|
+
const isActive = (year: number) => {
|
|
31
46
|
return !!(selectedDate && year === selectedDate.getFullYear());
|
|
32
47
|
};
|
|
33
48
|
|
|
34
|
-
const isThisYear = (year) => {
|
|
49
|
+
const isThisYear = (year: number) => {
|
|
35
50
|
return year === new Date().getFullYear();
|
|
36
51
|
};
|
|
37
52
|
|
|
38
|
-
const isDisabled = (year) => {
|
|
53
|
+
const isDisabled = (year: number) => {
|
|
39
54
|
return !!((min && year < min.getFullYear()) || (max && year > max.getFullYear()));
|
|
40
55
|
};
|
|
41
56
|
|
|
42
57
|
const autofocusYear = (() => {
|
|
43
|
-
const years =
|
|
58
|
+
const years = Array.from({ length: ROWS * COLS }, (_, index) => startYear + index);
|
|
44
59
|
return getFocusableTime({ isActive, isNow: isThisYear, isDisabled, timeSpan: years });
|
|
45
60
|
})();
|
|
46
61
|
|
|
@@ -48,37 +63,20 @@ const YearCalendarTable = ({ selectedDate, min, max, viewYear, placeholder, onSe
|
|
|
48
63
|
<table className="table table-condensed table-bordered tw-date-lookup-calendar m-b-0">
|
|
49
64
|
<thead className="sr-only">
|
|
50
65
|
<tr>
|
|
51
|
-
<th colSpan=
|
|
66
|
+
<th colSpan={COLS}>{placeholder}</th>
|
|
52
67
|
</tr>
|
|
53
68
|
</thead>
|
|
54
69
|
<tbody>
|
|
55
|
-
{
|
|
56
|
-
{[...new Array(ROWS)].map((row, rowIndex) => (
|
|
70
|
+
{Array.from({ length: ROWS }, (_, rowIndex) => (
|
|
57
71
|
<tr key={rowIndex}>
|
|
58
|
-
{
|
|
72
|
+
{Array.from({ length: COLS }, (_, colIndex) => (
|
|
59
73
|
<td key={colIndex}>{getLink(startYear + rowIndex * COLS + colIndex)}</td>
|
|
60
74
|
))}
|
|
61
75
|
</tr>
|
|
62
76
|
))}
|
|
63
|
-
{/* eslint-enable react/no-array-index-key */}
|
|
64
77
|
</tbody>
|
|
65
78
|
</table>
|
|
66
79
|
);
|
|
67
80
|
};
|
|
68
81
|
|
|
69
|
-
YearCalendarTable.propTypes = {
|
|
70
|
-
selectedDate: PropTypes.instanceOf(Date),
|
|
71
|
-
min: PropTypes.instanceOf(Date),
|
|
72
|
-
max: PropTypes.instanceOf(Date),
|
|
73
|
-
viewYear: PropTypes.number.isRequired,
|
|
74
|
-
placeholder: PropTypes.string.isRequired,
|
|
75
|
-
onSelect: PropTypes.func.isRequired,
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
YearCalendarTable.defaultProps = {
|
|
79
|
-
selectedDate: null,
|
|
80
|
-
min: null,
|
|
81
|
-
max: null,
|
|
82
|
-
};
|
|
83
|
-
|
|
84
82
|
export default YearCalendarTable;
|
package/src/i18n/th.json
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
"neptune.ClearButton.ariaLabel": "ล้าง",
|
|
5
5
|
"neptune.CloseButton.ariaLabel": "ปิด",
|
|
6
6
|
"neptune.DateInput.day.label": "วัน",
|
|
7
|
-
"neptune.DateInput.day.placeholder": "
|
|
7
|
+
"neptune.DateInput.day.placeholder": "วัน",
|
|
8
8
|
"neptune.DateInput.month.label": "เดือน",
|
|
9
9
|
"neptune.DateInput.year.label": "ปี",
|
|
10
|
-
"neptune.DateInput.year.placeholder": "
|
|
10
|
+
"neptune.DateInput.year.placeholder": "ปี",
|
|
11
11
|
"neptune.DateLookup.day": "วัน",
|
|
12
12
|
"neptune.DateLookup.goTo20YearView": "ไปที่มุมมอง 20 ปี",
|
|
13
13
|
"neptune.DateLookup.month": "เดือน",
|
package/src/index.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
export type { AccordionProps, AccordionItem } from './accordion';
|
|
5
5
|
export type { AvatarProps } from './avatar';
|
|
6
6
|
export type { ActionOptionProps } from './actionOption';
|
|
7
|
+
export type { AlertProps, AlertAction, AlertArrowPosition, AlertType } from './alert';
|
|
7
8
|
export type { BadgeProps } from './badge';
|
|
8
9
|
export type { CircularButtonProps } from './circularButton';
|
|
9
10
|
export type { DecisionProps } from './decision/Decision';
|
|
@@ -12,6 +13,7 @@ export type { InfoProps } from './info';
|
|
|
12
13
|
export type { SummaryProps } from './summary';
|
|
13
14
|
export type { InputProps } from './inputs/Input';
|
|
14
15
|
export type { DateInputProps } from './dateInput';
|
|
16
|
+
export type { DateLookupProps } from './dateLookup';
|
|
15
17
|
export type { InputWithDisplayFormatProps } from './inputWithDisplayFormat';
|
|
16
18
|
export type { InputGroupProps } from './inputs/InputGroup';
|
|
17
19
|
export type { LoaderProps } from './loader';
|
|
@@ -194,7 +196,6 @@ export { AvatarType } from './avatar';
|
|
|
194
196
|
export { InfoPresentation } from './info';
|
|
195
197
|
export { UploadStep } from './upload';
|
|
196
198
|
export { DecisionPresentation, DecisionType } from './decision';
|
|
197
|
-
export { AlertArrowPosition } from './alert/withArrow';
|
|
198
199
|
export { LogoType } from './logo';
|
|
199
200
|
export { FileType } from './common';
|
|
200
201
|
|
|
@@ -21,13 +21,6 @@ describe('InlineAlert', () => {
|
|
|
21
21
|
|
|
22
22
|
expect(component).toHaveClass('alert-neutral');
|
|
23
23
|
});
|
|
24
|
-
|
|
25
|
-
it('has a top left arrow', () => {
|
|
26
|
-
render(<InlineAlert>{message}</InlineAlert>);
|
|
27
|
-
const component = screen.getByRole('alert');
|
|
28
|
-
|
|
29
|
-
expect(component).toHaveClass('arrow');
|
|
30
|
-
});
|
|
31
24
|
});
|
|
32
25
|
|
|
33
26
|
describe('render with types', () => {
|
|
@@ -1,59 +1,31 @@
|
|
|
1
1
|
import { AlertCircle as AlertCircleIcon } from '@transferwise/icons';
|
|
2
|
-
import { useTheme } from '@wise/components-theming';
|
|
3
2
|
import classNames from 'classnames';
|
|
4
3
|
import { ReactNode } from 'react';
|
|
5
4
|
|
|
6
|
-
import withArrow, { AlertArrowPosition } from '../alert/withArrow';
|
|
7
5
|
import { Sentiment } from '../common';
|
|
8
|
-
import { SentimentString } from '../common/propsValues/sentiment';
|
|
9
6
|
|
|
10
7
|
export interface InlineAlertProps {
|
|
11
8
|
id?: string;
|
|
12
|
-
type?: Sentiment
|
|
9
|
+
type?: `${Sentiment}`;
|
|
13
10
|
className?: string;
|
|
14
11
|
children: ReactNode;
|
|
15
12
|
}
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const getAlertContents = ({
|
|
37
|
-
children,
|
|
38
|
-
className,
|
|
39
|
-
}: {
|
|
40
|
-
children: ReactNode;
|
|
41
|
-
className?: string;
|
|
42
|
-
}) => {
|
|
43
|
-
return (
|
|
44
|
-
<div
|
|
45
|
-
role="alert"
|
|
46
|
-
id={id}
|
|
47
|
-
className={classNames('alert alert-detach p-x-2 p-y-1', typeClass, className)}
|
|
48
|
-
>
|
|
49
|
-
{children}
|
|
50
|
-
</div>
|
|
51
|
-
);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const AlertWithArrow = withArrow(getAlertContents, AlertArrowPosition.TOP_LEFT);
|
|
55
|
-
|
|
56
|
-
return <AlertWithArrow {...{ id, type, className, children }} />;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export default InlineAlert;
|
|
14
|
+
export default function InlineAlert({
|
|
15
|
+
id,
|
|
16
|
+
type = 'neutral',
|
|
17
|
+
className,
|
|
18
|
+
children,
|
|
19
|
+
}: InlineAlertProps) {
|
|
20
|
+
const danger = type === 'negative' || type === 'error';
|
|
21
|
+
return (
|
|
22
|
+
<div
|
|
23
|
+
role="alert"
|
|
24
|
+
id={id}
|
|
25
|
+
className={classNames('alert alert-detach', `alert-${danger ? 'danger' : type}`, className)}
|
|
26
|
+
>
|
|
27
|
+
{danger && <AlertCircleIcon />}
|
|
28
|
+
<div>{children}</div>
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -107,9 +107,9 @@ function InputAddon({
|
|
|
107
107
|
const ref = useRef<HTMLSpanElement>(null);
|
|
108
108
|
useResizeObserver(ref, (entry) => {
|
|
109
109
|
// TODO: Remove fallback once most browsers support `borderBoxSize`
|
|
110
|
-
|
|
111
|
-
if (
|
|
112
|
-
setInputPadding(
|
|
110
|
+
const inlineSize = entry.borderBoxSize?.[0]?.inlineSize;
|
|
111
|
+
if (inlineSize != null) {
|
|
112
|
+
setInputPadding(inlineSize);
|
|
113
113
|
} else {
|
|
114
114
|
const targetStyle = getComputedStyle(entry.target);
|
|
115
115
|
setInputPadding(
|
|
@@ -12,7 +12,6 @@ import classNames from 'classnames';
|
|
|
12
12
|
import { useState } from 'react';
|
|
13
13
|
|
|
14
14
|
import { CloseButton } from '../common/closeButton';
|
|
15
|
-
import FocusBoundary from '../common/focusBoundary/FocusBoundary';
|
|
16
15
|
import { PreventScroll } from '../common/preventScroll/PreventScroll';
|
|
17
16
|
import { Size } from '../common/propsValues/size';
|
|
18
17
|
|
|
@@ -81,65 +80,56 @@ export function BottomSheet({
|
|
|
81
80
|
}}
|
|
82
81
|
afterLeave={onCloseEnd}
|
|
83
82
|
>
|
|
84
|
-
<
|
|
83
|
+
<Transition.Child
|
|
84
|
+
enter="np-bottom-sheet-v2-backdrop-container--enter"
|
|
85
|
+
enterFrom="np-bottom-sheet-v2-backdrop-container--enter-from"
|
|
86
|
+
leave="np-bottom-sheet-v2-backdrop-container--leave"
|
|
87
|
+
leaveTo="np-bottom-sheet-v2-backdrop-container--leave-to"
|
|
88
|
+
>
|
|
89
|
+
<div className="np-bottom-sheet-v2-backdrop" />
|
|
90
|
+
</Transition.Child>
|
|
91
|
+
|
|
92
|
+
<div className="np-bottom-sheet-v2">
|
|
85
93
|
<Transition.Child
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
94
|
+
className="np-bottom-sheet-v2-content"
|
|
95
|
+
enter="np-bottom-sheet-v2-content--enter"
|
|
96
|
+
enterFrom="np-bottom-sheet-v2-content--enter-from"
|
|
97
|
+
leave="np-bottom-sheet-v2-content--leave"
|
|
98
|
+
leaveTo="np-bottom-sheet-v2-content--leave-to"
|
|
90
99
|
>
|
|
91
|
-
<
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
enter="np-bottom-sheet-v2-content--enter"
|
|
98
|
-
enterFrom="np-bottom-sheet-v2-content--enter-from"
|
|
99
|
-
leave="np-bottom-sheet-v2-content--leave"
|
|
100
|
-
leaveTo="np-bottom-sheet-v2-content--leave-to"
|
|
101
|
-
>
|
|
102
|
-
<FloatingFocusManager
|
|
103
|
-
context={context}
|
|
104
|
-
initialFocus={initialFocusRef}
|
|
105
|
-
guards={false}
|
|
106
|
-
modal={false}
|
|
100
|
+
<FloatingFocusManager context={context} initialFocus={initialFocusRef}>
|
|
101
|
+
<div
|
|
102
|
+
key={floatingKey} // Force inner state invalidation on open
|
|
103
|
+
ref={refs.setFloating}
|
|
104
|
+
className="np-bottom-sheet-v2-content-inner-container"
|
|
105
|
+
{...getFloatingProps()}
|
|
107
106
|
>
|
|
107
|
+
<div className="np-bottom-sheet-v2-header">
|
|
108
|
+
<CloseButton
|
|
109
|
+
size={Size.SMALL}
|
|
110
|
+
onClick={() => {
|
|
111
|
+
onClose?.();
|
|
112
|
+
}}
|
|
113
|
+
/>
|
|
114
|
+
</div>
|
|
108
115
|
<div
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
116
|
+
className={classNames(
|
|
117
|
+
'np-bottom-sheet-v2-content-inner',
|
|
118
|
+
title && 'np-bottom-sheet-v2-content-inner--has-title',
|
|
119
|
+
{
|
|
120
|
+
'np-bottom-sheet-v2-content-inner--padding-md': padding === 'md',
|
|
121
|
+
},
|
|
122
|
+
)}
|
|
113
123
|
>
|
|
114
|
-
|
|
115
|
-
<
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
onClose?.();
|
|
119
|
-
}}
|
|
120
|
-
/>
|
|
121
|
-
</div>
|
|
122
|
-
<div
|
|
123
|
-
className={classNames(
|
|
124
|
-
'np-bottom-sheet-v2-content-inner',
|
|
125
|
-
title && 'np-bottom-sheet-v2-content-inner--has-title',
|
|
126
|
-
{
|
|
127
|
-
'np-bottom-sheet-v2-content-inner--padding-md': padding === 'md',
|
|
128
|
-
},
|
|
129
|
-
)}
|
|
130
|
-
>
|
|
131
|
-
{title ? (
|
|
132
|
-
<h2 className="np-bottom-sheet-v2-title np-text-title-body">{title}</h2>
|
|
133
|
-
) : null}
|
|
134
|
-
<div className="np-bottom-sheet-v2-body np-text-body-default">
|
|
135
|
-
{children}
|
|
136
|
-
</div>
|
|
137
|
-
</div>
|
|
124
|
+
{title ? (
|
|
125
|
+
<h2 className="np-bottom-sheet-v2-title np-text-title-body">{title}</h2>
|
|
126
|
+
) : null}
|
|
127
|
+
<div className="np-bottom-sheet-v2-body np-text-body-default">{children}</div>
|
|
138
128
|
</div>
|
|
139
|
-
</
|
|
140
|
-
</
|
|
141
|
-
</
|
|
142
|
-
</
|
|
129
|
+
</div>
|
|
130
|
+
</FloatingFocusManager>
|
|
131
|
+
</Transition.Child>
|
|
132
|
+
</div>
|
|
143
133
|
</Transition>
|
|
144
134
|
</ThemeProvider>
|
|
145
135
|
</FloatingPortal>
|