@transferwise/components 46.170.0 → 46.171.0
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/ListItem/Navigation/ListItemNavigation.js +9 -4
- package/build/ListItem/Navigation/ListItemNavigation.js.map +1 -1
- package/build/ListItem/Navigation/ListItemNavigation.mjs +9 -4
- package/build/ListItem/Navigation/ListItemNavigation.mjs.map +1 -1
- package/build/types/ListItem/ListItem.d.ts +1 -1
- package/build/types/ListItem/Navigation/ListItemNavigation.d.ts +2 -1
- package/build/types/ListItem/Navigation/ListItemNavigation.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ListItem/Navigation/ListItemNavigation.test.tsx +7 -0
- package/src/ListItem/Navigation/ListItemNavigation.tsx +15 -4
|
@@ -11,14 +11,17 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
11
11
|
const Navigation = function Navigation({
|
|
12
12
|
href,
|
|
13
13
|
hideIndicator,
|
|
14
|
-
|
|
14
|
+
target,
|
|
15
|
+
onClick,
|
|
16
|
+
...dataAttributes
|
|
15
17
|
}) {
|
|
16
18
|
const {
|
|
17
19
|
baseItemProps
|
|
18
20
|
} = useListItemControl.useListItemControl('navigation', {
|
|
19
21
|
href,
|
|
20
22
|
hideIndicator,
|
|
21
|
-
|
|
23
|
+
target,
|
|
24
|
+
onClick
|
|
22
25
|
});
|
|
23
26
|
const {
|
|
24
27
|
ids,
|
|
@@ -26,16 +29,18 @@ const Navigation = function Navigation({
|
|
|
26
29
|
} = React.useContext(ListItemContext.ListItemContext);
|
|
27
30
|
const icon = hideIndicator ? null : /*#__PURE__*/jsxRuntime.jsx(icons.ChevronEnd, {
|
|
28
31
|
size: 16,
|
|
29
|
-
"data-testid": "NavigationIndicator"
|
|
32
|
+
"data-testid": "NavigationIndicator",
|
|
33
|
+
...dataAttributes
|
|
30
34
|
});
|
|
31
35
|
return href ? /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
32
36
|
children: icon
|
|
33
37
|
}) : /*#__PURE__*/jsxRuntime.jsx(PrimitiveButton.default, {
|
|
38
|
+
...dataAttributes,
|
|
34
39
|
disabled: baseItemProps.disabled,
|
|
35
40
|
"aria-describedby": describedByIds,
|
|
36
41
|
id: ids.control,
|
|
37
42
|
className: "btn-unstyled wds-list-item-control",
|
|
38
|
-
onClick:
|
|
43
|
+
onClick: onClick,
|
|
39
44
|
children: icon
|
|
40
45
|
});
|
|
41
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItemNavigation.js","sources":["../../../src/ListItem/Navigation/ListItemNavigation.tsx"],"sourcesContent":["import { ChevronEnd } from '@transferwise/icons';\nimport type { ButtonProps } from '../../Button/Button.types';\nimport { useListItemControl } from '../useListItemControl';\nimport { PrimitiveButton } from '../../Primitives';\nimport { useContext } from 'react';\nimport { ListItemContext } from '../ListItemContext';\n\nexport type ListItemNavigationProps = Pick<ButtonProps, 'onClick' | 'href' | 'target'> & {\n /**\n * When `true`, the chevron indicator is hidden. Use when surrounding context makes the\n * interactive affordance clear without a directional cue (e.g. a widget row with trailing\n * value content).<br />\n * **NB:** This feature should be used with great care as it can result in the item looking\n * as non-interactive, significantly degrading accessibility, UX, and conversion,\n * especially if used on busy screens with multiple Lists.\n */\n hideIndicator?: boolean;\n};\n\n/**\n * This component allows for rendering a control functionally synonymous with HTML `anchor` or a\n * `button`, giving users a rich way to choose between options and navigate to another screen or\n * step in a flow. It offers only a subset of features of the HTML element in line with the\n * ListItem's constraints.<br />\n * <br />\n * Please refer to the [Design documentation](https://docs.wise.design/components/list-item---navigation) for details.\n */\nexport const Navigation = function Navigation({\n href,\n hideIndicator,\n ...
|
|
1
|
+
{"version":3,"file":"ListItemNavigation.js","sources":["../../../src/ListItem/Navigation/ListItemNavigation.tsx"],"sourcesContent":["import { ChevronEnd } from '@transferwise/icons';\nimport type { ButtonProps } from '../../Button/Button.types';\nimport { useListItemControl } from '../useListItemControl';\nimport { PrimitiveButton } from '../../Primitives';\nimport { useContext } from 'react';\nimport { ListItemContext } from '../ListItemContext';\n\nexport type ListItemNavigationProps = Pick<ButtonProps, 'onClick' | 'href' | 'target'> & {\n /**\n * When `true`, the chevron indicator is hidden. Use when surrounding context makes the\n * interactive affordance clear without a directional cue (e.g. a widget row with trailing\n * value content).<br />\n * **NB:** This feature should be used with great care as it can result in the item looking\n * as non-interactive, significantly degrading accessibility, UX, and conversion,\n * especially if used on busy screens with multiple Lists.\n */\n hideIndicator?: boolean;\n [key: `data-${string}`]: string | number | boolean | undefined;\n};\n\n/**\n * This component allows for rendering a control functionally synonymous with HTML `anchor` or a\n * `button`, giving users a rich way to choose between options and navigate to another screen or\n * step in a flow. It offers only a subset of features of the HTML element in line with the\n * ListItem's constraints.<br />\n * <br />\n * Please refer to the [Design documentation](https://docs.wise.design/components/list-item---navigation) for details.\n */\nexport const Navigation = function Navigation({\n href,\n hideIndicator,\n target,\n onClick,\n ...dataAttributes\n}: ListItemNavigationProps) {\n const { baseItemProps } = useListItemControl('navigation', {\n href,\n hideIndicator,\n target,\n onClick,\n });\n const { ids, describedByIds } = useContext(ListItemContext);\n const icon = hideIndicator ? null : (\n <ChevronEnd size={16} data-testid=\"NavigationIndicator\" {...dataAttributes} />\n );\n\n return href ? (\n <>{icon}</>\n ) : (\n <PrimitiveButton\n {...dataAttributes}\n disabled={baseItemProps.disabled}\n aria-describedby={describedByIds}\n id={ids.control}\n className=\"btn-unstyled wds-list-item-control\"\n onClick={onClick as React.MouseEventHandler<HTMLButtonElement> | undefined}\n >\n {icon}\n </PrimitiveButton>\n );\n};\n\nNavigation.displayName = 'ListItem.Navigation';\n"],"names":["Navigation","href","hideIndicator","target","onClick","dataAttributes","baseItemProps","useListItemControl","ids","describedByIds","useContext","ListItemContext","icon","_jsx","ChevronEnd","size","_Fragment","children","PrimitiveButton","disabled","id","control","className","displayName"],"mappings":";;;;;;;;;;AA4BO,MAAMA,UAAU,GAAG,SAASA,UAAUA,CAAC;EAC5CC,IAAI;EACJC,aAAa;EACbC,MAAM;EACNC,OAAO;EACP,GAAGC;AAAc,CACO,EAAA;EACxB,MAAM;AAAEC,IAAAA;AAAa,GAAE,GAAGC,qCAAkB,CAAC,YAAY,EAAE;IACzDN,IAAI;IACJC,aAAa;IACbC,MAAM;AACNC,IAAAA;AACD,GAAA,CAAC;EACF,MAAM;IAAEI,GAAG;AAAEC,IAAAA;AAAc,GAAE,GAAGC,gBAAU,CAACC,+BAAe,CAAC;EAC3D,MAAMC,IAAI,GAAGV,aAAa,GAAG,IAAI,gBAC/BW,cAAA,CAACC,gBAAU,EAAA;AAACC,IAAAA,IAAI,EAAE,EAAG;AAAC,IAAA,aAAA,EAAY,qBAAqB;IAAA,GAAKV;AAAc,GAAC,CAC5E;AAED,EAAA,OAAOJ,IAAI,gBACTY,cAAA,CAAAG,mBAAA,EAAA;AAAAC,IAAAA,QAAA,EAAGL;AAAI,GAAC,CAAG,gBAEXC,cAAA,CAACK,uBAAe,EAAA;AAAA,IAAA,GACVb,cAAc;IAClBc,QAAQ,EAAEb,aAAa,CAACa,QAAS;AACjC,IAAA,kBAAA,EAAkBV,cAAe;IACjCW,EAAE,EAAEZ,GAAG,CAACa,OAAQ;AAChBC,IAAAA,SAAS,EAAC,oCAAoC;AAC9ClB,IAAAA,OAAO,EAAEA,OAAkE;AAAAa,IAAAA,QAAA,EAE1EL;AAAI,GACU,CAClB;AACH;AAEAZ,UAAU,CAACuB,WAAW,GAAG,qBAAqB;;"}
|
|
@@ -9,14 +9,17 @@ import { jsx, Fragment } from 'react/jsx-runtime';
|
|
|
9
9
|
const Navigation = function Navigation({
|
|
10
10
|
href,
|
|
11
11
|
hideIndicator,
|
|
12
|
-
|
|
12
|
+
target,
|
|
13
|
+
onClick,
|
|
14
|
+
...dataAttributes
|
|
13
15
|
}) {
|
|
14
16
|
const {
|
|
15
17
|
baseItemProps
|
|
16
18
|
} = useListItemControl('navigation', {
|
|
17
19
|
href,
|
|
18
20
|
hideIndicator,
|
|
19
|
-
|
|
21
|
+
target,
|
|
22
|
+
onClick
|
|
20
23
|
});
|
|
21
24
|
const {
|
|
22
25
|
ids,
|
|
@@ -24,16 +27,18 @@ const Navigation = function Navigation({
|
|
|
24
27
|
} = useContext(ListItemContext);
|
|
25
28
|
const icon = hideIndicator ? null : /*#__PURE__*/jsx(ChevronEnd, {
|
|
26
29
|
size: 16,
|
|
27
|
-
"data-testid": "NavigationIndicator"
|
|
30
|
+
"data-testid": "NavigationIndicator",
|
|
31
|
+
...dataAttributes
|
|
28
32
|
});
|
|
29
33
|
return href ? /*#__PURE__*/jsx(Fragment, {
|
|
30
34
|
children: icon
|
|
31
35
|
}) : /*#__PURE__*/jsx(PrimitiveButton, {
|
|
36
|
+
...dataAttributes,
|
|
32
37
|
disabled: baseItemProps.disabled,
|
|
33
38
|
"aria-describedby": describedByIds,
|
|
34
39
|
id: ids.control,
|
|
35
40
|
className: "btn-unstyled wds-list-item-control",
|
|
36
|
-
onClick:
|
|
41
|
+
onClick: onClick,
|
|
37
42
|
children: icon
|
|
38
43
|
});
|
|
39
44
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItemNavigation.mjs","sources":["../../../src/ListItem/Navigation/ListItemNavigation.tsx"],"sourcesContent":["import { ChevronEnd } from '@transferwise/icons';\nimport type { ButtonProps } from '../../Button/Button.types';\nimport { useListItemControl } from '../useListItemControl';\nimport { PrimitiveButton } from '../../Primitives';\nimport { useContext } from 'react';\nimport { ListItemContext } from '../ListItemContext';\n\nexport type ListItemNavigationProps = Pick<ButtonProps, 'onClick' | 'href' | 'target'> & {\n /**\n * When `true`, the chevron indicator is hidden. Use when surrounding context makes the\n * interactive affordance clear without a directional cue (e.g. a widget row with trailing\n * value content).<br />\n * **NB:** This feature should be used with great care as it can result in the item looking\n * as non-interactive, significantly degrading accessibility, UX, and conversion,\n * especially if used on busy screens with multiple Lists.\n */\n hideIndicator?: boolean;\n};\n\n/**\n * This component allows for rendering a control functionally synonymous with HTML `anchor` or a\n * `button`, giving users a rich way to choose between options and navigate to another screen or\n * step in a flow. It offers only a subset of features of the HTML element in line with the\n * ListItem's constraints.<br />\n * <br />\n * Please refer to the [Design documentation](https://docs.wise.design/components/list-item---navigation) for details.\n */\nexport const Navigation = function Navigation({\n href,\n hideIndicator,\n ...
|
|
1
|
+
{"version":3,"file":"ListItemNavigation.mjs","sources":["../../../src/ListItem/Navigation/ListItemNavigation.tsx"],"sourcesContent":["import { ChevronEnd } from '@transferwise/icons';\nimport type { ButtonProps } from '../../Button/Button.types';\nimport { useListItemControl } from '../useListItemControl';\nimport { PrimitiveButton } from '../../Primitives';\nimport { useContext } from 'react';\nimport { ListItemContext } from '../ListItemContext';\n\nexport type ListItemNavigationProps = Pick<ButtonProps, 'onClick' | 'href' | 'target'> & {\n /**\n * When `true`, the chevron indicator is hidden. Use when surrounding context makes the\n * interactive affordance clear without a directional cue (e.g. a widget row with trailing\n * value content).<br />\n * **NB:** This feature should be used with great care as it can result in the item looking\n * as non-interactive, significantly degrading accessibility, UX, and conversion,\n * especially if used on busy screens with multiple Lists.\n */\n hideIndicator?: boolean;\n [key: `data-${string}`]: string | number | boolean | undefined;\n};\n\n/**\n * This component allows for rendering a control functionally synonymous with HTML `anchor` or a\n * `button`, giving users a rich way to choose between options and navigate to another screen or\n * step in a flow. It offers only a subset of features of the HTML element in line with the\n * ListItem's constraints.<br />\n * <br />\n * Please refer to the [Design documentation](https://docs.wise.design/components/list-item---navigation) for details.\n */\nexport const Navigation = function Navigation({\n href,\n hideIndicator,\n target,\n onClick,\n ...dataAttributes\n}: ListItemNavigationProps) {\n const { baseItemProps } = useListItemControl('navigation', {\n href,\n hideIndicator,\n target,\n onClick,\n });\n const { ids, describedByIds } = useContext(ListItemContext);\n const icon = hideIndicator ? null : (\n <ChevronEnd size={16} data-testid=\"NavigationIndicator\" {...dataAttributes} />\n );\n\n return href ? (\n <>{icon}</>\n ) : (\n <PrimitiveButton\n {...dataAttributes}\n disabled={baseItemProps.disabled}\n aria-describedby={describedByIds}\n id={ids.control}\n className=\"btn-unstyled wds-list-item-control\"\n onClick={onClick as React.MouseEventHandler<HTMLButtonElement> | undefined}\n >\n {icon}\n </PrimitiveButton>\n );\n};\n\nNavigation.displayName = 'ListItem.Navigation';\n"],"names":["Navigation","href","hideIndicator","target","onClick","dataAttributes","baseItemProps","useListItemControl","ids","describedByIds","useContext","ListItemContext","icon","_jsx","ChevronEnd","size","_Fragment","children","PrimitiveButton","disabled","id","control","className","displayName"],"mappings":";;;;;;;;AA4BO,MAAMA,UAAU,GAAG,SAASA,UAAUA,CAAC;EAC5CC,IAAI;EACJC,aAAa;EACbC,MAAM;EACNC,OAAO;EACP,GAAGC;AAAc,CACO,EAAA;EACxB,MAAM;AAAEC,IAAAA;AAAa,GAAE,GAAGC,kBAAkB,CAAC,YAAY,EAAE;IACzDN,IAAI;IACJC,aAAa;IACbC,MAAM;AACNC,IAAAA;AACD,GAAA,CAAC;EACF,MAAM;IAAEI,GAAG;AAAEC,IAAAA;AAAc,GAAE,GAAGC,UAAU,CAACC,eAAe,CAAC;EAC3D,MAAMC,IAAI,GAAGV,aAAa,GAAG,IAAI,gBAC/BW,GAAA,CAACC,UAAU,EAAA;AAACC,IAAAA,IAAI,EAAE,EAAG;AAAC,IAAA,aAAA,EAAY,qBAAqB;IAAA,GAAKV;AAAc,GAAC,CAC5E;AAED,EAAA,OAAOJ,IAAI,gBACTY,GAAA,CAAAG,QAAA,EAAA;AAAAC,IAAAA,QAAA,EAAGL;AAAI,GAAC,CAAG,gBAEXC,GAAA,CAACK,eAAe,EAAA;AAAA,IAAA,GACVb,cAAc;IAClBc,QAAQ,EAAEb,aAAa,CAACa,QAAS;AACjC,IAAA,kBAAA,EAAkBV,cAAe;IACjCW,EAAE,EAAEZ,GAAG,CAACa,OAAQ;AAChBC,IAAAA,SAAS,EAAC,oCAAoC;AAC9ClB,IAAAA,OAAO,EAAEA,OAAkE;AAAAa,IAAAA,QAAA,EAE1EL;AAAI,GACU,CAClB;AACH;AAEAZ,UAAU,CAACuB,WAAW,GAAG,qBAAqB;;"}
|
|
@@ -109,7 +109,7 @@ export declare const ListItem: {
|
|
|
109
109
|
displayName: string;
|
|
110
110
|
};
|
|
111
111
|
Navigation: {
|
|
112
|
-
({ href, hideIndicator, ...
|
|
112
|
+
({ href, hideIndicator, target, onClick, ...dataAttributes }: ListItemNavigationProps): import("react").JSX.Element;
|
|
113
113
|
displayName: string;
|
|
114
114
|
};
|
|
115
115
|
Button: import("react").ForwardRefExoticComponent<Omit<import("..").ButtonProps, "block" | "disabled" | "size" | "v2" | "addonStart"> & {
|
|
@@ -9,6 +9,7 @@ export type ListItemNavigationProps = Pick<ButtonProps, 'onClick' | 'href' | 'ta
|
|
|
9
9
|
* especially if used on busy screens with multiple Lists.
|
|
10
10
|
*/
|
|
11
11
|
hideIndicator?: boolean;
|
|
12
|
+
[key: `data-${string}`]: string | number | boolean | undefined;
|
|
12
13
|
};
|
|
13
14
|
/**
|
|
14
15
|
* This component allows for rendering a control functionally synonymous with HTML `anchor` or a
|
|
@@ -19,7 +20,7 @@ export type ListItemNavigationProps = Pick<ButtonProps, 'onClick' | 'href' | 'ta
|
|
|
19
20
|
* Please refer to the [Design documentation](https://docs.wise.design/components/list-item---navigation) for details.
|
|
20
21
|
*/
|
|
21
22
|
export declare const Navigation: {
|
|
22
|
-
({ href, hideIndicator, ...
|
|
23
|
+
({ href, hideIndicator, target, onClick, ...dataAttributes }: ListItemNavigationProps): import("react").JSX.Element;
|
|
23
24
|
displayName: string;
|
|
24
25
|
};
|
|
25
26
|
//# sourceMappingURL=ListItemNavigation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItemNavigation.d.ts","sourceRoot":"","sources":["../../../../src/ListItem/Navigation/ListItemNavigation.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAM7D,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC,GAAG;IACvF;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ListItemNavigation.d.ts","sourceRoot":"","sources":["../../../../src/ListItem/Navigation/ListItemNavigation.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAM7D,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC,GAAG;IACvF;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,CAAC,GAAG,EAAE,QAAQ,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;CAChE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU;kEAMpB,uBAAuB;;CA0BzB,CAAC"}
|
package/package.json
CHANGED
|
@@ -28,6 +28,13 @@ describe('ListItem.Navigation', () => {
|
|
|
28
28
|
expect(screen.queryByRole('button')).toBeDisabled();
|
|
29
29
|
expect(screen.queryByRole('link')).not.toBeInTheDocument();
|
|
30
30
|
});
|
|
31
|
+
|
|
32
|
+
it('passes data-* attributes to the button', () => {
|
|
33
|
+
renderWith({
|
|
34
|
+
control: <ListItem.Navigation data-tracking-id="nav-item" onClick={() => {}} />,
|
|
35
|
+
});
|
|
36
|
+
expect(screen.getByRole('button')).toHaveAttribute('data-tracking-id', 'nav-item');
|
|
37
|
+
});
|
|
31
38
|
});
|
|
32
39
|
|
|
33
40
|
describe('hideIndicator', () => {
|
|
@@ -15,6 +15,7 @@ export type ListItemNavigationProps = Pick<ButtonProps, 'onClick' | 'href' | 'ta
|
|
|
15
15
|
* especially if used on busy screens with multiple Lists.
|
|
16
16
|
*/
|
|
17
17
|
hideIndicator?: boolean;
|
|
18
|
+
[key: `data-${string}`]: string | number | boolean | undefined;
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
/**
|
|
@@ -28,21 +29,31 @@ export type ListItemNavigationProps = Pick<ButtonProps, 'onClick' | 'href' | 'ta
|
|
|
28
29
|
export const Navigation = function Navigation({
|
|
29
30
|
href,
|
|
30
31
|
hideIndicator,
|
|
31
|
-
|
|
32
|
+
target,
|
|
33
|
+
onClick,
|
|
34
|
+
...dataAttributes
|
|
32
35
|
}: ListItemNavigationProps) {
|
|
33
|
-
const { baseItemProps } = useListItemControl('navigation', {
|
|
36
|
+
const { baseItemProps } = useListItemControl('navigation', {
|
|
37
|
+
href,
|
|
38
|
+
hideIndicator,
|
|
39
|
+
target,
|
|
40
|
+
onClick,
|
|
41
|
+
});
|
|
34
42
|
const { ids, describedByIds } = useContext(ListItemContext);
|
|
35
|
-
const icon = hideIndicator ? null :
|
|
43
|
+
const icon = hideIndicator ? null : (
|
|
44
|
+
<ChevronEnd size={16} data-testid="NavigationIndicator" {...dataAttributes} />
|
|
45
|
+
);
|
|
36
46
|
|
|
37
47
|
return href ? (
|
|
38
48
|
<>{icon}</>
|
|
39
49
|
) : (
|
|
40
50
|
<PrimitiveButton
|
|
51
|
+
{...dataAttributes}
|
|
41
52
|
disabled={baseItemProps.disabled}
|
|
42
53
|
aria-describedby={describedByIds}
|
|
43
54
|
id={ids.control}
|
|
44
55
|
className="btn-unstyled wds-list-item-control"
|
|
45
|
-
onClick={
|
|
56
|
+
onClick={onClick as React.MouseEventHandler<HTMLButtonElement> | undefined}
|
|
46
57
|
>
|
|
47
58
|
{icon}
|
|
48
59
|
</PrimitiveButton>
|