@transferwise/components 46.119.5 → 46.120.1
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/alert/Alert.js +1 -1
- package/build/alert/Alert.js.map +1 -1
- package/build/alert/Alert.mjs +1 -1
- package/build/alert/Alert.mjs.map +1 -1
- package/build/checkbox/Checkbox.js +1 -1
- package/build/checkbox/Checkbox.js.map +1 -1
- package/build/checkbox/Checkbox.mjs +1 -1
- package/build/checkbox/Checkbox.mjs.map +1 -1
- package/build/common/initials.js +17 -7
- package/build/common/initials.js.map +1 -1
- package/build/common/initials.mjs +17 -7
- package/build/common/initials.mjs.map +1 -1
- package/build/field/Field.js +8 -4
- package/build/field/Field.js.map +1 -1
- package/build/field/Field.mjs +8 -4
- package/build/field/Field.mjs.map +1 -1
- package/build/inlineAlert/InlineAlert.js +1 -7
- package/build/inlineAlert/InlineAlert.js.map +1 -1
- package/build/inlineAlert/InlineAlert.mjs +1 -7
- package/build/inlineAlert/InlineAlert.mjs.map +1 -1
- package/build/main.css +20 -1
- package/build/prompt/InlinePrompt/InlinePrompt.js +2 -0
- package/build/prompt/InlinePrompt/InlinePrompt.js.map +1 -1
- package/build/prompt/InlinePrompt/InlinePrompt.mjs +2 -0
- package/build/prompt/InlinePrompt/InlinePrompt.mjs.map +1 -1
- package/build/radioGroup/RadioGroup.js +1 -0
- package/build/radioGroup/RadioGroup.js.map +1 -1
- package/build/radioGroup/RadioGroup.mjs +1 -0
- package/build/radioGroup/RadioGroup.mjs.map +1 -1
- package/build/styles/field/Field.css +10 -1
- package/build/styles/main.css +20 -1
- package/build/styles/prompt/InlinePrompt/InlinePrompt.css +3 -0
- package/build/styles/radioGroup/RadioGroup.css +3 -0
- package/build/styles/typeahead/Typeahead.css +4 -0
- package/build/typeahead/Typeahead.js +20 -7
- package/build/typeahead/Typeahead.js.map +1 -1
- package/build/typeahead/Typeahead.mjs +20 -7
- package/build/typeahead/Typeahead.mjs.map +1 -1
- package/build/types/alert/Alert.d.ts +1 -1
- package/build/types/alert/Alert.d.ts.map +1 -1
- package/build/types/common/initials.d.ts.map +1 -1
- package/build/types/field/Field.d.ts +8 -4
- package/build/types/field/Field.d.ts.map +1 -1
- package/build/types/inlineAlert/InlineAlert.d.ts +1 -7
- package/build/types/inlineAlert/InlineAlert.d.ts.map +1 -1
- package/build/types/listItem/_stories/variants/helpers.d.ts +7 -4
- package/build/types/listItem/_stories/variants/helpers.d.ts.map +1 -1
- package/build/types/prompt/InlinePrompt/InlinePrompt.d.ts +6 -1
- package/build/types/prompt/InlinePrompt/InlinePrompt.d.ts.map +1 -1
- package/build/types/radioGroup/RadioGroup.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts +0 -1
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/build/types/typeahead/Typeahead.d.ts +8 -4
- package/build/types/typeahead/Typeahead.d.ts.map +1 -1
- package/build/types/upload/Upload.d.ts +1 -1
- package/build/types/upload/steps/uploadImageStep/uploadImageStep.d.ts.map +1 -1
- package/build/upload/Upload.js.map +1 -1
- package/build/upload/Upload.mjs.map +1 -1
- package/build/upload/steps/uploadImageStep/uploadImageStep.js +5 -4
- package/build/upload/steps/uploadImageStep/uploadImageStep.js.map +1 -1
- package/build/upload/steps/uploadImageStep/uploadImageStep.mjs +5 -4
- package/build/upload/steps/uploadImageStep/uploadImageStep.mjs.map +1 -1
- package/package.json +9 -8
- package/src/DisabledComponents.story.tsx +1 -3
- package/src/actionButton/ActionButton.story.tsx +42 -45
- package/src/alert/Alert.spec.tsx +1 -1
- package/src/alert/Alert.tsx +2 -2
- package/src/avatar/Avatar.story.tsx +192 -188
- package/src/button/_stories/Button.tests.story.tsx +122 -119
- package/src/carousel/Carousel.story.tsx +4 -7
- package/src/checkbox/Checkbox.story.tsx +42 -21
- package/src/checkbox/Checkbox.tsx +1 -1
- package/src/checkbox/__snapshots__/Checkbox.spec.tsx.snap +1 -1
- package/src/circularButton/CircularButton.story.tsx +10 -2
- package/src/common/bottomSheet/BottomSheet.story.tsx +48 -14
- package/src/common/circle/Circle.story.tsx +62 -55
- package/src/common/initials.spec.tsx +31 -0
- package/src/common/initials.ts +19 -8
- package/src/criticalBanner/CriticalCommsBanner.story.tsx +30 -19
- package/src/dateInput/DateInput.tests.story.tsx +101 -74
- package/src/dateLookup/DateLookup.story.tsx +69 -59
- package/src/field/Field.css +10 -1
- package/src/field/Field.less +13 -2
- package/src/field/Field.spec.tsx +19 -3
- package/src/field/Field.story.tsx +18 -0
- package/src/field/Field.tsx +17 -5
- package/src/header/Header.story.tsx +5 -16
- package/src/header/Header.tests.story.tsx +95 -69
- package/src/info/Info.story.tsx +27 -11
- package/src/inlineAlert/InlineAlert.story.tsx +4 -0
- package/src/inlineAlert/InlineAlert.tsx +1 -7
- package/src/instructionsList/InstructionsList.story.tsx +0 -1
- package/src/listItem/_stories/ListItem.layout.test.story.tsx +1 -3
- package/src/listItem/_stories/variants/ListItem.brightGreen.test.story.tsx +77 -35
- package/src/listItem/_stories/variants/ListItem.dark.test.story.tsx +65 -29
- package/src/listItem/_stories/variants/ListItem.forestGreen.test.story.tsx +77 -35
- package/src/listItem/_stories/variants/ListItem.medium.test.story.tsx +38 -18
- package/src/listItem/_stories/variants/ListItem.neutral.test.story.tsx +0 -1
- package/src/listItem/_stories/variants/ListItem.personal.test.story.tsx +38 -18
- package/src/listItem/_stories/variants/ListItem.rtl.test.story.tsx +77 -29
- package/src/listItem/_stories/variants/ListItem.small.test.story.tsx +65 -18
- package/src/listItem/_stories/variants/helpers.tsx +136 -133
- package/src/main.css +20 -1
- package/src/main.less +1 -0
- package/src/modal/Modal.story.tsx +47 -8
- package/src/moneyInput/MoneyInput.story.tsx +2 -2
- package/src/primitives/PrimitiveAnchor/stories/PrimitiveAnchor.story.tsx +1 -0
- package/src/primitives/PrimitiveAnchor/stories/PrimitiveAnchor.tests.story.tsx +1 -0
- package/src/primitives/PrimitiveButton/stories/PrimitiveButton.story.tsx +1 -0
- package/src/primitives/PrimitiveButton/stories/PrimitiveButton.tests.story.tsx +1 -0
- package/src/prompt/InlinePrompt/InlinePrompt.css +3 -0
- package/src/prompt/InlinePrompt/InlinePrompt.less +5 -1
- package/src/prompt/InlinePrompt/InlinePrompt.spec.tsx +17 -0
- package/src/prompt/InlinePrompt/InlinePrompt.story.tsx +35 -0
- package/src/prompt/InlinePrompt/InlinePrompt.tsx +7 -0
- package/src/provider/theme/ThemeProvider.story.tsx +1 -0
- package/src/radioGroup/RadioGroup.css +3 -0
- package/src/radioGroup/RadioGroup.less +3 -0
- package/src/radioGroup/RadioGroup.story.tsx +2 -0
- package/src/radioGroup/RadioGroup.test.story.tsx +62 -0
- package/src/radioGroup/RadioGroup.tsx +6 -1
- package/src/segmentedControl/SegmentedControl.story.tsx +71 -67
- package/src/snackbar/Snackbar.tests.story.tsx +116 -114
- package/src/statusIcon/StatusIcon.story.tsx +41 -38
- package/src/test-utils/index.tsx +0 -2
- package/src/tokens/tokens.story.tsx +1 -1
- package/src/tooltip/Tooltip.story.tsx +10 -2
- package/src/typeahead/Typeahead.css +4 -0
- package/src/typeahead/Typeahead.less +5 -1
- package/src/typeahead/Typeahead.spec.tsx +1 -1
- package/src/typeahead/Typeahead.story.tsx +151 -3
- package/src/typeahead/Typeahead.tsx +33 -9
- package/src/upload/Upload.story.tsx +1 -1
- package/src/upload/Upload.tests.story.tsx +36 -1
- package/src/upload/Upload.tsx +1 -1
- package/src/upload/steps/uploadImageStep/uploadImageStep.tsx +7 -3
- package/src/withId/withId.story.tsx +1 -1
- package/build/types/test-utils/story-config.d.ts +0 -64
- package/build/types/test-utils/story-config.d.ts.map +0 -1
- package/src/test-utils/story-config.ts +0 -95
|
@@ -6,8 +6,8 @@ import { SnackbarConsumer } from './SnackbarContext';
|
|
|
6
6
|
import SnackbarProvider from './SnackbarProvider';
|
|
7
7
|
import Button from '../button';
|
|
8
8
|
import CheckboxOption from '../checkboxOption';
|
|
9
|
-
import { storyConfig } from '../test-utils';
|
|
10
9
|
import { wait } from '../test-utils/wait';
|
|
10
|
+
import { allModes } from '../../.storybook/modes';
|
|
11
11
|
|
|
12
12
|
export default {
|
|
13
13
|
title: 'Dialogs/Snackbar/Tests',
|
|
@@ -66,6 +66,7 @@ const Default = {
|
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
export const Basic = {
|
|
69
|
+
...Default,
|
|
69
70
|
args: {
|
|
70
71
|
...Default.args,
|
|
71
72
|
extraContext: (
|
|
@@ -99,30 +100,28 @@ export const Basic = {
|
|
|
99
100
|
</div>
|
|
100
101
|
) as React.ReactNode,
|
|
101
102
|
},
|
|
102
|
-
play: Default.play,
|
|
103
|
-
render: Default.render,
|
|
104
103
|
};
|
|
105
104
|
|
|
106
|
-
export const Mobile =
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
},
|
|
119
|
-
play: Default.play,
|
|
120
|
-
render: Default.render,
|
|
105
|
+
export const Mobile = {
|
|
106
|
+
...Default,
|
|
107
|
+
args: {
|
|
108
|
+
...Default.args,
|
|
109
|
+
extraContext: (
|
|
110
|
+
<div className="p-t-3">
|
|
111
|
+
<CheckboxOption
|
|
112
|
+
title="In mobile view, snackbar is full-width, not centered"
|
|
113
|
+
media={<MobileIcon />}
|
|
114
|
+
/>
|
|
115
|
+
</div>
|
|
116
|
+
) as React.ReactNode,
|
|
121
117
|
},
|
|
122
|
-
{
|
|
118
|
+
parameters: {
|
|
123
119
|
variants: ['mobile'],
|
|
120
|
+
chromatic: {
|
|
121
|
+
mobile: allModes.largeMobile,
|
|
122
|
+
},
|
|
124
123
|
},
|
|
125
|
-
|
|
124
|
+
};
|
|
126
125
|
|
|
127
126
|
const switchToDarkMode = async (context: { canvasElement: HTMLElement }) => {
|
|
128
127
|
await Default.play(context);
|
|
@@ -138,27 +137,28 @@ const switchToDarkMode = async (context: { canvasElement: HTMLElement }) => {
|
|
|
138
137
|
}
|
|
139
138
|
};
|
|
140
139
|
|
|
141
|
-
export const DarkMode =
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
},
|
|
155
|
-
play: switchToDarkMode,
|
|
156
|
-
render: Default.render,
|
|
140
|
+
export const DarkMode = {
|
|
141
|
+
...Default,
|
|
142
|
+
args: {
|
|
143
|
+
...Default.args,
|
|
144
|
+
extraContext: (
|
|
145
|
+
<div className="p-t-3">
|
|
146
|
+
<CheckboxOption title="In dark mode, snackbar has no drop shadow" media={<Theme />} />
|
|
147
|
+
<CheckboxOption
|
|
148
|
+
title="In dark mode, snackbar is inverted and has light background"
|
|
149
|
+
media={<Theme />}
|
|
150
|
+
/>
|
|
151
|
+
</div>
|
|
152
|
+
) as React.ReactNode,
|
|
157
153
|
},
|
|
158
|
-
|
|
154
|
+
play: switchToDarkMode,
|
|
155
|
+
parameters: {
|
|
159
156
|
variants: ['dark'],
|
|
157
|
+
chromatic: {
|
|
158
|
+
dark: allModes.dark,
|
|
159
|
+
},
|
|
160
160
|
},
|
|
161
|
-
|
|
161
|
+
};
|
|
162
162
|
|
|
163
163
|
const switchToRTL = async (context: { canvasElement: HTMLElement }) => {
|
|
164
164
|
await Default.play(context);
|
|
@@ -173,94 +173,97 @@ const switchToRTL = async (context: { canvasElement: HTMLElement }) => {
|
|
|
173
173
|
}
|
|
174
174
|
};
|
|
175
175
|
|
|
176
|
-
export const RTL =
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
},
|
|
211
|
-
play: switchToRTL,
|
|
212
|
-
render: Default.render,
|
|
176
|
+
export const RTL = {
|
|
177
|
+
...Default,
|
|
178
|
+
args: {
|
|
179
|
+
...Default.args,
|
|
180
|
+
extraContext: (
|
|
181
|
+
<div className="p-t-3">
|
|
182
|
+
<CheckboxOption
|
|
183
|
+
title="In RTL, snackbar is not left aligned"
|
|
184
|
+
content={
|
|
185
|
+
<a
|
|
186
|
+
href="https://transferwise.atlassian.net/browse/DS-4642"
|
|
187
|
+
target="_blank"
|
|
188
|
+
rel="noreferrer"
|
|
189
|
+
>
|
|
190
|
+
Bug DS-4642
|
|
191
|
+
</a>
|
|
192
|
+
}
|
|
193
|
+
media={<Switch />}
|
|
194
|
+
/>
|
|
195
|
+
<CheckboxOption
|
|
196
|
+
title="In RTL, snackbar has proper padding on left and right of button"
|
|
197
|
+
content={
|
|
198
|
+
<a
|
|
199
|
+
href="https://transferwise.atlassian.net/browse/DS-4643"
|
|
200
|
+
target="_blank"
|
|
201
|
+
rel="noreferrer"
|
|
202
|
+
>
|
|
203
|
+
Bug DS-4643
|
|
204
|
+
</a>
|
|
205
|
+
}
|
|
206
|
+
media={<Switch />}
|
|
207
|
+
/>
|
|
208
|
+
</div>
|
|
209
|
+
) as React.ReactNode,
|
|
213
210
|
},
|
|
214
|
-
|
|
211
|
+
play: switchToRTL,
|
|
212
|
+
parameters: {
|
|
215
213
|
variants: ['rtl'],
|
|
214
|
+
chromatic: {
|
|
215
|
+
rtl: allModes.rtl,
|
|
216
|
+
},
|
|
216
217
|
},
|
|
217
|
-
|
|
218
|
+
};
|
|
218
219
|
|
|
219
|
-
export const RTLMobile =
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
},
|
|
224
|
-
play: switchToRTL,
|
|
225
|
-
render: Default.render,
|
|
220
|
+
export const RTLMobile = {
|
|
221
|
+
...Default,
|
|
222
|
+
args: {
|
|
223
|
+
...RTL.args,
|
|
226
224
|
},
|
|
227
|
-
|
|
225
|
+
play: switchToRTL,
|
|
226
|
+
parameters: {
|
|
228
227
|
variants: ['rtl', 'mobile'],
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
export const Zoom400 = storyConfig(
|
|
233
|
-
{
|
|
234
|
-
args: {
|
|
235
|
-
...Default.args,
|
|
236
|
-
extraContext: (
|
|
237
|
-
<div className="p-t-3">
|
|
238
|
-
<CheckboxOption
|
|
239
|
-
content="Snackbar isn't transparent (I'm going to make this text very long so that it will fill up the entire page and go behind the snackbar. This way, when you look at it you will easily be able to tell if the snackbar is transparent and recognize the bug because we don't want it to be transparent. Transparent is bad. When we first did rebrand we had a lot of problems with transparencies. I don't know what happened to them. I don't see them a lot anymore but I also don't remember anybody fixing them.)"
|
|
240
|
-
title={
|
|
241
|
-
<a
|
|
242
|
-
href="https://transferwise.atlassian.net/browse/DS-3716"
|
|
243
|
-
target="_blank"
|
|
244
|
-
rel="noreferrer"
|
|
245
|
-
>
|
|
246
|
-
Bug DS-3716
|
|
247
|
-
</a>
|
|
248
|
-
}
|
|
249
|
-
media={<Coins />}
|
|
250
|
-
/>
|
|
251
|
-
</div>
|
|
252
|
-
),
|
|
228
|
+
chromatic: {
|
|
229
|
+
rtl: allModes.rtl,
|
|
230
|
+
mobile: allModes.largeMobile,
|
|
253
231
|
},
|
|
232
|
+
},
|
|
233
|
+
};
|
|
254
234
|
|
|
255
|
-
|
|
256
|
-
|
|
235
|
+
export const Zoom400 = {
|
|
236
|
+
...Default,
|
|
237
|
+
args: {
|
|
238
|
+
...Default.args,
|
|
239
|
+
extraContext: (
|
|
240
|
+
<div className="p-t-3">
|
|
241
|
+
<CheckboxOption
|
|
242
|
+
content="Snackbar isn't transparent (I'm going to make this text very long so that it will fill up the entire page and go behind the snackbar. This way, when you look at it you will easily be able to tell if the snackbar is transparent and recognize the bug because we don't want it to be transparent. Transparent is bad. When we first did rebrand we had a lot of problems with transparencies. I don't know what happened to them. I don't see them a lot anymore but I also don't remember anybody fixing them.)"
|
|
243
|
+
title={
|
|
244
|
+
<a
|
|
245
|
+
href="https://transferwise.atlassian.net/browse/DS-3716"
|
|
246
|
+
target="_blank"
|
|
247
|
+
rel="noreferrer"
|
|
248
|
+
>
|
|
249
|
+
Bug DS-3716
|
|
250
|
+
</a>
|
|
251
|
+
}
|
|
252
|
+
media={<Coins />}
|
|
253
|
+
/>
|
|
254
|
+
</div>
|
|
255
|
+
),
|
|
257
256
|
},
|
|
258
|
-
{
|
|
257
|
+
parameters: {
|
|
259
258
|
variants: ['400%'],
|
|
259
|
+
chromatic: {
|
|
260
|
+
zoom400: allModes.zoom400,
|
|
261
|
+
},
|
|
260
262
|
},
|
|
261
|
-
|
|
263
|
+
};
|
|
262
264
|
|
|
263
265
|
export const MultipleClicks = {
|
|
266
|
+
...Default,
|
|
264
267
|
args: {
|
|
265
268
|
...Default.args,
|
|
266
269
|
extraContext: (
|
|
@@ -278,5 +281,4 @@ export const MultipleClicks = {
|
|
|
278
281
|
await userEvent.click(canvas.getByRole('button'));
|
|
279
282
|
}
|
|
280
283
|
},
|
|
281
|
-
render: Default.render,
|
|
282
284
|
};
|
|
@@ -3,7 +3,7 @@ import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
|
3
3
|
import { Sentiment, Size, Status } from '../common';
|
|
4
4
|
|
|
5
5
|
import StatusIcon, { StatusIconSentiment } from './StatusIcon';
|
|
6
|
-
import {
|
|
6
|
+
import { allModes } from '../../.storybook/modes';
|
|
7
7
|
|
|
8
8
|
export default {
|
|
9
9
|
component: StatusIcon,
|
|
@@ -29,45 +29,48 @@ export const Presentational: Story = {
|
|
|
29
29
|
},
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
export const Variants =
|
|
33
|
-
{
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
export const Variants: Story = {
|
|
33
|
+
parameters: {
|
|
34
|
+
padding: '0',
|
|
35
|
+
variants: ['default', 'dark', 'bright-green', 'forest-green'],
|
|
36
|
+
chromatic: {
|
|
37
|
+
dark: allModes.dark,
|
|
38
|
+
brightGreen: allModes.brightGreen,
|
|
39
|
+
forestGreen: allModes.forestGreen,
|
|
36
40
|
},
|
|
37
|
-
render: () => (
|
|
38
|
-
<span style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '400px' }}>
|
|
39
|
-
{[
|
|
40
|
-
Sentiment.POSITIVE,
|
|
41
|
-
Sentiment.NEGATIVE,
|
|
42
|
-
Sentiment.WARNING,
|
|
43
|
-
Sentiment.NEUTRAL,
|
|
44
|
-
Sentiment.PENDING,
|
|
45
|
-
Status.PENDING,
|
|
46
|
-
].map((sentiment) => {
|
|
47
|
-
return (
|
|
48
|
-
<span
|
|
49
|
-
key={sentiment}
|
|
50
|
-
style={{
|
|
51
|
-
display: 'flex',
|
|
52
|
-
justifyContent: 'space-between',
|
|
53
|
-
flexDirection: 'column',
|
|
54
|
-
minHeight: '150px',
|
|
55
|
-
alignItems: 'center',
|
|
56
|
-
}}
|
|
57
|
-
>
|
|
58
|
-
{([16, 24, 32, 40, 48, 56, 72] as const).map((size) => {
|
|
59
|
-
return (
|
|
60
|
-
<StatusIcon key={size} size={size} sentiment={sentiment as StatusIconSentiment} />
|
|
61
|
-
);
|
|
62
|
-
})}
|
|
63
|
-
</span>
|
|
64
|
-
);
|
|
65
|
-
})}
|
|
66
|
-
</span>
|
|
67
|
-
),
|
|
68
41
|
},
|
|
69
|
-
|
|
70
|
-
|
|
42
|
+
render: () => (
|
|
43
|
+
<span style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '400px' }}>
|
|
44
|
+
{[
|
|
45
|
+
Sentiment.POSITIVE,
|
|
46
|
+
Sentiment.NEGATIVE,
|
|
47
|
+
Sentiment.WARNING,
|
|
48
|
+
Sentiment.NEUTRAL,
|
|
49
|
+
Sentiment.PENDING,
|
|
50
|
+
Status.PENDING,
|
|
51
|
+
].map((sentiment) => {
|
|
52
|
+
return (
|
|
53
|
+
<span
|
|
54
|
+
key={sentiment}
|
|
55
|
+
style={{
|
|
56
|
+
display: 'flex',
|
|
57
|
+
justifyContent: 'space-between',
|
|
58
|
+
flexDirection: 'column',
|
|
59
|
+
minHeight: '150px',
|
|
60
|
+
alignItems: 'center',
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
{([16, 24, 32, 40, 48, 56, 72] as const).map((size) => {
|
|
64
|
+
return (
|
|
65
|
+
<StatusIcon key={size} size={size} sentiment={sentiment as StatusIconSentiment} />
|
|
66
|
+
);
|
|
67
|
+
})}
|
|
68
|
+
</span>
|
|
69
|
+
);
|
|
70
|
+
})}
|
|
71
|
+
</span>
|
|
72
|
+
),
|
|
73
|
+
};
|
|
71
74
|
|
|
72
75
|
export const LegacySizes: Story = {
|
|
73
76
|
render: () => (
|
package/src/test-utils/index.tsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ReactElement, FC } from 'react';
|
|
2
2
|
import { render, renderHook } from '@testing-library/react';
|
|
3
|
-
import { renderToString } from 'react-dom/server';
|
|
4
3
|
import { userEvent } from '@testing-library/user-event';
|
|
5
4
|
|
|
6
5
|
import { Provider } from '..';
|
|
@@ -37,6 +36,5 @@ function customRenderHook(
|
|
|
37
36
|
|
|
38
37
|
export * from '@testing-library/react';
|
|
39
38
|
export * from './fake-data';
|
|
40
|
-
export * from './story-config';
|
|
41
39
|
export * from './window-mock';
|
|
42
40
|
export { customRender as render, customRenderHook as renderHook, userEvent };
|
|
@@ -2,9 +2,9 @@ import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
|
2
2
|
import { userEvent, within } from 'storybook/test';
|
|
3
3
|
|
|
4
4
|
import Button from '../button';
|
|
5
|
-
import { storyConfig } from '../test-utils';
|
|
6
5
|
|
|
7
6
|
import Tooltip from './Tooltip';
|
|
7
|
+
import { allModes } from '../../.storybook/modes';
|
|
8
8
|
|
|
9
9
|
export default {
|
|
10
10
|
component: Tooltip,
|
|
@@ -38,4 +38,12 @@ export const OpenedTooltip: Story = {
|
|
|
38
38
|
},
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
export const OpenedTooltipDark: Story =
|
|
41
|
+
export const OpenedTooltipDark: Story = {
|
|
42
|
+
...OpenedTooltip,
|
|
43
|
+
parameters: {
|
|
44
|
+
variants: ['dark'],
|
|
45
|
+
chromatic: {
|
|
46
|
+
dark: allModes.dark,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
@@ -122,6 +122,10 @@
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
&--prompt {
|
|
126
|
+
margin-top: var(--size-4);
|
|
127
|
+
}
|
|
128
|
+
|
|
125
129
|
// SIZES
|
|
126
130
|
&-sm {
|
|
127
131
|
&.typeahead--multiple {
|
|
@@ -207,7 +211,7 @@
|
|
|
207
211
|
}
|
|
208
212
|
|
|
209
213
|
.np-theme-personal & {
|
|
210
|
-
.input-group:not(.disabled
|
|
214
|
+
.input-group:not(.disabled, :disabled, .input-group--has-error):focus-within .tw-icon-search {
|
|
211
215
|
color: var(--color-interactive-primary);
|
|
212
216
|
}
|
|
213
217
|
.tw-icon-search {
|
|
@@ -102,7 +102,7 @@ describe('Typeahead', () => {
|
|
|
102
102
|
expect(onChange).toHaveBeenCalledWith([]);
|
|
103
103
|
});
|
|
104
104
|
|
|
105
|
-
it('shows
|
|
105
|
+
it('shows InlinePrompt when alert prop is provided', () => {
|
|
106
106
|
render(
|
|
107
107
|
<Typeahead
|
|
108
108
|
id="test"
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
2
|
import { Search as SearchIcon } from '@transferwise/icons';
|
|
3
3
|
import { userEvent, within, fn } from 'storybook/test';
|
|
4
|
-
|
|
5
|
-
import Typeahead, { type TypeaheadOption } from './Typeahead';
|
|
6
|
-
import { Size } from '../common';
|
|
7
4
|
import { useState } from 'react';
|
|
5
|
+
|
|
6
|
+
import { Sentiment, Size } from '../common';
|
|
8
7
|
import { Input } from '../inputs/Input';
|
|
9
8
|
import { Field } from '../field/Field';
|
|
10
9
|
import Button from '../button';
|
|
11
10
|
import Modal from '../modal';
|
|
11
|
+
import { InlinePromptProps } from '../prompt';
|
|
12
|
+
import Typeahead, { type TypeaheadOption } from './Typeahead';
|
|
12
13
|
|
|
14
|
+
// needed for SB to display correct name in the docs
|
|
15
|
+
(Typeahead as React.FC).displayName = 'Typeahead';
|
|
13
16
|
type Story = StoryObj<typeof Typeahead>;
|
|
14
17
|
|
|
15
18
|
/**
|
|
@@ -37,6 +40,7 @@ const meta: Meta<typeof Typeahead> = {
|
|
|
37
40
|
searchDelay: 200,
|
|
38
41
|
showSuggestions: true,
|
|
39
42
|
showNewEntry: true,
|
|
43
|
+
alert: undefined,
|
|
40
44
|
size: Size.MEDIUM,
|
|
41
45
|
initialValue: [],
|
|
42
46
|
id: 'myTypeahead',
|
|
@@ -54,6 +58,17 @@ const meta: Meta<typeof Typeahead> = {
|
|
|
54
58
|
control: 'inline-radio',
|
|
55
59
|
options: [Size.MEDIUM, Size.LARGE],
|
|
56
60
|
},
|
|
61
|
+
alert: {
|
|
62
|
+
description:
|
|
63
|
+
'Displays an [InlinePrompt](?path=/docs/prompts-inlineprompt--docs) below the input when provided. <blockquote class="m-0">**⚠️ DEPRECATED:** Please use [<Field />](?path=/docs/forms-field--docs) component and its `message` and `sentiment` props instead. `error`, `info` and `success` alert types are no longer supported and will be soon removed.</blockquote>',
|
|
64
|
+
control: 'object',
|
|
65
|
+
table: {
|
|
66
|
+
type: {
|
|
67
|
+
summary:
|
|
68
|
+
'{ message: ReactNode; type?: "negative" | "neutral" | "positive" | "warning" | "proposition" }',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
57
72
|
},
|
|
58
73
|
};
|
|
59
74
|
export default meta;
|
|
@@ -237,6 +252,14 @@ export const Search: Story = {
|
|
|
237
252
|
};
|
|
238
253
|
|
|
239
254
|
export const AutoFocusInModal: Story = {
|
|
255
|
+
parameters: {
|
|
256
|
+
docs: {
|
|
257
|
+
story: {
|
|
258
|
+
inline: false,
|
|
259
|
+
iframeHeight: 500,
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
},
|
|
240
263
|
render: function Render() {
|
|
241
264
|
const [open, setOpen] = useState<boolean>(true);
|
|
242
265
|
return (
|
|
@@ -279,3 +302,128 @@ export const AutoFocusInModal: Story = {
|
|
|
279
302
|
);
|
|
280
303
|
},
|
|
281
304
|
};
|
|
305
|
+
|
|
306
|
+
export const WithField: Story = {
|
|
307
|
+
args: {
|
|
308
|
+
autoFillOnBlur: undefined,
|
|
309
|
+
chipSeparators: undefined,
|
|
310
|
+
clearable: undefined,
|
|
311
|
+
initialValue: undefined,
|
|
312
|
+
inputAutoComplete: undefined,
|
|
313
|
+
minQueryLength: undefined,
|
|
314
|
+
onBlur: undefined,
|
|
315
|
+
onFocus: undefined,
|
|
316
|
+
onInputChange: undefined,
|
|
317
|
+
onSearch: undefined,
|
|
318
|
+
placeholder: undefined,
|
|
319
|
+
searchDelay: undefined,
|
|
320
|
+
showSuggestions: undefined,
|
|
321
|
+
showNewEntry: undefined,
|
|
322
|
+
size: undefined,
|
|
323
|
+
},
|
|
324
|
+
render: function Render(args) {
|
|
325
|
+
const options = [{ label: 'Option 1' }];
|
|
326
|
+
|
|
327
|
+
const alertTypes: InlinePromptProps['sentiment'][] = [
|
|
328
|
+
Sentiment.NEGATIVE,
|
|
329
|
+
Sentiment.WARNING,
|
|
330
|
+
Sentiment.NEUTRAL,
|
|
331
|
+
Sentiment.POSITIVE,
|
|
332
|
+
'proposition',
|
|
333
|
+
];
|
|
334
|
+
|
|
335
|
+
return (
|
|
336
|
+
<>
|
|
337
|
+
<Field
|
|
338
|
+
id="typeahead"
|
|
339
|
+
label="Field label"
|
|
340
|
+
description="Additional information about the field"
|
|
341
|
+
required
|
|
342
|
+
>
|
|
343
|
+
<Typeahead {...args} name="typeahead" options={options} />
|
|
344
|
+
</Field>
|
|
345
|
+
{alertTypes.map((sentiment) => (
|
|
346
|
+
<Field
|
|
347
|
+
key={sentiment}
|
|
348
|
+
label="Field label"
|
|
349
|
+
id={`typeahead-${sentiment}`}
|
|
350
|
+
message={`This is a ${sentiment} message`}
|
|
351
|
+
sentiment={sentiment}
|
|
352
|
+
>
|
|
353
|
+
<Typeahead {...args} name={`typeahead-${sentiment}`} options={options} />
|
|
354
|
+
</Field>
|
|
355
|
+
))}
|
|
356
|
+
</>
|
|
357
|
+
);
|
|
358
|
+
},
|
|
359
|
+
decorators: (Story) => (
|
|
360
|
+
<div className="d-flex flex-column">
|
|
361
|
+
<Story />
|
|
362
|
+
</div>
|
|
363
|
+
),
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* > **⚠️ DEPRECATED:** Please use [<Field />](?path=/docs/forms-field--docs) component and its `message` and `sentiment` props instead. <br/>`error`, `info` and `success` alert types are no longer supported and will be soon removed.
|
|
368
|
+
*/
|
|
369
|
+
export const WithAlert: Story = {
|
|
370
|
+
name: 'With Alert (deprecated)',
|
|
371
|
+
args: {
|
|
372
|
+
autoFillOnBlur: undefined,
|
|
373
|
+
chipSeparators: undefined,
|
|
374
|
+
clearable: undefined,
|
|
375
|
+
initialValue: undefined,
|
|
376
|
+
inputAutoComplete: undefined,
|
|
377
|
+
minQueryLength: undefined,
|
|
378
|
+
onBlur: undefined,
|
|
379
|
+
onFocus: undefined,
|
|
380
|
+
onInputChange: undefined,
|
|
381
|
+
onSearch: undefined,
|
|
382
|
+
placeholder: undefined,
|
|
383
|
+
searchDelay: undefined,
|
|
384
|
+
showSuggestions: undefined,
|
|
385
|
+
showNewEntry: undefined,
|
|
386
|
+
size: undefined,
|
|
387
|
+
},
|
|
388
|
+
parameters: {
|
|
389
|
+
docs: {
|
|
390
|
+
canvas: {
|
|
391
|
+
sourceState: 'hidden',
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
|
+
},
|
|
395
|
+
render: function Render(args) {
|
|
396
|
+
const options = [{ label: 'Option 1' }];
|
|
397
|
+
|
|
398
|
+
const alertTypes: InlinePromptProps['sentiment'][] = [
|
|
399
|
+
Sentiment.NEGATIVE,
|
|
400
|
+
Sentiment.WARNING,
|
|
401
|
+
Sentiment.NEUTRAL,
|
|
402
|
+
Sentiment.POSITIVE,
|
|
403
|
+
'proposition',
|
|
404
|
+
];
|
|
405
|
+
|
|
406
|
+
return (
|
|
407
|
+
<>
|
|
408
|
+
{alertTypes.map((sentiment) => (
|
|
409
|
+
<Typeahead
|
|
410
|
+
key={sentiment}
|
|
411
|
+
{...args}
|
|
412
|
+
id={`typeahead-${sentiment}`}
|
|
413
|
+
name={`typeahead-${sentiment}`}
|
|
414
|
+
options={options}
|
|
415
|
+
alert={{
|
|
416
|
+
message: `This is a ${sentiment} message`,
|
|
417
|
+
type: sentiment,
|
|
418
|
+
}}
|
|
419
|
+
/>
|
|
420
|
+
))}
|
|
421
|
+
</>
|
|
422
|
+
);
|
|
423
|
+
},
|
|
424
|
+
decorators: (Story) => (
|
|
425
|
+
<div className="d-flex flex-column">
|
|
426
|
+
<Story />
|
|
427
|
+
</div>
|
|
428
|
+
),
|
|
429
|
+
};
|