@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
|
@@ -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\n /** Makes the button take up the full width of its container */\n block?: boolean;\n\n /**\n * The `target` attribute for HTML anchor.\n * If set to `_blank`, `rel=\"noopener noreferrer\"` is automatically added to the rendered node.\n */\n target?: string;\n /**\n * Toggles the disabled state\n * @default false\n */\n\n disabled?: boolean;\n /**\n * Toggles the loading state\n * @default false\n */\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":"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"}
|
|
@@ -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: var(--size-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,35 +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
|
-
target?: string;
|
|
8
|
-
disabled?: boolean;
|
|
9
|
-
loading?: boolean;
|
|
10
|
-
type?: import("../common").ControlTypeAccent | import("../common").ControlTypeNegative | import("../common").ControlTypePositive | ("link" | "primary" | "secondary" | "pay" | "danger") | null;
|
|
11
|
-
priority?: import("../common").PriorityPrimary | import("../common").PrioritySecondary | import("../common").PriorityTertiary | null;
|
|
12
|
-
size?: import("../common").SizeSmall | import("../common").SizeMedium | import("../common").SizeLarge | "xs";
|
|
13
|
-
htmlType?: "submit" | "reset" | "button";
|
|
14
|
-
} & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
15
|
-
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;
|
|
16
|
-
}, "type"> & {
|
|
17
|
-
as?: "button";
|
|
18
|
-
}, "ref"> | Omit<{
|
|
19
|
-
v2?: false;
|
|
20
|
-
block?: boolean;
|
|
21
|
-
target?: string;
|
|
22
|
-
disabled?: boolean;
|
|
23
|
-
loading?: boolean;
|
|
24
|
-
type?: import("../common").ControlTypeAccent | import("../common").ControlTypeNegative | import("../common").ControlTypePositive | ("link" | "primary" | "secondary" | "pay" | "danger") | null;
|
|
25
|
-
priority?: import("../common").PriorityPrimary | import("../common").PrioritySecondary | import("../common").PriorityTertiary | null;
|
|
26
|
-
size?: import("../common").SizeSmall | import("../common").SizeMedium | import("../common").SizeLarge | "xs";
|
|
27
|
-
htmlType?: "submit" | "reset" | "button";
|
|
28
|
-
} & Omit<Omit<import("react").DetailedHTMLProps<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "ref"> & {
|
|
29
|
-
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;
|
|
30
|
-
}, "type"> & {
|
|
31
|
-
as?: "a";
|
|
32
|
-
href?: string;
|
|
33
|
-
}, "ref">) & import("react").RefAttributes<ButtonReferenceType>>;
|
|
34
|
-
export default Button;
|
|
35
|
-
//# 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,70 +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
|
-
type ButtonAddonIcon = {
|
|
8
|
-
type: 'icon';
|
|
9
|
-
value: ReactNode;
|
|
10
|
-
};
|
|
11
|
-
type ButtonAddonAvatar = {
|
|
12
|
-
type: 'avatar';
|
|
13
|
-
value: AvatarLayoutProps['avatars'];
|
|
14
|
-
};
|
|
15
|
-
type ButtonAddonStart = ButtonAddonIcon | ButtonAddonAvatar;
|
|
16
|
-
type ButtonAddonEnd = ButtonAddonIcon;
|
|
17
|
-
/**
|
|
18
|
-
* Common properties for the Button component.
|
|
19
|
-
*/
|
|
20
|
-
export interface CommonProps {
|
|
21
|
-
/**
|
|
22
|
-
* If set, toggles the new Button API
|
|
23
|
-
* @default false
|
|
24
|
-
* */
|
|
25
|
-
v2: true;
|
|
26
|
-
/**
|
|
27
|
-
* The HTML element to render. Takes precedence over `href` prop.
|
|
28
|
-
* @default undefined
|
|
29
|
-
**/
|
|
30
|
-
as?: 'button' | 'a';
|
|
31
|
-
/** @default false **/
|
|
32
|
-
disabled?: boolean;
|
|
33
|
-
/** If set, the component will render as an HTML anchor. */
|
|
34
|
-
href?: string;
|
|
35
|
-
/**
|
|
36
|
-
* The `target` attribute for HTML anchor.
|
|
37
|
-
* If set to `_blank`, `rel="noopener noreferrer"` is automatically added to the rendered node.
|
|
38
|
-
*/
|
|
39
|
-
target?: string;
|
|
40
|
-
/** @default false */
|
|
41
|
-
loading?: boolean;
|
|
42
|
-
/** Makes the button take up the full width of its container */
|
|
43
|
-
block?: boolean;
|
|
44
|
-
/**
|
|
45
|
-
* Sets the size of the button
|
|
46
|
-
* @default lg
|
|
47
|
-
* */
|
|
48
|
-
size?: ButtonSize;
|
|
49
|
-
/**
|
|
50
|
-
* Sets a visual hierarchy amongst the buttons displayed on the screen
|
|
51
|
-
* @default 'primary'
|
|
52
|
-
*/
|
|
53
|
-
priority?: ButtonPriority;
|
|
54
|
-
/**
|
|
55
|
-
* Emphasises the nature of the button's action
|
|
56
|
-
* @default default
|
|
57
|
-
*/
|
|
58
|
-
sentiment?: ButtonSentiment;
|
|
59
|
-
/** Accessory to be displayed before the label */
|
|
60
|
-
addonStart?: ButtonAddonStart;
|
|
61
|
-
/** Accessory to be displayed after the label */
|
|
62
|
-
addonEnd?: ButtonAddonEnd;
|
|
63
|
-
className?: string;
|
|
64
|
-
children?: ReactNode;
|
|
65
|
-
}
|
|
66
|
-
export type ButtonElementProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'disabled' | 'className'> & CommonProps;
|
|
67
|
-
export type AnchorElementProps = Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'type' | 'disabled' | 'href' | 'className'> & CommonProps;
|
|
68
|
-
export type ButtonProps = ButtonElementProps | AnchorElementProps;
|
|
69
|
-
export {};
|
|
70
|
-
//# 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;AAC9E,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,GAAG,iBAAiB,CAAC;AACxE,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC;AACF,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAC;CACrC,CAAC;AACF,KAAK,gBAAgB,GAAG,eAAe,GAAG,iBAAiB,CAAC;AAC5D,KAAK,cAAc,GAAG,eAAe,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;;SAGK;IACL,EAAE,EAAE,IAAI,CAAC;IAET;;;QAGI;IACJ,EAAE,CAAC,EAAE,QAAQ,GAAG,GAAG,CAAC;IAEpB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,2DAA2D;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,qBAAqB;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,+DAA+D;IAC/D,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;SAGK;IACL,IAAI,CAAC,EAAE,UAAU,CAAC;IAElB;;;OAGG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAC;IAE1B;;;OAGG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;IAE5B,iDAAiD;IACjD,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAE9B,gDAAgD;IAChD,QAAQ,CAAC,EAAE,cAAc,CAAC;IAE1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACnC,oBAAoB,CAAC,iBAAiB,CAAC,EACvC,UAAU,GAAG,WAAW,CACzB,GACC,WAAW,CAAC;AACd,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,44 +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
|
-
/** Makes the button take up the full width of its container */
|
|
10
|
-
block?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* The `target` attribute for HTML anchor.
|
|
13
|
-
* If set to `_blank`, `rel="noopener noreferrer"` is automatically added to the rendered node.
|
|
14
|
-
*/
|
|
15
|
-
target?: string;
|
|
16
|
-
/**
|
|
17
|
-
* Toggles the disabled state
|
|
18
|
-
* @default false
|
|
19
|
-
*/
|
|
20
|
-
disabled?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Toggles the loading state
|
|
23
|
-
* @default false
|
|
24
|
-
*/
|
|
25
|
-
loading?: boolean;
|
|
26
|
-
type?: ControlTypeAccent | ControlTypeNegative | ControlTypePositive | DeprecatedTypes | null;
|
|
27
|
-
priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary | null;
|
|
28
|
-
size?: SizeSmall | SizeMedium | SizeLarge | DeprecatedSizes;
|
|
29
|
-
htmlType?: 'submit' | 'reset' | 'button';
|
|
30
|
-
};
|
|
31
|
-
type ButtonProps = CommonProps & Omit<React.ComponentPropsWithRef<'button'>, 'type'> & {
|
|
32
|
-
as?: 'button';
|
|
33
|
-
};
|
|
34
|
-
type AnchorProps = CommonProps & Omit<React.ComponentPropsWithRef<'a'>, 'type'> & {
|
|
35
|
-
as?: 'a';
|
|
36
|
-
href?: string;
|
|
37
|
-
};
|
|
38
|
-
export type LegacyButtonProps = ButtonProps | AnchorProps;
|
|
39
|
-
/**
|
|
40
|
-
* @deprecated make sure you use new Button component via `<Button v2 .. />` and new props
|
|
41
|
-
*/
|
|
42
|
-
declare const LegacyButton: import("react").ForwardRefExoticComponent<(Omit<ButtonProps, "ref"> | Omit<AnchorProps, "ref">) & import("react").RefAttributes<ButtonReferenceType>>;
|
|
43
|
-
export default LegacyButton;
|
|
44
|
-
//# sourceMappingURL=LegacyButton.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LegacyButton.d.ts","sourceRoot":"","sources":["../../../src/button/LegacyButton.tsx"],"names":[],"mappings":"AAIA,OAAO,EAIL,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,SAAS,EACT,UAAU,EACV,SAAS,EACV,MAAM,WAAW,CAAC;AAMnB,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,kBAAkB;AAClB,KAAK,eAAe,GAAG,SAAS,GAAG,KAAK,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE3E,kBAAkB;AAClB,KAAK,eAAe,GAAG,cAAc,CAAC;AAEtC,KAAK,WAAW,GAAG;IACjB,EAAE,CAAC,EAAE,KAAK,CAAC;IAEX,+DAA+D;IAC/D,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IAEH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,iBAAiB,GAAG,mBAAmB,GAAG,mBAAmB,GAAG,eAAe,GAAG,IAAI,CAAC;IAC9F,QAAQ,CAAC,EAAE,eAAe,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,IAAI,CAAC;IACzE,IAAI,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,eAAe,CAAC;IAC5D,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;CAC1C,CAAC;AAEF,KAAK,WAAW,GAAG,WAAW,GAC5B,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,GAAG;IACpD,EAAE,CAAC,EAAE,QAAQ,CAAC;CACf,CAAC;AAEJ,KAAK,WAAW,GAAG,WAAW,GAC5B,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG;IAC/C,EAAE,CAAC,EAAE,GAAG,CAAC;IACT,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEJ,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,WAAW,CAAC;AAE1D;;GAEG;AACH,QAAA,MAAM,YAAY,uJAkGjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { Meta, Canvas, Source } from '@storybook/blocks';
|
|
2
|
-
import { NavigationOption } from '..';
|
|
3
|
-
import { Bulb } from '@transferwise/icons';
|
|
4
|
-
import * as stories from './Button.story';
|
|
5
|
-
|
|
6
|
-
<Meta title="Actions/Button/Accessibility" />
|
|
7
|
-
|
|
8
|
-
# Accessibility
|
|
9
|
-
|
|
10
|
-
Given the `Button` is a widely used and highly sensitive component, there are some instances where care is required to ensure inclusive and accessible experience.
|
|
11
|
-
|
|
12
|
-
<NavigationOption
|
|
13
|
-
media={<Bulb size={24} />}
|
|
14
|
-
title="Design guidance"
|
|
15
|
-
content="Before you start, familiarise yourself with the dedicated accessibility documentation."
|
|
16
|
-
href="https://wise.design/components/button#accessibility"
|
|
17
|
-
/>
|
|
18
|
-
|
|
19
|
-
<br />
|
|
20
|
-
<br />
|
|
21
|
-
|
|
22
|
-
## Anchors
|
|
23
|
-
|
|
24
|
-
While it's technically possible to make the `Button` component render as a link by using `as="a"` on its own, and there are use cases for it, this will not result in a semantic HTML anchor. For that to happen, you should set `href` instead – it will automatically render the component as a semantic anchor.
|
|
25
|
-
|
|
26
|
-
<Source dark code={`
|
|
27
|
-
// ⚠️ use with care
|
|
28
|
-
<Button v2 as="a">Inaccessible anchor</Button>
|
|
29
|
-
|
|
30
|
-
// ✅ semantic link
|
|
31
|
-
|
|
32
|
-
<Button v2 href="https://wise.com">
|
|
33
|
-
Accessible anchor
|
|
34
|
-
</Button>
|
|
35
|
-
<Button v2 href="https://wise.com" as="a">
|
|
36
|
-
Accessible anchor
|
|
37
|
-
</Button>
|
|
38
|
-
`}/>
|
|
39
|
-
|
|
40
|
-
It's also worth noting that HTML links without a valid `href` are not recognised by RTL via `getByRole('link')`.
|
|
41
|
-
|
|
42
|
-
**Additional resources:**
|
|
43
|
-
|
|
44
|
-
1. [Deque: Anchors must only be used as links with valid URLs or URL fragments](https://dequeuniversity.com/rules/axe-devtools/4.2/href-no-hash)
|
|
45
|
-
2. [whatwg HTML standard: 4.6.2 Links created by a and area elements](https://html.spec.whatwg.org/multipage/links.html#links-created-by-a-and-area-elements)
|
|
46
|
-
|
|
47
|
-
<br />
|
|
48
|
-
|
|
49
|
-
## Disabled anchors
|
|
50
|
-
|
|
51
|
-
Technically, there's no such thing as disabled HTML anchor and the `disabled` attribute is not recognised on the `<a />`. While the code shown below works in all major screen readers, should be overall considered a last resort and design teams should be encouraged to use it sporadically and consider alternative flows instead.
|
|
52
|
-
|
|
53
|
-
<Source
|
|
54
|
-
dark
|
|
55
|
-
code={`
|
|
56
|
-
// ⚠️ use with care
|
|
57
|
-
<Button v2 href="https://wise.com" disabled>Emulated disabled anchor</Button>
|
|
58
|
-
`}
|
|
59
|
-
/>
|
|
60
|
-
|
|
61
|
-
We're emulating this behaviour by applying a combination of the following:
|
|
62
|
-
|
|
63
|
-
1. removing `href` attribute to strip out the link's semantics.
|
|
64
|
-
2. adding `role="link"` to make it recognisable and discoverable by the assistive tech.
|
|
65
|
-
3. setting `aria-disabled="true"` to inform assistive tech of the component state.
|
|
66
|
-
|
|
67
|
-
**Additional resources:**
|
|
68
|
-
|
|
69
|
-
1. [Scott O'Hara: Disabling a link](https://www.scottohara.me/blog/2021/05/28/disabled-links.html)
|
|
70
|
-
2. [CSS-Tricks: How to Disable Links](https://css-tricks.com/how-to-disable-links/)
|
|
71
|
-
|
|
72
|
-
<br />
|
|
73
|
-
|
|
74
|
-
## Loading state
|
|
75
|
-
|
|
76
|
-
While it might be tempting to use the native, HTML `disabled` attribute for the `loading` state, it would result in a component that is completely invisible to the assistive tech – not focusable and not parsable – entirely inaccessible experience for users relying on such tools.
|
|
77
|
-
|
|
78
|
-
Instead, we're relying on ARIA attributes and roles to ensure the `Button` is focusable, correctly announced as "busy" and offering visual cue different to the disabled state.
|
|
79
|
-
|
|
80
|
-
<Source dark code={`
|
|
81
|
-
// ❌ do not use
|
|
82
|
-
<Button v2 loading disabled>Invisible</Button>
|
|
83
|
-
|
|
84
|
-
// ✅ semantic loading button
|
|
85
|
-
|
|
86
|
-
<Button v2 loading>
|
|
87
|
-
Proper loading state
|
|
88
|
-
</Button>
|
|
89
|
-
`}/>
|
|
90
|
-
|
|
91
|
-
`Button` instances rendered as HTML anchors, follow the strategy described in the [Disabled anchors](#disabled-anchors) section above.
|
|
92
|
-
|
|
93
|
-
<br />
|
|
94
|
-
|
|
95
|
-
## Working with addons (accessories)
|
|
96
|
-
|
|
97
|
-
One of the core requirements of accessible experience is that all users have equal access to the same content, no matter how they interact with our products.
|
|
98
|
-
|
|
99
|
-
This becomes troublesome for more complex instances of the `Button` such as those with contentful icons or avatars, e.g. those referring to particular currencies, people or action types.
|
|
100
|
-
|
|
101
|
-
Exposing separate ARIA labels for such addons would likely become problematic due to syntactic differences between different languages and so instead we recommend using simple `aria-label` attribute to describe given components complete content. Please note, that screen readers will use that text over the visible label
|
|
102
|
-
|
|
103
|
-
<Canvas of={stories.AccessibilityAddons} />
|
|
@@ -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;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Meta } from '@storybook/react';
|
|
2
|
-
import Button from './Button.resolver';
|
|
3
|
-
import { expect, userEvent, within } from '@storybook/test';
|
|
4
|
-
import { storyConfig } from '../test-utils';
|
|
5
|
-
|
|
6
|
-
const meta: Meta<typeof Button> = {
|
|
7
|
-
component: Button,
|
|
8
|
-
title: 'Actions/Button/Tests',
|
|
9
|
-
};
|
|
10
|
-
export default meta;
|
|
11
|
-
|
|
12
|
-
export const FocusMinimal = storyConfig(
|
|
13
|
-
{
|
|
14
|
-
render: () => (
|
|
15
|
-
<Button v2 priority="minimal">
|
|
16
|
-
Focus has underline
|
|
17
|
-
</Button>
|
|
18
|
-
),
|
|
19
|
-
},
|
|
20
|
-
{},
|
|
21
|
-
);
|
|
22
|
-
FocusMinimal.play = async ({ canvasElement }) => {
|
|
23
|
-
await userEvent.tab();
|
|
24
|
-
const canvas = within(canvasElement);
|
|
25
|
-
const buttonElement: HTMLButtonElement = canvas.getByRole('button');
|
|
26
|
-
await expect(buttonElement).toHaveFocus();
|
|
27
|
-
};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { AnchorHTMLAttributes, ButtonHTMLAttributes, ReactNode } from 'react';
|
|
2
|
-
import type { AvatarLayoutProps } from '../avatarLayout';
|
|
3
|
-
|
|
4
|
-
export type ButtonSentiment = 'default' | 'negative';
|
|
5
|
-
export type ButtonPriority = 'primary' | 'secondary' | 'tertiary' | 'minimal';
|
|
6
|
-
export type ButtonSize = 'sm' | 'md' | 'lg';
|
|
7
|
-
export type ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;
|
|
8
|
-
type ButtonAddonIcon = {
|
|
9
|
-
type: 'icon';
|
|
10
|
-
value: ReactNode;
|
|
11
|
-
};
|
|
12
|
-
type ButtonAddonAvatar = {
|
|
13
|
-
type: 'avatar';
|
|
14
|
-
value: AvatarLayoutProps['avatars'];
|
|
15
|
-
};
|
|
16
|
-
type ButtonAddonStart = ButtonAddonIcon | ButtonAddonAvatar;
|
|
17
|
-
type ButtonAddonEnd = ButtonAddonIcon;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Common properties for the Button component.
|
|
21
|
-
*/
|
|
22
|
-
export interface CommonProps {
|
|
23
|
-
/**
|
|
24
|
-
* If set, toggles the new Button API
|
|
25
|
-
* @default false
|
|
26
|
-
* */
|
|
27
|
-
v2: true;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* The HTML element to render. Takes precedence over `href` prop.
|
|
31
|
-
* @default undefined
|
|
32
|
-
**/
|
|
33
|
-
as?: 'button' | 'a';
|
|
34
|
-
|
|
35
|
-
/** @default false **/
|
|
36
|
-
disabled?: boolean;
|
|
37
|
-
|
|
38
|
-
/** If set, the component will render as an HTML anchor. */
|
|
39
|
-
href?: string;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* The `target` attribute for HTML anchor.
|
|
43
|
-
* If set to `_blank`, `rel="noopener noreferrer"` is automatically added to the rendered node.
|
|
44
|
-
*/
|
|
45
|
-
target?: string;
|
|
46
|
-
|
|
47
|
-
/** @default false */
|
|
48
|
-
loading?: boolean;
|
|
49
|
-
|
|
50
|
-
/** Makes the button take up the full width of its container */
|
|
51
|
-
block?: boolean;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Sets the size of the button
|
|
55
|
-
* @default lg
|
|
56
|
-
* */
|
|
57
|
-
size?: ButtonSize;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Sets a visual hierarchy amongst the buttons displayed on the screen
|
|
61
|
-
* @default 'primary'
|
|
62
|
-
*/
|
|
63
|
-
priority?: ButtonPriority;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Emphasises the nature of the button's action
|
|
67
|
-
* @default default
|
|
68
|
-
*/
|
|
69
|
-
sentiment?: ButtonSentiment;
|
|
70
|
-
|
|
71
|
-
/** Accessory to be displayed before the label */
|
|
72
|
-
addonStart?: ButtonAddonStart;
|
|
73
|
-
|
|
74
|
-
/** Accessory to be displayed after the label */
|
|
75
|
-
addonEnd?: ButtonAddonEnd;
|
|
76
|
-
|
|
77
|
-
className?: string;
|
|
78
|
-
children?: ReactNode;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export type ButtonElementProps = Omit<
|
|
82
|
-
ButtonHTMLAttributes<HTMLButtonElement>,
|
|
83
|
-
'disabled' | 'className'
|
|
84
|
-
> &
|
|
85
|
-
CommonProps;
|
|
86
|
-
export type AnchorElementProps = Omit<
|
|
87
|
-
AnchorHTMLAttributes<HTMLAnchorElement>,
|
|
88
|
-
'type' | 'disabled' | 'href' | 'className'
|
|
89
|
-
> &
|
|
90
|
-
CommonProps;
|
|
91
|
-
|
|
92
|
-
export type ButtonProps = ButtonElementProps | AnchorElementProps;
|