@transferwise/components 46.155.0 → 46.156.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/AvatarLayout/AvatarLayout.js.map +1 -1
- package/build/AvatarLayout/AvatarLayout.mjs.map +1 -1
- package/build/AvatarView/AvatarView.js.map +1 -1
- package/build/AvatarView/AvatarView.mjs.map +1 -1
- package/build/AvatarView/Dot/Dot.js.map +1 -1
- package/build/AvatarView/Dot/Dot.mjs.map +1 -1
- package/build/Body/Body.js.map +1 -1
- package/build/Body/Body.mjs.map +1 -1
- package/build/Chips/Chip/Chip.js.map +1 -1
- package/build/Chips/Chip/Chip.mjs.map +1 -1
- package/build/DefinitionList/DefinitionList.js +2 -1
- package/build/DefinitionList/DefinitionList.js.map +1 -1
- package/build/DefinitionList/DefinitionList.mjs +2 -1
- package/build/DefinitionList/DefinitionList.mjs.map +1 -1
- package/build/Display/Display.js.map +1 -1
- package/build/Display/Display.mjs.map +1 -1
- package/build/ExpressiveMoneyInput/AmountInput/AmountInput.js +2 -2
- package/build/ExpressiveMoneyInput/AmountInput/AmountInput.js.map +1 -1
- package/build/ExpressiveMoneyInput/AmountInput/AmountInput.mjs +1 -1
- package/build/ExpressiveMoneyInput/AmountInput/AmountInput.mjs.map +1 -1
- package/build/ExpressiveMoneyInput/AnimatedNumber/AnimatedNumber.js +4 -4
- package/build/ExpressiveMoneyInput/AnimatedNumber/AnimatedNumber.js.map +1 -1
- package/build/ExpressiveMoneyInput/AnimatedNumber/AnimatedNumber.mjs +1 -1
- package/build/ExpressiveMoneyInput/AnimatedNumber/AnimatedNumber.mjs.map +1 -1
- package/build/ExpressiveMoneyInput/Chevron/Chevron.js +2 -2
- package/build/ExpressiveMoneyInput/Chevron/Chevron.js.map +1 -1
- package/build/ExpressiveMoneyInput/Chevron/Chevron.mjs +1 -1
- package/build/ExpressiveMoneyInput/Chevron/Chevron.mjs.map +1 -1
- package/build/ExpressiveMoneyInput/CurrencySelector/CurrencySelector.js.map +1 -1
- package/build/ExpressiveMoneyInput/CurrencySelector/CurrencySelector.mjs.map +1 -1
- package/build/ExpressiveMoneyInput/ExpressiveMoneyInput.js +3 -3
- package/build/ExpressiveMoneyInput/ExpressiveMoneyInput.js.map +1 -1
- package/build/ExpressiveMoneyInput/ExpressiveMoneyInput.mjs +1 -1
- package/build/ExpressiveMoneyInput/ExpressiveMoneyInput.mjs.map +1 -1
- package/build/ExpressiveMoneyInput/hooks/useInputStyle.js.map +1 -1
- package/build/ExpressiveMoneyInput/hooks/useInputStyle.mjs.map +1 -1
- package/build/IconButton/IconButton.js.map +1 -1
- package/build/IconButton/IconButton.mjs.map +1 -1
- package/build/Link/Link.js.map +1 -1
- package/build/Link/Link.mjs.map +1 -1
- package/build/Markup/Markup.js +138 -0
- package/build/Markup/Markup.js.map +1 -0
- package/build/Markup/Markup.mjs +133 -0
- package/build/Markup/Markup.mjs.map +1 -0
- package/build/Markup/constants.js +21 -0
- package/build/Markup/constants.js.map +1 -0
- package/build/Markup/constants.mjs +15 -0
- package/build/Markup/constants.mjs.map +1 -0
- package/build/Markup/utils/parseMarkup.js +263 -0
- package/build/Markup/utils/parseMarkup.js.map +1 -0
- package/build/Markup/utils/parseMarkup.mjs +258 -0
- package/build/Markup/utils/parseMarkup.mjs.map +1 -0
- package/build/Markup/utils/sanitise.js +111 -0
- package/build/Markup/utils/sanitise.js.map +1 -0
- package/build/Markup/utils/sanitise.mjs +108 -0
- package/build/Markup/utils/sanitise.mjs.map +1 -0
- package/build/Nudge/Nudge.js +11 -2
- package/build/Nudge/Nudge.js.map +1 -1
- package/build/Nudge/Nudge.mjs +12 -3
- package/build/Nudge/Nudge.mjs.map +1 -1
- package/build/Sticky/Sticky.js +1 -0
- package/build/Sticky/Sticky.js.map +1 -1
- package/build/Sticky/Sticky.mjs +1 -0
- package/build/Sticky/Sticky.mjs.map +1 -1
- package/build/Title/Title.js +1 -0
- package/build/Title/Title.js.map +1 -1
- package/build/Title/Title.mjs +1 -0
- package/build/Title/Title.mjs.map +1 -1
- package/build/_deprecated/Select/Option/Option.js.map +1 -1
- package/build/_deprecated/Select/Option/Option.mjs.map +1 -1
- package/build/_deprecated/Select/SearchBox/SearchBox.js.map +1 -1
- package/build/_deprecated/Select/SearchBox/SearchBox.mjs.map +1 -1
- package/build/common/Circle/Circle.js.map +1 -1
- package/build/common/Circle/Circle.mjs.map +1 -1
- package/build/i18n/hu.json +1 -1
- package/build/i18n/hu.json.js +1 -1
- package/build/i18n/hu.json.mjs +1 -1
- package/build/index.js +2 -0
- package/build/index.js.map +1 -1
- package/build/index.mjs +1 -0
- package/build/index.mjs.map +1 -1
- package/build/main.css +71 -1
- package/build/styles/DefinitionList/DefinitionList.css +30 -0
- package/build/styles/Markup/Markup.css +28 -0
- package/build/styles/Markup/_stories/Vulnerability/Vulnerability.css +69 -0
- package/build/styles/Nudge/Nudge.css +1 -1
- package/build/styles/Sticky/Sticky.css +4 -0
- package/build/styles/main.css +71 -1
- package/build/types/AvatarLayout/AvatarLayout.d.ts +2 -2
- package/build/types/AvatarLayout/AvatarLayout.d.ts.map +1 -1
- package/build/types/AvatarLayout/index.d.ts +1 -1
- package/build/types/AvatarLayout/index.d.ts.map +1 -1
- package/build/types/AvatarView/AvatarView.d.ts +2 -2
- package/build/types/AvatarView/AvatarView.d.ts.map +1 -1
- package/build/types/AvatarView/Dot/Dot.d.ts +1 -1
- package/build/types/AvatarView/Dot/Dot.d.ts.map +1 -1
- package/build/types/AvatarView/index.d.ts +1 -1
- package/build/types/AvatarView/index.d.ts.map +1 -1
- package/build/types/Body/Body.d.ts +13 -2
- package/build/types/Body/Body.d.ts.map +1 -1
- package/build/types/Body/index.d.ts +1 -0
- package/build/types/Body/index.d.ts.map +1 -1
- package/build/types/Chips/Chip/Chip.d.ts +2 -2
- package/build/types/Chips/Chip/Chip.d.ts.map +1 -1
- package/build/types/Chips/index.d.ts +1 -1
- package/build/types/Chips/index.d.ts.map +1 -1
- package/build/types/DefinitionList/DefinitionList.d.ts.map +1 -1
- package/build/types/Display/Display.d.ts +2 -2
- package/build/types/Display/Display.d.ts.map +1 -1
- package/build/types/Display/index.d.ts +1 -0
- package/build/types/Display/index.d.ts.map +1 -1
- package/build/types/ExpressiveMoneyInput/AmountInput/AmountInput.d.ts +3 -3
- package/build/types/ExpressiveMoneyInput/AmountInput/AmountInput.d.ts.map +1 -1
- package/build/types/ExpressiveMoneyInput/CurrencySelector/CurrencySelector.d.ts +3 -3
- package/build/types/ExpressiveMoneyInput/CurrencySelector/CurrencySelector.d.ts.map +1 -1
- package/build/types/ExpressiveMoneyInput/ExpressiveMoneyInput.d.ts +4 -4
- package/build/types/ExpressiveMoneyInput/ExpressiveMoneyInput.d.ts.map +1 -1
- package/build/types/ExpressiveMoneyInput/hooks/useInputStyle.d.ts +1 -1
- package/build/types/ExpressiveMoneyInput/hooks/useInputStyle.d.ts.map +1 -1
- package/build/types/ExpressiveMoneyInput/index.d.ts +1 -1
- package/build/types/ExpressiveMoneyInput/index.d.ts.map +1 -1
- package/build/types/IconButton/IconButton.d.ts +2 -2
- package/build/types/IconButton/IconButton.d.ts.map +1 -1
- package/build/types/IconButton/index.d.ts +1 -1
- package/build/types/IconButton/index.d.ts.map +1 -1
- package/build/types/Link/Link.d.ts +2 -2
- package/build/types/Link/Link.d.ts.map +1 -1
- package/build/types/Link/index.d.ts +1 -1
- package/build/types/Link/index.d.ts.map +1 -1
- package/build/types/Markup/Markup.d.ts +18 -0
- package/build/types/Markup/Markup.d.ts.map +1 -0
- package/build/types/Markup/Markup.types.d.ts +77 -0
- package/build/types/Markup/Markup.types.d.ts.map +1 -0
- package/build/types/Markup/_stories/Vulnerability/Vulnerability.d.ts +12 -0
- package/build/types/Markup/_stories/Vulnerability/Vulnerability.d.ts.map +1 -0
- package/build/types/Markup/constants.d.ts +6 -0
- package/build/types/Markup/constants.d.ts.map +1 -0
- package/build/types/Markup/index.d.ts +3 -0
- package/build/types/Markup/index.d.ts.map +1 -0
- package/build/types/Markup/utils/parseMarkup.d.ts +8 -0
- package/build/types/Markup/utils/parseMarkup.d.ts.map +1 -0
- package/build/types/Markup/utils/sanitise.d.ts +4 -0
- package/build/types/Markup/utils/sanitise.d.ts.map +1 -0
- package/build/types/MoneyInput/MoneyInput.d.ts +1 -1
- package/build/types/MoneyInput/MoneyInput.d.ts.map +1 -1
- package/build/types/Nudge/Nudge.d.ts +28 -5
- package/build/types/Nudge/Nudge.d.ts.map +1 -1
- package/build/types/Nudge/index.d.ts +1 -1
- package/build/types/Nudge/index.d.ts.map +1 -1
- package/build/types/Sticky/Sticky.d.ts.map +1 -1
- package/build/types/Title/Title.d.ts +13 -3
- package/build/types/Title/Title.d.ts.map +1 -1
- package/build/types/Title/index.d.ts +1 -0
- package/build/types/Title/index.d.ts.map +1 -1
- package/build/types/Upload/Steps/UploadImageStep/UploadImageStep.d.ts +1 -1
- package/build/types/UploadInput/UploadItem/UploadItemLink.d.ts +1 -1
- package/build/types/_deprecated/Select/Option/Option.d.ts +2 -2
- package/build/types/_deprecated/Select/Option/Option.d.ts.map +1 -1
- package/build/types/common/Circle/Circle.d.ts +1 -1
- package/build/types/common/Circle/Circle.d.ts.map +1 -1
- package/build/types/common/Circle/index.d.ts +1 -1
- package/build/types/common/Circle/index.d.ts.map +1 -1
- package/build/types/index.d.ts +6 -0
- package/build/types/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/AvatarLayout/AvatarLayout.tsx +3 -3
- package/src/AvatarLayout/index.ts +1 -1
- package/src/AvatarView/AvatarView.tsx +4 -4
- package/src/AvatarView/Dot/Dot.tsx +1 -1
- package/src/AvatarView/index.ts +1 -1
- package/src/Body/Body.tsx +2 -2
- package/src/Body/index.ts +1 -0
- package/src/Chips/Chip/Chip.tsx +2 -2
- package/src/Chips/index.ts +1 -1
- package/src/DefinitionList/DefinitionList.css +30 -0
- package/src/DefinitionList/DefinitionList.less +24 -0
- package/src/DefinitionList/DefinitionList.tsx +1 -0
- package/src/DefinitionList/_stories/DefinitionList.test.story.tsx +168 -0
- package/src/Display/Display.tsx +2 -2
- package/src/Display/index.ts +1 -0
- package/src/Drawer/Drawer.test.tsx +2 -3
- package/src/ExpressiveMoneyInput/AmountInput/AmountInput.tsx +4 -4
- package/src/ExpressiveMoneyInput/AnimatedNumber/AnimatedNumber.tsx +1 -1
- package/src/ExpressiveMoneyInput/Chevron/Chevron.tsx +1 -1
- package/src/ExpressiveMoneyInput/CurrencySelector/CurrencySelector.tsx +3 -3
- package/src/ExpressiveMoneyInput/ExpressiveMoneyInput.test.tsx +1 -1
- package/src/ExpressiveMoneyInput/ExpressiveMoneyInput.tsx +5 -8
- package/src/ExpressiveMoneyInput/_stories/ExpressiveMoneyInput.story.tsx +1 -1
- package/src/ExpressiveMoneyInput/_stories/ExpressiveMoneyInput.test.story.tsx +1 -1
- package/src/ExpressiveMoneyInput/hooks/useInputStyle.ts +1 -1
- package/src/ExpressiveMoneyInput/index.ts +1 -1
- package/src/IconButton/IconButton.tsx +2 -2
- package/src/IconButton/_stories/IconButton.story.tsx +8 -8
- package/src/IconButton/index.ts +1 -1
- package/src/Link/Link.tsx +2 -2
- package/src/Link/index.ts +1 -1
- package/src/Markup/Markup.css +28 -0
- package/src/Markup/Markup.injection.test.tsx +163 -0
- package/src/Markup/Markup.less +29 -0
- package/src/Markup/Markup.test.tsx +502 -0
- package/src/Markup/Markup.tsx +175 -0
- package/src/Markup/Markup.types.ts +62 -0
- package/src/Markup/_stories/Markup.docs.mdx +75 -0
- package/src/Markup/_stories/Markup.security.docs.mdx +343 -0
- package/src/Markup/_stories/Markup.story.tsx +266 -0
- package/src/Markup/_stories/Vulnerability/Vulnerability.css +69 -0
- package/src/Markup/_stories/Vulnerability/Vulnerability.tsx +30 -0
- package/src/Markup/constants.ts +23 -0
- package/src/Markup/index.ts +2 -0
- package/src/Markup/utils/parseMarkup.test.ts +706 -0
- package/src/Markup/utils/parseMarkup.ts +265 -0
- package/src/Markup/utils/sanitise.test.ts +499 -0
- package/src/Markup/utils/sanitise.ts +129 -0
- package/src/Nudge/Nudge.css +1 -1
- package/src/Nudge/Nudge.less +1 -1
- package/src/Nudge/Nudge.test.tsx +43 -0
- package/src/Nudge/Nudge.tsx +43 -8
- package/src/Nudge/index.ts +1 -1
- package/src/Sticky/Sticky.css +4 -0
- package/src/Sticky/Sticky.less +6 -0
- package/src/Sticky/Sticky.test.tsx +1 -0
- package/src/Sticky/Sticky.tsx +1 -0
- package/src/Sticky/_stories/Sticky.test.story.tsx +177 -0
- package/src/Title/Title.tsx +25 -20
- package/src/Title/index.ts +1 -0
- package/src/_deprecated/LegacyListItem/_stories/LegacyListItem.story.tsx +2 -3
- package/src/_deprecated/Select/Option/Option.test.tsx +1 -1
- package/src/_deprecated/Select/Option/Option.tsx +2 -2
- package/src/_deprecated/Select/SearchBox/SearchBox.tsx +2 -2
- package/src/common/Circle/Circle.tsx +2 -2
- package/src/common/Circle/index.ts +1 -1
- package/src/i18n/hu.json +1 -1
- package/src/index.ts +6 -0
- package/src/main.css +71 -1
- package/src/main.less +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconButton.js","sources":["../../src/IconButton/IconButton.tsx"],"sourcesContent":["import { AnchorHTMLAttributes, ButtonHTMLAttributes, forwardRef, HTMLAttributes } from 'react';\nimport { PrimitiveAnchor, PrimitiveButton } from '../Primitives';\nimport Circle from '../common/Circle';\nimport { clsx } from 'clsx';\n\nexport type
|
|
1
|
+
{"version":3,"file":"IconButton.js","sources":["../../src/IconButton/IconButton.tsx"],"sourcesContent":["import { AnchorHTMLAttributes, ButtonHTMLAttributes, forwardRef, HTMLAttributes } from 'react';\nimport { PrimitiveAnchor, PrimitiveButton } from '../Primitives';\nimport Circle from '../common/Circle';\nimport { clsx } from 'clsx';\n\nexport type IconButtonProps = {\n /** @default 48 */\n size?: 16 | 24 | 32 | 40 | 48 | 56 | 72;\n /** @default 'primary' */\n priority?: 'primary' | 'secondary' | 'tertiary' | 'minimal';\n /** @default 'default' */\n type?: 'default' | 'negative';\n 'data-testid'?: string;\n} & Pick<AnchorHTMLAttributes<HTMLAnchorElement>, 'href' | 'target' | 'onClick'> &\n Pick<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick' | 'disabled'> &\n Pick<\n HTMLAttributes<HTMLDivElement>,\n 'id' | 'className' | 'role' | 'children' | 'aria-label' | 'tabIndex'\n >;\n\nconst IconButton = forwardRef(function IconButton(\n {\n size = 48,\n href = '#',\n children,\n className,\n priority = 'primary',\n type = 'default',\n ...props\n }: IconButtonProps,\n ref,\n) {\n const isLink = href !== '#';\n return (\n // @ts-expect-error it's either link or `button` element so it has `onClick` / `href`\n <Circle\n ref={ref}\n as={isLink ? PrimitiveAnchor : PrimitiveButton}\n size={size}\n fixedSize\n className={clsx(\n 'np-icon-button',\n `np-icon-button-${priority}-${type}`,\n {\n disabled: props.disabled,\n },\n className,\n )}\n {...(isLink ? { href } : {})}\n {...props}\n >\n {children}\n </Circle>\n );\n});\n\nexport default IconButton;\n"],"names":["IconButton","forwardRef","size","href","children","className","priority","type","props","ref","isLink","_jsx","Circle","as","PrimitiveAnchor","PrimitiveButton","fixedSize","clsx","disabled"],"mappings":";;;;;;;;;;;AAoBA,MAAMA,UAAU,gBAAGC,gBAAU,CAAC,SAASD,UAAUA,CAC/C;AACEE,EAAAA,IAAI,GAAG,EAAE;AACTC,EAAAA,IAAI,GAAG,GAAG;EACVC,QAAQ;EACRC,SAAS;AACTC,EAAAA,QAAQ,GAAG,SAAS;AACpBC,EAAAA,IAAI,GAAG,SAAS;EAChB,GAAGC;AAAK,CACQ,EAClBC,GAAG,EAAA;AAEH,EAAA,MAAMC,MAAM,GAAGP,IAAI,KAAK,GAAG;AAC3B,EAAA;AAAA;AACE;AACAQ,IAAAA,cAAA,CAACC,cAAM,EAAA;AACLH,MAAAA,GAAG,EAAEA,GAAI;AACTI,MAAAA,EAAE,EAAEH,MAAM,GAAGI,uBAAe,GAAGC,uBAAgB;AAC/Cb,MAAAA,IAAI,EAAEA,IAAK;MACXc,SAAS,EAAA,IAAA;MACTX,SAAS,EAAEY,SAAI,CACb,gBAAgB,EAChB,kBAAkBX,QAAQ,CAAA,CAAA,EAAIC,IAAI,CAAA,CAAE,EACpC;QACEW,QAAQ,EAAEV,KAAK,CAACU;OACjB,EACDb,SAAS,CACT;AAAA,MAAA,IACGK,MAAM,GAAG;AAAEP,QAAAA;OAAM,GAAG,EAAE,CAAA;AAAA,MAAA,GACvBK,KAAK;AAAAJ,MAAAA,QAAA,EAERA;KACK;AAAC;AAEb,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconButton.mjs","sources":["../../src/IconButton/IconButton.tsx"],"sourcesContent":["import { AnchorHTMLAttributes, ButtonHTMLAttributes, forwardRef, HTMLAttributes } from 'react';\nimport { PrimitiveAnchor, PrimitiveButton } from '../Primitives';\nimport Circle from '../common/Circle';\nimport { clsx } from 'clsx';\n\nexport type
|
|
1
|
+
{"version":3,"file":"IconButton.mjs","sources":["../../src/IconButton/IconButton.tsx"],"sourcesContent":["import { AnchorHTMLAttributes, ButtonHTMLAttributes, forwardRef, HTMLAttributes } from 'react';\nimport { PrimitiveAnchor, PrimitiveButton } from '../Primitives';\nimport Circle from '../common/Circle';\nimport { clsx } from 'clsx';\n\nexport type IconButtonProps = {\n /** @default 48 */\n size?: 16 | 24 | 32 | 40 | 48 | 56 | 72;\n /** @default 'primary' */\n priority?: 'primary' | 'secondary' | 'tertiary' | 'minimal';\n /** @default 'default' */\n type?: 'default' | 'negative';\n 'data-testid'?: string;\n} & Pick<AnchorHTMLAttributes<HTMLAnchorElement>, 'href' | 'target' | 'onClick'> &\n Pick<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick' | 'disabled'> &\n Pick<\n HTMLAttributes<HTMLDivElement>,\n 'id' | 'className' | 'role' | 'children' | 'aria-label' | 'tabIndex'\n >;\n\nconst IconButton = forwardRef(function IconButton(\n {\n size = 48,\n href = '#',\n children,\n className,\n priority = 'primary',\n type = 'default',\n ...props\n }: IconButtonProps,\n ref,\n) {\n const isLink = href !== '#';\n return (\n // @ts-expect-error it's either link or `button` element so it has `onClick` / `href`\n <Circle\n ref={ref}\n as={isLink ? PrimitiveAnchor : PrimitiveButton}\n size={size}\n fixedSize\n className={clsx(\n 'np-icon-button',\n `np-icon-button-${priority}-${type}`,\n {\n disabled: props.disabled,\n },\n className,\n )}\n {...(isLink ? { href } : {})}\n {...props}\n >\n {children}\n </Circle>\n );\n});\n\nexport default IconButton;\n"],"names":["IconButton","forwardRef","size","href","children","className","priority","type","props","ref","isLink","_jsx","Circle","as","PrimitiveAnchor","PrimitiveButton","fixedSize","clsx","disabled"],"mappings":";;;;;;;AAoBA,MAAMA,UAAU,gBAAGC,UAAU,CAAC,SAASD,UAAUA,CAC/C;AACEE,EAAAA,IAAI,GAAG,EAAE;AACTC,EAAAA,IAAI,GAAG,GAAG;EACVC,QAAQ;EACRC,SAAS;AACTC,EAAAA,QAAQ,GAAG,SAAS;AACpBC,EAAAA,IAAI,GAAG,SAAS;EAChB,GAAGC;AAAK,CACQ,EAClBC,GAAG,EAAA;AAEH,EAAA,MAAMC,MAAM,GAAGP,IAAI,KAAK,GAAG;AAC3B,EAAA;AAAA;AACE;AACAQ,IAAAA,GAAA,CAACC,MAAM,EAAA;AACLH,MAAAA,GAAG,EAAEA,GAAI;AACTI,MAAAA,EAAE,EAAEH,MAAM,GAAGI,eAAe,GAAGC,eAAgB;AAC/Cb,MAAAA,IAAI,EAAEA,IAAK;MACXc,SAAS,EAAA,IAAA;MACTX,SAAS,EAAEY,IAAI,CACb,gBAAgB,EAChB,kBAAkBX,QAAQ,CAAA,CAAA,EAAIC,IAAI,CAAA,CAAE,EACpC;QACEW,QAAQ,EAAEV,KAAK,CAACU;OACjB,EACDb,SAAS,CACT;AAAA,MAAA,IACGK,MAAM,GAAG;AAAEP,QAAAA;OAAM,GAAG,EAAE,CAAA;AAAA,MAAA,GACvBK,KAAK;AAAAJ,MAAAA,QAAA,EAERA;KACK;AAAC;AAEb,CAAC;;;;"}
|
package/build/Link/Link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.js","sources":["../../src/Link/Link.tsx"],"sourcesContent":["import { NavigateAway as NavigateAwayIcon } from '@transferwise/icons';\nimport { clsx } from 'clsx';\nimport { useIntl } from 'react-intl';\nimport { PrimitiveAnchor, PrimitiveButton } from '../Primitives';\nimport type { PrimitiveAnchorProps, PrimitiveButtonProps } from '../Primitives';\n\nimport { LinkLarge, LinkDefault, Typography } from '../common';\n\nimport messages from './Link.messages';\n\nexport type
|
|
1
|
+
{"version":3,"file":"Link.js","sources":["../../src/Link/Link.tsx"],"sourcesContent":["import { NavigateAway as NavigateAwayIcon } from '@transferwise/icons';\nimport { clsx } from 'clsx';\nimport { useIntl } from 'react-intl';\nimport { PrimitiveAnchor, PrimitiveButton } from '../Primitives';\nimport type { PrimitiveAnchorProps, PrimitiveButtonProps } from '../Primitives';\n\nimport { LinkLarge, LinkDefault, Typography } from '../common';\n\nimport messages from './Link.messages';\n\nexport type LinkProps = PrimitiveAnchorProps &\n Pick<PrimitiveButtonProps, 'onClick'> & { type?: LinkLarge | LinkDefault };\n\n/**\n * Standard Link component with navigate away icon\n *\n * Documentation: https://transferwise.github.io/neptune-web/components/content/Link\n */\nconst Link = ({\n className,\n children,\n href,\n target,\n type = Typography.LINK_DEFAULT,\n 'aria-label': ariaLabel,\n onClick,\n disabled,\n ...props\n}: LinkProps) => {\n const { formatMessage } = useIntl();\n const isButton = Boolean(onClick) && href === undefined;\n const isBlank = target === '_blank';\n\n const classNames = clsx(\n 'np-link',\n 'd-inline-flex',\n {\n [`np-text-${type}`]: type,\n 'np-link--disabled': disabled,\n },\n className,\n );\n\n return isButton ? (\n <PrimitiveButton\n type=\"button\"\n aria-label={ariaLabel}\n className={clsx(classNames, 'btn-unstyled')}\n disabled={disabled}\n onClick={onClick}\n >\n {children}\n </PrimitiveButton>\n ) : (\n <PrimitiveAnchor\n href={href}\n target={target}\n className={classNames}\n aria-label={ariaLabel}\n rel={isBlank ? 'noreferrer' : undefined}\n disabled={disabled}\n onClick={onClick}\n {...props}\n >\n {children} {isBlank && <NavigateAwayIcon title={formatMessage(messages.opensInNewTab)} />}\n </PrimitiveAnchor>\n );\n};\n\nexport default Link;\n"],"names":["Link","className","children","href","target","type","Typography","LINK_DEFAULT","ariaLabel","onClick","disabled","props","formatMessage","useIntl","isButton","Boolean","undefined","isBlank","classNames","clsx","_jsx","PrimitiveButton","_jsxs","PrimitiveAnchor","rel","NavigateAwayIcon","title","messages","opensInNewTab"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAMA,IAAI,GAAGA,CAAC;EACZC,SAAS;EACTC,QAAQ;EACRC,IAAI;EACJC,MAAM;EACNC,IAAI,GAAGC,qBAAU,CAACC,YAAY;AAC9B,EAAA,YAAY,EAAEC,SAAS;EACvBC,OAAO;EACPC,QAAQ;EACR,GAAGC;AAAK,CACE,KAAI;EACd,MAAM;AAAEC,IAAAA;GAAe,GAAGC,iBAAO,EAAE;EACnC,MAAMC,QAAQ,GAAGC,OAAO,CAACN,OAAO,CAAC,IAAIN,IAAI,KAAKa,SAAS;AACvD,EAAA,MAAMC,OAAO,GAAGb,MAAM,KAAK,QAAQ;AAEnC,EAAA,MAAMc,UAAU,GAAGC,SAAI,CACrB,SAAS,EACT,eAAe,EACf;AACE,IAAA,CAAC,CAAA,QAAA,EAAWd,IAAI,CAAA,CAAE,GAAGA,IAAI;AACzB,IAAA,mBAAmB,EAAEK;GACtB,EACDT,SAAS,CACV;AAED,EAAA,OAAOa,QAAQ,gBACbM,cAAA,CAACC,uBAAe,EAAA;AACdhB,IAAAA,IAAI,EAAC,QAAQ;AACb,IAAA,YAAA,EAAYG,SAAU;AACtBP,IAAAA,SAAS,EAAEkB,SAAI,CAACD,UAAU,EAAE,cAAc,CAAE;AAC5CR,IAAAA,QAAQ,EAAEA,QAAS;AACnBD,IAAAA,OAAO,EAAEA,OAAQ;AAAAP,IAAAA,QAAA,EAEhBA;AAAQ,GACM,CAAC,gBAElBoB,eAAA,CAACC,uBAAe,EAAA;AACdpB,IAAAA,IAAI,EAAEA,IAAK;AACXC,IAAAA,MAAM,EAAEA,MAAO;AACfH,IAAAA,SAAS,EAAEiB,UAAW;AACtB,IAAA,YAAA,EAAYV,SAAU;AACtBgB,IAAAA,GAAG,EAAEP,OAAO,GAAG,YAAY,GAAGD,SAAU;AACxCN,IAAAA,QAAQ,EAAEA,QAAS;AACnBD,IAAAA,OAAO,EAAEA,OAAQ;AAAA,IAAA,GACbE,KAAK;IAAAT,QAAA,EAAA,CAERA,QAAQ,EAAE,GAAA,EAACe,OAAO,iBAAIG,cAAA,CAACK,kBAAgB,EAAA;AAACC,MAAAA,KAAK,EAAEd,aAAa,CAACe,qBAAQ,CAACC,aAAa;AAAE,MAAG;AAAA,GAC1E,CAClB;AACH;;;;"}
|
package/build/Link/Link.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.mjs","sources":["../../src/Link/Link.tsx"],"sourcesContent":["import { NavigateAway as NavigateAwayIcon } from '@transferwise/icons';\nimport { clsx } from 'clsx';\nimport { useIntl } from 'react-intl';\nimport { PrimitiveAnchor, PrimitiveButton } from '../Primitives';\nimport type { PrimitiveAnchorProps, PrimitiveButtonProps } from '../Primitives';\n\nimport { LinkLarge, LinkDefault, Typography } from '../common';\n\nimport messages from './Link.messages';\n\nexport type
|
|
1
|
+
{"version":3,"file":"Link.mjs","sources":["../../src/Link/Link.tsx"],"sourcesContent":["import { NavigateAway as NavigateAwayIcon } from '@transferwise/icons';\nimport { clsx } from 'clsx';\nimport { useIntl } from 'react-intl';\nimport { PrimitiveAnchor, PrimitiveButton } from '../Primitives';\nimport type { PrimitiveAnchorProps, PrimitiveButtonProps } from '../Primitives';\n\nimport { LinkLarge, LinkDefault, Typography } from '../common';\n\nimport messages from './Link.messages';\n\nexport type LinkProps = PrimitiveAnchorProps &\n Pick<PrimitiveButtonProps, 'onClick'> & { type?: LinkLarge | LinkDefault };\n\n/**\n * Standard Link component with navigate away icon\n *\n * Documentation: https://transferwise.github.io/neptune-web/components/content/Link\n */\nconst Link = ({\n className,\n children,\n href,\n target,\n type = Typography.LINK_DEFAULT,\n 'aria-label': ariaLabel,\n onClick,\n disabled,\n ...props\n}: LinkProps) => {\n const { formatMessage } = useIntl();\n const isButton = Boolean(onClick) && href === undefined;\n const isBlank = target === '_blank';\n\n const classNames = clsx(\n 'np-link',\n 'd-inline-flex',\n {\n [`np-text-${type}`]: type,\n 'np-link--disabled': disabled,\n },\n className,\n );\n\n return isButton ? (\n <PrimitiveButton\n type=\"button\"\n aria-label={ariaLabel}\n className={clsx(classNames, 'btn-unstyled')}\n disabled={disabled}\n onClick={onClick}\n >\n {children}\n </PrimitiveButton>\n ) : (\n <PrimitiveAnchor\n href={href}\n target={target}\n className={classNames}\n aria-label={ariaLabel}\n rel={isBlank ? 'noreferrer' : undefined}\n disabled={disabled}\n onClick={onClick}\n {...props}\n >\n {children} {isBlank && <NavigateAwayIcon title={formatMessage(messages.opensInNewTab)} />}\n </PrimitiveAnchor>\n );\n};\n\nexport default Link;\n"],"names":["Link","className","children","href","target","type","Typography","LINK_DEFAULT","ariaLabel","onClick","disabled","props","formatMessage","useIntl","isButton","Boolean","undefined","isBlank","classNames","clsx","_jsx","PrimitiveButton","_jsxs","PrimitiveAnchor","rel","NavigateAwayIcon","title","messages","opensInNewTab"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAMA,IAAI,GAAGA,CAAC;EACZC,SAAS;EACTC,QAAQ;EACRC,IAAI;EACJC,MAAM;EACNC,IAAI,GAAGC,UAAU,CAACC,YAAY;AAC9B,EAAA,YAAY,EAAEC,SAAS;EACvBC,OAAO;EACPC,QAAQ;EACR,GAAGC;AAAK,CACE,KAAI;EACd,MAAM;AAAEC,IAAAA;GAAe,GAAGC,OAAO,EAAE;EACnC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+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var Link = require('../Link/Link.js');
|
|
7
|
+
var parseMarkup = require('./utils/parseMarkup.js');
|
|
8
|
+
var sanitise = require('./utils/sanitise.js');
|
|
9
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
10
|
+
|
|
11
|
+
const PLACEHOLDER_REGEX = /\{\{(\w+)\}\}/g;
|
|
12
|
+
function substituteData(text, data) {
|
|
13
|
+
return text.replace(PLACEHOLDER_REGEX, (match, key) => Object.prototype.hasOwnProperty.call(data, key) ? String(data[key]) : match);
|
|
14
|
+
}
|
|
15
|
+
function renderNodes(nodes, actions, data, allowLinks) {
|
|
16
|
+
return nodes.map((node, index) => renderNode(node, actions, data, allowLinks, index));
|
|
17
|
+
}
|
|
18
|
+
function renderLinkNode(node, actions, data, allowLinks, key) {
|
|
19
|
+
const children = renderNodes(node.children, actions, data, allowLinks);
|
|
20
|
+
if (node.action && actions?.[node.action]) {
|
|
21
|
+
return (
|
|
22
|
+
/*#__PURE__*/
|
|
23
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
|
|
24
|
+
jsxRuntime.jsx(Link.default, {
|
|
25
|
+
"aria-label": node.accessibilityLabel,
|
|
26
|
+
onClick: actions[node.action],
|
|
27
|
+
children: children
|
|
28
|
+
}, key)
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
const sanitisedHref = node.href ? sanitise.sanitiseHref(node.href) : undefined;
|
|
32
|
+
if (sanitisedHref && sanitise.isHrefAllowedByMode(sanitisedHref, allowLinks)) {
|
|
33
|
+
return /*#__PURE__*/jsxRuntime.jsx(Link.default, {
|
|
34
|
+
href: sanitisedHref,
|
|
35
|
+
target: node.target,
|
|
36
|
+
"aria-label": node.accessibilityLabel,
|
|
37
|
+
children: children
|
|
38
|
+
}, key);
|
|
39
|
+
}
|
|
40
|
+
return /*#__PURE__*/jsxRuntime.jsx(React.Fragment, {
|
|
41
|
+
children: children
|
|
42
|
+
}, key);
|
|
43
|
+
}
|
|
44
|
+
function renderNode(node, actions, data, allowLinks, key) {
|
|
45
|
+
switch (node.type) {
|
|
46
|
+
case 'text':
|
|
47
|
+
return /*#__PURE__*/jsxRuntime.jsx(React.Fragment, {
|
|
48
|
+
children: data ? substituteData(node.content, data) : node.content
|
|
49
|
+
}, key);
|
|
50
|
+
case 'newline':
|
|
51
|
+
return /*#__PURE__*/jsxRuntime.jsx("br", {}, key);
|
|
52
|
+
case 'important':
|
|
53
|
+
case 'positive':
|
|
54
|
+
case 'negative':
|
|
55
|
+
return /*#__PURE__*/jsxRuntime.jsx("em", {
|
|
56
|
+
className: `wds-markup-emphasis wds-markup-emphasis--${node.type}`,
|
|
57
|
+
"aria-label": node.accessibilityLabel,
|
|
58
|
+
children: renderNodes(node.children, actions, data, allowLinks)
|
|
59
|
+
}, key);
|
|
60
|
+
case 'strong':
|
|
61
|
+
return /*#__PURE__*/jsxRuntime.jsx("strong", {
|
|
62
|
+
className: "wds-markup-strong",
|
|
63
|
+
"aria-label": node.accessibilityLabel,
|
|
64
|
+
children: renderNodes(node.children, actions, data, allowLinks)
|
|
65
|
+
}, key);
|
|
66
|
+
case 'strikethrough':
|
|
67
|
+
return /*#__PURE__*/jsxRuntime.jsx("del", {
|
|
68
|
+
className: "wds-markup-strikethrough",
|
|
69
|
+
"aria-label": node.accessibilityLabel,
|
|
70
|
+
children: renderNodes(node.children, actions, data, allowLinks)
|
|
71
|
+
}, key);
|
|
72
|
+
case 'paragraph':
|
|
73
|
+
return /*#__PURE__*/jsxRuntime.jsx("p", {
|
|
74
|
+
className: "wds-markup-paragraph",
|
|
75
|
+
children: renderNodes(node.children, actions, data, allowLinks)
|
|
76
|
+
}, key);
|
|
77
|
+
case 'link':
|
|
78
|
+
return renderLinkNode(node, actions, data, allowLinks, key);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function hasParagraph(nodes) {
|
|
82
|
+
for (const node of nodes) {
|
|
83
|
+
if (node.type === 'paragraph') {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
if ('children' in node && hasParagraph(node.children)) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Parses a markup string and renders it as React elements. Supports `<important>`,
|
|
94
|
+
* `<positive>`, `<negative>`, `<strong>`, `<strikethrough>`, `<paragraph>` (alias `<p>`),
|
|
95
|
+
* and `<link>` (alias `<a>`) with secure href validation.
|
|
96
|
+
*
|
|
97
|
+
* It only processes `string` input, while `ReactNode` is passed-through without processing.
|
|
98
|
+
*
|
|
99
|
+
* > The component supersedes [Emphasis](?path=/docs/typography-emphasis--docs), which will be
|
|
100
|
+
* eventually deprecated.
|
|
101
|
+
*
|
|
102
|
+
* @see http://storybook.wise.design/?path=/docs/typography-markup--docs
|
|
103
|
+
* @link ../emphasis/Emphasis | Emphasis
|
|
104
|
+
*/
|
|
105
|
+
const Markup = ({
|
|
106
|
+
children,
|
|
107
|
+
data,
|
|
108
|
+
allowLinks = 'internal',
|
|
109
|
+
actions,
|
|
110
|
+
as,
|
|
111
|
+
className,
|
|
112
|
+
'data-testid': testId
|
|
113
|
+
}) => {
|
|
114
|
+
const tree = React.useMemo(() => typeof children === 'string' ? parseMarkup.parseMarkup(children) : [], [children]);
|
|
115
|
+
if (typeof children !== 'string') {
|
|
116
|
+
if (children == null) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
120
|
+
className: className,
|
|
121
|
+
"data-testid": testId,
|
|
122
|
+
children: children
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
if (tree.length === 0) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
const Element = as ?? (hasParagraph(tree) ? 'div' : 'span');
|
|
129
|
+
return /*#__PURE__*/jsxRuntime.jsx(Element, {
|
|
130
|
+
className: className,
|
|
131
|
+
"data-testid": testId,
|
|
132
|
+
children: renderNodes(tree, actions, data, allowLinks)
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
exports.Markup = Markup;
|
|
137
|
+
exports.default = Markup;
|
|
138
|
+
//# sourceMappingURL=Markup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Markup.js","sources":["../../src/Markup/Markup.tsx"],"sourcesContent":["import React, { Fragment, useMemo } from 'react';\n\nimport Link from '../Link';\n\nimport { parseMarkup } from './utils/parseMarkup';\nimport { type AllowLinksMode, isHrefAllowedByMode, sanitiseHref } from './utils/sanitise';\nimport type { MarkupActions, MarkupNode, MarkupProps } from './Markup.types';\n\nconst PLACEHOLDER_REGEX = /\\{\\{(\\w+)\\}\\}/g;\n\ntype MarkupData = Record<string, string | number>;\n\nfunction substituteData(text: string, data: MarkupData): string {\n return text.replace(PLACEHOLDER_REGEX, (match, key: string) =>\n Object.prototype.hasOwnProperty.call(data, key) ? String(data[key]) : match,\n );\n}\n\nfunction renderNodes(\n nodes: MarkupNode[],\n actions: MarkupActions | undefined,\n data: MarkupData | undefined,\n allowLinks: AllowLinksMode,\n): React.ReactNode[] {\n return nodes.map((node, index) => renderNode(node, actions, data, allowLinks, index));\n}\n\nfunction renderLinkNode(\n node: Extract<MarkupNode, { type: 'link' }>,\n actions: MarkupActions | undefined,\n data: MarkupData | undefined,\n allowLinks: AllowLinksMode,\n key: number,\n): React.ReactNode {\n const children = renderNodes(node.children, actions, data, allowLinks);\n\n if (node.action && actions?.[node.action]) {\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events\n <Link key={key} aria-label={node.accessibilityLabel} onClick={actions[node.action]}>\n {children}\n </Link>\n );\n }\n\n const sanitisedHref = node.href ? sanitiseHref(node.href) : undefined;\n if (sanitisedHref && isHrefAllowedByMode(sanitisedHref, allowLinks)) {\n return (\n <Link\n key={key}\n href={sanitisedHref}\n target={node.target}\n aria-label={node.accessibilityLabel}\n >\n {children}\n </Link>\n );\n }\n\n return <Fragment key={key}>{children}</Fragment>;\n}\n\nfunction renderNode(\n node: MarkupNode,\n actions: MarkupActions | undefined,\n data: MarkupData | undefined,\n allowLinks: AllowLinksMode,\n key: number,\n): React.ReactNode {\n switch (node.type) {\n case 'text':\n return (\n <Fragment key={key}>{data ? substituteData(node.content, data) : node.content}</Fragment>\n );\n case 'newline':\n return <br key={key} />;\n case 'important':\n case 'positive':\n case 'negative':\n return (\n <em\n key={key}\n className={`wds-markup-emphasis wds-markup-emphasis--${node.type}`}\n aria-label={node.accessibilityLabel}\n >\n {renderNodes(node.children, actions, data, allowLinks)}\n </em>\n );\n case 'strong':\n return (\n <strong key={key} className=\"wds-markup-strong\" aria-label={node.accessibilityLabel}>\n {renderNodes(node.children, actions, data, allowLinks)}\n </strong>\n );\n case 'strikethrough':\n return (\n <del key={key} className=\"wds-markup-strikethrough\" aria-label={node.accessibilityLabel}>\n {renderNodes(node.children, actions, data, allowLinks)}\n </del>\n );\n case 'paragraph':\n return (\n <p key={key} className=\"wds-markup-paragraph\">\n {renderNodes(node.children, actions, data, allowLinks)}\n </p>\n );\n case 'link':\n return renderLinkNode(node, actions, data, allowLinks, key);\n }\n}\n\nfunction hasParagraph(nodes: MarkupNode[]): boolean {\n for (const node of nodes) {\n if (node.type === 'paragraph') {\n return true;\n }\n if ('children' in node && hasParagraph(node.children)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Parses a markup string and renders it as React elements. Supports `<important>`,\n * `<positive>`, `<negative>`, `<strong>`, `<strikethrough>`, `<paragraph>` (alias `<p>`),\n * and `<link>` (alias `<a>`) with secure href validation.\n *\n * It only processes `string` input, while `ReactNode` is passed-through without processing.\n *\n * > The component supersedes [Emphasis](?path=/docs/typography-emphasis--docs), which will be\n * eventually deprecated.\n *\n * @see http://storybook.wise.design/?path=/docs/typography-markup--docs\n * @link ../emphasis/Emphasis | Emphasis\n */\nexport const Markup: React.FC<MarkupProps> = ({\n children,\n data,\n allowLinks = 'internal',\n actions,\n as,\n className,\n 'data-testid': testId,\n}) => {\n const tree = useMemo(\n () => (typeof children === 'string' ? parseMarkup(children) : []),\n [children],\n );\n\n if (typeof children !== 'string') {\n if (children == null) {\n return null;\n }\n return (\n <span className={className} data-testid={testId}>\n {children}\n </span>\n );\n }\n\n if (tree.length === 0) {\n return null;\n }\n\n const Element = as ?? (hasParagraph(tree) ? 'div' : 'span');\n\n return (\n <Element className={className} data-testid={testId}>\n {renderNodes(tree, actions, data, allowLinks)}\n </Element>\n );\n};\n\nexport default Markup;\n"],"names":["PLACEHOLDER_REGEX","substituteData","text","data","replace","match","key","Object","prototype","hasOwnProperty","call","String","renderNodes","nodes","actions","allowLinks","map","node","index","renderNode","renderLinkNode","children","action","_jsx","Link","accessibilityLabel","onClick","sanitisedHref","href","sanitiseHref","undefined","isHrefAllowedByMode","target","Fragment","type","content","className","hasParagraph","Markup","as","testId","tree","useMemo","parseMarkup","length","Element"],"mappings":";;;;;;;;;;AAQA,MAAMA,iBAAiB,GAAG,gBAAgB;AAI1C,SAASC,cAAcA,CAACC,IAAY,EAAEC,IAAgB,EAAA;AACpD,EAAA,OAAOD,IAAI,CAACE,OAAO,CAACJ,iBAAiB,EAAE,CAACK,KAAK,EAAEC,GAAW,KACxDC,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACP,IAAI,EAAEG,GAAG,CAAC,GAAGK,MAAM,CAACR,IAAI,CAACG,GAAG,CAAC,CAAC,GAAGD,KAAK,CAC5E;AACH;AAEA,SAASO,WAAWA,CAClBC,KAAmB,EACnBC,OAAkC,EAClCX,IAA4B,EAC5BY,UAA0B,EAAA;EAE1B,OAAOF,KAAK,CAACG,GAAG,CAAC,CAACC,IAAI,EAAEC,KAAK,KAAKC,UAAU,CAACF,IAAI,EAAEH,OAAO,EAAEX,IAAI,EAAEY,UAAU,EAAEG,KAAK,CAAC,CAAC;AACvF;AAEA,SAASE,cAAcA,CACrBH,IAA2C,EAC3CH,OAAkC,EAClCX,IAA4B,EAC5BY,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EAAE;AACrB,IAAA,OAAO,IAAI;AACb,EAAA;AAEA,EAAA,MAAMC,OAAO,GAAGN,EAAE,KAAKF,YAAY,CAACI,IAAI,CAAC,GAAG,KAAK,GAAG,MAAM,CAAC;EAE3D,oBACElB,cAAA,CAACsB,OAAO,EAAA;AAACT,IAAAA,SAAS,EAAEA,SAAU;AAAC,IAAA,aAAA,EAAaI,MAAO;IAAAnB,QAAA,EAChDT,WAAW,CAAC6B,IAAI,EAAE3B,OAAO,EAAEX,IAAI,EAAEY,UAAU;AAAC,GACtC,CAAC;AAEd;;;;;"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { useMemo, Fragment } from 'react';
|
|
2
|
+
import Link from '../Link/Link.mjs';
|
|
3
|
+
import { parseMarkup } from './utils/parseMarkup.mjs';
|
|
4
|
+
import { sanitiseHref, isHrefAllowedByMode } from './utils/sanitise.mjs';
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
const PLACEHOLDER_REGEX = /\{\{(\w+)\}\}/g;
|
|
8
|
+
function substituteData(text, data) {
|
|
9
|
+
return text.replace(PLACEHOLDER_REGEX, (match, key) => Object.prototype.hasOwnProperty.call(data, key) ? String(data[key]) : match);
|
|
10
|
+
}
|
|
11
|
+
function renderNodes(nodes, actions, data, allowLinks) {
|
|
12
|
+
return nodes.map((node, index) => renderNode(node, actions, data, allowLinks, index));
|
|
13
|
+
}
|
|
14
|
+
function renderLinkNode(node, actions, data, allowLinks, key) {
|
|
15
|
+
const children = renderNodes(node.children, actions, data, allowLinks);
|
|
16
|
+
if (node.action && actions?.[node.action]) {
|
|
17
|
+
return (
|
|
18
|
+
/*#__PURE__*/
|
|
19
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
|
|
20
|
+
jsx(Link, {
|
|
21
|
+
"aria-label": node.accessibilityLabel,
|
|
22
|
+
onClick: actions[node.action],
|
|
23
|
+
children: children
|
|
24
|
+
}, key)
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
const sanitisedHref = node.href ? sanitiseHref(node.href) : undefined;
|
|
28
|
+
if (sanitisedHref && isHrefAllowedByMode(sanitisedHref, allowLinks)) {
|
|
29
|
+
return /*#__PURE__*/jsx(Link, {
|
|
30
|
+
href: sanitisedHref,
|
|
31
|
+
target: node.target,
|
|
32
|
+
"aria-label": node.accessibilityLabel,
|
|
33
|
+
children: children
|
|
34
|
+
}, key);
|
|
35
|
+
}
|
|
36
|
+
return /*#__PURE__*/jsx(Fragment, {
|
|
37
|
+
children: children
|
|
38
|
+
}, key);
|
|
39
|
+
}
|
|
40
|
+
function renderNode(node, actions, data, allowLinks, key) {
|
|
41
|
+
switch (node.type) {
|
|
42
|
+
case 'text':
|
|
43
|
+
return /*#__PURE__*/jsx(Fragment, {
|
|
44
|
+
children: data ? substituteData(node.content, data) : node.content
|
|
45
|
+
}, key);
|
|
46
|
+
case 'newline':
|
|
47
|
+
return /*#__PURE__*/jsx("br", {}, key);
|
|
48
|
+
case 'important':
|
|
49
|
+
case 'positive':
|
|
50
|
+
case 'negative':
|
|
51
|
+
return /*#__PURE__*/jsx("em", {
|
|
52
|
+
className: `wds-markup-emphasis wds-markup-emphasis--${node.type}`,
|
|
53
|
+
"aria-label": node.accessibilityLabel,
|
|
54
|
+
children: renderNodes(node.children, actions, data, allowLinks)
|
|
55
|
+
}, key);
|
|
56
|
+
case 'strong':
|
|
57
|
+
return /*#__PURE__*/jsx("strong", {
|
|
58
|
+
className: "wds-markup-strong",
|
|
59
|
+
"aria-label": node.accessibilityLabel,
|
|
60
|
+
children: renderNodes(node.children, actions, data, allowLinks)
|
|
61
|
+
}, key);
|
|
62
|
+
case 'strikethrough':
|
|
63
|
+
return /*#__PURE__*/jsx("del", {
|
|
64
|
+
className: "wds-markup-strikethrough",
|
|
65
|
+
"aria-label": node.accessibilityLabel,
|
|
66
|
+
children: renderNodes(node.children, actions, data, allowLinks)
|
|
67
|
+
}, key);
|
|
68
|
+
case 'paragraph':
|
|
69
|
+
return /*#__PURE__*/jsx("p", {
|
|
70
|
+
className: "wds-markup-paragraph",
|
|
71
|
+
children: renderNodes(node.children, actions, data, allowLinks)
|
|
72
|
+
}, key);
|
|
73
|
+
case 'link':
|
|
74
|
+
return renderLinkNode(node, actions, data, allowLinks, key);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function hasParagraph(nodes) {
|
|
78
|
+
for (const node of nodes) {
|
|
79
|
+
if (node.type === 'paragraph') {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
if ('children' in node && hasParagraph(node.children)) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Parses a markup string and renders it as React elements. Supports `<important>`,
|
|
90
|
+
* `<positive>`, `<negative>`, `<strong>`, `<strikethrough>`, `<paragraph>` (alias `<p>`),
|
|
91
|
+
* and `<link>` (alias `<a>`) with secure href validation.
|
|
92
|
+
*
|
|
93
|
+
* It only processes `string` input, while `ReactNode` is passed-through without processing.
|
|
94
|
+
*
|
|
95
|
+
* > The component supersedes [Emphasis](?path=/docs/typography-emphasis--docs), which will be
|
|
96
|
+
* eventually deprecated.
|
|
97
|
+
*
|
|
98
|
+
* @see http://storybook.wise.design/?path=/docs/typography-markup--docs
|
|
99
|
+
* @link ../emphasis/Emphasis | Emphasis
|
|
100
|
+
*/
|
|
101
|
+
const Markup = ({
|
|
102
|
+
children,
|
|
103
|
+
data,
|
|
104
|
+
allowLinks = 'internal',
|
|
105
|
+
actions,
|
|
106
|
+
as,
|
|
107
|
+
className,
|
|
108
|
+
'data-testid': testId
|
|
109
|
+
}) => {
|
|
110
|
+
const tree = useMemo(() => typeof children === 'string' ? parseMarkup(children) : [], [children]);
|
|
111
|
+
if (typeof children !== 'string') {
|
|
112
|
+
if (children == null) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
return /*#__PURE__*/jsx("span", {
|
|
116
|
+
className: className,
|
|
117
|
+
"data-testid": testId,
|
|
118
|
+
children: children
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
if (tree.length === 0) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
const Element = as ?? (hasParagraph(tree) ? 'div' : 'span');
|
|
125
|
+
return /*#__PURE__*/jsx(Element, {
|
|
126
|
+
className: className,
|
|
127
|
+
"data-testid": testId,
|
|
128
|
+
children: renderNodes(tree, actions, data, allowLinks)
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export { Markup, Markup as default };
|
|
133
|
+
//# sourceMappingURL=Markup.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Markup.mjs","sources":["../../src/Markup/Markup.tsx"],"sourcesContent":["import React, { Fragment, useMemo } from 'react';\n\nimport Link from '../Link';\n\nimport { parseMarkup } from './utils/parseMarkup';\nimport { type AllowLinksMode, isHrefAllowedByMode, sanitiseHref } from './utils/sanitise';\nimport type { MarkupActions, MarkupNode, MarkupProps } from './Markup.types';\n\nconst PLACEHOLDER_REGEX = /\\{\\{(\\w+)\\}\\}/g;\n\ntype MarkupData = Record<string, string | number>;\n\nfunction substituteData(text: string, data: MarkupData): string {\n return text.replace(PLACEHOLDER_REGEX, (match, key: string) =>\n Object.prototype.hasOwnProperty.call(data, key) ? String(data[key]) : match,\n );\n}\n\nfunction renderNodes(\n nodes: MarkupNode[],\n actions: MarkupActions | undefined,\n data: MarkupData | undefined,\n allowLinks: AllowLinksMode,\n): React.ReactNode[] {\n return nodes.map((node, index) => renderNode(node, actions, data, allowLinks, index));\n}\n\nfunction renderLinkNode(\n node: Extract<MarkupNode, { type: 'link' }>,\n actions: MarkupActions | undefined,\n data: MarkupData | undefined,\n allowLinks: AllowLinksMode,\n key: number,\n): React.ReactNode {\n const children = renderNodes(node.children, actions, data, allowLinks);\n\n if (node.action && actions?.[node.action]) {\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events\n <Link key={key} aria-label={node.accessibilityLabel} onClick={actions[node.action]}>\n {children}\n </Link>\n );\n }\n\n const sanitisedHref = node.href ? sanitiseHref(node.href) : undefined;\n if (sanitisedHref && isHrefAllowedByMode(sanitisedHref, allowLinks)) {\n return (\n <Link\n key={key}\n href={sanitisedHref}\n target={node.target}\n aria-label={node.accessibilityLabel}\n >\n {children}\n </Link>\n );\n }\n\n return <Fragment key={key}>{children}</Fragment>;\n}\n\nfunction renderNode(\n node: MarkupNode,\n actions: MarkupActions | undefined,\n data: MarkupData | undefined,\n allowLinks: AllowLinksMode,\n key: number,\n): React.ReactNode {\n switch (node.type) {\n case 'text':\n return (\n <Fragment key={key}>{data ? substituteData(node.content, data) : node.content}</Fragment>\n );\n case 'newline':\n return <br key={key} />;\n case 'important':\n case 'positive':\n case 'negative':\n return (\n <em\n key={key}\n className={`wds-markup-emphasis wds-markup-emphasis--${node.type}`}\n aria-label={node.accessibilityLabel}\n >\n {renderNodes(node.children, actions, data, allowLinks)}\n </em>\n );\n case 'strong':\n return (\n <strong key={key} className=\"wds-markup-strong\" aria-label={node.accessibilityLabel}>\n {renderNodes(node.children, actions, data, allowLinks)}\n </strong>\n );\n case 'strikethrough':\n return (\n <del key={key} className=\"wds-markup-strikethrough\" aria-label={node.accessibilityLabel}>\n {renderNodes(node.children, actions, data, allowLinks)}\n </del>\n );\n case 'paragraph':\n return (\n <p key={key} className=\"wds-markup-paragraph\">\n {renderNodes(node.children, actions, data, allowLinks)}\n </p>\n );\n case 'link':\n return renderLinkNode(node, actions, data, allowLinks, key);\n }\n}\n\nfunction hasParagraph(nodes: MarkupNode[]): boolean {\n for (const node of nodes) {\n if (node.type === 'paragraph') {\n return true;\n }\n if ('children' in node && hasParagraph(node.children)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Parses a markup string and renders it as React elements. Supports `<important>`,\n * `<positive>`, `<negative>`, `<strong>`, `<strikethrough>`, `<paragraph>` (alias `<p>`),\n * and `<link>` (alias `<a>`) with secure href validation.\n *\n * It only processes `string` input, while `ReactNode` is passed-through without processing.\n *\n * > The component supersedes [Emphasis](?path=/docs/typography-emphasis--docs), which will be\n * eventually deprecated.\n *\n * @see http://storybook.wise.design/?path=/docs/typography-markup--docs\n * @link ../emphasis/Emphasis | Emphasis\n */\nexport const Markup: React.FC<MarkupProps> = ({\n children,\n data,\n allowLinks = 'internal',\n actions,\n as,\n className,\n 'data-testid': testId,\n}) => {\n const tree = useMemo(\n () => (typeof children === 'string' ? parseMarkup(children) : []),\n [children],\n );\n\n if (typeof children !== 'string') {\n if (children == null) {\n return null;\n }\n return (\n <span className={className} data-testid={testId}>\n {children}\n </span>\n );\n }\n\n if (tree.length === 0) {\n return null;\n }\n\n const Element = as ?? (hasParagraph(tree) ? 'div' : 'span');\n\n return (\n <Element className={className} data-testid={testId}>\n {renderNodes(tree, actions, data, allowLinks)}\n </Element>\n );\n};\n\nexport default Markup;\n"],"names":["PLACEHOLDER_REGEX","substituteData","text","data","replace","match","key","Object","prototype","hasOwnProperty","call","String","renderNodes","nodes","actions","allowLinks","map","node","index","renderNode","renderLinkNode","children","action","_jsx","Link","accessibilityLabel","onClick","sanitisedHref","href","sanitiseHref","undefined","isHrefAllowedByMode","target","Fragment","type","content","className","hasParagraph","Markup","as","testId","tree","useMemo","parseMarkup","length","Element"],"mappings":";;;;;;AAQA,MAAMA,iBAAiB,GAAG,gBAAgB;AAI1C,SAASC,cAAcA,CAACC,IAAY,EAAEC,IAAgB,EAAA;AACpD,EAAA,OAAOD,IAAI,CAACE,OAAO,CAACJ,iBAAiB,EAAE,CAACK,KAAK,EAAEC,GAAW,KACxDC,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACP,IAAI,EAAEG,GAAG,CAAC,GAAGK,MAAM,CAACR,IAAI,CAACG,GAAG,CAAC,CAAC,GAAGD,KAAK,CAC5E;AACH;AAEA,SAASO,WAAWA,CAClBC,KAAmB,EACnBC,OAAkC,EAClCX,IAA4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;AACpB,MAAA,OAAO,IAAI;AACb,IAAA;AACA,IAAA,oBACEE,GAAA,CAAA,MAAA,EAAA;AAAMa,MAAAA,SAAS,EAAEA,SAAU;AAAC,MAAA,aAAA,EAAaI,MAAO;AAAAnB,MAAAA,QAAA,EAC7CA;AAAQ,KACL,CAAC;AAEX,EAAA;AAEA,EAAA,IAAIoB,IAAI,CAACG,MAAM,KAAK,CAAC,EAAE;AACrB,IAAA,OAAO,IAAI;AACb,EAAA;AAEA,EAAA,MAAMC,OAAO,GAAGN,EAAE,KAAKF,YAAY,CAACI,IAAI,CAAC,GAAG,KAAK,GAAG,MAAM,CAAC;EAE3D,oBACElB,GAAA,CAACsB,OAAO,EAAA;AAACT,IAAAA,SAAS,EAAEA,SAAU;AAAC,IAAA,aAAA,EAAaI,MAAO;IAAAnB,QAAA,EAChDT,WAAW,CAAC6B,IAAI,EAAE3B,OAAO,EAAEX,IAAI,EAAEY,UAAU;AAAC,GACtC,CAAC;AAEd;;;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Only these tags are recognised — anything else is treated as plain text (security allow-list)
|
|
4
|
+
const ALLOWED_TAGS = ['important', 'positive', 'negative', 'strong', 'strikethrough', 'paragraph', 'p', 'link', 'a'];
|
|
5
|
+
const TAG_ALIASES = {
|
|
6
|
+
p: 'paragraph',
|
|
7
|
+
a: 'link'
|
|
8
|
+
};
|
|
9
|
+
// Maximum recursive nesting before the parser emits tags as literal text (DoS protection)
|
|
10
|
+
const MAX_NESTING_DEPTH = 32;
|
|
11
|
+
// Only these link targets are allowed — others are stripped to prevent iframe breakout
|
|
12
|
+
const ALLOWED_TARGETS = ['_blank', '_self'];
|
|
13
|
+
// Only these protocols pass href validation — all others are blocked
|
|
14
|
+
const ALLOWED_PROTOCOLS = ['https:', 'mailto:'];
|
|
15
|
+
|
|
16
|
+
exports.ALLOWED_PROTOCOLS = ALLOWED_PROTOCOLS;
|
|
17
|
+
exports.ALLOWED_TAGS = ALLOWED_TAGS;
|
|
18
|
+
exports.ALLOWED_TARGETS = ALLOWED_TARGETS;
|
|
19
|
+
exports.MAX_NESTING_DEPTH = MAX_NESTING_DEPTH;
|
|
20
|
+
exports.TAG_ALIASES = TAG_ALIASES;
|
|
21
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../src/Markup/constants.ts"],"sourcesContent":["// Only these tags are recognised — anything else is treated as plain text (security allow-list)\nexport const ALLOWED_TAGS = [\n 'important',\n 'positive',\n 'negative',\n 'strong',\n 'strikethrough',\n 'paragraph',\n 'p',\n 'link',\n 'a',\n] as const;\n\nexport const TAG_ALIASES: Record<string, string> = { p: 'paragraph', a: 'link' };\n\n// Maximum recursive nesting before the parser emits tags as literal text (DoS protection)\nexport const MAX_NESTING_DEPTH = 32;\n\n// Only these link targets are allowed — others are stripped to prevent iframe breakout\nexport const ALLOWED_TARGETS = ['_blank', '_self'];\n\n// Only these protocols pass href validation — all others are blocked\nexport const ALLOWED_PROTOCOLS = ['https:', 'mailto:'];\n"],"names":["ALLOWED_TAGS","TAG_ALIASES","p","a","MAX_NESTING_DEPTH","ALLOWED_TARGETS","ALLOWED_PROTOCOLS"],"mappings":";;AAAA;AACO,MAAMA,YAAY,GAAG,CAC1B,WAAW,EACX,UAAU,EACV,UAAU,EACV,QAAQ,EACR,eAAe,EACf,WAAW,EACX,GAAG,EACH,MAAM,EACN,GAAG;AAGE,MAAMC,WAAW,GAA2B;AAAEC,EAAAA,CAAC,EAAE,WAAW;AAAEC,EAAAA,CAAC,EAAE;;AAExE;AACO,MAAMC,iBAAiB,GAAG;AAEjC;MACaC,eAAe,GAAG,CAAC,QAAQ,EAAE,OAAO;AAEjD;MACaC,iBAAiB,GAAG,CAAC,QAAQ,EAAE,SAAS;;;;;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Only these tags are recognised — anything else is treated as plain text (security allow-list)
|
|
2
|
+
const ALLOWED_TAGS = ['important', 'positive', 'negative', 'strong', 'strikethrough', 'paragraph', 'p', 'link', 'a'];
|
|
3
|
+
const TAG_ALIASES = {
|
|
4
|
+
p: 'paragraph',
|
|
5
|
+
a: 'link'
|
|
6
|
+
};
|
|
7
|
+
// Maximum recursive nesting before the parser emits tags as literal text (DoS protection)
|
|
8
|
+
const MAX_NESTING_DEPTH = 32;
|
|
9
|
+
// Only these link targets are allowed — others are stripped to prevent iframe breakout
|
|
10
|
+
const ALLOWED_TARGETS = ['_blank', '_self'];
|
|
11
|
+
// Only these protocols pass href validation — all others are blocked
|
|
12
|
+
const ALLOWED_PROTOCOLS = ['https:', 'mailto:'];
|
|
13
|
+
|
|
14
|
+
export { ALLOWED_PROTOCOLS, ALLOWED_TAGS, ALLOWED_TARGETS, MAX_NESTING_DEPTH, TAG_ALIASES };
|
|
15
|
+
//# sourceMappingURL=constants.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.mjs","sources":["../../src/Markup/constants.ts"],"sourcesContent":["// Only these tags are recognised — anything else is treated as plain text (security allow-list)\nexport const ALLOWED_TAGS = [\n 'important',\n 'positive',\n 'negative',\n 'strong',\n 'strikethrough',\n 'paragraph',\n 'p',\n 'link',\n 'a',\n] as const;\n\nexport const TAG_ALIASES: Record<string, string> = { p: 'paragraph', a: 'link' };\n\n// Maximum recursive nesting before the parser emits tags as literal text (DoS protection)\nexport const MAX_NESTING_DEPTH = 32;\n\n// Only these link targets are allowed — others are stripped to prevent iframe breakout\nexport const ALLOWED_TARGETS = ['_blank', '_self'];\n\n// Only these protocols pass href validation — all others are blocked\nexport const ALLOWED_PROTOCOLS = ['https:', 'mailto:'];\n"],"names":["ALLOWED_TAGS","TAG_ALIASES","p","a","MAX_NESTING_DEPTH","ALLOWED_TARGETS","ALLOWED_PROTOCOLS"],"mappings":"AAAA;AACO,MAAMA,YAAY,GAAG,CAC1B,WAAW,EACX,UAAU,EACV,UAAU,EACV,QAAQ,EACR,eAAe,EACf,WAAW,EACX,GAAG,EACH,MAAM,EACN,GAAG;AAGE,MAAMC,WAAW,GAA2B;AAAEC,EAAAA,CAAC,EAAE,WAAW;AAAEC,EAAAA,CAAC,EAAE;;AAExE;AACO,MAAMC,iBAAiB,GAAG;AAEjC;MACaC,eAAe,GAAG,CAAC,QAAQ,EAAE,OAAO;AAEjD;MACaC,iBAAiB,GAAG,CAAC,QAAQ,EAAE,SAAS;;;;"}
|