@transferwise/components 46.98.1 → 46.99.0

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.
@@ -13,6 +13,7 @@ const Body = /*#__PURE__*/React.forwardRef(function Body({
13
13
  as: Element = 'div',
14
14
  type = DEFAULT_TYPE,
15
15
  className,
16
+ preserveNewlines,
16
17
  ...props
17
18
  }, reference) {
18
19
  const isTypeSupported = bodyTypes.has(type);
@@ -21,7 +22,7 @@ const Body = /*#__PURE__*/React.forwardRef(function Body({
21
22
  // @ts-expect-error TODO: Remove when component could be rewritten with generics
22
23
  // See: https://fettblog.eu/typescript-react-generic-forward-refs/
23
24
  ref: reference,
24
- className: clsx.clsx(`np-text-${isTypeSupported ? type : DEFAULT_TYPE}`, className)
25
+ className: clsx.clsx(`np-text-${isTypeSupported ? type : DEFAULT_TYPE}`, preserveNewlines && 'np-text--pre-line', className)
25
26
  });
26
27
  });
27
28
 
@@ -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\nconst Body = forwardRef(function Body(\n { as: Element = 'div', type = DEFAULT_TYPE, className, ...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(`np-text-${isTypeSupported ? type : DEFAULT_TYPE}`, className)}\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","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;AAaF,MAAMC,IAAI,gBAAGC,gBAAU,CAAC,SAASD,IAAIA,CACnC;EAAEE,EAAE,EAAEC,OAAO,GAAG,KAAK;AAAEC,EAAAA,IAAI,GAAGZ,YAAY;EAAEa,SAAS;EAAE,GAAGC;AAAc,CAAA,EACxEC,SAKC,EAAA;AAED,EAAA,MAAMC,eAAe,GAAGb,SAAS,CAACc,GAAG,CAACL,IAAI,CAAC;EAC3C,oBACEM,cAAA,CAACP,OAAO,EAAA;AAAA,IAAA,GACFG,KAAK;AACT;AACA;AACAK,IAAAA,GAAG,EAAEJ,SAAU;IACfF,SAAS,EAAEO,SAAI,CAAC,CAAWJ,QAAAA,EAAAA,eAAe,GAAGJ,IAAI,GAAGZ,YAAY,CAAE,CAAA,EAAEa,SAAS;AAAE,GAC/E,CAAA;AAEN,CAAC;;;;"}
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;;;;"}
@@ -9,6 +9,7 @@ const Body = /*#__PURE__*/forwardRef(function Body({
9
9
  as: Element = 'div',
10
10
  type = DEFAULT_TYPE,
11
11
  className,
12
+ preserveNewlines,
12
13
  ...props
13
14
  }, reference) {
14
15
  const isTypeSupported = bodyTypes.has(type);
@@ -17,7 +18,7 @@ const Body = /*#__PURE__*/forwardRef(function Body({
17
18
  // @ts-expect-error TODO: Remove when component could be rewritten with generics
18
19
  // See: https://fettblog.eu/typescript-react-generic-forward-refs/
19
20
  ref: reference,
20
- className: clsx(`np-text-${isTypeSupported ? type : DEFAULT_TYPE}`, className)
21
+ className: clsx(`np-text-${isTypeSupported ? type : DEFAULT_TYPE}`, preserveNewlines && 'np-text--pre-line', className)
21
22
  });
22
23
  });
23
24
 
@@ -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\nconst Body = forwardRef(function Body(\n { as: Element = 'div', type = DEFAULT_TYPE, className, ...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(`np-text-${isTypeSupported ? type : DEFAULT_TYPE}`, className)}\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","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;AAaF,MAAMC,IAAI,gBAAGC,UAAU,CAAC,SAASD,IAAIA,CACnC;EAAEE,EAAE,EAAEC,OAAO,GAAG,KAAK;AAAEC,EAAAA,IAAI,GAAGZ,YAAY;EAAEa,SAAS;EAAE,GAAGC;AAAc,CAAA,EACxEC,SAKC,EAAA;AAED,EAAA,MAAMC,eAAe,GAAGb,SAAS,CAACc,GAAG,CAACL,IAAI,CAAC;EAC3C,oBACEM,GAAA,CAACP,OAAO,EAAA;AAAA,IAAA,GACFG,KAAK;AACT;AACA;AACAK,IAAAA,GAAG,EAAEJ,SAAU;IACfF,SAAS,EAAEO,IAAI,CAAC,CAAWJ,QAAAA,EAAAA,eAAe,GAAGJ,IAAI,GAAGZ,YAAY,CAAE,CAAA,EAAEa,SAAS;AAAE,GAC/E,CAAA;AAEN,CAAC;;;;"}
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;;;;"}
@@ -77,6 +77,7 @@ function Instruction({
77
77
  }), /*#__PURE__*/jsxRuntime.jsx(Body.default, {
78
78
  className: "text-primary",
79
79
  type: typography.Typography.BODY_LARGE,
80
+ preserveNewlines: true,
80
81
  children: isInstructionNode ? item.content : item
81
82
  })]
82
83
  });
@@ -1 +1 @@
1
- {"version":3,"file":"InstructionsList.js","sources":["../../src/instructionsList/InstructionsList.tsx"],"sourcesContent":["import { CrossCircleFill as DontIcon, CheckCircleFill as DoIcon } from '@transferwise/icons';\nimport { clsx } from 'clsx';\nimport { ReactNode } from 'react';\n\nimport Body from '../body/Body';\nimport { Typography, CommonProps } from '../common';\n\ntype InstructionNode = {\n content: ReactNode;\n ['aria-label']: string;\n};\n\nexport type InstructionsListProps = CommonProps &\n (\n | {\n dos?: readonly ReactNode[];\n donts?: readonly ReactNode[];\n sort?: 'dosFirst' | 'dontsFirst';\n }\n | {\n dos?: readonly InstructionNode[];\n donts?: readonly InstructionNode[];\n sort?: 'dosFirst' | 'dontsFirst';\n }\n );\n\nconst InstructionsList = ({ className, dos, donts, sort = 'dosFirst' }: InstructionsListProps) => {\n const dosInstructions =\n dos?.map((doThis, index) => (\n // eslint-disable-next-line react/no-array-index-key\n <Instruction key={index} item={doThis} type=\"do\" />\n )) ?? null;\n\n const dontsInstructions =\n donts?.map((dont, index) => (\n // eslint-disable-next-line react/no-array-index-key\n <Instruction key={index} item={dont} type=\"dont\" />\n )) ?? null;\n\n const orderedInstructions =\n sort === 'dosFirst' ? (\n <>\n {dosInstructions}\n {dontsInstructions}\n </>\n ) : (\n <>\n {dontsInstructions}\n {dosInstructions}\n </>\n );\n\n return <ul className={clsx('tw-instructions', className)}>{orderedInstructions}</ul>;\n};\n\nfunction Instruction({ item, type }: { item: ReactNode | InstructionNode; type: 'do' | 'dont' }) {\n const isInstructionNode =\n typeof item === 'object' && item !== null && 'content' in item && 'aria-label' in item;\n return (\n <li className=\"instruction\">\n {type === 'do' ? (\n <DoIcon\n size={24}\n className={type}\n title={isInstructionNode ? item['aria-label'] : undefined}\n />\n ) : (\n <DontIcon\n size={24}\n className={type}\n title={isInstructionNode ? item['aria-label'] : undefined}\n />\n )}\n <Body className=\"text-primary\" type={Typography.BODY_LARGE}>\n {isInstructionNode ? item.content : item}\n </Body>\n </li>\n );\n}\n\nexport default InstructionsList;\n"],"names":["InstructionsList","className","dos","donts","sort","dosInstructions","map","doThis","index","_jsx","Instruction","item","type","dontsInstructions","dont","orderedInstructions","_jsxs","_Fragment","children","clsx","isInstructionNode","DoIcon","size","title","undefined","DontIcon","Body","Typography","BODY_LARGE","content"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BMA,MAAAA,gBAAgB,GAAGA,CAAC;EAAEC,SAAS;EAAEC,GAAG;EAAEC,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AAA,QAAA,GACxBN,IAAI,KAAK,IAAI,gBACZH,cAAA,CAACY,qBAAM,EAAA;AACLC,MAAAA,IAAI,EAAE,EAAG;AACTrB,MAAAA,SAAS,EAAEW,IAAK;AAChBW,MAAAA,KAAK,EAAEH,iBAAiB,GAAGT,IAAI,CAAC,YAAY,CAAC,GAAGa;AAAU,KAC1D,CAAA,gBAEFf,cAAA,CAACgB,qBAAQ,EAAA;AACPH,MAAAA,IAAI,EAAE,EAAG;AACTrB,MAAAA,SAAS,EAAEW,IAAK;AAChBW,MAAAA,KAAK,EAAEH,iBAAiB,GAAGT,IAAI,CAAC,YAAY,CAAC,GAAGa;AAAU,KAAA,CAE7D,eACDf,cAAA,CAACiB,YAAI,EAAA;AAACzB,MAAAA,SAAS,EAAC,cAAc;MAACW,IAAI,EAAEe,qBAAU,CAACC,UAAW;AAAAV,MAAAA,QAAA,EACxDE,iBAAiB,GAAGT,IAAI,CAACkB,OAAO,GAAGlB;AAAI,KACpC,CACR;AAAA,GAAI,CAAC;AAET;;;;"}
1
+ {"version":3,"file":"InstructionsList.js","sources":["../../src/instructionsList/InstructionsList.tsx"],"sourcesContent":["import { CrossCircleFill as DontIcon, CheckCircleFill as DoIcon } from '@transferwise/icons';\nimport { clsx } from 'clsx';\nimport { ReactNode } from 'react';\n\nimport Body from '../body/Body';\nimport { Typography, CommonProps } from '../common';\n\ntype InstructionNode = {\n content: ReactNode;\n ['aria-label']: string;\n};\n\nexport type InstructionsListProps = CommonProps &\n (\n | {\n dos?: readonly ReactNode[];\n donts?: readonly ReactNode[];\n sort?: 'dosFirst' | 'dontsFirst';\n }\n | {\n dos?: readonly InstructionNode[];\n donts?: readonly InstructionNode[];\n sort?: 'dosFirst' | 'dontsFirst';\n }\n );\n\nconst InstructionsList = ({ className, dos, donts, sort = 'dosFirst' }: InstructionsListProps) => {\n const dosInstructions =\n dos?.map((doThis, index) => (\n // eslint-disable-next-line react/no-array-index-key\n <Instruction key={index} item={doThis} type=\"do\" />\n )) ?? null;\n\n const dontsInstructions =\n donts?.map((dont, index) => (\n // eslint-disable-next-line react/no-array-index-key\n <Instruction key={index} item={dont} type=\"dont\" />\n )) ?? null;\n\n const orderedInstructions =\n sort === 'dosFirst' ? (\n <>\n {dosInstructions}\n {dontsInstructions}\n </>\n ) : (\n <>\n {dontsInstructions}\n {dosInstructions}\n </>\n );\n\n return <ul className={clsx('tw-instructions', className)}>{orderedInstructions}</ul>;\n};\n\nfunction Instruction({ item, type }: { item: ReactNode | InstructionNode; type: 'do' | 'dont' }) {\n const isInstructionNode =\n typeof item === 'object' && item !== null && 'content' in item && 'aria-label' in item;\n return (\n <li className=\"instruction\">\n {type === 'do' ? (\n <DoIcon\n size={24}\n className={type}\n title={isInstructionNode ? item['aria-label'] : undefined}\n />\n ) : (\n <DontIcon\n size={24}\n className={type}\n title={isInstructionNode ? item['aria-label'] : undefined}\n />\n )}\n <Body className=\"text-primary\" type={Typography.BODY_LARGE} preserveNewlines>\n {isInstructionNode ? item.content : item}\n </Body>\n </li>\n );\n}\n\nexport default InstructionsList;\n"],"names":["InstructionsList","className","dos","donts","sort","dosInstructions","map","doThis","index","_jsx","Instruction","item","type","dontsInstructions","dont","orderedInstructions","_jsxs","_Fragment","children","clsx","isInstructionNode","DoIcon","size","title","undefined","DontIcon","Body","Typography","BODY_LARGE","preserveNewlines","content"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BMA,MAAAA,gBAAgB,GAAGA,CAAC;EAAEC,SAAS;EAAEC,GAAG;EAAEC,KAAK;AAAEC,EAAAA,IAAI,GAAG;AAAU,CAAyB,KAAI;EAC/F,MAAMC,eAAe,GACnBH,GAAG,EAAEI,GAAG,CAAC,CAACC,MAAM,EAAEC,KAAK;AAAA;AACrB;AACAC,EAAAA,cAAA,CAACC,WAAW,EAAA;AAAaC,IAAAA,IAAI,EAAEJ,MAAO;AAACK,IAAAA,IAAI,EAAC;AAAI,GAAA,EAA9BJ,MACnB,CAAC,IAAI,IAAI;E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E,EAAG;AACTrB,MAAAA,SAAS,EAAEW,IAAK;AAChBW,MAAAA,KAAK,EAAEH,iBAAiB,GAAGT,IAAI,CAAC,YAAY,CAAC,GAAGa;AAAU,KAAA,CAE7D,eACDf,cAAA,CAACiB,YAAI,EAAA;AAACzB,MAAAA,SAAS,EAAC,cAAc;MAACW,IAAI,EAAEe,qBAAU,CAACC,UAAW;MAACC,gBAAgB,EAAA,IAAA;AAAAX,MAAAA,QAAA,EACzEE,iBAAiB,GAAGT,IAAI,CAACmB,OAAO,GAAGnB;AAAI,KACpC,CACR;AAAA,GAAI,CAAC;AAET;;;;"}
@@ -73,6 +73,7 @@ function Instruction({
73
73
  }), /*#__PURE__*/jsx(Body, {
74
74
  className: "text-primary",
75
75
  type: Typography.BODY_LARGE,
76
+ preserveNewlines: true,
76
77
  children: isInstructionNode ? item.content : item
77
78
  })]
78
79
  });
@@ -1 +1 @@
1
- {"version":3,"file":"InstructionsList.mjs","sources":["../../src/instructionsList/InstructionsList.tsx"],"sourcesContent":["import { CrossCircleFill as DontIcon, CheckCircleFill as DoIcon } from '@transferwise/icons';\nimport { clsx } from 'clsx';\nimport { ReactNode } from 'react';\n\nimport Body from '../body/Body';\nimport { Typography, CommonProps } from '../common';\n\ntype InstructionNode = {\n content: ReactNode;\n ['aria-label']: string;\n};\n\nexport type InstructionsListProps = CommonProps &\n (\n | {\n dos?: readonly ReactNode[];\n donts?: readonly ReactNode[];\n sort?: 'dosFirst' | 'dontsFirst';\n }\n | {\n dos?: readonly InstructionNode[];\n donts?: readonly InstructionNode[];\n sort?: 'dosFirst' | 'dontsFirst';\n }\n );\n\nconst InstructionsList = ({ className, dos, donts, sort = 'dosFirst' }: InstructionsListProps) => {\n const dosInstructions =\n dos?.map((doThis, index) => (\n // eslint-disable-next-line react/no-array-index-key\n <Instruction key={index} item={doThis} type=\"do\" />\n )) ?? null;\n\n const dontsInstructions =\n donts?.map((dont, index) => (\n // eslint-disable-next-line react/no-array-index-key\n <Instruction key={index} item={dont} type=\"dont\" />\n )) ?? null;\n\n const orderedInstructions =\n sort === 'dosFirst' ? (\n <>\n {dosInstructions}\n {dontsInstructions}\n </>\n ) : (\n <>\n {dontsInstructions}\n {dosInstructions}\n </>\n );\n\n return <ul className={clsx('tw-instructions', className)}>{orderedInstructions}</ul>;\n};\n\nfunction Instruction({ item, type }: { item: ReactNode | InstructionNode; type: 'do' | 'dont' }) {\n const isInstructionNode =\n typeof item === 'object' && item !== null && 'content' in item && 'aria-label' in item;\n return (\n <li className=\"instruction\">\n {type === 'do' ? (\n <DoIcon\n size={24}\n className={type}\n title={isInstructionNode ? item['aria-label'] : undefined}\n />\n ) : (\n <DontIcon\n size={24}\n className={type}\n title={isInstructionNode ? item['aria-label'] : undefined}\n />\n )}\n <Body className=\"text-primary\" type={Typography.BODY_LARGE}>\n {isInstructionNode ? item.content : item}\n </Body>\n </li>\n );\n}\n\nexport default InstructionsList;\n"],"names":["InstructionsList","className","dos","donts","sort","dosInstructions","map","doThis","index","_jsx","Instruction","item","type","dontsInstructions","dont","orderedInstructions","_jsxs","_Fragment","children","clsx","isInstructionNode","DoIcon","size","title","undefined","DontIcon","Body","Typography","BODY_LARGE","content"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BMA,MAAAA,gBAAgB,GAAGA,CAAC;EAAEC,SAAS;EAAEC,GAAG;EAAEC,KAAK;AAAEC,EAAAA,IAAI,GAAG;AAAU,CAAyB,KAAI;EAC/F,MAAMC,eAAe,GACnBH,GAAG,EAAEI,GAAG,CAAC,CAACC,MAAM,EAAEC,KAAK;AAAA;AACrB;AACAC,EAAAA,GAAA,CAACC,WAAW,EAAA;AAAaC,IAAAA,IAAI,EAAEJ,MAAO;AAACK,IAAAA,IAAI,EAAC;AAAI,GAAA,EAA9BJ,MACnB,CAAC,IAAI,IAAI;EAEZ,MAAMK,iBAAiB,GACrBV,KAAK,EAAEG,GAAG,CAAC,CAACQ,IAAI,EAAEN,KAAK;AAAA;AACrB;AACAC,EAAA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,GAAGa;AAAU,KAAA,CAE7D,eACDf,GAAA,CAACiB,IAAI,EAAA;AAACzB,MAAAA,SAAS,EAAC,cAAc;MAACW,IAAI,EAAEe,UAAU,CAACC,UAAW;AAAAV,MAAAA,QAAA,EACxDE,iBAAiB,GAAGT,IAAI,CAACkB,OAAO,GAAGlB;AAAI,KACpC,CACR;AAAA,GAAI,CAAC;AAET;;;;"}
1
+ {"version":3,"file":"InstructionsList.mjs","sources":["../../src/instructionsList/InstructionsList.tsx"],"sourcesContent":["import { CrossCircleFill as DontIcon, CheckCircleFill as DoIcon } from '@transferwise/icons';\nimport { clsx } from 'clsx';\nimport { ReactNode } from 'react';\n\nimport Body from '../body/Body';\nimport { Typography, CommonProps } from '../common';\n\ntype InstructionNode = {\n content: ReactNode;\n ['aria-label']: string;\n};\n\nexport type InstructionsListProps = CommonProps &\n (\n | {\n dos?: readonly ReactNode[];\n donts?: readonly ReactNode[];\n sort?: 'dosFirst' | 'dontsFirst';\n }\n | {\n dos?: readonly InstructionNode[];\n donts?: readonly InstructionNode[];\n sort?: 'dosFirst' | 'dontsFirst';\n }\n );\n\nconst InstructionsList = ({ className, dos, donts, sort = 'dosFirst' }: InstructionsListProps) => {\n const dosInstructions =\n dos?.map((doThis, index) => (\n // eslint-disable-next-line react/no-array-index-key\n <Instruction key={index} item={doThis} type=\"do\" />\n )) ?? null;\n\n const dontsInstructions =\n donts?.map((dont, index) => (\n // eslint-disable-next-line react/no-array-index-key\n <Instruction key={index} item={dont} type=\"dont\" />\n )) ?? null;\n\n const orderedInstructions =\n sort === 'dosFirst' ? (\n <>\n {dosInstructions}\n {dontsInstructions}\n </>\n ) : (\n <>\n {dontsInstructions}\n {dosInstructions}\n </>\n );\n\n return <ul className={clsx('tw-instructions', className)}>{orderedInstructions}</ul>;\n};\n\nfunction Instruction({ item, type }: { item: ReactNode | InstructionNode; type: 'do' | 'dont' }) {\n const isInstructionNode =\n typeof item === 'object' && item !== null && 'content' in item && 'aria-label' in item;\n return (\n <li className=\"instruction\">\n {type === 'do' ? (\n <DoIcon\n size={24}\n className={type}\n title={isInstructionNode ? item['aria-label'] : undefined}\n />\n ) : (\n <DontIcon\n size={24}\n className={type}\n title={isInstructionNode ? item['aria-label'] : undefined}\n />\n )}\n <Body className=\"text-primary\" type={Typography.BODY_LARGE} preserveNewlines>\n {isInstructionNode ? item.content : item}\n </Body>\n </li>\n );\n}\n\nexport default InstructionsList;\n"],"names":["InstructionsList","className","dos","donts","sort","dosInstructions","map","doThis","index","_jsx","Instruction","item","type","dontsInstructions","dont","orderedInstructions","_jsxs","_Fragment","children","clsx","isInstructionNode","DoIcon","size","title","undefined","DontIcon","Body","Typography","BODY_LARGE","preserveNewlines","content"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BMA,MAAAA,gBAAgB,GAAGA,CAAC;EAAEC,SAAS;EAAEC,GAAG;EAAEC,KAAK;AAAEC,EAAAA,IAAI,GAAG;AAAU,CAAyB,KAAI;EAC/F,MAAMC,eAAe,GACnBH,GAAG,EAAEI,GAAG,CAAC,CAACC,MAAM,EAAEC,KAAK;AAAA;AACrB;AACAC,EAAAA,GAAA,CAACC,WAAW,EAAA;AAAaC,IAAAA,IAAI,EAAEJ,MAAO;AAACK,IAAAA,IAAI,EAAC;AAAI,GAAA,EAA9BJ,MACnB,CAAC,IAAI,IAAI;EAEZ,MAAMK,iBAAiB,GACrBV,KAAK,EAAEG,GAAG,CAAC,CAACQ,IAAI,EAAEN,KAAK;AAAA;AACrB;AACAC,EAAAA,GAAA,CAACC,WAAW,EAAA;AAAaC,IAAAA,IAAI,EAAEG,IAAK;AAACF,IAAAA,IAAI,EAAC;AAAM,GAAA,EAA9BJ,MACnB,CAAC,IAAI,IAAI;EAEZ,MAAMO,mBAAmB,GACvBX,IAAI,KAAK,UAAU,gBACjBY,IAAA,CAAAC,QAAA,EAAA;IAAAC,QAAA,EAAA,CACGb,eAAe,EACfQ,iBAAiB;AAAA,GACpB,CAAG,gBAEHG,IAAA,CA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,6 +658,9 @@
658
658
  border-width: 1px;
659
659
  border-color: var(--badge-border-color);
660
660
  }
661
+ .np-text--pre-line {
662
+ white-space: pre-line;
663
+ }
661
664
  .np-btn {
662
665
  position: relative;
663
666
  }
@@ -0,0 +1,3 @@
1
+ .np-text--pre-line {
2
+ white-space: pre-line;
3
+ }
@@ -658,6 +658,9 @@
658
658
  border-width: 1px;
659
659
  border-color: var(--badge-border-color);
660
660
  }
661
+ .np-text--pre-line {
662
+ white-space: pre-line;
663
+ }
661
664
  .np-btn {
662
665
  position: relative;
663
666
  }
@@ -9,6 +9,11 @@ declare const Body: import("react").ForwardRefExoticComponent<HTMLAttributes<HTM
9
9
  * Default value: `div`
10
10
  */
11
11
  as?: "span" | "p" | "div";
12
+ /**
13
+ * When true, preserves newline characters in the text
14
+ * @default false
15
+ */
16
+ preserveNewlines?: boolean;
12
17
  } & import("react").RefAttributes<HTMLSpanElement | HTMLParagraphElement | HTMLDivElement | null>>;
13
18
  export default Body;
14
19
  //# sourceMappingURL=Body.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Body.d.ts","sourceRoot":"","sources":["../../../src/body/Body.tsx"],"names":[],"mappings":"AACA,OAAO,EAAc,cAAc,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAc,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAsBzE,QAAA,MAAM,IAAI;IAVR;;OAEG;WACI,SAAS;IAChB;;OAEG;SACE,MAAM,GAAG,GAAG,GAAG,KAAK;kGAsBzB,CAAC;AAEH,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"Body.d.ts","sourceRoot":"","sources":["../../../src/body/Body.tsx"],"names":[],"mappings":"AACA,OAAO,EAAc,cAAc,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAc,SAAS,EAAE,MAAM,kCAAkC,CAAC;AA2BzE,QAAA,MAAM,IAAI;IAfR;;OAEG;WACI,SAAS;IAChB;;OAEG;SACE,MAAM,GAAG,GAAG,GAAG,KAAK;IACzB;;;OAGG;uBACgB,OAAO;kGA0B1B,CAAC;AAEH,eAAe,IAAI,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "46.98.1",
3
+ "version": "46.99.0",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -43,7 +43,7 @@
43
43
  "@babel/preset-env": "^7.27.2",
44
44
  "@babel/preset-react": "^7.27.1",
45
45
  "@babel/preset-typescript": "^7.27.1",
46
- "@formatjs/cli": "^6.7.1",
46
+ "@formatjs/cli": "^6.7.2",
47
47
  "@rollup/plugin-babel": "^6.0.4",
48
48
  "@rollup/plugin-json": "^6.1.0",
49
49
  "@rollup/plugin-node-resolve": "^15.3.1",
@@ -80,7 +80,7 @@
80
80
  "@types/react-transition-group": "4.4.12",
81
81
  "@wise/art": "^2.21.2",
82
82
  "@wise/eslint-config": "^12.3.0",
83
- "babel-plugin-formatjs": "^10.5.38",
83
+ "babel-plugin-formatjs": "^10.5.39",
84
84
  "eslint": "^9.27.0",
85
85
  "gulp": "^5.0.1",
86
86
  "jest": "^29.7.0",
@@ -88,13 +88,13 @@
88
88
  "jest-fetch-mock": "^3.0.3",
89
89
  "lodash.times": "^4.3.2",
90
90
  "react-intl": "^7.1.11",
91
- "rollup": "^4.42.0",
91
+ "rollup": "^4.43.0",
92
92
  "rollup-preserve-directives": "^1.1.3",
93
93
  "storybook": "^8.6.14",
94
+ "@transferwise/less-config": "3.1.2",
94
95
  "@transferwise/neptune-css": "14.24.4",
95
- "@wise/components-theming": "1.6.3",
96
96
  "@wise/wds-configs": "0.0.0",
97
- "@transferwise/less-config": "3.1.2"
97
+ "@wise/components-theming": "1.6.3"
98
98
  },
99
99
  "peerDependencies": {
100
100
  "@transferwise/icons": "^3.22.0",
@@ -110,14 +110,14 @@
110
110
  "@floating-ui/react": "^0.27.9",
111
111
  "@headlessui/react": "^1.7.19",
112
112
  "@popperjs/core": "^2.11.8",
113
- "@react-aria/focus": "^3.20.4",
114
- "@react-aria/overlays": "^3.27.2",
113
+ "@react-aria/focus": "^3.20.5",
114
+ "@react-aria/overlays": "^3.27.3",
115
115
  "@react-spring/web": "~10.0.1",
116
116
  "@transferwise/formatting": "^2.13.1",
117
117
  "@transferwise/neptune-validation": "^3.3.0",
118
118
  "clsx": "^2.1.1",
119
119
  "commonmark": "^0.31.2",
120
- "core-js": "^3.42.0",
120
+ "core-js": "^3.43.0",
121
121
  "lodash.clamp": "^4.0.3",
122
122
  "lodash.debounce": "^4.0.8",
123
123
  "merge-props": "^6.0.0",
@@ -0,0 +1,3 @@
1
+ .np-text--pre-line {
2
+ white-space: pre-line;
3
+ }
@@ -0,0 +1,3 @@
1
+ .np-text--pre-line {
2
+ white-space: pre-line;
3
+ }
@@ -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
@@ -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
@@ -21,10 +21,15 @@ type Props = HTMLAttributes<HTMLSpanElement | HTMLParagraphElement> & {
21
21
  * Default value: `div`
22
22
  */
23
23
  as?: 'span' | 'p' | 'div';
24
+ /**
25
+ * When true, preserves newline characters in the text
26
+ * @default false
27
+ */
28
+ preserveNewlines?: boolean;
24
29
  };
25
30
 
26
31
  const Body = forwardRef(function Body(
27
- { as: Element = 'div', type = DEFAULT_TYPE, className, ...props }: Props,
32
+ { as: Element = 'div', type = DEFAULT_TYPE, className, preserveNewlines, ...props }: Props,
28
33
  reference: React.ForwardedRef<
29
34
  | {
30
35
  [key in typeof Element]: React.ElementRef<key>;
@@ -39,7 +44,11 @@ const Body = forwardRef(function Body(
39
44
  // @ts-expect-error TODO: Remove when component could be rewritten with generics
40
45
  // See: https://fettblog.eu/typescript-react-generic-forward-refs/
41
46
  ref={reference}
42
- className={clsx(`np-text-${isTypeSupported ? type : DEFAULT_TYPE}`, className)}
47
+ className={clsx(
48
+ `np-text-${isTypeSupported ? type : DEFAULT_TYPE}`,
49
+ preserveNewlines && 'np-text--pre-line',
50
+ className,
51
+ )}
43
52
  />
44
53
  );
45
54
  });
@@ -1,4 +1,6 @@
1
- import { StoryFn } from '@storybook/react';
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 Template: StoryFn = (args: InstructionsListProps) => {
13
- return (
14
- <>
15
- <InstructionsList
16
- className={args.className}
17
- dos={[
18
- 'Do an initial money transfer',
19
- 'Invite at least 3 friends',
20
- <span key="12">
21
- Paying extra{' '}
22
- <Link href="" type="link-large">
23
- hidden fees
24
- </Link>{' '}
25
- for transfers
26
- </span>,
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 Basic = {
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
  };
@@ -71,7 +71,7 @@ function Instruction({ item, type }: { item: ReactNode | InstructionNode; type:
71
71
  title={isInstructionNode ? item['aria-label'] : undefined}
72
72
  />
73
73
  )}
74
- <Body className="text-primary" type={Typography.BODY_LARGE}>
74
+ <Body className="text-primary" type={Typography.BODY_LARGE} preserveNewlines>
75
75
  {isInstructionNode ? item.content : item}
76
76
  </Body>
77
77
  </li>
package/src/main.css CHANGED
@@ -658,6 +658,9 @@
658
658
  border-width: 1px;
659
659
  border-color: var(--badge-border-color);
660
660
  }
661
+ .np-text--pre-line {
662
+ white-space: pre-line;
663
+ }
661
664
  .np-btn {
662
665
  position: relative;
663
666
  }
package/src/main.less CHANGED
@@ -8,6 +8,7 @@
8
8
  @import "./avatarLayout/AvatarLayout.less";
9
9
  @import "./iconButton/IconButton.less";
10
10
  @import "./badge/Badge.less";
11
+ @import "./body/Body.less";
11
12
  @import "./button/LegacyButton.less";
12
13
  @import "./button/Button.less";
13
14
  @import "./card/Card.less";