@transferwise/components 0.0.0-experimental-e05dfa3 → 0.0.0-experimental-d0b76b1

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 (42) hide show
  1. package/build/index.esm.js +76 -150
  2. package/build/index.esm.js.map +1 -1
  3. package/build/index.js +76 -150
  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/header/Header.css +1 -1
  8. package/build/styles/main.css +1 -1
  9. package/build/types/dateInput/DateInput.d.ts +2 -0
  10. package/build/types/dateInput/DateInput.d.ts.map +1 -1
  11. package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
  12. package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts +1 -1
  13. package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts.map +1 -1
  14. package/build/types/dateLookup/tableLink/TableLink.d.ts +2 -16
  15. package/build/types/dateLookup/tableLink/TableLink.d.ts.map +1 -1
  16. package/build/types/dateLookup/tableLink/index.d.ts +1 -1
  17. package/build/types/dateLookup/tableLink/index.d.ts.map +1 -1
  18. package/build/types/dateLookup/yearCalendar/table/YearCalendarTable.d.ts.map +1 -1
  19. package/package.json +1 -1
  20. package/src/dateInput/DateInput.js +6 -0
  21. package/src/dateInput/DateInput.story.tsx +43 -1
  22. package/src/dateLookup/DateLookup.css +1 -1
  23. package/src/dateLookup/DateLookup.js +3 -16
  24. package/src/dateLookup/DateLookup.keyboardEvents.spec.js +0 -12
  25. package/src/dateLookup/DateLookup.less +49 -46
  26. package/src/dateLookup/DateLookup.story.js +7 -8
  27. package/src/dateLookup/dayCalendar/table/DayCalendarTable.js +1 -14
  28. package/src/dateLookup/dayCalendar/table/DayCalendarTable.spec.js +0 -25
  29. package/src/dateLookup/monthCalendar/table/MonthCalendarTable.js +20 -33
  30. package/src/dateLookup/monthCalendar/table/MonthCalendarTable.spec.js +0 -33
  31. package/src/dateLookup/tableLink/TableLink.js +70 -0
  32. package/src/dateLookup/yearCalendar/table/YearCalendarTable.js +11 -33
  33. package/src/dateLookup/yearCalendar/table/YearCalendarTable.spec.js +0 -26
  34. package/src/header/Header.css +1 -1
  35. package/src/header/Header.less +0 -5
  36. package/src/main.css +1 -1
  37. package/build/types/dateLookup/getFocusableTime/getFocusableTime.d.ts +0 -2
  38. package/build/types/dateLookup/getFocusableTime/getFocusableTime.d.ts.map +0 -1
  39. package/src/dateLookup/getFocusableTime/getFocusable.spec.js +0 -38
  40. package/src/dateLookup/getFocusableTime/getFocusableTime.tsx +0 -28
  41. package/src/dateLookup/tableLink/TableLink.tsx +0 -80
  42. /package/src/dateLookup/tableLink/{index.ts → index.js} +0 -0
@@ -1,2 +0,0 @@
1
- export declare function getFocusableTime(isSelected: (time: number) => boolean, isNow: (time: number) => boolean, isDisabled: (time: number) => boolean, timeSpan: number[]): number | null;
2
- //# sourceMappingURL=getFocusableTime.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getFocusableTime.d.ts","sourceRoot":"","sources":["../../../../src/dateLookup/getFocusableTime/getFocusableTime.tsx"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,EACrC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,EAChC,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,EACrC,QAAQ,EAAE,MAAM,EAAE,GACjB,MAAM,GAAG,IAAI,CAsBf"}
@@ -1,38 +0,0 @@
1
- import { getFocusableTime } from './getFocusableTime';
2
-
3
- describe('getFocusableTime', () => {
4
- const isSelected = (value) => value === 2;
5
- const isNow = (value) => value === 3;
6
- const isDisabled = (value) => value === 4;
7
- const values = [1, 2, 3, 4, 5];
8
-
9
- it('returns first selected value', () => {
10
- expect(getFocusableTime(isSelected, isNow, isDisabled, values)).toBe(2);
11
- });
12
-
13
- it('returns first now value if nothing is selected', () => {
14
- expect(getFocusableTime(() => false, isNow, isDisabled, values)).toBe(3);
15
- });
16
-
17
- it('returns first non disabled value when nothing is selected or now', () => {
18
- expect(
19
- getFocusableTime(
20
- () => false,
21
- () => false,
22
- isDisabled,
23
- values,
24
- ),
25
- ).toBe(1);
26
- });
27
-
28
- it('returns null if no selected, now, or non-disabled', () => {
29
- expect(
30
- getFocusableTime(
31
- () => false,
32
- () => false,
33
- () => true,
34
- values,
35
- ),
36
- ).toBeNull();
37
- });
38
- });
@@ -1,28 +0,0 @@
1
- export function getFocusableTime(
2
- isSelected: (time: number) => boolean,
3
- isNow: (time: number) => boolean,
4
- isDisabled: (time: number) => boolean,
5
- timeSpan: number[],
6
- ): number | null {
7
- let selected: number | null = null;
8
- let now: number | null = null;
9
- let disabled: number | null = null;
10
-
11
- for (const time of timeSpan) {
12
- if (isSelected(time)) {
13
- selected = time;
14
- break;
15
- }
16
- if (isNow(time)) {
17
- now = time;
18
- }
19
- if (!isDisabled(time) && disabled === null) {
20
- disabled = time;
21
- }
22
-
23
- if (selected) {
24
- break;
25
- }
26
- }
27
- return selected || now || disabled;
28
- }
@@ -1,80 +0,0 @@
1
- import classNames from 'classnames';
2
- import { useEffect, useRef } from 'react';
3
- import { injectIntl, IntlShape } from 'react-intl';
4
-
5
- import messages from '../DateLookup.messages';
6
-
7
- interface TableLinkProps {
8
- item: number;
9
- type: 'day' | 'month' | 'year';
10
- title?: string;
11
- longTitle?: string;
12
- active: boolean;
13
- disabled: boolean;
14
- today: boolean;
15
- autofocus?: boolean;
16
- onClick: (item: number) => void;
17
- intl: IntlShape;
18
- }
19
-
20
- const TableLink = ({
21
- item,
22
- type,
23
- title,
24
- longTitle,
25
- active,
26
- disabled,
27
- today,
28
- autofocus,
29
- onClick,
30
- intl: { formatMessage },
31
- }: TableLinkProps) => {
32
- const buttonRef = useRef<HTMLButtonElement>(null);
33
-
34
- useEffect(() => {
35
- if (autofocus) {
36
- setTimeout(() => {
37
- buttonRef.current?.focus();
38
- }, 0);
39
- }
40
- }, [autofocus]);
41
-
42
- const onCalendarClick = (event: React.MouseEvent<HTMLButtonElement>) => {
43
- event.preventDefault();
44
- if (!disabled) {
45
- onClick(item);
46
- }
47
- };
48
-
49
- const calculateAriaLabel = () => {
50
- if (active) {
51
- return `${longTitle || title || ''}, ${formatMessage(messages.selected)} ${formatMessage(
52
- messages[type],
53
- )}`;
54
- }
55
- return longTitle || title;
56
- };
57
-
58
- return (
59
- <>
60
- <button
61
- ref={buttonRef}
62
- type="button"
63
- className={classNames(
64
- `tw-date-lookup-${type}-option np-text-body-default-bold`,
65
- { active: !!active },
66
- { today: !!today },
67
- )}
68
- disabled={disabled}
69
- tabIndex={autofocus ? 0 : -1}
70
- aria-label={calculateAriaLabel()}
71
- aria-pressed={active}
72
- onClick={onCalendarClick}
73
- >
74
- {title || item}
75
- </button>
76
- </>
77
- );
78
- };
79
-
80
- export default injectIntl(TableLink);
File without changes