@transferwise/components 0.0.0-experimental-fed4f10 → 0.0.0-experimental-8d08be7

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 (83) hide show
  1. package/build/alert/Alert.js.map +1 -1
  2. package/build/alert/Alert.mjs.map +1 -1
  3. package/build/avatarWrapper/AvatarWrapper.js.map +1 -1
  4. package/build/avatarWrapper/AvatarWrapper.mjs.map +1 -1
  5. package/build/common/propsValues/sentiment.js +1 -0
  6. package/build/common/propsValues/sentiment.js.map +1 -1
  7. package/build/common/propsValues/sentiment.mjs +1 -0
  8. package/build/common/propsValues/sentiment.mjs.map +1 -1
  9. package/build/index.js +0 -1
  10. package/build/index.js.map +1 -1
  11. package/build/index.mjs +1 -1
  12. package/build/main.css +60 -188
  13. package/build/statusIcon/StatusIcon.js +2 -2
  14. package/build/statusIcon/StatusIcon.js.map +1 -1
  15. package/build/statusIcon/StatusIcon.mjs +2 -2
  16. package/build/statusIcon/StatusIcon.mjs.map +1 -1
  17. package/build/styles/inputs/Input.css +28 -2
  18. package/build/styles/inputs/TextArea.css +28 -2
  19. package/build/styles/main.css +60 -188
  20. package/build/styles/popover/Popover.css +28 -2
  21. package/build/title/Title.js.map +1 -1
  22. package/build/title/Title.mjs.map +1 -1
  23. package/build/types/alert/Alert.d.ts +2 -2
  24. package/build/types/alert/Alert.d.ts.map +1 -1
  25. package/build/types/avatarWrapper/AvatarWrapper.d.ts +2 -2
  26. package/build/types/avatarWrapper/AvatarWrapper.d.ts.map +1 -1
  27. package/build/types/common/propsValues/sentiment.d.ts.map +1 -1
  28. package/build/types/index.d.ts +0 -2
  29. package/build/types/index.d.ts.map +1 -1
  30. package/build/types/statusIcon/StatusIcon.d.ts +3 -2
  31. package/build/types/statusIcon/StatusIcon.d.ts.map +1 -1
  32. package/build/types/test-utils/fake-data.d.ts +0 -1
  33. package/build/types/test-utils/fake-data.d.ts.map +1 -1
  34. package/build/types/title/Title.d.ts.map +1 -1
  35. package/package.json +5 -5
  36. package/src/alert/Alert.story.tsx +5 -3
  37. package/src/alert/Alert.tsx +11 -2
  38. package/src/avatarWrapper/AvatarWrapper.story.tsx +2 -2
  39. package/src/avatarWrapper/AvatarWrapper.tsx +3 -2
  40. package/src/common/propsValues/sentiment.ts +1 -0
  41. package/src/index.ts +0 -2
  42. package/src/inputs/Input.css +28 -2
  43. package/src/inputs/TextArea.css +28 -2
  44. package/src/main.css +60 -188
  45. package/src/main.less +0 -1
  46. package/src/popover/Popover.css +28 -2
  47. package/src/statusIcon/StatusIcon.docs.mdx +1 -1
  48. package/src/statusIcon/StatusIcon.spec.tsx +10 -4
  49. package/src/statusIcon/StatusIcon.story.tsx +10 -5
  50. package/src/statusIcon/StatusIcon.tsx +6 -4
  51. package/src/test-utils/fake-data.ts +0 -3
  52. package/src/title/Title.test.story.tsx +19 -12
  53. package/src/title/Title.tsx +1 -0
  54. package/build/styles/item/Item.css +0 -184
  55. package/build/types/item/Item.d.ts +0 -40
  56. package/build/types/item/Item.d.ts.map +0 -1
  57. package/build/types/item/ItemAdditionalInfo.d.ts +0 -9
  58. package/build/types/item/ItemAdditionalInfo.d.ts.map +0 -1
  59. package/build/types/item/ItemCheckbox.d.ts +0 -4
  60. package/build/types/item/ItemCheckbox.d.ts.map +0 -1
  61. package/build/types/item/ItemIconButton.d.ts +0 -4
  62. package/build/types/item/ItemIconButton.d.ts.map +0 -1
  63. package/build/types/item/ItemImage.d.ts +0 -4
  64. package/build/types/item/ItemImage.d.ts.map +0 -1
  65. package/build/types/item/ItemNavigation.d.ts +0 -4
  66. package/build/types/item/ItemNavigation.d.ts.map +0 -1
  67. package/build/types/item/index.d.ts +0 -5
  68. package/build/types/item/index.d.ts.map +0 -1
  69. package/build/types/item/prompt/Prompt.d.ts +0 -12
  70. package/build/types/item/prompt/Prompt.d.ts.map +0 -1
  71. package/src/item/Item.css +0 -184
  72. package/src/item/Item.less +0 -178
  73. package/src/item/Item.story.tsx +0 -93
  74. package/src/item/Item.tsx +0 -165
  75. package/src/item/ItemAdditionalInfo.tsx +0 -31
  76. package/src/item/ItemCheckbox.tsx +0 -16
  77. package/src/item/ItemIconButton.tsx +0 -15
  78. package/src/item/ItemImage.tsx +0 -11
  79. package/src/item/ItemNavigation.tsx +0 -16
  80. package/src/item/index.ts +0 -4
  81. package/src/item/prompt/Prompt.spec.tsx +0 -77
  82. package/src/item/prompt/Prompt.story.tsx +0 -170
  83. package/src/item/prompt/Prompt.tsx +0 -44
@@ -1,178 +0,0 @@
1
- .np-item {
2
- padding: var(--size-16);
3
- border-radius: var(--radius-large);
4
- background-color: var(--color-background-screen);
5
- display: flex;
6
- gap: var(--size-16);
7
- align-items: center;
8
- flex-direction: row;
9
- cursor: pointer;
10
-
11
- &:hover {
12
- background-color: var(--color-background-screen-hover);
13
- }
14
-
15
- &:active {
16
- background-color: var(--color-background-screen-active);
17
- }
18
-
19
- &-media {
20
- flex: 0 0 auto;
21
- align-items: flex-start;
22
- }
23
-
24
- &-title {
25
- color: var(--color-content-primary);
26
- }
27
-
28
- &-additional-info {
29
- color: var(--color-content-tertiary);
30
- }
31
-
32
- &-value {
33
- flex: 0 0 auto;
34
- }
35
-
36
- &-control {
37
- flex: 0 0 auto;
38
- }
39
-
40
- &-spotlight {
41
- &-active {
42
- background-color: var(--color-background-neutral);
43
-
44
- &:hover {
45
- background-color: var(--color-background-neutral-hover);
46
- }
47
- &:active {
48
- background-color: var(--color-background-neutral-active);
49
- }
50
- }
51
-
52
- &-inactive {
53
- background-color: color-mix(in srgb, var(--color-background-neutral) 25%, transparent);
54
- border: 1px dashed var(--color-border-neutral);
55
-
56
- &:hover {
57
- background-color: color-mix(in srgb, var(--color-background-neutral-hover) 25%, transparent);
58
- }
59
- &:active {
60
- background-color: color-mix(in srgb, var(--color-background-neutral-active) 25%, transparent);
61
- }
62
- }
63
- }
64
-
65
- &-prompt {
66
- display: inline-flex;
67
- padding-top: calc(var(--padding-x-small) / 2);
68
- padding-bottom: calc(var(--padding-x-small) / 2);
69
- padding-left: calc(var(--padding-x-small) - 1px);
70
- padding-right: var(--padding-x-small);
71
- border-radius: var(--radius-small);
72
- word-break: break-word;
73
- overflow-wrap: break-word;
74
-
75
- .np-prompt-icon {
76
- padding-right: 6px;
77
- padding-top: 3px;
78
- padding-bottom: 3px;
79
-
80
- .tw-icon-tags,
81
- .tw-icon-confetti {
82
- color: var(--color-sentiment-positive-primary);
83
- }
84
- }
85
-
86
- a {
87
- text-underline-offset: calc(var(--size-4) / 2);
88
- display: inline;
89
- }
90
-
91
- &.np-prompt-interactive {
92
- text-decoration: none;
93
- cursor: pointer;
94
- border: none;
95
- }
96
-
97
- &.negative {
98
- background-color: var(--color-sentiment-negative-secondary);
99
- color: var(--color-sentiment-negative-primary);
100
- a {
101
- color: var(--color-sentiment-negative-primary);
102
- &:hover {
103
- color: var(--color-sentiment-negative-primary-hover);
104
- }
105
- &:active {
106
- color: var(--color-sentiment-negative-primary-active);
107
- }
108
- }
109
- .np-prompt-interactive& {
110
- &:hover {
111
- background-color: color-mix(in srgb, var(--color-sentiment-negative-secondary) 95%, var(--color-sentiment-negative-primary));
112
- }
113
- &:active {
114
- background-color: color-mix(in srgb, var(--color-sentiment-negative-secondary) 90%, var(--color-sentiment-negative-primary));
115
- }
116
- }
117
- }
118
- &.positive,
119
- &.discount,
120
- &.savings {
121
- background-color: var(--color-sentiment-positive-secondary);
122
- color: var(--color-sentiment-positive-primary);
123
- a {
124
- color: var(--color-sentiment-positive-primary);
125
- &:hover {
126
- color: var(--color-sentiment-positive-primary-hover);
127
- }
128
- &:active {
129
- color: var(--color-sentiment-positive-primary-active);
130
- }
131
- }
132
- .np-prompt-interactive& {
133
- &:hover {
134
- background-color: color-mix(in srgb, var(--color-sentiment-positive-secondary) 95%, var(--color-sentiment-positive-primary));
135
- }
136
- &:active {
137
- background-color: color-mix(in srgb, var(--color-sentiment-positive-secondary) 90%, var(--color-sentiment-positive-primary));
138
- }
139
- }
140
- }
141
- &.neutral {
142
- background-color: var(--color-background-neutral);
143
- color: var(--color-content-primary);
144
- a {
145
- color: var(--color-content-primary);
146
- }
147
- .np-prompt-interactive& {
148
- &:hover {
149
- background-color: var(--color-background-neutral-hover);
150
- }
151
- &:active {
152
- background-color: var(--color-background-neutral-active);
153
- }
154
- }
155
- }
156
- &.warning {
157
- background-color: var(--color-sentiment-warning-secondary);
158
- color: var(--color-sentiment-warning-content);
159
- a {
160
- color: var(--color-sentiment-warning-content);
161
- &:hover {
162
- color: var(--color-sentiment-warning-content-hover);
163
- }
164
- &:active {
165
- color: var(--color-sentiment-warning-content-active);
166
- }
167
- }
168
- .np-prompt-interactive& {
169
- &:hover {
170
- background-color: color-mix(in srgb, var(--color-sentiment-warning-secondary) 90%, var(--color-sentiment-warning-primary));
171
- }
172
- &:active {
173
- background-color: color-mix(in srgb, var(--color-sentiment-warning-secondary) 80%, var(--color-sentiment-warning-primary));
174
- }
175
- }
176
- }
177
- }
178
- }
@@ -1,93 +0,0 @@
1
- import Item, { Props as ItemProps } from './Item';
2
- import { Meta, StoryObj } from '@storybook/react';
3
- import React from 'react';
4
- import { lorem10, lorem20, lorem40 } from '../test-utils';
5
-
6
- export default {
7
- component: Item,
8
- title: 'Content/Item',
9
- } satisfies Meta<ItemProps>;
10
-
11
- type Story = StoryObj<ItemProps>;
12
-
13
- // TODO: delete this story later when we have more peace of the List Item puzzle
14
- export const TempPlayground: Story = {
15
- render: () => (
16
- <div>
17
- <Item
18
- title="Test title"
19
- subtitle="Test subtitle"
20
- additionalInfo={<Item.AdditionalInfo>{lorem10}</Item.AdditionalInfo>}
21
- />
22
- <Item
23
- title="Test title"
24
- subtitle={lorem10}
25
- additionalInfo={<Item.AdditionalInfo>{lorem20}</Item.AdditionalInfo>}
26
- />
27
- <Item
28
- title="Test title"
29
- subtitle={lorem10}
30
- valueTitle="100 GBP"
31
- valueSubtitle="100 USD"
32
- additionalInfo={<Item.AdditionalInfo>{lorem20}</Item.AdditionalInfo>}
33
- />
34
- <Item
35
- title="Test title"
36
- subtitle="Test subtitle"
37
- additionalInfo={
38
- <Item.AdditionalInfo
39
- action={{ label: 'Learn more', href: 'https://wise.com', target: '_blank' }}
40
- >
41
- {lorem10}
42
- </Item.AdditionalInfo>
43
- }
44
- prompt={<Item.Prompt type="negative">You have done something wrong</Item.Prompt>}
45
- />
46
- <Item
47
- title="Test title"
48
- additionalInfo={<Item.AdditionalInfo>{lorem10}</Item.AdditionalInfo>}
49
- prompt={
50
- <Item.Prompt
51
- type="discount"
52
- action={{
53
- href: 'https://wise.com',
54
- target: '_blank',
55
- 'aria-label': 'clickable prompt',
56
- }}
57
- >
58
- The whole prompt is secretly clickable
59
- </Item.Prompt>
60
- }
61
- />
62
- </div>
63
- ),
64
- };
65
-
66
- export const ItemRadio: Story = {
67
- render: () => (
68
- <div>
69
- {/* Basic */}
70
- {/* with additional info */}
71
- {/* with prompt */}
72
- {/* Disabled */}
73
- {/* Spotlight */}
74
- {/* Active */}
75
- </div>
76
- ),
77
- };
78
-
79
- export const ItemButton: Story = {
80
- render: () => (
81
- <div>
82
- {/* Basic */}
83
- {/* with additional info */}
84
- {/* with prompt */}
85
- {/* partially interactive */}
86
- {/* Disabled */}
87
- {/* Spotlight */}
88
- {/* Active */}
89
- </div>
90
- ),
91
- };
92
-
93
- // add intaces with dark mode
package/src/item/Item.tsx DELETED
@@ -1,165 +0,0 @@
1
- import { createContext, ReactNode, useId, useMemo, useState } from 'react';
2
- import { Typography } from '../common';
3
- import Body from '../body';
4
- import { Image } from './ItemImage';
5
- import { AdditionalInfo } from './ItemAdditionalInfo';
6
- import { IconButton } from './ItemIconButton';
7
- import { Checkbox } from './ItemCheckbox';
8
- import { Navigation } from './ItemNavigation';
9
- import { clsx } from 'clsx';
10
- import Prompt from './prompt/Prompt';
11
-
12
- export type ItemTypes =
13
- | 'none'
14
- | 'navigation'
15
- | 'radio'
16
- | 'checkbox'
17
- | 'switch'
18
- | 'button'
19
- | 'icon-button';
20
-
21
- export type Props = {
22
- as?: 'li' | 'div' | 'span';
23
- inverted?: boolean;
24
- disabled?: boolean;
25
- partialInteractivity?: boolean;
26
- spotlight?: 'active' | 'inactive';
27
- title: ReactNode;
28
- subtitle?: ReactNode;
29
- additionalInfo?: ReactNode;
30
- valueTitle?: ReactNode;
31
- valueSubtitle?: ReactNode;
32
- media?: ReactNode;
33
- control?: ReactNode;
34
- prompt?: ReactNode;
35
- };
36
-
37
- export type ItemContextData = {
38
- setControlType: (type: ItemTypes) => void;
39
- ids: {
40
- label: string;
41
- additionalInfo: string;
42
- value: string;
43
- control: string;
44
- prompt: string;
45
- };
46
- props: Pick<Props, 'as' | 'disabled' | 'inverted'>;
47
- };
48
-
49
- // @ts-expect-error for now let's mock it with `null` value
50
- // but actually by default we should specify `setControlType('none')`
51
- export const ItemContext = createContext<ItemContextData>(null);
52
-
53
- export const Item = ({
54
- as: View = 'li',
55
- title,
56
- subtitle,
57
- additionalInfo,
58
- prompt,
59
- inverted,
60
- media,
61
- spotlight = undefined,
62
- valueTitle,
63
- valueSubtitle,
64
- control,
65
- disabled,
66
- }: Props) => {
67
- /*
68
- const returnType = (): ReactNode => {
69
- switch (type) {
70
- case 'Navigation':
71
- return <Chevron orientation={Position.RIGHT} disabled />;
72
- case 'Radio':
73
- return <RadioButton name="Hello" checked />;
74
- case 'Checkbox':
75
- return <CheckboxButton name="Hello" checked />;
76
- case 'Switch':
77
- return <Switch onClick={() => console.log('clicked')} />;
78
- case 'Button':
79
- return <Button v2>Hello</Button>;
80
- case 'IconButton':
81
- return (
82
- <IconButton size={40} priority="minimal">
83
- <InfoCircle />
84
- </IconButton>
85
- );
86
- case 'NonInteractive':
87
- default:
88
- return <></>;
89
- }
90
- };
91
- */
92
- const idPrefix = useId();
93
-
94
- const [controlType, setControlType] = useState<ItemTypes>();
95
- const ids = {
96
- label: `${idPrefix}_label`,
97
- value: `${idPrefix}_value`,
98
- control: `${idPrefix}_control`,
99
- prompt: `${idPrefix}_prompt`,
100
- additionalInfo: `${idPrefix}_additional-info`,
101
- };
102
-
103
- const itemCtx = useMemo(
104
- () => ({ setControlType, ids, props: { as: View, disabled, inverted } }),
105
- [],
106
- );
107
-
108
- return (
109
- <ItemContext.Provider value={itemCtx}>
110
- <View
111
- className={clsx('np-item', `np-item-${controlType}`, {
112
- [`np-item-spotlight-${spotlight}`]: !!spotlight,
113
- })}
114
- aria-describedby={[ids.additionalInfo].join(' ')}
115
- >
116
- {media && <div className="np-item-media">{media}</div>}
117
-
118
- {/* Title + Subtitle + Values + Additional Info - Group */}
119
- <div>
120
- {/* Title + Subtitle + Values - Group */}
121
- <div className="d-flex justify-content-between">
122
- <span>
123
- {/* @ts-expect-error div can have role and aria-lavel props */}
124
- <Body
125
- type={Typography.BODY_LARGE_BOLD}
126
- className="np-item-title"
127
- // for a11y this needs to be a header but for SEO it shouldn't be `h*` tag
128
- // so we enable header semantics via `role` and `aria-level` attrs
129
- role="heading"
130
- aria-level="4"
131
- >
132
- {title}
133
- </Body>
134
- <Body className="np-item-subtitle">{subtitle}</Body>
135
- </span>
136
- {(valueTitle || valueSubtitle) && (
137
- <span id={ids.value} className="np-item-value">
138
- <Body type={Typography.BODY_LARGE_BOLD} className="np-item-title-value">
139
- {valueTitle}
140
- </Body>
141
- <Body className="np-item-subtitle-value">{valueSubtitle}</Body>
142
- </span>
143
- )}
144
- </div>
145
-
146
- {/* Additional Info and Prompt here */}
147
- {Boolean(subtitle) && additionalInfo}
148
- </div>
149
- <Body className="np-item-control">{control}</Body>
150
- {prompt}
151
- </View>
152
- </ItemContext.Provider>
153
- );
154
- };
155
-
156
- /* eslint-disable functional/immutable-data */
157
- Item.Image = Image;
158
- Item.AdditionalInfo = AdditionalInfo;
159
- Item.Checkbox = Checkbox;
160
- Item.IconButton = IconButton;
161
- Item.Navigation = Navigation;
162
- Item.Prompt = Prompt;
163
- /* eslint-enable functional/immutable-data */
164
-
165
- export default Item;
@@ -1,31 +0,0 @@
1
- import { PropsWithChildren, useContext } from 'react';
2
- import { ItemContext, ItemContextData } from './Item';
3
- import Body from '../body';
4
- import Link, { LinkProps } from '../link';
5
- import { Typography } from '../common';
6
-
7
- export type ItemAdditionalInfoProps = PropsWithChildren<{
8
- action?: Pick<LinkProps, 'href' | 'onClick' | 'target'> & { label?: string };
9
- }>;
10
-
11
- export const AdditionalInfo = function ({ children, action }: ItemAdditionalInfoProps) {
12
- const { ids } = useContext<ItemContextData>(ItemContext);
13
-
14
- return (
15
- <Body
16
- type={Typography.BODY_DEFAULT}
17
- id={ids.additionalInfo}
18
- className="np-item-additional-info"
19
- >
20
- {children}
21
- {action ? (
22
- <>
23
- {' '}
24
- <Link href={action.href} target={action.target} onClick={action.onClick}>
25
- {action.label}
26
- </Link>
27
- </>
28
- ) : null}
29
- </Body>
30
- );
31
- };
@@ -1,16 +0,0 @@
1
- import { useContext, useEffect } from 'react';
2
- import CheckboxButton from '../checkboxButton';
3
- import { CheckboxButtonProps } from '../checkboxButton/CheckboxButton';
4
- import { ItemContext, ItemContextData } from './Item';
5
-
6
- export type ItemCheckboxProps = Pick<CheckboxButtonProps, 'checked' | 'indeterminate' | 'onChange'>;
7
-
8
- export const Checkbox = function (props: ItemCheckboxProps) {
9
- const { setControlType, props: baseItemProps } = useContext<ItemContextData>(ItemContext);
10
-
11
- useEffect(() => {
12
- setControlType('checkbox');
13
- }, []);
14
-
15
- return <CheckboxButton disabled={baseItemProps.disabled} {...props} />;
16
- };
@@ -1,15 +0,0 @@
1
- import { useContext, useEffect } from 'react';
2
- import { default as IconButtonComp, IconButtonProps } from '../iconButton';
3
- import { ItemContext, ItemContextData } from './Item';
4
-
5
- export type ItemIconButtonProps = Pick<IconButtonProps, 'onClick' | 'href' | 'target'>;
6
-
7
- export const IconButton = function (props: ItemIconButtonProps) {
8
- const { setControlType } = useContext<ItemContextData>(ItemContext);
9
-
10
- useEffect(() => {
11
- setControlType('icon-button');
12
- }, []);
13
-
14
- return <IconButtonComp {...props} size={32} />;
15
- };
@@ -1,11 +0,0 @@
1
- import { useContext, useEffect } from 'react';
2
- import Item, { ItemContext, ItemContextData } from './Item';
3
- import { default as Img, ImageProps } from '../image/Image';
4
-
5
- export type ItemImageProps = Pick<ImageProps, 'src' | 'alt'>;
6
-
7
- export const Image = function (props: ItemImageProps) {
8
- const { ids, props: baseItemProps } = useContext<ItemContextData>(ItemContext);
9
-
10
- return <Img {...props} />;
11
- };
@@ -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
- });