@transferwise/components 46.100.1 → 46.100.2
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/avatarLayout/AvatarLayout.js +1 -1
- package/build/avatarLayout/AvatarLayout.js.map +1 -1
- package/build/avatarLayout/AvatarLayout.mjs +1 -1
- package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
- package/build/dateLookup/DateLookup.js +3 -2
- package/build/dateLookup/DateLookup.js.map +1 -1
- package/build/dateLookup/DateLookup.mjs +3 -2
- package/build/dateLookup/DateLookup.mjs.map +1 -1
- package/build/main.css +4 -94
- package/build/styles/accordion/Accordion.css +27 -16
- package/build/styles/avatar/Avatar.css +95 -50
- package/build/styles/inputs/Input.css +37 -21
- package/build/styles/inputs/TextArea.css +35 -20
- package/build/styles/loader/Loader.css +4 -90
- package/build/styles/main.css +4 -94
- package/build/styles/popover/Popover.css +19 -12
- package/build/styles/select/Select.css +131 -68
- package/build/styles/switch/Switch.css +27 -16
- package/build/styles/tile/Tile.css +31 -18
- package/build/types/dateLookup/DateLookup.d.ts +2 -2
- package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
- package/build/types/test-utils/story-config.d.ts +2 -3
- package/build/types/test-utils/story-config.d.ts.map +1 -1
- package/package.json +20 -28
- package/src/accordion/Accordion.css +27 -16
- package/src/accordion/Accordion.story.tsx +1 -1
- package/src/actionButton/ActionButton.story.tsx +3 -2
- package/src/actionOption/ActionOption.story.tsx +2 -2
- package/src/alert/Alert.story.tsx +2 -2
- package/src/alert/Alert.tests.story.tsx +2 -2
- package/src/avatar/Avatar.css +95 -50
- package/src/avatar/Avatar.spec.tsx +1 -1
- package/src/avatar/Avatar.story.tsx +3 -2
- package/src/avatarLayout/AvatarLayout.story.tsx +1 -1
- package/src/avatarLayout/AvatarLayout.tsx +1 -1
- package/src/avatarView/AvatarView.story.tsx +1 -1
- package/src/avatarWrapper/AvatarWrapper.story.tsx +3 -2
- package/src/badge/Badge.story.tsx +49 -28
- package/src/button/Button.accessibility.docs.mdx +1 -1
- package/src/button/Button.story.tsx +2 -2
- package/src/button/Button.tests.story.tsx +2 -2
- package/src/button/LegacyButton.story.tsx +3 -2
- package/src/card/Card.story.tsx +2 -2
- package/src/carousel/Carousel.story.tsx +1 -1
- package/src/checkbox/Checkbox.story.tsx +2 -2
- package/src/checkboxButton/CheckboxButton.story.tsx +2 -2
- package/src/checkboxOption/CheckboxOption.story.tsx +35 -29
- package/src/chevron/Chevron.story.tsx +1 -1
- package/src/chips/Chips.story.tsx +1 -1
- package/src/circularButton/CircularButton.story.tsx +1 -1
- package/src/circularButton/CircularButton.tests.story.tsx +1 -1
- package/src/common/bottomSheet/BottomSheet.story.tsx +2 -2
- package/src/common/card/Card.story.tsx +1 -1
- package/src/common/circle/Circle.story.tsx +2 -2
- package/src/common/locale/index.spec.ts +28 -16
- package/src/common/responsivePanel/ResponsivePanel.spec.js +8 -29
- package/src/criticalBanner/CriticalCommsBanner.story.tsx +1 -1
- package/src/dateInput/DateInput.story.tsx +2 -2
- package/src/dateInput/DateInput.tests.story.tsx +2 -2
- package/src/dateLookup/DateLookup.spec.tsx +5 -5
- package/src/dateLookup/DateLookup.story.tsx +43 -71
- package/src/dateLookup/DateLookup.tests.story.tsx +3 -3
- package/src/dateLookup/DateLookup.tsx +4 -1
- package/src/decision/Decision.story.tsx +24 -49
- package/src/definitionList/DefinitionList.story.tsx +1 -1
- package/src/dimmer/Dimmer.story.tsx +2 -2
- package/src/divider/Divider.accessibility.docs.mdx +1 -1
- package/src/divider/Divider.story.tsx +1 -1
- package/src/drawer/Drawer.story.tsx +13 -7
- package/src/dropFade/DropFade.story.tsx +1 -1
- package/src/emphasis/Emphasis.spec.tsx +8 -8
- package/src/emphasis/Emphasis.story.tsx +1 -1
- package/src/field/Field.story.tsx +3 -3
- package/src/flowNavigation/FlowNavigation.story.tsx +305 -260
- package/src/iconButton/IconButton.story.tsx +2 -2
- package/src/image/Image.story.tsx +27 -54
- package/src/info/Info.story.tsx +2 -2
- package/src/inlineAlert/InlineAlert.story.tsx +1 -1
- package/src/inputWithDisplayFormat/InputWithDisplayFormat.story.tsx +2 -2
- package/src/inputs/Input.css +37 -21
- package/src/inputs/InputGroup.story.tsx +1 -1
- package/src/inputs/SearchInput.story.tsx +1 -1
- package/src/inputs/SelectInput.docs.mdx +1 -1
- package/src/inputs/SelectInput.story.tsx +2 -2
- package/src/inputs/TextArea.css +35 -20
- package/src/instructionsList/InstructionsList.story.tsx +2 -2
- package/src/legacylistItem/LegacyListItem.story.tsx +1 -1
- package/src/loader/Loader.css +4 -90
- package/src/loader/Loader.story.tsx +1 -1
- package/src/logo/Logo.story.tsx +1 -1
- package/src/main.css +4 -94
- package/src/markdown/Markdown.story.tsx +1 -1
- package/src/modal/Modal.story.tsx +2 -2
- package/src/money/Money.story.tsx +1 -1
- package/src/moneyInput/MoneyInput.docs.mdx +1 -1
- package/src/moneyInput/MoneyInput.spec.tsx +8 -5
- package/src/moneyInput/MoneyInput.story.tsx +2 -2
- package/src/moneyInput/currencyFormatting.spec.ts +1 -1
- package/src/navigationOption/NavigationOption.story.tsx +265 -226
- package/src/nudge/Nudge.story.tsx +1 -1
- package/src/overlayHeader/OverlayHeader.story.tsx +32 -24
- package/src/phoneNumberInput/PhoneNumberInput.story.tsx +1 -1
- package/src/phoneNumberInput/utils/setDefaultPrefix/setDefaultPrefix.spec.ts +6 -3
- package/src/popover/Popover.css +19 -12
- package/src/popover/Popover.story.tsx +2 -2
- package/src/primitives/PrimitiveAnchor/stories/PrimitiveAnchor.story.tsx +2 -2
- package/src/primitives/PrimitiveAnchor/stories/PrimitiveAnchor.tests.story.tsx +2 -2
- package/src/primitives/PrimitiveButton/stories/PrimitiveButton.story.tsx +2 -2
- package/src/primitives/PrimitiveButton/stories/PrimitiveButton.tests.story.tsx +2 -2
- package/src/processIndicator/ProcessIndicator.story.tsx +1 -1
- package/src/progress/Progress.story.tsx +1 -1
- package/src/progressBar/ProgressBar.story.tsx +1 -1
- package/src/promoCard/PromoCard.story.tsx +1 -1
- package/src/promoCard/PromoCardGroup.story.tsx +1 -1
- package/src/provider/Provider.spec.tsx +2 -2
- package/src/provider/Provider.story.tsx +1 -1
- package/src/provider/direction/DirectionProvider.spec.tsx +1 -1
- package/src/provider/language/LanguageProvider.spec.tsx +1 -1
- package/src/provider/theme/ThemeProvider.story.tsx +1 -1
- package/src/radio/Radio.story.tsx +59 -42
- package/src/radioGroup/RadioGroup.story.tsx +2 -2
- package/src/radioOption/RadioOption.story.tsx +73 -38
- package/src/segmentedControl/SegmentedControl.story.tsx +1 -1
- package/src/select/Select.css +131 -68
- package/src/select/Select.story.tsx +385 -397
- package/src/slidingPanel/SlidingPanel.story.tsx +30 -13
- package/src/snackbar/Snackbar.story.tsx +50 -36
- package/src/snackbar/Snackbar.tests.story.tsx +3 -2
- package/src/statusIcon/StatusIcon.docs.mdx +1 -1
- package/src/statusIcon/StatusIcon.spec.tsx +8 -5
- package/src/statusIcon/StatusIcon.story.tsx +1 -1
- package/src/stepper/Stepper.story.tsx +2 -2
- package/src/stepper/Stepper.tests.story.tsx +2 -2
- package/src/sticky/Sticky.story.tsx +1 -1
- package/src/summary/Summary.story.tsx +18 -17
- package/src/switch/Switch.css +27 -16
- package/src/switch/Switch.story.tsx +2 -2
- package/src/switchOption/SwitchOption.story.tsx +1 -1
- package/src/table/Table.story.tsx +1 -1
- package/src/test-utils/story-config.ts +9 -6
- package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.story.tsx +2 -2
- package/src/tile/Tile.css +31 -18
- package/src/tile/Tile.story.tsx +43 -43
- package/src/tooltip/Tooltip.story.tsx +2 -2
- package/src/typeahead/Typeahead.story.tsx +2 -2
- package/src/upload/Upload.story.tsx +2 -2
- package/src/upload/Upload.tests.story.tsx +2 -2
- package/src/upload/utils/isTypeValid/isTypeValid.spec.ts +3 -1
- package/src/uploadInput/UploadInput.story.tsx +1 -1
- package/src/uploadInput/UploadInput.tests.story.tsx +3 -3
- package/src/withId/withId.docs.mdx +1 -1
- package/src/withId/withId.story.tsx +1 -1
- package/src/common/responsivePanel/__snapshots__/ResponsivePanel.spec.js.snap +0 -21
package/src/popover/Popover.css
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
}@media (min-width: 768px) {
|
|
3
|
-
}.np-theme-personal .np-popover__container {
|
|
1
|
+
.np-theme-personal .np-popover__container {
|
|
4
2
|
border-radius: 16px;
|
|
5
3
|
border-radius: var(--radius-medium);
|
|
6
|
-
}
|
|
4
|
+
}
|
|
5
|
+
.np-popover__container .np-popover__content {
|
|
7
6
|
color: #5d7079;
|
|
8
7
|
color: var(--color-content-secondary);
|
|
9
8
|
font-size: 0.875rem;
|
|
10
9
|
font-size: var(--font-size-14);
|
|
11
|
-
}
|
|
10
|
+
}
|
|
11
|
+
.np-popover__container .np-popover__content p:last-child {
|
|
12
12
|
margin-bottom: 0;
|
|
13
|
-
}
|
|
13
|
+
}
|
|
14
|
+
.np-popover__container.np-panel .np-popover__content {
|
|
14
15
|
padding: 16px 24px;
|
|
15
16
|
padding: var(--size-16) var(--size-24);
|
|
16
17
|
max-width: 276px;
|
|
17
|
-
}
|
|
18
|
+
}
|
|
19
|
+
.np-theme-personal .np-popover__container.np-panel .np-popover__content {
|
|
18
20
|
padding: 24px;
|
|
19
21
|
padding: var(--size-24);
|
|
20
|
-
}
|
|
22
|
+
}
|
|
23
|
+
.np-popover__container.np-bottom-sheet .np-popover__title {
|
|
21
24
|
margin: 0;
|
|
22
25
|
color: #37517e;
|
|
23
26
|
color: var(--color-content-primary);
|
|
@@ -32,7 +35,8 @@
|
|
|
32
35
|
font-size: var(--font-size-26);
|
|
33
36
|
letter-spacing: -0.02em;
|
|
34
37
|
line-height: 122%;
|
|
35
|
-
}
|
|
38
|
+
}
|
|
39
|
+
@supports (hyphenate-limit-chars: 1) {
|
|
36
40
|
.np-popover__container.np-bottom-sheet .np-popover__title {
|
|
37
41
|
-webkit-hyphens: auto;
|
|
38
42
|
hyphens: auto;
|
|
@@ -48,7 +52,8 @@
|
|
|
48
52
|
hyphenate-limit-chars: 10 4 3;
|
|
49
53
|
}
|
|
50
54
|
}
|
|
51
|
-
}
|
|
55
|
+
}
|
|
56
|
+
@supports (not (hyphenate-limit-chars: 1)) and (-webkit-hyphenate-limit-before: 1) {
|
|
52
57
|
.np-popover__container.np-bottom-sheet .np-popover__title {
|
|
53
58
|
-webkit-hyphens: auto;
|
|
54
59
|
hyphens: auto;
|
|
@@ -60,12 +65,14 @@
|
|
|
60
65
|
-webkit-hyphenate-limit-before: 4;
|
|
61
66
|
}
|
|
62
67
|
}
|
|
63
|
-
}
|
|
68
|
+
}
|
|
69
|
+
.np-popover__container.np-bottom-sheet .np-popover__title + p,
|
|
64
70
|
.np-popover__container.np-bottom-sheet .np-popover__title + ul:not(.list-unstyled),
|
|
65
71
|
.np-popover__container.np-bottom-sheet .np-popover__title + ol:not(.list-unstyled) {
|
|
66
72
|
margin-top: 8px;
|
|
67
73
|
margin-top: var(--size-8);
|
|
68
|
-
}
|
|
74
|
+
}
|
|
75
|
+
.np-popover__container.np-bottom-sheet .np-popover__content {
|
|
69
76
|
padding: 32px 24px;
|
|
70
77
|
padding: var(--size-32) var(--size-24);
|
|
71
78
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { action } from '
|
|
1
|
+
import { action } from 'storybook/actions';
|
|
2
2
|
|
|
3
3
|
import Button from '../button';
|
|
4
4
|
import { Position } from '../common';
|
|
5
5
|
|
|
6
6
|
import Popover from './Popover';
|
|
7
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
7
|
+
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
8
8
|
|
|
9
9
|
type Story = StoryObj<typeof Popover>;
|
|
10
10
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { fn } from '
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { fn } from 'storybook/test';
|
|
3
3
|
import PrimitiveAnchor from '..';
|
|
4
4
|
|
|
5
5
|
const meta: Meta<typeof PrimitiveAnchor> = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import { userEvent, within, expect, waitFor } from '
|
|
3
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { userEvent, within, expect, waitFor } from 'storybook/test';
|
|
3
|
+
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
4
4
|
import PrimitiveAnchor from '..';
|
|
5
5
|
|
|
6
6
|
const meta = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { fn } from '
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { fn } from 'storybook/test';
|
|
3
3
|
import PrimitiveButton from '..';
|
|
4
4
|
|
|
5
5
|
const meta: Meta<typeof PrimitiveButton> = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import { userEvent, within, expect, waitFor } from '
|
|
3
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { userEvent, within, expect, waitFor } from 'storybook/test';
|
|
3
|
+
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
4
4
|
import PrimitiveButton from '..';
|
|
5
5
|
|
|
6
6
|
const meta = {
|
|
@@ -35,7 +35,7 @@ describe('Provider', () => {
|
|
|
35
35
|
['ja-JP', 'ja-JP'],
|
|
36
36
|
['', 'en-GB'],
|
|
37
37
|
[' ', 'en-GB'],
|
|
38
|
-
])('check locale value "%s"', (locale, expectedValue) => {
|
|
38
|
+
])('check locale value "%s"', (locale: string, expectedValue: string) => {
|
|
39
39
|
const TestComponent = () => {
|
|
40
40
|
const intl = useIntl();
|
|
41
41
|
return <>locale: {intl.locale}</>;
|
|
@@ -52,7 +52,7 @@ describe('Provider', () => {
|
|
|
52
52
|
it.each([
|
|
53
53
|
['ru', 'Закрыть'],
|
|
54
54
|
['en', 'Close'],
|
|
55
|
-
])('switching locale (%s)', async (locale, expectedMessage) => {
|
|
55
|
+
])('switching locale (%s)', async (locale: string, expectedMessage: string) => {
|
|
56
56
|
expect(document.body).toBeEmptyDOMElement();
|
|
57
57
|
|
|
58
58
|
const messages = (await import(`../i18n/${locale}.json`)) as Record<string, string>;
|
|
@@ -12,7 +12,7 @@ describe('DirectionProvider', () => {
|
|
|
12
12
|
it.each([
|
|
13
13
|
[Direction.LTR, false],
|
|
14
14
|
[Direction.RTL, true],
|
|
15
|
-
])('store direction %s in React Context', (direction, isRTL) => {
|
|
15
|
+
])('store direction %s in React Context', (direction: Direction, isRTL: boolean) => {
|
|
16
16
|
let directionContext = null;
|
|
17
17
|
const TestComponent = () => {
|
|
18
18
|
directionContext = useDirection();
|
|
@@ -7,7 +7,7 @@ describe('LanguageProvider', () => {
|
|
|
7
7
|
document.documentElement.removeAttribute('lang');
|
|
8
8
|
});
|
|
9
9
|
|
|
10
|
-
it.each([['en'], ['ru'], ['ja']])('store language %s in React Context', (locale) => {
|
|
10
|
+
it.each([['en'], ['ru'], ['ja']])('store language %s in React Context', (locale: string) => {
|
|
11
11
|
const TestComponent = () => {
|
|
12
12
|
return <>locale: {locale}</>;
|
|
13
13
|
};
|
|
@@ -1,52 +1,69 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
2
|
import { useState } from 'react';
|
|
3
|
-
import Radio from './Radio';
|
|
3
|
+
import Radio, { type RadioProps } from './Radio';
|
|
4
4
|
import AvatarView from '../avatarView';
|
|
5
5
|
import { Flag } from '@wise/art';
|
|
6
|
+
import { fn } from 'storybook/test';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
const meta: Meta<RadioProps> = {
|
|
8
9
|
component: Radio,
|
|
9
10
|
title: 'Forms/Radio',
|
|
11
|
+
argTypes: {
|
|
12
|
+
disabled: { control: 'boolean' },
|
|
13
|
+
},
|
|
10
14
|
};
|
|
15
|
+
export default meta;
|
|
11
16
|
|
|
12
|
-
export const Basic =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
export const Basic: StoryObj<RadioProps> = {
|
|
18
|
+
render: (args) => {
|
|
19
|
+
return <Radio {...args} value="option1" onChange={fn()} />;
|
|
20
|
+
},
|
|
21
|
+
args: {
|
|
22
|
+
checked: false,
|
|
23
|
+
disabled: false,
|
|
24
|
+
label: 'Without Avatar',
|
|
25
|
+
name: 'name',
|
|
26
|
+
secondary: 'This is secondary text',
|
|
27
|
+
id: 'radioGroup1',
|
|
28
|
+
value: 'option1',
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
export const Variants: StoryObj<RadioProps> = {
|
|
32
|
+
render: () => {
|
|
33
|
+
const [selectedValue, setSelectedValue] = useState('option1');
|
|
16
34
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
);
|
|
35
|
+
return (
|
|
36
|
+
<>
|
|
37
|
+
<div className={`form-group ${selectedValue === 'option1' ? 'has-error' : ''}`}>
|
|
38
|
+
<Radio
|
|
39
|
+
label="Without Avatar"
|
|
40
|
+
name="name"
|
|
41
|
+
secondary="This is secondary text"
|
|
42
|
+
id="radioGroup1"
|
|
43
|
+
value="option1"
|
|
44
|
+
checked={selectedValue === 'option1'}
|
|
45
|
+
onChange={() => setSelectedValue('option1')}
|
|
46
|
+
/>
|
|
47
|
+
</div>
|
|
48
|
+
<div className="form-group">
|
|
49
|
+
<Radio
|
|
50
|
+
label="With Avatar"
|
|
51
|
+
name="name"
|
|
52
|
+
id="radioGroup2"
|
|
53
|
+
avatar={
|
|
54
|
+
<AvatarView>
|
|
55
|
+
<Flag code="IMP" />
|
|
56
|
+
</AvatarView>
|
|
57
|
+
}
|
|
58
|
+
value="option2"
|
|
59
|
+
checked={selectedValue === 'option2'}
|
|
60
|
+
onChange={() => setSelectedValue('option2')}
|
|
61
|
+
/>
|
|
62
|
+
</div>
|
|
63
|
+
<div className="form-group">
|
|
64
|
+
<Radio label="Disabled" name="name" id="radioGroup3" disabled value="option3" />
|
|
65
|
+
</div>
|
|
66
|
+
</>
|
|
67
|
+
);
|
|
68
|
+
},
|
|
52
69
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Flag } from '@wise/art';
|
|
2
2
|
import RadioGroup, { RadioGroupProps, RadioGroupRadio } from './RadioGroup';
|
|
3
3
|
import { Field } from '../field/Field';
|
|
4
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
5
|
-
import { fn } from '
|
|
4
|
+
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
5
|
+
import { fn } from 'storybook/test';
|
|
6
6
|
import { useState } from 'react';
|
|
7
7
|
import AvatarView from '../avatarView';
|
|
8
8
|
|
|
@@ -1,75 +1,110 @@
|
|
|
1
|
-
import { action } from '@storybook/addon-actions';
|
|
2
|
-
import { boolean, text } from '@storybook/addon-knobs';
|
|
3
|
-
import { FastFlag as FastFlagIcon } from '@transferwise/icons';
|
|
4
1
|
import { useState } from 'react';
|
|
5
|
-
|
|
2
|
+
import { action } from 'storybook/actions';
|
|
3
|
+
import { fn } from 'storybook/test';
|
|
4
|
+
import { FastFlag as FastFlagIcon } from '@transferwise/icons';
|
|
6
5
|
import { Header, Nudge, Section, Title, Typography } from '..';
|
|
7
|
-
|
|
8
6
|
import RadioOption, { RadioOptionProps } from './RadioOption';
|
|
9
7
|
|
|
10
8
|
export default {
|
|
11
9
|
component: RadioOption,
|
|
12
10
|
title: 'Option/RadioOption',
|
|
11
|
+
argTypes: {
|
|
12
|
+
disabled: { control: 'boolean' },
|
|
13
|
+
secondary: { control: 'text' },
|
|
14
|
+
},
|
|
15
|
+
args: {
|
|
16
|
+
title: 'Radio option',
|
|
17
|
+
content: 'Button and icon are vertically centered.',
|
|
18
|
+
disabled: false,
|
|
19
|
+
},
|
|
13
20
|
};
|
|
14
21
|
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const title = text('title', 'title');
|
|
18
|
-
const disabled = boolean('disabled', false);
|
|
19
|
-
const content = text('content', 'content');
|
|
20
|
-
const isContainerAligned = boolean('isContainerAligned', false);
|
|
22
|
+
export const Basic = (args: RadioOptionProps) => {
|
|
23
|
+
const [checked, setChecked] = useState(false);
|
|
21
24
|
|
|
22
25
|
return (
|
|
23
26
|
<RadioOption
|
|
27
|
+
{...args}
|
|
24
28
|
media={<FastFlagIcon />}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
checked={props.checked}
|
|
30
|
-
complex={false}
|
|
31
|
-
disabled={disabled}
|
|
32
|
-
value="value"
|
|
33
|
-
showMediaAtAllSizes={showMediaAtAllSizes}
|
|
34
|
-
isContainerAligned={isContainerAligned}
|
|
35
|
-
onChange={(value) => {
|
|
36
|
-
action('checked');
|
|
37
|
-
props.onChange?.(value);
|
|
29
|
+
checked={checked}
|
|
30
|
+
onChange={() => {
|
|
31
|
+
fn();
|
|
32
|
+
setChecked(!checked);
|
|
38
33
|
}}
|
|
39
34
|
/>
|
|
40
35
|
);
|
|
41
36
|
};
|
|
42
37
|
|
|
43
|
-
export const
|
|
44
|
-
const checked = boolean('checked', false);
|
|
45
|
-
|
|
46
|
-
return <Template checked={checked} />;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export const Multiple = () => {
|
|
38
|
+
export const Multiple = (args: RadioOptionProps) => {
|
|
50
39
|
const [selected, setSelected] = useState(0);
|
|
51
40
|
|
|
41
|
+
const handleChange = (value: number) => {
|
|
42
|
+
action('changed')(value);
|
|
43
|
+
setSelected(value);
|
|
44
|
+
};
|
|
45
|
+
|
|
52
46
|
return (
|
|
53
47
|
<Section as="fieldset">
|
|
54
48
|
<Header as="legend" title="Test title" />
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
<RadioOption
|
|
50
|
+
{...args}
|
|
51
|
+
media={<FastFlagIcon />}
|
|
52
|
+
checked={selected === 0}
|
|
53
|
+
value="value0"
|
|
54
|
+
onChange={() => handleChange(0)}
|
|
55
|
+
/>
|
|
56
|
+
<RadioOption
|
|
57
|
+
{...args}
|
|
58
|
+
media={<FastFlagIcon />}
|
|
59
|
+
checked={selected === 1}
|
|
60
|
+
value="value1"
|
|
61
|
+
onChange={() => handleChange(1)}
|
|
62
|
+
/>
|
|
63
|
+
<RadioOption
|
|
64
|
+
{...args}
|
|
65
|
+
media={<FastFlagIcon />}
|
|
66
|
+
checked={selected === 2}
|
|
67
|
+
value="value2"
|
|
68
|
+
onChange={() => handleChange(2)}
|
|
69
|
+
/>
|
|
58
70
|
</Section>
|
|
59
71
|
);
|
|
60
72
|
};
|
|
61
73
|
|
|
62
|
-
export const WithContainerContent = () => {
|
|
74
|
+
export const WithContainerContent = (args: RadioOptionProps) => {
|
|
63
75
|
const [selected, setSelected] = useState(0);
|
|
64
76
|
|
|
77
|
+
const handleChange = (value: number) => {
|
|
78
|
+
action('changed')(value);
|
|
79
|
+
setSelected(value);
|
|
80
|
+
};
|
|
81
|
+
|
|
65
82
|
return (
|
|
66
83
|
<>
|
|
67
84
|
<Title type={Typography.TITLE_SUBSECTION} className="m-b-1">
|
|
68
85
|
Choose how to pay
|
|
69
86
|
</Title>
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
87
|
+
<RadioOption
|
|
88
|
+
{...args}
|
|
89
|
+
media={<FastFlagIcon />}
|
|
90
|
+
checked={selected === 0}
|
|
91
|
+
value="value0"
|
|
92
|
+
onChange={() => handleChange(0)}
|
|
93
|
+
/>
|
|
94
|
+
<RadioOption
|
|
95
|
+
{...args}
|
|
96
|
+
media={<FastFlagIcon />}
|
|
97
|
+
checked={selected === 1}
|
|
98
|
+
value="value1"
|
|
99
|
+
onChange={() => handleChange(1)}
|
|
100
|
+
/>
|
|
101
|
+
<RadioOption
|
|
102
|
+
{...args}
|
|
103
|
+
media={<FastFlagIcon />}
|
|
104
|
+
checked={selected === 2}
|
|
105
|
+
value="value2"
|
|
106
|
+
onChange={() => handleChange(2)}
|
|
107
|
+
/>
|
|
73
108
|
<div>
|
|
74
109
|
<Nudge
|
|
75
110
|
className="m-t-2"
|