@transferwise/components 0.0.0-experimental-6bea55b → 0.0.0-experimental-d4d4068

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 CHANGED
@@ -2682,6 +2682,17 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
2682
2682
  -webkit-text-decoration: none;
2683
2683
  text-decoration: none;
2684
2684
  }
2685
+ .wds-list-item.disabled {
2686
+ filter: none;
2687
+ opacity: 1;
2688
+ }
2689
+ .wds-list-item.disabled label {
2690
+ cursor: not-allowed;
2691
+ }
2692
+ .wds-list-item.disabled .tw-icon-backslash-circle {
2693
+ color: #768e9c;
2694
+ color: var(--color-content-tertiary);
2695
+ }
2685
2696
  .wds-list-item-spotlight-active {
2686
2697
  background-color: rgba(134,167,189,0.10196);
2687
2698
  background-color: var(--color-background-neutral);
@@ -62,6 +62,17 @@
62
62
  -webkit-text-decoration: none;
63
63
  text-decoration: none;
64
64
  }
65
+ .wds-list-item.disabled {
66
+ filter: none;
67
+ opacity: 1;
68
+ }
69
+ .wds-list-item.disabled label {
70
+ cursor: not-allowed;
71
+ }
72
+ .wds-list-item.disabled .tw-icon-backslash-circle {
73
+ color: #768e9c;
74
+ color: var(--color-content-tertiary);
75
+ }
65
76
  .wds-list-item-spotlight-active {
66
77
  background-color: rgba(134,167,189,0.10196);
67
78
  background-color: var(--color-background-neutral);
@@ -2682,6 +2682,17 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
2682
2682
  -webkit-text-decoration: none;
2683
2683
  text-decoration: none;
2684
2684
  }
2685
+ .wds-list-item.disabled {
2686
+ filter: none;
2687
+ opacity: 1;
2688
+ }
2689
+ .wds-list-item.disabled label {
2690
+ cursor: not-allowed;
2691
+ }
2692
+ .wds-list-item.disabled .tw-icon-backslash-circle {
2693
+ color: #768e9c;
2694
+ color: var(--color-content-tertiary);
2695
+ }
2685
2696
  .wds-list-item-spotlight-active {
2686
2697
  background-color: rgba(134,167,189,0.10196);
2687
2698
  background-color: var(--color-background-neutral);
@@ -32,7 +32,7 @@ const Switch = props => {
32
32
  'np-switch--checked': checked,
33
33
  disabled
34
34
  }, className),
35
- tabIndex: 0,
35
+ tabIndex: disabled ? -1 : 0,
36
36
  role: "switch",
37
37
  "aria-checked": checked,
38
38
  "aria-label": ariaLabel,
@@ -1 +1 @@
1
- {"version":3,"file":"Switch.js","sources":["../../src/switch/Switch.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport type { KeyboardEventHandler, MouseEvent } from 'react';\n\nimport type { CommonProps } from '../common';\nimport { useInputAttributes } from '../inputs/contexts';\n\nexport type SwitchProps = CommonProps & {\n /**\n * Used to describe the purpose of the switch. To be used if there is no external label (i.e. aria-labelledby is null)\n * @deprecated Use `Field` wrapper or the `aria-labelledby` attribute instead.\n */\n 'aria-label'?: string;\n /** A reference to a label that describes the purpose of the switch. Ignored if aria-label is provided */\n 'aria-labelledby'?: string;\n /** Whether the switch is checked or not */\n checked?: boolean;\n disabled?: boolean;\n /** ID to apply to the switch container */\n id?: string;\n /** Function called when the switch is toggled */\n onClick: (event?: MouseEvent<HTMLSpanElement>) => void;\n};\n\nconst Switch = (props: SwitchProps) => {\n const inputAttributes = useInputAttributes({ nonLabelable: true });\n\n const {\n checked,\n className,\n id = inputAttributes.id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledbyProp,\n onClick,\n disabled,\n } = props;\n\n const handleKeyDown: KeyboardEventHandler = (event) => {\n if (event.key === ' ') {\n event.preventDefault();\n onClick();\n }\n };\n\n const ariaLabelledby =\n (ariaLabel ? undefined : ariaLabelledbyProp) ?? inputAttributes['aria-labelledby'];\n\n return (\n <span\n className={clsx(\n 'np-switch',\n {\n 'np-switch--unchecked': !checked,\n 'np-switch--checked': checked,\n disabled,\n },\n className,\n )}\n tabIndex={0}\n role=\"switch\"\n aria-checked={checked}\n aria-label={ariaLabel}\n {...inputAttributes}\n aria-labelledby={ariaLabelledby}\n id={id}\n aria-disabled={disabled}\n onClick={!disabled ? onClick : undefined}\n onKeyDown={!disabled ? handleKeyDown : undefined}\n >\n <span className=\"np-switch--thumb\" />\n <input type=\"checkbox\" checked={checked} readOnly />\n </span>\n );\n};\n\nexport default Switch;\n"],"names":["Switch","props","inputAttributes","useInputAttributes","nonLabelable","checked","className","id","ariaLabel","ariaLabelledbyProp","onClick","disabled","handleKeyDown","event","key","preventDefault","ariaLabelledby","undefined","_jsxs","clsx","tabIndex","role","onKeyDown","children","_jsx","type","readOnly"],"mappings":";;;;;;;;AAuBMA,MAAAA,MAAM,GAAIC,KAAkB,IAAI;EACpC,MAAMC,eAAe,GAAGC,2BAAkB,CAAC;AAAEC,IAAAA,YAAY,EAAE;AAAM,GAAA,CAAC;EAElE,MAAM;IACJC,OAAO;IACPC,SAAS;IACTC,EAAE,GAAGL,eAAe,CAACK,EAAE;AACvB,IAAA,YAAY,EAAEC,SAAS;AACvB,IAAA,iBAAiB,EAAEC,kBAAkB;IACrCC,OAAO;AACPC,IAAAA;AAAQ,GACT,GAAGV,KAAK;EAET,MAAMW,aAAa,GAA0BC,KAAK,IAAI;AACpD,IAAA,IAAIA,KAAK,CAACC,GAAG,KAAK,GAAG,EAAE;MACrBD,KAAK,CAACE,cAAc,EAAE;AACtBL,MAAAA,OAAO,EAAE;AACX;GACD;AAED,EAAA,MAAMM,cAAc,GAClB,CAACR,SAAS,GAAGS,SAAS,GAAGR,kBAAkB,KAAKP,eAAe,CAAC,iBAAiB,CAAC;AAEpF,EAAA,oBACEgB,eAAA,CAAA,MAAA,EAAA;AACEZ,IAAAA,SAAS,EAAEa,SAAI,CACb,WAAW,EACX;MACE,sBAAsB,EAAE,CAACd,OAAO;AAChC,MAAA,oBAAoB,EAAEA,OAAO;AAC7BM,MAAAA;KACD,EACDL,SAAS,CACT;AACFc,IAAAA,QAAQ,EAAE,CAAE;AACZC,IAAAA,IAAI,EAAC,QAAQ;AACb,IAAA,cAAA,EAAchB,OAAQ;AACtB,IAAA,YAAA,EAAYG,SAAU;AAAA,IAAA,GAClBN,eAAe;AACnB,IAAA,iBAAA,EAAiBc,cAAe;AAChCT,IAAAA,EAAE,EAAEA,EAAG;AACP,IAAA,eAAA,EAAeI,QAAS;AACxBD,IAAAA,OAAO,EAAE,CAACC,QAAQ,GAAGD,OAAO,GAAGO,SAAU;AACzCK,IAAAA,SAAS,EAAE,CAACX,QAAQ,GAAGC,aAAa,GAAGK,SAAU;AAAAM,IAAAA,QAAA,gBAEjDC,cAAA,CAAA,MAAA,EAAA;AAAMlB,MAAAA,SAAS,EAAC;KAChB,CAAA,eAAAkB,cAAA,CAAA,OAAA,EAAA;AAAOC,MAAAA,IAAI,EAAC,UAAU;AAACpB,MAAAA,OAAO,EAAEA,OAAQ;MAACqB,QAAQ,EAAA;AAAA,KACnD,CAAA;AAAA,GAAM,CAAC;AAEX;;;;"}
1
+ {"version":3,"file":"Switch.js","sources":["../../src/switch/Switch.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport type { KeyboardEventHandler, MouseEvent } from 'react';\n\nimport type { CommonProps } from '../common';\nimport { useInputAttributes } from '../inputs/contexts';\n\nexport type SwitchProps = CommonProps & {\n /**\n * Used to describe the purpose of the switch. To be used if there is no external label (i.e. aria-labelledby is null)\n * @deprecated Use `Field` wrapper or the `aria-labelledby` attribute instead.\n */\n 'aria-label'?: string;\n /** A reference to a label that describes the purpose of the switch. Ignored if aria-label is provided */\n 'aria-labelledby'?: string;\n /** Whether the switch is checked or not */\n checked?: boolean;\n disabled?: boolean;\n /** ID to apply to the switch container */\n id?: string;\n /** Function called when the switch is toggled */\n onClick: (event?: MouseEvent<HTMLSpanElement>) => void;\n};\n\nconst Switch = (props: SwitchProps) => {\n const inputAttributes = useInputAttributes({ nonLabelable: true });\n\n const {\n checked,\n className,\n id = inputAttributes.id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledbyProp,\n onClick,\n disabled,\n } = props;\n\n const handleKeyDown: KeyboardEventHandler = (event) => {\n if (event.key === ' ') {\n event.preventDefault();\n onClick();\n }\n };\n\n const ariaLabelledby =\n (ariaLabel ? undefined : ariaLabelledbyProp) ?? inputAttributes['aria-labelledby'];\n\n return (\n <span\n className={clsx(\n 'np-switch',\n {\n 'np-switch--unchecked': !checked,\n 'np-switch--checked': checked,\n disabled,\n },\n className,\n )}\n tabIndex={disabled ? -1 : 0}\n role=\"switch\"\n aria-checked={checked}\n aria-label={ariaLabel}\n {...inputAttributes}\n aria-labelledby={ariaLabelledby}\n id={id}\n aria-disabled={disabled}\n onClick={!disabled ? onClick : undefined}\n onKeyDown={!disabled ? handleKeyDown : undefined}\n >\n <span className=\"np-switch--thumb\" />\n <input type=\"checkbox\" checked={checked} readOnly />\n </span>\n );\n};\n\nexport default Switch;\n"],"names":["Switch","props","inputAttributes","useInputAttributes","nonLabelable","checked","className","id","ariaLabel","ariaLabelledbyProp","onClick","disabled","handleKeyDown","event","key","preventDefault","ariaLabelledby","undefined","_jsxs","clsx","tabIndex","role","onKeyDown","children","_jsx","type","readOnly"],"mappings":";;;;;;;;AAuBMA,MAAAA,MAAM,GAAIC,KAAkB,IAAI;EACpC,MAAMC,eAAe,GAAGC,2BAAkB,CAAC;AAAEC,IAAAA,YAAY,EAAE;AAAM,GAAA,CAAC;EAElE,MAAM;IACJC,OAAO;IACPC,SAAS;IACTC,EAAE,GAAGL,eAAe,CAACK,EAAE;AACvB,IAAA,YAAY,EAAEC,SAAS;AACvB,IAAA,iBAAiB,EAAEC,kBAAkB;IACrCC,OAAO;AACPC,IAAAA;AAAQ,GACT,GAAGV,KAAK;EAET,MAAMW,aAAa,GAA0BC,KAAK,IAAI;AACpD,IAAA,IAAIA,KAAK,CAACC,GAAG,KAAK,GAAG,EAAE;MACrBD,KAAK,CAACE,cAAc,EAAE;AACtBL,MAAAA,OAAO,EAAE;AACX;GACD;AAED,EAAA,MAAMM,cAAc,GAClB,CAACR,SAAS,GAAGS,SAAS,GAAGR,kBAAkB,KAAKP,eAAe,CAAC,iBAAiB,CAAC;AAEpF,EAAA,oBACEgB,eAAA,CAAA,MAAA,EAAA;AACEZ,IAAAA,SAAS,EAAEa,SAAI,CACb,WAAW,EACX;MACE,sBAAsB,EAAE,CAACd,OAAO;AAChC,MAAA,oBAAoB,EAAEA,OAAO;AAC7BM,MAAAA;KACD,EACDL,SAAS,CACT;AACFc,IAAAA,QAAQ,EAAET,QAAQ,GAAG,EAAE,GAAG,CAAE;AAC5BU,IAAAA,IAAI,EAAC,QAAQ;AACb,IAAA,cAAA,EAAchB,OAAQ;AACtB,IAAA,YAAA,EAAYG,SAAU;AAAA,IAAA,GAClBN,eAAe;AACnB,IAAA,iBAAA,EAAiBc,cAAe;AAChCT,IAAAA,EAAE,EAAEA,EAAG;AACP,IAAA,eAAA,EAAeI,QAAS;AACxBD,IAAAA,OAAO,EAAE,CAACC,QAAQ,GAAGD,OAAO,GAAGO,SAAU;AACzCK,IAAAA,SAAS,EAAE,CAACX,QAAQ,GAAGC,aAAa,GAAGK,SAAU;AAAAM,IAAAA,QAAA,gBAEjDC,cAAA,CAAA,MAAA,EAAA;AAAMlB,MAAAA,SAAS,EAAC;KAChB,CAAA,eAAAkB,cAAA,CAAA,OAAA,EAAA;AAAOC,MAAAA,IAAI,EAAC,UAAU;AAACpB,MAAAA,OAAO,EAAEA,OAAQ;MAACqB,QAAQ,EAAA;AAAA,KACnD,CAAA;AAAA,GAAM,CAAC;AAEX;;;;"}
@@ -28,7 +28,7 @@ const Switch = props => {
28
28
  'np-switch--checked': checked,
29
29
  disabled
30
30
  }, className),
31
- tabIndex: 0,
31
+ tabIndex: disabled ? -1 : 0,
32
32
  role: "switch",
33
33
  "aria-checked": checked,
34
34
  "aria-label": ariaLabel,
@@ -1 +1 @@
1
- {"version":3,"file":"Switch.mjs","sources":["../../src/switch/Switch.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport type { KeyboardEventHandler, MouseEvent } from 'react';\n\nimport type { CommonProps } from '../common';\nimport { useInputAttributes } from '../inputs/contexts';\n\nexport type SwitchProps = CommonProps & {\n /**\n * Used to describe the purpose of the switch. To be used if there is no external label (i.e. aria-labelledby is null)\n * @deprecated Use `Field` wrapper or the `aria-labelledby` attribute instead.\n */\n 'aria-label'?: string;\n /** A reference to a label that describes the purpose of the switch. Ignored if aria-label is provided */\n 'aria-labelledby'?: string;\n /** Whether the switch is checked or not */\n checked?: boolean;\n disabled?: boolean;\n /** ID to apply to the switch container */\n id?: string;\n /** Function called when the switch is toggled */\n onClick: (event?: MouseEvent<HTMLSpanElement>) => void;\n};\n\nconst Switch = (props: SwitchProps) => {\n const inputAttributes = useInputAttributes({ nonLabelable: true });\n\n const {\n checked,\n className,\n id = inputAttributes.id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledbyProp,\n onClick,\n disabled,\n } = props;\n\n const handleKeyDown: KeyboardEventHandler = (event) => {\n if (event.key === ' ') {\n event.preventDefault();\n onClick();\n }\n };\n\n const ariaLabelledby =\n (ariaLabel ? undefined : ariaLabelledbyProp) ?? inputAttributes['aria-labelledby'];\n\n return (\n <span\n className={clsx(\n 'np-switch',\n {\n 'np-switch--unchecked': !checked,\n 'np-switch--checked': checked,\n disabled,\n },\n className,\n )}\n tabIndex={0}\n role=\"switch\"\n aria-checked={checked}\n aria-label={ariaLabel}\n {...inputAttributes}\n aria-labelledby={ariaLabelledby}\n id={id}\n aria-disabled={disabled}\n onClick={!disabled ? onClick : undefined}\n onKeyDown={!disabled ? handleKeyDown : undefined}\n >\n <span className=\"np-switch--thumb\" />\n <input type=\"checkbox\" checked={checked} readOnly />\n </span>\n );\n};\n\nexport default Switch;\n"],"names":["Switch","props","inputAttributes","useInputAttributes","nonLabelable","checked","className","id","ariaLabel","ariaLabelledbyProp","onClick","disabled","handleKeyDown","event","key","preventDefault","ariaLabelledby","undefined","_jsxs","clsx","tabIndex","role","onKeyDown","children","_jsx","type","readOnly"],"mappings":";;;;AAuBMA,MAAAA,MAAM,GAAIC,KA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AkB,GAAA,CAAA,OAAA,EAAA;AAAOC,MAAAA,IAAI,EAAC,UAAU;AAACpB,MAAAA,OAAO,EAAEA,OAAQ;MAACqB,QAAQ,EAAA;AAAA,KACnD,CAAA;AAAA,GAAM,CAAC;AAEX;;;;"}
1
+ {"version":3,"file":"Switch.mjs","sources":["../../src/switch/Switch.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport type { KeyboardEventHandler, MouseEvent } from 'react';\n\nimport type { CommonProps } from '../common';\nimport { useInputAttributes } from '../inputs/contexts';\n\nexport type SwitchProps = CommonProps & {\n /**\n * Used to describe the purpose of the switch. To be used if there is no external label (i.e. aria-labelledby is null)\n * @deprecated Use `Field` wrapper or the `aria-labelledby` attribute instead.\n */\n 'aria-label'?: string;\n /** A reference to a label that describes the purpose of the switch. Ignored if aria-label is provided */\n 'aria-labelledby'?: string;\n /** Whether the switch is checked or not */\n checked?: boolean;\n disabled?: boolean;\n /** ID to apply to the switch container */\n id?: string;\n /** Function called when the switch is toggled */\n onClick: (event?: MouseEvent<HTMLSpanElement>) => void;\n};\n\nconst Switch = (props: SwitchProps) => {\n const inputAttributes = useInputAttributes({ nonLabelable: true });\n\n const {\n checked,\n className,\n id = inputAttributes.id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledbyProp,\n onClick,\n disabled,\n } = props;\n\n const handleKeyDown: KeyboardEventHandler = (event) => {\n if (event.key === ' ') {\n event.preventDefault();\n onClick();\n }\n };\n\n const ariaLabelledby =\n (ariaLabel ? undefined : ariaLabelledbyProp) ?? inputAttributes['aria-labelledby'];\n\n return (\n <span\n className={clsx(\n 'np-switch',\n {\n 'np-switch--unchecked': !checked,\n 'np-switch--checked': checked,\n disabled,\n },\n className,\n )}\n tabIndex={disabled ? -1 : 0}\n role=\"switch\"\n aria-checked={checked}\n aria-label={ariaLabel}\n {...inputAttributes}\n aria-labelledby={ariaLabelledby}\n id={id}\n aria-disabled={disabled}\n onClick={!disabled ? onClick : undefined}\n onKeyDown={!disabled ? handleKeyDown : undefined}\n >\n <span className=\"np-switch--thumb\" />\n <input type=\"checkbox\" checked={checked} readOnly />\n </span>\n );\n};\n\nexport default Switch;\n"],"names":["Switch","props","inputAttributes","useInputAttributes","nonLabelable","checked","className","id","ariaLabel","ariaLabelledbyProp","onClick","disabled","handleKeyDown","event","key","preventDefault","ariaLabelledby","undefined","_jsxs","clsx","tabIndex","role","onKeyDown","children","_jsx","type","readOnly"],"mappings":";;;;AAuBMA,MAAAA,MAAM,GAAIC,KAAkB,IAAI;EACpC,MAAMC,eAAe,GAAGC,kBAAkB,CAAC;AAAEC,IAAAA,YAAY,EAAE;AAAM,GAAA,CAAC;EAElE,MAAM;IACJC,OAAO;IACPC,SAAS;IACTC,EAAE,GAAGL,eAAe,CAACK,EAAE;AACvB,IAAA,YAAY,EAAEC,SAAS;AACvB,IAAA,iBAAiB,EAAEC,kBAAkB;IACrCC,OAAO;AACPC,IAAAA;AAAQ,GACT,GAAGV,KAAK;EAET,MAAMW,aAAa,GAA0BC,KAAK,IAAI;AACpD,IAAA,IAAIA,KAAK,CAACC,GAAG,KAAK,GAAG,EAAE;MACrBD,KAAK,CAACE,cAAc,EAAE;AACtBL,MAAAA,OAAO,EAAE;AACX;GACD;AAED,EAAA,MAAMM,cAAc,GAClB,CAACR,SAAS,GAAGS,SAAS,GAAGR,kBAAkB,KAAKP,eAAe,CAAC,iBAAiB,CAAC;AAEpF,EAAA,oBACEgB,IAAA,CAAA,MAAA,EAAA;AACEZ,IAAAA,SAAS,EAAEa,IAAI,CACb,WAAW,EACX;MACE,sBAAsB,EAAE,CAACd,OAAO;AAChC,MAAA,oBAAoB,EAAEA,OAAO;AAC7BM,MAAAA;KACD,EACDL,SAAS,CACT;AACFc,IAAAA,QAAQ,EAAET,QAAQ,GAAG,EAAE,GAAG,CAAE;AAC5BU,IAAAA,IAAI,EAAC,QAAQ;AACb,IAAA,cAAA,EAAchB,OAAQ;AACtB,IAAA,YAAA,EAAYG,SAAU;AAAA,IAAA,GAClBN,eAAe;AACnB,IAAA,iBAAA,EAAiBc,cAAe;AAChCT,IAAAA,EAAE,EAAEA,EAAG;AACP,IAAA,eAAA,EAAeI,QAAS;AACxBD,IAAAA,OAAO,EAAE,CAACC,QAAQ,GAAGD,OAAO,GAAGO,SAAU;AACzCK,IAAAA,SAAS,EAAE,CAACX,QAAQ,GAAGC,aAAa,GAAGK,SAAU;AAAAM,IAAAA,QAAA,gBAEjDC,GAAA,CAAA,MAAA,EAAA;AAAMlB,MAAAA,SAAS,EAAC;KAChB,CAAA,eAAAkB,GAAA,CAAA,OAAA,EAAA;AAAOC,MAAAA,IAAI,EAAC,UAAU;AAACpB,MAAAA,OAAO,EAAEA,OAAQ;MAACqB,QAAQ,EAAA;AAAA,KACnD,CAAA;AAAA,GAAM,CAAC;AAEX;;;;"}
@@ -3,8 +3,10 @@ import { ListItemIconButtonProps } from './ListItemIconButton';
3
3
  import { ListItemCheckboxProps } from './ListItemCheckbox';
4
4
  import { ListItemNavigationProps } from './ListItemNavigation';
5
5
  import { ListItemButtonProps } from './ListItemButton';
6
+ import { ListItemRadioProps } from './ListItemRadio';
7
+ import { ListItemSwitchProps } from './ListItemSwitch';
6
8
  export type ListItemTypes = 'non-interactive' | 'navigation' | 'radio' | 'checkbox' | 'switch' | 'button' | 'icon-button';
7
- export type ListItemControlProps = ListItemNavigationProps | ListItemCheckboxProps | ListItemButtonProps | ListItemIconButtonProps;
9
+ export type ListItemControlProps = ListItemNavigationProps | ListItemCheckboxProps | ListItemButtonProps | ListItemIconButtonProps | ListItemRadioProps | ListItemSwitchProps;
8
10
  export type Props = {
9
11
  as?: 'li' | 'div' | 'span';
10
12
  inverted?: boolean;
@@ -24,13 +26,11 @@ export type ListItemContextData = {
24
26
  setControlType: (type: ListItemTypes) => void;
25
27
  setControlProps: (props: ListItemControlProps) => void;
26
28
  ids: {
27
- title: string;
28
- subtitle?: string;
29
- valueTitle?: string;
30
- valueSubtitle?: string;
31
- additionalInfo?: string;
29
+ label: string;
30
+ additionalInfo: string;
31
+ value: string;
32
32
  control: string;
33
- prompt?: string;
33
+ prompt: string;
34
34
  };
35
35
  props: Pick<Props, 'disabled' | 'inverted'>;
36
36
  };
@@ -42,10 +42,11 @@ export declare const ListItem: {
42
42
  AvatarLayout: ({ className, size, ...props }: import("./ListItemMedia").ListItemAvatarLayoutProps) => import("react").JSX.Element;
43
43
  AdditionalInfo: ({ children, action }: import("./ListItemAdditionalInfo").ListItemAdditionalInfoProps) => import("react").JSX.Element;
44
44
  Checkbox: (props: ListItemCheckboxProps) => import("react").JSX.Element;
45
+ Radio: (props: ListItemRadioProps) => import("react").JSX.Element;
45
46
  IconButton: (props: ListItemIconButtonProps) => import("react").JSX.Element;
46
47
  Navigation: ({ href, ...props }: ListItemNavigationProps) => import("react").JSX.Element;
47
48
  Button: ({ priority, partiallyInteractive, ...props }: ListItemButtonProps) => import("react").JSX.Element;
48
- Switch: (props: import("..").SwitchProps) => import("react").JSX.Element;
49
+ Switch: (props: ListItemSwitchProps) => import("react").JSX.Element;
49
50
  Prompt: ({ type, children, action }: import("./prompt/Prompt").ListItemPromptProps) => import("react").JSX.Element;
50
51
  };
51
52
  export default ListItem;
@@ -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;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,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C,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;;;;;;;;;;;;CAgHP,CAAC;AAsFF,eAAe,QAAQ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ListItemNavigation.d.ts","sourceRoot":"","sources":["../../../src/listItem/ListItemNavigation.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAIrD,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC,CAAC;AAEvF,eAAO,MAAM,UAAU,GAAuB,oBAA0B,uBAAuB,gCAe9F,CAAC"}
1
+ {"version":3,"file":"ListItemNavigation.d.ts","sourceRoot":"","sources":["../../../src/listItem/ListItemNavigation.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAIrD,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC,CAAC;AAEvF,eAAO,MAAM,UAAU,GAAuB,oBAA0B,uBAAuB,gCAkB9F,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { RadioButtonProps } from '../common/RadioButton/RadioButton';
2
+ export type ListItemRadioProps = Omit<RadioButtonProps, 'disabled'>;
3
+ export declare const Radio: (props: ListItemRadioProps) => import("react").JSX.Element;
4
+ //# sourceMappingURL=ListItemRadio.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ListItemRadio.d.ts","sourceRoot":"","sources":["../../../src/listItem/ListItemRadio.tsx"],"names":[],"mappings":"AAAA,OAAoB,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAGlF,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC;AAEpE,eAAO,MAAM,KAAK,GAAa,OAAO,kBAAkB,gCAIvD,CAAC"}
@@ -1,3 +1,4 @@
1
1
  import { SwitchProps } from '../switch';
2
- export declare const Switch: (props: SwitchProps) => import("react").JSX.Element;
2
+ export type ListItemSwitchProps = Omit<SwitchProps, 'disabled'>;
3
+ export declare const Switch: (props: ListItemSwitchProps) => import("react").JSX.Element;
3
4
  //# sourceMappingURL=ListItemSwitch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ListItemSwitch.d.ts","sourceRoot":"","sources":["../../../src/listItem/ListItemSwitch.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAyB,WAAW,EAAE,MAAM,WAAW,CAAC;AAG/D,eAAO,MAAM,MAAM,GAAa,OAAO,WAAW,gCAIjD,CAAC"}
1
+ {"version":3,"file":"ListItemSwitch.d.ts","sourceRoot":"","sources":["../../../src/listItem/ListItemSwitch.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAyB,WAAW,EAAE,MAAM,WAAW,CAAC;AAG/D,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;AAEhE,eAAO,MAAM,MAAM,GAAa,OAAO,mBAAmB,gCAIzD,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { ListItemControlProps, ListItemTypes } from './ListItem';
2
- export declare function useItemControl(controlType: ListItemTypes, controlProps?: ListItemControlProps): {
2
+ export declare function useItemControl(controlType: ListItemTypes, controlProps: ListItemControlProps): {
3
3
  baseItemProps: Pick<import("./ListItem").Props, "disabled" | "inverted">;
4
4
  };
5
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,EAGL,oBAAoB,EACpB,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB,wBAAgB,cAAc,CAAC,WAAW,EAAE,aAAa,EAAE,YAAY,CAAC,EAAE,oBAAoB;;EAc7F"}
1
+ {"version":3,"file":"useItemControl.d.ts","sourceRoot":"","sources":["../../../src/listItem/useItemControl.tsx"],"names":[],"mappings":"AACA,OAAO,EAGL,oBAAoB,EACpB,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB,wBAAgB,cAAc,CAAC,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,oBAAoB;;EAa5F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "0.0.0-experimental-6bea55b",
3
+ "version": "0.0.0-experimental-d4d4068",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -62,6 +62,17 @@
62
62
  -webkit-text-decoration: none;
63
63
  text-decoration: none;
64
64
  }
65
+ .wds-list-item.disabled {
66
+ filter: none;
67
+ opacity: 1;
68
+ }
69
+ .wds-list-item.disabled label {
70
+ cursor: not-allowed;
71
+ }
72
+ .wds-list-item.disabled .tw-icon-backslash-circle {
73
+ color: #768e9c;
74
+ color: var(--color-content-tertiary);
75
+ }
65
76
  .wds-list-item-spotlight-active {
66
77
  background-color: rgba(134,167,189,0.10196);
67
78
  background-color: var(--color-background-neutral);
@@ -72,6 +72,19 @@
72
72
  }
73
73
  }
74
74
 
75
+ &.disabled {
76
+ filter: none;
77
+ opacity: 1;
78
+
79
+ label {
80
+ cursor: not-allowed;
81
+ }
82
+
83
+ .tw-icon-backslash-circle {
84
+ color: var(--color-content-tertiary);
85
+ }
86
+ }
87
+
75
88
  &-spotlight {
76
89
  &-active {
77
90
  background-color: var(--color-background-neutral);
@@ -29,6 +29,7 @@ type Story = StoryObj<ItemProps>;
29
29
  export const TempPlayground: Story = {
30
30
  render: () => {
31
31
  const [checked, setChecked] = useState(false);
32
+ const [radio, setRadio] = useState('option2');
32
33
 
33
34
  return (
34
35
  <div>
@@ -109,6 +110,31 @@ export const TempPlayground: Story = {
109
110
  subtitle={lorem5}
110
111
  />
111
112
 
113
+ <ListItem
114
+ title="Radio 1"
115
+ subtitle={lorem10}
116
+ additionalInfo={<ListItem.AdditionalInfo>{lorem20}</ListItem.AdditionalInfo>}
117
+ control={
118
+ <ListItem.Radio
119
+ name="radios"
120
+ checked={radio === 'option1'}
121
+ onChange={() => setRadio('option1')}
122
+ />
123
+ }
124
+ />
125
+ <ListItem
126
+ title="Radio 2"
127
+ subtitle={lorem10}
128
+ additionalInfo={<ListItem.AdditionalInfo>{lorem20}</ListItem.AdditionalInfo>}
129
+ control={
130
+ <ListItem.Radio
131
+ name="radios"
132
+ checked={radio === 'option2'}
133
+ onChange={() => setRadio('option2')}
134
+ />
135
+ }
136
+ />
137
+
112
138
  <ListItem
113
139
  title="Test title"
114
140
  disabled
@@ -194,7 +220,6 @@ export const Navigation: Story = {
194
220
  <MultiCurrency />
195
221
  </ListItem.AvatarView>
196
222
  }
197
- inverted
198
223
  title="Test title"
199
224
  subtitle={lorem5}
200
225
  control={
@@ -344,7 +369,6 @@ export const NonInteractive: Story = {
344
369
  <FastFlag />
345
370
  </ListItem.AvatarView>
346
371
  }
347
- inverted
348
372
  title="Total paid"
349
373
  subtitle="Wise"
350
374
  valueTitle={<Money amount={12.15} currency="GBP" />}
@@ -460,4 +484,147 @@ export const ButtonInteractivity: Story = {
460
484
  },
461
485
  };
462
486
 
487
+ export const Disabled: Story = {
488
+ render: () => (
489
+ <div>
490
+ <ListItem
491
+ disabled
492
+ media={
493
+ <ListItem.AvatarView>
494
+ <MultiCurrency />
495
+ </ListItem.AvatarView>
496
+ }
497
+ title="Navigation"
498
+ subtitle={lorem5}
499
+ control={<ListItem.Navigation onClick={() => {}} />}
500
+ />
501
+ <ListItem
502
+ disabled
503
+ media={
504
+ <ListItem.AvatarView>
505
+ <MultiCurrency />
506
+ </ListItem.AvatarView>
507
+ }
508
+ title="Button secondary neutral"
509
+ subtitle={lorem5}
510
+ control={<ListItem.Button priority="secondary-neutral">Secondary Neutral</ListItem.Button>}
511
+ />
512
+ <ListItem
513
+ disabled
514
+ media={
515
+ <ListItem.AvatarView>
516
+ <MultiCurrency />
517
+ </ListItem.AvatarView>
518
+ }
519
+ title="Button primary"
520
+ subtitle={lorem5}
521
+ control={<ListItem.Button priority="primary">Primary</ListItem.Button>}
522
+ />
523
+ <ListItem
524
+ disabled
525
+ media={
526
+ <ListItem.AvatarView>
527
+ <MultiCurrency />
528
+ </ListItem.AvatarView>
529
+ }
530
+ title="Button tertiary"
531
+ subtitle={lorem5}
532
+ control={<ListItem.Button priority="tertiary">Tertiary</ListItem.Button>}
533
+ />
534
+ <ListItem
535
+ disabled
536
+ media={
537
+ <ListItem.AvatarView>
538
+ <MultiCurrency />
539
+ </ListItem.AvatarView>
540
+ }
541
+ title="Icon Button"
542
+ subtitle={lorem5}
543
+ control={
544
+ <ListItem.IconButton>
545
+ <Plus />
546
+ </ListItem.IconButton>
547
+ }
548
+ />
549
+ <ListItem
550
+ disabled
551
+ media={
552
+ <ListItem.AvatarView>
553
+ <MultiCurrency />
554
+ </ListItem.AvatarView>
555
+ }
556
+ title="Checkbox"
557
+ subtitle={lorem5}
558
+ control={<ListItem.Checkbox />}
559
+ />
560
+ <ListItem
561
+ disabled
562
+ media={
563
+ <ListItem.AvatarView>
564
+ <MultiCurrency />
565
+ </ListItem.AvatarView>
566
+ }
567
+ title="Checkbox checked"
568
+ subtitle={lorem5}
569
+ control={<ListItem.Checkbox checked />}
570
+ />
571
+ <ListItem
572
+ disabled
573
+ media={
574
+ <ListItem.AvatarView>
575
+ <MultiCurrency />
576
+ </ListItem.AvatarView>
577
+ }
578
+ title="Checkbox indeterminate"
579
+ subtitle={lorem5}
580
+ control={<ListItem.Checkbox indeterminate />}
581
+ />
582
+ <ListItem
583
+ disabled
584
+ media={
585
+ <ListItem.AvatarView>
586
+ <MultiCurrency />
587
+ </ListItem.AvatarView>
588
+ }
589
+ title="Switch on"
590
+ subtitle={lorem5}
591
+ control={<ListItem.Switch checked onClick={() => {}} />}
592
+ />
593
+ <ListItem
594
+ disabled
595
+ media={
596
+ <ListItem.AvatarView>
597
+ <MultiCurrency />
598
+ </ListItem.AvatarView>
599
+ }
600
+ title="Switch off"
601
+ subtitle={lorem5}
602
+ control={<ListItem.Switch onClick={() => {}} />}
603
+ />
604
+ <ListItem
605
+ disabled
606
+ media={
607
+ <ListItem.AvatarView>
608
+ <MultiCurrency />
609
+ </ListItem.AvatarView>
610
+ }
611
+ title="Switch off"
612
+ subtitle={lorem5}
613
+ control={<ListItem.Radio name="radio" checked />}
614
+ />
615
+ <ListItem
616
+ disabled
617
+ media={
618
+ <ListItem.AvatarView>
619
+ <MultiCurrency />
620
+ </ListItem.AvatarView>
621
+ }
622
+ title="Switch off"
623
+ subtitle={lorem5}
624
+ control={<ListItem.Radio name="radios" />}
625
+ />
626
+ </div>
627
+ ),
628
+ };
629
+
463
630
  // add intaces with dark mode
@@ -15,7 +15,8 @@ import { Checkbox, ListItemCheckboxProps } from './ListItemCheckbox';
15
15
  import { ListItemNavigationProps, Navigation } from './ListItemNavigation';
16
16
  import { clsx } from 'clsx';
17
17
  import { Button, ListItemButtonProps } from './ListItemButton';
18
- import { Switch } from './ListItemSwitch';
18
+ import { Radio, ListItemRadioProps } from './ListItemRadio';
19
+ import { Switch, ListItemSwitchProps } from './ListItemSwitch';
19
20
  import { AvatarLayout, AvatarView, Image } from './ListItemMedia';
20
21
  import Prompt from './prompt/Prompt';
21
22
  import { PrimitiveAnchor, PrimitiveButton } from '../primitives';
@@ -35,7 +36,9 @@ export type ListItemControlProps =
35
36
  // TODO: add more types for control props here;
36
37
  | ListItemCheckboxProps
37
38
  | ListItemButtonProps
38
- | ListItemIconButtonProps;
39
+ | ListItemIconButtonProps
40
+ | ListItemRadioProps
41
+ | ListItemSwitchProps;
39
42
 
40
43
  export type Props = {
41
44
  as?: 'li' | 'div' | 'span';
@@ -57,13 +60,11 @@ export type ListItemContextData = {
57
60
  setControlType: (type: ListItemTypes) => void;
58
61
  setControlProps: (props: ListItemControlProps) => void;
59
62
  ids: {
60
- title: string;
61
- subtitle?: string;
62
- valueTitle?: string;
63
- valueSubtitle?: string;
64
- additionalInfo?: string;
63
+ label: string;
64
+ additionalInfo: string;
65
+ value: string;
65
66
  control: string;
66
- prompt?: string;
67
+ prompt: string;
67
68
  };
68
69
  props: Pick<Props, 'disabled' | 'inverted'>;
69
70
  };
@@ -113,13 +114,11 @@ export const ListItem = ({
113
114
  const [controlProps, setControlProps] = useState<ListItemControlProps>({});
114
115
  const [controlType, setControlType] = useState<ListItemTypes>('non-interactive');
115
116
  const ids = {
116
- title: `${idPrefix}_title`,
117
- ...(subtitle && { subtitle: `${idPrefix}_subtitle` }),
118
- ...(valueTitle && { valueTitle: `${idPrefix}_value-title` }),
119
- ...(valueSubtitle && { valueSubtitle: `${idPrefix}_value-subtitle` }),
117
+ label: `${idPrefix}_label`,
118
+ value: `${idPrefix}_value`,
120
119
  control: `${idPrefix}_control`,
121
120
  prompt: `${idPrefix}_prompt`,
122
- ...(additionalInfo && { additionalInfo: `${idPrefix}_additional-info` }),
121
+ additionalInfo: `${idPrefix}_additional-info`,
123
122
  };
124
123
 
125
124
  // TODO: add partially interactive check from Button and IconButtons
@@ -130,8 +129,6 @@ export const ListItem = ({
130
129
  () => ({ setControlType, setControlProps, ids, props: { disabled, inverted } }),
131
130
  [],
132
131
  );
133
- const titleIds = [ids.title, ids.valueTitle].filter(Boolean);
134
- const subtitleIds = [ids.subtitle, ids.valueSubtitle].filter(Boolean);
135
132
  return (
136
133
  <ListItemContext.Provider value={listItemContext}>
137
134
  <ListItemElement
@@ -140,6 +137,7 @@ export const ListItem = ({
140
137
  {
141
138
  'wds-list-item-interactive':
142
139
  controlType !== 'non-interactive' &&
140
+ !disabled &&
143
141
  !(controlProps as ListItemButtonProps | ListItemIconButtonProps)
144
142
  ?.partiallyInteractive,
145
143
  },
@@ -150,10 +148,8 @@ export const ListItem = ({
150
148
  { disabled },
151
149
  className,
152
150
  )}
153
- aria-describedby={[
154
- ...(inverted ? [...subtitleIds, ...titleIds] : [...titleIds, ...subtitleIds]),
155
- ids.additionalInfo,
156
- ].join(' ')}
151
+ aria-disabled={disabled}
152
+ aria-describedby={[ids.additionalInfo].join(' ')}
157
153
  >
158
154
  <View {...{ prompt, controlType, controlProps }}>
159
155
  {media && <div className="wds-list-item-media">{media}</div>}
@@ -163,65 +159,34 @@ export const ListItem = ({
163
159
  {/* Title + Subtitle + Values - Group */}
164
160
  <div className="d-flex justify-content-between">
165
161
  <span>
166
- {(() => {
167
- const titles = [
168
- // @ts-expect-error div can have role and aria-lavel props
169
- <Body
170
- key={ids.title}
171
- id={ids.title}
172
- type={Typography.BODY_LARGE_BOLD}
173
- className="wds-list-item-title"
174
- // for a11y this needs to be a header but for SEO it shouldn't be `h*` tag
175
- // so we enable header semantics via `role` and `aria-level` attrs
176
- role="heading"
177
- aria-level="4"
178
- >
179
- {title}
180
- </Body>,
181
- ];
182
- if (subtitle) {
183
- titles.push(
184
- <Body key={ids.subtitle} id={ids.subtitle} className="wds-list-item-subtitle">
185
- {subtitle}
186
- </Body>,
187
- );
188
- }
189
- return inverted ? [...titles].reverse() : titles;
190
- })()}
162
+ {/* @ts-expect-error div can have role and aria-lavel props */}
163
+ <Body
164
+ type={Typography.BODY_LARGE_BOLD}
165
+ className="wds-list-item-title"
166
+ // for a11y this needs to be a header but for SEO it shouldn't be `h*` tag
167
+ // so we enable header semantics via `role` and `aria-level` attrs
168
+ role="heading"
169
+ aria-level="4"
170
+ >
171
+ {title}
172
+ </Body>
173
+ <Body className="wds-list-item-subtitle">{subtitle}</Body>
191
174
  </span>
192
175
  {(valueTitle || valueSubtitle) && (
193
176
  <span
177
+ id={ids.value}
194
178
  className={clsx('wds-list-item-value', 'd-flex align-items-center', {
195
179
  'flex-column': valueTitle !== undefined && valueSubtitle !== undefined,
196
180
  })}
197
181
  >
198
- {(() => {
199
- const values = [];
200
- if (valueTitle) {
201
- values.push(
202
- <Body
203
- key={ids.valueTitle}
204
- id={ids.valueTitle}
205
- type={Typography.BODY_LARGE_BOLD}
206
- className="wds-list-item-title-value"
207
- >
208
- {valueTitle}
209
- </Body>,
210
- );
211
- }
212
- if (valueSubtitle) {
213
- values.push(
214
- <Body
215
- key={ids.valueSubtitle}
216
- id={ids.valueSubtitle}
217
- className="wds-list-item-subtitle-value"
218
- >
219
- {valueSubtitle}
220
- </Body>,
221
- );
222
- }
223
- return inverted ? [...values].reverse() : values;
224
- })()}
182
+ {valueTitle && (
183
+ <Body type={Typography.BODY_LARGE_BOLD} className="wds-list-item-title-value">
184
+ {valueTitle}
185
+ </Body>
186
+ )}
187
+ {valueSubtitle && (
188
+ <Body className="wds-list-item-subtitle-value">{valueSubtitle}</Body>
189
+ )}
225
190
  </span>
226
191
  )}
227
192
  </div>
@@ -312,6 +277,7 @@ ListItem.AvatarView = AvatarView;
312
277
  ListItem.AvatarLayout = AvatarLayout;
313
278
  ListItem.AdditionalInfo = AdditionalInfo;
314
279
  ListItem.Checkbox = Checkbox;
280
+ ListItem.Radio = Radio;
315
281
  ListItem.IconButton = IconButton;
316
282
  ListItem.Navigation = Navigation;
317
283
  ListItem.Button = Button;
@@ -16,9 +16,9 @@ describe('ItemButton', () => {
16
16
  setControlType: mockSetControlType,
17
17
  setControlProps: mockSetControlProps,
18
18
  ids: {
19
- title: 'title',
19
+ label: 'label',
20
20
  additionalInfo: 'additional Info',
21
- valueTitle: 'value title',
21
+ value: 'value',
22
22
  control: 'control',
23
23
  prompt: 'prompt',
24
24
  },
@@ -8,7 +8,7 @@ export type ListItemCheckboxProps = Pick<
8
8
  >;
9
9
 
10
10
  export const Checkbox = function (props: ListItemCheckboxProps) {
11
- const { baseItemProps } = useItemControl('checkbox');
11
+ const { baseItemProps } = useItemControl('checkbox', { ...props });
12
12
 
13
13
  return <CheckboxButton disabled={baseItemProps.disabled} {...props} />;
14
14
  };
@@ -8,7 +8,10 @@ export type ListItemNavigationProps = Pick<ButtonProps, 'onClick' | 'href' | 'ta
8
8
  export const Navigation = function Navigation({ href = '#', ...props }: ListItemNavigationProps) {
9
9
  const { baseItemProps } = useItemControl('navigation', { href, ...props });
10
10
  const isLink = href !== '#';
11
- const icon = baseItemProps.disabled ? <BackslashCircle size={24} /> : <ChevronRight size={24} />;
11
+ const icon = <ChevronRight size={24} />;
12
+
13
+ if (baseItemProps.disabled) return <BackslashCircle size={24} />;
14
+
12
15
  return isLink ? (
13
16
  <>{icon}</>
14
17
  ) : (
@@ -0,0 +1,10 @@
1
+ import RadioButton, { RadioButtonProps } from '../common/RadioButton/RadioButton';
2
+ import { useItemControl } from './useItemControl';
3
+
4
+ export type ListItemRadioProps = Omit<RadioButtonProps, 'disabled'>;
5
+
6
+ export const Radio = function (props: ListItemRadioProps) {
7
+ const { baseItemProps } = useItemControl('radio', { ...props });
8
+
9
+ return <RadioButton disabled={baseItemProps.disabled} {...props} />;
10
+ };
@@ -1,8 +1,10 @@
1
1
  import { default as SwitchComp, SwitchProps } from '../switch';
2
2
  import { useItemControl } from './useItemControl';
3
3
 
4
- export const Switch = function (props: SwitchProps) {
5
- const { baseItemProps } = useItemControl('switch');
4
+ export type ListItemSwitchProps = Omit<SwitchProps, 'disabled'>;
5
+
6
+ export const Switch = function (props: ListItemSwitchProps) {
7
+ const { baseItemProps } = useItemControl('switch', { ...props });
6
8
 
7
9
  return <SwitchComp disabled={baseItemProps.disabled} {...props} />;
8
10
  };
@@ -6,7 +6,7 @@ import {
6
6
  ListItemTypes,
7
7
  } from './ListItem';
8
8
 
9
- export function useItemControl(controlType: ListItemTypes, controlProps?: ListItemControlProps) {
9
+ export function useItemControl(controlType: ListItemTypes, controlProps: ListItemControlProps) {
10
10
  const {
11
11
  setControlType,
12
12
  setControlProps,
@@ -15,7 +15,6 @@ export function useItemControl(controlType: ListItemTypes, controlProps?: ListIt
15
15
 
16
16
  useEffect(() => {
17
17
  setControlType(controlType);
18
- // @ts-expect-error TODO: fix the type error later
19
18
  setControlProps(controlProps);
20
19
  }, [controlType, controlProps, setControlType, setControlProps]);
21
20
 
package/src/main.css CHANGED
@@ -2682,6 +2682,17 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
2682
2682
  -webkit-text-decoration: none;
2683
2683
  text-decoration: none;
2684
2684
  }
2685
+ .wds-list-item.disabled {
2686
+ filter: none;
2687
+ opacity: 1;
2688
+ }
2689
+ .wds-list-item.disabled label {
2690
+ cursor: not-allowed;
2691
+ }
2692
+ .wds-list-item.disabled .tw-icon-backslash-circle {
2693
+ color: #768e9c;
2694
+ color: var(--color-content-tertiary);
2695
+ }
2685
2696
  .wds-list-item-spotlight-active {
2686
2697
  background-color: rgba(134,167,189,0.10196);
2687
2698
  background-color: var(--color-background-neutral);
@@ -55,7 +55,7 @@ const Switch = (props: SwitchProps) => {
55
55
  },
56
56
  className,
57
57
  )}
58
- tabIndex={0}
58
+ tabIndex={disabled ? -1 : 0}
59
59
  role="switch"
60
60
  aria-checked={checked}
61
61
  aria-label={ariaLabel}