@transferwise/components 0.0.0-experimental-3868cf1 → 0.0.0-experimental-69a95e1
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/avatarLayout/AvatarLayout.js +10 -4
- package/build/avatarLayout/AvatarLayout.js.map +1 -1
- package/build/avatarLayout/AvatarLayout.mjs +10 -4
- package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
- package/build/button/Button.js +79 -79
- package/build/button/Button.js.map +1 -1
- package/build/button/Button.mjs +80 -80
- package/build/button/Button.mjs.map +1 -1
- package/build/button/Button.resolver.js +86 -0
- package/build/button/Button.resolver.js.map +1 -0
- package/build/button/Button.resolver.mjs +84 -0
- package/build/button/Button.resolver.mjs.map +1 -0
- package/build/button/LegacyButton.js +114 -0
- package/build/button/LegacyButton.js.map +1 -0
- package/build/button/LegacyButton.mjs +112 -0
- package/build/button/LegacyButton.mjs.map +1 -0
- package/build/criticalBanner/CriticalCommsBanner.js +2 -2
- package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.mjs +1 -1
- package/build/header/Header.js +2 -2
- package/build/header/Header.js.map +1 -1
- package/build/header/Header.mjs +1 -1
- package/build/i18n/ja.json +0 -1
- package/build/i18n/ja.json.js +0 -1
- package/build/i18n/ja.json.js.map +1 -1
- package/build/i18n/ja.json.mjs +0 -1
- package/build/i18n/ja.json.mjs.map +1 -1
- package/build/i18n/pt.json +0 -1
- package/build/i18n/pt.json.js +0 -1
- package/build/i18n/pt.json.js.map +1 -1
- package/build/i18n/pt.json.mjs +0 -1
- package/build/i18n/pt.json.mjs.map +1 -1
- package/build/i18n/ru.json +0 -1
- package/build/i18n/ru.json.js +0 -1
- package/build/i18n/ru.json.js.map +1 -1
- package/build/i18n/ru.json.mjs +0 -1
- package/build/i18n/ru.json.mjs.map +1 -1
- package/build/i18n/zh-HK.json +0 -1
- package/build/i18n/zh-HK.json.js +0 -1
- package/build/i18n/zh-HK.json.js.map +1 -1
- package/build/i18n/zh-HK.json.mjs +0 -1
- package/build/i18n/zh-HK.json.mjs.map +1 -1
- package/build/index.js +2 -4
- package/build/index.js.map +1 -1
- package/build/index.mjs +1 -2
- package/build/index.mjs.map +1 -1
- package/build/link/Link.js +8 -3
- package/build/link/Link.js.map +1 -1
- package/build/link/Link.mjs +8 -3
- package/build/link/Link.mjs.map +1 -1
- package/build/main.css +227 -2
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js +2 -4
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js.map +1 -1
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs +2 -4
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs.map +1 -1
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.js +3 -5
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.js.map +1 -1
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs +3 -5
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs.map +1 -1
- package/build/select/Select.js +2 -2
- package/build/select/Select.js.map +1 -1
- package/build/select/Select.mjs +1 -1
- package/build/styles/avatarLayout/AvatarLayout.css +12 -2
- package/build/styles/button/Button.css +207 -15
- package/build/styles/button/Button.vars.css +39 -0
- package/build/styles/button/LegacyButton.css +23 -0
- package/build/styles/main.css +227 -2
- package/build/types/avatarLayout/AvatarLayout.d.ts +1 -2
- package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
- package/build/types/avatarLayout/index.d.ts +1 -0
- package/build/types/avatarLayout/index.d.ts.map +1 -1
- package/build/types/button/Button.d.ts +1 -23
- package/build/types/button/Button.d.ts.map +1 -1
- package/build/types/button/Button.resolver.d.ts +31 -0
- package/build/types/button/Button.resolver.d.ts.map +1 -0
- package/build/types/button/Button.types.d.ts +65 -0
- package/build/types/button/Button.types.d.ts.map +1 -0
- package/build/types/button/LegacyButton.d.ts +30 -0
- package/build/types/button/LegacyButton.d.ts.map +1 -0
- package/build/types/button/index.d.ts +2 -2
- package/build/types/button/index.d.ts.map +1 -1
- package/build/types/index.d.ts +0 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/link/Link.d.ts +2 -2
- package/build/types/link/Link.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts +5 -1
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveButton/src/PrimitiveButton.d.ts.map +1 -1
- package/build/types/test-utils/story-config.d.ts +1 -1
- package/build/types/test-utils/story-config.d.ts.map +1 -1
- package/build/types/uploadInput/uploadButton/getAllowedFileTypes.d.ts.map +1 -1
- package/build/upload/steps/completeStep/completeStep.js +2 -2
- package/build/upload/steps/completeStep/completeStep.js.map +1 -1
- package/build/upload/steps/completeStep/completeStep.mjs +1 -1
- package/build/upload/steps/processingStep/processingStep.js +2 -2
- package/build/upload/steps/processingStep/processingStep.js.map +1 -1
- package/build/upload/steps/processingStep/processingStep.mjs +1 -1
- package/build/uploadInput/UploadInput.js +3 -3
- package/build/uploadInput/UploadInput.js.map +1 -1
- package/build/uploadInput/UploadInput.mjs +1 -1
- package/build/uploadInput/uploadButton/getAllowedFileTypes.js +3 -23
- package/build/uploadInput/uploadButton/getAllowedFileTypes.js.map +1 -1
- package/build/uploadInput/uploadButton/getAllowedFileTypes.mjs +3 -23
- package/build/uploadInput/uploadButton/getAllowedFileTypes.mjs.map +1 -1
- package/package.json +5 -5
- package/src/alert/Alert.tests.story.tsx +1 -1
- package/src/avatarLayout/AvatarLayout.css +12 -2
- package/src/avatarLayout/AvatarLayout.less +19 -2
- package/src/avatarLayout/AvatarLayout.tsx +11 -4
- package/src/avatarLayout/index.ts +1 -0
- package/src/button/Button.css +207 -15
- package/src/button/Button.less +217 -14
- package/src/button/Button.resolver.tsx +134 -0
- package/src/button/Button.spec.tsx +176 -225
- package/src/button/Button.story.tsx +729 -135
- package/src/button/Button.tests.story.tsx +27 -0
- package/src/button/Button.tsx +89 -132
- package/src/button/Button.types.ts +86 -0
- package/src/button/Button.vars.css +39 -0
- package/src/button/Button.vars.less +49 -0
- package/src/button/LegacyButton.css +23 -0
- package/src/button/LegacyButton.less +24 -0
- package/src/button/LegacyButton.spec.tsx +146 -0
- package/src/button/LegacyButton.story.tsx +225 -0
- package/src/button/LegacyButton.tsx +161 -0
- package/src/button/index.ts +2 -3
- package/src/field/Field.story.tsx +1 -1
- package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +1 -2
- package/src/i18n/ja.json +0 -1
- package/src/i18n/pt.json +0 -1
- package/src/i18n/ru.json +0 -1
- package/src/i18n/zh-HK.json +0 -1
- package/src/index.ts +0 -12
- package/src/inputs/SelectInput.story.tsx +1 -1
- package/src/label/Label.story.tsx +1 -1
- package/src/link/Link.tsx +15 -6
- package/src/main.css +227 -2
- package/src/main.less +1 -0
- package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx +2 -8
- package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.ts +6 -1
- package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +1 -3
- package/src/primitives/PrimitiveButton/src/PrimitiveButton.tsx +4 -12
- package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +16 -13
- package/src/test-utils/Parameters.d.ts +9 -1
- package/src/test-utils/story-config.ts +10 -1
- package/src/uploadInput/UploadInput.tests.story.tsx +5 -5
- package/src/uploadInput/uploadButton/getAllowedFileTypes.spec.ts +0 -12
- package/src/uploadInput/uploadButton/getAllowedFileTypes.ts +7 -33
- package/build/table/Table.js +0 -166
- package/build/table/Table.js.map +0 -1
- package/build/table/Table.messages.js +0 -24
- package/build/table/Table.messages.js.map +0 -1
- package/build/table/Table.messages.mjs +0 -22
- package/build/table/Table.messages.mjs.map +0 -1
- package/build/table/Table.mjs +0 -164
- package/build/table/Table.mjs.map +0 -1
- package/build/table/TableCell.js +0 -86
- package/build/table/TableCell.js.map +0 -1
- package/build/table/TableCell.mjs +0 -84
- package/build/table/TableCell.mjs.map +0 -1
- package/build/table/TableHeader.js +0 -57
- package/build/table/TableHeader.js.map +0 -1
- package/build/table/TableHeader.mjs +0 -55
- package/build/table/TableHeader.mjs.map +0 -1
- package/build/table/TableRow.js +0 -85
- package/build/table/TableRow.js.map +0 -1
- package/build/table/TableRow.mjs +0 -83
- package/build/table/TableRow.mjs.map +0 -1
- package/build/table/TableStatusText.js +0 -54
- package/build/table/TableStatusText.js.map +0 -1
- package/build/table/TableStatusText.mjs +0 -52
- package/build/table/TableStatusText.mjs.map +0 -1
- package/src/button/__snapshots__/Button.spec.tsx.snap +0 -309
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { userEvent, within, fn, expect } from '@storybook/test';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
|
|
5
|
+
import Button from '.';
|
|
6
|
+
|
|
7
|
+
const withContainer = (Story: any) => (
|
|
8
|
+
<div
|
|
9
|
+
style={{
|
|
10
|
+
display: 'flex',
|
|
11
|
+
flexDirection: 'initial',
|
|
12
|
+
justifyContent: 'center',
|
|
13
|
+
flexFlow: 'column',
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
}}
|
|
16
|
+
>
|
|
17
|
+
<Story />
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const meta: Meta<typeof Button> = {
|
|
22
|
+
component: Button,
|
|
23
|
+
title: 'Actions/Button/Legacy',
|
|
24
|
+
args: {
|
|
25
|
+
children: 'Button text',
|
|
26
|
+
loading: false,
|
|
27
|
+
type: undefined,
|
|
28
|
+
onClick: fn(),
|
|
29
|
+
onBlur: fn(),
|
|
30
|
+
onFocus: fn(),
|
|
31
|
+
href: 'https://example.com',
|
|
32
|
+
as: undefined,
|
|
33
|
+
},
|
|
34
|
+
argTypes: {
|
|
35
|
+
as: {
|
|
36
|
+
control: {
|
|
37
|
+
name: 'enum',
|
|
38
|
+
options: ['button', 'a'],
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
type: {
|
|
42
|
+
type: {
|
|
43
|
+
name: 'enum',
|
|
44
|
+
value: ['accent', 'positive', 'negative'],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
size: {
|
|
48
|
+
type: {
|
|
49
|
+
name: 'enum',
|
|
50
|
+
value: ['xs', 'sm', 'md', 'lg'],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
priority: {
|
|
54
|
+
type: {
|
|
55
|
+
name: 'enum',
|
|
56
|
+
value: ['primary', 'secondary', 'tertiary'],
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
sentiment: {
|
|
60
|
+
table: {
|
|
61
|
+
disable: true,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
iconStart: {
|
|
65
|
+
table: {
|
|
66
|
+
disable: true,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
iconEnd: {
|
|
70
|
+
table: {
|
|
71
|
+
disable: true,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
avatars: {
|
|
75
|
+
table: {
|
|
76
|
+
disable: true,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
'data-testid': {
|
|
80
|
+
table: {
|
|
81
|
+
disable: true,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
tags: ['autodocs'],
|
|
86
|
+
decorators: [withContainer],
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export default meta;
|
|
90
|
+
|
|
91
|
+
type Story = StoryObj<typeof Button>;
|
|
92
|
+
|
|
93
|
+
export const Basic: Story = {};
|
|
94
|
+
|
|
95
|
+
export const Secondary: Story = {
|
|
96
|
+
args: {
|
|
97
|
+
type: 'accent',
|
|
98
|
+
priority: 'secondary',
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export const Tertiary: Story = {
|
|
103
|
+
args: {
|
|
104
|
+
type: 'accent',
|
|
105
|
+
priority: 'tertiary',
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export const Negative: Story = {
|
|
110
|
+
args: {
|
|
111
|
+
type: 'negative',
|
|
112
|
+
priority: 'primary',
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const Loading: Story = {
|
|
117
|
+
args: {
|
|
118
|
+
loading: true,
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const Variants: Story = {
|
|
123
|
+
render: () => {
|
|
124
|
+
return (
|
|
125
|
+
<div className="d-flex flex-column p-b-2 align-items-start">
|
|
126
|
+
<div className="d-flex flex-row p-b-2" style={{ gap: 'var(--size-16)' }}>
|
|
127
|
+
<Button type="accent" priority="primary">
|
|
128
|
+
Primary Accent
|
|
129
|
+
</Button>
|
|
130
|
+
<Button type="accent" priority="secondary">
|
|
131
|
+
Secondary Accent
|
|
132
|
+
</Button>
|
|
133
|
+
<Button type="accent" priority="tertiary">
|
|
134
|
+
Tertiary Accent
|
|
135
|
+
</Button>
|
|
136
|
+
</div>
|
|
137
|
+
<div className="d-flex flex-row p-b-2" style={{ gap: 'var(--size-16)' }}>
|
|
138
|
+
<Button type="positive" priority="primary">
|
|
139
|
+
Primary Positive
|
|
140
|
+
</Button>
|
|
141
|
+
<Button type="positive" priority="secondary">
|
|
142
|
+
Secondary Accent
|
|
143
|
+
</Button>
|
|
144
|
+
</div>
|
|
145
|
+
<div className="d-flex flex-row flex- p-b-2" style={{ gap: 'var(--size-16)' }}>
|
|
146
|
+
<Button type="negative" priority="primary">
|
|
147
|
+
Primary Negative
|
|
148
|
+
</Button>
|
|
149
|
+
<Button type="negative" priority="secondary">
|
|
150
|
+
Secondary Negative
|
|
151
|
+
</Button>
|
|
152
|
+
</div>
|
|
153
|
+
<div className="d-flex flex-row p-b-1" style={{ gap: 'var(--size-16)' }}>
|
|
154
|
+
<Button type="accent" priority="primary" disabled>
|
|
155
|
+
Button Disabled
|
|
156
|
+
</Button>
|
|
157
|
+
<Button type="accent" priority="secondary" disabled>
|
|
158
|
+
Button Disabled
|
|
159
|
+
</Button>
|
|
160
|
+
<Button type="accent" priority="tertiary" disabled>
|
|
161
|
+
Button Disabled
|
|
162
|
+
</Button>
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
);
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const wait = async (duration = 500) =>
|
|
170
|
+
new Promise<void>((resolve) => {
|
|
171
|
+
setTimeout(resolve, duration);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
export const Focused: Story = {
|
|
175
|
+
play: async ({ canvasElement }: { canvasElement: HTMLElement }) => {
|
|
176
|
+
const canvas = within(canvasElement);
|
|
177
|
+
const button = canvas.getByRole('button');
|
|
178
|
+
await userEvent.tab();
|
|
179
|
+
await expect(button).toHaveFocus();
|
|
180
|
+
await expect(button).toHaveTextContent('Focused!');
|
|
181
|
+
},
|
|
182
|
+
render: function Render(args: React.ComponentProps<typeof Button>) {
|
|
183
|
+
const [focused, setFocused] = useState(false);
|
|
184
|
+
|
|
185
|
+
return (
|
|
186
|
+
<Button {...args} onFocus={() => setFocused(true)}>
|
|
187
|
+
{focused ? 'Focused!' : 'Button text'}
|
|
188
|
+
</Button>
|
|
189
|
+
);
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export const SocialMedia: Story = {
|
|
194
|
+
render: () => {
|
|
195
|
+
return (
|
|
196
|
+
<>
|
|
197
|
+
<div className="m-b-2">
|
|
198
|
+
<button type="button" className="btn btn-google">
|
|
199
|
+
Login with Google
|
|
200
|
+
</button>
|
|
201
|
+
</div>
|
|
202
|
+
<div className="m-b-2">
|
|
203
|
+
<button type="button" className="btn btn-facebook">
|
|
204
|
+
Login with Facebook
|
|
205
|
+
</button>
|
|
206
|
+
</div>
|
|
207
|
+
<div className="m-b-2">
|
|
208
|
+
<button type="button" className="btn btn-lg btn-facebook">
|
|
209
|
+
Large Button
|
|
210
|
+
</button>
|
|
211
|
+
</div>
|
|
212
|
+
<div className="m-b-2">
|
|
213
|
+
<button type="button" className="btn btn-block btn-facebook">
|
|
214
|
+
Block Button
|
|
215
|
+
</button>
|
|
216
|
+
</div>
|
|
217
|
+
<div className="m-b-2">
|
|
218
|
+
<button type="button" className="btn btn-lg btn-block btn-facebook">
|
|
219
|
+
Large Block Button
|
|
220
|
+
</button>
|
|
221
|
+
</div>
|
|
222
|
+
</>
|
|
223
|
+
);
|
|
224
|
+
},
|
|
225
|
+
};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { clsx } from 'clsx';
|
|
2
|
+
import { ElementType, forwardRef, MouseEvent } from 'react';
|
|
3
|
+
import { useIntl } from 'react-intl';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Size,
|
|
7
|
+
ControlType,
|
|
8
|
+
Priority,
|
|
9
|
+
ControlTypeAccent,
|
|
10
|
+
ControlTypeNegative,
|
|
11
|
+
ControlTypePositive,
|
|
12
|
+
PriorityPrimary,
|
|
13
|
+
PrioritySecondary,
|
|
14
|
+
PriorityTertiary,
|
|
15
|
+
SizeExtraSmall,
|
|
16
|
+
SizeSmall,
|
|
17
|
+
SizeMedium,
|
|
18
|
+
SizeLarge,
|
|
19
|
+
} from '../common';
|
|
20
|
+
import ProcessIndicator from '../processIndicator';
|
|
21
|
+
|
|
22
|
+
import messages from '../i18n/commonMessages/Button.messages';
|
|
23
|
+
import { typeClassMap, priorityClassMap } from './classMap';
|
|
24
|
+
import { establishNewPriority, establishNewType, logDeprecationNotices } from './legacyUtils';
|
|
25
|
+
|
|
26
|
+
/** @deprecated */
|
|
27
|
+
type DeprecatedTypes = 'primary' | 'pay' | 'secondary' | 'danger' | 'link';
|
|
28
|
+
|
|
29
|
+
/** @deprecated */
|
|
30
|
+
type DeprecatedSizes = SizeExtraSmall;
|
|
31
|
+
|
|
32
|
+
type CommonProps = {
|
|
33
|
+
block?: boolean;
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
loading?: boolean;
|
|
36
|
+
/** @deprecated */
|
|
37
|
+
type?: ControlTypeAccent | ControlTypeNegative | ControlTypePositive | DeprecatedTypes | null;
|
|
38
|
+
priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary | null;
|
|
39
|
+
size?: SizeSmall | SizeMedium | SizeLarge | DeprecatedSizes;
|
|
40
|
+
htmlType?: 'submit' | 'reset' | 'button';
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type ButtonProps = CommonProps &
|
|
44
|
+
Omit<React.ComponentPropsWithRef<'button'>, 'type'> & {
|
|
45
|
+
as?: 'button';
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type AnchorProps = CommonProps &
|
|
49
|
+
Omit<React.ComponentPropsWithRef<'a'>, 'type'> & {
|
|
50
|
+
as?: 'a';
|
|
51
|
+
href?: string;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export type LegacyButtonProps = ButtonProps | AnchorProps;
|
|
55
|
+
|
|
56
|
+
export type ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @deprecated make sure you use new Button component via `<Button v2 .. />` and new props
|
|
60
|
+
*/
|
|
61
|
+
const LegacyButton = forwardRef<ButtonReferenceType, LegacyButtonProps>(
|
|
62
|
+
(
|
|
63
|
+
{
|
|
64
|
+
as: component = 'button',
|
|
65
|
+
block = false,
|
|
66
|
+
children,
|
|
67
|
+
className,
|
|
68
|
+
disabled,
|
|
69
|
+
loading = false,
|
|
70
|
+
priority = Priority.PRIMARY,
|
|
71
|
+
size = Size.MEDIUM,
|
|
72
|
+
type = ControlType.ACCENT,
|
|
73
|
+
onClick,
|
|
74
|
+
...rest
|
|
75
|
+
}: LegacyButtonProps,
|
|
76
|
+
ref,
|
|
77
|
+
) => {
|
|
78
|
+
const intl = useIntl();
|
|
79
|
+
|
|
80
|
+
logDeprecationNotices({ size, type });
|
|
81
|
+
|
|
82
|
+
const newType = establishNewType(type);
|
|
83
|
+
const newPriority = establishNewPriority(priority, type);
|
|
84
|
+
|
|
85
|
+
const classes = clsx(
|
|
86
|
+
`btn btn-${size}`,
|
|
87
|
+
`np-btn np-btn-${size}`,
|
|
88
|
+
{
|
|
89
|
+
'btn-loading': loading,
|
|
90
|
+
'btn-block np-btn-block': block,
|
|
91
|
+
disabled,
|
|
92
|
+
},
|
|
93
|
+
// @ts-expect-error fix when refactor `typeClassMap` to TypeScript
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
95
|
+
typeClassMap[newType],
|
|
96
|
+
// @ts-expect-error fix when refactor `typeClassMap` to TypeScript
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
98
|
+
priorityClassMap[newPriority],
|
|
99
|
+
className,
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
function processIndicatorSize() {
|
|
103
|
+
return ['sm', 'xs'].includes(size) ? 'xxs' : 'xs';
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const Element = (component as ElementType) ?? 'button';
|
|
107
|
+
let props;
|
|
108
|
+
|
|
109
|
+
if (Element === 'button') {
|
|
110
|
+
const { htmlType = 'button', ...restProps } = rest as ButtonProps;
|
|
111
|
+
props = {
|
|
112
|
+
...restProps,
|
|
113
|
+
disabled,
|
|
114
|
+
'aria-disabled': loading,
|
|
115
|
+
type: htmlType,
|
|
116
|
+
};
|
|
117
|
+
} else {
|
|
118
|
+
props = {
|
|
119
|
+
...rest,
|
|
120
|
+
'aria-disabled': loading,
|
|
121
|
+
} as AnchorProps;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Ensures that the button cannot be activated in loading or disabled mode,
|
|
126
|
+
* when `aria-disabled` might be used over the `disabled` HTML attribute
|
|
127
|
+
*/
|
|
128
|
+
const handleClick =
|
|
129
|
+
(handler: LegacyButtonProps['onClick']) =>
|
|
130
|
+
(event: MouseEvent<HTMLButtonElement> & MouseEvent<HTMLAnchorElement>) => {
|
|
131
|
+
if (disabled || loading) {
|
|
132
|
+
event.preventDefault();
|
|
133
|
+
} else if (typeof handler === 'function') {
|
|
134
|
+
handler(event);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<Element
|
|
140
|
+
ref={ref as React.Ref<ButtonReferenceType>}
|
|
141
|
+
className={classes}
|
|
142
|
+
onClick={handleClick(onClick)}
|
|
143
|
+
{...props}
|
|
144
|
+
aria-live={loading ? 'polite' : 'off'}
|
|
145
|
+
aria-busy={loading}
|
|
146
|
+
aria-label={loading ? intl.formatMessage(messages.loadingAriaLabel) : rest['aria-label']}
|
|
147
|
+
>
|
|
148
|
+
{children}
|
|
149
|
+
{loading && (
|
|
150
|
+
<ProcessIndicator
|
|
151
|
+
size={processIndicatorSize()}
|
|
152
|
+
className="btn-loader"
|
|
153
|
+
data-testid="ButtonProgressIndicator"
|
|
154
|
+
/>
|
|
155
|
+
)}
|
|
156
|
+
</Element>
|
|
157
|
+
);
|
|
158
|
+
},
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
export default LegacyButton;
|
package/src/button/index.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export { default } from './Button';
|
|
2
|
-
|
|
3
|
-
export type { Props as ButtonProps } from './Button';
|
|
1
|
+
export { default } from './Button.resolver';
|
|
2
|
+
export type { ButtonProps } from './Button.resolver';
|
|
@@ -9,10 +9,9 @@ exports[`FlowNavigation on mobile renders as expected 1`] = `
|
|
|
9
9
|
class="np-flow-header d-flex flex-wrap align-items-center justify-content-between flex__item--12 np-flow-navigation__content p-x-3 np-flow-navigation--xs-max"
|
|
10
10
|
>
|
|
11
11
|
<button
|
|
12
|
-
aria-disabled="false"
|
|
13
12
|
aria-label="back to previous step"
|
|
14
13
|
aria-live="off"
|
|
15
|
-
class="
|
|
14
|
+
class="np-circle d-flex align-items-center justify-content-center np-icon-button np-icon-button-tertiary-default"
|
|
16
15
|
style="--circle-size: 40px; --circle-icon-size: 20px; --circle-font-size: 18px;"
|
|
17
16
|
type="button"
|
|
18
17
|
>
|
package/src/i18n/ja.json
CHANGED
|
@@ -54,7 +54,6 @@
|
|
|
54
54
|
"neptune.UploadButton.allFileTypes": "すべてのファイル種類",
|
|
55
55
|
"neptune.UploadButton.dropFiles": "ファイルをドロップしてアップロードする",
|
|
56
56
|
"neptune.UploadButton.instructions": "{fileTypes}、{size}MB以下",
|
|
57
|
-
"neptune.UploadButton.maximumFiles": "最大ファイル数:{maxFiles}個",
|
|
58
57
|
"neptune.UploadButton.uploadFile": "ファイルをアップロードする",
|
|
59
58
|
"neptune.UploadButton.uploadFiles": "ファイルをアップロードする",
|
|
60
59
|
"neptune.UploadInput.deleteModalBody": "このファイルを削除すると、当社のシステムからも削除されます。",
|
package/src/i18n/pt.json
CHANGED
|
@@ -54,7 +54,6 @@
|
|
|
54
54
|
"neptune.UploadButton.allFileTypes": "Todos os tipos de arquivos",
|
|
55
55
|
"neptune.UploadButton.dropFiles": "Arraste o arquivo para iniciar o envio",
|
|
56
56
|
"neptune.UploadButton.instructions": "{fileTypes}, com menos de {size}MB",
|
|
57
|
-
"neptune.UploadButton.maximumFiles": "Máximo de {maxFiles} arquivos.",
|
|
58
57
|
"neptune.UploadButton.uploadFile": "Enviar arquivo",
|
|
59
58
|
"neptune.UploadButton.uploadFiles": "Enviar arquivos",
|
|
60
59
|
"neptune.UploadInput.deleteModalBody": "Se você remover este arquivo, ele será permanentemente excluído do nosso sistema.",
|
package/src/i18n/ru.json
CHANGED
|
@@ -54,7 +54,6 @@
|
|
|
54
54
|
"neptune.UploadButton.allFileTypes": "Все типы файлов",
|
|
55
55
|
"neptune.UploadButton.dropFiles": "Перетащите файл, чтобы начать загрузку",
|
|
56
56
|
"neptune.UploadButton.instructions": "{fileTypes}, не превышающий {size} MB",
|
|
57
|
-
"neptune.UploadButton.maximumFiles": "Макс. количество файлов: {maxFiles}.",
|
|
58
57
|
"neptune.UploadButton.uploadFile": "Загрузить файл",
|
|
59
58
|
"neptune.UploadButton.uploadFiles": "Загрузить файлы",
|
|
60
59
|
"neptune.UploadInput.deleteModalBody": "Удаление этого файла приведет к его удалению из нашей системы.",
|
package/src/i18n/zh-HK.json
CHANGED
|
@@ -54,7 +54,6 @@
|
|
|
54
54
|
"neptune.UploadButton.allFileTypes": "所有檔案類型",
|
|
55
55
|
"neptune.UploadButton.dropFiles": "拖放檔案以開始上載",
|
|
56
56
|
"neptune.UploadButton.instructions": "{fileTypes},小於{size}MB",
|
|
57
|
-
"neptune.UploadButton.maximumFiles": "最多{maxFiles}個檔案。",
|
|
58
57
|
"neptune.UploadButton.uploadFile": "上載檔案",
|
|
59
58
|
"neptune.UploadButton.uploadFiles": "上載檔案",
|
|
60
59
|
"neptune.UploadInput.deleteModalBody": "移除此檔案會把它從我們的系統中刪除。",
|
package/src/index.ts
CHANGED
|
@@ -96,17 +96,6 @@ export type { UploadProps } from './upload';
|
|
|
96
96
|
export type { UploadError, UploadResponse, UploadedFile } from './uploadInput/types';
|
|
97
97
|
export type { WithIdProps } from './withId';
|
|
98
98
|
export type { IconButtonProps } from './iconButton';
|
|
99
|
-
export type {
|
|
100
|
-
TableProps,
|
|
101
|
-
TableRowType,
|
|
102
|
-
TableRowClickableType,
|
|
103
|
-
TableHeaderType,
|
|
104
|
-
TableCellLeading,
|
|
105
|
-
TableCellText,
|
|
106
|
-
TableCellCurrency,
|
|
107
|
-
TableCellStatus,
|
|
108
|
-
TableCellType,
|
|
109
|
-
} from './table';
|
|
110
99
|
|
|
111
100
|
/**
|
|
112
101
|
* Components
|
|
@@ -207,7 +196,6 @@ export { default as Tooltip } from './tooltip';
|
|
|
207
196
|
export { default as Typeahead } from './typeahead';
|
|
208
197
|
export { default as Upload } from './upload';
|
|
209
198
|
export { default as UploadInput } from './uploadInput';
|
|
210
|
-
export { default as Table } from './table';
|
|
211
199
|
|
|
212
200
|
/**
|
|
213
201
|
* Hooks
|
|
@@ -5,7 +5,7 @@ import { Flag } from '@wise/art';
|
|
|
5
5
|
import { clsx } from 'clsx';
|
|
6
6
|
import { useState } from 'react';
|
|
7
7
|
|
|
8
|
-
import Button from '../button
|
|
8
|
+
import Button from '../button';
|
|
9
9
|
import { getMonthNames } from '../common/dateUtils';
|
|
10
10
|
import Drawer from '../drawer';
|
|
11
11
|
import { Field } from '../field/Field';
|
package/src/link/Link.tsx
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { NavigateAway as NavigateAwayIcon } from '@transferwise/icons';
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
|
-
import { AnchorHTMLAttributes } from 'react';
|
|
4
3
|
import { useIntl } from 'react-intl';
|
|
4
|
+
import { PrimitiveAnchor } from '../primitives';
|
|
5
|
+
import type { PrimitiveAnchorProps } from '../primitives';
|
|
5
6
|
|
|
6
7
|
import { LinkLarge, LinkDefault } from '../common';
|
|
7
8
|
|
|
8
9
|
import messages from './Link.messages';
|
|
9
10
|
|
|
10
|
-
export type Props =
|
|
11
|
+
export type Props = PrimitiveAnchorProps & { type?: LinkLarge | LinkDefault };
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Standard Link component with navigate away icon
|
|
@@ -24,22 +25,30 @@ const Link = ({
|
|
|
24
25
|
onClick,
|
|
25
26
|
...props
|
|
26
27
|
}: Props) => {
|
|
28
|
+
const { formatMessage } = useIntl();
|
|
27
29
|
const isBlank = target === '_blank';
|
|
28
30
|
|
|
29
|
-
const
|
|
31
|
+
const classNames = clsx(
|
|
32
|
+
'np-link',
|
|
33
|
+
'd-inline-flex',
|
|
34
|
+
{
|
|
35
|
+
[`np-text-${type}`]: type,
|
|
36
|
+
},
|
|
37
|
+
className,
|
|
38
|
+
);
|
|
30
39
|
|
|
31
40
|
return (
|
|
32
|
-
<
|
|
41
|
+
<PrimitiveAnchor
|
|
33
42
|
href={href}
|
|
34
43
|
target={target}
|
|
35
|
-
className={
|
|
44
|
+
className={classNames}
|
|
36
45
|
aria-label={ariaLabel}
|
|
37
46
|
rel={isBlank ? 'noreferrer' : undefined}
|
|
38
47
|
onClick={onClick}
|
|
39
48
|
{...props}
|
|
40
49
|
>
|
|
41
50
|
{children} {isBlank && <NavigateAwayIcon title={formatMessage(messages.opensInNewTab)} />}
|
|
42
|
-
</
|
|
51
|
+
</PrimitiveAnchor>
|
|
43
52
|
);
|
|
44
53
|
};
|
|
45
54
|
|