@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.
Files changed (30) hide show
  1. package/build/index.esm.js +70 -134
  2. package/build/index.esm.js.map +1 -1
  3. package/build/index.js +70 -134
  4. package/build/index.js.map +1 -1
  5. package/build/main.css +1 -1
  6. package/build/styles/dateLookup/DateLookup.css +1 -1
  7. package/build/styles/main.css +1 -1
  8. package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
  9. package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts +1 -1
  10. package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts.map +1 -1
  11. package/build/types/dateLookup/tableLink/TableLink.d.ts +2 -16
  12. package/build/types/dateLookup/tableLink/TableLink.d.ts.map +1 -1
  13. package/build/types/dateLookup/tableLink/index.d.ts +1 -1
  14. package/build/types/dateLookup/tableLink/index.d.ts.map +1 -1
  15. package/build/types/dateLookup/yearCalendar/table/YearCalendarTable.d.ts.map +1 -1
  16. package/build/types/info/Info.d.ts +6 -2
  17. package/build/types/info/Info.d.ts.map +1 -1
  18. package/package.json +1 -1
  19. package/src/dateLookup/DateLookup.css +1 -1
  20. package/src/dateLookup/DateLookup.js +0 -3
  21. package/src/dateLookup/DateLookup.less +47 -57
  22. package/src/dateLookup/DateLookup.story.js +5 -7
  23. package/src/dateLookup/dayCalendar/table/DayCalendarTable.js +1 -35
  24. package/src/dateLookup/monthCalendar/table/MonthCalendarTable.js +20 -43
  25. package/src/dateLookup/tableLink/TableLink.js +70 -0
  26. package/src/dateLookup/yearCalendar/table/YearCalendarTable.js +11 -39
  27. package/src/info/Info.tsx +6 -1
  28. package/src/main.css +1 -1
  29. package/src/dateLookup/tableLink/TableLink.tsx +0 -77
  30. /package/src/dateLookup/tableLink/{index.ts → index.js} +0 -0
@@ -1,77 +0,0 @@
1
- import { useEffect, useRef } from 'react';
2
- import { injectIntl, IntlShape } from 'react-intl';
3
-
4
- import messages from '../DateLookup.messages';
5
-
6
- interface TableLinkProps {
7
- item: number;
8
- type: 'day' | 'month' | 'year';
9
- title?: string;
10
- longTitle?: string;
11
- active: boolean;
12
- disabled: boolean;
13
- today: boolean;
14
- autofocus?: boolean;
15
- onClick: (item: number) => void;
16
- intl: IntlShape;
17
- }
18
-
19
- const TableLink = ({
20
- item,
21
- type,
22
- title,
23
- longTitle,
24
- active,
25
- disabled,
26
- today,
27
- autofocus,
28
- onClick,
29
- intl: { formatMessage },
30
- }: TableLinkProps) => {
31
- const buttonRef = useRef<HTMLButtonElement>(null);
32
-
33
- useEffect(() => {
34
- if (autofocus) {
35
- setTimeout(() => {
36
- buttonRef.current?.focus();
37
- }, 0);
38
- }
39
- }, [autofocus]);
40
-
41
- const onCalendarClick = (event: React.MouseEvent<HTMLButtonElement>) => {
42
- event.preventDefault();
43
- if (!disabled) {
44
- onClick(item);
45
- }
46
- };
47
-
48
- const calculateAriaLabel = () => {
49
- if (active) {
50
- return `${longTitle || title || ''}, ${formatMessage(messages.selected)} ${formatMessage(
51
- messages[type],
52
- )}`;
53
- }
54
- return longTitle || title;
55
- };
56
-
57
- return (
58
- <>
59
- <button
60
- ref={buttonRef}
61
- type="button"
62
- className={`tw-date-lookup-${type}-option ${active ? 'active' : ''} ${
63
- today ? 'today' : ''
64
- } np-text-body-default-bold`}
65
- disabled={disabled}
66
- tabIndex={autofocus ? 0 : -1}
67
- aria-label={calculateAriaLabel()}
68
- aria-pressed={active}
69
- onClick={onCalendarClick}
70
- >
71
- {title || item}
72
- </button>
73
- </>
74
- );
75
- };
76
-
77
- export default injectIntl(TableLink);
File without changes