@transferwise/components 0.0.0-experimental-3868cf1 → 0.0.0-experimental-69a95e1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/build/avatarLayout/AvatarLayout.js +10 -4
  2. package/build/avatarLayout/AvatarLayout.js.map +1 -1
  3. package/build/avatarLayout/AvatarLayout.mjs +10 -4
  4. package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
  5. package/build/button/Button.js +79 -79
  6. package/build/button/Button.js.map +1 -1
  7. package/build/button/Button.mjs +80 -80
  8. package/build/button/Button.mjs.map +1 -1
  9. package/build/button/Button.resolver.js +86 -0
  10. package/build/button/Button.resolver.js.map +1 -0
  11. package/build/button/Button.resolver.mjs +84 -0
  12. package/build/button/Button.resolver.mjs.map +1 -0
  13. package/build/button/LegacyButton.js +114 -0
  14. package/build/button/LegacyButton.js.map +1 -0
  15. package/build/button/LegacyButton.mjs +112 -0
  16. package/build/button/LegacyButton.mjs.map +1 -0
  17. package/build/criticalBanner/CriticalCommsBanner.js +2 -2
  18. package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
  19. package/build/criticalBanner/CriticalCommsBanner.mjs +1 -1
  20. package/build/header/Header.js +2 -2
  21. package/build/header/Header.js.map +1 -1
  22. package/build/header/Header.mjs +1 -1
  23. package/build/i18n/ja.json +0 -1
  24. package/build/i18n/ja.json.js +0 -1
  25. package/build/i18n/ja.json.js.map +1 -1
  26. package/build/i18n/ja.json.mjs +0 -1
  27. package/build/i18n/ja.json.mjs.map +1 -1
  28. package/build/i18n/pt.json +0 -1
  29. package/build/i18n/pt.json.js +0 -1
  30. package/build/i18n/pt.json.js.map +1 -1
  31. package/build/i18n/pt.json.mjs +0 -1
  32. package/build/i18n/pt.json.mjs.map +1 -1
  33. package/build/i18n/ru.json +0 -1
  34. package/build/i18n/ru.json.js +0 -1
  35. package/build/i18n/ru.json.js.map +1 -1
  36. package/build/i18n/ru.json.mjs +0 -1
  37. package/build/i18n/ru.json.mjs.map +1 -1
  38. package/build/i18n/zh-HK.json +0 -1
  39. package/build/i18n/zh-HK.json.js +0 -1
  40. package/build/i18n/zh-HK.json.js.map +1 -1
  41. package/build/i18n/zh-HK.json.mjs +0 -1
  42. package/build/i18n/zh-HK.json.mjs.map +1 -1
  43. package/build/index.js +2 -4
  44. package/build/index.js.map +1 -1
  45. package/build/index.mjs +1 -2
  46. package/build/index.mjs.map +1 -1
  47. package/build/link/Link.js +8 -3
  48. package/build/link/Link.js.map +1 -1
  49. package/build/link/Link.mjs +8 -3
  50. package/build/link/Link.mjs.map +1 -1
  51. package/build/main.css +227 -2
  52. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js +2 -4
  53. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js.map +1 -1
  54. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs +2 -4
  55. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs.map +1 -1
  56. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js +3 -5
  57. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js.map +1 -1
  58. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs +3 -5
  59. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs.map +1 -1
  60. package/build/select/Select.js +2 -2
  61. package/build/select/Select.js.map +1 -1
  62. package/build/select/Select.mjs +1 -1
  63. package/build/styles/avatarLayout/AvatarLayout.css +12 -2
  64. package/build/styles/button/Button.css +207 -15
  65. package/build/styles/button/Button.vars.css +39 -0
  66. package/build/styles/button/LegacyButton.css +23 -0
  67. package/build/styles/main.css +227 -2
  68. package/build/types/avatarLayout/AvatarLayout.d.ts +1 -2
  69. package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
  70. package/build/types/avatarLayout/index.d.ts +1 -0
  71. package/build/types/avatarLayout/index.d.ts.map +1 -1
  72. package/build/types/button/Button.d.ts +1 -23
  73. package/build/types/button/Button.d.ts.map +1 -1
  74. package/build/types/button/Button.resolver.d.ts +31 -0
  75. package/build/types/button/Button.resolver.d.ts.map +1 -0
  76. package/build/types/button/Button.types.d.ts +65 -0
  77. package/build/types/button/Button.types.d.ts.map +1 -0
  78. package/build/types/button/LegacyButton.d.ts +30 -0
  79. package/build/types/button/LegacyButton.d.ts.map +1 -0
  80. package/build/types/button/index.d.ts +2 -2
  81. package/build/types/button/index.d.ts.map +1 -1
  82. package/build/types/index.d.ts +0 -2
  83. package/build/types/index.d.ts.map +1 -1
  84. package/build/types/link/Link.d.ts +2 -2
  85. package/build/types/link/Link.d.ts.map +1 -1
  86. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.d.ts.map +1 -1
  87. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts +5 -1
  88. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts.map +1 -1
  89. package/build/types/primitives/PrimitiveButton/src/PrimitiveButton.d.ts.map +1 -1
  90. package/build/types/test-utils/story-config.d.ts +1 -1
  91. package/build/types/test-utils/story-config.d.ts.map +1 -1
  92. package/build/types/uploadInput/uploadButton/getAllowedFileTypes.d.ts.map +1 -1
  93. package/build/upload/steps/completeStep/completeStep.js +2 -2
  94. package/build/upload/steps/completeStep/completeStep.js.map +1 -1
  95. package/build/upload/steps/completeStep/completeStep.mjs +1 -1
  96. package/build/upload/steps/processingStep/processingStep.js +2 -2
  97. package/build/upload/steps/processingStep/processingStep.js.map +1 -1
  98. package/build/upload/steps/processingStep/processingStep.mjs +1 -1
  99. package/build/uploadInput/UploadInput.js +3 -3
  100. package/build/uploadInput/UploadInput.js.map +1 -1
  101. package/build/uploadInput/UploadInput.mjs +1 -1
  102. package/build/uploadInput/uploadButton/getAllowedFileTypes.js +3 -23
  103. package/build/uploadInput/uploadButton/getAllowedFileTypes.js.map +1 -1
  104. package/build/uploadInput/uploadButton/getAllowedFileTypes.mjs +3 -23
  105. package/build/uploadInput/uploadButton/getAllowedFileTypes.mjs.map +1 -1
  106. package/package.json +5 -5
  107. package/src/alert/Alert.tests.story.tsx +1 -1
  108. package/src/avatarLayout/AvatarLayout.css +12 -2
  109. package/src/avatarLayout/AvatarLayout.less +19 -2
  110. package/src/avatarLayout/AvatarLayout.tsx +11 -4
  111. package/src/avatarLayout/index.ts +1 -0
  112. package/src/button/Button.css +207 -15
  113. package/src/button/Button.less +217 -14
  114. package/src/button/Button.resolver.tsx +134 -0
  115. package/src/button/Button.spec.tsx +176 -225
  116. package/src/button/Button.story.tsx +729 -135
  117. package/src/button/Button.tests.story.tsx +27 -0
  118. package/src/button/Button.tsx +89 -132
  119. package/src/button/Button.types.ts +86 -0
  120. package/src/button/Button.vars.css +39 -0
  121. package/src/button/Button.vars.less +49 -0
  122. package/src/button/LegacyButton.css +23 -0
  123. package/src/button/LegacyButton.less +24 -0
  124. package/src/button/LegacyButton.spec.tsx +146 -0
  125. package/src/button/LegacyButton.story.tsx +225 -0
  126. package/src/button/LegacyButton.tsx +161 -0
  127. package/src/button/index.ts +2 -3
  128. package/src/field/Field.story.tsx +1 -1
  129. package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +1 -2
  130. package/src/i18n/ja.json +0 -1
  131. package/src/i18n/pt.json +0 -1
  132. package/src/i18n/ru.json +0 -1
  133. package/src/i18n/zh-HK.json +0 -1
  134. package/src/index.ts +0 -12
  135. package/src/inputs/SelectInput.story.tsx +1 -1
  136. package/src/label/Label.story.tsx +1 -1
  137. package/src/link/Link.tsx +15 -6
  138. package/src/main.css +227 -2
  139. package/src/main.less +1 -0
  140. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx +2 -8
  141. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.ts +6 -1
  142. package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +1 -3
  143. package/src/primitives/PrimitiveButton/src/PrimitiveButton.tsx +4 -12
  144. package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +16 -13
  145. package/src/test-utils/Parameters.d.ts +9 -1
  146. package/src/test-utils/story-config.ts +10 -1
  147. package/src/uploadInput/UploadInput.tests.story.tsx +5 -5
  148. package/src/uploadInput/uploadButton/getAllowedFileTypes.spec.ts +0 -12
  149. package/src/uploadInput/uploadButton/getAllowedFileTypes.ts +7 -33
  150. package/build/table/Table.js +0 -166
  151. package/build/table/Table.js.map +0 -1
  152. package/build/table/Table.messages.js +0 -24
  153. package/build/table/Table.messages.js.map +0 -1
  154. package/build/table/Table.messages.mjs +0 -22
  155. package/build/table/Table.messages.mjs.map +0 -1
  156. package/build/table/Table.mjs +0 -164
  157. package/build/table/Table.mjs.map +0 -1
  158. package/build/table/TableCell.js +0 -86
  159. package/build/table/TableCell.js.map +0 -1
  160. package/build/table/TableCell.mjs +0 -84
  161. package/build/table/TableCell.mjs.map +0 -1
  162. package/build/table/TableHeader.js +0 -57
  163. package/build/table/TableHeader.js.map +0 -1
  164. package/build/table/TableHeader.mjs +0 -55
  165. package/build/table/TableHeader.mjs.map +0 -1
  166. package/build/table/TableRow.js +0 -85
  167. package/build/table/TableRow.js.map +0 -1
  168. package/build/table/TableRow.mjs +0 -83
  169. package/build/table/TableRow.mjs.map +0 -1
  170. package/build/table/TableStatusText.js +0 -54
  171. package/build/table/TableStatusText.js.map +0 -1
  172. package/build/table/TableStatusText.mjs +0 -52
  173. package/build/table/TableStatusText.mjs.map +0 -1
  174. package/src/button/__snapshots__/Button.spec.tsx.snap +0 -309
@@ -1 +1 @@
1
- {"version":3,"file":"Button.mjs","sources":["../../src/button/Button.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { ElementType, forwardRef, MouseEvent } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport {\n Size,\n ControlType,\n Priority,\n ControlTypeAccent,\n ControlTypeNegative,\n ControlTypePositive,\n PriorityPrimary,\n PrioritySecondary,\n PriorityTertiary,\n SizeExtraSmall,\n SizeSmall,\n SizeMedium,\n SizeLarge,\n} from '../common';\nimport ProcessIndicator from '../processIndicator';\n\nimport messages from '../i18n/commonMessages/Button.messages';\nimport { typeClassMap, priorityClassMap } from './classMap';\nimport { establishNewPriority, establishNewType, logDeprecationNotices } from './legacyUtils';\n\n/** @deprecated */\ntype DeprecatedTypes = 'primary' | 'pay' | 'secondary' | 'danger' | 'link';\n\n/** @deprecated */\ntype DeprecatedSizes = SizeExtraSmall;\n\ntype CommonProps = {\n block?: boolean;\n disabled?: boolean;\n loading?: boolean;\n type?: ControlTypeAccent | ControlTypeNegative | ControlTypePositive | DeprecatedTypes | null;\n priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary | null;\n size?: SizeSmall | SizeMedium | SizeLarge | DeprecatedSizes;\n};\n\ntype ButtonProps = CommonProps &\n Omit<React.ComponentPropsWithRef<'button'>, 'type'> & {\n as?: 'button';\n htmlType?: 'submit' | 'reset' | 'button';\n };\n\ntype AnchorProps = CommonProps &\n Omit<React.ComponentPropsWithRef<'a'>, 'type'> & {\n as?: 'a';\n };\n\nexport type Props = ButtonProps | AnchorProps;\n\nexport type ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;\n\nconst Button = forwardRef<ButtonReferenceType, Props>(\n (\n {\n as: component,\n block = false,\n children,\n className,\n disabled,\n loading = false,\n priority = Priority.PRIMARY,\n size = Size.MEDIUM,\n type = ControlType.ACCENT,\n onClick,\n ...rest\n }: Props,\n reference,\n ) => {\n const intl = useIntl();\n\n logDeprecationNotices({ size, type });\n\n const newType = establishNewType(type);\n const newPriority = establishNewPriority(priority, type);\n\n const classes = clsx(\n `btn btn-${size}`,\n `np-btn np-btn-${size}`,\n {\n 'btn-loading': loading,\n 'btn-block np-btn-block': block,\n disabled,\n },\n // @ts-expect-error fix when refactor `typeClassMap` to TypeScript\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n typeClassMap[newType],\n // @ts-expect-error fix when refactor `typeClassMap` to TypeScript\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n priorityClassMap[newPriority],\n className,\n );\n\n function processIndicatorSize() {\n return ['sm', 'xs'].includes(size) ? 'xxs' : 'xs';\n }\n\n const Element = (component as ElementType) ?? 'button';\n let props;\n\n if (Element === 'button') {\n const { htmlType = 'button', ...restProps } = rest as ButtonProps;\n props = {\n ...restProps,\n disabled,\n 'aria-disabled': loading,\n type: htmlType,\n };\n } else {\n props = {\n ...rest,\n 'aria-disabled': loading,\n } as AnchorProps;\n }\n\n /**\n * Ensures that the button cannot be activated in loading or disabled mode,\n * when `aria-disabled` might be used over the `disabled` HTML attribute\n */\n const handleClick =\n (handler: Props['onClick']) =>\n (event: MouseEvent<HTMLButtonElement> & MouseEvent<HTMLAnchorElement>) => {\n if (disabled || loading) {\n event.preventDefault();\n } else if (typeof handler === 'function') {\n handler(event);\n }\n };\n\n return (\n <Element\n ref={reference}\n className={classes}\n onClick={handleClick(onClick)}\n {...props}\n aria-live={loading ? 'polite' : 'off'}\n aria-busy={loading}\n aria-label={loading ? intl.formatMessage(messages.loadingAriaLabel) : rest['aria-label']}\n >\n {children}\n {loading && (\n <ProcessIndicator\n size={processIndicatorSize()}\n className=\"btn-loader\"\n data-testid=\"ButtonProgressIndicator\"\n />\n )}\n </Element>\n );\n },\n);\n\nexport default Button;\n"],"names":["Button","forwardRef","as","component","block","children","className","disabled","loading","priority","Priority","PRIMARY","size","Size","MEDIUM","type","ControlType","ACCENT","onClick","rest","reference","intl","useIntl","logDeprecationNotices","newType","establishNewType","newPriority","establishNewPriority","classes","clsx","typeClassMap","priorityClassMap","processIndicatorSize","includes","Element","props","htmlType","restProps","handleClick","handler","event","preventDefault","_jsxs","ref","formatMessage","messages","loadingAriaLabel","_jsx","ProcessIndicator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,MAAMA,MAAM,gBAAGC,UAAU,CACvB,CACE;AACEC,EAAAA,EAAE,EAAEC,SAAS;AACbC,EAAAA,KAAK,GAAG,KAAK;EACbC,QAAQ;EACRC,SAAS;EACTC,QA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-disable @typescript-eslint/no-unsafe-assignment */\nimport { forwardRef } from 'react';\nimport { ButtonProps as NewButtonProps } from './Button.types';\nimport { PrimitiveAnchor, PrimitiveButton } from '../primitives';\nimport AvatarLayout from '../avatarLayout';\nimport ProcessIndicator from '../processIndicator';\nimport { clsx } from 'clsx';\nimport { Typography } from '../common';\nimport Body from '../body';\n\nconst Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, NewButtonProps>(\n (\n {\n as = 'button',\n children,\n className,\n size = 'lg',\n href,\n disabled = false,\n priority = 'primary',\n sentiment = 'default',\n iconStart: IconStart,\n iconEnd: IconEnd,\n avatars,\n type = 'button',\n loading = false,\n block = false,\n ...props\n },\n ref,\n ) => {\n const classNames = clsx(\n 'wds-Button',\n {\n [`wds-Button--block`]: block,\n [`wds-Button--disabled`]: disabled,\n [`wds-Button--loading`]: loading,\n },\n `wds-Button--${{ sm: 'small', md: 'medium', lg: 'large' }[size]}`,\n `wds-Button--${priority}`,\n `wds-Button--${sentiment}`,\n className,\n );\n\n const contentClassNames = clsx('wds-Button-content', {\n [`wds-Button-content--loading`]: loading,\n });\n\n const content = (\n <Body\n as=\"span\"\n type={size === 'sm' ? Typography.BODY_DEFAULT_BOLD : Typography.BODY_LARGE_BOLD}\n className={contentClassNames}\n >\n {loading && (\n <ProcessIndicator\n size={size === 'sm' ? 'xxs' : 'xs'}\n className=\"wds-Button-loader\"\n data-testid=\"button-loader-indicator\"\n />\n )}\n <span className=\"wds-Button-label\" aria-hidden={loading}>\n {size === 'lg' ? (\n children\n ) : (\n <>\n {size === 'md' && avatars && (\n <span className=\"wds-Button-avatars\">\n <AvatarLayout orientation=\"horizontal\" avatars={avatars} size={24} />\n </span>\n )}\n {!avatars && IconStart && (\n <IconStart className=\"wds-Button-icon wds-Button-icon--start\" />\n )}\n {children}\n {IconEnd && <IconEnd className=\"wds-Button-icon wds-Button-icon--end\" />}\n </>\n )}\n </span>\n </Body>\n );\n\n if (href || as === 'a') {\n return (\n <PrimitiveAnchor\n ref={ref as React.Ref<HTMLAnchorElement>}\n {...(props as any)}\n href={href}\n className={classNames}\n disabled={disabled || loading}\n aria-busy={loading || undefined}\n >\n {content}\n </PrimitiveAnchor>\n );\n }\n\n return (\n <PrimitiveButton\n ref={ref as React.Ref<HTMLButtonElement>}\n {...(props as any)}\n className={classNames}\n disabled={disabled}\n loading={loading}\n type={type}\n >\n {content}\n </PrimitiveButton>\n );\n },\n);\n\nexport default Button;\n"],"names":["Button","forwardRef","as","children","className","size","href","disabled","priority","sentiment","iconStart","IconStart","iconEnd","IconEnd","avatars","type","loading","block","props","ref","classNames","clsx","sm","md","lg","contentClassNames","content","_jsxs","Body","Typography","BODY_DEFAULT_BOLD","BODY_LARGE_BOLD","_jsx","ProcessIndicator","_Fragment","AvatarLayout","orientation","PrimitiveAnchor","undefined","PrimitiveButton"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAUA,MAAMA,MAAM,gBAAGC,UAAU,CACvB,CACE;AACEC,EAAAA,EAAE,GAAG,QAAQ;EACbC,QAAQ;EACRC,SAAS;AACTC,EAAAA,IAAI,GAAG,IAAI;EACXC,IAAI;AACJC,EAAAA,QAAQ,GAAG,KAAK;AAChBC,EAAAA,QAAQ,GAAG,SAAS;AACpBC,EAAAA,SAAS,GAAG,SAAS;AACrBC,EAAAA,SAAS,EAAEC,SAAS;AACpBC,EAAAA,OAAO,EAAEC,OAAO;EAChBC,OAAO;AACPC,EAAAA,IAAI,GAAG,QAAQ;AACfC,EAAAA,OAAO,GAAG,KAAK;AACfC,EAAAA,KAAK,GAAG,KAAK;EACb,GAAGC,KAAAA;AACJ,CAAA,EACDC,GAAG,KACD;AACF,EAAA,MAAMC,UAAU,GAAGC,IAAI,CACrB,YAAY,EACZ;IACE,CAAC,CAAA,iBAAA,CAAmB,GAAGJ,KAAK;IAC5B,CAAC,CAAA,oBAAA,CAAsB,GAAGV,QAAQ;AAClC,IAAA,CAAC,qBAAqB,GAAGS,OAAAA;AAC1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AA,WAAW,EAAC,YAAY;AAACtB,YAAAA,OAAO,EAAEA,OAAQ;AAACT,YAAAA,IAAI,EAAE,EAAA;WACjE,CAAA;SAAM,CACP,EACA,CAACS,OAAO,IAAIH,SAAS,iBACpBqB,GAAA,CAACrB,SAAS,EAAA;AAACP,UAAAA,SAAS,EAAC,wCAAA;SAAwC,CAC9D,EACAD,QAAQ,EACRU,OAAO,iBAAImB,GAAA,CAACnB,OAAO,EAAA;AAACT,UAAAA,SAAS,EAAC,sCAAA;AAAsC,SAAA,CAAG,CAAA;OAC1E,CAAA;AACD,KACG,CACR,CAAA;AAAA,GAAM,CACP,CAAA;AAED,EAAA,IAAIE,IAAI,IAAIJ,EAAE,KAAK,GAAG,EAAE;IACtB,oBACE8B,GAAA,CAACK,eAAe,EAAA;AACdlB,MAAAA,GAAG,EAAEA,GAAoC;AAAA,MAAA,GACpCD,KAAa;AAClBZ,MAAAA,IAAI,EAAEA,IAAK;AACXF,MAAAA,SAAS,EAAEgB,UAAW;MACtBb,QAAQ,EAAEA,QAAQ,IAAIS,OAAQ;MAC9B,WAAWA,EAAAA,OAAO,IAAIsB,SAAU;AAAAnC,MAAAA,QAAA,EAE/BuB,OAAAA;AAAO,KACO,CAAC,CAAA;AAEtB,GAAA;EAEA,oBACEM,GAAA,CAACO,eAAe,EAAA;AACdpB,IAAAA,GAAG,EAAEA,GAAoC;AAAA,IAAA,GACpCD,KAAa;AAClBd,IAAAA,SAAS,EAAEgB,UAAW;AACtBb,IAAAA,QAAQ,EAAEA,QAAS;AACnBS,IAAAA,OAAO,EAAEA,OAAQ;AACjBD,IAAAA,IAAI,EAAEA,IAAK;AAAAZ,IAAAA,QAAA,EAEVuB,OAAAA;AAAO,GACO,CAAC,CAAA;AAEtB,CAAC;;;;"}
@@ -0,0 +1,86 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var LegacyButton = require('./LegacyButton.js');
5
+ var Button$1 = require('./Button.js');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+
8
+ const mapProps = props => {
9
+ const {
10
+ priority,
11
+ size,
12
+ type,
13
+ as,
14
+ ...newProps
15
+ } = props;
16
+ const priorityMapping = {
17
+ accent: {
18
+ primary: 'primary',
19
+ secondary: 'tertiary',
20
+ tertiary: 'minimal'
21
+ },
22
+ positive: {
23
+ primary: 'primary',
24
+ secondary: 'tertiary',
25
+ tertiary: 'tertiary'
26
+ },
27
+ negative: {
28
+ primary: 'primary',
29
+ secondary: 'secondary',
30
+ tertiary: 'secondary'
31
+ }
32
+ };
33
+ const mappedPriority = type && priority ? priorityMapping[type]?.[priority] || priority : priority || undefined;
34
+ const mappedSentiment = type === 'negative' ? 'negative' : undefined;
35
+ const legacyButtonTypes = ['accent', 'negative', 'positive', 'primary', 'pay', 'secondary', 'danger', 'link'];
36
+ const resolveSize = () => {
37
+ if (size) {
38
+ return {
39
+ xs: 'sm',
40
+ sm: 'sm',
41
+ md: 'md',
42
+ lg: 'lg'
43
+ }[size] || size;
44
+ }
45
+ return size;
46
+ };
47
+ return {
48
+ ...newProps,
49
+ size: resolveSize(),
50
+ priority: mappedPriority,
51
+ sentiment: mappedSentiment || ('sentiment' in props ? props.sentiment : null),
52
+ type: type && !legacyButtonTypes.includes(type) ? type : props.htmlType || null,
53
+ v2: undefined
54
+ };
55
+ };
56
+ const Button = /*#__PURE__*/React.forwardRef((props, ref) => {
57
+ const {
58
+ v2 = false,
59
+ as,
60
+ ...rest
61
+ } = props;
62
+ if (v2) {
63
+ const mappedProps = mapProps(props);
64
+ return /*#__PURE__*/jsxRuntime.jsx(Button$1, {
65
+ ...mappedProps,
66
+ ref: ref,
67
+ as: as
68
+ });
69
+ }
70
+ if (as === 'a') {
71
+ return /*#__PURE__*/jsxRuntime.jsx(LegacyButton, {
72
+ ...rest,
73
+ ref: ref,
74
+ as: "a"
75
+ });
76
+ }
77
+ return /*#__PURE__*/jsxRuntime.jsx(LegacyButton, {
78
+ ...rest,
79
+ ref: ref,
80
+ as: "button"
81
+ });
82
+ });
83
+ Button.displayName = 'Button';
84
+
85
+ module.exports = Button;
86
+ //# sourceMappingURL=Button.resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.resolver.js","sources":["../../src/button/Button.resolver.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport LegacyButton, {\n AnchorProps as LegacyAnchorProps,\n ButtonProps as LegacyButtonProps,\n} from './LegacyButton';\nimport { ButtonProps as NewButtonProps } from './Button.types';\nimport NewButton from './Button';\n\ntype LegacyButtonType =\n | 'accent'\n | 'negative'\n | 'positive'\n | 'primary'\n | 'pay'\n | 'secondary'\n | 'danger'\n | 'link'\n | null\n | undefined;\n\ntype NewButtonType = 'button' | 'submit' | 'reset' | LegacyButtonType | undefined;\n\ntype CommonButtonProps = {\n href?: string;\n target?: string;\n ref?: React.Ref<HTMLButtonElement | HTMLAnchorElement>;\n};\n\nexport type ButtonProps =\n | (Omit<LegacyButtonProps, 'ref'> &\n CommonButtonProps & {\n priority?: LegacyButtonProps['priority'];\n type?: LegacyButtonType;\n htmlType?: string;\n v2?: false;\n })\n | (Omit<Omit<NewButtonProps, 'type'>, 'ref'> &\n CommonButtonProps & {\n priority?: NewButtonProps['priority'];\n type?: NewButtonType;\n v2: true;\n });\n\nconst mapProps = (props: LegacyButtonProps): NewButtonProps => {\n const { priority, size, type, as, ...newProps } = props;\n\n const priorityMapping: Record<string, Record<string, NewButtonProps['priority']>> = {\n accent: {\n primary: 'primary',\n secondary: 'tertiary',\n tertiary: 'minimal',\n },\n positive: {\n primary: 'primary',\n secondary: 'tertiary',\n tertiary: 'tertiary',\n },\n negative: {\n primary: 'primary',\n secondary: 'secondary',\n tertiary: 'secondary',\n },\n };\n\n const mappedPriority =\n type && priority ? priorityMapping[type]?.[priority] || priority : priority || undefined;\n const mappedSentiment = type === 'negative' ? 'negative' : undefined;\n\n const legacyButtonTypes: LegacyButtonType[] = [\n 'accent',\n 'negative',\n 'positive',\n 'primary',\n 'pay',\n 'secondary',\n 'danger',\n 'link',\n ];\n\n const resolveSize = () => {\n if (size) {\n return { xs: 'sm', sm: 'sm', md: 'md', lg: 'lg' }[size] || size;\n }\n\n return size;\n };\n\n return {\n ...newProps,\n size: resolveSize(),\n priority: mappedPriority,\n sentiment: mappedSentiment || ('sentiment' in props ? props.sentiment : null),\n type:\n type && !legacyButtonTypes.includes(type as LegacyButtonType) ? type : props.htmlType || null,\n v2: undefined,\n } as NewButtonProps;\n};\n\nconst Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>((props, ref) => {\n const { v2 = false, as, ...rest } = props;\n\n if (v2) {\n const mappedProps = mapProps(props as LegacyButtonProps);\n return (\n <NewButton\n {...mappedProps}\n ref={ref as React.Ref<HTMLButtonElement | HTMLAnchorElement>}\n as={as}\n />\n );\n }\n\n if (as === 'a') {\n return (\n <LegacyButton\n {...(rest as LegacyAnchorProps)}\n ref={ref as React.Ref<HTMLAnchorElement>}\n as=\"a\"\n />\n );\n }\n\n return (\n <LegacyButton\n {...(rest as LegacyButtonProps)}\n ref={ref as React.Ref<HTMLButtonElement>}\n as=\"button\"\n />\n );\n});\n\nButton.displayName = 'Button';\n\nexport default Button;\n"],"names":["mapProps","props","priority","size","type","as","newProps","priorityMapping","accent","primary","secondary","tertiary","positive","negative","mappedPriority","undefined","mappedSentiment","legacyButtonTypes","resolveSize","xs","sm","md","lg","sentiment","includes","htmlType","v2","Button","forwardRef","ref","rest","mappedProps","_jsx","NewButton","LegacyButton","displayName"],"mappings":";;;;;;;AA2CA,MAAMA,QAAQ,GAAIC,KAAwB,IAAoB;EAC5D,MAAM;IAAEC,QAAQ;IAAEC,IAAI;IAAEC,IAAI;IAAEC,EAAE;IAAE,GAAGC,QAAAA;AAAU,GAAA,GAAGL,KAAK,CAAA;AAEvD,EAAA,MAAMM,eAAe,GAA+D;AAClFC,IAAAA,MAAM,EAAE;AACNC,MAAAA,OAAO,EAAE,SAAS;AAClBC,MAAAA,SAAS,EAAE,UAAU;AACrBC,MAAAA,QAAQ,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CAACO,QAAQ,CAACpB,IAAwB,CAAC,GAAGA,IAAI,GAAGH,KAAK,CAACwB,QAAQ,IAAI,IAAI;AAC/FC,IAAAA,EAAE,EAAEX,SAAAA;GACa,CAAA;AACrB,CAAC,CAAA;AAEKY,MAAAA,MAAM,gBAAGC,gBAAU,CAAqD,CAAC3B,KAAK,EAAE4B,GAAG,KAAI;EAC3F,MAAM;AAAEH,IAAAA,EAAE,GAAG,KAAK;IAAErB,EAAE;IAAE,GAAGyB,IAAAA;AAAI,GAAE,GAAG7B,KAAK,CAAA;AAEzC,EAAA,IAAIyB,EAAE,EAAE;AACN,IAAA,MAAMK,WAAW,GAAG/B,QAAQ,CAACC,KAA0B,CAAC,CAAA;IACxD,oBACE+B,cAAA,CAACC,QAAS,EAAA;AAAA,MAAA,GACJF,WAAW;AACfF,MAAAA,GAAG,EAAEA,GAAwD;AAC7DxB,MAAAA,EAAE,EAAEA,EAAAA;AAAG,KACP,CAAA,CAAA;AAEN,GAAA;EAEA,IAAIA,EAAE,KAAK,GAAG,EAAE;IACd,oBACE2B,cAAA,CAACE,YAAY,EAAA;AAAA,MAAA,GACNJ,IAA0B;AAC/BD,MAAAA,GAAG,EAAEA,GAAoC;AACzCxB,MAAAA,EAAE,EAAC,GAAA;AAAG,KAAA,CACN,CAAA;AAEN,GAAA;EAEA,oBACE2B,cAAA,CAACE,YAAY,EAAA;AAAA,IAAA,GACNJ,IAA0B;AAC/BD,IAAAA,GAAG,EAAEA,GAAoC;AACzCxB,IAAAA,EAAE,EAAC,QAAA;AAAQ,GAAA,CACX,CAAA;AAEN,CAAC,EAAC;AAEFsB,MAAM,CAACQ,WAAW,GAAG,QAAQ;;;;"}
@@ -0,0 +1,84 @@
1
+ import { forwardRef } from 'react';
2
+ import LegacyButton from './LegacyButton.mjs';
3
+ import Button$1 from './Button.mjs';
4
+ import { jsx } from 'react/jsx-runtime';
5
+
6
+ const mapProps = props => {
7
+ const {
8
+ priority,
9
+ size,
10
+ type,
11
+ as,
12
+ ...newProps
13
+ } = props;
14
+ const priorityMapping = {
15
+ accent: {
16
+ primary: 'primary',
17
+ secondary: 'tertiary',
18
+ tertiary: 'minimal'
19
+ },
20
+ positive: {
21
+ primary: 'primary',
22
+ secondary: 'tertiary',
23
+ tertiary: 'tertiary'
24
+ },
25
+ negative: {
26
+ primary: 'primary',
27
+ secondary: 'secondary',
28
+ tertiary: 'secondary'
29
+ }
30
+ };
31
+ const mappedPriority = type && priority ? priorityMapping[type]?.[priority] || priority : priority || undefined;
32
+ const mappedSentiment = type === 'negative' ? 'negative' : undefined;
33
+ const legacyButtonTypes = ['accent', 'negative', 'positive', 'primary', 'pay', 'secondary', 'danger', 'link'];
34
+ const resolveSize = () => {
35
+ if (size) {
36
+ return {
37
+ xs: 'sm',
38
+ sm: 'sm',
39
+ md: 'md',
40
+ lg: 'lg'
41
+ }[size] || size;
42
+ }
43
+ return size;
44
+ };
45
+ return {
46
+ ...newProps,
47
+ size: resolveSize(),
48
+ priority: mappedPriority,
49
+ sentiment: mappedSentiment || ('sentiment' in props ? props.sentiment : null),
50
+ type: type && !legacyButtonTypes.includes(type) ? type : props.htmlType || null,
51
+ v2: undefined
52
+ };
53
+ };
54
+ const Button = /*#__PURE__*/forwardRef((props, ref) => {
55
+ const {
56
+ v2 = false,
57
+ as,
58
+ ...rest
59
+ } = props;
60
+ if (v2) {
61
+ const mappedProps = mapProps(props);
62
+ return /*#__PURE__*/jsx(Button$1, {
63
+ ...mappedProps,
64
+ ref: ref,
65
+ as: as
66
+ });
67
+ }
68
+ if (as === 'a') {
69
+ return /*#__PURE__*/jsx(LegacyButton, {
70
+ ...rest,
71
+ ref: ref,
72
+ as: "a"
73
+ });
74
+ }
75
+ return /*#__PURE__*/jsx(LegacyButton, {
76
+ ...rest,
77
+ ref: ref,
78
+ as: "button"
79
+ });
80
+ });
81
+ Button.displayName = 'Button';
82
+
83
+ export { Button as default };
84
+ //# sourceMappingURL=Button.resolver.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.resolver.mjs","sources":["../../src/button/Button.resolver.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport LegacyButton, {\n AnchorProps as LegacyAnchorProps,\n ButtonProps as LegacyButtonProps,\n} from './LegacyButton';\nimport { ButtonProps as NewButtonProps } from './Button.types';\nimport NewButton from './Button';\n\ntype LegacyButtonType =\n | 'accent'\n | 'negative'\n | 'positive'\n | 'primary'\n | 'pay'\n | 'secondary'\n | 'danger'\n | 'link'\n | null\n | undefined;\n\ntype NewButtonType = 'button' | 'submit' | 'reset' | LegacyButtonType | undefined;\n\ntype CommonButtonProps = {\n href?: string;\n target?: string;\n ref?: React.Ref<HTMLButtonElement | HTMLAnchorElement>;\n};\n\nexport type ButtonProps =\n | (Omit<LegacyButtonProps, 'ref'> &\n CommonButtonProps & {\n priority?: LegacyButtonProps['priority'];\n type?: LegacyButtonType;\n htmlType?: string;\n v2?: false;\n })\n | (Omit<Omit<NewButtonProps, 'type'>, 'ref'> &\n CommonButtonProps & {\n priority?: NewButtonProps['priority'];\n type?: NewButtonType;\n v2: true;\n });\n\nconst mapProps = (props: LegacyButtonProps): NewButtonProps => {\n const { priority, size, type, as, ...newProps } = props;\n\n const priorityMapping: Record<string, Record<string, NewButtonProps['priority']>> = {\n accent: {\n primary: 'primary',\n secondary: 'tertiary',\n tertiary: 'minimal',\n },\n positive: {\n primary: 'primary',\n secondary: 'tertiary',\n tertiary: 'tertiary',\n },\n negative: {\n primary: 'primary',\n secondary: 'secondary',\n tertiary: 'secondary',\n },\n };\n\n const mappedPriority =\n type && priority ? priorityMapping[type]?.[priority] || priority : priority || undefined;\n const mappedSentiment = type === 'negative' ? 'negative' : undefined;\n\n const legacyButtonTypes: LegacyButtonType[] = [\n 'accent',\n 'negative',\n 'positive',\n 'primary',\n 'pay',\n 'secondary',\n 'danger',\n 'link',\n ];\n\n const resolveSize = () => {\n if (size) {\n return { xs: 'sm', sm: 'sm', md: 'md', lg: 'lg' }[size] || size;\n }\n\n return size;\n };\n\n return {\n ...newProps,\n size: resolveSize(),\n priority: mappedPriority,\n sentiment: mappedSentiment || ('sentiment' in props ? props.sentiment : null),\n type:\n type && !legacyButtonTypes.includes(type as LegacyButtonType) ? type : props.htmlType || null,\n v2: undefined,\n } as NewButtonProps;\n};\n\nconst Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>((props, ref) => {\n const { v2 = false, as, ...rest } = props;\n\n if (v2) {\n const mappedProps = mapProps(props as LegacyButtonProps);\n return (\n <NewButton\n {...mappedProps}\n ref={ref as React.Ref<HTMLButtonElement | HTMLAnchorElement>}\n as={as}\n />\n );\n }\n\n if (as === 'a') {\n return (\n <LegacyButton\n {...(rest as LegacyAnchorProps)}\n ref={ref as React.Ref<HTMLAnchorElement>}\n as=\"a\"\n />\n );\n }\n\n return (\n <LegacyButton\n {...(rest as LegacyButtonProps)}\n ref={ref as React.Ref<HTMLButtonElement>}\n as=\"button\"\n />\n );\n});\n\nButton.displayName = 'Button';\n\nexport default Button;\n"],"names":["mapProps","props","priority","size","type","as","newProps","priorityMapping","accent","primary","secondary","tertiary","positive","negative","mappedPriority","undefined","mappedSentiment","legacyButtonTypes","resolveSize","xs","sm","md","lg","sentiment","includes","htmlType","v2","Button","forwardRef","ref","rest","mappedProps","_jsx","NewButton","LegacyButton","displayName"],"mappings":";;;;;AA2CA,MAAMA,QAAQ,GAAIC,KAAwB,IAAoB;EAC5D,MAAM;IAAEC,QAAQ;IAAEC,IAAI;IAAEC,IAAI;IAAEC,EAAE;IAAE,GAAGC,QAAAA;AAAU,GAAA,GAAGL,KAAK,CAAA;AAEvD,EAAA,MAAMM,eAAe,GAA+D;AAClFC,IAAAA,MAAM,EAAE;AACNC,MAAAA,OAAO,EAAE,SAAS;AAClBC,MAAAA,SAAS,EAAE,UAAU;AACrBC,MAAAA,QAAQ,EAAE,SAAA;KACX;AACDC,IAAAA,QAAQ,EAAE;AACRH,MAAAA,OAAO,EAAE,SAAS;AAClBC,MAAAA,SAAS,EAA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AA,EAAE,EAAEX,SAAAA;GACa,CAAA;AACrB,CAAC,CAAA;AAEKY,MAAAA,MAAM,gBAAGC,UAAU,CAAqD,CAAC3B,KAAK,EAAE4B,GAAG,KAAI;EAC3F,MAAM;AAAEH,IAAAA,EAAE,GAAG,KAAK;IAAErB,EAAE;IAAE,GAAGyB,IAAAA;AAAI,GAAE,GAAG7B,KAAK,CAAA;AAEzC,EAAA,IAAIyB,EAAE,EAAE;AACN,IAAA,MAAMK,WAAW,GAAG/B,QAAQ,CAACC,KAA0B,CAAC,CAAA;IACxD,oBACE+B,GAAA,CAACC,QAAS,EAAA;AAAA,MAAA,GACJF,WAAW;AACfF,MAAAA,GAAG,EAAEA,GAAwD;AAC7DxB,MAAAA,EAAE,EAAEA,EAAAA;AAAG,KACP,CAAA,CAAA;AAEN,GAAA;EAEA,IAAIA,EAAE,KAAK,GAAG,EAAE;IACd,oBACE2B,GAAA,CAACE,YAAY,EAAA;AAAA,MAAA,GACNJ,IAA0B;AAC/BD,MAAAA,GAAG,EAAEA,GAAoC;AACzCxB,MAAAA,EAAE,EAAC,GAAA;AAAG,KAAA,CACN,CAAA;AAEN,GAAA;EAEA,oBACE2B,GAAA,CAACE,YAAY,EAAA;AAAA,IAAA,GACNJ,IAA0B;AAC/BD,IAAAA,GAAG,EAAEA,GAAoC;AACzCxB,IAAAA,EAAE,EAAC,QAAA;AAAQ,GAAA,CACX,CAAA;AAEN,CAAC,EAAC;AAEFsB,MAAM,CAACQ,WAAW,GAAG,QAAQ;;;;"}
@@ -0,0 +1,114 @@
1
+ 'use strict';
2
+
3
+ var clsx = require('clsx');
4
+ var React = require('react');
5
+ var reactIntl = require('react-intl');
6
+ require('../common/theme.js');
7
+ require('../common/direction.js');
8
+ var control = require('../common/propsValues/control.js');
9
+ require('../common/propsValues/breakpoint.js');
10
+ var size = require('../common/propsValues/size.js');
11
+ require('../common/propsValues/typography.js');
12
+ require('../common/propsValues/width.js');
13
+ require('../common/propsValues/type.js');
14
+ require('../common/propsValues/dateMode.js');
15
+ require('../common/propsValues/monthFormat.js');
16
+ require('../common/propsValues/position.js');
17
+ require('../common/propsValues/layouts.js');
18
+ require('../common/propsValues/status.js');
19
+ require('../common/propsValues/sentiment.js');
20
+ require('../common/propsValues/profileType.js');
21
+ require('../common/propsValues/variant.js');
22
+ require('../common/propsValues/scroll.js');
23
+ require('../common/propsValues/markdownNodeType.js');
24
+ require('../common/fileType.js');
25
+ require('@transferwise/icons');
26
+ require('../common/closeButton/CloseButton.messages.js');
27
+ var jsxRuntime = require('react/jsx-runtime');
28
+ var ProcessIndicator = require('../processIndicator/ProcessIndicator.js');
29
+ var Button_messages = require('../i18n/commonMessages/Button.messages.js');
30
+ var classMap = require('./classMap.js');
31
+ var legacyUtils = require('./legacyUtils/legacyUtils.js');
32
+
33
+ const LegacyButton = /*#__PURE__*/React.forwardRef(({
34
+ as: component = 'button',
35
+ block = false,
36
+ children,
37
+ className,
38
+ disabled,
39
+ loading = false,
40
+ priority = control.Priority.PRIMARY,
41
+ size: size$1 = size.Size.MEDIUM,
42
+ type = control.ControlType.ACCENT,
43
+ onClick,
44
+ ...rest
45
+ }, ref) => {
46
+ const intl = reactIntl.useIntl();
47
+ legacyUtils.logDeprecationNotices({
48
+ size: size$1,
49
+ type
50
+ });
51
+ const newType = legacyUtils.establishNewType(type);
52
+ const newPriority = legacyUtils.establishNewPriority(priority, type);
53
+ const classes = clsx.clsx(`btn btn-${size$1}`, `np-btn np-btn-${size$1}`, {
54
+ 'btn-loading': loading,
55
+ 'btn-block np-btn-block': block,
56
+ disabled
57
+ },
58
+ // @ts-expect-error fix when refactor `typeClassMap` to TypeScript
59
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
60
+ classMap.typeClassMap[newType],
61
+ // @ts-expect-error fix when refactor `typeClassMap` to TypeScript
62
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
63
+ classMap.priorityClassMap[newPriority], className);
64
+ function processIndicatorSize() {
65
+ return ['sm', 'xs'].includes(size$1) ? 'xxs' : 'xs';
66
+ }
67
+ const Element = component ?? 'button';
68
+ let props;
69
+ if (Element === 'button') {
70
+ const {
71
+ htmlType = 'button',
72
+ ...restProps
73
+ } = rest;
74
+ props = {
75
+ ...restProps,
76
+ disabled,
77
+ 'aria-disabled': loading,
78
+ type: htmlType
79
+ };
80
+ } else {
81
+ props = {
82
+ ...rest,
83
+ 'aria-disabled': loading
84
+ };
85
+ }
86
+ /**
87
+ * Ensures that the button cannot be activated in loading or disabled mode,
88
+ * when `aria-disabled` might be used over the `disabled` HTML attribute
89
+ */
90
+ const handleClick = handler => event => {
91
+ if (disabled || loading) {
92
+ event.preventDefault();
93
+ } else if (typeof handler === 'function') {
94
+ handler(event);
95
+ }
96
+ };
97
+ return /*#__PURE__*/jsxRuntime.jsxs(Element, {
98
+ ref: ref,
99
+ className: classes,
100
+ onClick: handleClick(onClick),
101
+ ...props,
102
+ "aria-live": loading ? 'polite' : 'off',
103
+ "aria-busy": loading,
104
+ "aria-label": loading ? intl.formatMessage(Button_messages.loadingAriaLabel) : rest['aria-label'],
105
+ children: [children, loading && /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator, {
106
+ size: processIndicatorSize(),
107
+ className: "btn-loader",
108
+ "data-testid": "ButtonProgressIndicator"
109
+ })]
110
+ });
111
+ });
112
+
113
+ module.exports = LegacyButton;
114
+ //# sourceMappingURL=LegacyButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LegacyButton.js","sources":["../../src/button/LegacyButton.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { ElementType, forwardRef, MouseEvent } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport {\n Size,\n ControlType,\n Priority,\n ControlTypeAccent,\n ControlTypeNegative,\n ControlTypePositive,\n PriorityPrimary,\n PrioritySecondary,\n PriorityTertiary,\n SizeExtraSmall,\n SizeSmall,\n SizeMedium,\n SizeLarge,\n} from '../common';\nimport ProcessIndicator from '../processIndicator';\n\nimport messages from '../i18n/commonMessages/Button.messages';\nimport { typeClassMap, priorityClassMap } from './classMap';\nimport { establishNewPriority, establishNewType, logDeprecationNotices } from './legacyUtils';\n\n/** @deprecated */\ntype DeprecatedTypes = 'primary' | 'pay' | 'secondary' | 'danger' | 'link';\n\n/** @deprecated */\ntype DeprecatedSizes = SizeExtraSmall;\n\ntype CommonProps = {\n block?: boolean;\n disabled?: boolean;\n loading?: boolean;\n /** @deprecated */\n type?: ControlTypeAccent | ControlTypeNegative | ControlTypePositive | DeprecatedTypes | null;\n priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary | null;\n size?: SizeSmall | SizeMedium | SizeLarge | DeprecatedSizes;\n htmlType?: 'submit' | 'reset' | 'button';\n};\n\nexport type ButtonProps = CommonProps &\n Omit<React.ComponentPropsWithRef<'button'>, 'type'> & {\n as?: 'button';\n };\n\nexport type AnchorProps = CommonProps &\n Omit<React.ComponentPropsWithRef<'a'>, 'type'> & {\n as?: 'a';\n href?: string;\n };\n\nexport type LegacyButtonProps = ButtonProps | AnchorProps;\n\nexport type ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;\n\n/**\n * @deprecated make sure you use new Button component via `<Button v2 .. />` and new props\n */\nconst LegacyButton = forwardRef<ButtonReferenceType, LegacyButtonProps>(\n (\n {\n as: component = 'button',\n block = false,\n children,\n className,\n disabled,\n loading = false,\n priority = Priority.PRIMARY,\n size = Size.MEDIUM,\n type = ControlType.ACCENT,\n onClick,\n ...rest\n }: LegacyButtonProps,\n ref,\n ) => {\n const intl = useIntl();\n\n logDeprecationNotices({ size, type });\n\n const newType = establishNewType(type);\n const newPriority = establishNewPriority(priority, type);\n\n const classes = clsx(\n `btn btn-${size}`,\n `np-btn np-btn-${size}`,\n {\n 'btn-loading': loading,\n 'btn-block np-btn-block': block,\n disabled,\n },\n // @ts-expect-error fix when refactor `typeClassMap` to TypeScript\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n typeClassMap[newType],\n // @ts-expect-error fix when refactor `typeClassMap` to TypeScript\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n priorityClassMap[newPriority],\n className,\n );\n\n function processIndicatorSize() {\n return ['sm', 'xs'].includes(size) ? 'xxs' : 'xs';\n }\n\n const Element = (component as ElementType) ?? 'button';\n let props;\n\n if (Element === 'button') {\n const { htmlType = 'button', ...restProps } = rest as ButtonProps;\n props = {\n ...restProps,\n disabled,\n 'aria-disabled': loading,\n type: htmlType,\n };\n } else {\n props = {\n ...rest,\n 'aria-disabled': loading,\n } as AnchorProps;\n }\n\n /**\n * Ensures that the button cannot be activated in loading or disabled mode,\n * when `aria-disabled` might be used over the `disabled` HTML attribute\n */\n const handleClick =\n (handler: LegacyButtonProps['onClick']) =>\n (event: MouseEvent<HTMLButtonElement> & MouseEvent<HTMLAnchorElement>) => {\n if (disabled || loading) {\n event.preventDefault();\n } else if (typeof handler === 'function') {\n handler(event);\n }\n };\n\n return (\n <Element\n ref={ref as React.Ref<ButtonReferenceType>}\n className={classes}\n onClick={handleClick(onClick)}\n {...props}\n aria-live={loading ? 'polite' : 'off'}\n aria-busy={loading}\n aria-label={loading ? intl.formatMessage(messages.loadingAriaLabel) : rest['aria-label']}\n >\n {children}\n {loading && (\n <ProcessIndicator\n size={processIndicatorSize()}\n className=\"btn-loader\"\n data-testid=\"ButtonProgressIndicator\"\n />\n )}\n </Element>\n );\n },\n);\n\nexport default LegacyButton;\n"],"names":["LegacyButton","forwardRef","as","component","block","children","className","disabled","loading","priority","Priority","PRIMARY","size","Size","MEDIUM","type","ControlType","ACCENT","onClick","rest","ref","intl","useIntl","logDeprecationNotices","newType","establishNewType","newPriority","establishNewPriority","classes","clsx","typeClassMap","priorityClassMap","processIndicatorSize","includes","Element","props","htmlType","restProps","handleClick","handler","event","preventDefault","_jsxs","formatMessage","messages","loadingAriaLabel","_jsx","ProcessIndicator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,MAAMA,YAAY,gBAAGC,gBAAU,CAC7B,CACE;E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,CAAA;AAAA,GACM,CAAC,CAAA;AAEd,CAAC;;;;"}
@@ -0,0 +1,112 @@
1
+ import { clsx } from 'clsx';
2
+ import { forwardRef } from 'react';
3
+ import { useIntl } from 'react-intl';
4
+ import '../common/theme.mjs';
5
+ import '../common/direction.mjs';
6
+ import { Priority, ControlType } from '../common/propsValues/control.mjs';
7
+ import '../common/propsValues/breakpoint.mjs';
8
+ import { Size } from '../common/propsValues/size.mjs';
9
+ import '../common/propsValues/typography.mjs';
10
+ import '../common/propsValues/width.mjs';
11
+ import '../common/propsValues/type.mjs';
12
+ import '../common/propsValues/dateMode.mjs';
13
+ import '../common/propsValues/monthFormat.mjs';
14
+ import '../common/propsValues/position.mjs';
15
+ import '../common/propsValues/layouts.mjs';
16
+ import '../common/propsValues/status.mjs';
17
+ import '../common/propsValues/sentiment.mjs';
18
+ import '../common/propsValues/profileType.mjs';
19
+ import '../common/propsValues/variant.mjs';
20
+ import '../common/propsValues/scroll.mjs';
21
+ import '../common/propsValues/markdownNodeType.mjs';
22
+ import '../common/fileType.mjs';
23
+ import '@transferwise/icons';
24
+ import '../common/closeButton/CloseButton.messages.mjs';
25
+ import { jsxs, jsx } from 'react/jsx-runtime';
26
+ import ProcessIndicator from '../processIndicator/ProcessIndicator.mjs';
27
+ import messages from '../i18n/commonMessages/Button.messages.mjs';
28
+ import { typeClassMap, priorityClassMap } from './classMap.mjs';
29
+ import { logDeprecationNotices, establishNewType, establishNewPriority } from './legacyUtils/legacyUtils.mjs';
30
+
31
+ const LegacyButton = /*#__PURE__*/forwardRef(({
32
+ as: component = 'button',
33
+ block = false,
34
+ children,
35
+ className,
36
+ disabled,
37
+ loading = false,
38
+ priority = Priority.PRIMARY,
39
+ size = Size.MEDIUM,
40
+ type = ControlType.ACCENT,
41
+ onClick,
42
+ ...rest
43
+ }, ref) => {
44
+ const intl = useIntl();
45
+ logDeprecationNotices({
46
+ size,
47
+ type
48
+ });
49
+ const newType = establishNewType(type);
50
+ const newPriority = establishNewPriority(priority, type);
51
+ const classes = clsx(`btn btn-${size}`, `np-btn np-btn-${size}`, {
52
+ 'btn-loading': loading,
53
+ 'btn-block np-btn-block': block,
54
+ disabled
55
+ },
56
+ // @ts-expect-error fix when refactor `typeClassMap` to TypeScript
57
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
58
+ typeClassMap[newType],
59
+ // @ts-expect-error fix when refactor `typeClassMap` to TypeScript
60
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
61
+ priorityClassMap[newPriority], className);
62
+ function processIndicatorSize() {
63
+ return ['sm', 'xs'].includes(size) ? 'xxs' : 'xs';
64
+ }
65
+ const Element = component ?? 'button';
66
+ let props;
67
+ if (Element === 'button') {
68
+ const {
69
+ htmlType = 'button',
70
+ ...restProps
71
+ } = rest;
72
+ props = {
73
+ ...restProps,
74
+ disabled,
75
+ 'aria-disabled': loading,
76
+ type: htmlType
77
+ };
78
+ } else {
79
+ props = {
80
+ ...rest,
81
+ 'aria-disabled': loading
82
+ };
83
+ }
84
+ /**
85
+ * Ensures that the button cannot be activated in loading or disabled mode,
86
+ * when `aria-disabled` might be used over the `disabled` HTML attribute
87
+ */
88
+ const handleClick = handler => event => {
89
+ if (disabled || loading) {
90
+ event.preventDefault();
91
+ } else if (typeof handler === 'function') {
92
+ handler(event);
93
+ }
94
+ };
95
+ return /*#__PURE__*/jsxs(Element, {
96
+ ref: ref,
97
+ className: classes,
98
+ onClick: handleClick(onClick),
99
+ ...props,
100
+ "aria-live": loading ? 'polite' : 'off',
101
+ "aria-busy": loading,
102
+ "aria-label": loading ? intl.formatMessage(messages.loadingAriaLabel) : rest['aria-label'],
103
+ children: [children, loading && /*#__PURE__*/jsx(ProcessIndicator, {
104
+ size: processIndicatorSize(),
105
+ className: "btn-loader",
106
+ "data-testid": "ButtonProgressIndicator"
107
+ })]
108
+ });
109
+ });
110
+
111
+ export { LegacyButton as default };
112
+ //# sourceMappingURL=LegacyButton.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LegacyButton.mjs","sources":["../../src/button/LegacyButton.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { ElementType, forwardRef, MouseEvent } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport {\n Size,\n ControlType,\n Priority,\n ControlTypeAccent,\n ControlTypeNegative,\n ControlTypePositive,\n PriorityPrimary,\n PrioritySecondary,\n PriorityTertiary,\n SizeExtraSmall,\n SizeSmall,\n SizeMedium,\n SizeLarge,\n} from '../common';\nimport ProcessIndicator from '../processIndicator';\n\nimport messages from '../i18n/commonMessages/Button.messages';\nimport { typeClassMap, priorityClassMap } from './classMap';\nimport { establishNewPriority, establishNewType, logDeprecationNotices } from './legacyUtils';\n\n/** @deprecated */\ntype DeprecatedTypes = 'primary' | 'pay' | 'secondary' | 'danger' | 'link';\n\n/** @deprecated */\ntype DeprecatedSizes = SizeExtraSmall;\n\ntype CommonProps = {\n block?: boolean;\n disabled?: boolean;\n loading?: boolean;\n /** @deprecated */\n type?: ControlTypeAccent | ControlTypeNegative | ControlTypePositive | DeprecatedTypes | null;\n priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary | null;\n size?: SizeSmall | SizeMedium | SizeLarge | DeprecatedSizes;\n htmlType?: 'submit' | 'reset' | 'button';\n};\n\nexport type ButtonProps = CommonProps &\n Omit<React.ComponentPropsWithRef<'button'>, 'type'> & {\n as?: 'button';\n };\n\nexport type AnchorProps = CommonProps &\n Omit<React.ComponentPropsWithRef<'a'>, 'type'> & {\n as?: 'a';\n href?: string;\n };\n\nexport type LegacyButtonProps = ButtonProps | AnchorProps;\n\nexport type ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;\n\n/**\n * @deprecated make sure you use new Button component via `<Button v2 .. />` and new props\n */\nconst LegacyButton = forwardRef<ButtonReferenceType, LegacyButtonProps>(\n (\n {\n as: component = 'button',\n block = false,\n children,\n className,\n disabled,\n loading = false,\n priority = Priority.PRIMARY,\n size = Size.MEDIUM,\n type = ControlType.ACCENT,\n onClick,\n ...rest\n }: LegacyButtonProps,\n ref,\n ) => {\n const intl = useIntl();\n\n logDeprecationNotices({ size, type });\n\n const newType = establishNewType(type);\n const newPriority = establishNewPriority(priority, type);\n\n const classes = clsx(\n `btn btn-${size}`,\n `np-btn np-btn-${size}`,\n {\n 'btn-loading': loading,\n 'btn-block np-btn-block': block,\n disabled,\n },\n // @ts-expect-error fix when refactor `typeClassMap` to TypeScript\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n typeClassMap[newType],\n // @ts-expect-error fix when refactor `typeClassMap` to TypeScript\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n priorityClassMap[newPriority],\n className,\n );\n\n function processIndicatorSize() {\n return ['sm', 'xs'].includes(size) ? 'xxs' : 'xs';\n }\n\n const Element = (component as ElementType) ?? 'button';\n let props;\n\n if (Element === 'button') {\n const { htmlType = 'button', ...restProps } = rest as ButtonProps;\n props = {\n ...restProps,\n disabled,\n 'aria-disabled': loading,\n type: htmlType,\n };\n } else {\n props = {\n ...rest,\n 'aria-disabled': loading,\n } as AnchorProps;\n }\n\n /**\n * Ensures that the button cannot be activated in loading or disabled mode,\n * when `aria-disabled` might be used over the `disabled` HTML attribute\n */\n const handleClick =\n (handler: LegacyButtonProps['onClick']) =>\n (event: MouseEvent<HTMLButtonElement> & MouseEvent<HTMLAnchorElement>) => {\n if (disabled || loading) {\n event.preventDefault();\n } else if (typeof handler === 'function') {\n handler(event);\n }\n };\n\n return (\n <Element\n ref={ref as React.Ref<ButtonReferenceType>}\n className={classes}\n onClick={handleClick(onClick)}\n {...props}\n aria-live={loading ? 'polite' : 'off'}\n aria-busy={loading}\n aria-label={loading ? intl.formatMessage(messages.loadingAriaLabel) : rest['aria-label']}\n >\n {children}\n {loading && (\n <ProcessIndicator\n size={processIndicatorSize()}\n className=\"btn-loader\"\n data-testid=\"ButtonProgressIndicator\"\n />\n )}\n </Element>\n );\n },\n);\n\nexport default LegacyButton;\n"],"names":["LegacyButton","forwardRef","as","component","block","children","className","disabled","loading","priority","Priority","PRIMARY","size","Size","MEDIUM","type","ControlType","ACCENT","onClick","rest","ref","intl","useIntl","logDeprecationNotices","newType","establishNewType","newPriority","establishNewPriority","classes","clsx","typeClassMap","priorityClassMap","processIndicatorSize","includes","Element","props","htmlType","restProps","handleClick","handler","event","preventDefault","_jsxs","formatMessage","messages","loadingAriaLabel","_jsx","ProcessIndicator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,MAAMA,YAAY,gBAAGC,UAAU,CAC7B,CACE;EACEC,EAAE,EAAEC,SAAS,GAAG,QAAQ;AACxBC,EAAAA,KAAK,GAAG,KAAK;EACbC,QAAQ;EACRC,SAAS;EACTC,QAAQ;AACRC,EAAAA,OAAO,GAAG,KAAK;EACfC,QAAQ,GAAGC,QAAQ,CAACC,OAAO;EAC3BC,IAAI,GAAGC,IAAI,CAACC,MAAM;EAClBC,IAAI,GAAGC,WAAW,CAACC,MAAM;EACzBC,OAAO;EACP,GAAGC,IAAAA;AACe,CAAA,EACpBC,GAAG,KACD;AACF,EAAA,MAAMC,IAAI,GAAGC,OAAO,EAAE,CAAA;AAEtBC,EAAAA,qBAAqB,CAAC;IAAEX,IAAI;AAAEG,IAAAA,IAAAA;AAAI,GAAE,CAAC,CAAA;AAErC,EAAA,MAAMS,OAAO,GAAGC,gBAAgB,CAACV,IAAI,CAAC,CAAA;AACtC,EAAA,MAAMW,WAAW,GAAGC,oBAAoB,CAAClB,QAAQ,EAAEM,IAAI,CAAC,CAAA;EAExD,MAAMa,OAAO,GAAGC,IAAI,CAClB,CAAA,QAAA,EAAWjB,IAAI,CAAA,CAAE,EACjB,CAAA,cAAA,EAAiBA,IAAI,CAAA,CAAE,EACvB;AACE,IAAA,aAAa,EAAEJ,OAAO;AACtB,IAAA,wBAAwB,EAAEJ,KAAK;AAC/BG,IAAAA,QAAAA;GACD;AACD;AACA;EACAuB,YAAY,CAACN,OAAO,CAAC;AACrB;AACA;AACAO,EAAAA,gBAAg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AAWA,OAAQ;AACnB,IAAA,YAAA,EAAYA,OAAO,GAAGa,IAAI,CAACsB,aAAa,CAACC,QAAQ,CAACC,gBAAgB,CAAC,GAAG1B,IAAI,CAAC,YAAY,CAAE;AAAAd,IAAAA,QAAA,GAExFA,QAAQ,EACRG,OAAO,iBACNsC,GAAA,CAACC,gBAAgB,EAAA;MACfnC,IAAI,EAAEoB,oBAAoB,EAAG;AAC7B1B,MAAAA,SAAS,EAAC,YAAY;MACtB,aAAY,EAAA,yBAAA;AAAyB,KACrC,CACH,CAAA;AAAA,GACM,CAAC,CAAA;AAEd,CAAC;;;;"}
@@ -6,7 +6,7 @@ var clsx = require('clsx');
6
6
  var avatarTypes = require('../avatar/avatarTypes.js');
7
7
  var Avatar = require('../avatar/Avatar.js');
8
8
  var Body = require('../body/Body.js');
9
- var Button = require('../button/Button.js');
9
+ var Button_resolver = require('../button/Button.resolver.js');
10
10
  require('../common/theme.js');
11
11
  require('../common/direction.js');
12
12
  var control = require('../common/propsValues/control.js');
@@ -69,7 +69,7 @@ function CriticalCommsBanner({
69
69
  })]
70
70
  }), action ? /*#__PURE__*/jsxRuntime.jsx("div", {
71
71
  className: "critical-comms--cta",
72
- children: /*#__PURE__*/jsxRuntime.jsx(Button, {
72
+ children: /*#__PURE__*/jsxRuntime.jsx(Button_resolver, {
73
73
  block: isModern,
74
74
  size: size.Size.SMALL,
75
75
  type: control.ControlType.NEGATIVE,
@@ -1 +1 @@
1
- {"version":3,"file":"CriticalCommsBanner.js","sources":["../../src/criticalBanner/CriticalCommsBanner.tsx"],"sourcesContent":["import { Alert as DangerIcon, AlertCircleFill } from '@transferwise/icons';\nimport { useTheme } from '@wise/components-theming';\nimport { clsx } from 'clsx';\n\nimport Avatar, { AvatarType } from '../avatar';\nimport Body from '../body';\nimport Button from '../button';\nimport { ControlType, Priority, Size, Typography } from '../common';\nimport Title from '../title';\n\nexport type CriticalCommsBannerProps = {\n title: string;\n subtitle?: string;\n action?: {\n label: string;\n href: string;\n };\n className?: string;\n};\n\nfunction CriticalCommsBanner({ title, subtitle, action, className }: CriticalCommsBannerProps) {\n const { isModern } = useTheme();\n return (\n <div className={clsx('critical-comms', className)}>\n <div className=\"critical-comms-body\">\n <Avatar\n size={Size.MEDIUM}\n type={AvatarType.ICON}\n className={clsx(isModern ? 'm-r-2' : 'm-r-1')}\n backgroundColor={\n isModern ? 'var(--color-sentiment-negative)' : 'var(--color-background-negative)'\n }\n >\n {isModern ? <AlertCircleFill /> : <DangerIcon size={24} />}\n </Avatar>\n <div className=\"critical-comms-content d-flex align-items-center flex-grow-1\">\n <div className={clsx('flex-grow-1', { 'p-x-2': !isModern })}>\n <Title\n type={isModern ? Typography.TITLE_BODY : Typography.TITLE_GROUP}\n className=\"critical-comms--title\"\n >\n {title}\n </Title>\n <Body className=\"critical-comms--subtitle\">{subtitle}</Body>\n </div>\n {action ? (\n <div className=\"critical-comms--cta\">\n <Button\n block={isModern}\n size={Size.SMALL}\n type={ControlType.NEGATIVE}\n priority={isModern ? Priority.SECONDARY : Priority.PRIMARY}\n className=\"cta-btn\"\n onClick={() => {\n if (action) {\n window.location.href = action.href;\n }\n }}\n >\n {action.label}\n </Button>\n </div>\n ) : null}\n </div>\n </div>\n </div>\n );\n}\n\nexport default CriticalCommsBanner;\n"],"names":["CriticalCommsBanner","title","subtitle","action","className","isModern","useTheme","_jsx","clsx","children","_jsxs","Avatar","size","Size","MEDIUM","type","AvatarType","ICON","backgroundColor","AlertCircleFill","DangerIcon","Title","Typography","TITLE_BODY","TITLE_GROUP","Body","Button","block","SMALL","ControlType","NEGATIVE","priority","Priority","SECONDARY","PRIMARY","onClick","window","location","href","label"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,SAASA,mBAAmBA,CAAC;EAAEC,KAAK;EAAEC,QAAQ;EAAEC,MAAM;AAAEC,EAAAA,SAAAA;AAAqC,CAAA,EAAA;EAC3F,MAAM;AAAEC,IAAAA,QAAAA;GAAU,GAAGC,0BA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,EAACC,MAAM,gBACLI,cAAA,CAAA,KAAA,EAAA;AAAKH,UAAAA,SAAS,EAAC,qBAAqB;UAAAK,QAAA,eAClCF,cAAA,CAACmB,MAAM,EAAA;AACLC,YAAAA,KAAK,EAAEtB,QAAS;YAChBO,IAAI,EAAEC,SAAI,CAACe,KAAM;YACjBb,IAAI,EAAEc,mBAAW,CAACC,QAAS;YAC3BC,QAAQ,EAAE1B,QAAQ,GAAG2B,gBAAQ,CAACC,SAAS,GAAGD,gBAAQ,CAACE,OAAQ;AAC3D9B,YAAAA,SAAS,EAAC,SAAS;YACnB+B,OAAO,EAAEA,MAAK;AACZ,cAAA,IAAIhC,MAAM,EAAE;AACViC,gBAAAA,MAAM,CAACC,QAAQ,CAACC,IAAI,GAAGnC,MAAM,CAACmC,IAAI,CAAA;AACpC,eAAA;aACA;YAAA7B,QAAA,EAEDN,MAAM,CAACoC,KAAAA;WACF,CAAA;SACL,CAAC,GACJ,IAAI,CAAA;AAAA,OACL,CACP,CAAA;KAAK,CAAA;AACP,GAAK,CAAC,CAAA;AAEV;;;;"}
1
+ {"version":3,"file":"CriticalCommsBanner.js","sources":["../../src/criticalBanner/CriticalCommsBanner.tsx"],"sourcesContent":["import { Alert as DangerIcon, AlertCircleFill } from '@transferwise/icons';\nimport { useTheme } from '@wise/components-theming';\nimport { clsx } from 'clsx';\n\nimport Avatar, { AvatarType } from '../avatar';\nimport Body from '../body';\nimport Button from '../button';\nimport { ControlType, Priority, Size, Typography } from '../common';\nimport Title from '../title';\n\nexport type CriticalCommsBannerProps = {\n title: string;\n subtitle?: string;\n action?: {\n label: string;\n href: string;\n };\n className?: string;\n};\n\nfunction CriticalCommsBanner({ title, subtitle, action, className }: CriticalCommsBannerProps) {\n const { isModern } = useTheme();\n return (\n <div className={clsx('critical-comms', className)}>\n <div className=\"critical-comms-body\">\n <Avatar\n size={Size.MEDIUM}\n type={AvatarType.ICON}\n className={clsx(isModern ? 'm-r-2' : 'm-r-1')}\n backgroundColor={\n isModern ? 'var(--color-sentiment-negative)' : 'var(--color-background-negative)'\n }\n >\n {isModern ? <AlertCircleFill /> : <DangerIcon size={24} />}\n </Avatar>\n <div className=\"critical-comms-content d-flex align-items-center flex-grow-1\">\n <div className={clsx('flex-grow-1', { 'p-x-2': !isModern })}>\n <Title\n type={isModern ? Typography.TITLE_BODY : Typography.TITLE_GROUP}\n className=\"critical-comms--title\"\n >\n {title}\n </Title>\n <Body className=\"critical-comms--subtitle\">{subtitle}</Body>\n </div>\n {action ? (\n <div className=\"critical-comms--cta\">\n <Button\n block={isModern}\n size={Size.SMALL}\n type={ControlType.NEGATIVE}\n priority={isModern ? Priority.SECONDARY : Priority.PRIMARY}\n className=\"cta-btn\"\n onClick={() => {\n if (action) {\n window.location.href = action.href;\n }\n }}\n >\n {action.label}\n </Button>\n </div>\n ) : null}\n </div>\n </div>\n </div>\n );\n}\n\nexport default CriticalCommsBanner;\n"],"names":["CriticalCommsBanner","title","subtitle","action","className","isModern","useTheme","_jsx","clsx","children","_jsxs","Avatar","size","Size","MEDIUM","type","AvatarType","ICON","backgroundColor","AlertCircleFill","DangerIcon","Title","Typography","TITLE_BODY","TITLE_GROUP","Body","Button","block","SMALL","ControlType","NEGATIVE","priority","Priority","SECONDARY","PRIMARY","onClick","window","location","href","label"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,SAASA,mBAAmBA,CAAC;EAAEC,KAAK;EAAEC,QAAQ;EAAEC,MAAM;AAAEC,EAAAA,SAAAA;AAAqC,CAAA,EAAA;EAC3F,MAAM;AAAEC,IAAAA,QAAAA;GAAU,GAAGC,0BAAQ,EAAE,CAAA;AAC/B,EAAA,oBACEC,cAAA,CAAA,KAAA,EAAA;AAAKH,IAAAA,SAAS,EAAEI,SAAI,CAAC,gBAAgB,EAAEJ,SAAS,CAAE;AAAAK,IAAAA,QAAA,eAChDC,eAAA,CAAA,KAAA,EAAA;AAAKN,MAAAA,SAAS,EAAC,qBAAqB;MAAAK,QAA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ACC,QAAS;YAC3BC,QAAQ,EAAE1B,QAAQ,GAAG2B,gBAAQ,CAACC,SAAS,GAAGD,gBAAQ,CAACE,OAAQ;AAC3D9B,YAAAA,SAAS,EAAC,SAAS;YACnB+B,OAAO,EAAEA,MAAK;AACZ,cAAA,IAAIhC,MAAM,EAAE;AACViC,gBAAAA,MAAM,CAACC,QAAQ,CAACC,IAAI,GAAGnC,MAAM,CAACmC,IAAI,CAAA;AACpC,eAAA;aACA;YAAA7B,QAAA,EAEDN,MAAM,CAACoC,KAAAA;WACF,CAAA;SACL,CAAC,GACJ,IAAI,CAAA;AAAA,OACL,CACP,CAAA;KAAK,CAAA;AACP,GAAK,CAAC,CAAA;AAEV;;;;"}
@@ -4,7 +4,7 @@ import { clsx } from 'clsx';
4
4
  import { AvatarType } from '../avatar/avatarTypes.mjs';
5
5
  import Avatar from '../avatar/Avatar.mjs';
6
6
  import Body from '../body/Body.mjs';
7
- import Button from '../button/Button.mjs';
7
+ import Button from '../button/Button.resolver.mjs';
8
8
  import '../common/theme.mjs';
9
9
  import '../common/direction.mjs';
10
10
  import { ControlType, Priority } from '../common/propsValues/control.mjs';
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var clsx = require('clsx');
6
- var Button = require('../button/Button.js');
6
+ var Button_resolver = require('../button/Button.resolver.js');
7
7
  require('../common/theme.js');
8
8
  require('../common/direction.js');
9
9
  require('../common/propsValues/control.js');
@@ -46,7 +46,7 @@ const HeaderAction = ({
46
46
  children: action.text
47
47
  });
48
48
  }
49
- return /*#__PURE__*/jsxRuntime.jsx(Button, {
49
+ return /*#__PURE__*/jsxRuntime.jsx(Button_resolver, {
50
50
  className: "np-header__button",
51
51
  priority: "tertiary",
52
52
  size: "sm",
@@ -1 +1 @@
1
- {"version":3,"file":"Header.js","sources":["../../src/header/Header.tsx"],"sourcesContent":["import { clsx } from 'clsx';\n\nimport { ActionButtonProps } from '../actionButton/ActionButton';\nimport Button from '../button';\nimport { AriaLabelProperty, CommonProps, Heading, LinkProps, Typography } from '../common';\nimport Link from '../link';\nimport Title from '../title';\n\ntype ActionProps = AriaLabelProperty & {\n text: string;\n};\n\ntype ButtonActionProps = ActionProps & ActionButtonProps;\n\ntype LinkActionProps = ActionProps & LinkProps;\n\nexport type HeaderProps = CommonProps & {\n /**\n * When the `href` property is provided to the `action`, we will render a `Link` instead of a `ActionButton`.\n */\n action?: ButtonActionProps | LinkActionProps;\n /**\n * Override the heading element rendered for the title, useful to specify the semantics of your header.\n *\n * @default \"h5\"\n */\n as?: Heading | 'legend';\n title: string;\n};\n\nconst HeaderAction = ({ action }: { action: ButtonActionProps | LinkActionProps }) => {\n const props = {\n 'aria-label': action['aria-label'],\n };\n\n if ('href' in action) {\n return (\n <Link href={action.href} target={action.target} onClick={action.onClick} {...props}>\n {action.text}\n </Link>\n );\n }\n\n return (\n <Button\n className=\"np-header__button\"\n priority=\"tertiary\"\n size=\"sm\"\n onClick={action.onClick}\n {...props}\n >\n {action.text}\n </Button>\n );\n};\n\n/**\n *\n * Neptune Web: https://transferwise.github.io/neptune-web/components/content/Header\n *\n */\nexport const Header = ({ action, as = 'h5', title, className }: HeaderProps) => {\n if (!action) {\n return (\n <Title\n as={as}\n type={Typography.TITLE_GROUP}\n className={clsx('np-header', 'np-header__title', className)}\n >\n {title}\n </Title>\n );\n }\n\n if (as === 'legend') {\n // eslint-disable-next-line no-console\n console.warn(\n 'Legends should be the first child in a fieldset, and this is not possible when including an action',\n );\n }\n\n return (\n <div className={clsx('np-header', className)}>\n <Title as={as} type={Typography.TITLE_GROUP} className=\"np-header__title\">\n {title}\n </Title>\n <HeaderAction action={action} />\n </div>\n );\n};\n\nexport default Header;\n"],"names":["HeaderAction","action","props","_jsx","Link","href","target","onClick","children","text","Button","className","priority","size","Header","as","title","Title","type","Typography","TITLE_GROUP","clsx","console","warn","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAMA,YA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,CACrG,CAAA;AACH,GAAA;AAEA,EAAA,oBACEC,eAAA,CAAA,KAAA,EAAA;AAAKb,IAAAA,SAAS,EAAEU,SAAI,CAAC,WAAW,EAAEV,SAAS,CAAE;IAAAH,QAAA,EAAA,cAC3CL,cAAA,CAACc,KAAK,EAAA;AAACF,MAAAA,EAAE,EAAEA,EAAG;MAACG,IAAI,EAAEC,qBAAU,CAACC,WAAY;AAACT,MAAAA,SAAS,EAAC,kBAAkB;AAAAH,MAAAA,QAAA,EACtEQ,KAAAA;AAAK,KACD,CACP,eAAAb,cAAA,CAACH,YAAY,EAAA;AAACC,MAAAA,MAAM,EAAEA,MAAAA;AAAO,KAC/B,CAAA,CAAA;AAAA,GAAK,CAAC,CAAA;AAEV;;;;;"}
1
+ {"version":3,"file":"Header.js","sources":["../../src/header/Header.tsx"],"sourcesContent":["import { clsx } from 'clsx';\n\nimport { ActionButtonProps } from '../actionButton/ActionButton';\nimport Button from '../button';\nimport { AriaLabelProperty, CommonProps, Heading, LinkProps, Typography } from '../common';\nimport Link from '../link';\nimport Title from '../title';\n\ntype ActionProps = AriaLabelProperty & {\n text: string;\n};\n\ntype ButtonActionProps = ActionProps & ActionButtonProps;\n\ntype LinkActionProps = ActionProps & LinkProps;\n\nexport type HeaderProps = CommonProps & {\n /**\n * When the `href` property is provided to the `action`, we will render a `Link` instead of a `ActionButton`.\n */\n action?: ButtonActionProps | LinkActionProps;\n /**\n * Override the heading element rendered for the title, useful to specify the semantics of your header.\n *\n * @default \"h5\"\n */\n as?: Heading | 'legend';\n title: string;\n};\n\nconst HeaderAction = ({ action }: { action: ButtonActionProps | LinkActionProps }) => {\n const props = {\n 'aria-label': action['aria-label'],\n };\n\n if ('href' in action) {\n return (\n <Link href={action.href} target={action.target} onClick={action.onClick} {...props}>\n {action.text}\n </Link>\n );\n }\n\n return (\n <Button\n className=\"np-header__button\"\n priority=\"tertiary\"\n size=\"sm\"\n onClick={action.onClick}\n {...props}\n >\n {action.text}\n </Button>\n );\n};\n\n/**\n *\n * Neptune Web: https://transferwise.github.io/neptune-web/components/content/Header\n *\n */\nexport const Header = ({ action, as = 'h5', title, className }: HeaderProps) => {\n if (!action) {\n return (\n <Title\n as={as}\n type={Typography.TITLE_GROUP}\n className={clsx('np-header', 'np-header__title', className)}\n >\n {title}\n </Title>\n );\n }\n\n if (as === 'legend') {\n // eslint-disable-next-line no-console\n console.warn(\n 'Legends should be the first child in a fieldset, and this is not possible when including an action',\n );\n }\n\n return (\n <div className={clsx('np-header', className)}>\n <Title as={as} type={Typography.TITLE_GROUP} className=\"np-header__title\">\n {title}\n </Title>\n <HeaderAction action={action} />\n </div>\n );\n};\n\nexport default Header;\n"],"names":["HeaderAction","action","props","_jsx","Link","href","target","onClick","children","text","Button","className","priority","size","Header","as","title","Title","type","Typography","TITLE_GROUP","clsx","console","warn","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAMA,YAAY,GAAGA,CAAC;AAAEC,EAAAA,MAAAA;AAAM,CAAmD,KAAI;AACnF,EAAA,MAAMC,KAAK,GAAG;IACZ,YAAY,EAAED,MAAM,CAAC,YAAY,CAAA;GAClC,CAAA;EAED,IAAI,MAAM,IAAIA,MAAM,EAAE;IACpB,oBACEE,cAAA,CAACC,IAAI,EAAA;MAACC,IAAI,EAAEJ,MAAM,CAACI,IAAK;MAACC,MAAM,EAAEL,MAAM,CAACK,MAAO;MAACC,OAAO,EAAEN,MAAM,CAACM,OAAQ;AAAA,MAAA,GAAKL,KAAK;MAAAM,QAAA,EAC/EP,MAAM,CAACQ,IAAAA;AAAI,KACR,CAAC,CAAA;AAEX,GAAA;EAEA,oBACEN,cAAA,CAACO,eAAM,EAAA;AACLC,IAAAA,SAAS,EAAC,mBAAmB;AAC7BC,IAAAA,QAAQ,EAAC,UAAU;AACnBC,IAAAA,IAAI,EAAC,IAAI;IACTN,OAAO,EAAEN,MAAM,CAACM,OAAQ;AAAA,IAAA,GACpBL,KAAK;IAAAM,QA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