@transferwise/components 46.169.1 → 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/IconButton/ListItemIconButton.js +2 -1
- package/build/ListItem/IconButton/ListItemIconButton.js.map +1 -1
- package/build/ListItem/IconButton/ListItemIconButton.mjs +2 -1
- package/build/ListItem/IconButton/ListItemIconButton.mjs.map +1 -1
- 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/IconButton/ListItemIconButton.d.ts +3 -1
- package/build/types/ListItem/IconButton/ListItemIconButton.d.ts.map +1 -1
- package/build/types/ListItem/ListItem.d.ts +2 -2
- package/build/types/ListItem/Navigation/ListItemNavigation.d.ts +2 -1
- package/build/types/ListItem/Navigation/ListItemNavigation.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/ListItem/IconButton/ListItemIconButton.test.tsx +38 -0
- package/src/ListItem/IconButton/ListItemIconButton.tsx +4 -1
- package/src/ListItem/IconButton/_stories/ListItemIconButton.story.tsx +35 -0
- package/src/ListItem/Navigation/ListItemNavigation.test.tsx +7 -0
- package/src/ListItem/Navigation/ListItemNavigation.tsx +15 -4
- package/src/Prompt/CriticalBanner/_stories/CriticalBanner.docs.mdx +7 -3
|
@@ -9,6 +9,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
9
9
|
|
|
10
10
|
const IconButton = function ({
|
|
11
11
|
priority = 'minimal',
|
|
12
|
+
size = 40,
|
|
12
13
|
'aria-label': ariaLabel,
|
|
13
14
|
...props
|
|
14
15
|
}) {
|
|
@@ -45,7 +46,7 @@ const IconButton = function ({
|
|
|
45
46
|
...getAriaProps(),
|
|
46
47
|
className: clsx.clsx('wds-list-item-control', !partiallyInteractive && props.href && 'wds-list-item-control_pseudo-element'),
|
|
47
48
|
id: ids.control,
|
|
48
|
-
size:
|
|
49
|
+
size: size,
|
|
49
50
|
priority: priority,
|
|
50
51
|
disabled: baseItemProps.disabled
|
|
51
52
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItemIconButton.js","sources":["../../../src/ListItem/IconButton/ListItemIconButton.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useContext, type ReactNode } from 'react';\nimport IconButtonComp, { type IconButtonProps } from '../../IconButton';\nimport { useListItemControl } from '../useListItemControl';\nimport { ListItemContext } from '../ListItemContext';\n\nexport type ListItemIconButtonProps = Pick<\n IconButtonProps,\n 'type' | 'onClick' | 'href' | 'target' | 'aria-label'\n> & {\n children: ReactNode;\n partiallyInteractive?: boolean;\n /** @default 'minimal' */\n priority?: IconButtonProps['priority'];\n};\n\n/**\n * This component allows for rendering a IconButton control. It's a thin wrapper around the\n * [IconButton component](https://storybook.wise.design/?path=/docs/actions-iconbutton--docs), but offers only\n * a subset of its features in line with the ListItem's constraints. <br />\n * <br />\n * Please refer to the [Design documentation](https://docs.wise.design/components/list-item---icon-button) for details.\n */\nexport const IconButton = function ({\n priority = 'minimal',\n 'aria-label': ariaLabel,\n ...props\n}: ListItemIconButtonProps) {\n const { partiallyInteractive, ...restProps } = props;\n\n const { ids, props: itemProps } = useContext(ListItemContext);\n const { baseItemProps } = useListItemControl('icon-button', {\n partiallyInteractive,\n ...restProps,\n });\n\n const getAriaProps = () => {\n const labelIds = [\n itemProps.inverted ? ids.subtitle : ids.title,\n itemProps.inverted ? ids.title : ids.subtitle,\n itemProps.inverted ? ids.valueSubtitle : ids.valueTitle,\n itemProps.inverted ? ids.valueTitle : ids.valueSubtitle,\n ].join(' ');\n const descriptorIds = [ids.additionalInfo, ids.prompt].join(' ');\n\n if (ariaLabel) {\n return {\n 'aria-label': ariaLabel,\n 'aria-describedby': labelIds.concat(descriptorIds),\n };\n }\n\n return {\n 'aria-labelledby': labelIds,\n 'aria-describedby': descriptorIds,\n };\n };\n\n return (\n <IconButtonComp\n {...restProps}\n {...getAriaProps()}\n className={clsx(\n 'wds-list-item-control',\n !partiallyInteractive && props.href && 'wds-list-item-control_pseudo-element',\n )}\n id={ids.control}\n size={
|
|
1
|
+
{"version":3,"file":"ListItemIconButton.js","sources":["../../../src/ListItem/IconButton/ListItemIconButton.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useContext, type ReactNode } from 'react';\nimport IconButtonComp, { type IconButtonProps } from '../../IconButton';\nimport { useListItemControl } from '../useListItemControl';\nimport { ListItemContext } from '../ListItemContext';\n\nexport type ListItemIconButtonProps = Pick<\n IconButtonProps,\n 'type' | 'onClick' | 'href' | 'target' | 'aria-label'\n> & {\n /** @default 40 */\n size?: 24 | 40;\n children: ReactNode;\n partiallyInteractive?: boolean;\n /** @default 'minimal' */\n priority?: IconButtonProps['priority'];\n};\n\n/**\n * This component allows for rendering a IconButton control. It's a thin wrapper around the\n * [IconButton component](https://storybook.wise.design/?path=/docs/actions-iconbutton--docs), but offers only\n * a subset of its features in line with the ListItem's constraints. <br />\n * <br />\n * Please refer to the [Design documentation](https://docs.wise.design/components/list-item---icon-button) for details.\n */\nexport const IconButton = function ({\n priority = 'minimal',\n size = 40,\n 'aria-label': ariaLabel,\n ...props\n}: ListItemIconButtonProps) {\n const { partiallyInteractive, ...restProps } = props;\n\n const { ids, props: itemProps } = useContext(ListItemContext);\n const { baseItemProps } = useListItemControl('icon-button', {\n partiallyInteractive,\n ...restProps,\n });\n\n const getAriaProps = () => {\n const labelIds = [\n itemProps.inverted ? ids.subtitle : ids.title,\n itemProps.inverted ? ids.title : ids.subtitle,\n itemProps.inverted ? ids.valueSubtitle : ids.valueTitle,\n itemProps.inverted ? ids.valueTitle : ids.valueSubtitle,\n ].join(' ');\n const descriptorIds = [ids.additionalInfo, ids.prompt].join(' ');\n\n if (ariaLabel) {\n return {\n 'aria-label': ariaLabel,\n 'aria-describedby': labelIds.concat(descriptorIds),\n };\n }\n\n return {\n 'aria-labelledby': labelIds,\n 'aria-describedby': descriptorIds,\n };\n };\n\n return (\n <IconButtonComp\n {...restProps}\n {...getAriaProps()}\n className={clsx(\n 'wds-list-item-control',\n !partiallyInteractive && props.href && 'wds-list-item-control_pseudo-element',\n )}\n id={ids.control}\n size={size}\n priority={priority}\n disabled={baseItemProps.disabled}\n />\n );\n};\n\nIconButton.displayName = 'ListItem.IconButton';\n"],"names":["IconButton","priority","size","ariaLabel","props","partiallyInteractive","restProps","ids","itemProps","useContext","ListItemContext","baseItemProps","useListItemControl","getAriaProps","labelIds","inverted","subtitle","title","valueSubtitle","valueTitle","join","descriptorIds","additionalInfo","prompt","concat","_jsx","IconButtonComp","className","clsx","href","id","control","disabled","displayName"],"mappings":";;;;;;;;;AAyBO,MAAMA,UAAU,GAAG,UAAU;AAClCC,EAAAA,QAAQ,GAAG,SAAS;AACpBC,EAAAA,IAAI,GAAG,EAAE;AACT,EAAA,YAAY,EAAEC,SAAS;EACvB,GAAGC;AAAK,CACgB,EAAA;EACxB,MAAM;IAAEC,oBAAoB;IAAE,GAAGC;AAAS,GAAE,GAAGF,KAAK;EAEpD,MAAM;IAAEG,GAAG;AAAEH,IAAAA,KAAK,EAAEI;AAAS,GAAE,GAAGC,gBAAU,CAACC,+BAAe,CAAC;EAC7D,MAAM;AAAEC,IAAAA;AAAa,GAAE,GAAGC,qCAAkB,CAAC,aAAa,EAAE;IAC1DP,oBAAoB;IACpB,GAAGC;AACJ,GAAA,CAAC;EAEF,MAAMO,YAAY,GAAGA,MAAK;IACxB,MAAMC,QAAQ,GAAG,CACfN,SAAS,CAACO,QAAQ,GAAGR,GAAG,CAACS,QAAQ,GAAGT,GAAG,CAACU,KAAK,EAC7CT,SAAS,CAACO,QAAQ,GAAGR,GAAG,CAACU,KAAK,GAAGV,GAAG,CAACS,QAAQ,EAC7CR,SAAS,CAACO,QAAQ,GAAGR,GAAG,CAACW,aAAa,GAAGX,GAAG,CAACY,UAAU,EACvDX,SAAS,CAACO,QAAQ,GAAGR,GAAG,CAACY,UAAU,GAAGZ,GAAG,CAACW,aAAa,CACxD,CAACE,IAAI,CAAC,GAAG,CAAC;AACX,IAAA,MAAMC,aAAa,GAAG,CAACd,GAAG,CAACe,cAAc,EAAEf,GAAG,CAACgB,MAAM,CAAC,CAACH,IAAI,CAAC,GAAG,CAAC;AAEhE,IAAA,IAAIjB,SAAS,EAAE;MACb,OAAO;AACL,QAAA,YAAY,EAAEA,SAAS;AACvB,QAAA,kBAAkB,EAAEW,QAAQ,CAACU,MAAM,CAACH,aAAa;OAClD;AACH,IAAA;IAEA,OAAO;AACL,MAAA,iBAAiB,EAAEP,QAAQ;AAC3B,MAAA,kBAAkB,EAAEO;KACrB;EACH,CAAC;EAED,oBACEI,cAAA,CAACC,oBAAc,EAAA;AAAA,IAAA,GACTpB,SAAS;IAAA,GACTO,YAAY,EAAE;AAClBc,IAAAA,SAAS,EAAEC,SAAI,CACb,uBAAuB,EACvB,CAACvB,oBAAoB,IAAID,KAAK,CAACyB,IAAI,IAAI,sCAAsC,CAC7E;IACFC,EAAE,EAAEvB,GAAG,CAACwB,OAAQ;AAChB7B,IAAAA,IAAI,EAAEA,IAAK;AACXD,IAAAA,QAAQ,EAAEA,QAAS;IACnB+B,QAAQ,EAAErB,aAAa,CAACqB;AAAS,GAAA,CACjC;AAEN;AAEAhC,UAAU,CAACiC,WAAW,GAAG,qBAAqB;;"}
|
|
@@ -7,6 +7,7 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
7
7
|
|
|
8
8
|
const IconButton = function ({
|
|
9
9
|
priority = 'minimal',
|
|
10
|
+
size = 40,
|
|
10
11
|
'aria-label': ariaLabel,
|
|
11
12
|
...props
|
|
12
13
|
}) {
|
|
@@ -43,7 +44,7 @@ const IconButton = function ({
|
|
|
43
44
|
...getAriaProps(),
|
|
44
45
|
className: clsx('wds-list-item-control', !partiallyInteractive && props.href && 'wds-list-item-control_pseudo-element'),
|
|
45
46
|
id: ids.control,
|
|
46
|
-
size:
|
|
47
|
+
size: size,
|
|
47
48
|
priority: priority,
|
|
48
49
|
disabled: baseItemProps.disabled
|
|
49
50
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItemIconButton.mjs","sources":["../../../src/ListItem/IconButton/ListItemIconButton.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useContext, type ReactNode } from 'react';\nimport IconButtonComp, { type IconButtonProps } from '../../IconButton';\nimport { useListItemControl } from '../useListItemControl';\nimport { ListItemContext } from '../ListItemContext';\n\nexport type ListItemIconButtonProps = Pick<\n IconButtonProps,\n 'type' | 'onClick' | 'href' | 'target' | 'aria-label'\n> & {\n children: ReactNode;\n partiallyInteractive?: boolean;\n /** @default 'minimal' */\n priority?: IconButtonProps['priority'];\n};\n\n/**\n * This component allows for rendering a IconButton control. It's a thin wrapper around the\n * [IconButton component](https://storybook.wise.design/?path=/docs/actions-iconbutton--docs), but offers only\n * a subset of its features in line with the ListItem's constraints. <br />\n * <br />\n * Please refer to the [Design documentation](https://docs.wise.design/components/list-item---icon-button) for details.\n */\nexport const IconButton = function ({\n priority = 'minimal',\n 'aria-label': ariaLabel,\n ...props\n}: ListItemIconButtonProps) {\n const { partiallyInteractive, ...restProps } = props;\n\n const { ids, props: itemProps } = useContext(ListItemContext);\n const { baseItemProps } = useListItemControl('icon-button', {\n partiallyInteractive,\n ...restProps,\n });\n\n const getAriaProps = () => {\n const labelIds = [\n itemProps.inverted ? ids.subtitle : ids.title,\n itemProps.inverted ? ids.title : ids.subtitle,\n itemProps.inverted ? ids.valueSubtitle : ids.valueTitle,\n itemProps.inverted ? ids.valueTitle : ids.valueSubtitle,\n ].join(' ');\n const descriptorIds = [ids.additionalInfo, ids.prompt].join(' ');\n\n if (ariaLabel) {\n return {\n 'aria-label': ariaLabel,\n 'aria-describedby': labelIds.concat(descriptorIds),\n };\n }\n\n return {\n 'aria-labelledby': labelIds,\n 'aria-describedby': descriptorIds,\n };\n };\n\n return (\n <IconButtonComp\n {...restProps}\n {...getAriaProps()}\n className={clsx(\n 'wds-list-item-control',\n !partiallyInteractive && props.href && 'wds-list-item-control_pseudo-element',\n )}\n id={ids.control}\n size={
|
|
1
|
+
{"version":3,"file":"ListItemIconButton.mjs","sources":["../../../src/ListItem/IconButton/ListItemIconButton.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useContext, type ReactNode } from 'react';\nimport IconButtonComp, { type IconButtonProps } from '../../IconButton';\nimport { useListItemControl } from '../useListItemControl';\nimport { ListItemContext } from '../ListItemContext';\n\nexport type ListItemIconButtonProps = Pick<\n IconButtonProps,\n 'type' | 'onClick' | 'href' | 'target' | 'aria-label'\n> & {\n /** @default 40 */\n size?: 24 | 40;\n children: ReactNode;\n partiallyInteractive?: boolean;\n /** @default 'minimal' */\n priority?: IconButtonProps['priority'];\n};\n\n/**\n * This component allows for rendering a IconButton control. It's a thin wrapper around the\n * [IconButton component](https://storybook.wise.design/?path=/docs/actions-iconbutton--docs), but offers only\n * a subset of its features in line with the ListItem's constraints. <br />\n * <br />\n * Please refer to the [Design documentation](https://docs.wise.design/components/list-item---icon-button) for details.\n */\nexport const IconButton = function ({\n priority = 'minimal',\n size = 40,\n 'aria-label': ariaLabel,\n ...props\n}: ListItemIconButtonProps) {\n const { partiallyInteractive, ...restProps } = props;\n\n const { ids, props: itemProps } = useContext(ListItemContext);\n const { baseItemProps } = useListItemControl('icon-button', {\n partiallyInteractive,\n ...restProps,\n });\n\n const getAriaProps = () => {\n const labelIds = [\n itemProps.inverted ? ids.subtitle : ids.title,\n itemProps.inverted ? ids.title : ids.subtitle,\n itemProps.inverted ? ids.valueSubtitle : ids.valueTitle,\n itemProps.inverted ? ids.valueTitle : ids.valueSubtitle,\n ].join(' ');\n const descriptorIds = [ids.additionalInfo, ids.prompt].join(' ');\n\n if (ariaLabel) {\n return {\n 'aria-label': ariaLabel,\n 'aria-describedby': labelIds.concat(descriptorIds),\n };\n }\n\n return {\n 'aria-labelledby': labelIds,\n 'aria-describedby': descriptorIds,\n };\n };\n\n return (\n <IconButtonComp\n {...restProps}\n {...getAriaProps()}\n className={clsx(\n 'wds-list-item-control',\n !partiallyInteractive && props.href && 'wds-list-item-control_pseudo-element',\n )}\n id={ids.control}\n size={size}\n priority={priority}\n disabled={baseItemProps.disabled}\n />\n );\n};\n\nIconButton.displayName = 'ListItem.IconButton';\n"],"names":["IconButton","priority","size","ariaLabel","props","partiallyInteractive","restProps","ids","itemProps","useContext","ListItemContext","baseItemProps","useListItemControl","getAriaProps","labelIds","inverted","subtitle","title","valueSubtitle","valueTitle","join","descriptorIds","additionalInfo","prompt","concat","_jsx","IconButtonComp","className","clsx","href","id","control","disabled","displayName"],"mappings":";;;;;;;AAyBO,MAAMA,UAAU,GAAG,UAAU;AAClCC,EAAAA,QAAQ,GAAG,SAAS;AACpBC,EAAAA,IAAI,GAAG,EAAE;AACT,EAAA,YAAY,EAAEC,SAAS;EACvB,GAAGC;AAAK,CACgB,EAAA;EACxB,MAAM;IAAEC,oBAAoB;IAAE,GAAGC;AAAS,GAAE,GAAGF,KAAK;EAEpD,MAAM;IAAEG,GAAG;AAAEH,IAAAA,KAAK,EAAEI;AAAS,GAAE,GAAGC,UAAU,CAACC,eAAe,CAAC;EAC7D,MAAM;AAAEC,IAAAA;AAAa,GAAE,GAAGC,kBAAkB,CAAC,aAAa,EAAE;IAC1DP,oBAAoB;IACpB,GAAGC;AACJ,GAAA,CAAC;EAEF,MAAMO,YAAY,GAAGA,MAAK;IACxB,MAAMC,QAAQ,GAAG,CACfN,SAAS,CAACO,QAAQ,GAAGR,GAAG,CAACS,QAAQ,GAAGT,GAAG,CAACU,KAAK,EAC7CT,SAAS,CAACO,QAAQ,GAAGR,GAAG,CAACU,KAAK,GAAGV,GAAG,CAACS,QAAQ,EAC7CR,SAAS,CAACO,QAAQ,GAAGR,GAAG,CAACW,aAAa,GAAGX,GAAG,CAACY,UAAU,EACvDX,SAAS,CAACO,QAAQ,GAAGR,GAAG,CAACY,UAAU,GAAGZ,GAAG,CAACW,aAAa,CACxD,CAACE,IAAI,CAAC,GAAG,CAAC;AACX,IAAA,MAAMC,aAAa,GAAG,CAACd,GAAG,CAACe,cAAc,EAAEf,GAAG,CAACgB,MAAM,CAAC,CAACH,IAAI,CAAC,GAAG,CAAC;AAEhE,IAAA,IAAIjB,SAAS,EAAE;MACb,OAAO;AACL,QAAA,YAAY,EAAEA,SAAS;AACvB,QAAA,kBAAkB,EAAEW,QAAQ,CAACU,MAAM,CAACH,aAAa;OAClD;AACH,IAAA;IAEA,OAAO;AACL,MAAA,iBAAiB,EAAEP,QAAQ;AAC3B,MAAA,kBAAkB,EAAEO;KACrB;EACH,CAAC;EAED,oBACEI,GAAA,CAACC,YAAc,EAAA;AAAA,IAAA,GACTpB,SAAS;IAAA,GACTO,YAAY,EAAE;AAClBc,IAAAA,SAAS,EAAEC,IAAI,CACb,uBAAuB,EACvB,CAACvB,oBAAoB,IAAID,KAAK,CAACyB,IAAI,IAAI,sCAAsC,CAC7E;IACFC,EAAE,EAAEvB,GAAG,CAACwB,OAAQ;AAChB7B,IAAAA,IAAI,EAAEA,IAAK;AACXD,IAAAA,QAAQ,EAAEA,QAAS;IACnB+B,QAAQ,EAAErB,aAAa,CAACqB;AAAS,GAAA,CACjC;AAEN;AAEAhC,UAAU,CAACiC,WAAW,GAAG,qBAAqB;;"}
|
|
@@ -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;;"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import { type IconButtonProps } from '../../IconButton';
|
|
3
3
|
export type ListItemIconButtonProps = Pick<IconButtonProps, 'type' | 'onClick' | 'href' | 'target' | 'aria-label'> & {
|
|
4
|
+
/** @default 40 */
|
|
5
|
+
size?: 24 | 40;
|
|
4
6
|
children: ReactNode;
|
|
5
7
|
partiallyInteractive?: boolean;
|
|
6
8
|
/** @default 'minimal' */
|
|
@@ -14,7 +16,7 @@ export type ListItemIconButtonProps = Pick<IconButtonProps, 'type' | 'onClick' |
|
|
|
14
16
|
* Please refer to the [Design documentation](https://docs.wise.design/components/list-item---icon-button) for details.
|
|
15
17
|
*/
|
|
16
18
|
export declare const IconButton: {
|
|
17
|
-
({ priority, "aria-label": ariaLabel, ...props }: ListItemIconButtonProps): import("react").JSX.Element;
|
|
19
|
+
({ priority, size, "aria-label": ariaLabel, ...props }: ListItemIconButtonProps): import("react").JSX.Element;
|
|
18
20
|
displayName: string;
|
|
19
21
|
};
|
|
20
22
|
//# sourceMappingURL=ListItemIconButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItemIconButton.d.ts","sourceRoot":"","sources":["../../../../src/ListItem/IconButton/ListItemIconButton.tsx"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACnD,OAAuB,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAIxE,MAAM,MAAM,uBAAuB,GAAG,IAAI,CACxC,eAAe,EACf,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,YAAY,CACtD,GAAG;IACF,QAAQ,EAAE,SAAS,CAAC;IACpB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,yBAAyB;IACzB,QAAQ,CAAC,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;CACxC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU;
|
|
1
|
+
{"version":3,"file":"ListItemIconButton.d.ts","sourceRoot":"","sources":["../../../../src/ListItem/IconButton/ListItemIconButton.tsx"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACnD,OAAuB,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAIxE,MAAM,MAAM,uBAAuB,GAAG,IAAI,CACxC,eAAe,EACf,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,YAAY,CACtD,GAAG;IACF,kBAAkB;IAClB,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC;IACf,QAAQ,EAAE,SAAS,CAAC;IACpB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,yBAAyB;IACzB,QAAQ,CAAC,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;CACxC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU;4DAKpB,uBAAuB;;CA6CzB,CAAC"}
|
|
@@ -105,11 +105,11 @@ export declare const ListItem: {
|
|
|
105
105
|
displayName: string;
|
|
106
106
|
};
|
|
107
107
|
IconButton: {
|
|
108
|
-
({ priority, "aria-label": ariaLabel, ...props }: ListItemIconButtonProps): import("react").JSX.Element;
|
|
108
|
+
({ priority, size, "aria-label": ariaLabel, ...props }: ListItemIconButtonProps): import("react").JSX.Element;
|
|
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/components",
|
|
3
|
-
"version": "46.
|
|
3
|
+
"version": "46.171.0",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
"@types/react-dom": "^18.3.7",
|
|
73
73
|
"@types/react-transition-group": "4.4.12",
|
|
74
74
|
"@monaco-editor/react": "^4.7.0",
|
|
75
|
+
"modern-normalize": "^3.0.1",
|
|
75
76
|
"monaco-editor": "^0.57.0",
|
|
76
77
|
"monaco-editor-webpack-plugin": "^7.1.1",
|
|
77
78
|
"@wise/art": "^2.33.0",
|
|
@@ -117,6 +117,44 @@ describe('ListItem.IconButton', () => {
|
|
|
117
117
|
});
|
|
118
118
|
});
|
|
119
119
|
|
|
120
|
+
describe('size', () => {
|
|
121
|
+
it('renders at size 40 by default', () => {
|
|
122
|
+
renderWith({
|
|
123
|
+
control: (
|
|
124
|
+
<ListItem.IconButton>
|
|
125
|
+
<Edit />
|
|
126
|
+
</ListItem.IconButton>
|
|
127
|
+
),
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
expect(screen.getByRole('button')).toHaveStyle({ '--circle-size': '40px' });
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it.each([24, 40] as const)('renders at size %i when specified', (size) => {
|
|
134
|
+
renderWith({
|
|
135
|
+
control: (
|
|
136
|
+
<ListItem.IconButton size={size}>
|
|
137
|
+
<Edit />
|
|
138
|
+
</ListItem.IconButton>
|
|
139
|
+
),
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
expect(screen.getByRole('button')).toHaveStyle({ '--circle-size': `${size}px` });
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('applies size when rendered as link', () => {
|
|
146
|
+
renderWith({
|
|
147
|
+
control: (
|
|
148
|
+
<ListItem.IconButton href="/test" size={24}>
|
|
149
|
+
<Edit />
|
|
150
|
+
</ListItem.IconButton>
|
|
151
|
+
),
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
expect(screen.getByRole('link')).toHaveStyle({ '--circle-size': '24px' });
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
120
158
|
it('renders children content', () => {
|
|
121
159
|
renderWith({
|
|
122
160
|
control: (
|
|
@@ -8,6 +8,8 @@ export type ListItemIconButtonProps = Pick<
|
|
|
8
8
|
IconButtonProps,
|
|
9
9
|
'type' | 'onClick' | 'href' | 'target' | 'aria-label'
|
|
10
10
|
> & {
|
|
11
|
+
/** @default 40 */
|
|
12
|
+
size?: 24 | 40;
|
|
11
13
|
children: ReactNode;
|
|
12
14
|
partiallyInteractive?: boolean;
|
|
13
15
|
/** @default 'minimal' */
|
|
@@ -23,6 +25,7 @@ export type ListItemIconButtonProps = Pick<
|
|
|
23
25
|
*/
|
|
24
26
|
export const IconButton = function ({
|
|
25
27
|
priority = 'minimal',
|
|
28
|
+
size = 40,
|
|
26
29
|
'aria-label': ariaLabel,
|
|
27
30
|
...props
|
|
28
31
|
}: ListItemIconButtonProps) {
|
|
@@ -65,7 +68,7 @@ export const IconButton = function ({
|
|
|
65
68
|
!partiallyInteractive && props.href && 'wds-list-item-control_pseudo-element',
|
|
66
69
|
)}
|
|
67
70
|
id={ids.control}
|
|
68
|
-
size={
|
|
71
|
+
size={size}
|
|
69
72
|
priority={priority}
|
|
70
73
|
disabled={baseItemProps.disabled}
|
|
71
74
|
/>
|
|
@@ -31,6 +31,7 @@ const meta: Meta<ListItemIconButtonProps> = {
|
|
|
31
31
|
args: {
|
|
32
32
|
partiallyInteractive: false,
|
|
33
33
|
priority: undefined,
|
|
34
|
+
size: undefined,
|
|
34
35
|
type: undefined,
|
|
35
36
|
'aria-label': 'Edit details',
|
|
36
37
|
children: <Edit />,
|
|
@@ -54,6 +55,14 @@ const meta: Meta<ListItemIconButtonProps> = {
|
|
|
54
55
|
},
|
|
55
56
|
description: 'IconButton priority/style variant',
|
|
56
57
|
},
|
|
58
|
+
size: {
|
|
59
|
+
control: 'radio',
|
|
60
|
+
options: ['unset (undefined)', 24, 40],
|
|
61
|
+
mapping: {
|
|
62
|
+
'unset (undefined)': undefined,
|
|
63
|
+
},
|
|
64
|
+
description: 'IconButton size',
|
|
65
|
+
},
|
|
57
66
|
type: {
|
|
58
67
|
control: 'radio',
|
|
59
68
|
options: ['unset (undefined)', 'default', 'negative'],
|
|
@@ -253,6 +262,32 @@ export const Priority: Story = {
|
|
|
253
262
|
},
|
|
254
263
|
};
|
|
255
264
|
|
|
265
|
+
/**
|
|
266
|
+
* The icon button is available in two sizes: `24` and `40` (default). <br />
|
|
267
|
+
* [Design documentation](https://docs.wise.design/components/icon-button#sizes)
|
|
268
|
+
*/
|
|
269
|
+
export const Size: Story = {
|
|
270
|
+
argTypes: hideControls(['size']),
|
|
271
|
+
render: (args) => {
|
|
272
|
+
return (
|
|
273
|
+
<List>
|
|
274
|
+
<ListItem
|
|
275
|
+
title="Size 24"
|
|
276
|
+
subtitle="Small icon button"
|
|
277
|
+
media={MEDIA.avatarSingle}
|
|
278
|
+
control={<ListItem.IconButton {...args} size={24} />}
|
|
279
|
+
/>
|
|
280
|
+
<ListItem
|
|
281
|
+
title="Size 40"
|
|
282
|
+
subtitle="Large icon button (default)"
|
|
283
|
+
media={MEDIA.avatarSingle}
|
|
284
|
+
control={<ListItem.IconButton {...args} size={40} />}
|
|
285
|
+
/>
|
|
286
|
+
</List>
|
|
287
|
+
);
|
|
288
|
+
},
|
|
289
|
+
};
|
|
290
|
+
|
|
256
291
|
/**
|
|
257
292
|
* If `href` prop is set, the component will be automatically rendered as an HTML anchor element.
|
|
258
293
|
*/
|
|
@@ -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>
|
|
@@ -10,9 +10,11 @@ Typically `CriticalBanner` should be used in one of three ways. Pick the one tha
|
|
|
10
10
|
|
|
11
11
|
- `Layout` via `@transferwise/navigation-ui` - Fetched automatically from navigation-service (for non-flow layouts)
|
|
12
12
|
- `Flow` / `HashRouterFlow` via `@transferwise/flow` - Fetched automatically from navigation-service (for flows)
|
|
13
|
-
- `
|
|
13
|
+
- `FlowNavigationWrapper` via `@transferwise/navigation-ui` - Fetches, caches and renders the critical banner automatically for custom solutions
|
|
14
14
|
|
|
15
|
-
If your page uses `Layout`, `Flow` or `HashRouterFlow`, you don't need to render `CriticalBanner` yourself. These components fetch the banner,
|
|
15
|
+
If your page uses `Layout`, `FlowNavigationWrapper`, `Flow` or `HashRouterFlow`, you don't need to render `CriticalBanner` yourself. These components fetch and render the banner for you automatically, whilst caching it between page loads/navigation to avoid rerendering it unnecessarily.
|
|
16
|
+
|
|
17
|
+
Additionally, you can use `FlowNavigation` directly if you need a completely custom solution, however you will need to manage fetching the critical banner yourself.
|
|
16
18
|
|
|
17
19
|
## Layout from @transferwise/navigation-ui
|
|
18
20
|
|
|
@@ -90,7 +92,9 @@ const SendFlow = ({ navigationData }: { navigationData?: NavigationData }) => (
|
|
|
90
92
|
|
|
91
93
|
## FlowNavigation from @transferwise/components
|
|
92
94
|
|
|
93
|
-
`
|
|
95
|
+
We recommend using the `FlowNavigationWrapper` from `@transferwise/navigation-ui` for handling the critical banner automatically with `FlowNavigation`. [See the source code in navigation-web for further details](https://github.com/transferwise/navigation-web/blob/main/packages/ui/src/flow-wrapper/FlowNavigationWrapper.tsx#L22)
|
|
96
|
+
|
|
97
|
+
If you still want to use `FlowNavigation` from `@transferwise/components` directly, it renders a critical banner above the navigation when you pass a `banner` prop. Use this if you build your flow with `FlowNavigation` directly. You're responsible for getting the banner data.
|
|
94
98
|
|
|
95
99
|
`banner` accepts either:
|
|
96
100
|
|