@transferwise/components 0.0.0-experimental-3330579 → 0.0.0-experimental-67869a3

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.
@@ -33,6 +33,10 @@ const Accordion = ({
33
33
  subtitle: item.subtitle,
34
34
  content: item.content,
35
35
  icon: item.icon,
36
+ media: item.media,
37
+ showMediaAtAllSizes: item.showMediaAtAllSizes,
38
+ showMediaCircle: item.showMediaCircle,
39
+ isContainerAligned: item.isContainerAligned,
36
40
  onClick: () => handleOnClick(index)
37
41
  }, item.id || index))
38
42
  });
@@ -1 +1 @@
1
- {"version":3,"file":"Accordion.js","sources":["../../src/accordion/Accordion.tsx"],"sourcesContent":["import { useState, FC } from 'react';\n\nimport AccordionItem, { AccordionItemProps } from './AccordionItem';\n\nexport type AccordionItem = Pick<\n AccordionItemProps,\n 'id' | 'title' | 'subtitle' | 'content' | 'icon'\n>;\n\nexport interface AccordionProps {\n /** The index of the item that should be open by default. */\n indexOpen?: number;\n /** An array of items to display in the accordion. */\n items: readonly AccordionItem[];\n /** A callback function that is called when an item is clicked. */\n onClick?: (index: number) => void;\n /** @deprecated */\n theme?: 'light' | 'dark';\n}\n\n/**\n * Accordion\n *\n * A simple accordion component that displays a list of items that can be expanded or collapsed.\n *\n * @component\n * @param {number} indexOpen - index of the item that should be open\n * @param {Array<AccordionItemProps>} items - array of items to display\n * @param {Function} onClick - callback function\n * @example\n * // Example usage:\n *\n * import Accordion from './Accordion';\n *\n * const items = [\n * {\n * id: 'item1',\n * title: 'Item 1',\n * content: 'This is the content for item 1.',\n * },\n * {\n * id: 'item2',\n * title: 'Item 2',\n * content: 'This is the content for item 2.',\n * },\n * {\n * id: 'item3',\n * title: 'Item 3',\n * content: 'This is the content for item 3.',\n * },\n * ];\n *\n * function App() {\n * const handleItemClick = (index) => {\n * console.log(`Item ${index} was clicked.`);\n * };\n *\n * return (\n * <Accordion items={items} onClick={handleItemClick} />\n * );\n * }\n */\nconst Accordion: FC<AccordionProps> = ({ indexOpen = -1, items, onClick, theme = 'light' }) => {\n const [itemsOpen, setItemsOpen] = useState(() =>\n items.map((value, index) => index === indexOpen),\n );\n\n /**\n * Handles a click event on an accordion item.\n *\n * @param index The index of the item that was clicked.\n */\n const handleOnClick = (index: number) => {\n if (onClick) {\n onClick(index);\n }\n const newItems = [...itemsOpen];\n newItems[index] = !itemsOpen[index];\n setItemsOpen(newItems);\n };\n\n return (\n <>\n {items.map((item, index) => (\n <AccordionItem\n key={item.id || index}\n open={itemsOpen[index]}\n title={item.title}\n subtitle={item.subtitle}\n content={item.content}\n icon={item.icon}\n onClick={() => handleOnClick(index)}\n />\n ))}\n </>\n );\n};\n\nexport default Accordion;\n"],"names":["Accordion","indexOpen","items","onClick","theme","itemsOpen","setItemsOpen","useState","map","value","index","handleOnClick","newItems","_jsx","_Fragment","children","item","AccordionItem","open","title","subtitle","content","icon","id"],"mappings":";;;;;;;;AA8DMA,MAAAA,SAAS,GAAuBA,CAAC;EAAEC,SAAS,GAAG,EAAE;EAAEC,KAAK;EAAEC,OAAO;AAAEC,EAAAA,KAAK,GAAG;AAAO,CAAE,KAAI;EAC5F,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGC,cAAQ,CAAC,MACzCL,KAAK,CAACM,GAAG,CAAC,CAACC,KAAK,EAAEC,KAAK,KAAKA,KAAK,KAAKT,SAAS,CAAC,CACjD;AAED;;;;AAIG;EACH,MAAMU,aAAa,GAAID,KAAa,IAAI;AACtC,IAAA,IAAIP,OAAO,EAAE;MACXA,OAAO,CAACO,KAAK,CAAC;AAChB;AACA,IAAA,MAAME,QAAQ,GAAG,CAAC,GAAGP,SAAS,CAAC;IAC/BO,QAAQ,CAACF,KAAK,CAAC,GAAG,CAACL,SAAS,CAACK,KAAK,CAAC;IACnCJ,YAAY,CAACM,QAAQ,CAAC;GACvB;EAED,oBACEC,cAAA,CAAAC,mBAAA,EAAA;AAAAC,IAAAA,QAAA,EACGb,KAAK,CAACM,GAAG,CAAC,CAACQ,IAAI,EAAEN,KAAK,kBACrBG,cAAA,CAACI,qBAAa,EAAA;AAEZC,MAAAA,IAAI,EAAEb,SAAS,CAACK,KAAK,CAAE;MACvBS,KAAK,EAAEH,IAAI,CAACG,KAAM;MAClBC,QAAQ,EAAEJ,IAAI,CAACI,QAAS;MACxBC,OAAO,EAAEL,IAAI,CAACK,OAAQ;MACtBC,IAAI,EAAEN,IAAI,CAACM,IAAK;AAChBnB,MAAAA,OAAO,EAAEA,MAAMQ,aAAa,CAACD,KAAK;AAAE,KAAA,EAN/BM,IAAI,CAACO,EAAE,IAAIb,KAOhB,CACH;AAAC,GACJ,CAAG;AAEP;;;;"}
1
+ {"version":3,"file":"Accordion.js","sources":["../../src/accordion/Accordion.tsx"],"sourcesContent":["import { useState, FC } from 'react';\n\nimport AccordionItem, { AccordionItemProps } from './AccordionItem';\n\nexport type AccordionItem = Omit<AccordionItemProps, 'onClick' | 'open' | 'theme'>;\n\nexport interface AccordionProps {\n /** The index of the item that should be open by default. */\n indexOpen?: number;\n /** An array of items to display in the accordion. */\n items: readonly AccordionItem[];\n /** A callback function that is called when an item is clicked. */\n onClick?: (index: number) => void;\n /** @deprecated */\n theme?: 'light' | 'dark';\n}\n\n/**\n * Accordion\n *\n * A simple accordion component that displays a list of items that can be expanded or collapsed.\n *\n * @component\n * @param {number} indexOpen - index of the item that should be open\n * @param {Array<AccordionItemProps>} items - array of items to display\n * @param {Function} onClick - callback function\n * @example\n * // Example usage:\n *\n * import Accordion from './Accordion';\n *\n * const items = [\n * {\n * id: 'item1',\n * title: 'Item 1',\n * content: 'This is the content for item 1.',\n * },\n * {\n * id: 'item2',\n * title: 'Item 2',\n * content: 'This is the content for item 2.',\n * },\n * {\n * id: 'item3',\n * title: 'Item 3',\n * content: 'This is the content for item 3.',\n * },\n * ];\n *\n * function App() {\n * const handleItemClick = (index) => {\n * console.log(`Item ${index} was clicked.`);\n * };\n *\n * return (\n * <Accordion items={items} onClick={handleItemClick} />\n * );\n * }\n */\nconst Accordion: FC<AccordionProps> = ({ indexOpen = -1, items, onClick, theme = 'light' }) => {\n const [itemsOpen, setItemsOpen] = useState(() =>\n items.map((value, index) => index === indexOpen),\n );\n\n /**\n * Handles a click event on an accordion item.\n *\n * @param index The index of the item that was clicked.\n */\n const handleOnClick = (index: number) => {\n if (onClick) {\n onClick(index);\n }\n const newItems = [...itemsOpen];\n newItems[index] = !itemsOpen[index];\n setItemsOpen(newItems);\n };\n\n return (\n <>\n {items.map((item, index) => (\n <AccordionItem\n key={item.id || index}\n open={itemsOpen[index]}\n title={item.title}\n subtitle={item.subtitle}\n content={item.content}\n icon={item.icon}\n media={item.media}\n showMediaAtAllSizes={item.showMediaAtAllSizes}\n showMediaCircle={item.showMediaCircle}\n isContainerAligned={item.isContainerAligned}\n onClick={() => handleOnClick(index)}\n />\n ))}\n </>\n );\n};\n\nexport default Accordion;\n"],"names":["Accordion","indexOpen","items","onClick","theme","itemsOpen","setItemsOpen","useState","map","value","index","handleOnClick","newItems","_jsx","_Fragment","children","item","AccordionItem","open","title","subtitle","content","icon","media","showMediaAtAllSizes","showMediaCircle","isContainerAligned","id"],"mappings":";;;;;;;;AA2DMA,MAAAA,SAAS,GAAuBA,CAAC;EAAEC,SAAS,GAAG,EAAE;EAAEC,KAAK;EAAEC,OAAO;AAAEC,EAAAA,KAAK,GAAG;AAAO,CAAE,KAAI;EAC5F,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGC,cAAQ,CAAC,MACzCL,KAAK,CAACM,GAAG,CAAC,CAACC,KAAK,EAAEC,KAAK,KAAKA,KAAK,KAAKT,SAAS,CAAC,CACjD;AAED;;;;AAIG;EACH,MAAMU,aAAa,GAAID,KAAa,IAAI;AACtC,IAAA,IAAIP,OAAO,EAAE;MACXA,OAAO,CAACO,KAAK,CAAC;AAChB;AACA,IAAA,MAAME,QAAQ,GAAG,CAAC,GAAGP,SAAS,CAAC;IAC/BO,QAAQ,CAACF,KAAK,CAAC,GAAG,CAACL,SAAS,CAACK,KAAK,CAAC;IACnCJ,YAAY,CAACM,QAAQ,CAAC;GACvB;EAED,oBACEC,cAAA,CAAAC,mBAAA,EAAA;AAAAC,IAAAA,QAAA,EACGb,KAAK,CAACM,GAAG,CAAC,CAACQ,IAAI,EAAEN,KAAK,kBACrBG,cAAA,CAACI,qBAAa,EAAA;AAEZC,MAAAA,IAAI,EAAEb,SAAS,CAACK,KAAK,CAAE;MACvBS,KAAK,EAAEH,IAAI,CAACG,KAAM;MAClBC,QAAQ,EAAEJ,IAAI,CAACI,QAAS;MACxBC,OAAO,EAAEL,IAAI,CAACK,OAAQ;MACtBC,IAAI,EAAEN,IAAI,CAACM,IAAK;MAChBC,KAAK,EAAEP,IAAI,CAACO,KAAM;MAClBC,mBAAmB,EAAER,IAAI,CAACQ,mBAAoB;MAC9CC,eAAe,EAAET,IAAI,CAACS,eAAgB;MACtCC,kBAAkB,EAAEV,IAAI,CAACU,kBAAmB;AAC5CvB,MAAAA,OAAO,EAAEA,MAAMQ,aAAa,CAACD,KAAK;AAAE,KAAA,EAV/BM,IAAI,CAACW,EAAE,IAAIjB,KAUoB,CAEvC;AAAC,GACJ,CAAG;AAEP;;;;"}
@@ -29,6 +29,10 @@ const Accordion = ({
29
29
  subtitle: item.subtitle,
30
30
  content: item.content,
31
31
  icon: item.icon,
32
+ media: item.media,
33
+ showMediaAtAllSizes: item.showMediaAtAllSizes,
34
+ showMediaCircle: item.showMediaCircle,
35
+ isContainerAligned: item.isContainerAligned,
32
36
  onClick: () => handleOnClick(index)
33
37
  }, item.id || index))
34
38
  });
@@ -1 +1 @@
1
- {"version":3,"file":"Accordion.mjs","sources":["../../src/accordion/Accordion.tsx"],"sourcesContent":["import { useState, FC } from 'react';\n\nimport AccordionItem, { AccordionItemProps } from './AccordionItem';\n\nexport type AccordionItem = Pick<\n AccordionItemProps,\n 'id' | 'title' | 'subtitle' | 'content' | 'icon'\n>;\n\nexport interface AccordionProps {\n /** The index of the item that should be open by default. */\n indexOpen?: number;\n /** An array of items to display in the accordion. */\n items: readonly AccordionItem[];\n /** A callback function that is called when an item is clicked. */\n onClick?: (index: number) => void;\n /** @deprecated */\n theme?: 'light' | 'dark';\n}\n\n/**\n * Accordion\n *\n * A simple accordion component that displays a list of items that can be expanded or collapsed.\n *\n * @component\n * @param {number} indexOpen - index of the item that should be open\n * @param {Array<AccordionItemProps>} items - array of items to display\n * @param {Function} onClick - callback function\n * @example\n * // Example usage:\n *\n * import Accordion from './Accordion';\n *\n * const items = [\n * {\n * id: 'item1',\n * title: 'Item 1',\n * content: 'This is the content for item 1.',\n * },\n * {\n * id: 'item2',\n * title: 'Item 2',\n * content: 'This is the content for item 2.',\n * },\n * {\n * id: 'item3',\n * title: 'Item 3',\n * content: 'This is the content for item 3.',\n * },\n * ];\n *\n * function App() {\n * const handleItemClick = (index) => {\n * console.log(`Item ${index} was clicked.`);\n * };\n *\n * return (\n * <Accordion items={items} onClick={handleItemClick} />\n * );\n * }\n */\nconst Accordion: FC<AccordionProps> = ({ indexOpen = -1, items, onClick, theme = 'light' }) => {\n const [itemsOpen, setItemsOpen] = useState(() =>\n items.map((value, index) => index === indexOpen),\n );\n\n /**\n * Handles a click event on an accordion item.\n *\n * @param index The index of the item that was clicked.\n */\n const handleOnClick = (index: number) => {\n if (onClick) {\n onClick(index);\n }\n const newItems = [...itemsOpen];\n newItems[index] = !itemsOpen[index];\n setItemsOpen(newItems);\n };\n\n return (\n <>\n {items.map((item, index) => (\n <AccordionItem\n key={item.id || index}\n open={itemsOpen[index]}\n title={item.title}\n subtitle={item.subtitle}\n content={item.content}\n icon={item.icon}\n onClick={() => handleOnClick(index)}\n />\n ))}\n </>\n );\n};\n\nexport default Accordion;\n"],"names":["Accordion","indexOpen","items","onClick","theme","itemsOpen","setItemsOpen","useState","map","value","index","handleOnClick","newItems","_jsx","_Fragment","children","item","AccordionItem","open","title","subtitle","content","icon","id"],"mappings":";;;;AA8DMA,MAAAA,SAAS,GAAuBA,CAAC;EAAEC,SAAS,GAAG,EAAE;EAAEC,KAAK;EAAEC,OAAO;AAAEC,EAAAA,KAAK,GAAG;AAAO,CAAE,KAAI;EAC5F,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGC,QAAQ,CAAC,MACzCL,KAAK,CAACM,GAAG,CAAC,CAACC,KAAK,EAAEC,KAAK,KAAKA,KAAK,KAAKT,SAAS,CAAC,CACjD;AAED;;;;AAIG;EACH,MAAMU,aAAa,GAAID,KAAa,IAAI;AACtC,IAAA,IAAIP,OAAO,EAAE;MACXA,OAAO,CAACO,KAAK,CAAC;AAChB;AACA,IAAA,MAAME,QAAQ,GAAG,CAAC,GAAGP,SAAS,CAAC;IAC/BO,QAAQ,CAACF,KAAK,CAAC,GAAG,CAACL,SAAS,CAACK,KAAK,CAAC;IACnCJ,YAAY,CAACM,QAAQ,CAAC;GACvB;EAED,oBACEC,GAAA,CAAAC,QAAA,EAAA;AAAAC,IAAAA,QAAA,EACGb,KAAK,CAACM,GAAG,CAAC,CAACQ,IAAI,EAAEN,KAAK,kBACrBG,GAAA,CAACI,aAAa,EAAA;AAEZC,MAAAA,IAAI,EAAEb,SAAS,CAACK,KAAK,CAAE;MACvBS,KAAK,EAAEH,IAAI,CAACG,KAAM;MAClBC,QAAQ,EAAEJ,IAAI,CAACI,QAAS;MACxBC,OAAO,EAAEL,IAAI,CAACK,OAAQ;MACtBC,IAAI,EAAEN,IAAI,CAACM,IAAK;AAChBnB,MAAAA,OAAO,EAAEA,MAAMQ,aAAa,CAACD,KAAK;AAAE,KAAA,EAN/BM,IAAI,CAACO,EAAE,IAAIb,KAOhB,CACH;AAAC,GACJ,CAAG;AAEP;;;;"}
1
+ {"version":3,"file":"Accordion.mjs","sources":["../../src/accordion/Accordion.tsx"],"sourcesContent":["import { useState, FC } from 'react';\n\nimport AccordionItem, { AccordionItemProps } from './AccordionItem';\n\nexport type AccordionItem = Omit<AccordionItemProps, 'onClick' | 'open' | 'theme'>;\n\nexport interface AccordionProps {\n /** The index of the item that should be open by default. */\n indexOpen?: number;\n /** An array of items to display in the accordion. */\n items: readonly AccordionItem[];\n /** A callback function that is called when an item is clicked. */\n onClick?: (index: number) => void;\n /** @deprecated */\n theme?: 'light' | 'dark';\n}\n\n/**\n * Accordion\n *\n * A simple accordion component that displays a list of items that can be expanded or collapsed.\n *\n * @component\n * @param {number} indexOpen - index of the item that should be open\n * @param {Array<AccordionItemProps>} items - array of items to display\n * @param {Function} onClick - callback function\n * @example\n * // Example usage:\n *\n * import Accordion from './Accordion';\n *\n * const items = [\n * {\n * id: 'item1',\n * title: 'Item 1',\n * content: 'This is the content for item 1.',\n * },\n * {\n * id: 'item2',\n * title: 'Item 2',\n * content: 'This is the content for item 2.',\n * },\n * {\n * id: 'item3',\n * title: 'Item 3',\n * content: 'This is the content for item 3.',\n * },\n * ];\n *\n * function App() {\n * const handleItemClick = (index) => {\n * console.log(`Item ${index} was clicked.`);\n * };\n *\n * return (\n * <Accordion items={items} onClick={handleItemClick} />\n * );\n * }\n */\nconst Accordion: FC<AccordionProps> = ({ indexOpen = -1, items, onClick, theme = 'light' }) => {\n const [itemsOpen, setItemsOpen] = useState(() =>\n items.map((value, index) => index === indexOpen),\n );\n\n /**\n * Handles a click event on an accordion item.\n *\n * @param index The index of the item that was clicked.\n */\n const handleOnClick = (index: number) => {\n if (onClick) {\n onClick(index);\n }\n const newItems = [...itemsOpen];\n newItems[index] = !itemsOpen[index];\n setItemsOpen(newItems);\n };\n\n return (\n <>\n {items.map((item, index) => (\n <AccordionItem\n key={item.id || index}\n open={itemsOpen[index]}\n title={item.title}\n subtitle={item.subtitle}\n content={item.content}\n icon={item.icon}\n media={item.media}\n showMediaAtAllSizes={item.showMediaAtAllSizes}\n showMediaCircle={item.showMediaCircle}\n isContainerAligned={item.isContainerAligned}\n onClick={() => handleOnClick(index)}\n />\n ))}\n </>\n );\n};\n\nexport default Accordion;\n"],"names":["Accordion","indexOpen","items","onClick","theme","itemsOpen","setItemsOpen","useState","map","value","index","handleOnClick","newItems","_jsx","_Fragment","children","item","AccordionItem","open","title","subtitle","content","icon","media","showMediaAtAllSizes","showMediaCircle","isContainerAligned","id"],"mappings":";;;;AA2DMA,MAAAA,SAAS,GAAuBA,CAAC;EAAEC,SAAS,GAAG,EAAE;EAAEC,KAAK;EAAEC,OAAO;AAAEC,EAAAA,KAAK,GAAG;AAAO,CAAE,KAAI;EAC5F,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGC,QAAQ,CAAC,MACzCL,KAAK,CAACM,GAAG,CAAC,CAACC,KAAK,EAAEC,KAAK,KAAKA,KAAK,KAAKT,SAAS,CAAC,CACjD;AAED;;;;AAIG;EACH,MAAMU,aAAa,GAAID,KAAa,IAAI;AACtC,IAAA,IAAIP,OAAO,EAAE;MACXA,OAAO,CAACO,KAAK,CAAC;AAChB;AACA,IAAA,MAAME,QAAQ,GAAG,CAAC,GAAGP,SAAS,CAAC;IAC/BO,QAAQ,CAACF,KAAK,CAAC,GAAG,CAACL,SAAS,CAACK,KAAK,CAAC;IACnCJ,YAAY,CAACM,QAAQ,CAAC;GACvB;EAED,oBACEC,GAAA,CAAAC,QAAA,EAAA;AAAAC,IAAAA,QAAA,EACGb,KAAK,CAACM,GAAG,CAAC,CAACQ,IAAI,EAAEN,KAAK,kBACrBG,GAAA,CAACI,aAAa,EAAA;AAEZC,MAAAA,IAAI,EAAEb,SAAS,CAACK,KAAK,CAAE;MACvBS,KAAK,EAAEH,IAAI,CAACG,KAAM;MAClBC,QAAQ,EAAEJ,IAAI,CAACI,QAAS;MACxBC,OAAO,EAAEL,IAAI,CAACK,OAAQ;MACtBC,IAAI,EAAEN,IAAI,CAACM,IAAK;MAChBC,KAAK,EAAEP,IAAI,CAACO,KAAM;MAClBC,mBAAmB,EAAER,IAAI,CAACQ,mBAAoB;MAC9CC,eAAe,EAAET,IAAI,CAACS,eAAgB;MACtCC,kBAAkB,EAAEV,IAAI,CAACU,kBAAmB;AAC5CvB,MAAAA,OAAO,EAAEA,MAAMQ,aAAa,CAACD,KAAK;AAAE,KAAA,EAV/BM,IAAI,CAACW,EAAE,IAAIjB,KAUoB,CAEvC;AAAC,GACJ,CAAG;AAEP;;;;"}
@@ -40,22 +40,27 @@ const AccordionItem = ({
40
40
  onClick,
41
41
  open,
42
42
  icon,
43
+ media,
44
+ showMediaAtAllSizes,
45
+ showMediaCircle,
46
+ isContainerAligned,
43
47
  theme = 'light'
44
48
  }) => {
45
- const iconElement = icon ? /*#__PURE__*/React.cloneElement(icon, {
49
+ const mediaElement = icon ? /*#__PURE__*/React.cloneElement(icon, {
46
50
  size: 24
47
- }) : null;
51
+ }) : media;
48
52
  const fallbackId = React.useId();
49
53
  const accordionId = id ?? fallbackId;
50
54
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
51
55
  id: accordionId,
52
- className: clsx.clsx('np-accordion-item', iconElement ? 'np-accordion-item--with-icon' : null, {
53
- 'np-accordion-item--open': open
56
+ className: clsx.clsx('np-accordion-item', {
57
+ 'np-accordion-item--open': open,
58
+ 'np-accordion-item--with-icon': Boolean(icon)
54
59
  }),
55
60
  children: [/*#__PURE__*/jsxRuntime.jsx(Option.default, {
56
61
  "aria-label": ariaLabel,
57
62
  as: "button",
58
- media: iconElement,
63
+ media: mediaElement,
59
64
  title: title,
60
65
  content: subtitle,
61
66
  button: /*#__PURE__*/jsxRuntime.jsx(Chevron.default, {
@@ -66,6 +71,9 @@ const AccordionItem = ({
66
71
  "aria-expanded": open,
67
72
  "aria-controls": `${accordionId}-section`,
68
73
  id: `${accordionId}-control`,
74
+ showMediaCircle: showMediaCircle,
75
+ showMediaAtAllSizes: showMediaAtAllSizes,
76
+ isContainerAligned: isContainerAligned,
69
77
  onClick: onClick
70
78
  }), open && /*#__PURE__*/jsxRuntime.jsx("div", {
71
79
  id: `${accordionId}-section`,
@@ -1 +1 @@
1
- {"version":3,"file":"AccordionItem.js","sources":["../../../src/accordion/AccordionItem/AccordionItem.tsx"],"sourcesContent":["import { IdIconProps } from '@transferwise/icons';\nimport { clsx } from 'clsx';\nimport { FC, ReactNode, cloneElement, useId } from 'react';\n\nimport Body from '../../body';\nimport Chevron from '../../chevron';\nimport { Position, Size, Typography } from '../../common';\nimport Option from '../../common/Option';\n\nexport interface AccordionItemProps {\n /** A label for the accordion item, used for accessibility purposes. */\n 'aria-label'?: string;\n /** An ID for the accordion item, used for accessibility purposes. */\n id?: string;\n /** The title of the accordion item. */\n title: ReactNode;\n /** The subtitle of the accordion item. */\n subtitle?: ReactNode;\n /** The content of the accordion item. */\n content: ReactNode;\n /** A callback function that is called when the accordion item is clicked. */\n onClick: () => void;\n /** Whether the accordion item is currently open or closed. */\n open: boolean;\n /** An optional icon to display next to the accordion item title. */\n icon?: ReactNode;\n /** @deprecated ... */\n theme?: 'light' | 'dark';\n}\n\n/**\n * AccordionItem\n *\n * A single item in an accordion component.\n *\n * @component\n * @param {string} [aria-label] - A label for the accordion item, used for accessibility purposes.\n * @param {string} [id] - An ID for the accordion item, used for accessibility purposes.\n * @param {ReactNode} title - The title of the accordion item.\n * @param {ReactNode} subtitle - The subtitle of the accordion item.\n * @param {ReactNode} content - The content of the accordion item.\n * @param {Function} onClick - A callback function that is called when the accordion item is clicked.\n * @param {boolean} open - Whether the accordion item is currently open or closed.\n * @param {ReactNode} [icon] - An optional icon to display next to the accordion item title.\n * @example\n * // Example usage:\n *\n * import AccordionItem from './AccordionItem';\n *\n * function App() {\n * const handleItemClick = () => {\n * console.log('Accordion item was clicked.');\n * };\n *\n * return (\n * <AccordionItem\n * title={<h2>Item Title</h2>}\n * content={<p>Item content goes here.</p>}\n * onClick={handleItemClick}\n * open={true}\n * icon={<Chevron />}\n * />\n * );\n * }\n */\nconst AccordionItem: FC<AccordionItemProps> = ({\n 'aria-label': ariaLabel,\n id,\n title,\n subtitle,\n content,\n onClick,\n open,\n icon,\n theme = 'light',\n}) => {\n const iconElement = icon\n ? cloneElement(icon as React.ReactElement<IdIconProps>, { size: 24 })\n : null;\n const fallbackId = useId();\n const accordionId = id ?? fallbackId;\n\n return (\n <div\n id={accordionId}\n className={clsx('np-accordion-item', iconElement ? 'np-accordion-item--with-icon' : null, {\n 'np-accordion-item--open': open,\n })}\n >\n <Option\n aria-label={ariaLabel}\n as=\"button\"\n media={iconElement}\n title={title}\n content={subtitle}\n button={<Chevron orientation={open ? Position.TOP : Position.BOTTOM} size={Size.MEDIUM} />}\n inverseMediaCircle={false}\n aria-expanded={open}\n aria-controls={`${accordionId}-section`}\n id={`${accordionId}-control`}\n onClick={onClick}\n />\n {open && (\n <div id={`${accordionId}-section`} role=\"region\" aria-labelledby={`${accordionId}-control`}>\n <Body\n as=\"span\"\n type={Typography.BODY_LARGE}\n className={clsx('np-accordion-item__content', 'd-block', {\n 'has-icon': icon,\n })}\n >\n {content}\n </Body>\n </div>\n )}\n </div>\n );\n};\n\nexport default AccordionItem;\n"],"names":["AccordionItem","ariaLabel","id","title","subtitle","content","onClick","open","icon","theme","iconElement","cloneElement","size","fallbackId","useId","accordionId","_jsxs","className","clsx","children","_jsx","Option","as","media","button","Chevron","orientation","Position","TOP","BOTTOM","Size","MEDIUM","inverseMediaCircle","role","Body","type","Typography","BODY_LARGE"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEMA,MAAAA,aAAa,GAA2BA,CAAC;AAC7C,EAAA,YAAY,EAAEC,SAAS;EACvBC,EAAE;EACFC,KAAK;EACLC,QAAQ;EACRC,OAAO;EACPC,OAAO;EACPC,IAAI;EACJC,IAAI;AACJC,EAAAA,KAAK,GAAG;AACT,CAAA,KAAI;AACH,EAAA,MAAMC,WAAW,GAAGF,IAAI,gBACpBG,kBAAY,CAACH,IAAuC,EAAE;AAAEI,IAAAA,IAAI,EAAE;GAAI,CAAC,GACnE,IAAI;AACR,EAAA,MAAMC,UAAU,GAAGC,WAAK,EAAE;AAC1B,EAAA,MAAMC,WAAW,GAAGb,EAAE,IAAIW,UAAU;AAEpC,EAAA,oBACEG,eAAA,CAAA,KAAA,EAAA;AAC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EAEFd;OACG;AACR,KAAK,CACN;AAAA,GACE,CAAC;AAEV;;;;"}
1
+ {"version":3,"file":"AccordionItem.js","sources":["../../../src/accordion/AccordionItem/AccordionItem.tsx"],"sourcesContent":["import { IdIconProps } from '@transferwise/icons';\nimport { clsx } from 'clsx';\nimport { FC, ReactNode, cloneElement, useId } from 'react';\n\nimport Body from '../../body';\nimport Chevron from '../../chevron';\nimport { Position, Size, Typography } from '../../common';\nimport Option from '../../common/Option';\n\nexport interface AccordionItemProps {\n /** A label for the accordion item, used for accessibility purposes. */\n 'aria-label'?: string;\n /** An ID for the accordion item, used for accessibility purposes. */\n id?: string;\n /** The title of the accordion item. */\n title: ReactNode;\n /** The subtitle of the accordion item. */\n subtitle?: ReactNode;\n /** The content of the accordion item. */\n content: ReactNode;\n /** A callback function that is called when the accordion item is clicked. */\n onClick: () => void;\n /** Whether the accordion item is currently open or closed. */\n open: boolean;\n /** An optional icon to display next to the accordion item title. */\n icon?: ReactNode;\n /** An optional media element to display next to the accordion item title. */\n media?: ReactNode;\n /** An optional showMediaAtAllSizes with media available at all sizes of the screen. */\n showMediaAtAllSizes?: boolean;\n /** An optional showMediaCircle to display media within the circle. */\n showMediaCircle?: boolean;\n /** An optional isContainerAligned to display media aligned with the container. */\n isContainerAligned?: boolean;\n /** @deprecated ... */\n theme?: 'light' | 'dark';\n}\n\n/**\n * AccordionItem\n *\n * A single item in an accordion component.\n *\n * @component\n * @param {string} [aria-label] - A label for the accordion item, used for accessibility purposes.\n * @param {string} [id] - An ID for the accordion item, used for accessibility purposes.\n * @param {ReactNode} title - The title of the accordion item.\n * @param {ReactNode} subtitle - The subtitle of the accordion item.\n * @param {ReactNode} content - The content of the accordion item.\n * @param {Function} onClick - A callback function that is called when the accordion item is clicked.\n * @param {boolean} open - Whether the accordion item is currently open or closed.\n * @param {ReactNode} [icon] - An optional icon to display next to the accordion item title.\n * @param {ReactNode} [media] - An optional media to display next to the accordion item.\n * @param {boolean} [showMediaAtAllSizes] - An optional showMediaAtAllSizes with media available at all sizes of the screen.\n * @param {boolean} [showMediaCircle] - An optional showMediaCircle to display media within the circle.\n * @param {boolean} [isContainerAligned] - An optional isContainerAligned to display media aligned with the container.\n * @example\n * // Example usage:\n *\n * import AccordionItem from './AccordionItem';\n *\n * function App() {\n * const handleItemClick = () => {\n * console.log('Accordion item was clicked.');\n * };\n *\n * return (\n * <AccordionItem\n * title={<h2>Item Title</h2>}\n * content={<p>Item content goes here.</p>}\n * onClick={handleItemClick}\n * open={true}\n * icon={<Chevron />}\n * />\n * );\n * }\n */\nconst AccordionItem: FC<AccordionItemProps> = ({\n 'aria-label': ariaLabel,\n id,\n title,\n subtitle,\n content,\n onClick,\n open,\n icon,\n media,\n showMediaAtAllSizes,\n showMediaCircle,\n isContainerAligned,\n theme = 'light',\n}) => {\n const mediaElement = icon\n ? cloneElement(icon as React.ReactElement<IdIconProps>, { size: 24 })\n : media;\n const fallbackId = useId();\n const accordionId = id ?? fallbackId;\n\n return (\n <div\n id={accordionId}\n className={clsx('np-accordion-item', {\n 'np-accordion-item--open': open,\n 'np-accordion-item--with-icon': Boolean(icon),\n })}\n >\n <Option\n aria-label={ariaLabel}\n as=\"button\"\n media={mediaElement}\n title={title}\n content={subtitle}\n button={<Chevron orientation={open ? Position.TOP : Position.BOTTOM} size={Size.MEDIUM} />}\n inverseMediaCircle={false}\n aria-expanded={open}\n aria-controls={`${accordionId}-section`}\n id={`${accordionId}-control`}\n showMediaCircle={showMediaCircle}\n showMediaAtAllSizes={showMediaAtAllSizes}\n isContainerAligned={isContainerAligned}\n onClick={onClick}\n />\n {open && (\n <div id={`${accordionId}-section`} role=\"region\" aria-labelledby={`${accordionId}-control`}>\n <Body\n as=\"span\"\n type={Typography.BODY_LARGE}\n className={clsx('np-accordion-item__content', 'd-block', {\n 'has-icon': icon,\n })}\n >\n {content}\n </Body>\n </div>\n )}\n </div>\n );\n};\n\nexport default AccordionItem;\n"],"names":["AccordionItem","ariaLabel","id","title","subtitle","content","onClick","open","icon","media","showMediaAtAllSizes","showMediaCircle","isContainerAligned","theme","mediaElement","cloneElement","size","fallbackId","useId","accordionId","_jsxs","className","clsx","Boolean","children","_jsx","Option","as","button","Chevron","orientation","Position","TOP","BOTTOM","Size","MEDIUM","inverseMediaCircle","role","Body","type","Typography","BODY_LARGE"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6EMA,MAAAA,aAAa,GAA2BA,CAAC;AAC7C,EAAA,YAAY,EAAEC,SAAS;EACvBC,EAAE;EACFC,KAAK;EACLC,QAAQ;EACRC,OAAO;EACPC,OAAO;EACPC,IAAI;EACJC,IAAI;EACJC,KAAK;EACLC,mBAAmB;EACnBC,eAAe;EACfC,kBAAkB;AAClBC,EAAAA,KAAK,GAAG;AAAO,CAChB,KAAI;AACH,EAAA,MAAMC,YAAY,GAAGN,IAAI,gBACrBO,kBAAY,CAACP,IAAuC,EAAE;AAAEQ,IAAAA,IAAI,EAAE;GAAI,CAAC,GACnEP,KAAK;AACT,EAAA,MAAMQ,UAAU,GAAGC,WAAK,EAAE;AAC1B,EAAA,MAAMC,WAAW,GAAGjB,EAAE,IAAIe,UAAU;AAEpC,EAAA,oBACEG,eAAA,CAAA,KAAA,EAAA;AACElB,IAAAA,EAAE,EAAEiB,WAAY;AAChBE,IAAAA,SAAS,EAAEC,SAAI,CAAC,mBAAmB,EAAE;AACnC,MAAA,yBAAyB,EAAEf,IAAI;MAC/B,8BAA8B,EAAEgB,OAAO,CAACf,IAAI;AAC7C,KAAA,CAAE;IAAAgB,QAAA,EAAA,cAEHC,cAAA,CAACC,cAAM,EAAA;AACL,MAAA,YAAA,EAAYzB,SAAU;AACtB0B,MAAAA,EAAE,EAAC,QAAQ;AACXlB,MAAAA,KAAK,EAAEK,YAAa;AACpBX,MAAAA,KAAK,EAAEA,KAAM;AACbE,MAAAA,OAAO,EAAED,QAAS;MAClBwB,MAAM,eAAEH,cAAA,CAACI,eAAO,EAAA;QAACC,WAAW,EAAEvB,IAAI,GAAGwB,iBAAQ,CAACC,GAAG,GAAGD,iBAAQ,CAACE,MAAO;QAACjB,IAAI,EAAEkB,SAAI,CAACC;AAAO,OAAA,CAAI;AAC3FC,MAAAA,kBAAkB,EAAE,KAAM;AAC1B,MAAA,eAAA,EAAe7B,IAAK;MACpB,eAAe,EAAA,CAAA,EAAGY,WAAW,CAAW,QAAA,CAAA;MACxCjB,EAAE,EAAE,CAAGiB,EAAAA,WAAW,CAAW,QAAA,CAAA;AAC7BR,MAAAA,eAAe,EAAEA,eAAgB;AACjCD,MAAAA,mBAAmB,EAAEA,mBAAoB;AACzCE,MAAAA,kBAAkB,EAAEA,kBAAmB;AACvCN,MAAAA,OAAO,EAAEA;AAAQ,KAEnB,CAAA,EAACC,IAAI,iBACHkB,cAAA,CAAA,KAAA,EAAA;MAAKvB,EAAE,EAAE,CAAGiB,EAAAA,WAAW,CAAW,QAAA,CAAA;AAACkB,MAAAA,IAAI,EAAC,QAAQ;MAAC,iBAAiB,EAAA,CAAA,EAAGlB,WAAW,CAAW,QAAA,CAAA;MAAAK,QAAA,eACzFC,cAAA,CAACa,YAAI,EAAA;AACHX,QAAAA,EAAE,EAAC,MAAM;QACTY,IAAI,EAAEC,qBAAU,CAACC,UAAW;AAC5BpB,QAAAA,SAAS,EAAEC,SAAI,CAAC,4BAA4B,EAAE,SAAS,EAAE;AACvD,UAAA,UAAU,EAAEd;AACb,SAAA,CAAE;AAAAgB,QAAAA,QAAA,EAEFnB;OACG;AACR,KAAK,CACN;AAAA,GACE,CAAC;AAEV;;;;"}
@@ -36,22 +36,27 @@ const AccordionItem = ({
36
36
  onClick,
37
37
  open,
38
38
  icon,
39
+ media,
40
+ showMediaAtAllSizes,
41
+ showMediaCircle,
42
+ isContainerAligned,
39
43
  theme = 'light'
40
44
  }) => {
41
- const iconElement = icon ? /*#__PURE__*/cloneElement(icon, {
45
+ const mediaElement = icon ? /*#__PURE__*/cloneElement(icon, {
42
46
  size: 24
43
- }) : null;
47
+ }) : media;
44
48
  const fallbackId = useId();
45
49
  const accordionId = id ?? fallbackId;
46
50
  return /*#__PURE__*/jsxs("div", {
47
51
  id: accordionId,
48
- className: clsx('np-accordion-item', iconElement ? 'np-accordion-item--with-icon' : null, {
49
- 'np-accordion-item--open': open
52
+ className: clsx('np-accordion-item', {
53
+ 'np-accordion-item--open': open,
54
+ 'np-accordion-item--with-icon': Boolean(icon)
50
55
  }),
51
56
  children: [/*#__PURE__*/jsx(Option, {
52
57
  "aria-label": ariaLabel,
53
58
  as: "button",
54
- media: iconElement,
59
+ media: mediaElement,
55
60
  title: title,
56
61
  content: subtitle,
57
62
  button: /*#__PURE__*/jsx(Chevron, {
@@ -62,6 +67,9 @@ const AccordionItem = ({
62
67
  "aria-expanded": open,
63
68
  "aria-controls": `${accordionId}-section`,
64
69
  id: `${accordionId}-control`,
70
+ showMediaCircle: showMediaCircle,
71
+ showMediaAtAllSizes: showMediaAtAllSizes,
72
+ isContainerAligned: isContainerAligned,
65
73
  onClick: onClick
66
74
  }), open && /*#__PURE__*/jsx("div", {
67
75
  id: `${accordionId}-section`,
@@ -1 +1 @@
1
- {"version":3,"file":"AccordionItem.mjs","sources":["../../../src/accordion/AccordionItem/AccordionItem.tsx"],"sourcesContent":["import { IdIconProps } from '@transferwise/icons';\nimport { clsx } from 'clsx';\nimport { FC, ReactNode, cloneElement, useId } from 'react';\n\nimport Body from '../../body';\nimport Chevron from '../../chevron';\nimport { Position, Size, Typography } from '../../common';\nimport Option from '../../common/Option';\n\nexport interface AccordionItemProps {\n /** A label for the accordion item, used for accessibility purposes. */\n 'aria-label'?: string;\n /** An ID for the accordion item, used for accessibility purposes. */\n id?: string;\n /** The title of the accordion item. */\n title: ReactNode;\n /** The subtitle of the accordion item. */\n subtitle?: ReactNode;\n /** The content of the accordion item. */\n content: ReactNode;\n /** A callback function that is called when the accordion item is clicked. */\n onClick: () => void;\n /** Whether the accordion item is currently open or closed. */\n open: boolean;\n /** An optional icon to display next to the accordion item title. */\n icon?: ReactNode;\n /** @deprecated ... */\n theme?: 'light' | 'dark';\n}\n\n/**\n * AccordionItem\n *\n * A single item in an accordion component.\n *\n * @component\n * @param {string} [aria-label] - A label for the accordion item, used for accessibility purposes.\n * @param {string} [id] - An ID for the accordion item, used for accessibility purposes.\n * @param {ReactNode} title - The title of the accordion item.\n * @param {ReactNode} subtitle - The subtitle of the accordion item.\n * @param {ReactNode} content - The content of the accordion item.\n * @param {Function} onClick - A callback function that is called when the accordion item is clicked.\n * @param {boolean} open - Whether the accordion item is currently open or closed.\n * @param {ReactNode} [icon] - An optional icon to display next to the accordion item title.\n * @example\n * // Example usage:\n *\n * import AccordionItem from './AccordionItem';\n *\n * function App() {\n * const handleItemClick = () => {\n * console.log('Accordion item was clicked.');\n * };\n *\n * return (\n * <AccordionItem\n * title={<h2>Item Title</h2>}\n * content={<p>Item content goes here.</p>}\n * onClick={handleItemClick}\n * open={true}\n * icon={<Chevron />}\n * />\n * );\n * }\n */\nconst AccordionItem: FC<AccordionItemProps> = ({\n 'aria-label': ariaLabel,\n id,\n title,\n subtitle,\n content,\n onClick,\n open,\n icon,\n theme = 'light',\n}) => {\n const iconElement = icon\n ? cloneElement(icon as React.ReactElement<IdIconProps>, { size: 24 })\n : null;\n const fallbackId = useId();\n const accordionId = id ?? fallbackId;\n\n return (\n <div\n id={accordionId}\n className={clsx('np-accordion-item', iconElement ? 'np-accordion-item--with-icon' : null, {\n 'np-accordion-item--open': open,\n })}\n >\n <Option\n aria-label={ariaLabel}\n as=\"button\"\n media={iconElement}\n title={title}\n content={subtitle}\n button={<Chevron orientation={open ? Position.TOP : Position.BOTTOM} size={Size.MEDIUM} />}\n inverseMediaCircle={false}\n aria-expanded={open}\n aria-controls={`${accordionId}-section`}\n id={`${accordionId}-control`}\n onClick={onClick}\n />\n {open && (\n <div id={`${accordionId}-section`} role=\"region\" aria-labelledby={`${accordionId}-control`}>\n <Body\n as=\"span\"\n type={Typography.BODY_LARGE}\n className={clsx('np-accordion-item__content', 'd-block', {\n 'has-icon': icon,\n })}\n >\n {content}\n </Body>\n </div>\n )}\n </div>\n );\n};\n\nexport default AccordionItem;\n"],"names":["AccordionItem","ariaLabel","id","title","subtitle","content","onClick","open","icon","theme","iconElement","cloneElement","size","fallbackId","useId","accordionId","_jsxs","className","clsx","children","_jsx","Option","as","media","button","Chevron","orientation","Position","TOP","BOTTOM","Size","MEDIUM","inverseMediaCircle","role","Body","type","Typography","BODY_LARGE"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEMA,MAAAA,aAAa,GAA2BA,CAAC;AAC7C,EAAA,YAAY,EAAEC,SAAS;EACvBC,EAAE;EACFC,KAAK;EACLC,QAAQ;EACRC,OAAO;EACPC,OAAO;EACPC,IAAI;EACJC,IAAI;AACJC,EAAAA,KAAK,GAAG;AACT,CAAA,KAAI;AACH,EAAA,MAAMC,WAAW,GAAGF,IAAI,gBACpBG,YAAY,CAACH,IAAuC,EAAE;AAAEI,IAAAA,IAAI,EAAE;GAAI,CAAC,GACnE,IAAI;AACR,EAAA,MAAMC,UAAU,GAAGC,KAAK,EAAE;AAC1B,EAAA,MAAMC,WAAW,GAAGb,EAAE,IAAIW,UAAU;AAEpC,EAAA,oBACEG,IAAA,CAAA,KAAA,EAAA;AACEd,IAAAA,EAAE,EAAEa,WAAY;IAChBE,SAAS,EAAEC,IAAI,CAAC,mBAAmB,EAAER,WAAW,GAAG,8BAA8B,GAAG,IAAI,EAAE;AACxF,MAAA,yBAAyB,EAAEH;AAC5B,KAAA,CAAE;IAAAY,QAAA,EAAA,cAEHC,GAAA,CAACC,MAAM,EAAA;AACL,MAAA,YAAA,EAAYpB,SAAU;AACtBqB,MAAAA,EAAE,EAAC,QAAQ;AACXC,MAAAA,KAAK,EAAEb,WAAY;AACnBP,MAAAA,KAAK,EAAEA,KAAM;AACbE,MAAAA,OAAO,EAAED,QAAS;MAClBoB,MAAM,eAAEJ,GAAA,CAACK,OAAO,EAAA;QAACC,WAAW,EAAEnB,IAAI,GAAGoB,QAAQ,CAACC,GAAG,GAAGD,QAAQ,CAACE,MAAO;QAACjB,IAAI,EAAEkB,IAAI,CAACC;AAAO,OAAG,CAAC;AAC3FC,MAAAA,kBAAkB,EAAE,KAAM;AAC1B,MAAA,eAAA,EAAezB,IAAK;MACpB,eAAe,EAAA,CAAA,EAAGQ,WAAW,CAAW,QAAA,CAAA;MACxCb,EAAE,EAAE,CAAGa,EAAAA,WAAW,CAAW,QAAA,CAAA;AAC7BT,MAAAA,OAAO,EAAEA;AAAQ,KAEnB,CAAA,EAACC,IAAI,iBACHa,GAAA,CAAA,KAAA,EAAA;MAAKlB,EAAE,EAAE,CAAGa,EAAAA,WAAW,CAAW,QAAA,CAAA;AAACkB,MAAAA,IAAI,EAAC,QAAQ;MAAC,iBAAiB,EAAA,CAAA,EAAGlB,WAAW,CAAW,QAAA,CAAA;MAAAI,QAAA,eACzFC,GAAA,CAACc,IAAI,EAAA;AACHZ,QAAAA,EAAE,EAAC,MAAM;QACTa,IAAI,EAAEC,UAAU,CAACC,UAAW;AAC5BpB,QAAAA,SAAS,EAAEC,IAAI,CAAC,4BAA4B,EAAE,SAAS,EAAE;AACvD,UAAA,UAAU,EAAEV;AACb,SAAA,CAAE;AAAAW,QAAAA,QAAA,EAEFd;OACG;AACR,KAAK,CACN;AAAA,GACE,CAAC;AAEV;;;;"}
1
+ {"version":3,"file":"AccordionItem.mjs","sources":["../../../src/accordion/AccordionItem/AccordionItem.tsx"],"sourcesContent":["import { IdIconProps } from '@transferwise/icons';\nimport { clsx } from 'clsx';\nimport { FC, ReactNode, cloneElement, useId } from 'react';\n\nimport Body from '../../body';\nimport Chevron from '../../chevron';\nimport { Position, Size, Typography } from '../../common';\nimport Option from '../../common/Option';\n\nexport interface AccordionItemProps {\n /** A label for the accordion item, used for accessibility purposes. */\n 'aria-label'?: string;\n /** An ID for the accordion item, used for accessibility purposes. */\n id?: string;\n /** The title of the accordion item. */\n title: ReactNode;\n /** The subtitle of the accordion item. */\n subtitle?: ReactNode;\n /** The content of the accordion item. */\n content: ReactNode;\n /** A callback function that is called when the accordion item is clicked. */\n onClick: () => void;\n /** Whether the accordion item is currently open or closed. */\n open: boolean;\n /** An optional icon to display next to the accordion item title. */\n icon?: ReactNode;\n /** An optional media element to display next to the accordion item title. */\n media?: ReactNode;\n /** An optional showMediaAtAllSizes with media available at all sizes of the screen. */\n showMediaAtAllSizes?: boolean;\n /** An optional showMediaCircle to display media within the circle. */\n showMediaCircle?: boolean;\n /** An optional isContainerAligned to display media aligned with the container. */\n isContainerAligned?: boolean;\n /** @deprecated ... */\n theme?: 'light' | 'dark';\n}\n\n/**\n * AccordionItem\n *\n * A single item in an accordion component.\n *\n * @component\n * @param {string} [aria-label] - A label for the accordion item, used for accessibility purposes.\n * @param {string} [id] - An ID for the accordion item, used for accessibility purposes.\n * @param {ReactNode} title - The title of the accordion item.\n * @param {ReactNode} subtitle - The subtitle of the accordion item.\n * @param {ReactNode} content - The content of the accordion item.\n * @param {Function} onClick - A callback function that is called when the accordion item is clicked.\n * @param {boolean} open - Whether the accordion item is currently open or closed.\n * @param {ReactNode} [icon] - An optional icon to display next to the accordion item title.\n * @param {ReactNode} [media] - An optional media to display next to the accordion item.\n * @param {boolean} [showMediaAtAllSizes] - An optional showMediaAtAllSizes with media available at all sizes of the screen.\n * @param {boolean} [showMediaCircle] - An optional showMediaCircle to display media within the circle.\n * @param {boolean} [isContainerAligned] - An optional isContainerAligned to display media aligned with the container.\n * @example\n * // Example usage:\n *\n * import AccordionItem from './AccordionItem';\n *\n * function App() {\n * const handleItemClick = () => {\n * console.log('Accordion item was clicked.');\n * };\n *\n * return (\n * <AccordionItem\n * title={<h2>Item Title</h2>}\n * content={<p>Item content goes here.</p>}\n * onClick={handleItemClick}\n * open={true}\n * icon={<Chevron />}\n * />\n * );\n * }\n */\nconst AccordionItem: FC<AccordionItemProps> = ({\n 'aria-label': ariaLabel,\n id,\n title,\n subtitle,\n content,\n onClick,\n open,\n icon,\n media,\n showMediaAtAllSizes,\n showMediaCircle,\n isContainerAligned,\n theme = 'light',\n}) => {\n const mediaElement = icon\n ? cloneElement(icon as React.ReactElement<IdIconProps>, { size: 24 })\n : media;\n const fallbackId = useId();\n const accordionId = id ?? fallbackId;\n\n return (\n <div\n id={accordionId}\n className={clsx('np-accordion-item', {\n 'np-accordion-item--open': open,\n 'np-accordion-item--with-icon': Boolean(icon),\n })}\n >\n <Option\n aria-label={ariaLabel}\n as=\"button\"\n media={mediaElement}\n title={title}\n content={subtitle}\n button={<Chevron orientation={open ? Position.TOP : Position.BOTTOM} size={Size.MEDIUM} />}\n inverseMediaCircle={false}\n aria-expanded={open}\n aria-controls={`${accordionId}-section`}\n id={`${accordionId}-control`}\n showMediaCircle={showMediaCircle}\n showMediaAtAllSizes={showMediaAtAllSizes}\n isContainerAligned={isContainerAligned}\n onClick={onClick}\n />\n {open && (\n <div id={`${accordionId}-section`} role=\"region\" aria-labelledby={`${accordionId}-control`}>\n <Body\n as=\"span\"\n type={Typography.BODY_LARGE}\n className={clsx('np-accordion-item__content', 'd-block', {\n 'has-icon': icon,\n })}\n >\n {content}\n </Body>\n </div>\n )}\n </div>\n );\n};\n\nexport default AccordionItem;\n"],"names":["AccordionItem","ariaLabel","id","title","subtitle","content","onClick","open","icon","media","showMediaAtAllSizes","showMediaCircle","isContainerAligned","theme","mediaElement","cloneElement","size","fallbackId","useId","accordionId","_jsxs","className","clsx","Boolean","children","_jsx","Option","as","button","Chevron","orientation","Position","TOP","BOTTOM","Size","MEDIUM","inverseMediaCircle","role","Body","type","Typography","BODY_LARGE"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6EMA,MAAAA,aAAa,GAA2BA,CAAC;AAC7C,EAAA,YAAY,EAAEC,SAAS;EACvBC,EAAE;EACFC,KAAK;EACLC,QAAQ;EACRC,OAAO;EACPC,OAAO;EACPC,IAAI;EACJC,IAAI;EACJC,KAAK;EACLC,mBAAmB;EACnBC,eAAe;EACfC,kBAAkB;AAClBC,EAAAA,KA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BACHkB,GAAA,CAAA,KAAA,EAAA;MAAKvB,EAAE,EAAE,CAAGiB,EAAAA,WAAW,CAAW,QAAA,CAAA;AAACkB,MAAAA,IAAI,EAAC,QAAQ;MAAC,iBAAiB,EAAA,CAAA,EAAGlB,WAAW,CAAW,QAAA,CAAA;MAAAK,QAAA,eACzFC,GAAA,CAACa,IAAI,EAAA;AACHX,QAAAA,EAAE,EAAC,MAAM;QACTY,IAAI,EAAEC,UAAU,CAACC,UAAW;AAC5BpB,QAAAA,SAAS,EAAEC,IAAI,CAAC,4BAA4B,EAAE,SAAS,EAAE;AACvD,UAAA,UAAU,EAAEd;AACb,SAAA,CAAE;AAAAgB,QAAAA,QAAA,EAEFnB;OACG;AACR,KAAK,CACN;AAAA,GACE,CAAC;AAEV;;;;"}
@@ -14,7 +14,6 @@ const Body = /*#__PURE__*/React.forwardRef(function Body({
14
14
  type = DEFAULT_TYPE,
15
15
  className,
16
16
  preserveNewlines,
17
- style,
18
17
  ...props
19
18
  }, reference) {
20
19
  const isTypeSupported = bodyTypes.has(type);
@@ -1 +1 @@
1
- {"version":3,"file":"Body.js","sources":["../../src/body/Body.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { forwardRef, HTMLAttributes } from 'react';\n\nimport { Typography, BodyTypes } from '../common/propsValues/typography';\n\nconst DEFAULT_TYPE = Typography.BODY_DEFAULT;\n\nconst bodyTypes = new Set<BodyTypes>([\n Typography.BODY_DEFAULT,\n Typography.BODY_DEFAULT_BOLD,\n Typography.BODY_LARGE,\n Typography.BODY_LARGE_BOLD,\n]);\n\ntype Props = HTMLAttributes<HTMLSpanElement | HTMLParagraphElement> & {\n /**\n * Default value: {@link DEFAULT_TYPE}\n */\n type?: BodyTypes;\n /**\n * Default value: `div`\n */\n as?: 'span' | 'p' | 'div';\n /**\n * When true, preserves newline characters in the text\n * @default false\n */\n preserveNewlines?: boolean;\n};\n\nconst Body = forwardRef(function Body(\n { as: Element = 'div', type = DEFAULT_TYPE, className, preserveNewlines, style, ...props }: Props,\n reference: React.ForwardedRef<\n | {\n [key in typeof Element]: React.ElementRef<key>;\n }[typeof Element]\n | null\n >,\n) {\n const isTypeSupported = bodyTypes.has(type);\n return (\n <Element\n {...props}\n // @ts-expect-error TODO: Remove when component could be rewritten with generics\n // See: https://fettblog.eu/typescript-react-generic-forward-refs/\n ref={reference}\n className={clsx(\n `np-text-${isTypeSupported ? type : DEFAULT_TYPE}`,\n preserveNewlines && 'np-text--pre-line',\n className,\n )}\n />\n );\n});\n\nexport default Body;\n"],"names":["DEFAULT_TYPE","Typography","BODY_DEFAULT","bodyTypes","Set","BODY_DEFAULT_BOLD","BODY_LARGE","BODY_LARGE_BOLD","Body","forwardRef","as","Element","type","className","preserveNewlines","style","props","reference","isTypeSupported","has","_jsx","ref","clsx"],"mappings":";;;;;;;;;AAKA,MAAMA,YAAY,GAAGC,qBAAU,CAACC,YAAY;AAE5C,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAAY,CACnCH,qBAAU,CAACC,YAAY,EACvBD,qBAAU,CAACI,iBAAiB,EAC5BJ,qBAAU,CAACK,UAAU,EACrBL,qBAAU,CAACM,eAAe,CAC3B,CAAC;AAkBF,MAAMC,IAAI,gBAAGC,gBAAU,CAAC,SAASD,IAAIA,CACnC;EAAEE,EAAE,EAAEC,OAAO,GAAG,KAAK;AAAEC,EAAAA,IAAI,GAAGZ,YAAY;EAAEa,SAAS;EAAEC,gBAAgB;EAAEC,KAAK;EAAE,GAAGC;AAAc,CAAA,EACjGC,SAKC,EAAA;AAED,EAAA,MAAMC,eAAe,GAAGf,SAAS,CAACgB,GAAG,CAACP,IAAI,CAAC;EAC3C,oBACEQ,cAAA,CAACT,OAAO,EAAA;AAAA,IAAA,GACFK,KAAK;AACT;AACA;AACAK,IAAAA,GAAG,EAAEJ,SAAU;AACfJ,IAAAA,SAAS,EAAES,SAAI,CACb,CAAA,QAAA,EAAWJ,eAAe,GAAGN,IAAI,GAAGZ,YAAY,EAAE,EAClDc,gBAAgB,IAAI,mBAAmB,EACvCD,SAAS;AACT,GAAA,CACF;AAEN,CAAC;;;;"}
1
+ {"version":3,"file":"Body.js","sources":["../../src/body/Body.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { forwardRef, HTMLAttributes } from 'react';\n\nimport { Typography, BodyTypes } from '../common/propsValues/typography';\n\nconst DEFAULT_TYPE = Typography.BODY_DEFAULT;\n\nconst bodyTypes = new Set<BodyTypes>([\n Typography.BODY_DEFAULT,\n Typography.BODY_DEFAULT_BOLD,\n Typography.BODY_LARGE,\n Typography.BODY_LARGE_BOLD,\n]);\n\ntype Props = HTMLAttributes<HTMLSpanElement | HTMLParagraphElement> & {\n /**\n * Default value: {@link DEFAULT_TYPE}\n */\n type?: BodyTypes;\n /**\n * Default value: `div`\n */\n as?: 'span' | 'p' | 'div';\n /**\n * When true, preserves newline characters in the text\n * @default false\n */\n preserveNewlines?: boolean;\n};\n\nconst Body = forwardRef(function Body(\n { as: Element = 'div', type = DEFAULT_TYPE, className, preserveNewlines, ...props }: Props,\n reference: React.ForwardedRef<\n | {\n [key in typeof Element]: React.ElementRef<key>;\n }[typeof Element]\n | null\n >,\n) {\n const isTypeSupported = bodyTypes.has(type);\n return (\n <Element\n {...props}\n // @ts-expect-error TODO: Remove when component could be rewritten with generics\n // See: https://fettblog.eu/typescript-react-generic-forward-refs/\n ref={reference}\n className={clsx(\n `np-text-${isTypeSupported ? type : DEFAULT_TYPE}`,\n preserveNewlines && 'np-text--pre-line',\n className,\n )}\n />\n );\n});\n\nexport default Body;\n"],"names":["DEFAULT_TYPE","Typography","BODY_DEFAULT","bodyTypes","Set","BODY_DEFAULT_BOLD","BODY_LARGE","BODY_LARGE_BOLD","Body","forwardRef","as","Element","type","className","preserveNewlines","props","reference","isTypeSupported","has","_jsx","ref","clsx"],"mappings":";;;;;;;;;AAKA,MAAMA,YAAY,GAAGC,qBAAU,CAACC,YAAY;AAE5C,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAAY,CACnCH,qBAAU,CAACC,YAAY,EACvBD,qBAAU,CAACI,iBAAiB,EAC5BJ,qBAAU,CAACK,UAAU,EACrBL,qBAAU,CAACM,eAAe,CAC3B,CAAC;AAkBF,MAAMC,IAAI,gBAAGC,gBAAU,CAAC,SAASD,IAAIA,CACnC;EAAEE,EAAE,EAAEC,OAAO,GAAG,KAAK;AAAEC,EAAAA,IAAI,GAAGZ,YAAY;EAAEa,SAAS;EAAEC,gBAAgB;EAAE,GAAGC;AAAc,CAAA,EAC1FC,SAKC,EAAA;AAED,EAAA,MAAMC,eAAe,GAAGd,SAAS,CAACe,GAAG,CAACN,IAAI,CAAC;EAC3C,oBACEO,cAAA,CAACR,OAAO,EAAA;AAAA,IAAA,GACFI,KAAK;AACT;AACA;AACAK,IAAAA,GAAG,EAAEJ,SAAU;AACfH,IAAAA,SAAS,EAAEQ,SAAI,CACb,CAAA,QAAA,EAAWJ,eAAe,GAAGL,IAAI,GAAGZ,YAAY,EAAE,EAClDc,gBAAgB,IAAI,mBAAmB,EACvCD,SAAS;AACT,GAAA,CACF;AAEN,CAAC;;;;"}
@@ -10,7 +10,6 @@ const Body = /*#__PURE__*/forwardRef(function Body({
10
10
  type = DEFAULT_TYPE,
11
11
  className,
12
12
  preserveNewlines,
13
- style,
14
13
  ...props
15
14
  }, reference) {
16
15
  const isTypeSupported = bodyTypes.has(type);
@@ -1 +1 @@
1
- {"version":3,"file":"Body.mjs","sources":["../../src/body/Body.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { forwardRef, HTMLAttributes } from 'react';\n\nimport { Typography, BodyTypes } from '../common/propsValues/typography';\n\nconst DEFAULT_TYPE = Typography.BODY_DEFAULT;\n\nconst bodyTypes = new Set<BodyTypes>([\n Typography.BODY_DEFAULT,\n Typography.BODY_DEFAULT_BOLD,\n Typography.BODY_LARGE,\n Typography.BODY_LARGE_BOLD,\n]);\n\ntype Props = HTMLAttributes<HTMLSpanElement | HTMLParagraphElement> & {\n /**\n * Default value: {@link DEFAULT_TYPE}\n */\n type?: BodyTypes;\n /**\n * Default value: `div`\n */\n as?: 'span' | 'p' | 'div';\n /**\n * When true, preserves newline characters in the text\n * @default false\n */\n preserveNewlines?: boolean;\n};\n\nconst Body = forwardRef(function Body(\n { as: Element = 'div', type = DEFAULT_TYPE, className, preserveNewlines, style, ...props }: Props,\n reference: React.ForwardedRef<\n | {\n [key in typeof Element]: React.ElementRef<key>;\n }[typeof Element]\n | null\n >,\n) {\n const isTypeSupported = bodyTypes.has(type);\n return (\n <Element\n {...props}\n // @ts-expect-error TODO: Remove when component could be rewritten with generics\n // See: https://fettblog.eu/typescript-react-generic-forward-refs/\n ref={reference}\n className={clsx(\n `np-text-${isTypeSupported ? type : DEFAULT_TYPE}`,\n preserveNewlines && 'np-text--pre-line',\n className,\n )}\n />\n );\n});\n\nexport default Body;\n"],"names":["DEFAULT_TYPE","Typography","BODY_DEFAULT","bodyTypes","Set","BODY_DEFAULT_BOLD","BODY_LARGE","BODY_LARGE_BOLD","Body","forwardRef","as","Element","type","className","preserveNewlines","style","props","reference","isTypeSupported","has","_jsx","ref","clsx"],"mappings":";;;;;AAKA,MAAMA,YAAY,GAAGC,UAAU,CAACC,YAAY;AAE5C,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAAY,CACnCH,UAAU,CAACC,YAAY,EACvBD,UAAU,CAACI,iBAAiB,EAC5BJ,UAAU,CAACK,UAAU,EACrBL,UAAU,CAACM,eAAe,CAC3B,CAAC;AAkBF,MAAMC,IAAI,gBAAGC,UAAU,CAAC,SAASD,IAAIA,CACnC;EAAEE,EAAE,EAAEC,OAAO,GAAG,KAAK;AAAEC,EAAAA,IAAI,GAAGZ,YAAY;EAAEa,SAAS;EAAEC,gBAAgB;EAAEC,KAAK;EAAE,GAAGC;AAAc,CAAA,EACjGC,SAKC,EAAA;AAED,EAAA,MAAMC,eAAe,GAAGf,SAAS,CAACgB,GAAG,CAACP,IAAI,CAAC;EAC3C,oBACEQ,GAAA,CAACT,OAAO,EAAA;AAAA,IAAA,GACFK,KAAK;AACT;AACA;AACAK,IAAAA,GAAG,EAAEJ,SAAU;AACfJ,IAAAA,SAAS,EAAES,IAAI,CACb,CAAA,QAAA,EAAWJ,eAAe,GAAGN,IAAI,GAAGZ,YAAY,EAAE,EAClDc,gBAAgB,IAAI,mBAAmB,EACvCD,SAAS;AACT,GAAA,CACF;AAEN,CAAC;;;;"}
1
+ {"version":3,"file":"Body.mjs","sources":["../../src/body/Body.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { forwardRef, HTMLAttributes } from 'react';\n\nimport { Typography, BodyTypes } from '../common/propsValues/typography';\n\nconst DEFAULT_TYPE = Typography.BODY_DEFAULT;\n\nconst bodyTypes = new Set<BodyTypes>([\n Typography.BODY_DEFAULT,\n Typography.BODY_DEFAULT_BOLD,\n Typography.BODY_LARGE,\n Typography.BODY_LARGE_BOLD,\n]);\n\ntype Props = HTMLAttributes<HTMLSpanElement | HTMLParagraphElement> & {\n /**\n * Default value: {@link DEFAULT_TYPE}\n */\n type?: BodyTypes;\n /**\n * Default value: `div`\n */\n as?: 'span' | 'p' | 'div';\n /**\n * When true, preserves newline characters in the text\n * @default false\n */\n preserveNewlines?: boolean;\n};\n\nconst Body = forwardRef(function Body(\n { as: Element = 'div', type = DEFAULT_TYPE, className, preserveNewlines, ...props }: Props,\n reference: React.ForwardedRef<\n | {\n [key in typeof Element]: React.ElementRef<key>;\n }[typeof Element]\n | null\n >,\n) {\n const isTypeSupported = bodyTypes.has(type);\n return (\n <Element\n {...props}\n // @ts-expect-error TODO: Remove when component could be rewritten with generics\n // See: https://fettblog.eu/typescript-react-generic-forward-refs/\n ref={reference}\n className={clsx(\n `np-text-${isTypeSupported ? type : DEFAULT_TYPE}`,\n preserveNewlines && 'np-text--pre-line',\n className,\n )}\n />\n );\n});\n\nexport default Body;\n"],"names":["DEFAULT_TYPE","Typography","BODY_DEFAULT","bodyTypes","Set","BODY_DEFAULT_BOLD","BODY_LARGE","BODY_LARGE_BOLD","Body","forwardRef","as","Element","type","className","preserveNewlines","props","reference","isTypeSupported","has","_jsx","ref","clsx"],"mappings":";;;;;AAKA,MAAMA,YAAY,GAAGC,UAAU,CAACC,YAAY;AAE5C,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAAY,CACnCH,UAAU,CAACC,YAAY,EACvBD,UAAU,CAACI,iBAAiB,EAC5BJ,UAAU,CAACK,UAAU,EACrBL,UAAU,CAACM,eAAe,CAC3B,CAAC;AAkBF,MAAMC,IAAI,gBAAGC,UAAU,CAAC,SAASD,IAAIA,CACnC;EAAEE,EAAE,EAAEC,OAAO,GAAG,KAAK;AAAEC,EAAAA,IAAI,GAAGZ,YAAY;EAAEa,SAAS;EAAEC,gBAAgB;EAAE,GAAGC;AAAc,CAAA,EAC1FC,SAKC,EAAA;AAED,EAAA,MAAMC,eAAe,GAAGd,SAAS,CAACe,GAAG,CAACN,IAAI,CAAC;EAC3C,oBACEO,GAAA,CAACR,OAAO,EAAA;AAAA,IAAA,GACFI,KAAK;AACT;AACA;AACAK,IAAAA,GAAG,EAAEJ,SAAU;AACfH,IAAAA,SAAS,EAAEQ,IAAI,CACb,CAAA,QAAA,EAAWJ,eAAe,GAAGL,IAAI,GAAGZ,YAAY,EAAE,EAClDc,gBAAgB,IAAI,mBAAmB,EACvCD,SAAS;AACT,GAAA,CACF;AAEN,CAAC;;;;"}
@@ -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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;;;;;;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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B,sBAAsB;IACtB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,QAAA,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CA4DzC,CAAC;AAEF,eAAe,aAAa,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "0.0.0-experimental-3330579",
3
+ "version": "0.0.0-experimental-67869a3",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -92,8 +92,8 @@
92
92
  "rollup-preserve-directives": "^1.1.3",
93
93
  "storybook": "^8.6.14",
94
94
  "@transferwise/less-config": "3.1.2",
95
- "@wise/components-theming": "1.6.3",
96
95
  "@transferwise/neptune-css": "14.24.4",
96
+ "@wise/components-theming": "1.6.3",
97
97
  "@wise/wds-configs": "0.0.0"
98
98
  },
99
99
  "peerDependencies": {
@@ -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,30 @@ 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),
88
105
  })}
89
106
  >
90
107
  <Option
91
108
  aria-label={ariaLabel}
92
109
  as="button"
93
- media={iconElement}
110
+ media={mediaElement}
94
111
  title={title}
95
112
  content={subtitle}
96
113
  button={<Chevron orientation={open ? Position.TOP : Position.BOTTOM} size={Size.MEDIUM} />}
@@ -98,6 +115,9 @@ const AccordionItem: FC<AccordionItemProps> = ({
98
115
  aria-expanded={open}
99
116
  aria-controls={`${accordionId}-section`}
100
117
  id={`${accordionId}-control`}
118
+ showMediaCircle={showMediaCircle}
119
+ showMediaAtAllSizes={showMediaAtAllSizes}
120
+ isContainerAligned={isContainerAligned}
101
121
  onClick={onClick}
102
122
  />
103
123
  {open && (
@@ -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
@@ -18,6 +18,9 @@ export const Basic = () => {
18
18
  We’re building the world’s most <strong>international account</strong>. We’re building the
19
19
  world’s most <b>international account</b>.
20
20
  </Body>
21
+ <Body as="p" type={Typography.BODY_LARGE_BOLD} preserveNewlines>
22
+ {'This is line one.\nThis is line two.'}
23
+ </Body>
21
24
  <Body as="p" type={Typography.BODY_LARGE_BOLD}>
22
25
  Ми будуємо найбільш <strong>міжнародний рахунок у світі</strong>. Ми будуємо найбільш{' '}
23
26
  <b>міжнародний рахунок у світі</b>.
@@ -40,6 +43,9 @@ export const Basic = () => {
40
43
  We’re building the world’s most <strong>international account</strong>. We’re building the
41
44
  world’s most <b>international account</b>.
42
45
  </Body>
46
+ <Body as="p" preserveNewlines>
47
+ {'This is line one.\nThis is line two.'}
48
+ </Body>
43
49
  <Body as="p" type={Typography.BODY_DEFAULT}>
44
50
  Ми будуємо найбільш <strong>міжнародний рахунок у світі</strong>. Ми будуємо найбільш{' '}
45
51
  <b>міжнародний рахунок у світі</b>.
@@ -62,6 +68,9 @@ export const Basic = () => {
62
68
  We’re building the world’s most <strong>international account</strong>. We’re building the
63
69
  world’s most <b>international account</b>.
64
70
  </Body>
71
+ <Body as="p" type={Typography.BODY_DEFAULT_BOLD} preserveNewlines>
72
+ {'This is line one.\nThis is line two.'}
73
+ </Body>
65
74
  <Body as="p" type={Typography.BODY_DEFAULT_BOLD}>
66
75
  Ми будуємо найбільш <strong>міжнародний рахунок у світі</strong>. Ми будуємо найбільш{' '}
67
76
  <b>міжнародний рахунок у світі</b>.
@@ -84,6 +93,9 @@ export const Basic = () => {
84
93
  We’re building the world’s most <strong>international account</strong>. We’re building the
85
94
  world’s most <b>international account</b>.
86
95
  </Body>
96
+ <Body as="p" type={Typography.BODY_LARGE} preserveNewlines>
97
+ {'This is line one.\nThis is line two.'}
98
+ </Body>
87
99
  <Body as="p" type={Typography.BODY_LARGE}>
88
100
  Ми будуємо найбільш <strong>міжнародний рахунок у світі</strong>. Ми будуємо найбільш{' '}
89
101
  <b>міжнародний рахунок у світі</b>.
package/src/body/Body.tsx CHANGED
@@ -29,7 +29,7 @@ type Props = HTMLAttributes<HTMLSpanElement | HTMLParagraphElement> & {
29
29
  };
30
30
 
31
31
  const Body = forwardRef(function Body(
32
- { as: Element = 'div', type = DEFAULT_TYPE, className, preserveNewlines, style, ...props }: Props,
32
+ { as: Element = 'div', type = DEFAULT_TYPE, className, preserveNewlines, ...props }: Props,
33
33
  reference: React.ForwardedRef<
34
34
  | {
35
35
  [key in typeof Element]: React.ElementRef<key>;
@@ -1,4 +1,6 @@
1
- import { StoryFn } from '@storybook/react';
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import { fn } from '@storybook/test';
3
+ import { storyConfig } from '../test-utils';
2
4
 
3
5
  import Link from '../link';
4
6
 
@@ -7,46 +9,42 @@ import InstructionsList, { InstructionsListProps } from './InstructionsList';
7
9
  export default {
8
10
  component: InstructionsList,
9
11
  title: 'Typography/InstructionsList',
10
- };
12
+ render: (args) => <InstructionsList {...args} />,
13
+ tags: ['autodocs'],
14
+ } satisfies Meta<typeof InstructionsList>;
15
+
16
+ type Story = StoryObj<typeof InstructionsList>;
11
17
 
12
- export const Template: StoryFn = (args: InstructionsListProps) => {
13
- return (
14
- <>
15
- <InstructionsList
16
- className={args.className}
17
- dos={[
18
- 'Do an initial money transfer',
19
- 'Invite at least 3 friends',
20
- <span key="12">
21
- Paying extra{' '}
22
- <Link href="" type="link-large">
23
- hidden fees
24
- </Link>{' '}
25
- for transfers
26
- </span>,
27
- ]}
28
- donts={['Paying extra hidden fees for transfers', 'Use bad exchange rate']}
29
- sort={args.sort}
30
- />
31
- <hr />
32
- <InstructionsList
33
- dos={[
34
- { content: 'Multiple currencies', 'aria-label': 'Supports multiple currencies' },
35
- { content: 'Existing recipients', 'aria-label': 'Supports existing recipients' },
36
- ]}
37
- donts={[
38
- { content: 'Create recipients', 'aria-label': "Doesn't support creating recipients" },
39
- { content: 'Edit recipients', 'aria-label': "Doesn't support editing recipients" },
40
- ]}
41
- sort={args.sort}
42
- />
43
- </>
44
- );
18
+ export const Basic: Story = {
19
+ args: {
20
+ sort: 'dosFirst',
21
+ dos: [
22
+ 'Do an initial money transfer',
23
+ 'Invite at least 3 friends',
24
+ <span key="12">
25
+ Paying extra{' '}
26
+ <Link href="" type="link-large">
27
+ hidden fees
28
+ </Link>{' '}
29
+ for transfers
30
+ </span>,
31
+ ],
32
+ donts: ['Paying extra hidden fees for transfers', 'Use bad exchange rate'],
33
+ },
45
34
  };
46
35
 
47
- export const Basic = {
48
- render: Template,
36
+ export const WithNewLine: Story = {
49
37
  args: {
50
38
  sort: 'dosFirst',
39
+ dos: [
40
+ 'Do an initial money transfer',
41
+ 'Invite at least 3 friends',
42
+ 'This do item has a newline:\nSecond line appears below',
43
+ ],
44
+ donts: [
45
+ 'Paying extra hidden fees for transfers',
46
+ 'Use bad exchange rate',
47
+ 'This dont item has a newline:\nSecond line appears below',
48
+ ],
51
49
  },
52
50
  };