@transferwise/components 0.0.0-experimental-28eac06 → 0.0.0-experimental-9b6d886
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/alert/Alert.js +17 -17
- package/build/alert/Alert.js.map +1 -1
- package/build/alert/Alert.mjs +14 -14
- package/build/alert/Alert.mjs.map +1 -1
- package/build/avatarLayout/AvatarLayout.js +2 -9
- package/build/avatarLayout/AvatarLayout.js.map +1 -1
- package/build/avatarLayout/AvatarLayout.mjs +2 -9
- package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
- package/build/button/Button.js +79 -86
- package/build/button/Button.js.map +1 -1
- package/build/button/Button.mjs +80 -87
- package/build/button/Button.mjs.map +1 -1
- package/build/circularButton/CircularButton.js.map +1 -1
- package/build/circularButton/CircularButton.mjs.map +1 -1
- package/build/common/action/Action.js +15 -26
- package/build/common/action/Action.js.map +1 -1
- package/build/common/action/Action.mjs +15 -26
- package/build/common/action/Action.mjs.map +1 -1
- package/build/common/propsValues/sentiment.js +0 -1
- package/build/common/propsValues/sentiment.js.map +1 -1
- package/build/common/propsValues/sentiment.mjs +0 -1
- package/build/common/propsValues/sentiment.mjs.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.js +73 -10
- package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.mjs +74 -11
- package/build/criticalBanner/CriticalCommsBanner.mjs.map +1 -1
- package/build/header/Header.js +2 -2
- package/build/header/Header.js.map +1 -1
- package/build/header/Header.mjs +1 -1
- package/build/i18n/en.json +0 -1
- package/build/i18n/en.json.js +0 -1
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +0 -1
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/i18n/ja.json +1 -0
- package/build/i18n/ja.json.js +1 -0
- package/build/i18n/ja.json.js.map +1 -1
- package/build/i18n/ja.json.mjs +1 -0
- package/build/i18n/ja.json.mjs.map +1 -1
- package/build/i18n/pt.json +1 -0
- package/build/i18n/pt.json.js +1 -0
- package/build/i18n/pt.json.js.map +1 -1
- package/build/i18n/pt.json.mjs +1 -0
- package/build/i18n/pt.json.mjs.map +1 -1
- package/build/i18n/ru.json +1 -0
- package/build/i18n/ru.json.js +1 -0
- package/build/i18n/ru.json.js.map +1 -1
- package/build/i18n/ru.json.mjs +1 -0
- package/build/i18n/ru.json.mjs.map +1 -1
- package/build/i18n/zh-HK.json +1 -0
- package/build/i18n/zh-HK.json.js +1 -0
- package/build/i18n/zh-HK.json.js.map +1 -1
- package/build/i18n/zh-HK.json.mjs +1 -0
- package/build/i18n/zh-HK.json.mjs.map +1 -1
- package/build/index.js +2 -2
- package/build/index.mjs +1 -1
- package/build/link/Link.js +3 -8
- package/build/link/Link.js.map +1 -1
- package/build/link/Link.mjs +3 -8
- package/build/link/Link.mjs.map +1 -1
- package/build/main.css +70 -267
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js +4 -2
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js.map +1 -1
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs +4 -2
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs.map +1 -1
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.js +5 -3
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.js.map +1 -1
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs +5 -3
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs.map +1 -1
- package/build/select/Select.js +2 -2
- package/build/select/Select.js.map +1 -1
- package/build/select/Select.mjs +1 -1
- package/build/statusIcon/StatusIcon.js +1 -5
- package/build/statusIcon/StatusIcon.js.map +1 -1
- package/build/statusIcon/StatusIcon.messages.js +0 -3
- package/build/statusIcon/StatusIcon.messages.js.map +1 -1
- package/build/statusIcon/StatusIcon.messages.mjs +0 -3
- package/build/statusIcon/StatusIcon.messages.mjs.map +1 -1
- package/build/statusIcon/StatusIcon.mjs +1 -5
- package/build/statusIcon/StatusIcon.mjs.map +1 -1
- package/build/styles/avatarLayout/AvatarLayout.css +0 -11
- package/build/styles/button/Button.css +15 -230
- package/build/styles/criticalBanner/CriticalCommsBanner.css +73 -21
- package/build/styles/main.css +70 -267
- package/build/types/alert/Alert.d.ts +4 -3
- package/build/types/alert/Alert.d.ts.map +1 -1
- package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
- package/build/types/button/Button.d.ts +23 -2
- package/build/types/button/Button.d.ts.map +1 -1
- package/build/types/button/index.d.ts +2 -2
- package/build/types/button/index.d.ts.map +1 -1
- package/build/types/circularButton/CircularButton.d.ts.map +1 -1
- package/build/types/common/action/Action.d.ts +2 -5
- package/build/types/common/action/Action.d.ts.map +1 -1
- package/build/types/common/propsValues/sentiment.d.ts +0 -1
- package/build/types/common/propsValues/sentiment.d.ts.map +1 -1
- package/build/types/criticalBanner/CriticalCommsBanner.d.ts.map +1 -1
- package/build/types/index.d.ts +1 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/link/Link.d.ts +2 -2
- package/build/types/link/Link.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts +2 -6
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveButton/src/PrimitiveButton.d.ts.map +1 -1
- package/build/types/statusIcon/StatusIcon.d.ts.map +1 -1
- package/build/types/statusIcon/StatusIcon.messages.d.ts +0 -5
- package/build/types/statusIcon/StatusIcon.messages.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts +0 -2
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/build/types/test-utils/story-config.d.ts +1 -1
- package/build/types/test-utils/story-config.d.ts.map +1 -1
- package/build/upload/steps/completeStep/completeStep.js +2 -2
- package/build/upload/steps/completeStep/completeStep.js.map +1 -1
- package/build/upload/steps/completeStep/completeStep.mjs +1 -1
- package/build/upload/steps/processingStep/processingStep.js +2 -2
- package/build/upload/steps/processingStep/processingStep.js.map +1 -1
- package/build/upload/steps/processingStep/processingStep.mjs +1 -1
- package/build/uploadInput/UploadInput.js +3 -3
- package/build/uploadInput/UploadInput.js.map +1 -1
- package/build/uploadInput/UploadInput.mjs +1 -1
- package/package.json +3 -3
- package/src/alert/Alert.spec.tsx +30 -0
- package/src/alert/Alert.story.tsx +1 -34
- package/src/alert/Alert.tests.story.tsx +1 -1
- package/src/alert/Alert.tsx +15 -20
- package/src/avatarLayout/AvatarLayout.css +0 -11
- package/src/avatarLayout/AvatarLayout.less +1 -18
- package/src/avatarLayout/AvatarLayout.tsx +2 -10
- package/src/button/Button.css +15 -230
- package/src/button/Button.less +14 -242
- package/src/button/Button.spec.tsx +226 -215
- package/src/button/Button.story.tsx +134 -761
- package/src/button/Button.tsx +132 -103
- package/src/button/__snapshots__/Button.spec.tsx.snap +309 -0
- package/src/button/index.ts +3 -2
- package/src/circularButton/CircularButton.tsx +0 -1
- package/src/common/action/Action.tsx +22 -40
- package/src/common/propsValues/sentiment.ts +0 -1
- package/src/criticalBanner/CriticalCommsBanner.css +73 -21
- package/src/criticalBanner/CriticalCommsBanner.less +70 -24
- package/src/criticalBanner/CriticalCommsBanner.story.tsx +4 -26
- package/src/criticalBanner/CriticalCommsBanner.tsx +50 -8
- package/src/field/Field.story.tsx +1 -1
- package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +2 -1
- package/src/i18n/en.json +0 -1
- package/src/i18n/ja.json +1 -0
- package/src/i18n/pt.json +1 -0
- package/src/i18n/ru.json +1 -0
- package/src/i18n/zh-HK.json +1 -0
- package/src/index.ts +1 -0
- package/src/inputs/SelectInput.story.tsx +1 -1
- package/src/label/Label.story.tsx +1 -1
- package/src/link/Link.tsx +6 -15
- package/src/main.css +70 -267
- package/src/main.less +0 -1
- package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx +8 -2
- package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.ts +2 -7
- package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +3 -1
- package/src/primitives/PrimitiveButton/src/PrimitiveButton.tsx +12 -4
- package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +13 -16
- package/src/radio/Radio.spec.tsx +73 -0
- package/src/radio/Radio.story.tsx +22 -52
- package/src/radioGroup/RadioGroup.spec.tsx +91 -0
- package/src/radioGroup/RadioGroup.story.tsx +3 -5
- package/src/statusIcon/StatusIcon.less +0 -1
- package/src/statusIcon/StatusIcon.messages.ts +0 -6
- package/src/statusIcon/StatusIcon.tsx +1 -8
- package/src/test-utils/Parameters.d.ts +1 -9
- package/src/test-utils/story-config.ts +1 -10
- package/build/button/Button.resolver.js +0 -74
- package/build/button/Button.resolver.js.map +0 -1
- package/build/button/Button.resolver.mjs +0 -72
- package/build/button/Button.resolver.mjs.map +0 -1
- package/build/button/LegacyButton.js +0 -114
- package/build/button/LegacyButton.js.map +0 -1
- package/build/button/LegacyButton.mjs +0 -112
- package/build/button/LegacyButton.mjs.map +0 -1
- package/build/styles/button/Button.vars.css +0 -46
- package/build/styles/button/LegacyButton.css +0 -23
- package/build/types/button/Button.resolver.d.ts +0 -35
- package/build/types/button/Button.resolver.d.ts.map +0 -1
- package/build/types/button/Button.types.d.ts +0 -70
- package/build/types/button/Button.types.d.ts.map +0 -1
- package/build/types/button/LegacyButton.d.ts +0 -44
- package/build/types/button/LegacyButton.d.ts.map +0 -1
- package/src/button/Button.accessibility.docs.mdx +0 -103
- package/src/button/Button.resolver.tsx +0 -73
- package/src/button/Button.tests.story.tsx +0 -27
- package/src/button/Button.types.ts +0 -92
- package/src/button/Button.vars.css +0 -46
- package/src/button/Button.vars.less +0 -55
- package/src/button/LegacyButton.css +0 -23
- package/src/button/LegacyButton.less +0 -24
- package/src/button/LegacyButton.spec.tsx +0 -147
- package/src/button/LegacyButton.story.tsx +0 -228
- package/src/button/LegacyButton.tsx +0 -177
- package/src/radio/Radio.rtl.spec.tsx +0 -24
- package/src/radio/Radio.spec.js +0 -76
- package/src/radio/__snapshots__/Radio.rtl.spec.tsx.snap +0 -49
- package/src/radioGroup/RadioGroup.rtl.spec.tsx +0 -30
- package/src/radioGroup/RadioGroup.spec.js +0 -90
package/src/button/Button.tsx
CHANGED
|
@@ -1,125 +1,154 @@
|
|
|
1
|
-
/* eslint-disable react/display-name */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
3
|
-
import { forwardRef } from 'react';
|
|
4
|
-
import { ButtonReferenceType, ButtonProps as NewButtonProps } from './Button.types';
|
|
5
|
-
import { PrimitiveAnchor, PrimitiveButton } from '../primitives';
|
|
6
|
-
import AvatarLayout from '../avatarLayout';
|
|
7
|
-
import ProcessIndicator from '../processIndicator';
|
|
8
1
|
import { clsx } from 'clsx';
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
2
|
+
import { ElementType, forwardRef, MouseEvent } from 'react';
|
|
3
|
+
import { useIntl } from 'react-intl';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Size,
|
|
7
|
+
ControlType,
|
|
8
|
+
Priority,
|
|
9
|
+
ControlTypeAccent,
|
|
10
|
+
ControlTypeNegative,
|
|
11
|
+
ControlTypePositive,
|
|
12
|
+
PriorityPrimary,
|
|
13
|
+
PrioritySecondary,
|
|
14
|
+
PriorityTertiary,
|
|
15
|
+
SizeExtraSmall,
|
|
16
|
+
SizeSmall,
|
|
17
|
+
SizeMedium,
|
|
18
|
+
SizeLarge,
|
|
19
|
+
} from '../common';
|
|
20
|
+
import ProcessIndicator from '../processIndicator';
|
|
21
|
+
|
|
22
|
+
import messages from '../i18n/commonMessages/Button.messages';
|
|
23
|
+
import { typeClassMap, priorityClassMap } from './classMap';
|
|
24
|
+
import { establishNewPriority, establishNewType, logDeprecationNotices } from './legacyUtils';
|
|
25
|
+
|
|
26
|
+
/** @deprecated */
|
|
27
|
+
type DeprecatedTypes = 'primary' | 'pay' | 'secondary' | 'danger' | 'link';
|
|
28
|
+
|
|
29
|
+
/** @deprecated */
|
|
30
|
+
type DeprecatedSizes = SizeExtraSmall;
|
|
31
|
+
|
|
32
|
+
type CommonProps = {
|
|
33
|
+
block?: boolean;
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
loading?: boolean;
|
|
36
|
+
type?: ControlTypeAccent | ControlTypeNegative | ControlTypePositive | DeprecatedTypes | null;
|
|
37
|
+
priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary | null;
|
|
38
|
+
size?: SizeSmall | SizeMedium | SizeLarge | DeprecatedSizes;
|
|
39
|
+
};
|
|
11
40
|
|
|
12
|
-
|
|
41
|
+
type ButtonProps = CommonProps &
|
|
42
|
+
Omit<React.ComponentPropsWithRef<'button'>, 'type'> & {
|
|
43
|
+
as?: 'button';
|
|
44
|
+
htmlType?: 'submit' | 'reset' | 'button';
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
type AnchorProps = CommonProps &
|
|
48
|
+
Omit<React.ComponentPropsWithRef<'a'>, 'type'> & {
|
|
49
|
+
as?: 'a';
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type Props = ButtonProps | AnchorProps;
|
|
53
|
+
|
|
54
|
+
export type ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;
|
|
55
|
+
|
|
56
|
+
const Button = forwardRef<ButtonReferenceType, Props>(
|
|
13
57
|
(
|
|
14
58
|
{
|
|
15
|
-
as,
|
|
59
|
+
as: component,
|
|
60
|
+
block = false,
|
|
16
61
|
children,
|
|
17
62
|
className,
|
|
18
|
-
|
|
19
|
-
href,
|
|
20
|
-
disabled = false,
|
|
21
|
-
priority = 'primary',
|
|
22
|
-
sentiment = 'default',
|
|
23
|
-
addonStart,
|
|
24
|
-
addonEnd,
|
|
25
|
-
// @ts-expect-error NewButtonProps has `type` prop
|
|
26
|
-
type,
|
|
63
|
+
disabled,
|
|
27
64
|
loading = false,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
65
|
+
priority = Priority.PRIMARY,
|
|
66
|
+
size = Size.MEDIUM,
|
|
67
|
+
type = ControlType.ACCENT,
|
|
68
|
+
onClick,
|
|
69
|
+
...rest
|
|
70
|
+
}: Props,
|
|
71
|
+
reference,
|
|
33
72
|
) => {
|
|
34
|
-
const
|
|
35
|
-
|
|
73
|
+
const intl = useIntl();
|
|
74
|
+
|
|
75
|
+
logDeprecationNotices({ size, type });
|
|
76
|
+
|
|
77
|
+
const newType = establishNewType(type);
|
|
78
|
+
const newPriority = establishNewPriority(priority, type);
|
|
79
|
+
|
|
80
|
+
const classes = clsx(
|
|
81
|
+
`btn btn-${size}`,
|
|
82
|
+
`np-btn np-btn-${size}`,
|
|
36
83
|
{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
84
|
+
'btn-loading': loading,
|
|
85
|
+
'btn-block np-btn-block': block,
|
|
86
|
+
disabled,
|
|
40
87
|
},
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
88
|
+
// @ts-expect-error fix when refactor `typeClassMap` to TypeScript
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
90
|
+
typeClassMap[newType],
|
|
91
|
+
// @ts-expect-error fix when refactor `typeClassMap` to TypeScript
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
93
|
+
priorityClassMap[newPriority],
|
|
44
94
|
className,
|
|
45
95
|
);
|
|
46
96
|
|
|
47
|
-
|
|
48
|
-
[
|
|
49
|
-
}
|
|
97
|
+
function processIndicatorSize() {
|
|
98
|
+
return ['sm', 'xs'].includes(size) ? 'xxs' : 'xs';
|
|
99
|
+
}
|
|
50
100
|
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
as="span"
|
|
54
|
-
type={size === 'sm' ? Typography.BODY_DEFAULT_BOLD : Typography.BODY_LARGE_BOLD}
|
|
55
|
-
className={contentClassNames}
|
|
56
|
-
>
|
|
57
|
-
{loading && (
|
|
58
|
-
<ProcessIndicator
|
|
59
|
-
size={size === 'sm' ? 'xxs' : 'xs'}
|
|
60
|
-
className="wds-Button-loader"
|
|
61
|
-
data-testid="button-loader-indicator"
|
|
62
|
-
/>
|
|
63
|
-
)}
|
|
64
|
-
<span className="wds-Button-label" aria-hidden={loading}>
|
|
65
|
-
{size === 'lg' ? (
|
|
66
|
-
children
|
|
67
|
-
) : (
|
|
68
|
-
<>
|
|
69
|
-
{size === 'md' && addonStart?.type === 'avatar' && addonStart.value && (
|
|
70
|
-
<span className="wds-Button-avatars">
|
|
71
|
-
<AvatarLayout orientation="horizontal" avatars={addonStart?.value} size={24} />
|
|
72
|
-
</span>
|
|
73
|
-
)}
|
|
74
|
-
|
|
75
|
-
{addonStart?.type === 'icon' && addonStart.value && (
|
|
76
|
-
<span className={`wds-Button-icon wds-Button-icon--${size} wds-Button-icon--start`}>
|
|
77
|
-
{addonStart.value}
|
|
78
|
-
</span>
|
|
79
|
-
)}
|
|
80
|
-
|
|
81
|
-
{children}
|
|
82
|
-
|
|
83
|
-
{addonEnd?.type === 'icon' && addonEnd?.value && (
|
|
84
|
-
<span className={`wds-Button-icon wds-Button-icon--${size} wds-Button-icon--end`}>
|
|
85
|
-
{addonEnd.value}
|
|
86
|
-
</span>
|
|
87
|
-
)}
|
|
88
|
-
</>
|
|
89
|
-
)}
|
|
90
|
-
</span>
|
|
91
|
-
</Body>
|
|
92
|
-
);
|
|
101
|
+
const Element = (component as ElementType) ?? 'button';
|
|
102
|
+
let props;
|
|
93
103
|
|
|
94
|
-
if (
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
);
|
|
104
|
+
if (Element === 'button') {
|
|
105
|
+
const { htmlType = 'button', ...restProps } = rest as ButtonProps;
|
|
106
|
+
props = {
|
|
107
|
+
...restProps,
|
|
108
|
+
disabled,
|
|
109
|
+
'aria-disabled': loading,
|
|
110
|
+
type: htmlType,
|
|
111
|
+
};
|
|
112
|
+
} else {
|
|
113
|
+
props = {
|
|
114
|
+
...rest,
|
|
115
|
+
'aria-disabled': loading,
|
|
116
|
+
} as AnchorProps;
|
|
108
117
|
}
|
|
109
118
|
|
|
119
|
+
/**
|
|
120
|
+
* Ensures that the button cannot be activated in loading or disabled mode,
|
|
121
|
+
* when `aria-disabled` might be used over the `disabled` HTML attribute
|
|
122
|
+
*/
|
|
123
|
+
const handleClick =
|
|
124
|
+
(handler: Props['onClick']) =>
|
|
125
|
+
(event: MouseEvent<HTMLButtonElement> & MouseEvent<HTMLAnchorElement>) => {
|
|
126
|
+
if (disabled || loading) {
|
|
127
|
+
event.preventDefault();
|
|
128
|
+
} else if (typeof handler === 'function') {
|
|
129
|
+
handler(event);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
110
133
|
return (
|
|
111
|
-
<
|
|
112
|
-
ref={
|
|
113
|
-
{
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
target={undefined}
|
|
134
|
+
<Element
|
|
135
|
+
ref={reference}
|
|
136
|
+
className={classes}
|
|
137
|
+
onClick={handleClick(onClick)}
|
|
138
|
+
{...props}
|
|
139
|
+
aria-live={loading ? 'polite' : 'off'}
|
|
140
|
+
aria-busy={loading}
|
|
141
|
+
aria-label={loading ? intl.formatMessage(messages.loadingAriaLabel) : rest['aria-label']}
|
|
120
142
|
>
|
|
121
|
-
{
|
|
122
|
-
|
|
143
|
+
{children}
|
|
144
|
+
{loading && (
|
|
145
|
+
<ProcessIndicator
|
|
146
|
+
size={processIndicatorSize()}
|
|
147
|
+
className="btn-loader"
|
|
148
|
+
data-testid="ButtonProgressIndicator"
|
|
149
|
+
/>
|
|
150
|
+
)}
|
|
151
|
+
</Element>
|
|
123
152
|
);
|
|
124
153
|
},
|
|
125
154
|
);
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Button by default renders a medium button of type accent and priority primary 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<button
|
|
6
|
+
aria-busy="false"
|
|
7
|
+
aria-disabled="false"
|
|
8
|
+
aria-live="off"
|
|
9
|
+
class="btn btn-md np-btn np-btn-md btn-accent btn-priority-1"
|
|
10
|
+
type="button"
|
|
11
|
+
>
|
|
12
|
+
Send money
|
|
13
|
+
</button>
|
|
14
|
+
</div>
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
exports[`Button by default renders an anchor tag with button styles of type accent and priority primary 1`] = `
|
|
18
|
+
<div>
|
|
19
|
+
<a
|
|
20
|
+
aria-busy="false"
|
|
21
|
+
aria-disabled="false"
|
|
22
|
+
aria-live="off"
|
|
23
|
+
class="btn btn-md np-btn np-btn-md btn-accent btn-priority-1"
|
|
24
|
+
href="#"
|
|
25
|
+
>
|
|
26
|
+
Send money
|
|
27
|
+
</a>
|
|
28
|
+
</div>
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
exports[`Button deprecated types renders danger as negative buttons with priority secondary and logs a warning 1`] = `
|
|
32
|
+
<div>
|
|
33
|
+
<button
|
|
34
|
+
aria-busy="false"
|
|
35
|
+
aria-disabled="false"
|
|
36
|
+
aria-live="off"
|
|
37
|
+
class="btn btn-md np-btn np-btn-md btn-negative btn-priority-2"
|
|
38
|
+
type="button"
|
|
39
|
+
>
|
|
40
|
+
Send money
|
|
41
|
+
</button>
|
|
42
|
+
</div>
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
exports[`Button deprecated types renders link as accent buttons with priority tertiary and logs a warning 1`] = `
|
|
46
|
+
<div>
|
|
47
|
+
<button
|
|
48
|
+
aria-busy="false"
|
|
49
|
+
aria-disabled="false"
|
|
50
|
+
aria-live="off"
|
|
51
|
+
class="btn btn-md np-btn np-btn-md btn-accent btn-priority-3"
|
|
52
|
+
type="button"
|
|
53
|
+
>
|
|
54
|
+
Send money
|
|
55
|
+
</button>
|
|
56
|
+
</div>
|
|
57
|
+
`;
|
|
58
|
+
|
|
59
|
+
exports[`Button deprecated types renders pay as positive buttons and logs a warning 1`] = `
|
|
60
|
+
<div>
|
|
61
|
+
<button
|
|
62
|
+
aria-busy="false"
|
|
63
|
+
aria-disabled="false"
|
|
64
|
+
aria-live="off"
|
|
65
|
+
class="btn btn-md np-btn np-btn-md btn-positive btn-priority-1"
|
|
66
|
+
type="button"
|
|
67
|
+
>
|
|
68
|
+
Send money
|
|
69
|
+
</button>
|
|
70
|
+
</div>
|
|
71
|
+
`;
|
|
72
|
+
|
|
73
|
+
exports[`Button deprecated types renders primary as accent buttons and logs a warning 1`] = `
|
|
74
|
+
<div>
|
|
75
|
+
<button
|
|
76
|
+
aria-busy="false"
|
|
77
|
+
aria-disabled="false"
|
|
78
|
+
aria-live="off"
|
|
79
|
+
class="btn btn-md np-btn np-btn-md btn-accent btn-priority-1"
|
|
80
|
+
type="button"
|
|
81
|
+
>
|
|
82
|
+
Send money
|
|
83
|
+
</button>
|
|
84
|
+
</div>
|
|
85
|
+
`;
|
|
86
|
+
|
|
87
|
+
exports[`Button other states renders as block if block is true 1`] = `
|
|
88
|
+
<div>
|
|
89
|
+
<button
|
|
90
|
+
aria-busy="false"
|
|
91
|
+
aria-disabled="false"
|
|
92
|
+
aria-live="off"
|
|
93
|
+
class="btn btn-md np-btn np-btn-md btn-block np-btn-block btn-accent btn-priority-1"
|
|
94
|
+
type="button"
|
|
95
|
+
>
|
|
96
|
+
Send money
|
|
97
|
+
</button>
|
|
98
|
+
</div>
|
|
99
|
+
`;
|
|
100
|
+
|
|
101
|
+
exports[`Button priorities defaults tertiary buttons to secondary for positive buttons 1`] = `
|
|
102
|
+
<div>
|
|
103
|
+
<button
|
|
104
|
+
aria-busy="false"
|
|
105
|
+
aria-disabled="false"
|
|
106
|
+
aria-live="off"
|
|
107
|
+
class="btn btn-md np-btn np-btn-md btn-positive btn-priority-2"
|
|
108
|
+
type="button"
|
|
109
|
+
>
|
|
110
|
+
Send money
|
|
111
|
+
</button>
|
|
112
|
+
</div>
|
|
113
|
+
`;
|
|
114
|
+
|
|
115
|
+
exports[`Button priorities defaults tertiary buttons to secondary for positive buttons 2`] = `
|
|
116
|
+
<div>
|
|
117
|
+
<button
|
|
118
|
+
aria-busy="false"
|
|
119
|
+
aria-disabled="false"
|
|
120
|
+
aria-live="off"
|
|
121
|
+
class="btn btn-md np-btn np-btn-md btn-negative btn-priority-2"
|
|
122
|
+
type="button"
|
|
123
|
+
>
|
|
124
|
+
Send money
|
|
125
|
+
</button>
|
|
126
|
+
</div>
|
|
127
|
+
`;
|
|
128
|
+
|
|
129
|
+
exports[`Button priorities renders primary buttons 1`] = `
|
|
130
|
+
<div>
|
|
131
|
+
<button
|
|
132
|
+
aria-busy="false"
|
|
133
|
+
aria-disabled="false"
|
|
134
|
+
aria-live="off"
|
|
135
|
+
class="btn btn-md np-btn np-btn-md btn-accent btn-priority-1"
|
|
136
|
+
type="button"
|
|
137
|
+
>
|
|
138
|
+
Send money
|
|
139
|
+
</button>
|
|
140
|
+
</div>
|
|
141
|
+
`;
|
|
142
|
+
|
|
143
|
+
exports[`Button priorities renders primary buttons 2`] = `
|
|
144
|
+
<div>
|
|
145
|
+
<button
|
|
146
|
+
aria-busy="false"
|
|
147
|
+
aria-disabled="false"
|
|
148
|
+
aria-live="off"
|
|
149
|
+
class="btn btn-md np-btn np-btn-md btn-positive btn-priority-1"
|
|
150
|
+
type="button"
|
|
151
|
+
>
|
|
152
|
+
Send money
|
|
153
|
+
</button>
|
|
154
|
+
</div>
|
|
155
|
+
`;
|
|
156
|
+
|
|
157
|
+
exports[`Button priorities renders primary buttons 3`] = `
|
|
158
|
+
<div>
|
|
159
|
+
<button
|
|
160
|
+
aria-busy="false"
|
|
161
|
+
aria-disabled="false"
|
|
162
|
+
aria-live="off"
|
|
163
|
+
class="btn btn-md np-btn np-btn-md btn-negative btn-priority-1"
|
|
164
|
+
type="button"
|
|
165
|
+
>
|
|
166
|
+
Send money
|
|
167
|
+
</button>
|
|
168
|
+
</div>
|
|
169
|
+
`;
|
|
170
|
+
|
|
171
|
+
exports[`Button priorities renders secondary buttons 1`] = `
|
|
172
|
+
<div>
|
|
173
|
+
<button
|
|
174
|
+
aria-busy="false"
|
|
175
|
+
aria-disabled="false"
|
|
176
|
+
aria-live="off"
|
|
177
|
+
class="btn btn-md np-btn np-btn-md btn-accent btn-priority-2"
|
|
178
|
+
type="button"
|
|
179
|
+
>
|
|
180
|
+
Send money
|
|
181
|
+
</button>
|
|
182
|
+
</div>
|
|
183
|
+
`;
|
|
184
|
+
|
|
185
|
+
exports[`Button priorities renders secondary buttons 2`] = `
|
|
186
|
+
<div>
|
|
187
|
+
<button
|
|
188
|
+
aria-busy="false"
|
|
189
|
+
aria-disabled="false"
|
|
190
|
+
aria-live="off"
|
|
191
|
+
class="btn btn-md np-btn np-btn-md btn-positive btn-priority-2"
|
|
192
|
+
type="button"
|
|
193
|
+
>
|
|
194
|
+
Send money
|
|
195
|
+
</button>
|
|
196
|
+
</div>
|
|
197
|
+
`;
|
|
198
|
+
|
|
199
|
+
exports[`Button priorities renders secondary buttons 3`] = `
|
|
200
|
+
<div>
|
|
201
|
+
<button
|
|
202
|
+
aria-busy="false"
|
|
203
|
+
aria-disabled="false"
|
|
204
|
+
aria-live="off"
|
|
205
|
+
class="btn btn-md np-btn np-btn-md btn-negative btn-priority-2"
|
|
206
|
+
type="button"
|
|
207
|
+
>
|
|
208
|
+
Send money
|
|
209
|
+
</button>
|
|
210
|
+
</div>
|
|
211
|
+
`;
|
|
212
|
+
|
|
213
|
+
exports[`Button priorities renders tertiary buttons 1`] = `
|
|
214
|
+
<div>
|
|
215
|
+
<button
|
|
216
|
+
aria-busy="false"
|
|
217
|
+
aria-disabled="false"
|
|
218
|
+
aria-live="off"
|
|
219
|
+
class="btn btn-md np-btn np-btn-md btn-accent btn-priority-3"
|
|
220
|
+
type="button"
|
|
221
|
+
>
|
|
222
|
+
Send money
|
|
223
|
+
</button>
|
|
224
|
+
</div>
|
|
225
|
+
`;
|
|
226
|
+
|
|
227
|
+
exports[`Button sizes renders large buttons 1`] = `
|
|
228
|
+
<div>
|
|
229
|
+
<button
|
|
230
|
+
aria-busy="false"
|
|
231
|
+
aria-disabled="false"
|
|
232
|
+
aria-live="off"
|
|
233
|
+
class="btn btn-lg np-btn np-btn-lg btn-accent btn-priority-1"
|
|
234
|
+
type="button"
|
|
235
|
+
>
|
|
236
|
+
Send money
|
|
237
|
+
</button>
|
|
238
|
+
</div>
|
|
239
|
+
`;
|
|
240
|
+
|
|
241
|
+
exports[`Button sizes renders medium buttons 1`] = `
|
|
242
|
+
<div>
|
|
243
|
+
<button
|
|
244
|
+
aria-busy="false"
|
|
245
|
+
aria-disabled="false"
|
|
246
|
+
aria-live="off"
|
|
247
|
+
class="btn btn-md np-btn np-btn-md btn-accent btn-priority-1"
|
|
248
|
+
type="button"
|
|
249
|
+
>
|
|
250
|
+
Send money
|
|
251
|
+
</button>
|
|
252
|
+
</div>
|
|
253
|
+
`;
|
|
254
|
+
|
|
255
|
+
exports[`Button sizes renders small buttons 1`] = `
|
|
256
|
+
<div>
|
|
257
|
+
<button
|
|
258
|
+
aria-busy="false"
|
|
259
|
+
aria-disabled="false"
|
|
260
|
+
aria-live="off"
|
|
261
|
+
class="btn btn-sm np-btn np-btn-sm btn-accent btn-priority-1"
|
|
262
|
+
type="button"
|
|
263
|
+
>
|
|
264
|
+
Send money
|
|
265
|
+
</button>
|
|
266
|
+
</div>
|
|
267
|
+
`;
|
|
268
|
+
|
|
269
|
+
exports[`Button types renders accent buttons 1`] = `
|
|
270
|
+
<div>
|
|
271
|
+
<button
|
|
272
|
+
aria-busy="false"
|
|
273
|
+
aria-disabled="false"
|
|
274
|
+
aria-live="off"
|
|
275
|
+
class="btn btn-md np-btn np-btn-md btn-accent btn-priority-1"
|
|
276
|
+
type="button"
|
|
277
|
+
>
|
|
278
|
+
Send money
|
|
279
|
+
</button>
|
|
280
|
+
</div>
|
|
281
|
+
`;
|
|
282
|
+
|
|
283
|
+
exports[`Button types renders negative buttons 1`] = `
|
|
284
|
+
<div>
|
|
285
|
+
<button
|
|
286
|
+
aria-busy="false"
|
|
287
|
+
aria-disabled="false"
|
|
288
|
+
aria-live="off"
|
|
289
|
+
class="btn btn-md np-btn np-btn-md btn-negative btn-priority-1"
|
|
290
|
+
type="button"
|
|
291
|
+
>
|
|
292
|
+
Send money
|
|
293
|
+
</button>
|
|
294
|
+
</div>
|
|
295
|
+
`;
|
|
296
|
+
|
|
297
|
+
exports[`Button types renders positive buttons 1`] = `
|
|
298
|
+
<div>
|
|
299
|
+
<button
|
|
300
|
+
aria-busy="false"
|
|
301
|
+
aria-disabled="false"
|
|
302
|
+
aria-live="off"
|
|
303
|
+
class="btn btn-md np-btn np-btn-md btn-positive btn-priority-1"
|
|
304
|
+
type="button"
|
|
305
|
+
>
|
|
306
|
+
Send money
|
|
307
|
+
</button>
|
|
308
|
+
</div>
|
|
309
|
+
`;
|
package/src/button/index.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { default } from './Button
|
|
2
|
-
|
|
1
|
+
export { default } from './Button';
|
|
2
|
+
|
|
3
|
+
export type { Props as ButtonProps } from './Button';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { clsx } from 'clsx';
|
|
2
2
|
|
|
3
3
|
import Body from '../body/Body';
|
|
4
|
-
import { typeClassMap, priorityClassMap } from '../button/classMap';
|
|
5
4
|
import { Breakpoint, ControlType, Priority, Typography } from '../common';
|
|
6
5
|
import IconButton, { IconButtonProps } from '../iconButton';
|
|
7
6
|
import { useMedia } from '../common/hooks/useMedia';
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { clsx } from 'clsx';
|
|
2
2
|
import Link from '../../link';
|
|
3
3
|
import { Typography } from '../propsValues/typography';
|
|
4
|
+
import ActionButton from '../../actionButton';
|
|
4
5
|
import { Priority } from '../propsValues/control';
|
|
5
|
-
import Button from '../../button';
|
|
6
|
-
import { ButtonPriority, ButtonSentiment } from '../../button/Button.types';
|
|
7
6
|
|
|
8
7
|
export type ActionOptions = {
|
|
9
8
|
'aria-label'?: string;
|
|
@@ -14,20 +13,12 @@ export type ActionOptions = {
|
|
|
14
13
|
};
|
|
15
14
|
|
|
16
15
|
type Props = {
|
|
16
|
+
variant?: 'button' | 'action-button';
|
|
17
17
|
action: ActionOptions;
|
|
18
18
|
className?: string;
|
|
19
|
-
variant?: 'button' | 'action-button';
|
|
20
|
-
sentiment?: ButtonSentiment;
|
|
21
|
-
priority?: ButtonPriority;
|
|
22
19
|
};
|
|
23
20
|
|
|
24
|
-
export function Action({
|
|
25
|
-
action,
|
|
26
|
-
className,
|
|
27
|
-
variant = 'button',
|
|
28
|
-
sentiment = 'default',
|
|
29
|
-
priority = Priority.SECONDARY,
|
|
30
|
-
}: Props) {
|
|
21
|
+
export function Action({ action, className, variant = 'button' }: Props) {
|
|
31
22
|
if ('href' in action) {
|
|
32
23
|
return (
|
|
33
24
|
<Link
|
|
@@ -43,32 +34,23 @@ export function Action({
|
|
|
43
34
|
);
|
|
44
35
|
}
|
|
45
36
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
type="button"
|
|
66
|
-
aria-label={action['aria-label']}
|
|
67
|
-
className={clsx('btn-unstyled np-text-link-large', className)}
|
|
68
|
-
onClick={action.onClick}
|
|
69
|
-
>
|
|
70
|
-
{action.text}
|
|
71
|
-
</button>
|
|
72
|
-
);
|
|
73
|
-
}
|
|
37
|
+
return variant === 'button' ? (
|
|
38
|
+
<button
|
|
39
|
+
type="button"
|
|
40
|
+
aria-label={action['aria-label']}
|
|
41
|
+
className={clsx('btn-unstyled np-text-link-large', className)}
|
|
42
|
+
onClick={action.onClick}
|
|
43
|
+
>
|
|
44
|
+
{action.text}
|
|
45
|
+
</button>
|
|
46
|
+
) : (
|
|
47
|
+
<ActionButton
|
|
48
|
+
aria-label={action['aria-label']}
|
|
49
|
+
priority={Priority.SECONDARY}
|
|
50
|
+
className={clsx(className)}
|
|
51
|
+
onClick={action.onClick}
|
|
52
|
+
>
|
|
53
|
+
{action.text}
|
|
54
|
+
</ActionButton>
|
|
55
|
+
);
|
|
74
56
|
}
|