@transferwise/components 46.98.1 → 46.100.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/accordion/Accordion.js +4 -0
- package/build/accordion/Accordion.js.map +1 -1
- package/build/accordion/Accordion.mjs +4 -0
- package/build/accordion/Accordion.mjs.map +1 -1
- package/build/accordion/AccordionItem/AccordionItem.js +14 -5
- package/build/accordion/AccordionItem/AccordionItem.js.map +1 -1
- package/build/accordion/AccordionItem/AccordionItem.mjs +14 -5
- package/build/accordion/AccordionItem/AccordionItem.mjs.map +1 -1
- package/build/body/Body.js +2 -1
- package/build/body/Body.js.map +1 -1
- package/build/body/Body.mjs +2 -1
- package/build/body/Body.mjs.map +1 -1
- package/build/instructionsList/InstructionsList.js +1 -0
- package/build/instructionsList/InstructionsList.js.map +1 -1
- package/build/instructionsList/InstructionsList.mjs +1 -0
- package/build/instructionsList/InstructionsList.mjs.map +1 -1
- package/build/main.css +19 -16
- package/build/styles/accordion/Accordion.css +4 -1
- package/build/styles/body/Body.css +3 -0
- package/build/styles/main.css +19 -16
- package/build/styles/switch/Switch.css +22 -41
- package/build/styles/switchOption/SwitchOption.css +4 -0
- package/build/switch/Switch.js +7 -18
- package/build/switch/Switch.js.map +1 -1
- package/build/switch/Switch.mjs +8 -19
- package/build/switch/Switch.mjs.map +1 -1
- package/build/switchOption/SwitchOption.js +1 -0
- package/build/switchOption/SwitchOption.js.map +1 -1
- package/build/switchOption/SwitchOption.mjs +1 -0
- package/build/switchOption/SwitchOption.mjs.map +1 -1
- package/build/types/accordion/Accordion.d.ts +1 -1
- package/build/types/accordion/Accordion.d.ts.map +1 -1
- package/build/types/accordion/AccordionItem/AccordionItem.d.ts +12 -0
- package/build/types/accordion/AccordionItem/AccordionItem.d.ts.map +1 -1
- package/build/types/body/Body.d.ts +5 -0
- package/build/types/body/Body.d.ts.map +1 -1
- package/build/types/switch/Switch.d.ts.map +1 -1
- package/build/types/switchOption/SwitchOption.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/accordion/Accordion.css +4 -1
- package/src/accordion/Accordion.less +10 -5
- package/src/accordion/Accordion.story.tsx +30 -1
- package/src/accordion/Accordion.tsx +5 -4
- package/src/accordion/AccordionItem/AccordionItem.tsx +25 -4
- package/src/body/Body.css +3 -0
- package/src/body/Body.less +3 -0
- package/src/body/Body.spec.tsx +8 -0
- package/src/body/Body.story.tsx +12 -0
- package/src/body/Body.tsx +11 -2
- package/src/instructionsList/InstructionsList.story.tsx +35 -37
- package/src/instructionsList/InstructionsList.tsx +1 -1
- package/src/main.css +19 -16
- package/src/main.less +2 -0
- package/src/switch/Switch.css +22 -41
- package/src/switch/Switch.less +6 -12
- package/src/switch/Switch.spec.tsx +11 -9
- package/src/switch/Switch.story.tsx +158 -33
- package/src/switch/Switch.tsx +6 -15
- package/src/switchOption/SwitchOption.css +4 -0
- package/src/switchOption/SwitchOption.less +8 -0
- package/src/switchOption/SwitchOption.spec.tsx +4 -5
- package/src/switchOption/SwitchOption.story.tsx +42 -38
- package/src/switchOption/SwitchOption.tsx +1 -0
- 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 =
|
|
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 =
|
|
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,E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showMediaCircle,
|
|
46
|
+
isContainerAligned,
|
|
43
47
|
theme = 'light'
|
|
44
48
|
}) => {
|
|
45
|
-
const
|
|
49
|
+
const mediaElement = icon ? /*#__PURE__*/React.cloneElement(icon, {
|
|
46
50
|
size: 24
|
|
47
|
-
}) :
|
|
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',
|
|
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:
|
|
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
|
|
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
|
|
45
|
+
const mediaElement = icon ? /*#__PURE__*/cloneElement(icon, {
|
|
42
46
|
size: 24
|
|
43
|
-
}) :
|
|
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',
|
|
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:
|
|
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
|
|
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,QAA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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/body/Body.js
CHANGED
|
@@ -13,6 +13,7 @@ const Body = /*#__PURE__*/React.forwardRef(function Body({
|
|
|
13
13
|
as: Element = 'div',
|
|
14
14
|
type = DEFAULT_TYPE,
|
|
15
15
|
className,
|
|
16
|
+
preserveNewlines,
|
|
16
17
|
...props
|
|
17
18
|
}, reference) {
|
|
18
19
|
const isTypeSupported = bodyTypes.has(type);
|
|
@@ -21,7 +22,7 @@ const Body = /*#__PURE__*/React.forwardRef(function Body({
|
|
|
21
22
|
// @ts-expect-error TODO: Remove when component could be rewritten with generics
|
|
22
23
|
// See: https://fettblog.eu/typescript-react-generic-forward-refs/
|
|
23
24
|
ref: reference,
|
|
24
|
-
className: clsx.clsx(`np-text-${isTypeSupported ? type : DEFAULT_TYPE}`, className)
|
|
25
|
+
className: clsx.clsx(`np-text-${isTypeSupported ? type : DEFAULT_TYPE}`, preserveNewlines && 'np-text--pre-line', className)
|
|
25
26
|
});
|
|
26
27
|
});
|
|
27
28
|
|
package/build/body/Body.js.map
CHANGED
|
@@ -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\nconst Body = forwardRef(function Body(\n { as: Element = 'div', type = DEFAULT_TYPE, className, ...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(`np-text-${isTypeSupported ? type : DEFAULT_TYPE}
|
|
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;;;;"}
|
package/build/body/Body.mjs
CHANGED
|
@@ -9,6 +9,7 @@ const Body = /*#__PURE__*/forwardRef(function Body({
|
|
|
9
9
|
as: Element = 'div',
|
|
10
10
|
type = DEFAULT_TYPE,
|
|
11
11
|
className,
|
|
12
|
+
preserveNewlines,
|
|
12
13
|
...props
|
|
13
14
|
}, reference) {
|
|
14
15
|
const isTypeSupported = bodyTypes.has(type);
|
|
@@ -17,7 +18,7 @@ const Body = /*#__PURE__*/forwardRef(function Body({
|
|
|
17
18
|
// @ts-expect-error TODO: Remove when component could be rewritten with generics
|
|
18
19
|
// See: https://fettblog.eu/typescript-react-generic-forward-refs/
|
|
19
20
|
ref: reference,
|
|
20
|
-
className: clsx(`np-text-${isTypeSupported ? type : DEFAULT_TYPE}`, className)
|
|
21
|
+
className: clsx(`np-text-${isTypeSupported ? type : DEFAULT_TYPE}`, preserveNewlines && 'np-text--pre-line', className)
|
|
21
22
|
});
|
|
22
23
|
});
|
|
23
24
|
|
package/build/body/Body.mjs.map
CHANGED
|
@@ -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\nconst Body = forwardRef(function Body(\n { as: Element = 'div', type = DEFAULT_TYPE, className, ...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(`np-text-${isTypeSupported ? type : DEFAULT_TYPE}
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstructionsList.js","sources":["../../src/instructionsList/InstructionsList.tsx"],"sourcesContent":["import { CrossCircleFill as DontIcon, CheckCircleFill as DoIcon } from '@transferwise/icons';\nimport { clsx } from 'clsx';\nimport { ReactNode } from 'react';\n\nimport Body from '../body/Body';\nimport { Typography, CommonProps } from '../common';\n\ntype InstructionNode = {\n content: ReactNode;\n ['aria-label']: string;\n};\n\nexport type InstructionsListProps = CommonProps &\n (\n | {\n dos?: readonly ReactNode[];\n donts?: readonly ReactNode[];\n sort?: 'dosFirst' | 'dontsFirst';\n }\n | {\n dos?: readonly InstructionNode[];\n donts?: readonly InstructionNode[];\n sort?: 'dosFirst' | 'dontsFirst';\n }\n );\n\nconst InstructionsList = ({ className, dos, donts, sort = 'dosFirst' }: InstructionsListProps) => {\n const dosInstructions =\n dos?.map((doThis, index) => (\n // eslint-disable-next-line react/no-array-index-key\n <Instruction key={index} item={doThis} type=\"do\" />\n )) ?? null;\n\n const dontsInstructions =\n donts?.map((dont, index) => (\n // eslint-disable-next-line react/no-array-index-key\n <Instruction key={index} item={dont} type=\"dont\" />\n )) ?? null;\n\n const orderedInstructions =\n sort === 'dosFirst' ? (\n <>\n {dosInstructions}\n {dontsInstructions}\n </>\n ) : (\n <>\n {dontsInstructions}\n {dosInstructions}\n </>\n );\n\n return <ul className={clsx('tw-instructions', className)}>{orderedInstructions}</ul>;\n};\n\nfunction Instruction({ item, type }: { item: ReactNode | InstructionNode; type: 'do' | 'dont' }) {\n const isInstructionNode =\n typeof item === 'object' && item !== null && 'content' in item && 'aria-label' in item;\n return (\n <li className=\"instruction\">\n {type === 'do' ? (\n <DoIcon\n size={24}\n className={type}\n title={isInstructionNode ? item['aria-label'] : undefined}\n />\n ) : (\n <DontIcon\n size={24}\n className={type}\n title={isInstructionNode ? item['aria-label'] : undefined}\n />\n )}\n <Body className=\"text-primary\" type={Typography.BODY_LARGE}>\n {isInstructionNode ? item.content : item}\n </Body>\n </li>\n );\n}\n\nexport default InstructionsList;\n"],"names":["InstructionsList","className","dos","donts","sort","dosInstructions","map","doThis","index","_jsx","Instruction","item","type","dontsInstructions","dont","orderedInstructions","_jsxs","_Fragment","children","clsx","isInstructionNode","DoIcon","size","title","undefined","DontIcon","Body","Typography","BODY_LARGE","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IAAI,IAAI,YAAY,IAAIA,IAAI;AACxF,EAAA,oBACEK,eAAA,CAAA,IAAA,EAAA;AAAIf,IAAAA,SAAS,EAAC,aAAa;AAAAiB,IAAAA,QAAA,GACxBN,IAAI,KAAK,IAAI,gBACZH,cAAA,CAACY,qBAAM,EAAA;AACLC,MAAAA,IAAI,EAAE,EAAG;AACTrB,MAAAA,SAAS,EAAEW,IAAK;AAChBW,MAAAA,KAAK,EAAEH,iBAAiB,GAAGT,IAAI,CAAC,YAAY,CAAC,GAAGa;AAAU,KAC1D,CAAA,gBAEFf,cAAA,CAACgB,qBAAQ,EAAA;AACPH,MAAAA,IAAI,EAAE,EAAG;AACTrB,MAAAA,SAAS,EAAEW,IAAK;AAChBW,MAAAA,KAAK,EAAEH,iBAAiB,GAAGT,IAAI,CAAC,YAAY,CAAC,GAAGa;AAAU,KAAA,CAE7D,eACDf,cAAA,CAACiB,YAAI,EAAA;AAACzB,MAAAA,SAAS,EAAC,cAAc;MAACW,IAAI,EAAEe,qBAAU,CAACC,UAAW;
|
|
1
|
+
{"version":3,"file":"InstructionsList.js","sources":["../../src/instructionsList/InstructionsList.tsx"],"sourcesContent":["import { CrossCircleFill as DontIcon, CheckCircleFill as DoIcon } from '@transferwise/icons';\nimport { clsx } from 'clsx';\nimport { ReactNode } from 'react';\n\nimport Body from '../body/Body';\nimport { Typography, CommonProps } from '../common';\n\ntype InstructionNode = {\n content: ReactNode;\n ['aria-label']: string;\n};\n\nexport type InstructionsListProps = CommonProps &\n (\n | {\n dos?: readonly ReactNode[];\n donts?: readonly ReactNode[];\n sort?: 'dosFirst' | 'dontsFirst';\n }\n | {\n dos?: readonly InstructionNode[];\n donts?: readonly InstructionNode[];\n sort?: 'dosFirst' | 'dontsFirst';\n }\n );\n\nconst InstructionsList = ({ className, dos, donts, sort = 'dosFirst' }: InstructionsListProps) => {\n const dosInstructions =\n dos?.map((doThis, index) => (\n // eslint-disable-next-line react/no-array-index-key\n <Instruction key={index} item={doThis} type=\"do\" />\n )) ?? null;\n\n const dontsInstructions =\n donts?.map((dont, index) => (\n // eslint-disable-next-line react/no-array-index-key\n <Instruction key={index} item={dont} type=\"dont\" />\n )) ?? null;\n\n const orderedInstructions =\n sort === 'dosFirst' ? (\n <>\n {dosInstructions}\n {dontsInstructions}\n </>\n ) : (\n <>\n {dontsInstructions}\n {dosInstructions}\n </>\n );\n\n return <ul className={clsx('tw-instructions', className)}>{orderedInstructions}</ul>;\n};\n\nfunction Instruction({ item, type }: { item: ReactNode | InstructionNode; type: 'do' | 'dont' }) {\n const isInstructionNode =\n typeof item === 'object' && item !== null && 'content' in item && 'aria-label' in item;\n return (\n <li className=\"instruction\">\n {type === 'do' ? (\n <DoIcon\n size={24}\n className={type}\n title={isInstructionNode ? item['aria-label'] : undefined}\n />\n ) : (\n <DontIcon\n size={24}\n className={type}\n title={isInstructionNode ? item['aria-label'] : undefined}\n />\n )}\n <Body className=\"text-primary\" type={Typography.BODY_LARGE} preserveNewlines>\n {isInstructionNode ? item.content : item}\n </Body>\n </li>\n );\n}\n\nexport default InstructionsList;\n"],"names":["InstructionsList","className","dos","donts","sort","dosInstructions","map","doThis","index","_jsx","Instruction","item","type","dontsInstructions","dont","orderedInstructions","_jsxs","_Fragment","children","clsx","isInstructionNode","DoIcon","size","title","undefined","DontIcon","Body","Typography","BODY_LARGE","preserveNewlines","content"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BMA,MAAAA,gBAAgB,GAAGA,CAAC;EAAEC,SAAS;EAAEC,GAAG;EAAEC,KAAK;AAAEC,EAAAA,IAAI,GAAG;AAAU,CAAyB,KAAI;EAC/F,MAAMC,eAAe,GACnBH,GAAG,EAAEI,GAAG,CAAC,CAACC,MAAM,EAAEC,KAAK;AAAA;AACrB;AACAC,EAAAA,cAAA,CAACC,WAAW,EAAA;AAAaC,IAAAA,IAAI,EAAEJ,MAAO;AAACK,IAAAA,IAAI,EAAC;AAAI,GAAA,EAA9BJ,MACnB,CAAC,IAAI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AAI,EAAE,EAAG;AACTrB,MAAAA,SAAS,EAAEW,IAAK;AAChBW,MAAAA,KAAK,EAAEH,iBAAiB,GAAGT,IAAI,CAAC,YAAY,CAAC,GAAGa;AAAU,KAAA,CAE7D,eACDf,cAAA,CAACiB,YAAI,EAAA;AAACzB,MAAAA,SAAS,EAAC,cAAc;MAACW,IAAI,EAAEe,qBAAU,CAACC,UAAW;MAACC,gBAAgB,EAAA,IAAA;AAAAX,MAAAA,QAAA,EACzEE,iBAAiB,GAAGT,IAAI,CAACmB,OAAO,GAAGnB;AAAI,KACpC,CACR;AAAA,GAAI,CAAC;AAET;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstructionsList.mjs","sources":["../../src/instructionsList/InstructionsList.tsx"],"sourcesContent":["import { CrossCircleFill as DontIcon, CheckCircleFill as DoIcon } from '@transferwise/icons';\nimport { clsx } from 'clsx';\nimport { ReactNode } from 'react';\n\nimport Body from '../body/Body';\nimport { Typography, CommonProps } from '../common';\n\ntype InstructionNode = {\n content: ReactNode;\n ['aria-label']: string;\n};\n\nexport type InstructionsListProps = CommonProps &\n (\n | {\n dos?: readonly ReactNode[];\n donts?: readonly ReactNode[];\n sort?: 'dosFirst' | 'dontsFirst';\n }\n | {\n dos?: readonly InstructionNode[];\n donts?: readonly InstructionNode[];\n sort?: 'dosFirst' | 'dontsFirst';\n }\n );\n\nconst InstructionsList = ({ className, dos, donts, sort = 'dosFirst' }: InstructionsListProps) => {\n const dosInstructions =\n dos?.map((doThis, index) => (\n // eslint-disable-next-line react/no-array-index-key\n <Instruction key={index} item={doThis} type=\"do\" />\n )) ?? null;\n\n const dontsInstructions =\n donts?.map((dont, index) => (\n // eslint-disable-next-line react/no-array-index-key\n <Instruction key={index} item={dont} type=\"dont\" />\n )) ?? null;\n\n const orderedInstructions =\n sort === 'dosFirst' ? (\n <>\n {dosInstructions}\n {dontsInstructions}\n </>\n ) : (\n <>\n {dontsInstructions}\n {dosInstructions}\n </>\n );\n\n return <ul className={clsx('tw-instructions', className)}>{orderedInstructions}</ul>;\n};\n\nfunction Instruction({ item, type }: { item: ReactNode | InstructionNode; type: 'do' | 'dont' }) {\n const isInstructionNode =\n typeof item === 'object' && item !== null && 'content' in item && 'aria-label' in item;\n return (\n <li className=\"instruction\">\n {type === 'do' ? (\n <DoIcon\n size={24}\n className={type}\n title={isInstructionNode ? item['aria-label'] : undefined}\n />\n ) : (\n <DontIcon\n size={24}\n className={type}\n title={isInstructionNode ? item['aria-label'] : undefined}\n />\n )}\n <Body className=\"text-primary\" type={Typography.BODY_LARGE}>\n {isInstructionNode ? item.content : item}\n </Body>\n </li>\n );\n}\n\nexport default InstructionsList;\n"],"names":["InstructionsList","className","dos","donts","sort","dosInstructions","map","doThis","index","_jsx","Instruction","item","type","dontsInstructions","dont","orderedInstructions","_jsxs","_Fragment","children","clsx","isInstructionNode","DoIcon","size","title","undefined","DontIcon","Body","Typography","BODY_LARGE","content"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BMA,MAAAA,gBAAgB,GAAGA,CAAC;EAAEC,SAAS;EAAEC,GAAG;EAAEC,KAAK;AAAEC,EAAAA,IAAI,GAAG;AAAU,CAAyB,KAAI;EAC/F,MAAMC,eAAe,GACnBH,GAAG,EAAEI,GAAG,CAAC,CAACC,MAAM,EAAEC,KAAK;AAAA;AACrB;AACAC,EAAAA,GAAA,CAACC,WAAW,EAAA;AAAaC,IAAAA,IAAI,EAAEJ,MAAO;AAACK,IAAAA,IAAI,EAAC;AAAI,GAAA,EAA9BJ,MACnB,CAAC,IAAI,IAAI;EAEZ,MAAMK,iBAAiB,GACrBV,KAAK,EAAEG,GAAG,CAAC,CAACQ,IAAI,EAAEN,KAAK;AAAA;AACrB;AACAC,EAAAA,GAAA,CAACC,WAAW,EAAA;AAAaC,IAAAA,IAAI,EAAEG,IAAK;AAACF,IAAAA,IAAI,EAAC;AAAM,GAAA,EAA9BJ,MACnB,CAAC,IAAI,IAAI;EAEZ,M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+
{"version":3,"file":"InstructionsList.mjs","sources":["../../src/instructionsList/InstructionsList.tsx"],"sourcesContent":["import { CrossCircleFill as DontIcon, CheckCircleFill as DoIcon } from '@transferwise/icons';\nimport { clsx } from 'clsx';\nimport { ReactNode } from 'react';\n\nimport Body from '../body/Body';\nimport { Typography, CommonProps } from '../common';\n\ntype InstructionNode = {\n content: ReactNode;\n ['aria-label']: string;\n};\n\nexport type InstructionsListProps = CommonProps &\n (\n | {\n dos?: readonly ReactNode[];\n donts?: readonly ReactNode[];\n sort?: 'dosFirst' | 'dontsFirst';\n }\n | {\n dos?: readonly InstructionNode[];\n donts?: readonly InstructionNode[];\n sort?: 'dosFirst' | 'dontsFirst';\n }\n );\n\nconst InstructionsList = ({ className, dos, donts, sort = 'dosFirst' }: InstructionsListProps) => {\n const dosInstructions =\n dos?.map((doThis, index) => (\n // eslint-disable-next-line react/no-array-index-key\n <Instruction key={index} item={doThis} type=\"do\" />\n )) ?? null;\n\n const dontsInstructions =\n donts?.map((dont, index) => (\n // eslint-disable-next-line react/no-array-index-key\n <Instruction key={index} item={dont} type=\"dont\" />\n )) ?? null;\n\n const orderedInstructions =\n sort === 'dosFirst' ? (\n <>\n {dosInstructions}\n {dontsInstructions}\n </>\n ) : (\n <>\n {dontsInstructions}\n {dosInstructions}\n </>\n );\n\n return <ul className={clsx('tw-instructions', className)}>{orderedInstructions}</ul>;\n};\n\nfunction Instruction({ item, type }: { item: ReactNode | InstructionNode; type: 'do' | 'dont' }) {\n const isInstructionNode =\n typeof item === 'object' && item !== null && 'content' in item && 'aria-label' in item;\n return (\n <li className=\"instruction\">\n {type === 'do' ? (\n <DoIcon\n size={24}\n className={type}\n title={isInstructionNode ? item['aria-label'] : undefined}\n />\n ) : (\n <DontIcon\n size={24}\n className={type}\n title={isInstructionNode ? item['aria-label'] : undefined}\n />\n )}\n <Body className=\"text-primary\" type={Typography.BODY_LARGE} preserveNewlines>\n {isInstructionNode ? item.content : item}\n </Body>\n </li>\n );\n}\n\nexport default InstructionsList;\n"],"names":["InstructionsList","className","dos","donts","sort","dosInstructions","map","doThis","index","_jsx","Instruction","item","type","dontsInstructions","dont","orderedInstructions","_jsxs","_Fragment","children","clsx","isInstructionNode","DoIcon","size","title","undefined","DontIcon","Body","Typography","BODY_LARGE","preserveNewlines","content"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BMA,MAAAA,gBAAgB,GAAGA,CAAC;EAAEC,SAAS;EAAEC,GAAG;EAAEC,KAAK;AAAEC,EAAAA,IAAI,GAAG;AAAU,CAAyB,KAAI;EAC/F,MAAMC,eAAe,GACnBH,GAAG,EAAEI,GAAG,CAAC,CAACC,MAAM,EAAEC,KAAK;AAAA;AACrB;AACAC,EAAAA,GAAA,CAACC,WAAW,EAAA;AAAaC,IAAAA,IAAI,EAAEJ,MAAO;AAACK,IAAAA,IAAI,EAAC;AAAI,GAAA,EAA9BJ,MACnB,CAAC,IAAI,IAAI;EAEZ,MAAMK,iBAAiB,GACrBV,KAAK,EAAEG,GAAG,CAAC,CAACQ,IAAI,EAAEN,KAAK;AAAA;AACrB;AACAC,EAAAA,GAAA,CAACC,WAAW,EAAA;AAAaC,IAAAA,IAAI,EAAEG,IAAK;AAACF,IAAAA,IAAI,EAAC;AAAM,GAAA,EAA9BJ,MACnB,CAAC,IAAI,IAAI;EAEZ,MAAMO,mBAAmB,GACvBX,IAAI,KAAK,UAAU,gBACjBY,IAAA,CAAAC,QAAA,EAAA;IAAAC,QAAA,EAAA,CACGb,eAAe,EACfQ,iBAAiB;AAAA,GACpB,CAAG,gBAEHG,IAAA,CAAAC,QAAA,EAAA;IAAAC,QAAA,EAAA,CACGL,iBAAiB,EACjBR,eAAe;AAAA,GAClB,CACD;AAEH,EAAA,oBAAOI,GAAA,CAAA,IAAA,EAAA;AAAIR,IAAAA,SAAS,EAAEkB,IAAI,CAAC,iBAAiB,EAAElB,SAAS,CAAE;AAAAiB,IAAAA,QAAA,EAAEH;AAAmB,GAAK,CAAC;AACtF;AAEA,SAASL,WAAWA,CAAC;EAAEC,IAAI;AAAEC,EAAAA;AAAkE,CAAA,EAAA;AAC7F,EAAA,MAAMQ,iBAAiB,GACrB,OAAOT,IAAI,KAAK,QAAQ,IAAIA,IAAI,KAAK,IAAI,IAAI,SAAS,IAAIA,IAAI,IAAI,YAAY,IAAIA,IAAI;AACxF,EAAA,oBACEK,IAAA,CAAA,IAAA,EAAA;AAAIf,IAAAA,SAAS,EAAC,aAAa;AAAAiB,IAAAA,QAAA,GACxBN,IAAI,KAAK,IAAI,gBACZH,GAAA,CAACY,eAAM,EAAA;AACLC,MAAAA,IAAI,EAAE,EAAG;AACTrB,MAAAA,SAAS,EAAEW,IAAK;AAChBW,MAAAA,KAAK,EAAEH,iBAAiB,GAAGT,IAAI,CAAC,YAAY,CAAC,GAAGa;AAAU,KAC1D,CAAA,gBAEFf,GAAA,CAACgB,eAAQ,EAAA;AACPH,MAAAA,IAAI,EAAE,EAAG;AACTrB,MAAAA,SAAS,EAAEW,IAAK;AAChBW,MAAAA,KAAK,EAAEH,iBAAiB,GAAGT,IAAI,CAAC,YAAY,CAAC,GAAGa;AAAU,KAAA,CAE7D,eACDf,GAAA,CAACiB,IAAI,EAAA;AAACzB,MAAAA,SAAS,EAAC,cAAc;MAACW,IAAI,EAAEe,UAAU,CAACC,UAAW;MAACC,gBAAgB,EAAA,IAAA;AAAAX,MAAAA,QAAA,EACzEE,iBAAiB,GAAGT,IAAI,CAACmB,OAAO,GAAGnB;AAAI,KACpC,CACR;AAAA,GAAI,CAAC;AAET;;;;"}
|
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
|
}
|
|
@@ -658,6 +662,9 @@
|
|
|
658
662
|
border-width: 1px;
|
|
659
663
|
border-color: var(--badge-border-color);
|
|
660
664
|
}
|
|
665
|
+
.np-text--pre-line {
|
|
666
|
+
white-space: pre-line;
|
|
667
|
+
}
|
|
661
668
|
.np-btn {
|
|
662
669
|
position: relative;
|
|
663
670
|
}
|
|
@@ -5142,6 +5149,8 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
5142
5149
|
margin-top: var(--size-24);
|
|
5143
5150
|
}
|
|
5144
5151
|
.np-switch {
|
|
5152
|
+
all: unset;
|
|
5153
|
+
box-sizing: border-box;
|
|
5145
5154
|
display: inline-flex;
|
|
5146
5155
|
overflow: hidden;
|
|
5147
5156
|
width: 50px;
|
|
@@ -5150,6 +5159,7 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
5150
5159
|
-webkit-user-select: none;
|
|
5151
5160
|
-moz-user-select: none;
|
|
5152
5161
|
user-select: none;
|
|
5162
|
+
cursor: pointer;
|
|
5153
5163
|
}
|
|
5154
5164
|
.np-switch:focus {
|
|
5155
5165
|
outline: none;
|
|
@@ -5182,21 +5192,10 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
5182
5192
|
[dir="rtl"] .np-switch--checked .np-switch--thumb {
|
|
5183
5193
|
transform: translateX(-20px) ;
|
|
5184
5194
|
}
|
|
5185
|
-
.np-switch
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
width: 0;
|
|
5190
|
-
height: 0;
|
|
5191
|
-
opacity: 0;
|
|
5192
|
-
}
|
|
5193
|
-
[dir="rtl"] .np-switch input {
|
|
5194
|
-
right: -100%;
|
|
5195
|
-
left: auto;
|
|
5196
|
-
left: initial;
|
|
5197
|
-
}
|
|
5198
|
-
.np-switch:not([aria-disabled]) {
|
|
5199
|
-
cursor: pointer;
|
|
5195
|
+
.np-switch.disabled {
|
|
5196
|
+
filter: grayscale(1);
|
|
5197
|
+
opacity: 0.45;
|
|
5198
|
+
cursor: not-allowed !important;
|
|
5200
5199
|
}
|
|
5201
5200
|
.np-theme-personal .np-switch {
|
|
5202
5201
|
padding: 1px 2px;
|
|
@@ -5212,6 +5211,10 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
5212
5211
|
background-color: #ffffff;
|
|
5213
5212
|
background-color: var(--color-background-screen);
|
|
5214
5213
|
}
|
|
5214
|
+
.np-switch-option.disabled .np-switch {
|
|
5215
|
+
filter: none;
|
|
5216
|
+
opacity: 1;
|
|
5217
|
+
}
|
|
5215
5218
|
.tabs {
|
|
5216
5219
|
position: relative;
|
|
5217
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 {
|
package/build/styles/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
|
}
|
|
@@ -658,6 +662,9 @@
|
|
|
658
662
|
border-width: 1px;
|
|
659
663
|
border-color: var(--badge-border-color);
|
|
660
664
|
}
|
|
665
|
+
.np-text--pre-line {
|
|
666
|
+
white-space: pre-line;
|
|
667
|
+
}
|
|
661
668
|
.np-btn {
|
|
662
669
|
position: relative;
|
|
663
670
|
}
|
|
@@ -5142,6 +5149,8 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
5142
5149
|
margin-top: var(--size-24);
|
|
5143
5150
|
}
|
|
5144
5151
|
.np-switch {
|
|
5152
|
+
all: unset;
|
|
5153
|
+
box-sizing: border-box;
|
|
5145
5154
|
display: inline-flex;
|
|
5146
5155
|
overflow: hidden;
|
|
5147
5156
|
width: 50px;
|
|
@@ -5150,6 +5159,7 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
5150
5159
|
-webkit-user-select: none;
|
|
5151
5160
|
-moz-user-select: none;
|
|
5152
5161
|
user-select: none;
|
|
5162
|
+
cursor: pointer;
|
|
5153
5163
|
}
|
|
5154
5164
|
.np-switch:focus {
|
|
5155
5165
|
outline: none;
|
|
@@ -5182,21 +5192,10 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
5182
5192
|
[dir="rtl"] .np-switch--checked .np-switch--thumb {
|
|
5183
5193
|
transform: translateX(-20px) ;
|
|
5184
5194
|
}
|
|
5185
|
-
.np-switch
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
width: 0;
|
|
5190
|
-
height: 0;
|
|
5191
|
-
opacity: 0;
|
|
5192
|
-
}
|
|
5193
|
-
[dir="rtl"] .np-switch input {
|
|
5194
|
-
right: -100%;
|
|
5195
|
-
left: auto;
|
|
5196
|
-
left: initial;
|
|
5197
|
-
}
|
|
5198
|
-
.np-switch:not([aria-disabled]) {
|
|
5199
|
-
cursor: pointer;
|
|
5195
|
+
.np-switch.disabled {
|
|
5196
|
+
filter: grayscale(1);
|
|
5197
|
+
opacity: 0.45;
|
|
5198
|
+
cursor: not-allowed !important;
|
|
5200
5199
|
}
|
|
5201
5200
|
.np-theme-personal .np-switch {
|
|
5202
5201
|
padding: 1px 2px;
|
|
@@ -5212,6 +5211,10 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
5212
5211
|
background-color: #ffffff;
|
|
5213
5212
|
background-color: var(--color-background-screen);
|
|
5214
5213
|
}
|
|
5214
|
+
.np-switch-option.disabled .np-switch {
|
|
5215
|
+
filter: none;
|
|
5216
|
+
opacity: 1;
|
|
5217
|
+
}
|
|
5215
5218
|
.tabs {
|
|
5216
5219
|
position: relative;
|
|
5217
5220
|
}
|