@transferwise/components 0.0.0-experimental-0400704 → 0.0.0-experimental-c09cb11

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 (121) hide show
  1. package/build/dateLookup/dateTrigger/DateTrigger.js +8 -4
  2. package/build/dateLookup/dateTrigger/DateTrigger.js.map +1 -1
  3. package/build/dateLookup/dateTrigger/DateTrigger.mjs +8 -4
  4. package/build/dateLookup/dateTrigger/DateTrigger.mjs.map +1 -1
  5. package/build/field/Field.js +34 -7
  6. package/build/field/Field.js.map +1 -1
  7. package/build/field/Field.mjs +34 -7
  8. package/build/field/Field.mjs.map +1 -1
  9. package/build/i18n/en.json +1 -0
  10. package/build/i18n/en.json.js +1 -0
  11. package/build/i18n/en.json.js.map +1 -1
  12. package/build/i18n/en.json.mjs +1 -0
  13. package/build/i18n/en.json.mjs.map +1 -1
  14. package/build/index.js +2 -2
  15. package/build/index.mjs +1 -1
  16. package/build/inlineAlert/InlineAlert.js +13 -6
  17. package/build/inlineAlert/InlineAlert.js.map +1 -1
  18. package/build/inlineAlert/InlineAlert.mjs +13 -6
  19. package/build/inlineAlert/InlineAlert.mjs.map +1 -1
  20. package/build/label/Label.js +49 -5
  21. package/build/label/Label.js.map +1 -1
  22. package/build/label/Label.messages.js +12 -0
  23. package/build/label/Label.messages.js.map +1 -0
  24. package/build/label/Label.messages.mjs +10 -0
  25. package/build/label/Label.messages.mjs.map +1 -0
  26. package/build/label/Label.mjs +50 -6
  27. package/build/label/Label.mjs.map +1 -1
  28. package/build/main.css +4 -8
  29. package/build/styles/dateLookup/dateTrigger/DateTrigger.css +0 -8
  30. package/build/styles/field/Field.css +4 -0
  31. package/build/styles/main.css +4 -8
  32. package/build/tabs/Tab.js +38 -13
  33. package/build/tabs/Tab.js.map +1 -1
  34. package/build/tabs/Tab.mjs +34 -13
  35. package/build/tabs/Tab.mjs.map +1 -1
  36. package/build/tabs/TabList.js +11 -3
  37. package/build/tabs/TabList.js.map +1 -1
  38. package/build/tabs/TabList.mjs +7 -3
  39. package/build/tabs/TabList.mjs.map +1 -1
  40. package/build/tabs/TabPanel.js +16 -3
  41. package/build/tabs/TabPanel.js.map +1 -1
  42. package/build/tabs/TabPanel.mjs +12 -3
  43. package/build/tabs/TabPanel.mjs.map +1 -1
  44. package/build/tabs/Tabs.js +48 -24
  45. package/build/tabs/Tabs.js.map +1 -1
  46. package/build/tabs/Tabs.mjs +47 -24
  47. package/build/tabs/Tabs.mjs.map +1 -1
  48. package/build/tabs/utils.js +1 -0
  49. package/build/tabs/utils.js.map +1 -1
  50. package/build/tabs/utils.mjs +1 -0
  51. package/build/tabs/utils.mjs.map +1 -1
  52. package/build/types/dateLookup/dateTrigger/DateTrigger.d.ts.map +1 -1
  53. package/build/types/field/Field.d.ts +4 -2
  54. package/build/types/field/Field.d.ts.map +1 -1
  55. package/build/types/index.d.ts +1 -2
  56. package/build/types/index.d.ts.map +1 -1
  57. package/build/types/inlineAlert/InlineAlert.d.ts +9 -0
  58. package/build/types/inlineAlert/InlineAlert.d.ts.map +1 -1
  59. package/build/types/label/Label.d.ts +39 -3
  60. package/build/types/label/Label.d.ts.map +1 -1
  61. package/build/types/label/Label.messages.d.ts +8 -0
  62. package/build/types/label/Label.messages.d.ts.map +1 -0
  63. package/build/types/label/index.d.ts +3 -0
  64. package/build/types/label/index.d.ts.map +1 -0
  65. package/build/types/tabs/Tab.d.ts +1 -12
  66. package/build/types/tabs/Tab.d.ts.map +1 -1
  67. package/build/types/tabs/TabList.d.ts +8 -3
  68. package/build/types/tabs/TabList.d.ts.map +1 -1
  69. package/build/types/tabs/TabPanel.d.ts +14 -6
  70. package/build/types/tabs/TabPanel.d.ts.map +1 -1
  71. package/build/types/tabs/Tabs.d.ts +30 -83
  72. package/build/types/tabs/Tabs.d.ts.map +1 -1
  73. package/build/types/tabs/index.d.ts +1 -2
  74. package/build/types/tabs/index.d.ts.map +1 -1
  75. package/build/types/tabs/utils.d.ts +7 -12
  76. package/build/types/tabs/utils.d.ts.map +1 -1
  77. package/package.json +4 -4
  78. package/src/dateInput/DateInput.tests.story.tsx +6 -41
  79. package/src/dateLookup/DateLookup.rtl.spec.tsx +1 -1
  80. package/src/dateLookup/dateTrigger/DateTrigger.css +0 -8
  81. package/src/dateLookup/dateTrigger/DateTrigger.less +0 -8
  82. package/src/dateLookup/dateTrigger/DateTrigger.spec.js +1 -1
  83. package/src/dateLookup/dateTrigger/DateTrigger.tsx +9 -4
  84. package/src/field/Field.css +4 -0
  85. package/src/field/Field.less +5 -0
  86. package/src/field/Field.spec.tsx +41 -5
  87. package/src/field/Field.story.tsx +105 -7
  88. package/src/field/Field.tsx +33 -9
  89. package/src/i18n/en.json +1 -0
  90. package/src/index.ts +1 -2
  91. package/src/inlineAlert/InlineAlert.story.tsx +7 -72
  92. package/src/inlineAlert/InlineAlert.tsx +14 -3
  93. package/src/inputWithDisplayFormat/InputWithDisplayFormat.story.js +5 -10
  94. package/src/inputs/InputGroup.spec.tsx +1 -1
  95. package/src/inputs/SearchInput.spec.tsx +1 -1
  96. package/src/inputs/SelectInput.spec.tsx +1 -1
  97. package/src/label/Label.messages.tsx +8 -0
  98. package/src/label/Label.spec.tsx +42 -7
  99. package/src/label/Label.story.tsx +30 -25
  100. package/src/label/Label.tsx +66 -8
  101. package/src/label/index.ts +2 -0
  102. package/src/main.css +4 -8
  103. package/src/main.less +1 -0
  104. package/src/moneyInput/MoneyInput.story.tsx +11 -11
  105. package/src/radioGroup/RadioGroup.rtl.spec.tsx +1 -1
  106. package/src/select/Select.rtl.spec.tsx +1 -1
  107. package/src/switch/Switch.spec.tsx +1 -1
  108. package/src/switch/Switch.story.tsx +19 -21
  109. package/src/tabs/Tab.js +71 -0
  110. package/src/tabs/TabList.js +15 -0
  111. package/src/tabs/TabPanel.js +20 -0
  112. package/src/tabs/{Tabs.tsx → Tabs.js} +74 -111
  113. package/src/tabs/{Tabs.story.tsx → Tabs.story.js} +1 -1
  114. package/src/tabs/index.js +1 -0
  115. package/src/tabs/{utils.ts → utils.js} +9 -15
  116. package/src/tabs/{utils.spec.ts → utils.spec.js} +21 -24
  117. package/src/field/Field.tests.story.tsx +0 -33
  118. package/src/tabs/Tab.tsx +0 -72
  119. package/src/tabs/TabList.tsx +0 -11
  120. package/src/tabs/TabPanel.tsx +0 -14
  121. package/src/tabs/index.ts +0 -2
@@ -5,13 +5,12 @@ import {
5
5
  getSwipeDifference,
6
6
  swipeShouldChangeTab,
7
7
  getVelocity,
8
- Swipe,
9
8
  } from './utils';
10
9
 
11
10
  describe('Tabs Utility', () => {
12
- let start: Swipe;
13
- let end: Swipe;
14
- let coords: Swipe[];
11
+ let start;
12
+ let end;
13
+ let coords;
15
14
 
16
15
  beforeEach(() => {
17
16
  jest.clearAllMocks();
@@ -19,8 +18,8 @@ describe('Tabs Utility', () => {
19
18
 
20
19
  describe('when the ending x axis is greater than the starting x axis', () => {
21
20
  beforeEach(() => {
22
- start = { x: 0, y: 0, time: 1569538800000 };
23
- end = { x: 50, y: 0, time: 1569538800300 };
21
+ start = { x: 0, time: 1569538800000 };
22
+ end = { x: 50, time: 1569538800300 };
24
23
  });
25
24
 
26
25
  it('determines that the swipe was left to right', () => {
@@ -35,8 +34,8 @@ describe('Tabs Utility', () => {
35
34
 
36
35
  describe('when the ending x axis is less than the starting x axis', () => {
37
36
  beforeEach(() => {
38
- start = { x: 50, y: 0, time: 1569538800000 };
39
- end = { x: 0, y: 0, time: 1569538800300 };
37
+ start = { x: 50, time: 1569538800000 };
38
+ end = { x: 0, time: 1569538800300 };
40
39
  });
41
40
 
42
41
  it('determines that the swipe was right to left', () => {
@@ -51,20 +50,20 @@ describe('Tabs Utility', () => {
51
50
 
52
51
  describe('checking if a swipe should change tabs', () => {
53
52
  it('should change tab when the difference and velocity are significant', () => {
54
- start = { x: 0, y: 0, time: 1569538800000 };
55
- end = { x: 100, y: 0, time: 1569538800001 };
53
+ start = { x: 0, time: 1569538800000 };
54
+ end = { x: 100, time: 1569538800001 };
56
55
  expect(swipeShouldChangeTab(start, end)).toBe(true);
57
56
  });
58
57
 
59
58
  it('should not change tab when the difference is small', () => {
60
- start = { x: 0, y: 0, time: 1569538800000 };
61
- end = { x: 1, y: 0, time: 1569538800001 };
59
+ start = { x: 0, time: 1569538800000 };
60
+ end = { x: 1, time: 1569538800001 };
62
61
  expect(swipeShouldChangeTab(start, end)).toBe(false);
63
62
  });
64
63
 
65
64
  it('should not change tab when the velocity is small', () => {
66
- start = { x: 0, y: 0, time: 1569538800000 };
67
- end = { x: 100, y: 0, time: 1569538900000 };
65
+ start = { x: 0, time: 1569538800000 };
66
+ end = { x: 100, time: 1569538900000 };
68
67
  expect(swipeShouldChangeTab(start, end)).toBe(false);
69
68
  });
70
69
  });
@@ -72,11 +71,11 @@ describe('Tabs Utility', () => {
72
71
  describe('checking for velocity against an array of touches', () => {
73
72
  beforeEach(() => {
74
73
  coords = [
75
- { x: 0, y: 0, time: 1569538800000 },
76
- { x: 100, y: 0, time: 1569538825000 },
77
- { x: 200, y: 0, time: 1569538850000 },
78
- { x: 300, y: 0, time: 1569538875000 },
79
- { x: 400, y: 0, time: 1569538900000 },
74
+ { x: 0, time: 1569538800000 },
75
+ { x: 100, time: 1569538825000 },
76
+ { x: 200, time: 1569538850000 },
77
+ { x: 300, time: 1569538875000 },
78
+ { x: 400, time: 1569538900000 },
80
79
  ];
81
80
  });
82
81
 
@@ -85,15 +84,13 @@ describe('Tabs Utility', () => {
85
84
  });
86
85
 
87
86
  it('should only take into account the last 5 coordinates', () => {
88
- coords.unshift(
89
- { x: 10000, y: 0, time: 1569538800000 },
90
- { x: 100000, y: 0, time: 1569538800000 },
91
- );
87
+ coords.unshift({ x: 10000, time: 1569538800000 }, { x: 100000, time: 1569538800000 });
92
88
  expect(getVelocity(coords)).toBe(0.004);
93
89
  });
94
90
 
95
91
  it('returns a default 0 if there are any issues with the touches passed in', () => {
96
92
  expect(getVelocity([])).toBe(0);
93
+ expect(getVelocity([null, null, null])).toBe(0);
97
94
  });
98
95
  });
99
96
 
@@ -122,5 +119,5 @@ describe('Tabs Utility', () => {
122
119
  });
123
120
  });
124
121
 
125
- const getApproximateElasticDragDifference = (difference: number) =>
122
+ const getApproximateElasticDragDifference = (difference) =>
126
123
  Math.round(getElasticDragDifference(difference));
@@ -1,33 +0,0 @@
1
- import { useState } from 'react';
2
-
3
- import { Input } from '../inputs/Input';
4
- import { Field } from './Field';
5
- import { Sentiment } from '../common';
6
-
7
- export default {
8
- component: Field,
9
- title: 'Field/Tests',
10
- };
11
-
12
- export const WithHelpAndErrorOnBlur = () => {
13
- const [value, setValue] = useState('This is some text');
14
- const [error, setError] = useState<string | undefined>(undefined);
15
- return (
16
- <Field
17
- label="Phone number"
18
- sentiment={error ? Sentiment.NEGATIVE : Sentiment.NEUTRAL}
19
- message={error || 'Please include country code'}
20
- >
21
- <Input
22
- value={value}
23
- onChange={({ target }) => {
24
- setValue(target.value);
25
- setError(undefined);
26
- }}
27
- onBlur={() => {
28
- setError('Something went wrong');
29
- }}
30
- />
31
- </Field>
32
- );
33
- };
package/src/tabs/Tab.tsx DELETED
@@ -1,72 +0,0 @@
1
- import { clsx } from 'clsx';
2
- import { forwardRef, useEffect, useRef } from 'react';
3
- import { useEffectEvent } from '../common/hooks/useEffectEvent';
4
-
5
- export interface TabProps {
6
- children?: React.ReactNode;
7
- disabled?: boolean;
8
- selected?: boolean;
9
- id: string;
10
- panelId: string;
11
- style?: React.CSSProperties;
12
- focusTab?: () => void;
13
- onKeyDown: React.KeyboardEventHandler<HTMLLIElement>;
14
- onClick?: React.MouseEventHandler<HTMLLIElement>;
15
- }
16
-
17
- const noop = () => {};
18
-
19
- const Tab = forwardRef(function Tab(
20
- {
21
- children,
22
- id,
23
- disabled,
24
- panelId,
25
- selected,
26
- onKeyDown,
27
- onClick,
28
- style,
29
- focusTab = noop,
30
- }: TabProps,
31
- reference: React.ForwardedRef<HTMLLIElement>,
32
- ) {
33
- const handleFocusTab = useEffectEvent(focusTab);
34
- const firstUpdate = useRef(true);
35
- useEffect(
36
- function checkFocus() {
37
- if (firstUpdate.current) {
38
- firstUpdate.current = false;
39
- return;
40
- }
41
-
42
- if (selected) {
43
- handleFocusTab();
44
- }
45
- },
46
- [handleFocusTab, selected],
47
- );
48
-
49
- return (
50
- <li
51
- ref={reference}
52
- className={clsx('tabs__tab', selected ? 'np-text-body-large-bold' : 'np-text-body-large', {
53
- 'tabs__tab--selected': selected,
54
- clickable: !disabled,
55
- disabled,
56
- })}
57
- role="tab"
58
- id={id}
59
- aria-selected={selected ? 'true' : 'false'}
60
- aria-disabled={disabled ? 'true' : 'false'}
61
- aria-controls={disabled ? undefined : panelId}
62
- tabIndex={0}
63
- style={style}
64
- onKeyDown={disabled ? undefined : onKeyDown}
65
- onClick={onClick}
66
- >
67
- <span className="tabs__tab__content">{children}</span>
68
- </li>
69
- );
70
- });
71
-
72
- export default Tab;
@@ -1,11 +0,0 @@
1
- export interface TabListProps {
2
- children?: React.ReactNode;
3
- }
4
-
5
- export default function TabList({ children }: TabListProps) {
6
- return (
7
- <ul className="tabs__tab-list" role="tablist">
8
- {children}
9
- </ul>
10
- );
11
- }
@@ -1,14 +0,0 @@
1
- export interface TabPanelProps {
2
- children?: React.ReactNode;
3
- id: string;
4
- tabId: string;
5
- style: React.CSSProperties;
6
- }
7
-
8
- export default function TabPanel({ children, id, tabId, style }: TabPanelProps) {
9
- return (
10
- <div className="tabs__panel" role="tabpanel" id={id} aria-labelledby={tabId} style={style}>
11
- {children}
12
- </div>
13
- );
14
- }
package/src/tabs/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export { default } from './Tabs';
2
- export type { TabItem, TabsProps } from './Tabs';