@transferwise/components 46.99.0 → 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 (46) 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/main.css +16 -16
  10. package/build/styles/accordion/Accordion.css +4 -1
  11. package/build/styles/main.css +16 -16
  12. package/build/styles/switch/Switch.css +22 -41
  13. package/build/styles/switchOption/SwitchOption.css +4 -0
  14. package/build/switch/Switch.js +7 -18
  15. package/build/switch/Switch.js.map +1 -1
  16. package/build/switch/Switch.mjs +8 -19
  17. package/build/switch/Switch.mjs.map +1 -1
  18. package/build/switchOption/SwitchOption.js +1 -0
  19. package/build/switchOption/SwitchOption.js.map +1 -1
  20. package/build/switchOption/SwitchOption.mjs +1 -0
  21. package/build/switchOption/SwitchOption.mjs.map +1 -1
  22. package/build/types/accordion/Accordion.d.ts +1 -1
  23. package/build/types/accordion/Accordion.d.ts.map +1 -1
  24. package/build/types/accordion/AccordionItem/AccordionItem.d.ts +12 -0
  25. package/build/types/accordion/AccordionItem/AccordionItem.d.ts.map +1 -1
  26. package/build/types/switch/Switch.d.ts.map +1 -1
  27. package/build/types/switchOption/SwitchOption.d.ts.map +1 -1
  28. package/package.json +3 -3
  29. package/src/accordion/Accordion.css +4 -1
  30. package/src/accordion/Accordion.less +10 -5
  31. package/src/accordion/Accordion.story.tsx +30 -1
  32. package/src/accordion/Accordion.tsx +5 -4
  33. package/src/accordion/AccordionItem/AccordionItem.tsx +25 -4
  34. package/src/main.css +16 -16
  35. package/src/main.less +1 -0
  36. package/src/switch/Switch.css +22 -41
  37. package/src/switch/Switch.less +6 -12
  38. package/src/switch/Switch.spec.tsx +11 -9
  39. package/src/switch/Switch.story.tsx +158 -33
  40. package/src/switch/Switch.tsx +6 -15
  41. package/src/switchOption/SwitchOption.css +4 -0
  42. package/src/switchOption/SwitchOption.less +8 -0
  43. package/src/switchOption/SwitchOption.spec.tsx +4 -5
  44. package/src/switchOption/SwitchOption.story.tsx +42 -38
  45. package/src/switchOption/SwitchOption.tsx +1 -0
  46. package/src/switch/__snapshots__/Switch.spec.tsx.snap +0 -44
@@ -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,28 @@ 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),
59
+ 'np-accordion-item--with-media': Boolean(media)
54
60
  }),
55
61
  children: [/*#__PURE__*/jsxRuntime.jsx(Option.default, {
56
62
  "aria-label": ariaLabel,
57
63
  as: "button",
58
- media: iconElement,
64
+ media: mediaElement,
59
65
  title: title,
60
66
  content: subtitle,
61
67
  button: /*#__PURE__*/jsxRuntime.jsx(Chevron.default, {
@@ -66,6 +72,9 @@ const AccordionItem = ({
66
72
  "aria-expanded": open,
67
73
  "aria-controls": `${accordionId}-section`,
68
74
  id: `${accordionId}-control`,
75
+ showMediaCircle: showMediaCircle,
76
+ showMediaAtAllSizes: showMediaAtAllSizes,
77
+ isContainerAligned: isContainerAligned,
69
78
  onClick: onClick
70
79
  }), open && /*#__PURE__*/jsxRuntime.jsx("div", {
71
80
  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;AACEd,IAAAA,EAAE,EAAEa,WAAY;IAChBE,SAAS,EAAEC,SAAI,CAAC,mBAAmB,EAAER,WAAW,GAAG,8BAA8B,GAAG,IAAI,EAAE;AACxF,MAAA,yBAAyB,EAAEH;AAC5B,KAAA,CAAE;IAAAY,QAAA,EAAA,cAEHC,cAAA,CAACC,cAAM,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,cAAA,CAACK,eAAO,EAAA;QAACC,WAAW,EAAEnB,IAAI,GAAGoB,iBAAQ,CAACC,GAAG,GAAGD,iBAAQ,CAACE,MAAO;QAACjB,IAAI,EAAEkB,SAAI,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,cAAA,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,cAAA,CAACc,YAAI,EAAA;AACHZ,QAAAA,EAAE,EAAC,MAAM;QACTa,IAAI,EAAEC,qBAAU,CAACC,UAAW;AAC5BpB,QAAAA,SAAS,EAAEC,SAAI,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.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 'np-accordion-item--with-media': Boolean(media),\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;AAC/B,MAAA,8BAA8B,EAAEgB,OAAO,CAACf,IAAI,CAAC;MAC7C,+BAA+B,EAAEe,OAAO,CAACd,KAAK;AAC/C,KAAA,CAAE;IAAAe,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,28 @@ 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),
55
+ 'np-accordion-item--with-media': Boolean(media)
50
56
  }),
51
57
  children: [/*#__PURE__*/jsx(Option, {
52
58
  "aria-label": ariaLabel,
53
59
  as: "button",
54
- media: iconElement,
60
+ media: mediaElement,
55
61
  title: title,
56
62
  content: subtitle,
57
63
  button: /*#__PURE__*/jsx(Chevron, {
@@ -62,6 +68,9 @@ const AccordionItem = ({
62
68
  "aria-expanded": open,
63
69
  "aria-controls": `${accordionId}-section`,
64
70
  id: `${accordionId}-control`,
71
+ showMediaCircle: showMediaCircle,
72
+ showMediaAtAllSizes: showMediaAtAllSizes,
73
+ isContainerAligned: isContainerAligned,
65
74
  onClick: onClick
66
75
  }), open && /*#__PURE__*/jsx("div", {
67
76
  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 'np-accordion-item--with-media': Boolean(media),\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,YAAY,CAACP,IAAuC,EAAE;AAAEQ,IAAAA,IAAI,EAAE;GAAI,CAAC,GACnEP,KAAK;AACT,EAAA,MAAMQ,UAAU,GAAGC,KAAK,EAAE;AAC1B,EAAA,MAAMC,WAAW,GAAGjB,EAAE,IAAIe,UAAU;AAEpC,EAAA,oBACEG,IAAA,CAAA,KAAA,EAAA;AACElB,IAAAA,EAAE,EAAEiB,WAAY;AAChBE,IAAAA,SAAS,EAAEC,IAAI,CAAC,mBAAmB,EAAE;AACnC,MAAA,yBAAyB,EAAEf,IAAI;AAC/B,MAAA,8BAA8B,EAAEgB,OAAO,CAACf,IAAI,CAAC;MAC7C,+BAA+B,EAAEe,OAAO,CAACd,KAAK;AAC/C,KAAA,CAAE;IAAAe,QAAA,EAAA,cAEHC,GAAA,CAACC,MAAM,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,GAAA,CAACI,OAAO,EAAA;QAACC,WAAW,EAAEvB,IAAI,GAAGwB,QAAQ,CAACC,GAAG,GAAGD,QAAQ,CAACE,MAAO;QAACjB,IAAI,EAAEkB,IAAI,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,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;;;;"}
package/build/main.css CHANGED
@@ -72,11 +72,15 @@
72
72
  font-weight: 600;
73
73
  font-weight: var(--font-weight-semi-bold);
74
74
  }
75
+ .np-theme-personal .np-accordion-item--with-media .media {
76
+ display: flex;
77
+ align-items: center;
78
+ }
75
79
  .np-theme-personal .np-accordion-item--with-icon .np-accordion-item__content {
76
80
  padding: 0 56px 16px;
77
81
  padding: 0 var(--size-56) var(--size-16);
78
82
  }
79
- .np-theme-personal .np-accordion-item .media {
83
+ .np-theme-personal .np-accordion-item--with-icon .media {
80
84
  display: flex;
81
85
  align-items: flex-start;
82
86
  }
@@ -5145,6 +5149,8 @@ html:not([dir="rtl"]) .np-navigation-option {
5145
5149
  margin-top: var(--size-24);
5146
5150
  }
5147
5151
  .np-switch {
5152
+ all: unset;
5153
+ box-sizing: border-box;
5148
5154
  display: inline-flex;
5149
5155
  overflow: hidden;
5150
5156
  width: 50px;
@@ -5153,6 +5159,7 @@ html:not([dir="rtl"]) .np-navigation-option {
5153
5159
  -webkit-user-select: none;
5154
5160
  -moz-user-select: none;
5155
5161
  user-select: none;
5162
+ cursor: pointer;
5156
5163
  }
5157
5164
  .np-switch:focus {
5158
5165
  outline: none;
@@ -5185,21 +5192,10 @@ html:not([dir="rtl"]) .np-navigation-option {
5185
5192
  [dir="rtl"] .np-switch--checked .np-switch--thumb {
5186
5193
  transform: translateX(-20px) ;
5187
5194
  }
5188
- .np-switch input {
5189
- position: absolute;
5190
- left: -100%;
5191
- display: none;
5192
- width: 0;
5193
- height: 0;
5194
- opacity: 0;
5195
- }
5196
- [dir="rtl"] .np-switch input {
5197
- right: -100%;
5198
- left: auto;
5199
- left: initial;
5200
- }
5201
- .np-switch:not([aria-disabled]) {
5202
- cursor: pointer;
5195
+ .np-switch.disabled {
5196
+ filter: grayscale(1);
5197
+ opacity: 0.45;
5198
+ cursor: not-allowed !important;
5203
5199
  }
5204
5200
  .np-theme-personal .np-switch {
5205
5201
  padding: 1px 2px;
@@ -5215,6 +5211,10 @@ html:not([dir="rtl"]) .np-navigation-option {
5215
5211
  background-color: #ffffff;
5216
5212
  background-color: var(--color-background-screen);
5217
5213
  }
5214
+ .np-switch-option.disabled .np-switch {
5215
+ filter: none;
5216
+ opacity: 1;
5217
+ }
5218
5218
  .tabs {
5219
5219
  position: relative;
5220
5220
  }
@@ -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 {
@@ -72,11 +72,15 @@
72
72
  font-weight: 600;
73
73
  font-weight: var(--font-weight-semi-bold);
74
74
  }
75
+ .np-theme-personal .np-accordion-item--with-media .media {
76
+ display: flex;
77
+ align-items: center;
78
+ }
75
79
  .np-theme-personal .np-accordion-item--with-icon .np-accordion-item__content {
76
80
  padding: 0 56px 16px;
77
81
  padding: 0 var(--size-56) var(--size-16);
78
82
  }
79
- .np-theme-personal .np-accordion-item .media {
83
+ .np-theme-personal .np-accordion-item--with-icon .media {
80
84
  display: flex;
81
85
  align-items: flex-start;
82
86
  }
@@ -5145,6 +5149,8 @@ html:not([dir="rtl"]) .np-navigation-option {
5145
5149
  margin-top: var(--size-24);
5146
5150
  }
5147
5151
  .np-switch {
5152
+ all: unset;
5153
+ box-sizing: border-box;
5148
5154
  display: inline-flex;
5149
5155
  overflow: hidden;
5150
5156
  width: 50px;
@@ -5153,6 +5159,7 @@ html:not([dir="rtl"]) .np-navigation-option {
5153
5159
  -webkit-user-select: none;
5154
5160
  -moz-user-select: none;
5155
5161
  user-select: none;
5162
+ cursor: pointer;
5156
5163
  }
5157
5164
  .np-switch:focus {
5158
5165
  outline: none;
@@ -5185,21 +5192,10 @@ html:not([dir="rtl"]) .np-navigation-option {
5185
5192
  [dir="rtl"] .np-switch--checked .np-switch--thumb {
5186
5193
  transform: translateX(-20px) ;
5187
5194
  }
5188
- .np-switch input {
5189
- position: absolute;
5190
- left: -100%;
5191
- display: none;
5192
- width: 0;
5193
- height: 0;
5194
- opacity: 0;
5195
- }
5196
- [dir="rtl"] .np-switch input {
5197
- right: -100%;
5198
- left: auto;
5199
- left: initial;
5200
- }
5201
- .np-switch:not([aria-disabled]) {
5202
- cursor: pointer;
5195
+ .np-switch.disabled {
5196
+ filter: grayscale(1);
5197
+ opacity: 0.45;
5198
+ cursor: not-allowed !important;
5203
5199
  }
5204
5200
  .np-theme-personal .np-switch {
5205
5201
  padding: 1px 2px;
@@ -5215,6 +5211,10 @@ html:not([dir="rtl"]) .np-navigation-option {
5215
5211
  background-color: #ffffff;
5216
5212
  background-color: var(--color-background-screen);
5217
5213
  }
5214
+ .np-switch-option.disabled .np-switch {
5215
+ filter: none;
5216
+ opacity: 1;
5217
+ }
5218
5218
  .tabs {
5219
5219
  position: relative;
5220
5220
  }
@@ -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;;;;"}