@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
package/src/main.css
CHANGED
|
@@ -949,6 +949,9 @@
|
|
|
949
949
|
.wds-inline-prompt:has(button):active {
|
|
950
950
|
background-color: var(--color-sentiment-background-surface-active);
|
|
951
951
|
}
|
|
952
|
+
.wds-inline-prompt--full-width {
|
|
953
|
+
width: 100%;
|
|
954
|
+
}
|
|
952
955
|
.wds-inline-prompt--muted {
|
|
953
956
|
opacity: 0.93;
|
|
954
957
|
filter: grayscale(1);
|
|
@@ -3822,10 +3825,19 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
|
|
|
3822
3825
|
stroke-dasharray: calc(12px * 0.5) calc(12px * 0.5);
|
|
3823
3826
|
stroke-dasharray: var(--wds-list-item-spotlight-strokeDashSize) var(--wds-list-item-spotlight-strokeDashSize);
|
|
3824
3827
|
}
|
|
3825
|
-
.np-field-control
|
|
3828
|
+
.np-field-control,
|
|
3829
|
+
.np-field__prompt {
|
|
3826
3830
|
margin-top: 4px;
|
|
3827
3831
|
margin-top: var(--size-4);
|
|
3828
3832
|
}
|
|
3833
|
+
.np-field .form-group--typeahead[class],
|
|
3834
|
+
.np-field .np-checkbox-label[class] {
|
|
3835
|
+
margin-bottom: 0;
|
|
3836
|
+
}
|
|
3837
|
+
.np-field:has(.wds-radio-group) .np-field__prompt {
|
|
3838
|
+
margin-top: 12px;
|
|
3839
|
+
margin-top: var(--size-12);
|
|
3840
|
+
}
|
|
3829
3841
|
.np-input-group {
|
|
3830
3842
|
display: inline-grid;
|
|
3831
3843
|
width: 100%;
|
|
@@ -5394,6 +5406,9 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
5394
5406
|
.np-CardGroup .np-Card.np-Card--promoCard {
|
|
5395
5407
|
max-width: 100%;
|
|
5396
5408
|
}
|
|
5409
|
+
.wds-radio-group .np-radio:last-child label {
|
|
5410
|
+
margin-bottom: 0;
|
|
5411
|
+
}
|
|
5397
5412
|
.np-section {
|
|
5398
5413
|
margin-top: 32px;
|
|
5399
5414
|
margin-top: var(--size-32);
|
|
@@ -6920,6 +6935,10 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
6920
6935
|
padding: 0;
|
|
6921
6936
|
margin: 0;
|
|
6922
6937
|
}
|
|
6938
|
+
.typeahead--prompt {
|
|
6939
|
+
margin-top: 4px;
|
|
6940
|
+
margin-top: var(--size-4);
|
|
6941
|
+
}
|
|
6923
6942
|
.typeahead-sm.typeahead--multiple .typeahead__input-container {
|
|
6924
6943
|
min-height: 32px;
|
|
6925
6944
|
}
|
package/src/main.less
CHANGED
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
@import "./phoneNumberInput/PhoneNumberInput.less";
|
|
62
62
|
@import "./popover/Popover.less";
|
|
63
63
|
@import "./promoCard/PromoCard.less";
|
|
64
|
+
@import "./radioGroup/RadioGroup.less";
|
|
64
65
|
@import "./section/Section.less";
|
|
65
66
|
@import "./slidingPanel/SlidingPanel.less";
|
|
66
67
|
@import "./snackbar/Snackbar.less";
|
|
@@ -5,7 +5,8 @@ import { useState } from 'react';
|
|
|
5
5
|
|
|
6
6
|
import { Button, Modal, ModalProps } from '..';
|
|
7
7
|
import { CommonProps, Scroll } from '../common';
|
|
8
|
-
import { lorem10, lorem100, lorem1000
|
|
8
|
+
import { lorem10, lorem100, lorem1000 } from '../test-utils';
|
|
9
|
+
import { allModes } from '../../.storybook/modes';
|
|
9
10
|
|
|
10
11
|
export default {
|
|
11
12
|
component: Modal,
|
|
@@ -75,7 +76,15 @@ export const Basic: Story = {
|
|
|
75
76
|
render: (args, context) => <StoryContent args={args} viewMode={context.viewMode} />,
|
|
76
77
|
};
|
|
77
78
|
|
|
78
|
-
export const BasicMobile: Story =
|
|
79
|
+
export const BasicMobile: Story = {
|
|
80
|
+
...Basic,
|
|
81
|
+
parameters: {
|
|
82
|
+
variants: ['mobile'],
|
|
83
|
+
chromatic: {
|
|
84
|
+
mobile: allModes.largeMobile,
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
};
|
|
79
88
|
|
|
80
89
|
export const ContentScroll: Story = {
|
|
81
90
|
args: {
|
|
@@ -86,7 +95,15 @@ export const ContentScroll: Story = {
|
|
|
86
95
|
render: (args, context) => <StoryContent args={args} viewMode={context.viewMode} />,
|
|
87
96
|
};
|
|
88
97
|
|
|
89
|
-
export const ContentScrollMobile: Story =
|
|
98
|
+
export const ContentScrollMobile: Story = {
|
|
99
|
+
...ContentScroll,
|
|
100
|
+
parameters: {
|
|
101
|
+
variants: ['mobile'],
|
|
102
|
+
chromatic: {
|
|
103
|
+
mobile: allModes.largeMobile,
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
};
|
|
90
107
|
|
|
91
108
|
export const ViewportScroll: Story = {
|
|
92
109
|
args: {
|
|
@@ -97,7 +114,15 @@ export const ViewportScroll: Story = {
|
|
|
97
114
|
render: (args, context) => <StoryContent args={args} viewMode={context.viewMode} />,
|
|
98
115
|
};
|
|
99
116
|
|
|
100
|
-
export const ViewportScrollMobile: Story =
|
|
117
|
+
export const ViewportScrollMobile: Story = {
|
|
118
|
+
...ViewportScroll,
|
|
119
|
+
parameters: {
|
|
120
|
+
variants: ['mobile'],
|
|
121
|
+
chromatic: {
|
|
122
|
+
mobile: allModes.largeMobile,
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
};
|
|
101
126
|
|
|
102
127
|
export const WithoutTitle: Story = {
|
|
103
128
|
args: {
|
|
@@ -107,7 +132,15 @@ export const WithoutTitle: Story = {
|
|
|
107
132
|
render: (args, context) => <StoryContent args={args} viewMode={context.viewMode} />,
|
|
108
133
|
};
|
|
109
134
|
|
|
110
|
-
export const WithoutTitleMobile: Story =
|
|
135
|
+
export const WithoutTitleMobile: Story = {
|
|
136
|
+
...WithoutTitle,
|
|
137
|
+
parameters: {
|
|
138
|
+
variants: ['mobile'],
|
|
139
|
+
chromatic: {
|
|
140
|
+
mobile: allModes.largeMobile,
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
};
|
|
111
144
|
|
|
112
145
|
export const WithThemeProviderInContent: Story = {
|
|
113
146
|
args: {
|
|
@@ -126,6 +159,12 @@ export const WithThemeProviderInContent: Story = {
|
|
|
126
159
|
),
|
|
127
160
|
};
|
|
128
161
|
|
|
129
|
-
export const WithThemeProviderInContentMobile: Story =
|
|
130
|
-
|
|
131
|
-
|
|
162
|
+
export const WithThemeProviderInContentMobile: Story = {
|
|
163
|
+
...WithThemeProviderInContent,
|
|
164
|
+
parameters: {
|
|
165
|
+
variants: ['mobile'],
|
|
166
|
+
chromatic: {
|
|
167
|
+
mobile: allModes.largeMobile,
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
};
|
|
@@ -191,14 +191,14 @@ export const SmallInput: Story = {
|
|
|
191
191
|
};
|
|
192
192
|
|
|
193
193
|
export const MediumInput: Story = {
|
|
194
|
-
|
|
194
|
+
...SmallInput,
|
|
195
195
|
args: {
|
|
196
196
|
size: 'md',
|
|
197
197
|
},
|
|
198
198
|
};
|
|
199
199
|
|
|
200
200
|
export const LargeInput: Story = {
|
|
201
|
-
|
|
201
|
+
...SmallInput,
|
|
202
202
|
args: {
|
|
203
203
|
size: 'lg',
|
|
204
204
|
},
|
|
@@ -23,6 +23,10 @@
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
&--full-width {
|
|
27
|
+
width: 100%;
|
|
28
|
+
}
|
|
29
|
+
|
|
26
30
|
&--muted {
|
|
27
31
|
opacity: 0.93;
|
|
28
32
|
filter: grayscale(1);
|
|
@@ -69,6 +73,6 @@
|
|
|
69
73
|
// styles in the CSS package, so keeping it colocated for now.
|
|
70
74
|
.process-circle {
|
|
71
75
|
stroke: currentColor;
|
|
72
|
-
}
|
|
76
|
+
}
|
|
73
77
|
}
|
|
74
78
|
}
|
|
@@ -155,4 +155,21 @@ describe('InlinePrompt', () => {
|
|
|
155
155
|
expect(el).toHaveClass('wds-sentiment-surface');
|
|
156
156
|
});
|
|
157
157
|
});
|
|
158
|
+
|
|
159
|
+
describe('width', () => {
|
|
160
|
+
it('defaults to auto width (no full-width class)', () => {
|
|
161
|
+
render(<InlinePrompt {...defaultProps} data-testid="prompt" />);
|
|
162
|
+
expect(screen.getByTestId('prompt')).not.toHaveClass('wds-inline-prompt--full-width');
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('applies auto width (no full-width class) when explicitly set', () => {
|
|
166
|
+
render(<InlinePrompt {...defaultProps} width="auto" data-testid="prompt" />);
|
|
167
|
+
expect(screen.getByTestId('prompt')).not.toHaveClass('wds-inline-prompt--full-width');
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('applies full width class when set to full', () => {
|
|
171
|
+
render(<InlinePrompt {...defaultProps} width="full" data-testid="prompt" />);
|
|
172
|
+
expect(screen.getByTestId('prompt')).toHaveClass('wds-inline-prompt--full-width');
|
|
173
|
+
});
|
|
174
|
+
});
|
|
158
175
|
});
|
|
@@ -14,6 +14,9 @@ const withComponentGrid =
|
|
|
14
14
|
width: '100%',
|
|
15
15
|
display: 'flex',
|
|
16
16
|
flexDirection: 'column',
|
|
17
|
+
justifyContent: 'flex-start',
|
|
18
|
+
alignItems: 'flex-start',
|
|
19
|
+
alignContent: 'flex-start',
|
|
17
20
|
gap,
|
|
18
21
|
maxWidth,
|
|
19
22
|
}}
|
|
@@ -26,6 +29,7 @@ export default {
|
|
|
26
29
|
title: 'Prompts/InlinePrompt',
|
|
27
30
|
component: InlinePrompt,
|
|
28
31
|
tags: ['new'],
|
|
32
|
+
decorators: [withComponentGrid()],
|
|
29
33
|
args: {
|
|
30
34
|
loading: false,
|
|
31
35
|
muted: false,
|
|
@@ -243,6 +247,37 @@ export const IconOverrides: StoryObj<PreviewStoryArgs> = {
|
|
|
243
247
|
decorators: [withComponentGrid()],
|
|
244
248
|
};
|
|
245
249
|
|
|
250
|
+
/**
|
|
251
|
+
* `InlinePrompt` can either hug its content or take the full width of its container,
|
|
252
|
+
* depending on the `width` prop.
|
|
253
|
+
* Components like `ListItem`, `ExpressiveMoneyInput` or similar will often set it to
|
|
254
|
+
* `auto`, while plain inputs will prefer `full` to visually match their boundaries.
|
|
255
|
+
*
|
|
256
|
+
* **NB**: `InlinePrompt` in its default – `auto` – width will expand to the full width of its container when the content spans across multiple lines.
|
|
257
|
+
*/
|
|
258
|
+
export const SizingStrategies: StoryObj<PreviewStoryArgs> = {
|
|
259
|
+
render: (args: PreviewStoryArgs) => {
|
|
260
|
+
return (
|
|
261
|
+
<>
|
|
262
|
+
<InlinePrompt {...args} media={<Travel />} sentiment="positive" width="full">
|
|
263
|
+
This prompt will take the full width of its container.
|
|
264
|
+
</InlinePrompt>
|
|
265
|
+
<InlinePrompt {...args} media={<Travel />} sentiment="positive">
|
|
266
|
+
This prompt will hug its content.
|
|
267
|
+
</InlinePrompt>
|
|
268
|
+
<InlinePrompt {...args} media={<Travel />} sentiment="positive">
|
|
269
|
+
This prompt is configured to hug its content, but since the content is long enough to span
|
|
270
|
+
across multiple lines, it will expand to the full width of its container. And no, you
|
|
271
|
+
should not put pages of text here in the first place, but we recognise that some
|
|
272
|
+
translations are longer than others, and people also use accessibility features that
|
|
273
|
+
increase font size.
|
|
274
|
+
</InlinePrompt>
|
|
275
|
+
</>
|
|
276
|
+
);
|
|
277
|
+
},
|
|
278
|
+
decorators: [withComponentGrid()],
|
|
279
|
+
};
|
|
280
|
+
|
|
246
281
|
/**
|
|
247
282
|
* When configured with any of the supported sentiments, the colour scheme of the component will propagate to all of its supported descendants, such as instances of a `Link`, `Icon`, and `StatusIcon`.
|
|
248
283
|
*/
|
|
@@ -33,6 +33,11 @@ export type InlinePromptProps = {
|
|
|
33
33
|
* To be used primarily for `proposition` sentiment.
|
|
34
34
|
*/
|
|
35
35
|
mediaLabel?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Defines the sizing strategy of the prompt component - either hugging the content or taking full width of the container.
|
|
38
|
+
* @default auto
|
|
39
|
+
*/
|
|
40
|
+
width?: 'auto' | 'full';
|
|
36
41
|
id?: string;
|
|
37
42
|
className?: string;
|
|
38
43
|
'data-testid'?: string;
|
|
@@ -53,6 +58,7 @@ export const InlinePrompt = ({
|
|
|
53
58
|
children,
|
|
54
59
|
media = null,
|
|
55
60
|
mediaLabel,
|
|
61
|
+
width = 'auto',
|
|
56
62
|
'data-testid': dataTestId,
|
|
57
63
|
...rest
|
|
58
64
|
}: InlinePromptProps) => {
|
|
@@ -91,6 +97,7 @@ export const InlinePrompt = ({
|
|
|
91
97
|
'wds-inline-prompt',
|
|
92
98
|
`wds-inline-prompt--${sentiment}`,
|
|
93
99
|
{
|
|
100
|
+
'wds-inline-prompt--full-width': width === 'full',
|
|
94
101
|
'wds-inline-prompt--muted': muted,
|
|
95
102
|
'wds-inline-prompt--loading': loading,
|
|
96
103
|
},
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import RadioGroup, { RadioGroupProps } from './RadioGroup';
|
|
2
|
+
import { Field } from '../field/Field';
|
|
3
|
+
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
4
|
+
import { fn } from 'storybook/test';
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
component: RadioGroup,
|
|
8
|
+
title: 'Forms/RadioGroup/tests',
|
|
9
|
+
tags: ['!autodocs'],
|
|
10
|
+
args: {
|
|
11
|
+
selectedValue: 'radio-2',
|
|
12
|
+
name: 'radio-group',
|
|
13
|
+
radios: [
|
|
14
|
+
{
|
|
15
|
+
value: 'radio-1',
|
|
16
|
+
label: 'Radio1',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
value: 'radio-2',
|
|
20
|
+
label: 'Radio2',
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
onChange: fn(),
|
|
24
|
+
},
|
|
25
|
+
} satisfies Meta<typeof RadioGroup>;
|
|
26
|
+
|
|
27
|
+
export default meta;
|
|
28
|
+
type Story<T extends string | number = string> = StoryObj<RadioGroupProps<T>>;
|
|
29
|
+
|
|
30
|
+
export const FieldsWithPrompt = {
|
|
31
|
+
render: function Render(args) {
|
|
32
|
+
return (
|
|
33
|
+
<>
|
|
34
|
+
{['i1', 'i2'].map((id) => (
|
|
35
|
+
<Field
|
|
36
|
+
key={id}
|
|
37
|
+
label="Field label"
|
|
38
|
+
description="Field description"
|
|
39
|
+
message="Something went great"
|
|
40
|
+
sentiment="positive"
|
|
41
|
+
>
|
|
42
|
+
<RadioGroup {...args} selectedValue="radio-2" />
|
|
43
|
+
</Field>
|
|
44
|
+
))}
|
|
45
|
+
</>
|
|
46
|
+
);
|
|
47
|
+
},
|
|
48
|
+
} satisfies Story;
|
|
49
|
+
|
|
50
|
+
export const FieldsWithoutPrompt = {
|
|
51
|
+
render: function Render(args) {
|
|
52
|
+
return (
|
|
53
|
+
<>
|
|
54
|
+
{['i1', 'i2'].map((id) => (
|
|
55
|
+
<Field key={id} label="Field label" sentiment="positive">
|
|
56
|
+
<RadioGroup {...args} selectedValue="radio-2" />
|
|
57
|
+
</Field>
|
|
58
|
+
))}
|
|
59
|
+
</>
|
|
60
|
+
);
|
|
61
|
+
},
|
|
62
|
+
} satisfies Story;
|
|
@@ -29,7 +29,12 @@ export default function RadioGroup<T extends string | number = never>({
|
|
|
29
29
|
const [uncontrolledValue, setUncontrolledValue] = useState(controlledValue);
|
|
30
30
|
|
|
31
31
|
return radios.length > 0 ? (
|
|
32
|
-
<div
|
|
32
|
+
<div
|
|
33
|
+
role="radiogroup"
|
|
34
|
+
{...inputAttributes}
|
|
35
|
+
{...UNSAFE_inputAttributes}
|
|
36
|
+
className="wds-radio-group"
|
|
37
|
+
>
|
|
33
38
|
{radios.map(({ value = '' as T, ...restProps }, index) => (
|
|
34
39
|
<Radio
|
|
35
40
|
// eslint-disable-next-line react/no-array-index-key
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StoryFn } from '@storybook/react-webpack5';
|
|
1
|
+
import { StoryFn, StoryObj } from '@storybook/react-webpack5';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
4
|
import Button from '../button';
|
|
@@ -10,83 +10,87 @@ export default {
|
|
|
10
10
|
title: 'Forms/SegmentedControl',
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
const [segments, setSegments] = React.useState([
|
|
15
|
-
{ id: 'CUPCAKE', label: 'Cupcakes', value: 'cupcakes' },
|
|
16
|
-
{ id: 'SPONGECAKE', label: 'Sponge cake', value: 'spongecake' },
|
|
17
|
-
{ id: 'CARROT_CAKE', label: 'Carrot cake', value: 'carrotcake' },
|
|
18
|
-
]);
|
|
13
|
+
type Story = StoryObj<typeof SegmentedControl>;
|
|
19
14
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
const Template: Story = {
|
|
16
|
+
render: (args) => {
|
|
17
|
+
const [segments, setSegments] = React.useState([
|
|
18
|
+
{ id: 'CUPCAKE', label: 'Cupcakes', value: 'cupcakes' },
|
|
19
|
+
{ id: 'SPONGECAKE', label: 'Sponge cake', value: 'spongecake' },
|
|
20
|
+
{ id: 'CARROT_CAKE', label: 'Carrot cake', value: 'carrotcake' },
|
|
21
|
+
]);
|
|
25
22
|
|
|
26
|
-
|
|
23
|
+
const [segmentsWithControls, setSegmentsWithControls] = React.useState([
|
|
24
|
+
{ id: 'CUPCAKE', label: 'Cupcakes', value: 'cupcakes', controls: 'aControlId' },
|
|
25
|
+
{ id: 'SPONGECAKE', label: 'Sponge cake', value: 'spongecake', controls: 'aControlId' },
|
|
26
|
+
{ id: 'CARROT_CAKE', label: 'Carrot cake', value: 'carrotcake', controls: 'aControlId' },
|
|
27
|
+
]);
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
29
|
+
const [value, setValue] = React.useState(segments[0].value);
|
|
30
|
+
|
|
31
|
+
console.log('render: segments.length', segments.length);
|
|
32
|
+
return (
|
|
33
|
+
<div className="p-a-2">
|
|
34
|
+
<SegmentedControl
|
|
35
|
+
name="aSegmentedControl"
|
|
36
|
+
value={value}
|
|
37
|
+
onChange={setValue}
|
|
38
|
+
{...(args.mode === 'view'
|
|
39
|
+
? { segments: segmentsWithControls, mode: 'view', controls: 'aControlId' }
|
|
40
|
+
: { segments, mode: 'input' })}
|
|
41
|
+
/>
|
|
42
|
+
<div className="m-a-2" id="aControlId">
|
|
43
|
+
<p>Selected value: {value}</p>
|
|
44
|
+
</div>
|
|
45
|
+
<div className="m-a-2">
|
|
46
|
+
<p>
|
|
47
|
+
Force the <b>selectedValue</b> to be one of the following:
|
|
48
|
+
<ul>
|
|
49
|
+
{segments.map((segment) => (
|
|
50
|
+
<li key={segment.id}>
|
|
51
|
+
<a
|
|
52
|
+
href="/"
|
|
53
|
+
onClick={(e) => {
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
setValue(segment.value);
|
|
56
|
+
}}
|
|
57
|
+
>
|
|
58
|
+
{segment.label}
|
|
59
|
+
</a>
|
|
60
|
+
</li>
|
|
61
|
+
))}
|
|
62
|
+
</ul>
|
|
63
|
+
</p>
|
|
64
|
+
</div>
|
|
65
|
+
<div className="m-a-2">
|
|
66
|
+
<Button
|
|
67
|
+
priority="secondary"
|
|
68
|
+
type="danger"
|
|
69
|
+
size="sm"
|
|
70
|
+
disabled={segments.length < 2}
|
|
71
|
+
onClick={() => {
|
|
72
|
+
const index = segments.findIndex((s) => s.value !== value);
|
|
73
|
+
setSegments((prev) => prev.filter((_, i) => i !== index));
|
|
74
|
+
setSegmentsWithControls((prev) => prev.filter((_, i) => i !== index));
|
|
75
|
+
}}
|
|
76
|
+
>
|
|
77
|
+
Remove one segment
|
|
78
|
+
</Button>
|
|
79
|
+
</div>
|
|
76
80
|
</div>
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
);
|
|
82
|
+
},
|
|
79
83
|
};
|
|
80
84
|
|
|
81
|
-
export const SegmentedControlDefault = {
|
|
82
|
-
|
|
85
|
+
export const SegmentedControlDefault: Story = {
|
|
86
|
+
...Template,
|
|
83
87
|
args: {
|
|
84
88
|
mode: 'input',
|
|
85
89
|
},
|
|
86
90
|
};
|
|
87
91
|
|
|
88
|
-
export const SegmentedControlView = {
|
|
89
|
-
|
|
92
|
+
export const SegmentedControlView: Story = {
|
|
93
|
+
...Template,
|
|
90
94
|
args: {
|
|
91
95
|
mode: 'view',
|
|
92
96
|
},
|