@transferwise/components 0.0.0-experimental-e72bc9f → 0.0.0-experimental-7646a35

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.
@@ -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;
@@ -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;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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,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "0.0.0-experimental-e72bc9f",
3
+ "version": "0.0.0-experimental-7646a35",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -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 { FastFlag, MultiCurrency, Plus, Receipt, Savings } from '@transferwise/icons';
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';
@@ -138,16 +146,30 @@ export const TempPlayground: Story = {
138
146
  />
139
147
 
140
148
  <ListItem
149
+ media={
150
+ <ListItem.AvatarView>
151
+ <Bank />
152
+ </ListItem.AvatarView>
153
+ }
154
+ spotlight="inactive"
141
155
  title="Test title"
142
- subtitle={lorem10}
143
- additionalInfo={<ListItem.AdditionalInfo>{lorem20}</ListItem.AdditionalInfo>}
156
+ subtitle={lorem5}
157
+ additionalInfo={<ListItem.AdditionalInfo>{lorem10}</ListItem.AdditionalInfo>}
144
158
  control={<ListItem.Checkbox indeterminate />}
159
+ className="m-t-2"
145
160
  />
146
161
 
147
162
  <ListItem
163
+ media={
164
+ <ListItem.AvatarLayout
165
+ orientation="diagonal"
166
+ avatars={[{ asset: <BankTransfer /> }, { asset: <Bank /> }]}
167
+ />
168
+ }
169
+ spotlight="active"
148
170
  title="Test title"
149
- subtitle={lorem10}
150
- additionalInfo={<ListItem.AdditionalInfo>{lorem20}</ListItem.AdditionalInfo>}
171
+ subtitle={lorem5}
172
+ additionalInfo={<ListItem.AdditionalInfo>{lorem10}</ListItem.AdditionalInfo>}
151
173
  control={
152
174
  <ListItem.Switch
153
175
  checked={checked}
@@ -156,6 +178,7 @@ export const TempPlayground: Story = {
156
178
  }}
157
179
  />
158
180
  }
181
+ className="m-t-2 m-b-4"
159
182
  />
160
183
  </div>
161
184
  );
@@ -33,6 +33,7 @@ export type Props = {
33
33
  media?: ReactNode;
34
34
  control?: ReactNode;
35
35
  prompt?: ReactNode;
36
+ className?: string;
36
37
  };
37
38
 
38
39
  export type ListItemContextData = {
@@ -64,6 +65,7 @@ export const ListItem = ({
64
65
  valueSubtitle,
65
66
  control = null,
66
67
  disabled,
68
+ className,
67
69
  }: Props) => {
68
70
  /*
69
71
  const returnType = (): ReactNode => {
@@ -98,6 +100,10 @@ export const ListItem = ({
98
100
  additionalInfo: `${idPrefix}_additional-info`,
99
101
  };
100
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
+
101
107
  const listItemContext = useMemo(
102
108
  () => ({ setControlType, ids, props: { as: View, disabled, inverted } }),
103
109
  [],
@@ -113,8 +119,9 @@ export const ListItem = ({
113
119
  'd-flex flex-row',
114
120
  { 'align-items-center': !subtitle },
115
121
  {
116
- [`wds-list-item-spotlight-${spotlight}`]: !!spotlight,
122
+ [`wds-list-item-spotlight-${spotlight}`]: isFullyInteractive && !!spotlight,
117
123
  },
124
+ className,
118
125
  )}
119
126
  aria-describedby={[ids.additionalInfo].join(' ')}
120
127
  >