@transferwise/components 0.0.0-experimental-696128b → 0.0.0-experimental-b662b9c
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/types/button/Button.d.ts +2 -2
- package/build/types/button/Button.d.ts.map +1 -1
- package/build/types/button/Button.resolver.d.ts +2 -2
- package/build/types/button/Button.resolver.d.ts.map +1 -1
- package/build/types/button/Button.types.d.ts +3 -4
- package/build/types/button/Button.types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/button/Button.spec.tsx +17 -4
- package/src/button/Button.story.tsx +7 -49
- package/src/button/Button.types.ts +11 -3
- package/src/button/LegacyButton.story.tsx +0 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const Button: import("react").ForwardRefExoticComponent<
|
|
1
|
+
import { ButtonReferenceType, ButtonProps as NewButtonProps } from './Button.types';
|
|
2
|
+
declare const Button: import("react").ForwardRefExoticComponent<NewButtonProps & import("react").RefAttributes<ButtonReferenceType>>;
|
|
3
3
|
export default Button;
|
|
4
4
|
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/button/Button.tsx"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/button/Button.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEL,mBAAmB,EACnB,WAAW,IAAI,cAAc,EAC9B,MAAM,gBAAgB,CAAC;AAQxB,QAAA,MAAM,MAAM,gHAqGX,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LegacyButtonProps } from './LegacyButton';
|
|
2
2
|
import { ButtonReferenceType, ButtonProps as NewButtonProps } from './Button.types';
|
|
3
3
|
export type ButtonProps = LegacyButtonProps | NewButtonProps;
|
|
4
|
-
declare const Button: import("react").ForwardRefExoticComponent<(Omit<{
|
|
4
|
+
declare const Button: import("react").ForwardRefExoticComponent<(NewButtonProps | Omit<{
|
|
5
5
|
v2?: false;
|
|
6
6
|
block?: boolean;
|
|
7
7
|
disabled?: boolean;
|
|
@@ -28,6 +28,6 @@ declare const Button: import("react").ForwardRefExoticComponent<(Omit<{
|
|
|
28
28
|
}, "type"> & {
|
|
29
29
|
as?: "a";
|
|
30
30
|
href?: string;
|
|
31
|
-
}, "ref">
|
|
31
|
+
}, "ref">) & import("react").RefAttributes<ButtonReferenceType>>;
|
|
32
32
|
export default Button;
|
|
33
33
|
//# sourceMappingURL=Button.resolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.resolver.d.ts","sourceRoot":"","sources":["../../../src/button/Button.resolver.tsx"],"names":[],"mappings":"AACA,OAAqB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,WAAW,IAAI,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGpF,MAAM,MAAM,WAAW,GAAG,iBAAiB,GAAG,cAAc,CAAC;AAwD7D,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Button.resolver.d.ts","sourceRoot":"","sources":["../../../src/button/Button.resolver.tsx"],"names":[],"mappings":"AACA,OAAqB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,WAAW,IAAI,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGpF,MAAM,MAAM,WAAW,GAAG,iBAAiB,GAAG,cAAc,CAAC;AAwD7D,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;gEAOV,CAAC;AAIH,eAAe,MAAM,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import type { PrimitiveButtonProps, PrimitiveAnchorProps } from '../primitives';
|
|
1
|
+
import { AnchorHTMLAttributes, ButtonHTMLAttributes, ReactNode } from 'react';
|
|
3
2
|
import type { AvatarLayoutProps } from '../avatarLayout';
|
|
4
3
|
export type ButtonSentiment = 'default' | 'negative';
|
|
5
4
|
export type ButtonPriority = 'primary' | 'secondary' | 'tertiary' | 'minimal';
|
|
@@ -52,7 +51,7 @@ export interface CommonProps {
|
|
|
52
51
|
/** Content to be displayed inside the button */
|
|
53
52
|
children?: ReactNode;
|
|
54
53
|
}
|
|
55
|
-
export type ButtonElementProps =
|
|
56
|
-
export type AnchorElementProps =
|
|
54
|
+
export type ButtonElementProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'disabled' | 'className'> & CommonProps;
|
|
55
|
+
export type AnchorElementProps = Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'type' | 'disabled' | 'href' | 'className'> & CommonProps;
|
|
57
56
|
export type ButtonProps = ButtonElementProps | AnchorElementProps;
|
|
58
57
|
//# sourceMappingURL=Button.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.types.d.ts","sourceRoot":"","sources":["../../../src/button/Button.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Button.types.d.ts","sourceRoot":"","sources":["../../../src/button/Button.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,UAAU,CAAC;AACrD,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;AAC9E,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAC5C,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,GAA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experimental-
|
|
3
|
+
"version": "0.0.0-experimental-b662b9c",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -91,13 +91,13 @@
|
|
|
91
91
|
"rollup": "^4.18.1",
|
|
92
92
|
"rollup-preserve-directives": "^1.1.1",
|
|
93
93
|
"storybook": "^8.2.2",
|
|
94
|
+
"@transferwise/neptune-css": "0.0.0-experimental-b662b9c",
|
|
94
95
|
"@transferwise/less-config": "3.1.0",
|
|
95
|
-
"@transferwise/neptune-css": "0.0.0-experimental-696128b",
|
|
96
96
|
"@wise/components-theming": "1.6.1"
|
|
97
97
|
},
|
|
98
98
|
"peerDependencies": {
|
|
99
99
|
"@transferwise/icons": "^3.13.1",
|
|
100
|
-
"@transferwise/neptune-css": "0.0.0-experimental-
|
|
100
|
+
"@transferwise/neptune-css": "0.0.0-experimental-b662b9c",
|
|
101
101
|
"@wise/art": "^2.16",
|
|
102
102
|
"@wise/components-theming": "^1.0.0",
|
|
103
103
|
"react": ">=18",
|
|
@@ -14,9 +14,10 @@ describe('Button', () => {
|
|
|
14
14
|
v2: true,
|
|
15
15
|
priority: 'primary',
|
|
16
16
|
size: 'md',
|
|
17
|
-
testId: 'new-button',
|
|
18
17
|
};
|
|
19
18
|
|
|
19
|
+
const testId = 'new-button';
|
|
20
|
+
|
|
20
21
|
it('renders LegacyButton when v2 is false', () => {
|
|
21
22
|
render(<Button {...legacyProps}>Legacy Button</Button>);
|
|
22
23
|
const button = screen.getByText('Legacy Button');
|
|
@@ -25,7 +26,11 @@ describe('Button', () => {
|
|
|
25
26
|
});
|
|
26
27
|
|
|
27
28
|
it('renders the new Button when v2 is true', () => {
|
|
28
|
-
render(
|
|
29
|
+
render(
|
|
30
|
+
<Button data-testid={testId} {...newProps}>
|
|
31
|
+
New Button
|
|
32
|
+
</Button>,
|
|
33
|
+
);
|
|
29
34
|
const button = screen.getByTestId('new-button');
|
|
30
35
|
expect(button).toBeInTheDocument();
|
|
31
36
|
expect(button).toHaveClass('wds-Button wds-Button--medium wds-Button--primary');
|
|
@@ -75,7 +80,11 @@ describe('Button', () => {
|
|
|
75
80
|
// @ts-expect-error here we intentionally set wrong value to test `type` attr in DOM
|
|
76
81
|
type: 'accent',
|
|
77
82
|
};
|
|
78
|
-
render(
|
|
83
|
+
render(
|
|
84
|
+
<Button data-testid={testId} {...legacyTypeProps}>
|
|
85
|
+
Button Type
|
|
86
|
+
</Button>,
|
|
87
|
+
);
|
|
79
88
|
const button = screen.getByTestId('new-button');
|
|
80
89
|
expect(button).toBeInTheDocument();
|
|
81
90
|
expect(button).not.toHaveAttribute('type');
|
|
@@ -86,7 +95,11 @@ describe('Button', () => {
|
|
|
86
95
|
...newProps,
|
|
87
96
|
type: 'submit',
|
|
88
97
|
};
|
|
89
|
-
render(
|
|
98
|
+
render(
|
|
99
|
+
<Button data-testid={testId} {...buttonTypeProps}>
|
|
100
|
+
Submit Button
|
|
101
|
+
</Button>,
|
|
102
|
+
);
|
|
90
103
|
const button = screen.getByTestId('new-button');
|
|
91
104
|
expect(button).toBeInTheDocument();
|
|
92
105
|
expect(button).toHaveAttribute('type', 'submit');
|
|
@@ -225,11 +225,6 @@ const meta: Meta<typeof Button> = {
|
|
|
225
225
|
disable: true,
|
|
226
226
|
},
|
|
227
227
|
},
|
|
228
|
-
'data-testid': {
|
|
229
|
-
table: {
|
|
230
|
-
disable: true,
|
|
231
|
-
},
|
|
232
|
-
},
|
|
233
228
|
},
|
|
234
229
|
args: {
|
|
235
230
|
v2: true,
|
|
@@ -245,7 +240,6 @@ const meta: Meta<typeof Button> = {
|
|
|
245
240
|
iconStart: undefined,
|
|
246
241
|
iconEnd: undefined,
|
|
247
242
|
avatars: undefined,
|
|
248
|
-
testId: undefined,
|
|
249
243
|
className: undefined,
|
|
250
244
|
onClick: fn(),
|
|
251
245
|
children: 'Button text',
|
|
@@ -313,16 +307,7 @@ export const Sentiment: StoryObj<PreviewStoryArgs> = {
|
|
|
313
307
|
);
|
|
314
308
|
},
|
|
315
309
|
argTypes: {
|
|
316
|
-
...hideControls([
|
|
317
|
-
'sentiment',
|
|
318
|
-
'priority',
|
|
319
|
-
'block',
|
|
320
|
-
'href',
|
|
321
|
-
'target',
|
|
322
|
-
'as',
|
|
323
|
-
'children',
|
|
324
|
-
'testId',
|
|
325
|
-
]),
|
|
310
|
+
...hideControls(['sentiment', 'priority', 'block', 'href', 'target', 'as', 'children']),
|
|
326
311
|
...previewArgTypes,
|
|
327
312
|
},
|
|
328
313
|
args: {
|
|
@@ -361,7 +346,7 @@ export const Priority: StoryObj<PreviewStoryArgs> = {
|
|
|
361
346
|
);
|
|
362
347
|
},
|
|
363
348
|
argTypes: {
|
|
364
|
-
...hideControls(['priority', 'block', 'href', 'target', 'as', 'children'
|
|
349
|
+
...hideControls(['priority', 'block', 'href', 'target', 'as', 'children']),
|
|
365
350
|
...previewArgTypes,
|
|
366
351
|
},
|
|
367
352
|
args: {
|
|
@@ -395,7 +380,7 @@ export const Size: StoryObj<PreviewStoryArgs> = {
|
|
|
395
380
|
);
|
|
396
381
|
},
|
|
397
382
|
argTypes: {
|
|
398
|
-
...hideControls(['size', 'block', 'href', 'target', 'as', 'children'
|
|
383
|
+
...hideControls(['size', 'block', 'href', 'target', 'as', 'children']),
|
|
399
384
|
...previewArgTypes,
|
|
400
385
|
},
|
|
401
386
|
args: {
|
|
@@ -491,16 +476,7 @@ export const DisplayBlock: StoryObj<PreviewStoryArgs> = {
|
|
|
491
476
|
);
|
|
492
477
|
},
|
|
493
478
|
argTypes: {
|
|
494
|
-
...hideControls([
|
|
495
|
-
'href',
|
|
496
|
-
'target',
|
|
497
|
-
'priority',
|
|
498
|
-
'sentiment',
|
|
499
|
-
'as',
|
|
500
|
-
'disabled',
|
|
501
|
-
'children',
|
|
502
|
-
'testId',
|
|
503
|
-
]),
|
|
479
|
+
...hideControls(['href', 'target', 'priority', 'sentiment', 'as', 'disabled', 'children']),
|
|
504
480
|
...previewArgTypes,
|
|
505
481
|
},
|
|
506
482
|
args: {
|
|
@@ -536,16 +512,7 @@ export const WithIcons: StoryObj<PreviewStoryArgs> = {
|
|
|
536
512
|
);
|
|
537
513
|
},
|
|
538
514
|
argTypes: {
|
|
539
|
-
...hideControls([
|
|
540
|
-
'href',
|
|
541
|
-
'target',
|
|
542
|
-
'priority',
|
|
543
|
-
'sentiment',
|
|
544
|
-
'as',
|
|
545
|
-
'disabled',
|
|
546
|
-
'children',
|
|
547
|
-
'testId',
|
|
548
|
-
]),
|
|
515
|
+
...hideControls(['href', 'target', 'priority', 'sentiment', 'as', 'disabled', 'children']),
|
|
549
516
|
},
|
|
550
517
|
args: {
|
|
551
518
|
size: 'md',
|
|
@@ -582,16 +549,7 @@ export const WithAvatars: StoryObj<PreviewStoryArgs> = {
|
|
|
582
549
|
</>
|
|
583
550
|
);
|
|
584
551
|
},
|
|
585
|
-
argTypes: hideControls([
|
|
586
|
-
'href',
|
|
587
|
-
'target',
|
|
588
|
-
'priority',
|
|
589
|
-
'sentiment',
|
|
590
|
-
'as',
|
|
591
|
-
'disabled',
|
|
592
|
-
'children',
|
|
593
|
-
'testId',
|
|
594
|
-
]),
|
|
552
|
+
argTypes: hideControls(['href', 'target', 'priority', 'sentiment', 'as', 'disabled', 'children']),
|
|
595
553
|
args: {
|
|
596
554
|
size: 'md',
|
|
597
555
|
avatars: [],
|
|
@@ -634,7 +592,7 @@ export const WithAvatarAndIcon: Story = {
|
|
|
634
592
|
avatars: [{ profileName: 'John Doe' }],
|
|
635
593
|
iconEnd: ArrowRight,
|
|
636
594
|
},
|
|
637
|
-
argTypes: hideControls(['href', 'target', 'as', 'children'
|
|
595
|
+
argTypes: hideControls(['href', 'target', 'as', 'children']),
|
|
638
596
|
parameters: augmentIconProps(),
|
|
639
597
|
};
|
|
640
598
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { AnchorHTMLAttributes, ButtonHTMLAttributes, ReactNode } from 'react';
|
|
2
2
|
import type { PrimitiveButtonProps, PrimitiveAnchorProps } from '../primitives';
|
|
3
3
|
import type { AvatarLayoutProps } from '../avatarLayout';
|
|
4
4
|
|
|
@@ -68,7 +68,15 @@ export interface CommonProps {
|
|
|
68
68
|
children?: ReactNode;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
export type ButtonElementProps =
|
|
72
|
-
|
|
71
|
+
export type ButtonElementProps = Omit<
|
|
72
|
+
ButtonHTMLAttributes<HTMLButtonElement>,
|
|
73
|
+
'disabled' | 'className'
|
|
74
|
+
> &
|
|
75
|
+
CommonProps;
|
|
76
|
+
export type AnchorElementProps = Omit<
|
|
77
|
+
AnchorHTMLAttributes<HTMLAnchorElement>,
|
|
78
|
+
'type' | 'disabled' | 'href' | 'className'
|
|
79
|
+
> &
|
|
80
|
+
CommonProps;
|
|
73
81
|
|
|
74
82
|
export type ButtonProps = ButtonElementProps | AnchorElementProps;
|