@transferwise/components 0.0.0-experimental-0192429 → 0.0.0-experimental-385bb2a

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.
Files changed (47) hide show
  1. package/build/index.js +0 -1
  2. package/build/index.js.map +1 -1
  3. package/build/index.mjs +1 -1
  4. package/build/main.css +4 -190
  5. package/build/styles/main.css +4 -190
  6. package/build/styles/typeahead/Typeahead.css +4 -4
  7. package/build/types/index.d.ts +0 -2
  8. package/build/types/index.d.ts.map +1 -1
  9. package/build/types/test-utils/fake-data.d.ts +0 -1
  10. package/build/types/test-utils/fake-data.d.ts.map +1 -1
  11. package/package.json +3 -3
  12. package/src/index.ts +0 -2
  13. package/src/main.css +4 -190
  14. package/src/main.less +0 -1
  15. package/src/test-utils/fake-data.ts +0 -3
  16. package/src/typeahead/Typeahead.css +4 -4
  17. package/src/typeahead/Typeahead.less +2 -2
  18. package/build/styles/item/Item.css +0 -186
  19. package/build/types/item/Item.d.ts +0 -40
  20. package/build/types/item/Item.d.ts.map +0 -1
  21. package/build/types/item/ItemAdditionalInfo.d.ts +0 -9
  22. package/build/types/item/ItemAdditionalInfo.d.ts.map +0 -1
  23. package/build/types/item/ItemCheckbox.d.ts +0 -4
  24. package/build/types/item/ItemCheckbox.d.ts.map +0 -1
  25. package/build/types/item/ItemIconButton.d.ts +0 -4
  26. package/build/types/item/ItemIconButton.d.ts.map +0 -1
  27. package/build/types/item/ItemImage.d.ts +0 -4
  28. package/build/types/item/ItemImage.d.ts.map +0 -1
  29. package/build/types/item/ItemNavigation.d.ts +0 -4
  30. package/build/types/item/ItemNavigation.d.ts.map +0 -1
  31. package/build/types/item/index.d.ts +0 -5
  32. package/build/types/item/index.d.ts.map +0 -1
  33. package/build/types/item/prompt/Prompt.d.ts +0 -12
  34. package/build/types/item/prompt/Prompt.d.ts.map +0 -1
  35. package/src/item/Item.css +0 -186
  36. package/src/item/Item.less +0 -177
  37. package/src/item/Item.story.tsx +0 -93
  38. package/src/item/Item.tsx +0 -165
  39. package/src/item/ItemAdditionalInfo.tsx +0 -31
  40. package/src/item/ItemCheckbox.tsx +0 -16
  41. package/src/item/ItemIconButton.tsx +0 -15
  42. package/src/item/ItemImage.tsx +0 -11
  43. package/src/item/ItemNavigation.tsx +0 -16
  44. package/src/item/index.ts +0 -4
  45. package/src/item/prompt/Prompt.spec.tsx +0 -77
  46. package/src/item/prompt/Prompt.story.tsx +0 -170
  47. package/src/item/prompt/Prompt.tsx +0 -44
@@ -1,16 +0,0 @@
1
- import { ChevronRight, BillSplit as Disabled } from '@transferwise/icons';
2
- import { ButtonProps } from '../button/Button.types';
3
- import Item, { ItemContext, ItemContextData } from './Item';
4
- import { useContext, useEffect } from 'react';
5
-
6
- export type ItemNavigationProps = Pick<ButtonProps, 'onClick' | 'href'>;
7
-
8
- export const Navigation = function Navigation({ onClick }: ItemNavigationProps) {
9
- const { setControlType, props: baseItemProps } = useContext<ItemContextData>(ItemContext);
10
-
11
- useEffect(() => {
12
- setControlType('navigation');
13
- }, []);
14
-
15
- return baseItemProps?.disabled ? <Disabled size={24} /> : <ChevronRight size={24} />;
16
- };
package/src/item/index.ts DELETED
@@ -1,4 +0,0 @@
1
- export type { Props as ItemProps } from './Item';
2
- export type { ItemAdditionalInfoProps } from './ItemAdditionalInfo';
3
- export type { ItemCheckboxProps } from './ItemCheckbox';
4
- export { default } from './Item';
@@ -1,77 +0,0 @@
1
- import { render, screen, mockMatchMedia } from '../../test-utils';
2
- import { ItemPrompt } from './Prompt';
3
- import { Sentiment } from '../../common';
4
-
5
- mockMatchMedia();
6
-
7
- describe('ItemPrompt', () => {
8
- it('renders the aria-label when provided', () => {
9
- const ariaLabel = 'Test aria-label';
10
- render(
11
- <ItemPrompt
12
- type={Sentiment.POSITIVE}
13
- action={{ 'aria-label': ariaLabel, href: 'https://example.com' }}
14
- >
15
- Positive prompt
16
- </ItemPrompt>,
17
- );
18
-
19
- expect(screen.getByLabelText(ariaLabel)).toBeInTheDocument();
20
- });
21
-
22
- it('applies the interactive class when href is provided', () => {
23
- render(
24
- <ItemPrompt
25
- type={Sentiment.POSITIVE}
26
- action={{ href: 'https://example.com', 'aria-label': 'Interactive link' }}
27
- >
28
- Interactive link
29
- </ItemPrompt>,
30
- );
31
-
32
- expect(screen.getByRole('link')).toHaveClass('np-prompt-interactive');
33
- });
34
-
35
- it('applies the interactive class when onClick is provided', () => {
36
- render(
37
- <ItemPrompt
38
- type={Sentiment.POSITIVE}
39
- action={{ onClick: jest.fn(), 'aria-label': 'Interactive button' }}
40
- >
41
- Interactive button
42
- </ItemPrompt>,
43
- );
44
-
45
- expect(screen.getByRole('button')).toHaveClass('np-prompt-interactive');
46
- });
47
-
48
- it('does not apply the interactive class when no action is provided', () => {
49
- render(<ItemPrompt type={Sentiment.POSITIVE}>Non-interactive prompt</ItemPrompt>);
50
-
51
- expect(screen.getByText('Non-interactive prompt')).not.toHaveClass('np-prompt-interactive');
52
- });
53
-
54
- it('renders the children content', () => {
55
- render(<ItemPrompt type={Sentiment.POSITIVE}>This is a child prompt</ItemPrompt>);
56
-
57
- expect(screen.getByText('This is a child prompt')).toBeInTheDocument();
58
- });
59
-
60
- it('spreads additional props to the wrapper element', () => {
61
- render(
62
- <ItemPrompt
63
- type={Sentiment.POSITIVE}
64
- action={{
65
- href: 'https://example.com',
66
- target: '_blank',
67
- 'aria-label': 'Custom props prompt',
68
- }}
69
- >
70
- Custom props prompt
71
- </ItemPrompt>,
72
- );
73
-
74
- const link = screen.getByRole('link');
75
- expect(link).toHaveAttribute('target', '_blank');
76
- });
77
- });
@@ -1,170 +0,0 @@
1
- import Link from '../../link';
2
- import { Sentiment } from '../../common';
3
- import { ItemPrompt, ItemPromptProps } from './Prompt';
4
- import { lorem40 } from '../../test-utils';
5
- import { StoryObj } from '@storybook/react';
6
-
7
- export default {
8
- component: ItemPrompt,
9
- title: 'Content/Item/Prompt',
10
- args: {
11
- type: Sentiment.NEGATIVE,
12
- children: 'You have done a terrible thing',
13
- },
14
- argTypes: {
15
- type: {
16
- options: [
17
- Sentiment.POSITIVE,
18
- Sentiment.NEGATIVE,
19
- Sentiment.NEUTRAL,
20
- Sentiment.WARNING,
21
- 'discount',
22
- 'savings',
23
- ],
24
- control: { type: 'radio' },
25
- description: 'The type of prompt to display',
26
- },
27
- action: {
28
- table: {
29
- disable: true,
30
- },
31
- },
32
- children: {
33
- type: {
34
- name: 'string',
35
- required: true,
36
- description: 'The content of the prompt',
37
- },
38
- },
39
- },
40
- };
41
-
42
- type CustomStory = StoryObj<
43
- ItemPromptProps & {
44
- interactivity?: 'none' | 'full-anchor' | 'full-button' | 'link';
45
- }
46
- >;
47
-
48
- export const Basic: CustomStory = {
49
- args: {
50
- interactivity: 'none',
51
- },
52
- argTypes: {
53
- interactivity: {
54
- options: ['none', 'full-button', 'full-anchor', 'link'],
55
- control: { type: 'radio' },
56
- description: 'The type of interactivity to display',
57
- },
58
- },
59
- render: ({ interactivity, ...args }) => {
60
- return (
61
- <div>
62
- <ItemPrompt
63
- type={args.type}
64
- action={
65
- interactivity === 'full-anchor'
66
- ? { href: 'wise.com' }
67
- : interactivity === 'full-button'
68
- ? {
69
- onClick: () => {
70
- console.log('clicked');
71
- },
72
- }
73
- : undefined
74
- }
75
- >
76
- {args.children} {interactivity === 'link' && <Link href="www.wise.com">with a link</Link>}
77
- </ItemPrompt>
78
- </div>
79
- );
80
- },
81
- };
82
-
83
- export const Variants = () => {
84
- return (
85
- <>
86
- <div className="m-b-2">
87
- <ItemPrompt type={Sentiment.POSITIVE}>
88
- Positive prompt <Link href="www.wise.com">with a link to amazing content</Link>
89
- </ItemPrompt>
90
- </div>
91
- <div className="m-b-2">
92
- <ItemPrompt type={Sentiment.NEGATIVE}>
93
- Negative prompt <Link href="www.wise.com">with a link to amazing content</Link>
94
- </ItemPrompt>
95
- </div>
96
- <div className="m-b-2">
97
- <ItemPrompt type={Sentiment.NEUTRAL}>
98
- Neutral prompt <Link href="www.wise.com">with a link to amazing content</Link>
99
- </ItemPrompt>
100
- </div>
101
- <div className="m-b-2">
102
- <ItemPrompt type={Sentiment.WARNING}>
103
- Warning prompt <Link href="www.wise.com">with a link to amazing content</Link>
104
- </ItemPrompt>
105
- </div>
106
- <div className="m-b-2">
107
- <ItemPrompt type="discount">
108
- Discount prompt <Link href="www.wise.com">with a link to amazing content</Link>
109
- </ItemPrompt>
110
- </div>
111
- <div className="m-b-2">
112
- <ItemPrompt type="savings">
113
- Savings prompt <Link href="www.wise.com">with a link to amazing content</Link>
114
- </ItemPrompt>
115
- </div>
116
- <div className="m-b-2">
117
- <ItemPrompt
118
- type="discount"
119
- action={{
120
- href: 'www.wise.com',
121
- target: '_self',
122
- 'aria-label': 'hidden anchor tags are accessible, right?',
123
- }}
124
- >
125
- The whole prompt is secretly clickable
126
- </ItemPrompt>
127
- </div>
128
- <div className="m-b-2">
129
- <ItemPrompt
130
- type="negative"
131
- action={{
132
- href: 'www.wise.com',
133
- target: '_self',
134
- 'aria-label': 'clickable <a>',
135
- }}
136
- >
137
- The whole prompt is secretly clickable as an anchor tag
138
- </ItemPrompt>
139
- </div>
140
- <div className="m-b-2">
141
- <ItemPrompt
142
- type="warning"
143
- action={{
144
- onClick: () => {
145
- console.log('clicked');
146
- },
147
- 'aria-label': 'clickable button',
148
- }}
149
- >
150
- The whole prompt is secretly clickable as a button
151
- </ItemPrompt>
152
- </div>
153
- <div className="m-b-2">
154
- <ItemPrompt
155
- type="neutral"
156
- action={{
157
- href: 'www.wise.com',
158
- target: '_self',
159
- 'aria-label': 'clickable prompt',
160
- }}
161
- >
162
- The whole prompt is secretly clickable
163
- </ItemPrompt>
164
- </div>
165
- <div className="m-b-2" style={{ maxWidth: '300px' }}>
166
- <ItemPrompt type="warning">The prompt has very long text that wraps {lorem40}</ItemPrompt>
167
- </div>
168
- </>
169
- );
170
- };
@@ -1,44 +0,0 @@
1
- import { Confetti, Tags } from '@transferwise/icons';
2
- import { Sentiment } from '../../common';
3
- import StatusIcon from '../../statusIcon';
4
- import { clsx } from 'clsx';
5
- import { LinkProps } from '../../link';
6
- import Body from '../../body';
7
-
8
- export type ItemPromptProps = {
9
- type:
10
- | `${Sentiment.POSITIVE | Sentiment.NEGATIVE | Sentiment.NEUTRAL | Sentiment.WARNING}`
11
- | 'discount'
12
- | 'savings';
13
- children: React.ReactNode;
14
- action?: Pick<LinkProps, 'href' | 'target' | 'onClick'> & { 'aria-label'?: string };
15
- };
16
-
17
- export const ItemPrompt = ({ type, children, action }: ItemPromptProps) => {
18
- const Wrapper = action?.href ? 'a' : action?.onClick ? 'button' : 'span';
19
-
20
- const icon =
21
- type === 'discount' ? (
22
- <Tags size={16} />
23
- ) : type === 'savings' ? (
24
- <Confetti size={16} />
25
- ) : (
26
- <StatusIcon size={16} sentiment={type} />
27
- );
28
-
29
- return (
30
- <Wrapper
31
- className={clsx(
32
- 'np-item-prompt',
33
- type,
34
- (action?.href || action?.onClick) && 'np-prompt-interactive',
35
- )}
36
- {...(action ?? {})}
37
- >
38
- <div className="np-prompt-icon">{icon}</div>
39
- <Body>{children}</Body>
40
- </Wrapper>
41
- );
42
- };
43
-
44
- export default ItemPrompt;