@transferwise/components 0.0.0-experimental-22400c4 → 0.0.0-experimental-1c8c18d
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/types/listItem/ListItem.d.ts +3 -2
- package/build/types/listItem/ListItem.d.ts.map +1 -1
- package/build/types/listItem/ListItemIconButton.d.ts +1 -0
- package/build/types/listItem/ListItemIconButton.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/listItem/ListItem.story.tsx +20 -0
- package/src/listItem/ListItem.tsx +10 -4
- package/src/listItem/ListItemIconButton.tsx +5 -2
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
import { ListItemIconButtonProps } from './ListItemIconButton';
|
|
2
3
|
import { ListItemCheckboxProps } from './ListItemCheckbox';
|
|
3
4
|
import { ListItemNavigationProps } from './ListItemNavigation';
|
|
4
5
|
import { ListItemButtonProps } from './ListItemButton';
|
|
5
6
|
export type ListItemTypes = 'non-interactive' | 'navigation' | 'radio' | 'checkbox' | 'switch' | 'button' | 'icon-button';
|
|
6
|
-
export type ListItemControlProps = ListItemNavigationProps | ListItemCheckboxProps | ListItemButtonProps;
|
|
7
|
+
export type ListItemControlProps = ListItemNavigationProps | ListItemCheckboxProps | ListItemButtonProps | ListItemIconButtonProps;
|
|
7
8
|
export type Props = {
|
|
8
9
|
as?: 'li' | 'div' | 'span';
|
|
9
10
|
inverted?: boolean;
|
|
@@ -39,7 +40,7 @@ export declare const ListItem: {
|
|
|
39
40
|
AvatarLayout: ({ className, size, ...props }: import("./ListItemMedia").ListItemAvatarLayoutProps) => import("react").JSX.Element;
|
|
40
41
|
AdditionalInfo: ({ children, action }: import("./ListItemAdditionalInfo").ListItemAdditionalInfoProps) => import("react").JSX.Element;
|
|
41
42
|
Checkbox: (props: ListItemCheckboxProps) => import("react").JSX.Element;
|
|
42
|
-
IconButton: (props:
|
|
43
|
+
IconButton: (props: ListItemIconButtonProps) => import("react").JSX.Element;
|
|
43
44
|
Navigation: ({ href, ...props }: ListItemNavigationProps) => import("react").JSX.Element;
|
|
44
45
|
Button: ({ priority, partiallyInteractive, ...props }: ListItemButtonProps) => import("react").JSX.Element;
|
|
45
46
|
Switch: (props: import("..").SwitchProps) => import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.d.ts","sourceRoot":"","sources":["../../../src/listItem/ListItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,SAAS,EAIV,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ListItem.d.ts","sourceRoot":"","sources":["../../../src/listItem/ListItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,SAAS,EAIV,MAAM,OAAO,CAAC;AAIf,OAAO,EAAc,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAY,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAc,MAAM,sBAAsB,CAAC;AAE3E,OAAO,EAAU,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAO/D,MAAM,MAAM,aAAa,GACrB,iBAAiB,GACjB,YAAY,GACZ,OAAO,GACP,UAAU,GACV,QAAQ,GACR,QAAQ,GACR,aAAa,CAAC;AAElB,MAAM,MAAM,oBAAoB,GAC5B,uBAAuB,GAEvB,qBAAqB,GACrB,mBAAmB,GACnB,uBAAuB,CAAC;AAE5B,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,eAAe,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAC;IACvD,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,UAAU,GAAG,UAAU,CAAC,CAAC;CAC7C,CAAC;AAIF,eAAO,MAAM,eAAe,8CAA2C,CAAC;AAExE,eAAO,MAAM,QAAQ;6JAclB,KAAK;;;;;;;;;;;CA8GP,CAAC;AAqFF,eAAe,QAAQ,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { IconButtonProps } from '../iconButton';
|
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
export type ListItemIconButtonProps = Pick<IconButtonProps, 'onClick' | 'href' | 'target'> & {
|
|
4
4
|
children: ReactNode;
|
|
5
|
+
partiallyInteractive?: boolean;
|
|
5
6
|
};
|
|
6
7
|
export declare const IconButton: (props: ListItemIconButtonProps) => import("react").JSX.Element;
|
|
7
8
|
//# sourceMappingURL=ListItemIconButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItemIconButton.d.ts","sourceRoot":"","sources":["../../../src/listItem/ListItemIconButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,eAAe,EAAE,MAAM,eAAe,CAAC;AAE3E,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,eAAe,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC,GAAG;IAC3F,QAAQ,EAAE,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"ListItemIconButton.d.ts","sourceRoot":"","sources":["../../../src/listItem/ListItemIconButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,eAAe,EAAE,MAAM,eAAe,CAAC;AAE3E,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,eAAe,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC,GAAG;IAC3F,QAAQ,EAAE,SAAS,CAAC;IACpB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF,eAAO,MAAM,UAAU,GAAa,OAAO,uBAAuB,gCAMjE,CAAC"}
|
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-1c8c18d",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -91,8 +91,8 @@
|
|
|
91
91
|
"rollup": "^4.41.1",
|
|
92
92
|
"rollup-preserve-directives": "^1.1.3",
|
|
93
93
|
"storybook": "^8.6.14",
|
|
94
|
-
"@transferwise/neptune-css": "14.24.4",
|
|
95
94
|
"@transferwise/less-config": "3.1.2",
|
|
95
|
+
"@transferwise/neptune-css": "14.24.4",
|
|
96
96
|
"@wise/components-theming": "1.6.3",
|
|
97
97
|
"@wise/wds-configs": "0.0.0"
|
|
98
98
|
},
|
|
@@ -433,6 +433,26 @@ export const ButtonInteractivity: Story = {
|
|
|
433
433
|
</ListItem.Button>
|
|
434
434
|
}
|
|
435
435
|
/>
|
|
436
|
+
<ListItem
|
|
437
|
+
title="Fully interactive"
|
|
438
|
+
subtitle={lorem10}
|
|
439
|
+
additionalInfo={<ListItem.AdditionalInfo>{lorem20}</ListItem.AdditionalInfo>}
|
|
440
|
+
control={
|
|
441
|
+
<ListItem.IconButton onClick={() => setClicked(clicked + 1)}>
|
|
442
|
+
<Plus />
|
|
443
|
+
</ListItem.IconButton>
|
|
444
|
+
}
|
|
445
|
+
/>
|
|
446
|
+
<ListItem
|
|
447
|
+
title="Partially interactive"
|
|
448
|
+
subtitle={lorem10}
|
|
449
|
+
additionalInfo={<ListItem.AdditionalInfo>{lorem20}</ListItem.AdditionalInfo>}
|
|
450
|
+
control={
|
|
451
|
+
<ListItem.IconButton partiallyInteractive onClick={() => setClicked(clicked + 1)}>
|
|
452
|
+
<Plus />
|
|
453
|
+
</ListItem.IconButton>
|
|
454
|
+
}
|
|
455
|
+
/>
|
|
436
456
|
</>
|
|
437
457
|
);
|
|
438
458
|
},
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import { Typography } from '../common';
|
|
11
11
|
import Body from '../body';
|
|
12
12
|
import { AdditionalInfo } from './ListItemAdditionalInfo';
|
|
13
|
-
import { IconButton } from './ListItemIconButton';
|
|
13
|
+
import { IconButton, ListItemIconButtonProps } from './ListItemIconButton';
|
|
14
14
|
import { Checkbox, ListItemCheckboxProps } from './ListItemCheckbox';
|
|
15
15
|
import { ListItemNavigationProps, Navigation } from './ListItemNavigation';
|
|
16
16
|
import { clsx } from 'clsx';
|
|
@@ -34,7 +34,8 @@ export type ListItemControlProps =
|
|
|
34
34
|
| ListItemNavigationProps
|
|
35
35
|
// TODO: add more types for control props here;
|
|
36
36
|
| ListItemCheckboxProps
|
|
37
|
-
| ListItemButtonProps
|
|
37
|
+
| ListItemButtonProps
|
|
38
|
+
| ListItemIconButtonProps;
|
|
38
39
|
|
|
39
40
|
export type Props = {
|
|
40
41
|
as?: 'li' | 'div' | 'span';
|
|
@@ -133,7 +134,8 @@ export const ListItem = ({
|
|
|
133
134
|
{
|
|
134
135
|
'wds-list-item-interactive':
|
|
135
136
|
controlType !== 'non-interactive' &&
|
|
136
|
-
!(controlProps as ListItemButtonProps)
|
|
137
|
+
!(controlProps as ListItemButtonProps | ListItemIconButtonProps)
|
|
138
|
+
?.partiallyInteractive,
|
|
137
139
|
},
|
|
138
140
|
`wds-list-item-${controlType}`,
|
|
139
141
|
{
|
|
@@ -202,9 +204,13 @@ type ViewProps = PropsWithChildren<{
|
|
|
202
204
|
|
|
203
205
|
function View({ children, prompt, controlType = 'non-interactive', controlProps }: ViewProps) {
|
|
204
206
|
const isLinkControl = ['navigation' /* TODO: add other link controls */].includes(controlType);
|
|
207
|
+
|
|
205
208
|
const isPartiallyInteractive =
|
|
206
209
|
(controlType === 'button' || controlType === 'icon-button') &&
|
|
207
|
-
!!(
|
|
210
|
+
!!(
|
|
211
|
+
controlProps &&
|
|
212
|
+
(controlProps as ListItemButtonProps | ListItemIconButtonProps).partiallyInteractive
|
|
213
|
+
);
|
|
208
214
|
const isHrefProvided = isLinkControl
|
|
209
215
|
? (controlProps as ListItemNavigationProps)?.href !== '#'
|
|
210
216
|
: false;
|
|
@@ -4,10 +4,13 @@ import { ReactNode } from 'react';
|
|
|
4
4
|
|
|
5
5
|
export type ListItemIconButtonProps = Pick<IconButtonProps, 'onClick' | 'href' | 'target'> & {
|
|
6
6
|
children: ReactNode;
|
|
7
|
+
partiallyInteractive?: boolean;
|
|
7
8
|
};
|
|
8
9
|
|
|
9
10
|
export const IconButton = function (props: ListItemIconButtonProps) {
|
|
10
|
-
const {
|
|
11
|
+
const { partiallyInteractive, ...restProps } = props;
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
const { baseItemProps } = useItemControl('icon-button', { partiallyInteractive, ...restProps });
|
|
14
|
+
|
|
15
|
+
return <IconButtonComp {...restProps} size={32} disabled={baseItemProps.disabled} />;
|
|
13
16
|
};
|