@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.
Files changed (125) hide show
  1. package/build/i18n/th.json +2 -2
  2. package/build/index.js +327 -630
  3. package/build/index.js.map +1 -1
  4. package/build/index.mjs +328 -631
  5. package/build/index.mjs.map +1 -1
  6. package/build/types/alert/Alert.d.ts +47 -58
  7. package/build/types/alert/Alert.d.ts.map +1 -1
  8. package/build/types/alert/index.d.ts +2 -1
  9. package/build/types/alert/index.d.ts.map +1 -1
  10. package/build/types/button/Button.d.ts +7 -9
  11. package/build/types/button/Button.d.ts.map +1 -1
  12. package/build/types/common/dateUtils/isWithinRange/isWithinRange.d.ts +1 -1
  13. package/build/types/common/dateUtils/isWithinRange/isWithinRange.d.ts.map +1 -1
  14. package/build/types/common/dateUtils/moveToWithinRange/moveToWithinRange.d.ts +1 -1
  15. package/build/types/common/dateUtils/moveToWithinRange/moveToWithinRange.d.ts.map +1 -1
  16. package/build/types/common/propsValues/sentiment.d.ts +0 -1
  17. package/build/types/common/propsValues/sentiment.d.ts.map +1 -1
  18. package/build/types/dateLookup/DateLookup.d.ts +75 -28
  19. package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
  20. package/build/types/dateLookup/DateLookup.messages.d.ts +42 -63
  21. package/build/types/dateLookup/DateLookup.messages.d.ts.map +1 -1
  22. package/build/types/dateLookup/dateHeader/DateHeader.d.ts +9 -22
  23. package/build/types/dateLookup/dateHeader/DateHeader.d.ts.map +1 -1
  24. package/build/types/dateLookup/dateHeader/index.d.ts +1 -1
  25. package/build/types/dateLookup/dateHeader/index.d.ts.map +1 -1
  26. package/build/types/dateLookup/dateTrigger/DateTrigger.d.ts +13 -31
  27. package/build/types/dateLookup/dateTrigger/DateTrigger.d.ts.map +1 -1
  28. package/build/types/dateLookup/dateTrigger/index.d.ts +1 -1
  29. package/build/types/dateLookup/dateTrigger/index.d.ts.map +1 -1
  30. package/build/types/dateLookup/dayCalendar/DayCalendar.d.ts +19 -2
  31. package/build/types/dateLookup/dayCalendar/DayCalendar.d.ts.map +1 -1
  32. package/build/types/dateLookup/dayCalendar/index.d.ts +1 -1
  33. package/build/types/dateLookup/dayCalendar/index.d.ts.map +1 -1
  34. package/build/types/dateLookup/dayCalendar/table/DayCalendarTable.d.ts +12 -2
  35. package/build/types/dateLookup/dayCalendar/table/DayCalendarTable.d.ts.map +1 -1
  36. package/build/types/dateLookup/dayCalendar/table/index.d.ts +1 -1
  37. package/build/types/dateLookup/dayCalendar/table/index.d.ts.map +1 -1
  38. package/build/types/dateLookup/getStartOfDay/getStartOfDay.d.ts +1 -1
  39. package/build/types/dateLookup/getStartOfDay/getStartOfDay.d.ts.map +1 -1
  40. package/build/types/dateLookup/getStartOfDay/index.d.ts +1 -1
  41. package/build/types/dateLookup/getStartOfDay/index.d.ts.map +1 -1
  42. package/build/types/dateLookup/index.d.ts +2 -1
  43. package/build/types/dateLookup/index.d.ts.map +1 -1
  44. package/build/types/dateLookup/monthCalendar/MonthCalendar.d.ts +17 -2
  45. package/build/types/dateLookup/monthCalendar/MonthCalendar.d.ts.map +1 -1
  46. package/build/types/dateLookup/monthCalendar/index.d.ts +1 -1
  47. package/build/types/dateLookup/monthCalendar/index.d.ts.map +1 -1
  48. package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts +10 -26
  49. package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts.map +1 -1
  50. package/build/types/dateLookup/monthCalendar/table/index.d.ts +1 -1
  51. package/build/types/dateLookup/monthCalendar/table/index.d.ts.map +1 -1
  52. package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts +15 -2
  53. package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts.map +1 -1
  54. package/build/types/dateLookup/yearCalendar/index.d.ts +1 -1
  55. package/build/types/dateLookup/yearCalendar/index.d.ts.map +1 -1
  56. package/build/types/dateLookup/yearCalendar/table/YearCalendarTable.d.ts +10 -26
  57. package/build/types/dateLookup/yearCalendar/table/YearCalendarTable.d.ts.map +1 -1
  58. package/build/types/dateLookup/yearCalendar/table/index.d.ts +1 -1
  59. package/build/types/dateLookup/yearCalendar/table/index.d.ts.map +1 -1
  60. package/build/types/index.d.ts +2 -1
  61. package/build/types/index.d.ts.map +1 -1
  62. package/build/types/inlineAlert/InlineAlert.d.ts +2 -4
  63. package/build/types/inlineAlert/InlineAlert.d.ts.map +1 -1
  64. package/build/types/inputs/SelectInput.d.ts.map +1 -1
  65. package/build/types/inputs/_BottomSheet.d.ts.map +1 -1
  66. package/build/types/inputs/_Popover.d.ts.map +1 -1
  67. package/build/types/statusIcon/StatusIcon.d.ts +1 -1
  68. package/build/types/statusIcon/StatusIcon.d.ts.map +1 -1
  69. package/package.json +1 -1
  70. package/src/alert/{Alert.spec.js → Alert.spec.tsx} +43 -40
  71. package/src/alert/Alert.story.tsx +1 -2
  72. package/src/alert/Alert.tsx +218 -0
  73. package/src/alert/index.ts +2 -0
  74. package/src/button/Button.tsx +6 -10
  75. package/src/common/dateUtils/isWithinRange/isWithinRange.spec.ts +21 -0
  76. package/src/common/dateUtils/isWithinRange/isWithinRange.ts +2 -2
  77. package/src/common/dateUtils/moveToWithinRange/moveToWithinRange.ts +8 -4
  78. package/src/common/propsValues/sentiment.ts +0 -10
  79. package/src/dateLookup/DateLookup.state.spec.js +7 -0
  80. package/src/dateLookup/{DateLookup.story.js → DateLookup.story.tsx} +13 -14
  81. package/src/dateLookup/DateLookup.tests.story.tsx +70 -0
  82. package/src/dateLookup/{DateLookup.js → DateLookup.tsx} +115 -81
  83. package/src/dateLookup/dateHeader/{DateHeader.js → DateHeader.tsx} +15 -15
  84. package/src/dateLookup/dateTrigger/DateTrigger.spec.js +0 -22
  85. package/src/dateLookup/dateTrigger/{DateTrigger.js → DateTrigger.tsx} +15 -32
  86. package/src/dateLookup/dayCalendar/{DayCalendar.js → DayCalendar.tsx} +14 -21
  87. package/src/dateLookup/dayCalendar/table/{DayCalendarTable.js → DayCalendarTable.tsx} +26 -37
  88. package/src/dateLookup/getStartOfDay/{getStartOfDay.js → getStartOfDay.tsx} +1 -1
  89. package/src/dateLookup/index.ts +2 -0
  90. package/src/dateLookup/monthCalendar/{MonthCalendar.js → MonthCalendar.tsx} +19 -22
  91. package/src/dateLookup/monthCalendar/table/{MonthCalendarTable.js → MonthCalendarTable.tsx} +31 -30
  92. package/src/dateLookup/yearCalendar/{YearCalendar.js → YearCalendar.tsx} +18 -21
  93. package/src/dateLookup/yearCalendar/table/{YearCalendarTable.js → YearCalendarTable.tsx} +26 -28
  94. package/src/i18n/th.json +2 -2
  95. package/src/index.ts +2 -1
  96. package/src/inlineAlert/InlineAlert.spec.tsx +0 -7
  97. package/src/inlineAlert/InlineAlert.tsx +19 -47
  98. package/src/inputs/InputGroup.tsx +3 -3
  99. package/src/inputs/SelectInput.tsx +1 -0
  100. package/src/inputs/_BottomSheet.tsx +44 -54
  101. package/src/inputs/_Popover.tsx +20 -23
  102. package/src/statusIcon/StatusIcon.tsx +14 -14
  103. package/build/types/alert/withArrow/alertArrowPositions.d.ts +0 -9
  104. package/build/types/alert/withArrow/alertArrowPositions.d.ts.map +0 -1
  105. package/build/types/alert/withArrow/index.d.ts +0 -3
  106. package/build/types/alert/withArrow/index.d.ts.map +0 -1
  107. package/build/types/alert/withArrow/withArrow.d.ts +0 -11
  108. package/build/types/alert/withArrow/withArrow.d.ts.map +0 -1
  109. package/src/alert/Alert.js +0 -196
  110. package/src/alert/index.js +0 -1
  111. package/src/alert/withArrow/alertArrowPositions.ts +0 -9
  112. package/src/alert/withArrow/index.js +0 -2
  113. package/src/alert/withArrow/withArrow.js +0 -50
  114. package/src/alert/withArrow/withArrow.spec.js +0 -51
  115. package/src/dateLookup/index.js +0 -1
  116. /package/src/dateLookup/{DateLookup.messages.js → DateLookup.messages.ts} +0 -0
  117. /package/src/dateLookup/dateHeader/{index.js → index.ts} +0 -0
  118. /package/src/dateLookup/dateTrigger/{index.js → index.ts} +0 -0
  119. /package/src/dateLookup/dayCalendar/{index.js → index.ts} +0 -0
  120. /package/src/dateLookup/dayCalendar/table/{index.js → index.ts} +0 -0
  121. /package/src/dateLookup/getStartOfDay/{index.js → index.ts} +0 -0
  122. /package/src/dateLookup/monthCalendar/{index.js → index.ts} +0 -0
  123. /package/src/dateLookup/monthCalendar/table/{index.js → index.ts} +0 -0
  124. /package/src/dateLookup/yearCalendar/{index.js → index.ts} +0 -0
  125. /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
  }
@@ -0,0 +1,2 @@
1
+ export { default } from './DateLookup';
2
+ export type { DateLookupProps } from './DateLookup';
@@ -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
- class MonthCalendar extends PureComponent {
12
- onMonthSelect = (month) => {
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
- {...{ selectedDate, min, max, viewYear, placeholder }}
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 = ({ selectedDate, min, max, viewYear, placeholder, onSelect }) => {
20
+ const MonthCalendarTable = ({
21
+ selectedDate,
22
+ min,
23
+ max,
24
+ viewYear,
25
+ placeholder,
26
+ onSelect,
27
+ }: MonthCalendarTableProps) => {
13
28
  const { locale } = useIntl();
14
- const getLink = (month) => {
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 && month === selectedDate.getMonth() && viewYear === selectedDate.getFullYear()
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 = [...new Array(ROWS * COLS)].map((_, index) => index);
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="3">{placeholder}</th>
74
+ <th colSpan={COLS}>{placeholder}</th>
57
75
  </tr>
58
76
  </thead>
59
77
  <tbody>
60
- {/* eslint-disable react/no-array-index-key */}
61
- {[...new Array(ROWS)].map((row, rowIndex) => (
78
+ {Array.from({ length: ROWS }, (_, rowIndex) => (
62
79
  <tr key={rowIndex}>
63
- {[...new Array(COLS)].map((col, colIndex) => (
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
- class YearCalendar extends PureComponent {
11
- onYearSelect = (year) => {
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
- {...{ selectedDate, min, max, viewYear, placeholder }}
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 = ({ selectedDate, min, max, viewYear, placeholder, onSelect }) => {
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 = [...new Array(ROWS * COLS)].map((_, index) => startYear + index);
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="4">{placeholder}</th>
66
+ <th colSpan={COLS}>{placeholder}</th>
52
67
  </tr>
53
68
  </thead>
54
69
  <tbody>
55
- {/* eslint-disable react/no-array-index-key */}
56
- {[...new Array(ROWS)].map((row, rowIndex) => (
70
+ {Array.from({ length: ROWS }, (_, rowIndex) => (
57
71
  <tr key={rowIndex}>
58
- {[...new Array(COLS)].map((col, colIndex) => (
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": "DD",
7
+ "neptune.DateInput.day.placeholder": "วัน",
8
8
  "neptune.DateInput.month.label": "เดือน",
9
9
  "neptune.DateInput.year.label": "ปี",
10
- "neptune.DateInput.year.placeholder": "YYYY",
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 | SentimentString;
9
+ type?: `${Sentiment}`;
13
10
  className?: string;
14
11
  children: ReactNode;
15
12
  }
16
13
 
17
- const typeClassMap: Record<Sentiment.ERROR | Sentiment.NEGATIVE, string> = {
18
- [Sentiment.ERROR]: 'danger',
19
- [Sentiment.NEGATIVE]: 'danger',
20
- };
21
-
22
- const InlineAlert = ({ id, type = Sentiment.NEUTRAL, className, children }: InlineAlertProps) => {
23
- const { isModern } = useTheme();
24
-
25
- const typeClass = `alert-${typeClassMap[type as Sentiment.ERROR | Sentiment.NEGATIVE] || type}`;
26
-
27
- if (isModern) {
28
- return (
29
- <div role="alert" id={id} className={classNames('alert alert-detach', typeClass, className)}>
30
- {(type === 'error' || type === 'negative') && <AlertCircleIcon />}
31
- <div>{children}</div>
32
- </div>
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
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
111
- if (entry.borderBoxSize != null) {
112
- setInputPadding(entry.borderBoxSize[0].inlineSize);
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(
@@ -537,6 +537,7 @@ function SelectInputOptions<T = string>({
537
537
 
538
538
  <section
539
539
  ref={listboxContainerRef}
540
+ tabIndex={-1}
540
541
  className={classNames(
541
542
  'np-select-input-listbox-container',
542
543
  items.some((item) => item.type === 'group') &&
@@ -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
- <FocusBoundary>
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
- enter="np-bottom-sheet-v2-backdrop-container--enter"
87
- enterFrom="np-bottom-sheet-v2-backdrop-container--enter-from"
88
- leave="np-bottom-sheet-v2-backdrop-container--leave"
89
- leaveTo="np-bottom-sheet-v2-backdrop-container--leave-to"
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
- <div className="np-bottom-sheet-v2-backdrop" />
92
- </Transition.Child>
93
-
94
- <div className="np-bottom-sheet-v2">
95
- <Transition.Child
96
- className="np-bottom-sheet-v2-content"
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
- key={floatingKey} // Force inner state invalidation on open
110
- ref={refs.setFloating}
111
- className="np-bottom-sheet-v2-content-inner-container"
112
- {...getFloatingProps()}
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
- <div className="np-bottom-sheet-v2-header">
115
- <CloseButton
116
- size={Size.SMALL}
117
- onClick={() => {
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
- </FloatingFocusManager>
140
- </Transition.Child>
141
- </div>
142
- </FocusBoundary>
129
+ </div>
130
+ </FloatingFocusManager>
131
+ </Transition.Child>
132
+ </div>
143
133
  </Transition>
144
134
  </ThemeProvider>
145
135
  </FloatingPortal>