@transferwise/components 0.0.0-experimental-de8fd4d → 0.0.0-experimental-59a94f4
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/main.css +5 -4
- package/build/styles/circularButton/CircularButton.css +1 -0
- package/build/styles/listItem/ListItem.css +4 -4
- package/build/styles/main.css +5 -4
- package/build/types/listItem/ListItem.d.ts +2 -2
- package/build/types/listItem/ListItem.d.ts.map +1 -1
- package/build/types/listItem/useItemControl.d.ts +0 -7
- package/build/types/listItem/useItemControl.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/circularButton/CircularButton.css +1 -0
- package/src/circularButton/CircularButton.less +1 -0
- package/src/circularButton/CircularButton.tests.story.tsx +23 -0
- package/src/listItem/ListItem.css +4 -4
- package/src/listItem/ListItem.less +4 -6
- package/src/listItem/ListItem.spec.tsx +35 -0
- package/src/listItem/ListItem.story.tsx +28 -30
- package/src/listItem/ListItem.tsx +65 -68
- package/src/listItem/useItemControl.tsx +2 -6
- package/src/main.css +5 -4
- package/build/types/listItem/ListItemRadio.d.ts +0 -3
- package/build/types/listItem/ListItemRadio.d.ts.map +0 -1
- package/src/listItem/ListItemRadio.tsx +0 -8
package/build/main.css
CHANGED
|
@@ -1402,6 +1402,7 @@
|
|
|
1402
1402
|
}
|
|
1403
1403
|
.np-circular-btn-primary-default .np-circular-btn-label,
|
|
1404
1404
|
.np-circular-btn-secondary-default .np-circular-btn-label {
|
|
1405
|
+
text-align: center;
|
|
1405
1406
|
color: var(--color-interactive-primary);
|
|
1406
1407
|
}
|
|
1407
1408
|
.np-circular-btn-primary-default .np-circular-btn-label:not(.disabled):not(:disabled):hover,
|
|
@@ -2705,10 +2706,10 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
|
|
|
2705
2706
|
background-color: rgba(134,167,189,0.10196);
|
|
2706
2707
|
background-color: var(--color-background-neutral);
|
|
2707
2708
|
}
|
|
2708
|
-
.wds-list-item-spotlight-active:hover {
|
|
2709
|
+
.wds-list-item-spotlight-active:not(.disabled):not(:disabled):hover {
|
|
2709
2710
|
background-color: var(--color-background-neutral-hover);
|
|
2710
2711
|
}
|
|
2711
|
-
.wds-list-item-spotlight-active:active {
|
|
2712
|
+
.wds-list-item-spotlight-active:not(.disabled):not(:disabled):active {
|
|
2712
2713
|
background-color: var(--color-background-neutral-active);
|
|
2713
2714
|
}
|
|
2714
2715
|
.wds-list-item-spotlight-inactive {
|
|
@@ -2721,10 +2722,10 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
|
|
|
2721
2722
|
background-color: color-mix(in srgb, var(--color-background-neutral) 25%, transparent);
|
|
2722
2723
|
}
|
|
2723
2724
|
}
|
|
2724
|
-
.wds-list-item-spotlight-inactive:hover {
|
|
2725
|
+
.wds-list-item-spotlight-inactive:not(.disabled):not(:disabled):hover {
|
|
2725
2726
|
background-color: color-mix(in srgb, var(--color-background-neutral-hover) 25%, transparent);
|
|
2726
2727
|
}
|
|
2727
|
-
.wds-list-item-spotlight-inactive:active {
|
|
2728
|
+
.wds-list-item-spotlight-inactive:not(.disabled):not(:disabled):active {
|
|
2728
2729
|
background-color: color-mix(in srgb, var(--color-background-neutral-active) 25%, transparent);
|
|
2729
2730
|
}
|
|
2730
2731
|
.wds-list-item-prompt {
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
}
|
|
7
7
|
.np-circular-btn-primary-default .np-circular-btn-label,
|
|
8
8
|
.np-circular-btn-secondary-default .np-circular-btn-label {
|
|
9
|
+
text-align: center;
|
|
9
10
|
color: var(--color-interactive-primary);
|
|
10
11
|
}
|
|
11
12
|
.np-circular-btn-primary-default .np-circular-btn-label:not(.disabled):not(:disabled):hover,
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
background-color: rgba(134,167,189,0.10196);
|
|
43
43
|
background-color: var(--color-background-neutral);
|
|
44
44
|
}
|
|
45
|
-
.wds-list-item-spotlight-active:hover {
|
|
45
|
+
.wds-list-item-spotlight-active:not(.disabled):not(:disabled):hover {
|
|
46
46
|
background-color: var(--color-background-neutral-hover);
|
|
47
47
|
}
|
|
48
|
-
.wds-list-item-spotlight-active:active {
|
|
48
|
+
.wds-list-item-spotlight-active:not(.disabled):not(:disabled):active {
|
|
49
49
|
background-color: var(--color-background-neutral-active);
|
|
50
50
|
}
|
|
51
51
|
.wds-list-item-spotlight-inactive {
|
|
@@ -58,10 +58,10 @@
|
|
|
58
58
|
background-color: color-mix(in srgb, var(--color-background-neutral) 25%, transparent);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
.wds-list-item-spotlight-inactive:hover {
|
|
61
|
+
.wds-list-item-spotlight-inactive:not(.disabled):not(:disabled):hover {
|
|
62
62
|
background-color: color-mix(in srgb, var(--color-background-neutral-hover) 25%, transparent);
|
|
63
63
|
}
|
|
64
|
-
.wds-list-item-spotlight-inactive:active {
|
|
64
|
+
.wds-list-item-spotlight-inactive:not(.disabled):not(:disabled):active {
|
|
65
65
|
background-color: color-mix(in srgb, var(--color-background-neutral-active) 25%, transparent);
|
|
66
66
|
}
|
|
67
67
|
.wds-list-item-prompt {
|
package/build/styles/main.css
CHANGED
|
@@ -1402,6 +1402,7 @@
|
|
|
1402
1402
|
}
|
|
1403
1403
|
.np-circular-btn-primary-default .np-circular-btn-label,
|
|
1404
1404
|
.np-circular-btn-secondary-default .np-circular-btn-label {
|
|
1405
|
+
text-align: center;
|
|
1405
1406
|
color: var(--color-interactive-primary);
|
|
1406
1407
|
}
|
|
1407
1408
|
.np-circular-btn-primary-default .np-circular-btn-label:not(.disabled):not(:disabled):hover,
|
|
@@ -2705,10 +2706,10 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
|
|
|
2705
2706
|
background-color: rgba(134,167,189,0.10196);
|
|
2706
2707
|
background-color: var(--color-background-neutral);
|
|
2707
2708
|
}
|
|
2708
|
-
.wds-list-item-spotlight-active:hover {
|
|
2709
|
+
.wds-list-item-spotlight-active:not(.disabled):not(:disabled):hover {
|
|
2709
2710
|
background-color: var(--color-background-neutral-hover);
|
|
2710
2711
|
}
|
|
2711
|
-
.wds-list-item-spotlight-active:active {
|
|
2712
|
+
.wds-list-item-spotlight-active:not(.disabled):not(:disabled):active {
|
|
2712
2713
|
background-color: var(--color-background-neutral-active);
|
|
2713
2714
|
}
|
|
2714
2715
|
.wds-list-item-spotlight-inactive {
|
|
@@ -2721,10 +2722,10 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
|
|
|
2721
2722
|
background-color: color-mix(in srgb, var(--color-background-neutral) 25%, transparent);
|
|
2722
2723
|
}
|
|
2723
2724
|
}
|
|
2724
|
-
.wds-list-item-spotlight-inactive:hover {
|
|
2725
|
+
.wds-list-item-spotlight-inactive:not(.disabled):not(:disabled):hover {
|
|
2725
2726
|
background-color: color-mix(in srgb, var(--color-background-neutral-hover) 25%, transparent);
|
|
2726
2727
|
}
|
|
2727
|
-
.wds-list-item-spotlight-inactive:active {
|
|
2728
|
+
.wds-list-item-spotlight-inactive:not(.disabled):not(:disabled):active {
|
|
2728
2729
|
background-color: color-mix(in srgb, var(--color-background-neutral-active) 25%, transparent);
|
|
2729
2730
|
}
|
|
2730
2731
|
.wds-list-item-prompt {
|
|
@@ -13,6 +13,7 @@ export type Props = {
|
|
|
13
13
|
media?: ReactNode;
|
|
14
14
|
control?: ReactNode;
|
|
15
15
|
prompt?: ReactNode;
|
|
16
|
+
className?: string;
|
|
16
17
|
};
|
|
17
18
|
export type ListItemContextData = {
|
|
18
19
|
setControlType: (type: ListItemTypes) => void;
|
|
@@ -27,7 +28,7 @@ export type ListItemContextData = {
|
|
|
27
28
|
};
|
|
28
29
|
export declare const ListItemContext: import("react").Context<ListItemContextData>;
|
|
29
30
|
export declare const ListItem: {
|
|
30
|
-
({ as: View, title, subtitle, additionalInfo, prompt, inverted, media, spotlight, valueTitle, valueSubtitle, control, disabled, }: Props): import("react").JSX.Element;
|
|
31
|
+
({ as: View, title, subtitle, additionalInfo, prompt, inverted, media, spotlight, valueTitle, valueSubtitle, control, disabled, className, }: Props): import("react").JSX.Element;
|
|
31
32
|
Image: ({ alt, size, ...props }: import("./ListItemMedia").ListItemImageProps) => import("react").JSX.Element;
|
|
32
33
|
AvatarView: ({ className, size, ...props }: import("./ListItemMedia").ListItemAvatarViewProps) => import("react").JSX.Element;
|
|
33
34
|
AvatarLayout: ({ className, size, ...props }: import("./ListItemMedia").ListItemAvatarLayoutProps) => import("react").JSX.Element;
|
|
@@ -35,7 +36,6 @@ export declare const ListItem: {
|
|
|
35
36
|
Checkbox: (props: import("./ListItemCheckbox").ListItemCheckboxProps) => import("react").JSX.Element;
|
|
36
37
|
IconButton: (props: import("./ListItemIconButton").ListItemIconButtonProps) => import("react").JSX.Element;
|
|
37
38
|
Navigation: ({ onClick }: import("./ListItemNavigation").ListItemNavigationProps) => import("react").JSX.Element;
|
|
38
|
-
Radio: (props: import("../common/RadioButton/RadioButton").RadioButtonProps) => import("react").JSX.Element;
|
|
39
39
|
Button: ({ priority, ...props }: import("./ListItemButton").ListItemButtonProps) => import("react").JSX.Element;
|
|
40
40
|
Switch: (props: import("..").SwitchProps) => import("react").JSX.Element;
|
|
41
41
|
Prompt: ({ type, children, action }: import("./prompt/Prompt").ListItemPromptProps) => import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.d.ts","sourceRoot":"","sources":["../../../src/listItem/ListItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAA4B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ListItem.d.ts","sourceRoot":"","sources":["../../../src/listItem/ListItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAA4B,MAAM,OAAO,CAAC;AAa3E,MAAM,MAAM,aAAa,GACrB,iBAAiB,GACjB,YAAY,GACZ,OAAO,GACP,UAAU,GACV,QAAQ,GACR,QAAQ,GACR,aAAa,CAAC;AAElB,MAAM,MAAM,KAAK,GAAG;IAClB,EAAE,CAAC,EAAE,IAAI,GAAG,KAAK,GAAG,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IAClC,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,cAAc,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;IAC9C,GAAG,EAAE;QACH,KAAK,EAAE,MAAM,CAAC;QACd,cAAc,EAAE,MAAM,CAAC;QACvB,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,GAAG,UAAU,GAAG,UAAU,CAAC,CAAC;CACpD,CAAC;AAIF,eAAO,MAAM,eAAe,8CAA2C,CAAC;AAExE,eAAO,MAAM,QAAQ;kJAclB,KAAK;;;;;;;;;;;CA0GP,CAAC;AAeF,eAAe,QAAQ,CAAC"}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { ListItemTypes } from './ListItem';
|
|
2
2
|
export declare function useItemControl(controlType: ListItemTypes): {
|
|
3
|
-
ids: {
|
|
4
|
-
label: string;
|
|
5
|
-
additionalInfo: string;
|
|
6
|
-
value: string;
|
|
7
|
-
control: string;
|
|
8
|
-
prompt: string;
|
|
9
|
-
};
|
|
10
3
|
baseItemProps: Pick<import("./ListItem").Props, "as" | "disabled" | "inverted">;
|
|
11
4
|
};
|
|
12
5
|
//# sourceMappingURL=useItemControl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useItemControl.d.ts","sourceRoot":"","sources":["../../../src/listItem/useItemControl.tsx"],"names":[],"mappings":"AACA,OAAO,EAAwC,aAAa,EAAE,MAAM,YAAY,CAAC;AAEjF,wBAAgB,cAAc,CAAC,WAAW,EAAE,aAAa
|
|
1
|
+
{"version":3,"file":"useItemControl.d.ts","sourceRoot":"","sources":["../../../src/listItem/useItemControl.tsx"],"names":[],"mappings":"AACA,OAAO,EAAwC,aAAa,EAAE,MAAM,YAAY,CAAC;AAEjF,wBAAgB,cAAc,CAAC,WAAW,EAAE,aAAa;;EAQxD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/components",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-59a94f4",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -92,9 +92,9 @@
|
|
|
92
92
|
"rollup-preserve-directives": "^1.1.3",
|
|
93
93
|
"storybook": "^8.6.14",
|
|
94
94
|
"@transferwise/less-config": "3.1.2",
|
|
95
|
+
"@transferwise/neptune-css": "14.24.4",
|
|
95
96
|
"@wise/components-theming": "1.6.3",
|
|
96
|
-
"@wise/wds-configs": "0.0.0"
|
|
97
|
-
"@transferwise/neptune-css": "14.24.4"
|
|
97
|
+
"@wise/wds-configs": "0.0.0"
|
|
98
98
|
},
|
|
99
99
|
"peerDependencies": {
|
|
100
100
|
"@transferwise/icons": "^3.22.0",
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
}
|
|
7
7
|
.np-circular-btn-primary-default .np-circular-btn-label,
|
|
8
8
|
.np-circular-btn-secondary-default .np-circular-btn-label {
|
|
9
|
+
text-align: center;
|
|
9
10
|
color: var(--color-interactive-primary);
|
|
10
11
|
}
|
|
11
12
|
.np-circular-btn-primary-default .np-circular-btn-label:not(.disabled):not(:disabled):hover,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Freeze } from '@transferwise/icons';
|
|
2
|
+
|
|
3
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
4
|
+
import CircularButton from './CircularButton';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
component: CircularButton,
|
|
8
|
+
title: 'Actions/CircularButton/Tests',
|
|
9
|
+
} satisfies Meta<typeof CircularButton>;
|
|
10
|
+
|
|
11
|
+
type Story = StoryObj<typeof CircularButton>;
|
|
12
|
+
|
|
13
|
+
export const CenteredText: Story = {
|
|
14
|
+
render: () => {
|
|
15
|
+
return (
|
|
16
|
+
<div style={{ maxWidth: '100px' }}>
|
|
17
|
+
<CircularButton priority="primary" type="default" icon={<Freeze />}>
|
|
18
|
+
Very long text for a circular button that will be centered
|
|
19
|
+
</CircularButton>
|
|
20
|
+
</div>
|
|
21
|
+
);
|
|
22
|
+
},
|
|
23
|
+
};
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
background-color: rgba(134,167,189,0.10196);
|
|
43
43
|
background-color: var(--color-background-neutral);
|
|
44
44
|
}
|
|
45
|
-
.wds-list-item-spotlight-active:hover {
|
|
45
|
+
.wds-list-item-spotlight-active:not(.disabled):not(:disabled):hover {
|
|
46
46
|
background-color: var(--color-background-neutral-hover);
|
|
47
47
|
}
|
|
48
|
-
.wds-list-item-spotlight-active:active {
|
|
48
|
+
.wds-list-item-spotlight-active:not(.disabled):not(:disabled):active {
|
|
49
49
|
background-color: var(--color-background-neutral-active);
|
|
50
50
|
}
|
|
51
51
|
.wds-list-item-spotlight-inactive {
|
|
@@ -58,10 +58,10 @@
|
|
|
58
58
|
background-color: color-mix(in srgb, var(--color-background-neutral) 25%, transparent);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
.wds-list-item-spotlight-inactive:hover {
|
|
61
|
+
.wds-list-item-spotlight-inactive:not(.disabled):not(:disabled):hover {
|
|
62
62
|
background-color: color-mix(in srgb, var(--color-background-neutral-hover) 25%, transparent);
|
|
63
63
|
}
|
|
64
|
-
.wds-list-item-spotlight-inactive:active {
|
|
64
|
+
.wds-list-item-spotlight-inactive:not(.disabled):not(:disabled):active {
|
|
65
65
|
background-color: color-mix(in srgb, var(--color-background-neutral-active) 25%, transparent);
|
|
66
66
|
}
|
|
67
67
|
.wds-list-item-prompt {
|
|
@@ -45,11 +45,10 @@
|
|
|
45
45
|
&-spotlight {
|
|
46
46
|
&-active {
|
|
47
47
|
background-color: var(--color-background-neutral);
|
|
48
|
-
|
|
49
|
-
&:hover {
|
|
48
|
+
&:not(.disabled, :disabled):hover {
|
|
50
49
|
background-color: var(--color-background-neutral-hover);
|
|
51
50
|
}
|
|
52
|
-
&:active {
|
|
51
|
+
&:not(.disabled, :disabled):active {
|
|
53
52
|
background-color: var(--color-background-neutral-active);
|
|
54
53
|
}
|
|
55
54
|
}
|
|
@@ -57,11 +56,10 @@
|
|
|
57
56
|
&-inactive {
|
|
58
57
|
background-color: color-mix(in srgb, var(--color-background-neutral) 25%, transparent);
|
|
59
58
|
border: 1px dashed var(--color-border-neutral);
|
|
60
|
-
|
|
61
|
-
&:hover {
|
|
59
|
+
&:not(.disabled, :disabled):hover {
|
|
62
60
|
background-color: color-mix(in srgb, var(--color-background-neutral-hover) 25%, transparent);
|
|
63
61
|
}
|
|
64
|
-
&:active {
|
|
62
|
+
&:not(.disabled, :disabled):active {
|
|
65
63
|
background-color: color-mix(in srgb, var(--color-background-neutral-active) 25%, transparent);
|
|
66
64
|
}
|
|
67
65
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { render, screen } from '../test-utils';
|
|
2
|
+
import ListItem from './ListItem';
|
|
3
|
+
|
|
4
|
+
describe('ListItem', () => {
|
|
5
|
+
describe('spotlight', () => {
|
|
6
|
+
it('only fully interactive variant can have spotlight:active', () => {
|
|
7
|
+
render(<ListItem title="Test Title" spotlight="active" control={<ListItem.Navigation />} />);
|
|
8
|
+
const listItem = screen.getByRole('listitem');
|
|
9
|
+
expect(listItem).toHaveClass('wds-list-item-interactive');
|
|
10
|
+
expect(listItem).toHaveClass('wds-list-item-spotlight-active');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('only fully interactive variant can have spotlight:inactive', () => {
|
|
14
|
+
render(
|
|
15
|
+
<ListItem
|
|
16
|
+
title="Test Title"
|
|
17
|
+
spotlight="inactive"
|
|
18
|
+
control={<ListItem.Switch onClick={() => {}} />}
|
|
19
|
+
/>,
|
|
20
|
+
);
|
|
21
|
+
const listItem = screen.getByRole('listitem');
|
|
22
|
+
expect(listItem).toHaveClass('wds-list-item-interactive');
|
|
23
|
+
expect(listItem).toHaveClass('wds-list-item-spotlight-inactive');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('non interactive variant can have spotlight', () => {
|
|
27
|
+
render(<ListItem title="Test Title" spotlight="inactive" />);
|
|
28
|
+
const listItem = screen.getByRole('listitem');
|
|
29
|
+
expect(listItem).toHaveClass('wds-list-item-non-interactive');
|
|
30
|
+
expect(listItem).not.toHaveClass('wds-list-item-interactive');
|
|
31
|
+
expect(listItem).not.toHaveClass('wds-list-item-spotlight-inactive');
|
|
32
|
+
expect(listItem).not.toHaveClass('wds-list-item-spotlight-active');
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import ListItem, { Props as ItemProps } from './ListItem';
|
|
2
2
|
import { Meta, StoryObj } from '@storybook/react';
|
|
3
3
|
import React, { useState } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
Bank,
|
|
6
|
+
BankTransfer,
|
|
7
|
+
FastFlag,
|
|
8
|
+
MultiCurrency,
|
|
9
|
+
Plus,
|
|
10
|
+
Receipt,
|
|
11
|
+
Savings,
|
|
12
|
+
} from '@transferwise/icons';
|
|
5
13
|
|
|
6
14
|
import { lorem10, lorem20, lorem40, lorem5 } from '../test-utils';
|
|
7
15
|
import { Flag } from '@wise/art';
|
|
@@ -21,7 +29,6 @@ type Story = StoryObj<ItemProps>;
|
|
|
21
29
|
export const TempPlayground: Story = {
|
|
22
30
|
render: () => {
|
|
23
31
|
const [checked, setChecked] = useState(false);
|
|
24
|
-
const [radio, setRadio] = useState('option2');
|
|
25
32
|
|
|
26
33
|
return (
|
|
27
34
|
<div>
|
|
@@ -137,42 +144,32 @@ export const TempPlayground: Story = {
|
|
|
137
144
|
</ListItem.Button>
|
|
138
145
|
}
|
|
139
146
|
/>
|
|
140
|
-
<ListItem
|
|
141
|
-
title="Test title"
|
|
142
|
-
subtitle={lorem10}
|
|
143
|
-
additionalInfo={<ListItem.AdditionalInfo>{lorem20}</ListItem.AdditionalInfo>}
|
|
144
|
-
control={
|
|
145
|
-
<ListItem.Radio
|
|
146
|
-
name="option1"
|
|
147
|
-
checked={radio === 'option1'}
|
|
148
|
-
onChange={() => setRadio('option1')}
|
|
149
|
-
/>
|
|
150
|
-
}
|
|
151
|
-
/>
|
|
152
|
-
<ListItem
|
|
153
|
-
title="Test title"
|
|
154
|
-
subtitle={lorem10}
|
|
155
|
-
additionalInfo={<ListItem.AdditionalInfo>{lorem20}</ListItem.AdditionalInfo>}
|
|
156
|
-
control={
|
|
157
|
-
<ListItem.Radio
|
|
158
|
-
name="option2"
|
|
159
|
-
checked={radio === 'option2'}
|
|
160
|
-
onChange={() => setRadio('option2')}
|
|
161
|
-
/>
|
|
162
|
-
}
|
|
163
|
-
/>
|
|
164
147
|
|
|
165
148
|
<ListItem
|
|
149
|
+
media={
|
|
150
|
+
<ListItem.AvatarView>
|
|
151
|
+
<Bank />
|
|
152
|
+
</ListItem.AvatarView>
|
|
153
|
+
}
|
|
154
|
+
spotlight="inactive"
|
|
166
155
|
title="Test title"
|
|
167
|
-
subtitle={
|
|
168
|
-
additionalInfo={<ListItem.AdditionalInfo>{
|
|
156
|
+
subtitle={lorem5}
|
|
157
|
+
additionalInfo={<ListItem.AdditionalInfo>{lorem10}</ListItem.AdditionalInfo>}
|
|
169
158
|
control={<ListItem.Checkbox indeterminate />}
|
|
159
|
+
className="m-t-2"
|
|
170
160
|
/>
|
|
171
161
|
|
|
172
162
|
<ListItem
|
|
163
|
+
media={
|
|
164
|
+
<ListItem.AvatarLayout
|
|
165
|
+
orientation="diagonal"
|
|
166
|
+
avatars={[{ asset: <BankTransfer /> }, { asset: <Bank /> }]}
|
|
167
|
+
/>
|
|
168
|
+
}
|
|
169
|
+
spotlight="active"
|
|
173
170
|
title="Test title"
|
|
174
|
-
subtitle={
|
|
175
|
-
additionalInfo={<ListItem.AdditionalInfo>{
|
|
171
|
+
subtitle={lorem5}
|
|
172
|
+
additionalInfo={<ListItem.AdditionalInfo>{lorem10}</ListItem.AdditionalInfo>}
|
|
176
173
|
control={
|
|
177
174
|
<ListItem.Switch
|
|
178
175
|
checked={checked}
|
|
@@ -181,6 +178,7 @@ export const TempPlayground: Story = {
|
|
|
181
178
|
}}
|
|
182
179
|
/>
|
|
183
180
|
}
|
|
181
|
+
className="m-t-2 m-b-4"
|
|
184
182
|
/>
|
|
185
183
|
</div>
|
|
186
184
|
);
|
|
@@ -4,7 +4,6 @@ import Body from '../body';
|
|
|
4
4
|
import { AdditionalInfo } from './ListItemAdditionalInfo';
|
|
5
5
|
import { IconButton } from './ListItemIconButton';
|
|
6
6
|
import { Checkbox } from './ListItemCheckbox';
|
|
7
|
-
import { Radio } from './ListItemRadio';
|
|
8
7
|
import { Navigation } from './ListItemNavigation';
|
|
9
8
|
import { clsx } from 'clsx';
|
|
10
9
|
import { Button } from './ListItemButton';
|
|
@@ -34,6 +33,7 @@ export type Props = {
|
|
|
34
33
|
media?: ReactNode;
|
|
35
34
|
control?: ReactNode;
|
|
36
35
|
prompt?: ReactNode;
|
|
36
|
+
className?: string;
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
export type ListItemContextData = {
|
|
@@ -65,6 +65,7 @@ export const ListItem = ({
|
|
|
65
65
|
valueSubtitle,
|
|
66
66
|
control = null,
|
|
67
67
|
disabled,
|
|
68
|
+
className,
|
|
68
69
|
}: Props) => {
|
|
69
70
|
/*
|
|
70
71
|
const returnType = (): ReactNode => {
|
|
@@ -99,81 +100,78 @@ export const ListItem = ({
|
|
|
99
100
|
additionalInfo: `${idPrefix}_additional-info`,
|
|
100
101
|
};
|
|
101
102
|
|
|
103
|
+
// TODO: add partially interactive check from Button and IconButtons
|
|
104
|
+
// (https://transferwise.atlassian.net/browse/DS-7562)
|
|
105
|
+
const isFullyInteractive = controlType !== 'non-interactive';
|
|
106
|
+
|
|
102
107
|
const listItemContext = useMemo(
|
|
103
108
|
() => ({ setControlType, ids, props: { as: View, disabled, inverted } }),
|
|
104
109
|
[],
|
|
105
110
|
);
|
|
106
111
|
|
|
107
|
-
|
|
108
|
-
<
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
112
|
+
return (
|
|
113
|
+
<ListItemContext.Provider value={listItemContext}>
|
|
114
|
+
<View
|
|
115
|
+
className={clsx(
|
|
116
|
+
'wds-list-item',
|
|
117
|
+
{ 'wds-list-item-interactive': controlType !== 'non-interactive' },
|
|
118
|
+
`wds-list-item-${controlType}`,
|
|
119
|
+
'd-flex flex-row',
|
|
120
|
+
{ 'align-items-center': !subtitle },
|
|
121
|
+
{
|
|
122
|
+
[`wds-list-item-spotlight-${spotlight}`]: isFullyInteractive && !!spotlight,
|
|
123
|
+
},
|
|
124
|
+
className,
|
|
125
|
+
)}
|
|
126
|
+
aria-describedby={[ids.additionalInfo].join(' ')}
|
|
127
|
+
>
|
|
128
|
+
{media && <div className="wds-list-item-media">{media}</div>}
|
|
122
129
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
</span>
|
|
141
|
-
{(valueTitle || valueSubtitle) && (
|
|
142
|
-
<span
|
|
143
|
-
id={ids.value}
|
|
144
|
-
className={clsx('wds-list-item-value', 'd-flex align-items-center', {
|
|
145
|
-
'flex-column': valueTitle !== undefined && valueSubtitle !== undefined,
|
|
146
|
-
})}
|
|
147
|
-
>
|
|
148
|
-
{valueTitle && (
|
|
149
|
-
<Body type={Typography.BODY_LARGE_BOLD} className="wds-list-item-title-value">
|
|
150
|
-
{valueTitle}
|
|
151
|
-
</Body>
|
|
152
|
-
)}
|
|
153
|
-
{valueSubtitle && (
|
|
154
|
-
<Body className="wds-list-item-subtitle-value">{valueSubtitle}</Body>
|
|
155
|
-
)}
|
|
130
|
+
{/* Title + Subtitle + Values + Additional Info - Group */}
|
|
131
|
+
<div className="wds-list-item-body">
|
|
132
|
+
{/* Title + Subtitle + Values - Group */}
|
|
133
|
+
<div className="d-flex justify-content-between">
|
|
134
|
+
<span>
|
|
135
|
+
{/* @ts-expect-error div can have role and aria-lavel props */}
|
|
136
|
+
<Body
|
|
137
|
+
type={Typography.BODY_LARGE_BOLD}
|
|
138
|
+
className="wds-list-item-title"
|
|
139
|
+
// for a11y this needs to be a header but for SEO it shouldn't be `h*` tag
|
|
140
|
+
// so we enable header semantics via `role` and `aria-level` attrs
|
|
141
|
+
role="heading"
|
|
142
|
+
aria-level="4"
|
|
143
|
+
>
|
|
144
|
+
{title}
|
|
145
|
+
</Body>
|
|
146
|
+
<Body className="wds-list-item-subtitle">{subtitle}</Body>
|
|
156
147
|
</span>
|
|
157
|
-
|
|
158
|
-
|
|
148
|
+
{(valueTitle || valueSubtitle) && (
|
|
149
|
+
<span
|
|
150
|
+
id={ids.value}
|
|
151
|
+
className={clsx('wds-list-item-value', 'd-flex align-items-center', {
|
|
152
|
+
'flex-column': valueTitle !== undefined && valueSubtitle !== undefined,
|
|
153
|
+
})}
|
|
154
|
+
>
|
|
155
|
+
{valueTitle && (
|
|
156
|
+
<Body type={Typography.BODY_LARGE_BOLD} className="wds-list-item-title-value">
|
|
157
|
+
{valueTitle}
|
|
158
|
+
</Body>
|
|
159
|
+
)}
|
|
160
|
+
{valueSubtitle && (
|
|
161
|
+
<Body className="wds-list-item-subtitle-value">{valueSubtitle}</Body>
|
|
162
|
+
)}
|
|
163
|
+
</span>
|
|
164
|
+
)}
|
|
165
|
+
</div>
|
|
159
166
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
167
|
+
{/* Additional Info and Prompt here */}
|
|
168
|
+
{Boolean(subtitle) && additionalInfo}
|
|
169
|
+
</div>
|
|
170
|
+
{control === null ? null : <Body className="wds-list-item-control">{control}</Body>}
|
|
171
|
+
{prompt}
|
|
172
|
+
</View>
|
|
173
|
+
</ListItemContext.Provider>
|
|
166
174
|
);
|
|
167
|
-
|
|
168
|
-
if (controlType === 'radio' && ids.control) {
|
|
169
|
-
return (
|
|
170
|
-
<ListItemContext.Provider value={listItemContext}>
|
|
171
|
-
<label htmlFor={ids.control}>{content}</label>
|
|
172
|
-
</ListItemContext.Provider>
|
|
173
|
-
);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return <ListItemContext.Provider value={listItemContext}>{content}</ListItemContext.Provider>;
|
|
177
175
|
};
|
|
178
176
|
|
|
179
177
|
/* eslint-disable functional/immutable-data */
|
|
@@ -184,7 +182,6 @@ ListItem.AdditionalInfo = AdditionalInfo;
|
|
|
184
182
|
ListItem.Checkbox = Checkbox;
|
|
185
183
|
ListItem.IconButton = IconButton;
|
|
186
184
|
ListItem.Navigation = Navigation;
|
|
187
|
-
ListItem.Radio = Radio;
|
|
188
185
|
ListItem.Button = Button;
|
|
189
186
|
ListItem.Switch = Switch;
|
|
190
187
|
ListItem.Prompt = Prompt;
|
|
@@ -2,15 +2,11 @@ import { useContext, useEffect } from 'react';
|
|
|
2
2
|
import { ListItemContext, ListItemContextData, ListItemTypes } from './ListItem';
|
|
3
3
|
|
|
4
4
|
export function useItemControl(controlType: ListItemTypes) {
|
|
5
|
-
const {
|
|
6
|
-
ids,
|
|
7
|
-
setControlType,
|
|
8
|
-
props: baseItemProps,
|
|
9
|
-
} = useContext<ListItemContextData>(ListItemContext);
|
|
5
|
+
const { setControlType, props: baseItemProps } = useContext<ListItemContextData>(ListItemContext);
|
|
10
6
|
|
|
11
7
|
useEffect(() => {
|
|
12
8
|
setControlType(controlType);
|
|
13
9
|
}, [controlType, setControlType]);
|
|
14
10
|
|
|
15
|
-
return {
|
|
11
|
+
return { baseItemProps };
|
|
16
12
|
}
|
package/src/main.css
CHANGED
|
@@ -1402,6 +1402,7 @@
|
|
|
1402
1402
|
}
|
|
1403
1403
|
.np-circular-btn-primary-default .np-circular-btn-label,
|
|
1404
1404
|
.np-circular-btn-secondary-default .np-circular-btn-label {
|
|
1405
|
+
text-align: center;
|
|
1405
1406
|
color: var(--color-interactive-primary);
|
|
1406
1407
|
}
|
|
1407
1408
|
.np-circular-btn-primary-default .np-circular-btn-label:not(.disabled):not(:disabled):hover,
|
|
@@ -2705,10 +2706,10 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
|
|
|
2705
2706
|
background-color: rgba(134,167,189,0.10196);
|
|
2706
2707
|
background-color: var(--color-background-neutral);
|
|
2707
2708
|
}
|
|
2708
|
-
.wds-list-item-spotlight-active:hover {
|
|
2709
|
+
.wds-list-item-spotlight-active:not(.disabled):not(:disabled):hover {
|
|
2709
2710
|
background-color: var(--color-background-neutral-hover);
|
|
2710
2711
|
}
|
|
2711
|
-
.wds-list-item-spotlight-active:active {
|
|
2712
|
+
.wds-list-item-spotlight-active:not(.disabled):not(:disabled):active {
|
|
2712
2713
|
background-color: var(--color-background-neutral-active);
|
|
2713
2714
|
}
|
|
2714
2715
|
.wds-list-item-spotlight-inactive {
|
|
@@ -2721,10 +2722,10 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
|
|
|
2721
2722
|
background-color: color-mix(in srgb, var(--color-background-neutral) 25%, transparent);
|
|
2722
2723
|
}
|
|
2723
2724
|
}
|
|
2724
|
-
.wds-list-item-spotlight-inactive:hover {
|
|
2725
|
+
.wds-list-item-spotlight-inactive:not(.disabled):not(:disabled):hover {
|
|
2725
2726
|
background-color: color-mix(in srgb, var(--color-background-neutral-hover) 25%, transparent);
|
|
2726
2727
|
}
|
|
2727
|
-
.wds-list-item-spotlight-inactive:active {
|
|
2728
|
+
.wds-list-item-spotlight-inactive:not(.disabled):not(:disabled):active {
|
|
2728
2729
|
background-color: color-mix(in srgb, var(--color-background-neutral-active) 25%, transparent);
|
|
2729
2730
|
}
|
|
2730
2731
|
.wds-list-item-prompt {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ListItemRadio.d.ts","sourceRoot":"","sources":["../../../src/listItem/ListItemRadio.tsx"],"names":[],"mappings":"AAAA,OAAoB,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAGlF,eAAO,MAAM,KAAK,GAAa,OAAO,gBAAgB,gCAIrD,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import RadioButton, { RadioButtonProps } from '../common/RadioButton/RadioButton';
|
|
2
|
-
import { useItemControl } from './useItemControl';
|
|
3
|
-
|
|
4
|
-
export const Radio = function (props: RadioButtonProps) {
|
|
5
|
-
const { ids, baseItemProps } = useItemControl('radio');
|
|
6
|
-
|
|
7
|
-
return <RadioButton disabled={baseItemProps.disabled} {...props} id={ids.control} />;
|
|
8
|
-
};
|