@transferwise/components 0.0.0-experimental-3780b7e → 0.0.0-experimental-b458b80
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/listItem/Prompt/ListItemPrompt.js +5 -4
- package/build/listItem/Prompt/ListItemPrompt.js.map +1 -1
- package/build/listItem/Prompt/ListItemPrompt.mjs +6 -2
- package/build/listItem/Prompt/ListItemPrompt.mjs.map +1 -1
- package/build/types/listItem/ListItem.d.ts +1 -1
- package/build/types/listItem/Prompt/ListItemPrompt.d.ts +2 -3
- package/build/types/listItem/Prompt/ListItemPrompt.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/listItem/Prompt/ListItemPrompt.story.tsx +71 -9
- package/src/listItem/Prompt/ListItemPrompt.test.tsx +31 -0
- package/src/listItem/Prompt/ListItemPrompt.tsx +8 -2
- package/src/prompt/InlinePrompt/InlinePrompt.story.tsx +13 -10
- package/src/prompt/InlinePrompt/InlinePrompt.test.tsx +13 -1
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var React = require('react');
|
|
6
4
|
require('../../common/theme.js');
|
|
7
5
|
require('../../common/direction.js');
|
|
@@ -44,7 +42,9 @@ require('../../link/Link.messages.js');
|
|
|
44
42
|
const Prompt = ({
|
|
45
43
|
sentiment: sentiment$1 = sentiment.Sentiment.NEUTRAL,
|
|
46
44
|
mediaLabel,
|
|
47
|
-
children
|
|
45
|
+
children,
|
|
46
|
+
media,
|
|
47
|
+
loading
|
|
48
48
|
}) => {
|
|
49
49
|
const {
|
|
50
50
|
ids,
|
|
@@ -54,6 +54,8 @@ const Prompt = ({
|
|
|
54
54
|
return /*#__PURE__*/jsxRuntime.jsx(InlinePrompt.InlinePrompt, {
|
|
55
55
|
id: ids.prompt,
|
|
56
56
|
sentiment: sentiment$1,
|
|
57
|
+
media: media,
|
|
58
|
+
loading: loading,
|
|
57
59
|
mediaLabel: mediaLabel,
|
|
58
60
|
muted: isLongLivedMuted,
|
|
59
61
|
className: "wds-list-item-prompt",
|
|
@@ -63,5 +65,4 @@ const Prompt = ({
|
|
|
63
65
|
Prompt.displayName = 'ListItem.Prompt';
|
|
64
66
|
|
|
65
67
|
exports.Prompt = Prompt;
|
|
66
|
-
exports.default = Prompt;
|
|
67
68
|
//# sourceMappingURL=ListItemPrompt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItemPrompt.js","sources":["../../../src/listItem/Prompt/ListItemPrompt.tsx"],"sourcesContent":["import { useContext } from 'react';\nimport { Sentiment } from '../../common';\nimport { ListItemContext, type ListItemContextData } from '../ListItemContext';\nimport { InlinePrompt, type InlinePromptProps } from '../../prompt';\n\nexport type ListItemPromptProps = Pick
|
|
1
|
+
{"version":3,"file":"ListItemPrompt.js","sources":["../../../src/listItem/Prompt/ListItemPrompt.tsx"],"sourcesContent":["import { useContext } from 'react';\nimport { Sentiment } from '../../common';\nimport { ListItemContext, type ListItemContextData } from '../ListItemContext';\nimport { InlinePrompt, type InlinePromptProps } from '../../prompt';\n\nexport type ListItemPromptProps = Pick<\n InlinePromptProps,\n 'children' | 'sentiment' | 'mediaLabel' | 'media' | 'loading'\n>;\n\n/**\n * This component allows for rendering an Inline Prompt. <br />\n * In the future it will be a thin wrapper around a standalone component.<br />\n *\n * Please refer to the [Design documentation](https://wise.design/components/list-item#prompt) for details.\n */\nexport const Prompt = ({\n sentiment = Sentiment.NEUTRAL,\n mediaLabel,\n children,\n media,\n loading,\n}: ListItemPromptProps) => {\n const { ids, props } = useContext<ListItemContextData>(ListItemContext);\n const isLongLivedMuted = props.disabled && Boolean(props.disabledPromptMessage);\n\n return (\n <InlinePrompt\n id={ids.prompt}\n sentiment={sentiment}\n media={media}\n loading={loading}\n mediaLabel={mediaLabel}\n muted={isLongLivedMuted}\n className=\"wds-list-item-prompt\"\n >\n {isLongLivedMuted ? props.disabledPromptMessage : children}\n </InlinePrompt>\n );\n};\n\nPrompt.displayName = 'ListItem.Prompt';\n"],"names":["Prompt","sentiment","Sentiment","NEUTRAL","mediaLabel","children","media","loading","ids","props","useContext","ListItemContext","isLongLivedMuted","disabled","Boolean","disabledPromptMessage","_jsx","InlinePrompt","id","prompt","muted","className","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBO,MAAMA,MAAM,GAAGA,CAAC;aACrBC,WAAS,GAAGC,mBAAS,CAACC,OAAO;EAC7BC,UAAU;EACVC,QAAQ;EACRC,KAAK;AACLC,EAAAA;AAAO,CACa,KAAI;EACxB,MAAM;IAAEC,GAAG;AAAEC,IAAAA;AAAK,GAAE,GAAGC,gBAAU,CAAsBC,+BAAe,CAAC;EACvE,MAAMC,gBAAgB,GAAGH,KAAK,CAACI,QAAQ,IAAIC,OAAO,CAACL,KAAK,CAACM,qBAAqB,CAAC;EAE/E,oBACEC,cAAA,CAACC,yBAAY,EAAA;IACXC,EAAE,EAAEV,GAAG,CAACW,MAAO;AACflB,IAAAA,SAAS,EAAEA,WAAU;AACrBK,IAAAA,KAAK,EAAEA,KAAM;AACbC,IAAAA,OAAO,EAAEA,OAAQ;AACjBH,IAAAA,UAAU,EAAEA,UAAW;AACvBgB,IAAAA,KAAK,EAAER,gBAAiB;AACxBS,IAAAA,SAAS,EAAC,sBAAsB;AAAAhB,IAAAA,QAAA,EAE/BO,gBAAgB,GAAGH,KAAK,CAACM,qBAAqB,GAAGV;AAAQ,GAC9C,CAAC;AAEnB;AAEAL,MAAM,CAACsB,WAAW,GAAG,iBAAiB;;;;"}
|
|
@@ -40,7 +40,9 @@ import '../../link/Link.messages.mjs';
|
|
|
40
40
|
const Prompt = ({
|
|
41
41
|
sentiment = Sentiment.NEUTRAL,
|
|
42
42
|
mediaLabel,
|
|
43
|
-
children
|
|
43
|
+
children,
|
|
44
|
+
media,
|
|
45
|
+
loading
|
|
44
46
|
}) => {
|
|
45
47
|
const {
|
|
46
48
|
ids,
|
|
@@ -50,6 +52,8 @@ const Prompt = ({
|
|
|
50
52
|
return /*#__PURE__*/jsx(InlinePrompt, {
|
|
51
53
|
id: ids.prompt,
|
|
52
54
|
sentiment: sentiment,
|
|
55
|
+
media: media,
|
|
56
|
+
loading: loading,
|
|
53
57
|
mediaLabel: mediaLabel,
|
|
54
58
|
muted: isLongLivedMuted,
|
|
55
59
|
className: "wds-list-item-prompt",
|
|
@@ -58,5 +62,5 @@ const Prompt = ({
|
|
|
58
62
|
};
|
|
59
63
|
Prompt.displayName = 'ListItem.Prompt';
|
|
60
64
|
|
|
61
|
-
export { Prompt
|
|
65
|
+
export { Prompt };
|
|
62
66
|
//# sourceMappingURL=ListItemPrompt.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItemPrompt.mjs","sources":["../../../src/listItem/Prompt/ListItemPrompt.tsx"],"sourcesContent":["import { useContext } from 'react';\nimport { Sentiment } from '../../common';\nimport { ListItemContext, type ListItemContextData } from '../ListItemContext';\nimport { InlinePrompt, type InlinePromptProps } from '../../prompt';\n\nexport type ListItemPromptProps = Pick
|
|
1
|
+
{"version":3,"file":"ListItemPrompt.mjs","sources":["../../../src/listItem/Prompt/ListItemPrompt.tsx"],"sourcesContent":["import { useContext } from 'react';\nimport { Sentiment } from '../../common';\nimport { ListItemContext, type ListItemContextData } from '../ListItemContext';\nimport { InlinePrompt, type InlinePromptProps } from '../../prompt';\n\nexport type ListItemPromptProps = Pick<\n InlinePromptProps,\n 'children' | 'sentiment' | 'mediaLabel' | 'media' | 'loading'\n>;\n\n/**\n * This component allows for rendering an Inline Prompt. <br />\n * In the future it will be a thin wrapper around a standalone component.<br />\n *\n * Please refer to the [Design documentation](https://wise.design/components/list-item#prompt) for details.\n */\nexport const Prompt = ({\n sentiment = Sentiment.NEUTRAL,\n mediaLabel,\n children,\n media,\n loading,\n}: ListItemPromptProps) => {\n const { ids, props } = useContext<ListItemContextData>(ListItemContext);\n const isLongLivedMuted = props.disabled && Boolean(props.disabledPromptMessage);\n\n return (\n <InlinePrompt\n id={ids.prompt}\n sentiment={sentiment}\n media={media}\n loading={loading}\n mediaLabel={mediaLabel}\n muted={isLongLivedMuted}\n className=\"wds-list-item-prompt\"\n >\n {isLongLivedMuted ? props.disabledPromptMessage : children}\n </InlinePrompt>\n );\n};\n\nPrompt.displayName = 'ListItem.Prompt';\n"],"names":["Prompt","sentiment","Sentiment","NEUTRAL","mediaLabel","children","media","loading","ids","props","useContext","ListItemContext","isLongLivedMuted","disabled","Boolean","disabledPromptMessage","_jsx","InlinePrompt","id","prompt","muted","className","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBO,MAAMA,MAAM,GAAGA,CAAC;EACrBC,SAAS,GAAGC,SAAS,CAACC,OAAO;EAC7BC,UAAU;EACVC,QAAQ;EACRC,KAAK;AACLC,EAAAA;AAAO,CACa,KAAI;EACxB,MAAM;IAAEC,GAAG;AAAEC,IAAAA;AAAK,GAAE,GAAGC,UAAU,CAAsBC,eAAe,CAAC;EACvE,MAAMC,gBAAgB,GAAGH,KAAK,CAACI,QAAQ,IAAIC,OAAO,CAACL,KAAK,CAACM,qBAAqB,CAAC;EAE/E,oBACEC,GAAA,CAACC,YAAY,EAAA;IACXC,EAAE,EAAEV,GAAG,CAACW,MAAO;AACflB,IAAAA,SAAS,EAAEA,SAAU;AACrBK,IAAAA,KAAK,EAAEA,KAAM;AACbC,IAAAA,OAAO,EAAEA,OAAQ;AACjBH,IAAAA,UAAU,EAAEA,UAAW;AACvBgB,IAAAA,KAAK,EAAER,gBAAiB;AACxBS,IAAAA,SAAS,EAAC,sBAAsB;AAAAhB,IAAAA,QAAA,EAE/BO,gBAAgB,GAAGH,KAAK,CAACM,qBAAqB,GAAGV;AAAQ,GAC9C,CAAC;AAEnB;AAEAL,MAAM,CAACsB,WAAW,GAAG,iBAAiB;;;;"}
|
|
@@ -112,7 +112,7 @@ export declare const ListItem: {
|
|
|
112
112
|
displayName: string;
|
|
113
113
|
};
|
|
114
114
|
Prompt: {
|
|
115
|
-
({ sentiment, mediaLabel, children, }: import("./Prompt").ListItemPromptProps): import("react").JSX.Element;
|
|
115
|
+
({ sentiment, mediaLabel, children, media, loading, }: import("./Prompt").ListItemPromptProps): import("react").JSX.Element;
|
|
116
116
|
displayName: string;
|
|
117
117
|
};
|
|
118
118
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type InlinePromptProps } from '../../prompt';
|
|
2
|
-
export type ListItemPromptProps = Pick<InlinePromptProps, 'children' | 'sentiment' | 'mediaLabel'>;
|
|
2
|
+
export type ListItemPromptProps = Pick<InlinePromptProps, 'children' | 'sentiment' | 'mediaLabel' | 'media' | 'loading'>;
|
|
3
3
|
/**
|
|
4
4
|
* This component allows for rendering an Inline Prompt. <br />
|
|
5
5
|
* In the future it will be a thin wrapper around a standalone component.<br />
|
|
@@ -7,8 +7,7 @@ export type ListItemPromptProps = Pick<InlinePromptProps, 'children' | 'sentimen
|
|
|
7
7
|
* Please refer to the [Design documentation](https://wise.design/components/list-item#prompt) for details.
|
|
8
8
|
*/
|
|
9
9
|
export declare const Prompt: {
|
|
10
|
-
({ sentiment, mediaLabel, children, }: ListItemPromptProps): import("react").JSX.Element;
|
|
10
|
+
({ sentiment, mediaLabel, children, media, loading, }: ListItemPromptProps): import("react").JSX.Element;
|
|
11
11
|
displayName: string;
|
|
12
12
|
};
|
|
13
|
-
export default Prompt;
|
|
14
13
|
//# sourceMappingURL=ListItemPrompt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItemPrompt.d.ts","sourceRoot":"","sources":["../../../../src/listItem/Prompt/ListItemPrompt.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAgB,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEpE,MAAM,MAAM,mBAAmB,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"ListItemPrompt.d.ts","sourceRoot":"","sources":["../../../../src/listItem/Prompt/ListItemPrompt.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAgB,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEpE,MAAM,MAAM,mBAAmB,GAAG,IAAI,CACpC,iBAAiB,EACjB,UAAU,GAAG,WAAW,GAAG,YAAY,GAAG,OAAO,GAAG,SAAS,CAC9D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,MAAM;2DAMhB,mBAAmB;;CAiBrB,CAAC"}
|
package/package.json
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
} from '../_stories/subcomponents';
|
|
12
12
|
import { ListItem } from '../ListItem';
|
|
13
13
|
import { Prompt, type ListItemPromptProps } from './ListItemPrompt';
|
|
14
|
+
import { Clock } from '@transferwise/icons';
|
|
14
15
|
|
|
15
16
|
const meta: Meta<ListItemPromptProps> = {
|
|
16
17
|
component: Prompt,
|
|
@@ -66,7 +67,7 @@ export const Playground: Story = {
|
|
|
66
67
|
subtitle={lorem10}
|
|
67
68
|
media={MEDIA.avatarSingle}
|
|
68
69
|
control={CONTROLS.switch}
|
|
69
|
-
prompt={<Prompt {...args} />}
|
|
70
|
+
prompt={<ListItem.Prompt {...args} />}
|
|
70
71
|
/>
|
|
71
72
|
</List>
|
|
72
73
|
),
|
|
@@ -86,28 +87,89 @@ export const Sentiment: Story = {
|
|
|
86
87
|
subtitle={lorem10}
|
|
87
88
|
media={MEDIA.avatarSingle}
|
|
88
89
|
control={CONTROLS.switch}
|
|
89
|
-
prompt={
|
|
90
|
+
prompt={
|
|
91
|
+
<ListItem.Prompt sentiment={Sentiments.NEUTRAL}>
|
|
92
|
+
This is a neutral prompt.
|
|
93
|
+
</ListItem.Prompt>
|
|
94
|
+
}
|
|
90
95
|
/>
|
|
91
96
|
<ListItem
|
|
92
97
|
title={lorem5}
|
|
93
98
|
subtitle={lorem10}
|
|
94
99
|
media={MEDIA.avatarSingle}
|
|
95
100
|
control={CONTROLS.switch}
|
|
96
|
-
prompt={
|
|
101
|
+
prompt={
|
|
102
|
+
<ListItem.Prompt sentiment={Sentiments.POSITIVE}>
|
|
103
|
+
This is a positive prompt.
|
|
104
|
+
</ListItem.Prompt>
|
|
105
|
+
}
|
|
97
106
|
/>
|
|
98
107
|
<ListItem
|
|
99
108
|
title={lorem5}
|
|
100
109
|
subtitle={lorem10}
|
|
101
110
|
media={MEDIA.avatarSingle}
|
|
102
111
|
control={CONTROLS.switch}
|
|
103
|
-
prompt={
|
|
112
|
+
prompt={
|
|
113
|
+
<ListItem.Prompt sentiment={Sentiments.WARNING}>
|
|
114
|
+
This is a warning prompt.
|
|
115
|
+
</ListItem.Prompt>
|
|
116
|
+
}
|
|
104
117
|
/>
|
|
105
118
|
<ListItem
|
|
106
119
|
title={lorem5}
|
|
107
120
|
subtitle={lorem10}
|
|
108
121
|
media={MEDIA.avatarSingle}
|
|
109
122
|
control={CONTROLS.switch}
|
|
110
|
-
prompt={
|
|
123
|
+
prompt={
|
|
124
|
+
<ListItem.Prompt sentiment={Sentiments.NEGATIVE}>
|
|
125
|
+
This is a negative prompt.
|
|
126
|
+
</ListItem.Prompt>
|
|
127
|
+
}
|
|
128
|
+
/>
|
|
129
|
+
</List>
|
|
130
|
+
),
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* While all main sentiments (`warning`, `negative`, `positive` and `neutral`) are associated with a
|
|
135
|
+
* default `StatusIcon`s, we also allow for Icon overrides to bring the prompt's visual language
|
|
136
|
+
* closer to the prompt's content. <br /><br />
|
|
137
|
+
* It's also possible to override the default StatusIcon's accessible name announced by screen
|
|
138
|
+
* readers via `mediaLabel` prop, which is especially useful for the `proposition` sentiment.
|
|
139
|
+
* <br /><br />
|
|
140
|
+
* **NB**: If you're setting a label on a custom Icon, the accessible name should be provided via
|
|
141
|
+
* Icon's `title` prop instead.
|
|
142
|
+
*/
|
|
143
|
+
export const IconOverrides: Story = {
|
|
144
|
+
parameters: {
|
|
145
|
+
controls: { disable: true },
|
|
146
|
+
actions: { disable: true },
|
|
147
|
+
a11y: { disable: true },
|
|
148
|
+
knobs: { disable: true },
|
|
149
|
+
},
|
|
150
|
+
render: (args) => (
|
|
151
|
+
<List>
|
|
152
|
+
<ListItem
|
|
153
|
+
title={lorem5}
|
|
154
|
+
subtitle={lorem10}
|
|
155
|
+
media={MEDIA.avatarSingle}
|
|
156
|
+
control={CONTROLS.switch}
|
|
157
|
+
prompt={
|
|
158
|
+
<ListItem.Prompt sentiment={Sentiments.WARNING} mediaLabel="Processing: ">
|
|
159
|
+
This prompt uses default Icon, but with a custom label for screen readers.
|
|
160
|
+
</ListItem.Prompt>
|
|
161
|
+
}
|
|
162
|
+
/>
|
|
163
|
+
<ListItem
|
|
164
|
+
title={lorem5}
|
|
165
|
+
subtitle={lorem10}
|
|
166
|
+
media={MEDIA.avatarSingle}
|
|
167
|
+
control={CONTROLS.switch}
|
|
168
|
+
prompt={
|
|
169
|
+
<ListItem.Prompt sentiment={Sentiments.WARNING} media={<Clock title="Processing: " />}>
|
|
170
|
+
This prompt uses custom Icon with a custom label for screen readers.
|
|
171
|
+
</ListItem.Prompt>
|
|
172
|
+
}
|
|
111
173
|
/>
|
|
112
174
|
</List>
|
|
113
175
|
),
|
|
@@ -135,13 +197,13 @@ export const Interactivity: Story = {
|
|
|
135
197
|
media={MEDIA.avatarSingle}
|
|
136
198
|
control={CONTROLS.switch}
|
|
137
199
|
prompt={
|
|
138
|
-
<Prompt sentiment={args.sentiment}>
|
|
200
|
+
<ListItem.Prompt sentiment={args.sentiment}>
|
|
139
201
|
This prompt includes a{' '}
|
|
140
202
|
<Link href="https://wise.com" target="_blank" rel="noreferrer">
|
|
141
203
|
link to some resource
|
|
142
204
|
</Link>{' '}
|
|
143
205
|
to help the user in their journey.
|
|
144
|
-
</Prompt>
|
|
206
|
+
</ListItem.Prompt>
|
|
145
207
|
}
|
|
146
208
|
/>
|
|
147
209
|
|
|
@@ -151,13 +213,13 @@ export const Interactivity: Story = {
|
|
|
151
213
|
media={MEDIA.avatarSingle}
|
|
152
214
|
control={CONTROLS.switch}
|
|
153
215
|
prompt={
|
|
154
|
-
<Prompt sentiment={args.sentiment}>
|
|
216
|
+
<ListItem.Prompt sentiment={args.sentiment}>
|
|
155
217
|
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events */}
|
|
156
218
|
This prompt includes an <Link onClick={action('inline button')}>
|
|
157
219
|
inline button
|
|
158
220
|
</Link>{' '}
|
|
159
221
|
than can e.g. trigger a modal.
|
|
160
|
-
</Prompt>
|
|
222
|
+
</ListItem.Prompt>
|
|
161
223
|
}
|
|
162
224
|
/>
|
|
163
225
|
</List>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Clock } from '@transferwise/icons';
|
|
1
2
|
import { mockMatchMedia, render, screen } from '../../test-utils';
|
|
2
3
|
import { Sentiment } from '../../common';
|
|
3
4
|
import { ListItem } from '../ListItem';
|
|
@@ -18,6 +19,8 @@ describe('ListItem.Prompt', () => {
|
|
|
18
19
|
});
|
|
19
20
|
|
|
20
21
|
describe('render icon', () => {
|
|
22
|
+
const customLabel = 'Custom icon label';
|
|
23
|
+
|
|
21
24
|
it.each([
|
|
22
25
|
[Sentiment.NEUTRAL, 'info-icon'],
|
|
23
26
|
[Sentiment.POSITIVE, 'check-icon'],
|
|
@@ -32,6 +35,34 @@ describe('ListItem.Prompt', () => {
|
|
|
32
35
|
);
|
|
33
36
|
expect(screen.getByTestId(iconId)).toBeInTheDocument();
|
|
34
37
|
});
|
|
38
|
+
|
|
39
|
+
it('should accept accessible name override for a status icon', () => {
|
|
40
|
+
render(
|
|
41
|
+
<ListItem
|
|
42
|
+
title="Test Title"
|
|
43
|
+
prompt={
|
|
44
|
+
<ListItem.Prompt sentiment={Sentiment.NEGATIVE} mediaLabel={customLabel}>
|
|
45
|
+
Message
|
|
46
|
+
</ListItem.Prompt>
|
|
47
|
+
}
|
|
48
|
+
/>,
|
|
49
|
+
);
|
|
50
|
+
expect(screen.getByLabelText(customLabel)).toBeInTheDocument();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should accept icon accessible name override', () => {
|
|
54
|
+
render(
|
|
55
|
+
<ListItem
|
|
56
|
+
title="Test Title"
|
|
57
|
+
prompt={
|
|
58
|
+
<ListItem.Prompt sentiment={Sentiment.NEGATIVE} media={<Clock title={customLabel} />}>
|
|
59
|
+
Message
|
|
60
|
+
</ListItem.Prompt>
|
|
61
|
+
}
|
|
62
|
+
/>,
|
|
63
|
+
);
|
|
64
|
+
expect(screen.getByLabelText(customLabel)).toBeInTheDocument();
|
|
65
|
+
});
|
|
35
66
|
});
|
|
36
67
|
|
|
37
68
|
describe('muted state', () => {
|
|
@@ -3,7 +3,10 @@ import { Sentiment } from '../../common';
|
|
|
3
3
|
import { ListItemContext, type ListItemContextData } from '../ListItemContext';
|
|
4
4
|
import { InlinePrompt, type InlinePromptProps } from '../../prompt';
|
|
5
5
|
|
|
6
|
-
export type ListItemPromptProps = Pick<
|
|
6
|
+
export type ListItemPromptProps = Pick<
|
|
7
|
+
InlinePromptProps,
|
|
8
|
+
'children' | 'sentiment' | 'mediaLabel' | 'media' | 'loading'
|
|
9
|
+
>;
|
|
7
10
|
|
|
8
11
|
/**
|
|
9
12
|
* This component allows for rendering an Inline Prompt. <br />
|
|
@@ -15,6 +18,8 @@ export const Prompt = ({
|
|
|
15
18
|
sentiment = Sentiment.NEUTRAL,
|
|
16
19
|
mediaLabel,
|
|
17
20
|
children,
|
|
21
|
+
media,
|
|
22
|
+
loading,
|
|
18
23
|
}: ListItemPromptProps) => {
|
|
19
24
|
const { ids, props } = useContext<ListItemContextData>(ListItemContext);
|
|
20
25
|
const isLongLivedMuted = props.disabled && Boolean(props.disabledPromptMessage);
|
|
@@ -23,6 +28,8 @@ export const Prompt = ({
|
|
|
23
28
|
<InlinePrompt
|
|
24
29
|
id={ids.prompt}
|
|
25
30
|
sentiment={sentiment}
|
|
31
|
+
media={media}
|
|
32
|
+
loading={loading}
|
|
26
33
|
mediaLabel={mediaLabel}
|
|
27
34
|
muted={isLongLivedMuted}
|
|
28
35
|
className="wds-list-item-prompt"
|
|
@@ -33,4 +40,3 @@ export const Prompt = ({
|
|
|
33
40
|
};
|
|
34
41
|
|
|
35
42
|
Prompt.displayName = 'ListItem.Prompt';
|
|
36
|
-
export default Prompt;
|
|
@@ -225,24 +225,27 @@ export const Muted: StoryObj<PreviewStoryArgs> = {
|
|
|
225
225
|
* While all main sentiments (`warning`, `negative`, `positive` and`neutral`) are associated with a
|
|
226
226
|
* default `StatusIcon`s, we also allow for Icon overrides to bring the prompt's visual language
|
|
227
227
|
* closer to the prompt's content. <br /><br />
|
|
228
|
-
* It's also possible to override the default
|
|
229
|
-
* via `mediaLabel` prop, which is especially useful for the `proposition` sentiment.
|
|
228
|
+
* It's also possible to override the default StatusIcon's accessible name announced by screen
|
|
229
|
+
* readers via `mediaLabel` prop, which is especially useful for the `proposition` sentiment.
|
|
230
|
+
* <br /><br />
|
|
231
|
+
* **NB**: If you're setting a label on a custom Icon, the accessible name should be provided via
|
|
232
|
+
* Icon's `title` prop instead.
|
|
230
233
|
*/
|
|
231
234
|
export const IconOverrides: StoryObj<PreviewStoryArgs> = {
|
|
232
235
|
render: (args: PreviewStoryArgs) => {
|
|
233
236
|
return (
|
|
234
237
|
<>
|
|
235
|
-
<InlinePrompt {...args}
|
|
236
|
-
|
|
237
|
-
</InlinePrompt>
|
|
238
|
-
<InlinePrompt {...args} media={<Taxi />} sentiment="proposition" mediaLabel="Taxi addon: ">
|
|
239
|
-
Connect Wise with your taxi app to get exclusive discounts.
|
|
238
|
+
<InlinePrompt {...args} sentiment="negative" mediaLabel="Rejected: ">
|
|
239
|
+
This prompt uses default Icon, but with a custom label for screen readers.
|
|
240
240
|
</InlinePrompt>
|
|
241
|
-
<InlinePrompt {...args} media={<Clock />} sentiment="warning"
|
|
241
|
+
<InlinePrompt {...args} media={<Clock title="Processing: " />} sentiment="warning">
|
|
242
242
|
The account verification is taking longer than usual.
|
|
243
243
|
</InlinePrompt>
|
|
244
|
-
<InlinePrompt {...args} media={<
|
|
245
|
-
|
|
244
|
+
<InlinePrompt {...args} media={<Travel title="Activated: " />} sentiment="positive">
|
|
245
|
+
Your travel account is set up and ready to use.
|
|
246
|
+
</InlinePrompt>
|
|
247
|
+
<InlinePrompt {...args} media={<Taxi title="Taxi addon: " />} sentiment="proposition">
|
|
248
|
+
Connect Wise with your taxi app to get exclusive discounts.
|
|
246
249
|
</InlinePrompt>
|
|
247
250
|
</>
|
|
248
251
|
);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Clock } from '@transferwise/icons';
|
|
1
2
|
import { mockMatchMedia, render, screen } from '../../test-utils';
|
|
2
3
|
import { InlinePrompt, InlinePromptProps } from './InlinePrompt';
|
|
3
4
|
import { Sentiment } from '../../common';
|
|
@@ -91,11 +92,22 @@ describe('InlinePrompt', () => {
|
|
|
91
92
|
});
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
it('should allow for customisation of aria label', () => {
|
|
95
|
+
it('should allow for customisation of aria label for StatusIcon', () => {
|
|
95
96
|
render(<InlinePrompt {...defaultProps} sentiment={sentiment} mediaLabel={mediaLabel} />);
|
|
96
97
|
expect(screen.getByLabelText(mediaLabel)).toBeInTheDocument();
|
|
97
98
|
});
|
|
98
99
|
|
|
100
|
+
it('should allow for customisation of aria label for a custom Icon', () => {
|
|
101
|
+
render(
|
|
102
|
+
<InlinePrompt
|
|
103
|
+
{...defaultProps}
|
|
104
|
+
sentiment={sentiment}
|
|
105
|
+
media={<Clock title={mediaLabel} />}
|
|
106
|
+
/>,
|
|
107
|
+
);
|
|
108
|
+
expect(screen.getByLabelText(mediaLabel)).toBeInTheDocument();
|
|
109
|
+
});
|
|
110
|
+
|
|
99
111
|
it('should retain custom label while muted', () => {
|
|
100
112
|
render(
|
|
101
113
|
<InlinePrompt {...defaultProps} sentiment={sentiment} mediaLabel={mediaLabel} muted />,
|