@transferwise/components 0.0.0-experimental-db4013c → 0.0.0-experimental-bd6f8cc

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 (118) hide show
  1. package/build/avatarLayout/AvatarLayout.js +2 -9
  2. package/build/avatarLayout/AvatarLayout.js.map +1 -1
  3. package/build/avatarLayout/AvatarLayout.mjs +2 -9
  4. package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
  5. package/build/button/Button.js +79 -84
  6. package/build/button/Button.js.map +1 -1
  7. package/build/button/Button.mjs +80 -85
  8. package/build/button/Button.mjs.map +1 -1
  9. package/build/criticalBanner/CriticalCommsBanner.js +2 -2
  10. package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
  11. package/build/criticalBanner/CriticalCommsBanner.mjs +1 -1
  12. package/build/header/Header.js +2 -2
  13. package/build/header/Header.js.map +1 -1
  14. package/build/header/Header.mjs +1 -1
  15. package/build/index.js +2 -2
  16. package/build/index.mjs +1 -1
  17. package/build/link/Link.js +3 -8
  18. package/build/link/Link.js.map +1 -1
  19. package/build/link/Link.mjs +3 -8
  20. package/build/link/Link.mjs.map +1 -1
  21. package/build/main.css +11 -226
  22. package/build/nudge/Nudge.js.map +1 -1
  23. package/build/nudge/Nudge.mjs.map +1 -1
  24. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js +4 -2
  25. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js.map +1 -1
  26. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs +4 -2
  27. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs.map +1 -1
  28. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js +5 -3
  29. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js.map +1 -1
  30. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs +5 -3
  31. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs.map +1 -1
  32. package/build/select/Select.js +2 -2
  33. package/build/select/Select.js.map +1 -1
  34. package/build/select/Select.mjs +1 -1
  35. package/build/styles/avatarLayout/AvatarLayout.css +0 -11
  36. package/build/styles/button/Button.css +15 -207
  37. package/build/styles/main.css +11 -226
  38. package/build/styles/nudge/Nudge.css +11 -0
  39. package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
  40. package/build/types/button/Button.d.ts +23 -2
  41. package/build/types/button/Button.d.ts.map +1 -1
  42. package/build/types/button/index.d.ts +2 -2
  43. package/build/types/button/index.d.ts.map +1 -1
  44. package/build/types/link/Link.d.ts +2 -2
  45. package/build/types/link/Link.d.ts.map +1 -1
  46. package/build/types/nudge/Nudge.d.ts +1 -1
  47. package/build/types/nudge/Nudge.d.ts.map +1 -1
  48. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.d.ts.map +1 -1
  49. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts +2 -6
  50. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts.map +1 -1
  51. package/build/types/primitives/PrimitiveButton/src/PrimitiveButton.d.ts.map +1 -1
  52. package/build/types/test-utils/story-config.d.ts +1 -1
  53. package/build/types/test-utils/story-config.d.ts.map +1 -1
  54. package/build/upload/steps/completeStep/completeStep.js +2 -2
  55. package/build/upload/steps/completeStep/completeStep.js.map +1 -1
  56. package/build/upload/steps/completeStep/completeStep.mjs +1 -1
  57. package/build/upload/steps/processingStep/processingStep.js +2 -2
  58. package/build/upload/steps/processingStep/processingStep.js.map +1 -1
  59. package/build/upload/steps/processingStep/processingStep.mjs +1 -1
  60. package/build/uploadInput/UploadInput.js +3 -3
  61. package/build/uploadInput/UploadInput.js.map +1 -1
  62. package/build/uploadInput/UploadInput.mjs +1 -1
  63. package/package.json +3 -3
  64. package/src/alert/Alert.tests.story.tsx +1 -1
  65. package/src/avatarLayout/AvatarLayout.css +0 -11
  66. package/src/avatarLayout/AvatarLayout.less +1 -18
  67. package/src/avatarLayout/AvatarLayout.tsx +2 -10
  68. package/src/button/Button.css +15 -207
  69. package/src/button/Button.less +14 -214
  70. package/src/button/Button.spec.tsx +224 -188
  71. package/src/button/Button.story.tsx +135 -701
  72. package/src/button/Button.tsx +131 -97
  73. package/src/button/__snapshots__/Button.spec.tsx.snap +309 -0
  74. package/src/button/index.ts +3 -2
  75. package/src/field/Field.story.tsx +1 -1
  76. package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +2 -1
  77. package/src/inputs/SelectInput.story.tsx +1 -1
  78. package/src/label/Label.story.tsx +1 -1
  79. package/src/link/Link.tsx +6 -15
  80. package/src/main.css +11 -226
  81. package/src/main.less +0 -1
  82. package/src/nudge/Nudge.css +11 -0
  83. package/src/nudge/Nudge.less +3 -0
  84. package/src/nudge/Nudge.story.tsx +10 -0
  85. package/src/nudge/Nudge.tsx +2 -1
  86. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx +8 -2
  87. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.ts +2 -7
  88. package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +3 -1
  89. package/src/primitives/PrimitiveButton/src/PrimitiveButton.tsx +12 -4
  90. package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +13 -16
  91. package/src/test-utils/Parameters.d.ts +1 -9
  92. package/src/test-utils/story-config.ts +1 -10
  93. package/build/button/Button.resolver.js +0 -74
  94. package/build/button/Button.resolver.js.map +0 -1
  95. package/build/button/Button.resolver.mjs +0 -72
  96. package/build/button/Button.resolver.mjs.map +0 -1
  97. package/build/button/LegacyButton.js +0 -114
  98. package/build/button/LegacyButton.js.map +0 -1
  99. package/build/button/LegacyButton.mjs +0 -112
  100. package/build/button/LegacyButton.mjs.map +0 -1
  101. package/build/styles/button/Button.vars.css +0 -46
  102. package/build/styles/button/LegacyButton.css +0 -23
  103. package/build/types/button/Button.resolver.d.ts +0 -33
  104. package/build/types/button/Button.resolver.d.ts.map +0 -1
  105. package/build/types/button/Button.types.d.ts +0 -67
  106. package/build/types/button/Button.types.d.ts.map +0 -1
  107. package/build/types/button/LegacyButton.d.ts +0 -30
  108. package/build/types/button/LegacyButton.d.ts.map +0 -1
  109. package/src/button/Button.resolver.tsx +0 -73
  110. package/src/button/Button.tests.story.tsx +0 -27
  111. package/src/button/Button.types.ts +0 -94
  112. package/src/button/Button.vars.css +0 -46
  113. package/src/button/Button.vars.less +0 -60
  114. package/src/button/LegacyButton.css +0 -23
  115. package/src/button/LegacyButton.less +0 -24
  116. package/src/button/LegacyButton.spec.tsx +0 -147
  117. package/src/button/LegacyButton.story.tsx +0 -220
  118. package/src/button/LegacyButton.tsx +0 -160
@@ -1,72 +0,0 @@
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
- ...newProps
12
- } = props;
13
- const priorityMapping = {
14
- accent: {
15
- primary: 'primary',
16
- secondary: 'tertiary',
17
- tertiary: 'minimal'
18
- },
19
- positive: {
20
- primary: 'primary',
21
- secondary: 'tertiary',
22
- tertiary: 'tertiary'
23
- },
24
- negative: {
25
- primary: 'primary',
26
- secondary: 'secondary',
27
- tertiary: 'secondary'
28
- }
29
- };
30
- const mappedPriority = type && priority ? priorityMapping[type]?.[priority] || priority : priority || undefined;
31
- const mappedSentiment = type === 'negative' ? 'negative' : undefined;
32
- const legacyButtonTypes = ['accent', 'negative', 'positive', 'primary', 'pay', 'secondary', 'danger', 'link'];
33
- const resolveSize = () => {
34
- if (size) {
35
- return {
36
- xs: 'sm',
37
- sm: 'sm',
38
- md: 'md',
39
- lg: 'lg'
40
- }[size] || size;
41
- }
42
- return size;
43
- };
44
- return {
45
- ...newProps,
46
- size: resolveSize(),
47
- priority: mappedPriority,
48
- sentiment: mappedSentiment || ('sentiment' in props ? props.sentiment : null),
49
- type: type && !legacyButtonTypes.includes(type) ? type : props.htmlType || null,
50
- v2: true
51
- };
52
- };
53
- const Button = /*#__PURE__*/forwardRef(({
54
- v2 = false,
55
- ...props
56
- }, ref) => {
57
- if (v2) {
58
- const mappedProps = mapProps(props);
59
- return /*#__PURE__*/jsx(Button$1, {
60
- ...mappedProps,
61
- ref: ref
62
- });
63
- }
64
- return /*#__PURE__*/jsx(LegacyButton, {
65
- ...props,
66
- ref: ref
67
- });
68
- });
69
- Button.displayName = 'Button';
70
-
71
- export { Button as default };
72
- //# sourceMappingURL=Button.resolver.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Button.resolver.mjs","sources":["../../src/button/Button.resolver.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport LegacyButton, { LegacyButtonProps } from './LegacyButton';\nimport { ButtonReferenceType, ButtonProps as NewButtonProps } from './Button.types';\nimport NewButton from './Button';\n\nexport type ButtonProps = LegacyButtonProps | NewButtonProps;\n\nconst mapProps = (props: LegacyButtonProps): NewButtonProps => {\n const { priority, size, type, ...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: LegacyButtonProps['type'][] = [\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: type && !legacyButtonTypes.includes(type) ? type : props.htmlType || null,\n v2: true,\n } as NewButtonProps;\n};\n\nconst Button = forwardRef<ButtonReferenceType, ButtonProps>(({ v2 = false, ...props }, ref) => {\n if (v2) {\n const mappedProps = mapProps(props as LegacyButtonProps);\n return <NewButton {...mappedProps} ref={ref} />;\n }\n\n return <LegacyButton {...(props as LegacyButtonProps)} ref={ref} />;\n});\n\nButton.displayName = 'Button';\n\nexport default Button;\n"],"names":["mapProps","props","priority","size","type","newProps","priorityMapping","accent","primary","secondary","tertiary","positive","negative","mappedPriority","undefined","mappedSentiment","legacyButtonTypes","resolveSize","xs","sm","md","lg","sentiment","includes","htmlType","v2","Button","forwardRef","ref","mappedProps","_jsx","NewButton","LegacyButton","displayName"],"mappings":";;;;;AAOA,MAAMA,QAAQ,GAAIC,KAAwB,IAAoB;EAC5D,MAAM;IAAEC,QAAQ;IAAEC,IAAI;IAAEC,IAAI;IAAE,GAAGC,QAAAA;AAAQ,GAAE,GAAGJ,KAAK,CAAA;AAEnD,EAAA,MAAMK,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,EAAE,UAAU;AACrBC,MAAAA,QAAQ,EAAE,UAAA;KACX;AACDE,IAAAA,QAAQ,EAAE;AACRJ,MAAAA,OAAO,EAAE,SAAS;AAClBC,MAAAA,SAAS,EAAE,WAAW;AACtBC,MAAAA,QAAQ,EAAE,WAAA;AACX,KAAA;GACF,CAAA;AAED,EAAA,MAAMG,cAAc,GAClBT,IAAI,IAAIF,QAAQ,GAAGI,eAAe,CAACF,IAAI,CAAC,GAAGF,QAAQ,CAAC,IAAIA,QAAQ,GAAGA,QAAQ,IAAIY,SAAS,CAAA;EAC1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,GAAG,EAAEA,GAAAA;AAAI,MAAG,CAAA;AACjD,GAAA;EAEA,oBAAOE,GAAA,CAACE,YAAY,EAAA;AAAA,IAAA,GAAM/B,KAA2B;AAAE2B,IAAAA,GAAG,EAAEA,GAAAA;AAAI,IAAG,CAAA;AACrE,CAAC,EAAC;AAEFF,MAAM,CAACO,WAAW,GAAG,QAAQ;;;;"}
@@ -1,114 +0,0 @@
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
@@ -1 +0,0 @@
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';\nimport { ButtonReferenceType } from './Button.types';\n\n/** @deprecated */\ntype DeprecatedTypes = 'primary' | 'pay' | 'secondary' | 'danger' | 'link';\n\n/** @deprecated */\ntype DeprecatedSizes = SizeExtraSmall;\n\ntype CommonProps = {\n v2?: false;\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 htmlType?: 'submit' | 'reset' | 'button';\n};\n\ntype ButtonProps = CommonProps &\n Omit<React.ComponentPropsWithRef<'button'>, 'type'> & {\n as?: 'button';\n };\n\ntype AnchorProps = CommonProps &\n Omit<React.ComponentPropsWithRef<'a'>, 'type'> & {\n as?: 'a';\n href?: string;\n };\n\nexport type LegacyButtonProps = ButtonProps | AnchorProps;\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,MAAMA,YAAY,gBAAGC,gBAAU,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,gBAAQ,CAACC,OAAO;QAC3BC,MAAI,GAAGC,SAAI,CAACC,MAAM;EAClBC,IAAI,GAAGC,mBAAW,CAACC,MAAM;EACzBC,OAAO;EACP,GAAGC,IAAAA;AACe,CAAA,EACpBC,GAAG,KACD;AACF,EAAA,MAAMC,IAAI,GAAGC,iBAAO,EAAE,CAAA;AAEtBC,EAAAA,iCAAqB,CAAC;UAAEX,MAAI;AAAEG,IAAAA,IAAAA;AAAI,GAAE,CAAC,CAAA;AAErC,EAAA,MAAMS,OAAO,GAAGC,4BAAgB,CAACV,IAAI,CAAC,CAAA;AACtC,EAAA,MAAMW,WAAW,GAAGC,gCAAoB,CAAClB,QAAQ,EAAEM,IAAI,CAAC,CAAA;EAExD,MAAMa,OAAO,GAAGC,SAAI,CAClB,CAAA,QAAA,EAAWjB,MAAI,CAAA,CAAE,EACjB,CAAA,cAAA,EAAiBA,MAAI,CAAA,CAAE,EACvB;AACE,IAAA,aAAa,EAAEJ,OAAO;AACtB,IAAA,wBAAwB,EAAEJ,KAAK;AAC/BG,IAAAA,QAAAA;GACD;AACD;AACA;EACAuB,qBAAY,CAACN,OAAO,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AQ,GAAG,KAAM;AACtC,IAAA,WAAA,EAAWA,OAAQ;AACnB,IAAA,YAAA,EAAYA,OAAO,GAAGa,IAAI,CAACsB,aAAa,CAACC,eAAQ,CAACC,gBAAgB,CAAC,GAAG1B,IAAI,CAAC,YAAY,CAAE;AAAAd,IAAAA,QAAA,GAExFA,QAAQ,EACRG,OAAO,iBACNsC,cAAA,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;;;;"}
@@ -1,112 +0,0 @@
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
@@ -1 +0,0 @@
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';\nimport { ButtonReferenceType } from './Button.types';\n\n/** @deprecated */\ntype DeprecatedTypes = 'primary' | 'pay' | 'secondary' | 'danger' | 'link';\n\n/** @deprecated */\ntype DeprecatedSizes = SizeExtraSmall;\n\ntype CommonProps = {\n v2?: false;\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 htmlType?: 'submit' | 'reset' | 'button';\n};\n\ntype ButtonProps = CommonProps &\n Omit<React.ComponentPropsWithRef<'button'>, 'type'> & {\n as?: 'button';\n };\n\ntype AnchorProps = CommonProps &\n Omit<React.ComponentPropsWithRef<'a'>, 'type'> & {\n as?: 'a';\n href?: string;\n };\n\nexport type LegacyButtonProps = ButtonProps | AnchorProps;\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,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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EAAEA,GAAsC;AAC3Cd,IAAAA,SAAS,EAAEsB,OAAQ;AACnBV,IAAAA,OAAO,EAAEoB,WAAW,CAACpB,OAAO,CAAE;AAAA,IAAA,GAC1BiB,KAAK;AACT,IAAA,WAAA,EAAW3B,OAAO,GAAG,QAAQ,GAAG,KAAM;AACtC,IAAA,WAAA,EAAWA,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;;;;"}
@@ -1,46 +0,0 @@
1
- .wds-Button {
2
- --Button-background: var(--color-interactive-accent);
3
- --Button-background-hover: var(--color-interactive-accent-hover);
4
- --Button-background-active: var(--color-interactive-accent-active);
5
- --Button-color: var(--color-interactive-control);
6
- --Button-border-radius: var(--radius-full);
7
- --Button-label-gap: var(--size-4);
8
- --Button-large-padding: var(--size-12) var(--size-16);
9
- --Button-medium-padding: var(--size-8) var(--size-12);
10
- --Button-small-padding: calc(var(--size-10) * 0.5) var(--size-12);
11
- --Button-avatar-border-color: var(--color-border-neutral);
12
- --Button-transition-duration: 150ms;
13
- --Button-transition-easing: ease-in-out;
14
- --Button-secondary-background: var(--color-interactive-neutral);
15
- --Button-secondary-background-hover: var(--color-interactive-neutral-hover);
16
- --Button-secondary-background-active: var(--color-interactive-neutral-active);
17
- --Button-secondary-color: var(--color-interactive-primary);
18
- --Button-tertiary-background: var(--color-background-neutral);
19
- --Button-tertiary-background-hover: var(--color-background-neutral-hover);
20
- --Button-tertiary-background-active: var(--color-background-neutral-active);
21
- --Button-tertiary-color: var(--color-content-primary);
22
- --Button-minimal-background: transparent;
23
- --Button-minimal-background-hover: var(--color-background-screen-hover);
24
- --Button-minimal-background-active: var(--color-background-screen-active);
25
- --Button-minimal-color: var(--color-interactive-primary);
26
- --Button-primary-negative-background: var(--color-sentiment-negative-primary);
27
- --Button-primary-negative-background-hover: var(--color-sentiment-negative-primary-hover);
28
- --Button-primary-negative-background-active: var(--color-sentiment-negative-primary-active);
29
- --Button-primary-negative-color: var(--color-contrast-overlay);
30
- --Button-secondary-negative-background: var(--color-sentiment-negative-secondary);
31
- --Button-secondary-negative-background-hover: var(--color-sentiment-negative-secondary-hover);
32
- --Button-secondary-negative-background-active: var(--color-sentiment-negative-secondary-active);
33
- --Button-secondary-negative-color: var(--color-sentiment-negative-primary);
34
- }
35
- .np-theme-personal--bright-green .wds-Button {
36
- --Button-primary-negative-color: var(--color-white);
37
- --Button-secondary-color: var(--color-interactive-control);
38
- --Button-secondary-negative-color: var(--color-white);
39
- }
40
- .np-theme-personal--forest-green .wds-Button {
41
- --Button-secondary-background: var(--color-interactive-neutral);
42
- --Button-secondary-negative-background: var(--color-sentiment-negative-primary);
43
- --Button-secondary-negative-background-hover: var(--color-sentiment-negative-primary-hover);
44
- --Button-secondary-negative-background-active: var(--color-sentiment-negative-primary-active);
45
- --Button-secondary-negative-color: var(--color-contrast-overlay);
46
- }
@@ -1,23 +0,0 @@
1
- .np-btn {
2
- position: relative;
3
- }
4
- .np-btn.np-btn-block > span.btn-loader {
5
- position: absolute;
6
- left: 24px;
7
- left: var(--size-24);
8
- }
9
- [dir="rtl"] .np-btn.np-btn-block > span.btn-loader {
10
- right: 24px;
11
- right: var(--size-24);
12
- left: auto;
13
- left: initial;
14
- }
15
- .np-btn.np-btn-xs > span.btn-loader {
16
- background-size: 16px 16px;
17
- }
18
- .np-btn.np-btn-xs.btn-block > span.btn-loader {
19
- top: 0;
20
- }
21
- .np-btn.disabled[class] {
22
- pointer-events: auto;
23
- }
@@ -1,33 +0,0 @@
1
- import { LegacyButtonProps } from './LegacyButton';
2
- import { ButtonReferenceType, ButtonProps as NewButtonProps } from './Button.types';
3
- export type ButtonProps = LegacyButtonProps | NewButtonProps;
4
- declare const Button: import("react").ForwardRefExoticComponent<(NewButtonProps | Omit<{
5
- v2?: false;
6
- block?: boolean;
7
- disabled?: boolean;
8
- loading?: boolean;
9
- type?: import("../common").ControlTypeAccent | import("../common").ControlTypeNegative | import("../common").ControlTypePositive | ("link" | "primary" | "secondary" | "pay" | "danger") | null;
10
- priority?: import("../common").PriorityPrimary | import("../common").PrioritySecondary | import("../common").PriorityTertiary | null;
11
- size?: import("../common").SizeSmall | import("../common").SizeMedium | import("../common").SizeLarge | "xs";
12
- htmlType?: "submit" | "reset" | "button";
13
- } & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
14
- ref?: ((instance: HTMLButtonElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLButtonElement> | null | undefined;
15
- }, "type"> & {
16
- as?: "button";
17
- }, "ref"> | Omit<{
18
- v2?: false;
19
- block?: boolean;
20
- disabled?: boolean;
21
- loading?: boolean;
22
- type?: import("../common").ControlTypeAccent | import("../common").ControlTypeNegative | import("../common").ControlTypePositive | ("link" | "primary" | "secondary" | "pay" | "danger") | null;
23
- priority?: import("../common").PriorityPrimary | import("../common").PrioritySecondary | import("../common").PriorityTertiary | null;
24
- size?: import("../common").SizeSmall | import("../common").SizeMedium | import("../common").SizeLarge | "xs";
25
- htmlType?: "submit" | "reset" | "button";
26
- } & Omit<Omit<import("react").DetailedHTMLProps<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "ref"> & {
27
- ref?: ((instance: HTMLAnchorElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLAnchorElement> | null | undefined;
28
- }, "type"> & {
29
- as?: "a";
30
- href?: string;
31
- }, "ref">) & import("react").RefAttributes<ButtonReferenceType>>;
32
- export default Button;
33
- //# sourceMappingURL=Button.resolver.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Button.resolver.d.ts","sourceRoot":"","sources":["../../../src/button/Button.resolver.tsx"],"names":[],"mappings":"AACA,OAAqB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,WAAW,IAAI,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGpF,MAAM,MAAM,WAAW,GAAG,iBAAiB,GAAG,cAAc,CAAC;AAwD7D,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;gEAOV,CAAC;AAIH,eAAe,MAAM,CAAC"}
@@ -1,67 +0,0 @@
1
- import { AnchorHTMLAttributes, ButtonHTMLAttributes, ReactNode } from 'react';
2
- import type { AvatarLayoutProps } from '../avatarLayout';
3
- export type ButtonSentiment = 'default' | 'negative';
4
- export type ButtonPriority = 'primary' | 'secondary' | 'tertiary' | 'minimal';
5
- export type ButtonSize = 'sm' | 'md' | 'lg';
6
- export type ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;
7
- /**
8
- * Common properties for the Button component.
9
- */
10
- export interface CommonProps {
11
- v2: true;
12
- /**
13
- * The HTML element to render
14
- * @default 'button'
15
- **/
16
- as?: 'button' | 'a';
17
- /** Additional class name(s) to apply to the button */
18
- className?: string;
19
- /**
20
- * @default false
21
- **/
22
- disabled?: boolean;
23
- href?: string;
24
- /**
25
- * @default false
26
- * */
27
- loading?: boolean;
28
- /** Whether the button should take up the full width of its container */
29
- block?: boolean;
30
- /**
31
- * Size of the button
32
- * @default lg
33
- * */
34
- size?: ButtonSize;
35
- /**
36
- * Priority of the button
37
- * @default "primary"
38
- */
39
- priority?: ButtonPriority;
40
- /**
41
- * Sentiment of the button
42
- * @default default
43
- */
44
- sentiment?: ButtonSentiment;
45
- /** Icon to be displayed on the left side of the button */
46
- iconStart?: React.ElementType;
47
- /** Icon to be displayed on the right side of the button */
48
- iconEnd?: React.ElementType;
49
- /** Media to be displayed on the left side of the button */
50
- avatars?: AvatarLayoutProps['avatars'];
51
- /** Content to be displayed inside the button */
52
- children?: ReactNode;
53
- addonStart?: ButtonAddonStart;
54
- addonEnd?: ButtonAddonEnd;
55
- }
56
- type ButtonAddonStart = {
57
- icon?: React.ElementType;
58
- avatars?: AvatarLayoutProps['avatars'];
59
- };
60
- type ButtonAddonEnd = {
61
- icon?: React.ElementType;
62
- };
63
- export type ButtonElementProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'disabled' | 'className'> & CommonProps;
64
- export type AnchorElementProps = Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'type' | 'disabled' | 'href' | 'className'> & CommonProps;
65
- export type ButtonProps = ButtonElementProps | AnchorElementProps;
66
- export {};
67
- //# sourceMappingURL=Button.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Button.types.d.ts","sourceRoot":"","sources":["../../../src/button/Button.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,UAAU,CAAC;AACrD,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;AAC9E,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAC5C,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,G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,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACnC,oBAAoB,CAAC,iBAAiB,CAAC,EACvC,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,WAAW,CAC3C,GACC,WAAW,CAAC;AAEd,MAAM,MAAM,WAAW,GAAG,kBAAkB,GAAG,kBAAkB,CAAC"}
@@ -1,30 +0,0 @@
1
- import { ControlTypeAccent, ControlTypeNegative, ControlTypePositive, PriorityPrimary, PrioritySecondary, PriorityTertiary, SizeExtraSmall, SizeSmall, SizeMedium, SizeLarge } from '../common';
2
- import { ButtonReferenceType } from './Button.types';
3
- /** @deprecated */
4
- type DeprecatedTypes = 'primary' | 'pay' | 'secondary' | 'danger' | 'link';
5
- /** @deprecated */
6
- type DeprecatedSizes = SizeExtraSmall;
7
- type CommonProps = {
8
- v2?: false;
9
- block?: boolean;
10
- disabled?: boolean;
11
- loading?: boolean;
12
- type?: ControlTypeAccent | ControlTypeNegative | ControlTypePositive | DeprecatedTypes | null;
13
- priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary | null;
14
- size?: SizeSmall | SizeMedium | SizeLarge | DeprecatedSizes;
15
- htmlType?: 'submit' | 'reset' | 'button';
16
- };
17
- type ButtonProps = CommonProps & Omit<React.ComponentPropsWithRef<'button'>, 'type'> & {
18
- as?: 'button';
19
- };
20
- type AnchorProps = CommonProps & Omit<React.ComponentPropsWithRef<'a'>, 'type'> & {
21
- as?: 'a';
22
- href?: string;
23
- };
24
- export type LegacyButtonProps = ButtonProps | AnchorProps;
25
- /**
26
- * @deprecated make sure you use new Button component via `<Button v2 .. />` and new props
27
- */
28
- declare const LegacyButton: import("react").ForwardRefExoticComponent<(Omit<ButtonProps, "ref"> | Omit<AnchorProps, "ref">) & import("react").RefAttributes<ButtonReferenceType>>;
29
- export default LegacyButton;
30
- //# sourceMappingURL=LegacyButton.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LegacyButton.d.ts","sourceRoot":"","sources":["../../../src/button/LegacyButton.tsx"],"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J,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,WAAW,CAAC;AAE1D;;GAEG;AACH,QAAA,MAAM,YAAY,uJAkGjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -1,73 +0,0 @@
1
- import { forwardRef } from 'react';
2
- import LegacyButton, { LegacyButtonProps } from './LegacyButton';
3
- import { ButtonReferenceType, ButtonProps as NewButtonProps } from './Button.types';
4
- import NewButton from './Button';
5
-
6
- export type ButtonProps = LegacyButtonProps | NewButtonProps;
7
-
8
- const mapProps = (props: LegacyButtonProps): NewButtonProps => {
9
- const { priority, size, type, ...newProps } = props;
10
-
11
- const priorityMapping: Record<string, Record<string, NewButtonProps['priority']>> = {
12
- accent: {
13
- primary: 'primary',
14
- secondary: 'tertiary',
15
- tertiary: 'minimal',
16
- },
17
- positive: {
18
- primary: 'primary',
19
- secondary: 'tertiary',
20
- tertiary: 'tertiary',
21
- },
22
- negative: {
23
- primary: 'primary',
24
- secondary: 'secondary',
25
- tertiary: 'secondary',
26
- },
27
- };
28
-
29
- const mappedPriority =
30
- type && priority ? priorityMapping[type]?.[priority] || priority : priority || undefined;
31
- const mappedSentiment = type === 'negative' ? 'negative' : undefined;
32
-
33
- const legacyButtonTypes: LegacyButtonProps['type'][] = [
34
- 'accent',
35
- 'negative',
36
- 'positive',
37
- 'primary',
38
- 'pay',
39
- 'secondary',
40
- 'danger',
41
- 'link',
42
- ];
43
-
44
- const resolveSize = () => {
45
- if (size) {
46
- return { xs: 'sm', sm: 'sm', md: 'md', lg: 'lg' }[size] || size;
47
- }
48
-
49
- return size;
50
- };
51
-
52
- return {
53
- ...newProps,
54
- size: resolveSize(),
55
- priority: mappedPriority,
56
- sentiment: mappedSentiment || ('sentiment' in props ? props.sentiment : null),
57
- type: type && !legacyButtonTypes.includes(type) ? type : props.htmlType || null,
58
- v2: true,
59
- } as NewButtonProps;
60
- };
61
-
62
- const Button = forwardRef<ButtonReferenceType, ButtonProps>(({ v2 = false, ...props }, ref) => {
63
- if (v2) {
64
- const mappedProps = mapProps(props as LegacyButtonProps);
65
- return <NewButton {...mappedProps} ref={ref} />;
66
- }
67
-
68
- return <LegacyButton {...(props as LegacyButtonProps)} ref={ref} />;
69
- });
70
-
71
- Button.displayName = 'Button';
72
-
73
- export default Button;