@transferwise/components 0.0.0-experimental-6940853 → 0.0.0-experimental-d4d8885
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/body/Body.js +0 -1
- package/build/body/Body.js.map +1 -1
- package/build/body/Body.mjs +0 -1
- package/build/body/Body.mjs.map +1 -1
- package/package.json +2 -2
- package/src/body/Body.spec.tsx +8 -0
- package/src/body/Body.story.tsx +12 -0
- package/src/body/Body.tsx +1 -1
- package/src/instructionsList/InstructionsList.story.tsx +35 -37
package/build/body/Body.js
CHANGED
package/build/body/Body.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Body.js","sources":["../../src/body/Body.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { forwardRef, HTMLAttributes } from 'react';\n\nimport { Typography, BodyTypes } from '../common/propsValues/typography';\n\nconst DEFAULT_TYPE = Typography.BODY_DEFAULT;\n\nconst bodyTypes = new Set<BodyTypes>([\n Typography.BODY_DEFAULT,\n Typography.BODY_DEFAULT_BOLD,\n Typography.BODY_LARGE,\n Typography.BODY_LARGE_BOLD,\n]);\n\ntype Props = HTMLAttributes<HTMLSpanElement | HTMLParagraphElement> & {\n /**\n * Default value: {@link DEFAULT_TYPE}\n */\n type?: BodyTypes;\n /**\n * Default value: `div`\n */\n as?: 'span' | 'p' | 'div';\n /**\n * When true, preserves newline characters in the text\n * @default false\n */\n preserveNewlines?: boolean;\n};\n\nconst Body = forwardRef(function Body(\n { as: Element = 'div', type = DEFAULT_TYPE, className, preserveNewlines,
|
|
1
|
+
{"version":3,"file":"Body.js","sources":["../../src/body/Body.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { forwardRef, HTMLAttributes } from 'react';\n\nimport { Typography, BodyTypes } from '../common/propsValues/typography';\n\nconst DEFAULT_TYPE = Typography.BODY_DEFAULT;\n\nconst bodyTypes = new Set<BodyTypes>([\n Typography.BODY_DEFAULT,\n Typography.BODY_DEFAULT_BOLD,\n Typography.BODY_LARGE,\n Typography.BODY_LARGE_BOLD,\n]);\n\ntype Props = HTMLAttributes<HTMLSpanElement | HTMLParagraphElement> & {\n /**\n * Default value: {@link DEFAULT_TYPE}\n */\n type?: BodyTypes;\n /**\n * Default value: `div`\n */\n as?: 'span' | 'p' | 'div';\n /**\n * When true, preserves newline characters in the text\n * @default false\n */\n preserveNewlines?: boolean;\n};\n\nconst Body = forwardRef(function Body(\n { as: Element = 'div', type = DEFAULT_TYPE, className, preserveNewlines, ...props }: Props,\n reference: React.ForwardedRef<\n | {\n [key in typeof Element]: React.ElementRef<key>;\n }[typeof Element]\n | null\n >,\n) {\n const isTypeSupported = bodyTypes.has(type);\n return (\n <Element\n {...props}\n // @ts-expect-error TODO: Remove when component could be rewritten with generics\n // See: https://fettblog.eu/typescript-react-generic-forward-refs/\n ref={reference}\n className={clsx(\n `np-text-${isTypeSupported ? type : DEFAULT_TYPE}`,\n preserveNewlines && 'np-text--pre-line',\n className,\n )}\n />\n );\n});\n\nexport default Body;\n"],"names":["DEFAULT_TYPE","Typography","BODY_DEFAULT","bodyTypes","Set","BODY_DEFAULT_BOLD","BODY_LARGE","BODY_LARGE_BOLD","Body","forwardRef","as","Element","type","className","preserveNewlines","props","reference","isTypeSupported","has","_jsx","ref","clsx"],"mappings":";;;;;;;;;AAKA,MAAMA,YAAY,GAAGC,qBAAU,CAACC,YAAY;AAE5C,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAAY,CACnCH,qBAAU,CAACC,YAAY,EACvBD,qBAAU,CAACI,iBAAiB,EAC5BJ,qBAAU,CAACK,UAAU,EACrBL,qBAAU,CAACM,eAAe,CAC3B,CAAC;AAkBF,MAAMC,IAAI,gBAAGC,gBAAU,CAAC,SAASD,IAAIA,CACnC;EAAEE,EAAE,EAAEC,OAAO,GAAG,KAAK;AAAEC,EAAAA,IAAI,GAAGZ,YAAY;EAAEa,SAAS;EAAEC,gBAAgB;EAAE,GAAGC;AAAc,CAAA,EAC1FC,SAKC,EAAA;AAED,EAAA,MAAMC,eAAe,GAAGd,SAAS,CAACe,GAAG,CAACN,IAAI,CAAC;EAC3C,oBACEO,cAAA,CAACR,OAAO,EAAA;AAAA,IAAA,GACFI,KAAK;AACT;AACA;AACAK,IAAAA,GAAG,EAAEJ,SAAU;AACfH,IAAAA,SAAS,EAAEQ,SAAI,CACb,CAAA,QAAA,EAAWJ,eAAe,GAAGL,IAAI,GAAGZ,YAAY,EAAE,EAClDc,gBAAgB,IAAI,mBAAmB,EACvCD,SAAS;AACT,GAAA,CACF;AAEN,CAAC;;;;"}
|
package/build/body/Body.mjs
CHANGED
package/build/body/Body.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Body.mjs","sources":["../../src/body/Body.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { forwardRef, HTMLAttributes } from 'react';\n\nimport { Typography, BodyTypes } from '../common/propsValues/typography';\n\nconst DEFAULT_TYPE = Typography.BODY_DEFAULT;\n\nconst bodyTypes = new Set<BodyTypes>([\n Typography.BODY_DEFAULT,\n Typography.BODY_DEFAULT_BOLD,\n Typography.BODY_LARGE,\n Typography.BODY_LARGE_BOLD,\n]);\n\ntype Props = HTMLAttributes<HTMLSpanElement | HTMLParagraphElement> & {\n /**\n * Default value: {@link DEFAULT_TYPE}\n */\n type?: BodyTypes;\n /**\n * Default value: `div`\n */\n as?: 'span' | 'p' | 'div';\n /**\n * When true, preserves newline characters in the text\n * @default false\n */\n preserveNewlines?: boolean;\n};\n\nconst Body = forwardRef(function Body(\n { as: Element = 'div', type = DEFAULT_TYPE, className, preserveNewlines,
|
|
1
|
+
{"version":3,"file":"Body.mjs","sources":["../../src/body/Body.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { forwardRef, HTMLAttributes } from 'react';\n\nimport { Typography, BodyTypes } from '../common/propsValues/typography';\n\nconst DEFAULT_TYPE = Typography.BODY_DEFAULT;\n\nconst bodyTypes = new Set<BodyTypes>([\n Typography.BODY_DEFAULT,\n Typography.BODY_DEFAULT_BOLD,\n Typography.BODY_LARGE,\n Typography.BODY_LARGE_BOLD,\n]);\n\ntype Props = HTMLAttributes<HTMLSpanElement | HTMLParagraphElement> & {\n /**\n * Default value: {@link DEFAULT_TYPE}\n */\n type?: BodyTypes;\n /**\n * Default value: `div`\n */\n as?: 'span' | 'p' | 'div';\n /**\n * When true, preserves newline characters in the text\n * @default false\n */\n preserveNewlines?: boolean;\n};\n\nconst Body = forwardRef(function Body(\n { as: Element = 'div', type = DEFAULT_TYPE, className, preserveNewlines, ...props }: Props,\n reference: React.ForwardedRef<\n | {\n [key in typeof Element]: React.ElementRef<key>;\n }[typeof Element]\n | null\n >,\n) {\n const isTypeSupported = bodyTypes.has(type);\n return (\n <Element\n {...props}\n // @ts-expect-error TODO: Remove when component could be rewritten with generics\n // See: https://fettblog.eu/typescript-react-generic-forward-refs/\n ref={reference}\n className={clsx(\n `np-text-${isTypeSupported ? type : DEFAULT_TYPE}`,\n preserveNewlines && 'np-text--pre-line',\n className,\n )}\n />\n );\n});\n\nexport default Body;\n"],"names":["DEFAULT_TYPE","Typography","BODY_DEFAULT","bodyTypes","Set","BODY_DEFAULT_BOLD","BODY_LARGE","BODY_LARGE_BOLD","Body","forwardRef","as","Element","type","className","preserveNewlines","props","reference","isTypeSupported","has","_jsx","ref","clsx"],"mappings":";;;;;AAKA,MAAMA,YAAY,GAAGC,UAAU,CAACC,YAAY;AAE5C,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAAY,CACnCH,UAAU,CAACC,YAAY,EACvBD,UAAU,CAACI,iBAAiB,EAC5BJ,UAAU,CAACK,UAAU,EACrBL,UAAU,CAACM,eAAe,CAC3B,CAAC;AAkBF,MAAMC,IAAI,gBAAGC,UAAU,CAAC,SAASD,IAAIA,CACnC;EAAEE,EAAE,EAAEC,OAAO,GAAG,KAAK;AAAEC,EAAAA,IAAI,GAAGZ,YAAY;EAAEa,SAAS;EAAEC,gBAAgB;EAAE,GAAGC;AAAc,CAAA,EAC1FC,SAKC,EAAA;AAED,EAAA,MAAMC,eAAe,GAAGd,SAAS,CAACe,GAAG,CAACN,IAAI,CAAC;EAC3C,oBACEO,GAAA,CAACR,OAAO,EAAA;AAAA,IAAA,GACFI,KAAK;AACT;AACA;AACAK,IAAAA,GAAG,EAAEJ,SAAU;AACfH,IAAAA,SAAS,EAAEQ,IAAI,CACb,CAAA,QAAA,EAAWJ,eAAe,GAAGL,IAAI,GAAGZ,YAAY,EAAE,EAClDc,gBAAgB,IAAI,mBAAmB,EACvCD,SAAS;AACT,GAAA,CACF;AAEN,CAAC;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/components",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-d4d8885",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -92,8 +92,8 @@
|
|
|
92
92
|
"rollup-preserve-directives": "^1.1.3",
|
|
93
93
|
"storybook": "^8.6.14",
|
|
94
94
|
"@transferwise/less-config": "3.1.2",
|
|
95
|
-
"@wise/components-theming": "1.6.3",
|
|
96
95
|
"@transferwise/neptune-css": "14.24.4",
|
|
96
|
+
"@wise/components-theming": "1.6.3",
|
|
97
97
|
"@wise/wds-configs": "0.0.0"
|
|
98
98
|
},
|
|
99
99
|
"peerDependencies": {
|
package/src/body/Body.spec.tsx
CHANGED
|
@@ -32,6 +32,14 @@ describe('Body', () => {
|
|
|
32
32
|
expect(copy).toHaveAttribute('role', 'banner');
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
+
it('renders newlines as line breaks when preserveNewlines is true', () => {
|
|
36
|
+
render(<Body preserveNewlines>{'Line 1.\nLine 2'}</Body>);
|
|
37
|
+
const copy = screen.getByText(/Line 1\.\s*Line 2/);
|
|
38
|
+
expect(copy).toHaveClass('np-text--pre-line');
|
|
39
|
+
expect(copy).toHaveTextContent('Line 1.');
|
|
40
|
+
expect(copy).toHaveTextContent('Line 2');
|
|
41
|
+
});
|
|
42
|
+
|
|
35
43
|
it('handles unsupported typography type', () => {
|
|
36
44
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
37
45
|
// @ts-expect-error
|
package/src/body/Body.story.tsx
CHANGED
|
@@ -18,6 +18,9 @@ export const Basic = () => {
|
|
|
18
18
|
We’re building the world’s most <strong>international account</strong>. We’re building the
|
|
19
19
|
world’s most <b>international account</b>.
|
|
20
20
|
</Body>
|
|
21
|
+
<Body as="p" type={Typography.BODY_LARGE_BOLD} preserveNewlines>
|
|
22
|
+
{'This is line one.\nThis is line two.'}
|
|
23
|
+
</Body>
|
|
21
24
|
<Body as="p" type={Typography.BODY_LARGE_BOLD}>
|
|
22
25
|
Ми будуємо найбільш <strong>міжнародний рахунок у світі</strong>. Ми будуємо найбільш{' '}
|
|
23
26
|
<b>міжнародний рахунок у світі</b>.
|
|
@@ -40,6 +43,9 @@ export const Basic = () => {
|
|
|
40
43
|
We’re building the world’s most <strong>international account</strong>. We’re building the
|
|
41
44
|
world’s most <b>international account</b>.
|
|
42
45
|
</Body>
|
|
46
|
+
<Body as="p" preserveNewlines>
|
|
47
|
+
{'This is line one.\nThis is line two.'}
|
|
48
|
+
</Body>
|
|
43
49
|
<Body as="p" type={Typography.BODY_DEFAULT}>
|
|
44
50
|
Ми будуємо найбільш <strong>міжнародний рахунок у світі</strong>. Ми будуємо найбільш{' '}
|
|
45
51
|
<b>міжнародний рахунок у світі</b>.
|
|
@@ -62,6 +68,9 @@ export const Basic = () => {
|
|
|
62
68
|
We’re building the world’s most <strong>international account</strong>. We’re building the
|
|
63
69
|
world’s most <b>international account</b>.
|
|
64
70
|
</Body>
|
|
71
|
+
<Body as="p" type={Typography.BODY_DEFAULT_BOLD} preserveNewlines>
|
|
72
|
+
{'This is line one.\nThis is line two.'}
|
|
73
|
+
</Body>
|
|
65
74
|
<Body as="p" type={Typography.BODY_DEFAULT_BOLD}>
|
|
66
75
|
Ми будуємо найбільш <strong>міжнародний рахунок у світі</strong>. Ми будуємо найбільш{' '}
|
|
67
76
|
<b>міжнародний рахунок у світі</b>.
|
|
@@ -84,6 +93,9 @@ export const Basic = () => {
|
|
|
84
93
|
We’re building the world’s most <strong>international account</strong>. We’re building the
|
|
85
94
|
world’s most <b>international account</b>.
|
|
86
95
|
</Body>
|
|
96
|
+
<Body as="p" type={Typography.BODY_LARGE} preserveNewlines>
|
|
97
|
+
{'This is line one.\nThis is line two.'}
|
|
98
|
+
</Body>
|
|
87
99
|
<Body as="p" type={Typography.BODY_LARGE}>
|
|
88
100
|
Ми будуємо найбільш <strong>міжнародний рахунок у світі</strong>. Ми будуємо найбільш{' '}
|
|
89
101
|
<b>міжнародний рахунок у світі</b>.
|
package/src/body/Body.tsx
CHANGED
|
@@ -29,7 +29,7 @@ type Props = HTMLAttributes<HTMLSpanElement | HTMLParagraphElement> & {
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
const Body = forwardRef(function Body(
|
|
32
|
-
{ as: Element = 'div', type = DEFAULT_TYPE, className, preserveNewlines,
|
|
32
|
+
{ as: Element = 'div', type = DEFAULT_TYPE, className, preserveNewlines, ...props }: Props,
|
|
33
33
|
reference: React.ForwardedRef<
|
|
34
34
|
| {
|
|
35
35
|
[key in typeof Element]: React.ElementRef<key>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { fn } from '@storybook/test';
|
|
3
|
+
import { storyConfig } from '../test-utils';
|
|
2
4
|
|
|
3
5
|
import Link from '../link';
|
|
4
6
|
|
|
@@ -7,46 +9,42 @@ import InstructionsList, { InstructionsListProps } from './InstructionsList';
|
|
|
7
9
|
export default {
|
|
8
10
|
component: InstructionsList,
|
|
9
11
|
title: 'Typography/InstructionsList',
|
|
10
|
-
}
|
|
12
|
+
render: (args) => <InstructionsList {...args} />,
|
|
13
|
+
tags: ['autodocs'],
|
|
14
|
+
} satisfies Meta<typeof InstructionsList>;
|
|
15
|
+
|
|
16
|
+
type Story = StoryObj<typeof InstructionsList>;
|
|
11
17
|
|
|
12
|
-
export const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
donts={['Paying extra hidden fees for transfers', 'Use bad exchange rate']}
|
|
29
|
-
sort={args.sort}
|
|
30
|
-
/>
|
|
31
|
-
<hr />
|
|
32
|
-
<InstructionsList
|
|
33
|
-
dos={[
|
|
34
|
-
{ content: 'Multiple currencies', 'aria-label': 'Supports multiple currencies' },
|
|
35
|
-
{ content: 'Existing recipients', 'aria-label': 'Supports existing recipients' },
|
|
36
|
-
]}
|
|
37
|
-
donts={[
|
|
38
|
-
{ content: 'Create recipients', 'aria-label': "Doesn't support creating recipients" },
|
|
39
|
-
{ content: 'Edit recipients', 'aria-label': "Doesn't support editing recipients" },
|
|
40
|
-
]}
|
|
41
|
-
sort={args.sort}
|
|
42
|
-
/>
|
|
43
|
-
</>
|
|
44
|
-
);
|
|
18
|
+
export const Basic: Story = {
|
|
19
|
+
args: {
|
|
20
|
+
sort: 'dosFirst',
|
|
21
|
+
dos: [
|
|
22
|
+
'Do an initial money transfer',
|
|
23
|
+
'Invite at least 3 friends',
|
|
24
|
+
<span key="12">
|
|
25
|
+
Paying extra{' '}
|
|
26
|
+
<Link href="" type="link-large">
|
|
27
|
+
hidden fees
|
|
28
|
+
</Link>{' '}
|
|
29
|
+
for transfers
|
|
30
|
+
</span>,
|
|
31
|
+
],
|
|
32
|
+
donts: ['Paying extra hidden fees for transfers', 'Use bad exchange rate'],
|
|
33
|
+
},
|
|
45
34
|
};
|
|
46
35
|
|
|
47
|
-
export const
|
|
48
|
-
render: Template,
|
|
36
|
+
export const WithNewLine: Story = {
|
|
49
37
|
args: {
|
|
50
38
|
sort: 'dosFirst',
|
|
39
|
+
dos: [
|
|
40
|
+
'Do an initial money transfer',
|
|
41
|
+
'Invite at least 3 friends',
|
|
42
|
+
'This do item has a newline:\nSecond line appears below',
|
|
43
|
+
],
|
|
44
|
+
donts: [
|
|
45
|
+
'Paying extra hidden fees for transfers',
|
|
46
|
+
'Use bad exchange rate',
|
|
47
|
+
'This dont item has a newline:\nSecond line appears below',
|
|
48
|
+
],
|
|
51
49
|
},
|
|
52
50
|
};
|