@transferwise/components 0.0.0-experimental-8edf644 → 0.0.0-experimental-9381602

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,6 @@ export type InstructionsListProps = CommonProps & ({
13
13
  donts?: readonly InstructionNode[];
14
14
  sort?: 'dosFirst' | 'dontsFirst';
15
15
  });
16
- declare const InstructionsList: ({ className, dos, donts, sort }: InstructionsListProps) => import("react").JSX.Element;
16
+ declare const InstructionsList: ({ dos, donts, sort }: InstructionsListProps) => import("react").JSX.Element;
17
17
  export default InstructionsList;
18
18
  //# sourceMappingURL=InstructionsList.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"InstructionsList.d.ts","sourceRoot":"","sources":["../../../src/instructionsList/InstructionsList.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC,OAAO,EAAc,WAAW,EAAE,MAAM,WAAW,CAAC;AAEpD,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,SAAS,CAAC;IACnB,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,WAAW,GAC7C,CACI;IACE,GAAG,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IAC3B,KAAK,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IAC7B,IAAI,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;CAClC,GACD;IACE,GAAG,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;IACjC,KAAK,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;IACnC,IAAI,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;CAClC,CACJ,CAAC;AAEJ,QAAA,MAAM,gBAAgB,oCAAkD,qBAAqB,gCA2B5F,CAAC;AAsBF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"InstructionsList.d.ts","sourceRoot":"","sources":["../../../src/instructionsList/InstructionsList.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC,OAAO,EAAc,WAAW,EAAE,MAAM,WAAW,CAAC;AAEpD,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,SAAS,CAAC;IACnB,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,WAAW,GAC7C,CACI;IACE,GAAG,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IAC3B,KAAK,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IAC7B,IAAI,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;CAClC,GACD;IACE,GAAG,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;IACjC,KAAK,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;IACnC,IAAI,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;CAClC,CACJ,CAAC;AAEJ,QAAA,MAAM,gBAAgB,yBAAuC,qBAAqB,gCA2BjF,CAAC;AAsBF,eAAe,gBAAgB,CAAC"}
@@ -4,6 +4,7 @@ export type MarkdownProps = {
4
4
  as?: React.ElementType;
5
5
  config?: {
6
6
  link?: Pick<React.ComponentPropsWithoutRef<'a'>, 'target'>;
7
+ paragraph?: Pick<React.ComponentPropsWithoutRef<'p'>, 'className'>;
7
8
  };
8
9
  className?: string;
9
10
  children?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Markdown.d.ts","sourceRoot":"","sources":["../../../src/markdown/Markdown.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAQ7C,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC;IACvB,MAAM,CAAC,EAAE;QACP,IAAI,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,GAAG,CAAC,EAAE,QAA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AE,CAAC;CAC9C,CACJ,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC/B,EAAE,EAAE,OAAe,EACnB,SAAS,EACT,SAAS,EACT,MAAM,EACN,SAAS,EACT,QAAQ,GACT,EAAE,aAAa,sCA8Bf"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "0.0.0-experimental-8edf644",
3
+ "version": "0.0.0-experimental-9381602",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -94,9 +94,9 @@
94
94
  "react-intl": "^5.10.0",
95
95
  "rollup": "^3.28.1",
96
96
  "storybook": "^7.6.17",
97
- "@transferwise/less-config": "3.1.0",
98
97
  "@transferwise/neptune-css": "14.9.6",
99
- "@wise/components-theming": "1.1.0"
98
+ "@wise/components-theming": "1.1.0",
99
+ "@transferwise/less-config": "3.1.0"
100
100
  },
101
101
  "peerDependencies": {
102
102
  "@transferwise/icons": "^3.7.0",
@@ -3,11 +3,6 @@ import { render, screen } from '../test-utils';
3
3
  import InstructionsList from '.';
4
4
 
5
5
  describe('InstructionsList', () => {
6
- it('should render with custom class', () => {
7
- render(<InstructionsList className="foo" dos={['bar', 'baz']} />);
8
- expect(screen.getByRole('list')).toHaveClass('foo');
9
- });
10
-
11
6
  it('should render dos list only', () => {
12
7
  const dos = ['Test this component', 'With multiple dos'];
13
8
  render(<InstructionsList dos={dos} />);
@@ -13,7 +13,6 @@ export const Template: StoryFn = (args: InstructionsListProps) => {
13
13
  return (
14
14
  <>
15
15
  <InstructionsList
16
- className="tw-instructions--className"
17
16
  dos={[
18
17
  'Do an initial money transfer',
19
18
  'Invite at least 3 friends',
@@ -1,5 +1,4 @@
1
1
  import { CrossCircleFill as DontIcon, CheckCircleFill as DoIcon } from '@transferwise/icons';
2
- import classNames from 'classnames';
3
2
  import { ReactNode } from 'react';
4
3
 
5
4
  import Body from '../body/Body';
@@ -24,7 +23,7 @@ export type InstructionsListProps = CommonProps &
24
23
  }
25
24
  );
26
25
 
27
- const InstructionsList = ({ className, dos, donts, sort = 'dosFirst' }: InstructionsListProps) => {
26
+ const InstructionsList = ({ dos, donts, sort = 'dosFirst' }: InstructionsListProps) => {
28
27
  const dosInstructions =
29
28
  dos?.map((doThis, index) => (
30
29
  // eslint-disable-next-line react/no-array-index-key
@@ -50,7 +49,7 @@ const InstructionsList = ({ className, dos, donts, sort = 'dosFirst' }: Instruct
50
49
  </>
51
50
  );
52
51
 
53
- return <ul className={classNames('tw-instructions', className)}>{orderedInstructions}</ul>;
52
+ return <ul className="tw-instructions">{orderedInstructions}</ul>;
54
53
  };
55
54
 
56
55
  function Instruction({ item, type }: { item: ReactNode | InstructionNode; type: 'do' | 'dont' }) {
@@ -126,6 +126,22 @@ describe('Markdown', () => {
126
126
  });
127
127
  });
128
128
 
129
+ describe('config.paragraph.className', () => {
130
+ it('adds a custom class when specified', () => {
131
+ render(
132
+ <Markdown config={{ paragraph: { className: 'm-b-0' } }}>{`# Heading
133
+
134
+ This is a paragraph
135
+ `}</Markdown>,
136
+ );
137
+
138
+ expect(screen.getByText('This is a paragraph').closest('p')).toHaveAttribute(
139
+ 'class',
140
+ 'm-b-0',
141
+ );
142
+ });
143
+ });
144
+
129
145
  it('adds a target=_self attribute when nothing specified', () => {
130
146
  render(
131
147
  <Markdown>{`# Heading
@@ -12,6 +12,7 @@ export type MarkdownProps = {
12
12
  as?: React.ElementType;
13
13
  config?: {
14
14
  link?: Pick<React.ComponentPropsWithoutRef<'a'>, 'target'>;
15
+ paragraph?: Pick<React.ComponentPropsWithoutRef<'p'>, 'className'>;
15
16
  };
16
17
  className?: string;
17
18
  children?: string;
@@ -39,6 +40,7 @@ export default function Markdown({
39
40
  }
40
41
 
41
42
  const linkTarget = config?.link?.target ?? '_self';
43
+ const paragraphClass = config?.paragraph?.className ?? '';
42
44
 
43
45
  if (allowList != null && blockList != null) {
44
46
  logActionRequired(
@@ -55,7 +57,10 @@ export default function Markdown({
55
57
 
56
58
  const createMarkup = () => {
57
59
  const parsed = parser(children);
58
- return writer.render(parsed).replace(/<a href="/g, `<a target="${linkTarget}" href="`);
60
+ return writer
61
+ .render(parsed)
62
+ .replace(/<a href="/g, `<a target="${linkTarget}" href="`)
63
+ .replace(/<p>/g, `<p class="${paragraphClass}">`);
59
64
  };
60
65
 
61
66
  return <Element className={className} dangerouslySetInnerHTML={{ __html: createMarkup() }} />;