@transferwise/components 46.98.1 → 46.100.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.
Files changed (64) hide show
  1. package/build/accordion/Accordion.js +4 -0
  2. package/build/accordion/Accordion.js.map +1 -1
  3. package/build/accordion/Accordion.mjs +4 -0
  4. package/build/accordion/Accordion.mjs.map +1 -1
  5. package/build/accordion/AccordionItem/AccordionItem.js +14 -5
  6. package/build/accordion/AccordionItem/AccordionItem.js.map +1 -1
  7. package/build/accordion/AccordionItem/AccordionItem.mjs +14 -5
  8. package/build/accordion/AccordionItem/AccordionItem.mjs.map +1 -1
  9. package/build/body/Body.js +2 -1
  10. package/build/body/Body.js.map +1 -1
  11. package/build/body/Body.mjs +2 -1
  12. package/build/body/Body.mjs.map +1 -1
  13. package/build/instructionsList/InstructionsList.js +1 -0
  14. package/build/instructionsList/InstructionsList.js.map +1 -1
  15. package/build/instructionsList/InstructionsList.mjs +1 -0
  16. package/build/instructionsList/InstructionsList.mjs.map +1 -1
  17. package/build/main.css +19 -16
  18. package/build/styles/accordion/Accordion.css +4 -1
  19. package/build/styles/body/Body.css +3 -0
  20. package/build/styles/main.css +19 -16
  21. package/build/styles/switch/Switch.css +22 -41
  22. package/build/styles/switchOption/SwitchOption.css +4 -0
  23. package/build/switch/Switch.js +7 -18
  24. package/build/switch/Switch.js.map +1 -1
  25. package/build/switch/Switch.mjs +8 -19
  26. package/build/switch/Switch.mjs.map +1 -1
  27. package/build/switchOption/SwitchOption.js +1 -0
  28. package/build/switchOption/SwitchOption.js.map +1 -1
  29. package/build/switchOption/SwitchOption.mjs +1 -0
  30. package/build/switchOption/SwitchOption.mjs.map +1 -1
  31. package/build/types/accordion/Accordion.d.ts +1 -1
  32. package/build/types/accordion/Accordion.d.ts.map +1 -1
  33. package/build/types/accordion/AccordionItem/AccordionItem.d.ts +12 -0
  34. package/build/types/accordion/AccordionItem/AccordionItem.d.ts.map +1 -1
  35. package/build/types/body/Body.d.ts +5 -0
  36. package/build/types/body/Body.d.ts.map +1 -1
  37. package/build/types/switch/Switch.d.ts.map +1 -1
  38. package/build/types/switchOption/SwitchOption.d.ts.map +1 -1
  39. package/package.json +7 -7
  40. package/src/accordion/Accordion.css +4 -1
  41. package/src/accordion/Accordion.less +10 -5
  42. package/src/accordion/Accordion.story.tsx +30 -1
  43. package/src/accordion/Accordion.tsx +5 -4
  44. package/src/accordion/AccordionItem/AccordionItem.tsx +25 -4
  45. package/src/body/Body.css +3 -0
  46. package/src/body/Body.less +3 -0
  47. package/src/body/Body.spec.tsx +8 -0
  48. package/src/body/Body.story.tsx +12 -0
  49. package/src/body/Body.tsx +11 -2
  50. package/src/instructionsList/InstructionsList.story.tsx +35 -37
  51. package/src/instructionsList/InstructionsList.tsx +1 -1
  52. package/src/main.css +19 -16
  53. package/src/main.less +2 -0
  54. package/src/switch/Switch.css +22 -41
  55. package/src/switch/Switch.less +6 -12
  56. package/src/switch/Switch.spec.tsx +11 -9
  57. package/src/switch/Switch.story.tsx +158 -33
  58. package/src/switch/Switch.tsx +6 -15
  59. package/src/switchOption/SwitchOption.css +4 -0
  60. package/src/switchOption/SwitchOption.less +8 -0
  61. package/src/switchOption/SwitchOption.spec.tsx +4 -5
  62. package/src/switchOption/SwitchOption.story.tsx +42 -38
  63. package/src/switchOption/SwitchOption.tsx +1 -0
  64. package/src/switch/__snapshots__/Switch.spec.tsx.snap +0 -44
@@ -1,4 +1,8 @@
1
- .np-switch {
1
+ @media (min-width: 768px) {
2
+ }@media (min-width: 768px) {
3
+ }.np-switch {
4
+ all: unset;
5
+ box-sizing: border-box;
2
6
  display: inline-flex;
3
7
  overflow: hidden;
4
8
  width: 50px;
@@ -7,61 +11,38 @@
7
11
  -webkit-user-select: none;
8
12
  -moz-user-select: none;
9
13
  user-select: none;
10
- }
11
- .np-switch:focus {
14
+ cursor: pointer;
15
+ }.np-switch:focus {
12
16
  outline: none;
13
- }
14
- .np-switch:focus-visible {
17
+ }.np-switch:focus-visible {
15
18
  outline: var(--ring-outline-color) solid var(--ring-outline-width);
16
19
  outline-offset: var(--ring-outline-offset);
17
- }
18
- .np-switch--thumb {
20
+ }.np-switch--thumb {
19
21
  display: flex;
20
22
  transition: transform cubic-bezier(0, 0.94, 0.62, 1) 350ms;
21
- }
22
- .np-switch--thumb .tw-icon {
23
+ }.np-switch--thumb .tw-icon {
23
24
  color: #fff;
24
- }
25
- .np-switch--unchecked {
25
+ }.np-switch--unchecked {
26
26
  background: #c9cbce;
27
27
  background: var(--color-interactive-secondary);
28
- }
29
- .np-switch--unchecked .switch--thumb {
28
+ }.np-switch--unchecked .switch--thumb {
30
29
  transform: translateX(0);
31
- }
32
- .np-switch--checked {
30
+ }.np-switch--checked {
33
31
  background: #00a2dd;
34
32
  background: var(--color-interactive-accent);
35
- }
36
- .np-switch--checked .np-switch--thumb {
33
+ }.np-switch--checked .np-switch--thumb {
37
34
  transform: translateX(20px) ;
38
- }
39
- [dir="rtl"] .np-switch--checked .np-switch--thumb {
35
+ }[dir="rtl"] .np-switch--checked .np-switch--thumb {
40
36
  transform: translateX(-20px) ;
41
- }
42
- .np-switch input {
43
- position: absolute;
44
- left: -100%;
45
- display: none;
46
- width: 0;
47
- height: 0;
48
- opacity: 0;
49
- }
50
- [dir="rtl"] .np-switch input {
51
- right: -100%;
52
- left: auto;
53
- left: initial;
54
- }
55
- .np-switch:not([aria-disabled]) {
56
- cursor: pointer;
57
- }
58
- .np-theme-personal .np-switch {
37
+ }.np-switch.disabled {
38
+ filter: grayscale(1);
39
+ opacity: 0.45;
40
+ cursor: not-allowed !important;
41
+ }.np-theme-personal .np-switch {
59
42
  padding: 1px 2px;
60
- }
61
- .np-theme-personal .np-switch--checked {
43
+ }.np-theme-personal .np-switch--checked {
62
44
  background: var(--color-interactive-primary);
63
- }
64
- .np-theme-personal .np-switch--thumb {
45
+ }.np-theme-personal .np-switch--thumb {
65
46
  width: 20px;
66
47
  height: 20px;
67
48
  margin: 3px;
@@ -0,0 +1,4 @@
1
+ .np-switch-option.disabled .np-switch {
2
+ filter: none;
3
+ opacity: 1;
4
+ }
@@ -19,36 +19,25 @@ const Switch = props => {
19
19
  onClick,
20
20
  disabled
21
21
  } = props;
22
- const handleKeyDown = event => {
23
- if (event.key === ' ') {
24
- event.preventDefault();
25
- onClick();
26
- }
27
- };
28
22
  const ariaLabelledby = (ariaLabel ? undefined : ariaLabelledbyProp) ?? inputAttributes['aria-labelledby'];
29
- return /*#__PURE__*/jsxRuntime.jsxs("span", {
23
+ return /*#__PURE__*/jsxRuntime.jsx("button", {
30
24
  className: clsx.clsx('np-switch', {
31
25
  'np-switch--unchecked': !checked,
32
26
  'np-switch--checked': checked,
33
27
  disabled
34
28
  }, className),
35
- tabIndex: 0,
29
+ type: "button",
36
30
  role: "switch",
31
+ ...inputAttributes,
32
+ id: id,
37
33
  "aria-checked": checked,
38
34
  "aria-label": ariaLabel,
39
- ...inputAttributes,
40
35
  "aria-labelledby": ariaLabelledby,
41
- id: id,
42
- "aria-disabled": disabled,
36
+ disabled: disabled,
43
37
  onClick: !disabled ? onClick : undefined,
44
- onKeyDown: !disabled ? handleKeyDown : undefined,
45
- children: [/*#__PURE__*/jsxRuntime.jsx("span", {
38
+ children: /*#__PURE__*/jsxRuntime.jsx("span", {
46
39
  className: "np-switch--thumb"
47
- }), /*#__PURE__*/jsxRuntime.jsx("input", {
48
- type: "checkbox",
49
- checked: checked,
50
- readOnly: true
51
- })]
40
+ })
52
41
  });
53
42
  };
54
43
 
@@ -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 ariaLabelledby =\n (ariaLabel ? undefined : ariaLabelledbyProp) ?? inputAttributes['aria-labelledby'];\n\n return (\n <button\n className={clsx(\n 'np-switch',\n {\n 'np-switch--unchecked': !checked,\n 'np-switch--checked': checked,\n disabled,\n },\n className,\n )}\n type=\"button\"\n role=\"switch\"\n {...inputAttributes}\n id={id}\n aria-checked={checked}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n disabled={disabled}\n onClick={!disabled ? onClick : undefined}\n >\n <span className=\"np-switch--thumb\" />\n </button>\n );\n};\n\nexport default Switch;\n"],"names":["Switch","props","inputAttributes","useInputAttributes","nonLabelable","checked","className","id","ariaLabel","ariaLabelledbyProp","onClick","disabled","ariaLabelledby","undefined","_jsx","clsx","type","role","children"],"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;AAET,EAAA,MAAMW,cAAc,GAClB,CAACJ,SAAS,GAAGK,SAAS,GAAGJ,kBAAkB,KAAKP,eAAe,CAAC,iBAAiB,CAAC;AAEpF,EAAA,oBACEY,cAAA,CAAA,QAAA,EAAA;AACER,IAAAA,SAAS,EAAES,SAAI,CACb,WAAW,EACX;MACE,sBAAsB,EAAE,CAACV,OAAO;AAChC,MAAA,oBAAoB,EAAEA,OAAO;AAC7BM,MAAAA;KACD,EACDL,SAAS,CACT;AACFU,IAAAA,IAAI,EAAC,QAAQ;AACbC,IAAAA,IAAI,EAAC,QAAQ;AAAA,IAAA,GACTf,eAAe;AACnBK,IAAAA,EAAE,EAAEA,EAAG;AACP,IAAA,cAAA,EAAcF,OAAQ;AACtB,IAAA,YAAA,EAAYG,SAAU;AACtB,IAAA,iBAAA,EAAiBI,cAAe;AAChCD,IAAAA,QAAQ,EAAEA,QAAS;AACnBD,IAAAA,OAAO,EAAE,CAACC,QAAQ,GAAGD,OAAO,GAAGG,SAAU;AAAAK,IAAAA,QAAA,eAEzCJ,cAAA,CAAA,MAAA,EAAA;AAAMR,MAAAA,SAAS,EAAC;KAClB;AAAA,GAAQ,CAAC;AAEb;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { clsx } from 'clsx';
2
2
  import { useInputAttributes } from '../inputs/contexts.mjs';
3
- import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { jsx } from 'react/jsx-runtime';
4
4
 
5
5
  const Switch = props => {
6
6
  const inputAttributes = useInputAttributes({
@@ -15,36 +15,25 @@ const Switch = props => {
15
15
  onClick,
16
16
  disabled
17
17
  } = props;
18
- const handleKeyDown = event => {
19
- if (event.key === ' ') {
20
- event.preventDefault();
21
- onClick();
22
- }
23
- };
24
18
  const ariaLabelledby = (ariaLabel ? undefined : ariaLabelledbyProp) ?? inputAttributes['aria-labelledby'];
25
- return /*#__PURE__*/jsxs("span", {
19
+ return /*#__PURE__*/jsx("button", {
26
20
  className: clsx('np-switch', {
27
21
  'np-switch--unchecked': !checked,
28
22
  'np-switch--checked': checked,
29
23
  disabled
30
24
  }, className),
31
- tabIndex: 0,
25
+ type: "button",
32
26
  role: "switch",
27
+ ...inputAttributes,
28
+ id: id,
33
29
  "aria-checked": checked,
34
30
  "aria-label": ariaLabel,
35
- ...inputAttributes,
36
31
  "aria-labelledby": ariaLabelledby,
37
- id: id,
38
- "aria-disabled": disabled,
32
+ disabled: disabled,
39
33
  onClick: !disabled ? onClick : undefined,
40
- onKeyDown: !disabled ? handleKeyDown : undefined,
41
- children: [/*#__PURE__*/jsx("span", {
34
+ children: /*#__PURE__*/jsx("span", {
42
35
  className: "np-switch--thumb"
43
- }), /*#__PURE__*/jsx("input", {
44
- type: "checkbox",
45
- checked: checked,
46
- readOnly: true
47
- })]
36
+ })
48
37
  });
49
38
  };
50
39
 
@@ -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,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,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,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;;;;"}
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 ariaLabelledby =\n (ariaLabel ? undefined : ariaLabelledbyProp) ?? inputAttributes['aria-labelledby'];\n\n return (\n <button\n className={clsx(\n 'np-switch',\n {\n 'np-switch--unchecked': !checked,\n 'np-switch--checked': checked,\n disabled,\n },\n className,\n )}\n type=\"button\"\n role=\"switch\"\n {...inputAttributes}\n id={id}\n aria-checked={checked}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n disabled={disabled}\n onClick={!disabled ? onClick : undefined}\n >\n <span className=\"np-switch--thumb\" />\n </button>\n );\n};\n\nexport default Switch;\n"],"names":["Switch","props","inputAttributes","useInputAttributes","nonLabelable","checked","className","id","ariaLabel","ariaLabelledbyProp","onClick","disabled","ariaLabelledby","undefined","_jsx","clsx","type","role","children"],"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;AAET,EAAA,MAAMW,cAAc,GAClB,CAACJ,SAAS,GAAGK,SAAS,GAAGJ,kBAAkB,KAAKP,eAAe,CAAC,iBAAiB,CAAC;AAEpF,EAAA,oBACEY,GAAA,CAAA,QAAA,EAAA;AACER,IAAAA,SAAS,EAAES,IAAI,CACb,WAAW,EACX;MACE,sBAAsB,EAAE,CAACV,OAAO;AAChC,MAAA,oBAAoB,EAAEA,OAAO;AAC7BM,MAAAA;KACD,EACDL,SAAS,CACT;AACFU,IAAAA,IAAI,EAAC,QAAQ;AACbC,IAAAA,IAAI,EAAC,QAAQ;AAAA,IAAA,GACTf,eAAe;AACnBK,IAAAA,EAAE,EAAEA,EAAG;AACP,IAAA,cAAA,EAAcF,OAAQ;AACtB,IAAA,YAAA,EAAYG,SAAU;AACtB,IAAA,iBAAA,EAAiBI,cAAe;AAChCD,IAAAA,QAAQ,EAAEA,QAAS;AACnBD,IAAAA,OAAO,EAAE,CAACC,QAAQ,GAAGD,OAAO,GAAGG,SAAU;AAAAK,IAAAA,QAAA,eAEzCJ,GAAA,CAAA,MAAA,EAAA;AAAMR,MAAAA,SAAS,EAAC;KAClB;AAAA,GAAQ,CAAC;AAEb;;;;"}
@@ -46,6 +46,7 @@ const SwitchOption = ({
46
46
  };
47
47
  return /*#__PURE__*/jsxRuntime.jsx(Option.default, {
48
48
  ...sharedProps,
49
+ className: "np-switch-option",
49
50
  button: /*#__PURE__*/jsxRuntime.jsx(Switch.default, {
50
51
  id: id,
51
52
  checked: checked,
@@ -1 +1 @@
1
- {"version":3,"file":"SwitchOption.js","sources":["../../src/switchOption/SwitchOption.tsx"],"sourcesContent":["import { MouseEvent } from 'react';\n\nimport Option from '../common/Option';\nimport Switch from '../switch';\n\nexport type SwitchOptionProps = {\n checked?: boolean;\n complex?: boolean;\n content?: React.ReactNode;\n disabled?: boolean;\n showMediaCircle?: boolean;\n showMediaAtAllSizes?: boolean;\n isContainerAligned?: boolean;\n id?: string;\n media?: React.ReactNode;\n onChange: (newValue: boolean) => void;\n title: React.ReactNode;\n 'aria-label': string;\n};\n\nconst stopPropagation = (event?: MouseEvent<HTMLSpanElement>) => {\n if (event) {\n event.stopPropagation();\n event.preventDefault();\n event.nativeEvent?.stopImmediatePropagation?.();\n }\n};\n\nconst SwitchOption = ({\n checked,\n complex,\n content,\n disabled,\n id,\n media,\n onChange,\n title,\n showMediaCircle,\n showMediaAtAllSizes,\n isContainerAligned,\n 'aria-label': ariaLabel,\n}: SwitchOptionProps) => {\n const sharedProps = {\n media,\n title,\n content,\n complex,\n disabled,\n showMediaCircle,\n showMediaAtAllSizes,\n isContainerAligned,\n };\n const toggle = (event?: MouseEvent<HTMLSpanElement>) => {\n stopPropagation(event);\n if (disabled) {\n return;\n }\n\n onChange(!checked);\n };\n\n return (\n <Option\n {...sharedProps}\n button={\n <Switch\n id={id}\n checked={checked}\n disabled={disabled}\n aria-label={ariaLabel}\n onClick={toggle}\n />\n }\n onClick={toggle}\n />\n );\n};\n\nexport default SwitchOption;\n"],"names":["stopPropagation","event","preventDefault","nativeEvent","stopImmediatePropagation","SwitchOption","checked","complex","content","disabled","id","media","onChange","title","showMediaCircle","showMediaAtAllSizes","isContainerAligned","ariaLabel","sharedProps","toggle","_jsx","Option","button","Switch","onClick"],"mappings":";;;;;;;;AAoBA,MAAMA,eAAe,GAAIC,KAAmC,IAAI;AAC9D,EAAA,IAAIA,KAAK,EAAE;IACTA,KAAK,CAACD,eAAe,EAAE;IACvBC,KAAK,CAACC,cAAc,EAAE;AACtBD,IAAAA,KAAK,CAACE,WAAW,EAAEC,wBAAwB,IAAI;AACjD;AACF,CAAC;AAEKC,MAAAA,YAAY,GAAGA,CAAC;EACpBC,OAAO;EACPC,OAAO;EACPC,OAAO;EACPC,QAAQ;EACRC,EAAE;EACFC,KAAK;EACLC,QAAQ;EACRC,KAAK;EACLC,eAAe;EACfC,mBAAmB;EACnBC,kBAAkB;AAClB,EAAA,YAAY,EAAEC;AAAS,CACL,KAAI;AACtB,EAAA,MAAMC,WAAW,GAAG;IAClBP,KAAK;IACLE,KAAK;IACLL,OAAO;IACPD,OAAO;IACPE,QAAQ;IACRK,eAAe;IACfC,mBAAmB;AACnBC,IAAAA;GACD;EACD,MAAMG,MAAM,GAAIlB,KAAmC,IAAI;IACrDD,eAAe,CAACC,KAAK,CAAC;AACtB,IAAA,IAAIQ,QAAQ,EAAE;AACZ,MAAA;AACF;IAEAG,QAAQ,CAAC,CAACN,OAAO,CAAC;GACnB;EAED,oBACEc,cAAA,CAACC,cAAM,EAAA;AAAA,IAAA,GACDH,WAAW;IACfI,MAAM,eACJF,cAAA,CAACG,cAAM,EAAA;AACLb,MAAAA,EAAE,EAAEA,EAAG;AACPJ,MAAAA,OAAO,EAAEA,OAAQ;AACjBG,MAAAA,QAAQ,EAAEA,QAAS;AACnB,MAAA,YAAA,EAAYQ,SAAU;AACtBO,MAAAA,OAAO,EAAEL;AAAO,KAEpB,CAAC;AACDK,IAAAA,OAAO,EAAEL;AAAO,GAChB,CAAA;AAEN;;;;"}
1
+ {"version":3,"file":"SwitchOption.js","sources":["../../src/switchOption/SwitchOption.tsx"],"sourcesContent":["import { MouseEvent } from 'react';\n\nimport Option from '../common/Option';\nimport Switch from '../switch';\n\nexport type SwitchOptionProps = {\n checked?: boolean;\n complex?: boolean;\n content?: React.ReactNode;\n disabled?: boolean;\n showMediaCircle?: boolean;\n showMediaAtAllSizes?: boolean;\n isContainerAligned?: boolean;\n id?: string;\n media?: React.ReactNode;\n onChange: (newValue: boolean) => void;\n title: React.ReactNode;\n 'aria-label': string;\n};\n\nconst stopPropagation = (event?: MouseEvent<HTMLSpanElement>) => {\n if (event) {\n event.stopPropagation();\n event.preventDefault();\n event.nativeEvent?.stopImmediatePropagation?.();\n }\n};\n\nconst SwitchOption = ({\n checked,\n complex,\n content,\n disabled,\n id,\n media,\n onChange,\n title,\n showMediaCircle,\n showMediaAtAllSizes,\n isContainerAligned,\n 'aria-label': ariaLabel,\n}: SwitchOptionProps) => {\n const sharedProps = {\n media,\n title,\n content,\n complex,\n disabled,\n showMediaCircle,\n showMediaAtAllSizes,\n isContainerAligned,\n };\n const toggle = (event?: MouseEvent<HTMLSpanElement>) => {\n stopPropagation(event);\n if (disabled) {\n return;\n }\n\n onChange(!checked);\n };\n\n return (\n <Option\n {...sharedProps}\n className=\"np-switch-option\"\n button={\n <Switch\n id={id}\n checked={checked}\n disabled={disabled}\n aria-label={ariaLabel}\n onClick={toggle}\n />\n }\n onClick={toggle}\n />\n );\n};\n\nexport default SwitchOption;\n"],"names":["stopPropagation","event","preventDefault","nativeEvent","stopImmediatePropagation","SwitchOption","checked","complex","content","disabled","id","media","onChange","title","showMediaCircle","showMediaAtAllSizes","isContainerAligned","ariaLabel","sharedProps","toggle","_jsx","Option","className","button","Switch","onClick"],"mappings":";;;;;;;;AAoBA,MAAMA,eAAe,GAAIC,KAAmC,IAAI;AAC9D,EAAA,IAAIA,KAAK,EAAE;IACTA,KAAK,CAACD,eAAe,EAAE;IACvBC,KAAK,CAACC,cAAc,EAAE;AACtBD,IAAAA,KAAK,CAACE,WAAW,EAAEC,wBAAwB,IAAI;AACjD;AACF,CAAC;AAEKC,MAAAA,YAAY,GAAGA,CAAC;EACpBC,OAAO;EACPC,OAAO;EACPC,OAAO;EACPC,QAAQ;EACRC,EAAE;EACFC,KAAK;EACLC,QAAQ;EACRC,KAAK;EACLC,eAAe;EACfC,mBAAmB;EACnBC,kBAAkB;AAClB,EAAA,YAAY,EAAEC;AAAS,CACL,KAAI;AACtB,EAAA,MAAMC,WAAW,GAAG;IAClBP,KAAK;IACLE,KAAK;IACLL,OAAO;IACPD,OAAO;IACPE,QAAQ;IACRK,eAAe;IACfC,mBAAmB;AACnBC,IAAAA;GACD;EACD,MAAMG,MAAM,GAAIlB,KAAmC,IAAI;IACrDD,eAAe,CAACC,KAAK,CAAC;AACtB,IAAA,IAAIQ,QAAQ,EAAE;AACZ,MAAA;AACF;IAEAG,QAAQ,CAAC,CAACN,OAAO,CAAC;GACnB;EAED,oBACEc,cAAA,CAACC,cAAM,EAAA;AAAA,IAAA,GACDH,WAAW;AACfI,IAAAA,SAAS,EAAC,kBAAkB;IAC5BC,MAAM,eACJH,cAAA,CAACI,cAAM,EAAA;AACLd,MAAAA,EAAE,EAAEA,EAAG;AACPJ,MAAAA,OAAO,EAAEA,OAAQ;AACjBG,MAAAA,QAAQ,EAAEA,QAAS;AACnB,MAAA,YAAA,EAAYQ,SAAU;AACtBQ,MAAAA,OAAO,EAAEN;AAAO,KAEpB,CAAC;AACDM,IAAAA,OAAO,EAAEN;AAAO,GAChB,CAAA;AAEN;;;;"}
@@ -42,6 +42,7 @@ const SwitchOption = ({
42
42
  };
43
43
  return /*#__PURE__*/jsx(Option, {
44
44
  ...sharedProps,
45
+ className: "np-switch-option",
45
46
  button: /*#__PURE__*/jsx(Switch, {
46
47
  id: id,
47
48
  checked: checked,
@@ -1 +1 @@
1
- {"version":3,"file":"SwitchOption.mjs","sources":["../../src/switchOption/SwitchOption.tsx"],"sourcesContent":["import { MouseEvent } from 'react';\n\nimport Option from '../common/Option';\nimport Switch from '../switch';\n\nexport type SwitchOptionProps = {\n checked?: boolean;\n complex?: boolean;\n content?: React.ReactNode;\n disabled?: boolean;\n showMediaCircle?: boolean;\n showMediaAtAllSizes?: boolean;\n isContainerAligned?: boolean;\n id?: string;\n media?: React.ReactNode;\n onChange: (newValue: boolean) => void;\n title: React.ReactNode;\n 'aria-label': string;\n};\n\nconst stopPropagation = (event?: MouseEvent<HTMLSpanElement>) => {\n if (event) {\n event.stopPropagation();\n event.preventDefault();\n event.nativeEvent?.stopImmediatePropagation?.();\n }\n};\n\nconst SwitchOption = ({\n checked,\n complex,\n content,\n disabled,\n id,\n media,\n onChange,\n title,\n showMediaCircle,\n showMediaAtAllSizes,\n isContainerAligned,\n 'aria-label': ariaLabel,\n}: SwitchOptionProps) => {\n const sharedProps = {\n media,\n title,\n content,\n complex,\n disabled,\n showMediaCircle,\n showMediaAtAllSizes,\n isContainerAligned,\n };\n const toggle = (event?: MouseEvent<HTMLSpanElement>) => {\n stopPropagation(event);\n if (disabled) {\n return;\n }\n\n onChange(!checked);\n };\n\n return (\n <Option\n {...sharedProps}\n button={\n <Switch\n id={id}\n checked={checked}\n disabled={disabled}\n aria-label={ariaLabel}\n onClick={toggle}\n />\n }\n onClick={toggle}\n />\n );\n};\n\nexport default SwitchOption;\n"],"names":["stopPropagation","event","preventDefault","nativeEvent","stopImmediatePropagation","SwitchOption","checked","complex","content","disabled","id","media","onChange","title","showMediaCircle","showMediaAtAllSizes","isContainerAligned","ariaLabel","sharedProps","toggle","_jsx","Option","button","Switch","onClick"],"mappings":";;;;AAoBA,MAAMA,eAAe,GAAIC,KAAmC,IAAI;AAC9D,EAAA,IAAIA,KAAK,EAAE;IACTA,KAAK,CAACD,eAAe,EAAE;IACvBC,KAAK,CAACC,cAAc,EAAE;AACtBD,IAAAA,KAAK,CAACE,WAAW,EAAEC,wBAAwB,IAAI;AACjD;AACF,CAAC;AAEKC,MAAAA,YAAY,GAAGA,CAAC;EACpBC,OAAO;EACPC,OAAO;EACPC,OAAO;EACPC,QAAQ;EACRC,EAAE;EACFC,KAAK;EACLC,QAAQ;EACRC,KAAK;EACLC,eAAe;EACfC,mBAAmB;EACnBC,kBAAkB;AAClB,EAAA,YAAY,EAAEC;AAAS,CACL,KAAI;AACtB,EAAA,MAAMC,WAAW,GAAG;IAClBP,KAAK;IACLE,KAAK;IACLL,OAAO;IACPD,OAAO;IACPE,QAAQ;IACRK,eAAe;IACfC,mBAAmB;AACnBC,IAAAA;GACD;EACD,MAAMG,MAAM,GAAIlB,KAAmC,IAAI;IACrDD,eAAe,CAACC,KAAK,CAAC;AACtB,IAAA,IAAIQ,QAAQ,EAAE;AACZ,MAAA;AACF;IAEAG,QAAQ,CAAC,CAACN,OAAO,CAAC;GACnB;EAED,oBACEc,GAAA,CAACC,MAAM,EAAA;AAAA,IAAA,GACDH,WAAW;IACfI,MAAM,eACJF,GAAA,CAACG,MAAM,EAAA;AACLb,MAAAA,EAAE,EAAEA,EAAG;AACPJ,MAAAA,OAAO,EAAEA,OAAQ;AACjBG,MAAAA,QAAQ,EAAEA,QAAS;AACnB,MAAA,YAAA,EAAYQ,SAAU;AACtBO,MAAAA,OAAO,EAAEL;AAAO,KAEpB,CAAC;AACDK,IAAAA,OAAO,EAAEL;AAAO,GAChB,CAAA;AAEN;;;;"}
1
+ {"version":3,"file":"SwitchOption.mjs","sources":["../../src/switchOption/SwitchOption.tsx"],"sourcesContent":["import { MouseEvent } from 'react';\n\nimport Option from '../common/Option';\nimport Switch from '../switch';\n\nexport type SwitchOptionProps = {\n checked?: boolean;\n complex?: boolean;\n content?: React.ReactNode;\n disabled?: boolean;\n showMediaCircle?: boolean;\n showMediaAtAllSizes?: boolean;\n isContainerAligned?: boolean;\n id?: string;\n media?: React.ReactNode;\n onChange: (newValue: boolean) => void;\n title: React.ReactNode;\n 'aria-label': string;\n};\n\nconst stopPropagation = (event?: MouseEvent<HTMLSpanElement>) => {\n if (event) {\n event.stopPropagation();\n event.preventDefault();\n event.nativeEvent?.stopImmediatePropagation?.();\n }\n};\n\nconst SwitchOption = ({\n checked,\n complex,\n content,\n disabled,\n id,\n media,\n onChange,\n title,\n showMediaCircle,\n showMediaAtAllSizes,\n isContainerAligned,\n 'aria-label': ariaLabel,\n}: SwitchOptionProps) => {\n const sharedProps = {\n media,\n title,\n content,\n complex,\n disabled,\n showMediaCircle,\n showMediaAtAllSizes,\n isContainerAligned,\n };\n const toggle = (event?: MouseEvent<HTMLSpanElement>) => {\n stopPropagation(event);\n if (disabled) {\n return;\n }\n\n onChange(!checked);\n };\n\n return (\n <Option\n {...sharedProps}\n className=\"np-switch-option\"\n button={\n <Switch\n id={id}\n checked={checked}\n disabled={disabled}\n aria-label={ariaLabel}\n onClick={toggle}\n />\n }\n onClick={toggle}\n />\n );\n};\n\nexport default SwitchOption;\n"],"names":["stopPropagation","event","preventDefault","nativeEvent","stopImmediatePropagation","SwitchOption","checked","complex","content","disabled","id","media","onChange","title","showMediaCircle","showMediaAtAllSizes","isContainerAligned","ariaLabel","sharedProps","toggle","_jsx","Option","className","button","Switch","onClick"],"mappings":";;;;AAoBA,MAAMA,eAAe,GAAIC,KAAmC,IAAI;AAC9D,EAAA,IAAIA,KAAK,EAAE;IACTA,KAAK,CAACD,eAAe,EAAE;IACvBC,KAAK,CAACC,cAAc,EAAE;AACtBD,IAAAA,KAAK,CAACE,WAAW,EAAEC,wBAAwB,IAAI;AACjD;AACF,CAAC;AAEKC,MAAAA,YAAY,GAAGA,CAAC;EACpBC,OAAO;EACPC,OAAO;EACPC,OAAO;EACPC,QAAQ;EACRC,EAAE;EACFC,KAAK;EACLC,QAAQ;EACRC,KAAK;EACLC,eAAe;EACfC,mBAAmB;EACnBC,kBAAkB;AAClB,EAAA,YAAY,EAAEC;AAAS,CACL,KAAI;AACtB,EAAA,MAAMC,WAAW,GAAG;IAClBP,KAAK;IACLE,KAAK;IACLL,OAAO;IACPD,OAAO;IACPE,QAAQ;IACRK,eAAe;IACfC,mBAAmB;AACnBC,IAAAA;GACD;EACD,MAAMG,MAAM,GAAIlB,KAAmC,IAAI;IACrDD,eAAe,CAACC,KAAK,CAAC;AACtB,IAAA,IAAIQ,QAAQ,EAAE;AACZ,MAAA;AACF;IAEAG,QAAQ,CAAC,CAACN,OAAO,CAAC;GACnB;EAED,oBACEc,GAAA,CAACC,MAAM,EAAA;AAAA,IAAA,GACDH,WAAW;AACfI,IAAAA,SAAS,EAAC,kBAAkB;IAC5BC,MAAM,eACJH,GAAA,CAACI,MAAM,EAAA;AACLd,MAAAA,EAAE,EAAEA,EAAG;AACPJ,MAAAA,OAAO,EAAEA,OAAQ;AACjBG,MAAAA,QAAQ,EAAEA,QAAS;AACnB,MAAA,YAAA,EAAYQ,SAAU;AACtBQ,MAAAA,OAAO,EAAEN;AAAO,KAEpB,CAAC;AACDM,IAAAA,OAAO,EAAEN;AAAO,GAChB,CAAA;AAEN;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { FC } from 'react';
2
2
  import { AccordionItemProps } from './AccordionItem';
3
- export type AccordionItem = Pick<AccordionItemProps, 'id' | 'title' | 'subtitle' | 'content' | 'icon'>;
3
+ export type AccordionItem = Omit<AccordionItemProps, 'onClick' | 'open' | 'theme'>;
4
4
  export interface AccordionProps {
5
5
  /** The index of the item that should be open by default. */
6
6
  indexOpen?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"Accordion.d.ts","sourceRoot":"","sources":["../../../src/accordion/Accordion.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,EAAE,EAAE,MAAM,OAAO,CAAC;AAErC,OAAsB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAEpE,MAAM,MAAM,aAAa,GAAG,IAAI,CAC9B,kBAAkB,EAClB,IAAI,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG,MAAM,CACjD,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qDAAqD;IACrD,KAAK,EAAE,SAAS,aAAa,EAAE,CAAC;IAChC,kEAAkE;IAClE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,kBAAkB;IAClB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,QAAA,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAkCjC,CAAC;AAEF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"Accordion.d.ts","sourceRoot":"","sources":["../../../src/accordion/Accordion.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,EAAE,EAAE,MAAM,OAAO,CAAC;AAErC,OAAsB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAEpE,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,kBAAkB,EAAE,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;AAEnF,MAAM,WAAW,cAAc;IAC7B,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qDAAqD;IACrD,KAAK,EAAE,SAAS,aAAa,EAAE,CAAC;IAChC,kEAAkE;IAClE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,kBAAkB;IAClB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,QAAA,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAsCjC,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -16,6 +16,14 @@ export interface AccordionItemProps {
16
16
  open: boolean;
17
17
  /** An optional icon to display next to the accordion item title. */
18
18
  icon?: ReactNode;
19
+ /** An optional media element to display next to the accordion item title. */
20
+ media?: ReactNode;
21
+ /** An optional showMediaAtAllSizes with media available at all sizes of the screen. */
22
+ showMediaAtAllSizes?: boolean;
23
+ /** An optional showMediaCircle to display media within the circle. */
24
+ showMediaCircle?: boolean;
25
+ /** An optional isContainerAligned to display media aligned with the container. */
26
+ isContainerAligned?: boolean;
19
27
  /** @deprecated ... */
20
28
  theme?: 'light' | 'dark';
21
29
  }
@@ -33,6 +41,10 @@ export interface AccordionItemProps {
33
41
  * @param {Function} onClick - A callback function that is called when the accordion item is clicked.
34
42
  * @param {boolean} open - Whether the accordion item is currently open or closed.
35
43
  * @param {ReactNode} [icon] - An optional icon to display next to the accordion item title.
44
+ * @param {ReactNode} [media] - An optional media to display next to the accordion item.
45
+ * @param {boolean} [showMediaAtAllSizes] - An optional showMediaAtAllSizes with media available at all sizes of the screen.
46
+ * @param {boolean} [showMediaCircle] - An optional showMediaCircle to display media within the circle.
47
+ * @param {boolean} [isContainerAligned] - An optional isContainerAligned to display media aligned with the container.
36
48
  * @example
37
49
  * // Example usage:
38
50
  *
@@ -1 +1 @@
1
- {"version":3,"file":"AccordionItem.d.ts","sourceRoot":"","sources":["../../../../src/accordion/AccordionItem/AccordionItem.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAC;AAO3D,MAAM,WAAW,kBAAkB;IACjC,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,uCAAuC;IACvC,KAAK,EAAE,SAAS,CAAC;IACjB,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,yCAAyC;IACzC,OAAO,EAAE,SAAS,CAAC;IACnB,6EAA6E;IAC7E,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,8DAA8D;IAC9D,IAAI,EAAE,OAAO,CAAC;IACd,oEAAoE;IACpE,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,sBAAsB;IACtB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,QAAA,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CAoDzC,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"AccordionItem.d.ts","sourceRoot":"","sources":["../../../../src/accordion/AccordionItem/AccordionItem.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAC;AAO3D,MAAM,WAAW,kBAAkB;IACjC,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,uCAAuC;IACvC,KAAK,EAAE,SAAS,CAAC;IACjB,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,yCAAyC;IACzC,OAAO,EAAE,SAAS,CAAC;IACnB,6EAA6E;IAC7E,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,8DAA8D;IAC9D,IAAI,EAAE,OAAO,CAAC;IACd,oEAAoE;IACpE,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,6EAA6E;IAC7E,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,uFAAuF;IACvF,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,sEAAsE;IACtE,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,kFAAkF;IAClF,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,sBAAsB;IACtB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,QAAA,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CA6DzC,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -9,6 +9,11 @@ declare const Body: import("react").ForwardRefExoticComponent<HTMLAttributes<HTM
9
9
  * Default value: `div`
10
10
  */
11
11
  as?: "span" | "p" | "div";
12
+ /**
13
+ * When true, preserves newline characters in the text
14
+ * @default false
15
+ */
16
+ preserveNewlines?: boolean;
12
17
  } & import("react").RefAttributes<HTMLSpanElement | HTMLParagraphElement | HTMLDivElement | null>>;
13
18
  export default Body;
14
19
  //# sourceMappingURL=Body.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Body.d.ts","sourceRoot":"","sources":["../../../src/body/Body.tsx"],"names":[],"mappings":"AACA,OAAO,EAAc,cAAc,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAc,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAsBzE,QAAA,MAAM,IAAI;IAVR;;OAEG;WACI,SAAS;IAChB;;OAEG;SACE,MAAM,GAAG,GAAG,GAAG,KAAK;kGAsBzB,CAAC;AAEH,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"Body.d.ts","sourceRoot":"","sources":["../../../src/body/Body.tsx"],"names":[],"mappings":"AACA,OAAO,EAAc,cAAc,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAc,SAAS,EAAE,MAAM,kCAAkC,CAAC;AA2BzE,QAAA,MAAM,IAAI;IAfR;;OAEG;WACI,SAAS;IAChB;;OAEG;SACE,MAAM,GAAG,GAAG,GAAG,KAAK;IACzB;;;OAGG;uBACgB,OAAO;kGA0B1B,CAAC;AAEH,eAAe,IAAI,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../../src/switch/Switch.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAwB,UAAU,EAAE,MAAM,OAAO,CAAC;AAE9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAG7C,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG;IACtC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yGAAyG;IACzG,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,2CAA2C;IAC3C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0CAA0C;IAC1C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,iDAAiD;IACjD,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,eAAe,CAAC,KAAK,IAAI,CAAC;CACxD,CAAC;AAEF,QAAA,MAAM,MAAM,GAAI,OAAO,WAAW,gCAiDjC,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../../src/switch/Switch.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAwB,UAAU,EAAE,MAAM,OAAO,CAAC;AAE9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAG7C,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG;IACtC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yGAAyG;IACzG,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,2CAA2C;IAC3C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0CAA0C;IAC1C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,iDAAiD;IACjD,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,eAAe,CAAC,KAAK,IAAI,CAAC;CACxD,CAAC;AAEF,QAAA,MAAM,MAAM,GAAI,OAAO,WAAW,gCAwCjC,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"SwitchOption.d.ts","sourceRoot":"","sources":["../../../src/switchOption/SwitchOption.tsx"],"names":[],"mappings":"AAKA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAUF,QAAA,MAAM,YAAY,GAAI,yJAanB,iBAAiB,gCAmCnB,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"SwitchOption.d.ts","sourceRoot":"","sources":["../../../src/switchOption/SwitchOption.tsx"],"names":[],"mappings":"AAKA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAUF,QAAA,MAAM,YAAY,GAAI,yJAanB,iBAAiB,gCAoCnB,CAAC;AAEF,eAAe,YAAY,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "46.98.1",
3
+ "version": "46.100.0",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -43,7 +43,7 @@
43
43
  "@babel/preset-env": "^7.27.2",
44
44
  "@babel/preset-react": "^7.27.1",
45
45
  "@babel/preset-typescript": "^7.27.1",
46
- "@formatjs/cli": "^6.7.1",
46
+ "@formatjs/cli": "^6.7.2",
47
47
  "@rollup/plugin-babel": "^6.0.4",
48
48
  "@rollup/plugin-json": "^6.1.0",
49
49
  "@rollup/plugin-node-resolve": "^15.3.1",
@@ -80,7 +80,7 @@
80
80
  "@types/react-transition-group": "4.4.12",
81
81
  "@wise/art": "^2.21.2",
82
82
  "@wise/eslint-config": "^12.3.0",
83
- "babel-plugin-formatjs": "^10.5.38",
83
+ "babel-plugin-formatjs": "^10.5.39",
84
84
  "eslint": "^9.27.0",
85
85
  "gulp": "^5.0.1",
86
86
  "jest": "^29.7.0",
@@ -88,7 +88,7 @@
88
88
  "jest-fetch-mock": "^3.0.3",
89
89
  "lodash.times": "^4.3.2",
90
90
  "react-intl": "^7.1.11",
91
- "rollup": "^4.42.0",
91
+ "rollup": "^4.43.0",
92
92
  "rollup-preserve-directives": "^1.1.3",
93
93
  "storybook": "^8.6.14",
94
94
  "@transferwise/neptune-css": "14.24.4",
@@ -110,14 +110,14 @@
110
110
  "@floating-ui/react": "^0.27.9",
111
111
  "@headlessui/react": "^1.7.19",
112
112
  "@popperjs/core": "^2.11.8",
113
- "@react-aria/focus": "^3.20.4",
114
- "@react-aria/overlays": "^3.27.2",
113
+ "@react-aria/focus": "^3.20.5",
114
+ "@react-aria/overlays": "^3.27.3",
115
115
  "@react-spring/web": "~10.0.1",
116
116
  "@transferwise/formatting": "^2.13.1",
117
117
  "@transferwise/neptune-validation": "^3.3.0",
118
118
  "clsx": "^2.1.1",
119
119
  "commonmark": "^0.31.2",
120
- "core-js": "^3.42.0",
120
+ "core-js": "^3.43.0",
121
121
  "lodash.clamp": "^4.0.3",
122
122
  "lodash.debounce": "^4.0.8",
123
123
  "merge-props": "^6.0.0",
@@ -27,10 +27,13 @@
27
27
  }.np-accordion-item .np-option .np-option__title {
28
28
  font-weight: 600;
29
29
  font-weight: var(--font-weight-semi-bold);
30
+ }.np-theme-personal .np-accordion-item--with-media .media {
31
+ display: flex;
32
+ align-items: center;
30
33
  }.np-theme-personal .np-accordion-item--with-icon .np-accordion-item__content {
31
34
  padding: 0 56px 16px;
32
35
  padding: 0 var(--size-56) var(--size-16);
33
- }.np-theme-personal .np-accordion-item .media {
36
+ }.np-theme-personal .np-accordion-item--with-icon .media {
34
37
  display: flex;
35
38
  align-items: flex-start;
36
39
  }.np-theme-personal .np-accordion-item .decision__title {
@@ -41,15 +41,20 @@
41
41
  }
42
42
 
43
43
  .np-theme-personal & {
44
+ &--with-media {
45
+ .media {
46
+ display: flex;
47
+ align-items: center;
48
+ }
49
+ }
44
50
  &--with-icon {
45
51
  .np-accordion-item__content {
46
52
  padding: 0 var(--size-56) var(--size-16);
47
53
  }
48
- }
49
-
50
- .media {
51
- display: flex;
52
- align-items: flex-start;
54
+ .media {
55
+ display: flex;
56
+ align-items: flex-start;
57
+ }
53
58
  }
54
59
 
55
60
  .decision__title {
@@ -1,5 +1,5 @@
1
1
  import { Meta, StoryObj } from '@storybook/react';
2
- import { FastFlag as FastFlagIcon } from '@transferwise/icons';
2
+ import { FastFlag as FastFlagIcon, CardWise as CardWiseIcon } from '@transferwise/icons';
3
3
 
4
4
  import { Scroll, Size } from '../common';
5
5
  import Modal from '../modal';
@@ -53,6 +53,34 @@ const meta: Meta<typeof Accordion> = {
53
53
  id: 'Item 5',
54
54
  icon: <FastFlagIcon size={24} />,
55
55
  },
56
+ {
57
+ title: 'Item 6',
58
+ subtitle: 'Sixth item',
59
+ content: lorem10,
60
+ id: 'Item 6',
61
+ icon: <CardWiseIcon size={24} />,
62
+ media: (
63
+ <img
64
+ src="https://wise.com/public-resources/assets/spend/card/asset//digital_card_2023.png"
65
+ alt=""
66
+ />
67
+ ),
68
+ },
69
+ {
70
+ title: 'Item 7',
71
+ subtitle: 'Seventh item',
72
+ content: lorem10,
73
+ id: 'Item 7',
74
+ media: (
75
+ <img
76
+ src="https://wise.com/public-resources/assets/spend/card/asset//digital_card_2023.png"
77
+ alt=""
78
+ />
79
+ ),
80
+ showMediaAtAllSizes: false,
81
+ showMediaCircle: false,
82
+ isContainerAligned: false,
83
+ },
56
84
  ],
57
85
  },
58
86
  };
@@ -81,6 +109,7 @@ export const Multiple: Story = {
81
109
  <Accordion {...args} items={[items[0]]} />
82
110
  <Accordion {...args} items={[items[0]]} indexOpen={0} />
83
111
  <Accordion {...args} items={items} />
112
+ <Accordion {...args} items={[items[6]]} indexOpen={0} />
84
113
  </>
85
114
  );
86
115
  },
@@ -2,10 +2,7 @@ import { useState, FC } from 'react';
2
2
 
3
3
  import AccordionItem, { AccordionItemProps } from './AccordionItem';
4
4
 
5
- export type AccordionItem = Pick<
6
- AccordionItemProps,
7
- 'id' | 'title' | 'subtitle' | 'content' | 'icon'
8
- >;
5
+ export type AccordionItem = Omit<AccordionItemProps, 'onClick' | 'open' | 'theme'>;
9
6
 
10
7
  export interface AccordionProps {
11
8
  /** The index of the item that should be open by default. */
@@ -89,6 +86,10 @@ const Accordion: FC<AccordionProps> = ({ indexOpen = -1, items, onClick, theme =
89
86
  subtitle={item.subtitle}
90
87
  content={item.content}
91
88
  icon={item.icon}
89
+ media={item.media}
90
+ showMediaAtAllSizes={item.showMediaAtAllSizes}
91
+ showMediaCircle={item.showMediaCircle}
92
+ isContainerAligned={item.isContainerAligned}
92
93
  onClick={() => handleOnClick(index)}
93
94
  />
94
95
  ))}
@@ -24,6 +24,14 @@ export interface AccordionItemProps {
24
24
  open: boolean;
25
25
  /** An optional icon to display next to the accordion item title. */
26
26
  icon?: ReactNode;
27
+ /** An optional media element to display next to the accordion item title. */
28
+ media?: ReactNode;
29
+ /** An optional showMediaAtAllSizes with media available at all sizes of the screen. */
30
+ showMediaAtAllSizes?: boolean;
31
+ /** An optional showMediaCircle to display media within the circle. */
32
+ showMediaCircle?: boolean;
33
+ /** An optional isContainerAligned to display media aligned with the container. */
34
+ isContainerAligned?: boolean;
27
35
  /** @deprecated ... */
28
36
  theme?: 'light' | 'dark';
29
37
  }
@@ -42,6 +50,10 @@ export interface AccordionItemProps {
42
50
  * @param {Function} onClick - A callback function that is called when the accordion item is clicked.
43
51
  * @param {boolean} open - Whether the accordion item is currently open or closed.
44
52
  * @param {ReactNode} [icon] - An optional icon to display next to the accordion item title.
53
+ * @param {ReactNode} [media] - An optional media to display next to the accordion item.
54
+ * @param {boolean} [showMediaAtAllSizes] - An optional showMediaAtAllSizes with media available at all sizes of the screen.
55
+ * @param {boolean} [showMediaCircle] - An optional showMediaCircle to display media within the circle.
56
+ * @param {boolean} [isContainerAligned] - An optional isContainerAligned to display media aligned with the container.
45
57
  * @example
46
58
  * // Example usage:
47
59
  *
@@ -72,25 +84,31 @@ const AccordionItem: FC<AccordionItemProps> = ({
72
84
  onClick,
73
85
  open,
74
86
  icon,
87
+ media,
88
+ showMediaAtAllSizes,
89
+ showMediaCircle,
90
+ isContainerAligned,
75
91
  theme = 'light',
76
92
  }) => {
77
- const iconElement = icon
93
+ const mediaElement = icon
78
94
  ? cloneElement(icon as React.ReactElement<IdIconProps>, { size: 24 })
79
- : null;
95
+ : media;
80
96
  const fallbackId = useId();
81
97
  const accordionId = id ?? fallbackId;
82
98
 
83
99
  return (
84
100
  <div
85
101
  id={accordionId}
86
- className={clsx('np-accordion-item', iconElement ? 'np-accordion-item--with-icon' : null, {
102
+ className={clsx('np-accordion-item', {
87
103
  'np-accordion-item--open': open,
104
+ 'np-accordion-item--with-icon': Boolean(icon),
105
+ 'np-accordion-item--with-media': Boolean(media),
88
106
  })}
89
107
  >
90
108
  <Option
91
109
  aria-label={ariaLabel}
92
110
  as="button"
93
- media={iconElement}
111
+ media={mediaElement}
94
112
  title={title}
95
113
  content={subtitle}
96
114
  button={<Chevron orientation={open ? Position.TOP : Position.BOTTOM} size={Size.MEDIUM} />}
@@ -98,6 +116,9 @@ const AccordionItem: FC<AccordionItemProps> = ({
98
116
  aria-expanded={open}
99
117
  aria-controls={`${accordionId}-section`}
100
118
  id={`${accordionId}-control`}
119
+ showMediaCircle={showMediaCircle}
120
+ showMediaAtAllSizes={showMediaAtAllSizes}
121
+ isContainerAligned={isContainerAligned}
101
122
  onClick={onClick}
102
123
  />
103
124
  {open && (
@@ -0,0 +1,3 @@
1
+ .np-text--pre-line {
2
+ white-space: pre-line;
3
+ }
@@ -0,0 +1,3 @@
1
+ .np-text--pre-line {
2
+ white-space: pre-line;
3
+ }
@@ -32,6 +32,14 @@ describe('Body', () => {
32
32
  expect(copy).toHaveAttribute('role', 'banner');
33
33
  });
34
34
 
35
+ it('renders newlines as line breaks when preserveNewlines is true', () => {
36
+ render(<Body preserveNewlines>{'Line 1.\nLine 2'}</Body>);
37
+ const copy = screen.getByText(/Line 1\.\s*Line 2/);
38
+ expect(copy).toHaveClass('np-text--pre-line');
39
+ expect(copy).toHaveTextContent('Line 1.');
40
+ expect(copy).toHaveTextContent('Line 2');
41
+ });
42
+
35
43
  it('handles unsupported typography type', () => {
36
44
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
37
45
  // @ts-expect-error