@transferwise/components 0.0.0-experimental-6528439 → 0.0.0-experimental-1ffdc56
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 +33 -17
- package/build/alert/Alert.js.map +1 -1
- package/build/alert/Alert.mjs +30 -14
- package/build/alert/Alert.mjs.map +1 -1
- package/build/avatarLayout/AvatarLayout.js +9 -2
- package/build/avatarLayout/AvatarLayout.js.map +1 -1
- package/build/avatarLayout/AvatarLayout.mjs +9 -2
- package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
- package/build/button/Button.js +86 -79
- package/build/button/Button.js.map +1 -1
- package/build/button/Button.mjs +87 -80
- package/build/button/Button.mjs.map +1 -1
- package/build/button/Button.resolver.js +74 -0
- package/build/button/Button.resolver.js.map +1 -0
- package/build/button/Button.resolver.mjs +72 -0
- package/build/button/Button.resolver.mjs.map +1 -0
- package/build/button/LegacyButton.js +114 -0
- package/build/button/LegacyButton.js.map +1 -0
- package/build/button/LegacyButton.mjs +112 -0
- package/build/button/LegacyButton.mjs.map +1 -0
- package/build/common/action/Action.js +26 -15
- package/build/common/action/Action.js.map +1 -1
- package/build/common/action/Action.mjs +26 -15
- package/build/common/action/Action.mjs.map +1 -1
- package/build/common/propsValues/sentiment.js +1 -0
- package/build/common/propsValues/sentiment.js.map +1 -1
- package/build/common/propsValues/sentiment.mjs +1 -0
- package/build/common/propsValues/sentiment.mjs.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.js +10 -73
- package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.mjs +11 -74
- package/build/criticalBanner/CriticalCommsBanner.mjs.map +1 -1
- package/build/dimmer/Dimmer.js +67 -41
- package/build/dimmer/Dimmer.js.map +1 -1
- package/build/dimmer/Dimmer.mjs +69 -43
- package/build/dimmer/Dimmer.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 +1 -0
- package/build/i18n/en.json.js +1 -0
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +1 -0
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/index.js +2 -2
- package/build/index.mjs +1 -1
- package/build/inputs/_BottomSheet.js +8 -1
- package/build/inputs/_BottomSheet.js.map +1 -1
- package/build/inputs/_BottomSheet.mjs +9 -2
- package/build/inputs/_BottomSheet.mjs.map +1 -1
- package/build/inputs/_Popover.js +8 -1
- package/build/inputs/_Popover.js.map +1 -1
- package/build/inputs/_Popover.mjs +9 -2
- package/build/inputs/_Popover.mjs.map +1 -1
- package/build/link/Link.js +8 -3
- package/build/link/Link.js.map +1 -1
- package/build/link/Link.mjs +8 -3
- package/build/link/Link.mjs.map +1 -1
- package/build/main.css +250 -72
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js +2 -4
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js.map +1 -1
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs +2 -4
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs.map +1 -1
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.js +3 -5
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.js.map +1 -1
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs +3 -5
- 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 +5 -1
- package/build/statusIcon/StatusIcon.js.map +1 -1
- package/build/statusIcon/StatusIcon.messages.js +3 -0
- package/build/statusIcon/StatusIcon.messages.js.map +1 -1
- package/build/statusIcon/StatusIcon.messages.mjs +3 -0
- package/build/statusIcon/StatusIcon.messages.mjs.map +1 -1
- package/build/statusIcon/StatusIcon.mjs +5 -1
- package/build/statusIcon/StatusIcon.mjs.map +1 -1
- package/build/styles/avatarLayout/AvatarLayout.css +11 -0
- package/build/styles/button/Button.css +220 -15
- package/build/styles/button/Button.vars.css +46 -0
- package/build/styles/button/LegacyButton.css +23 -0
- package/build/styles/criticalBanner/CriticalCommsBanner.css +7 -72
- package/build/styles/main.css +250 -72
- package/build/styles/statusIcon/StatusIcon.css +4 -0
- package/build/types/alert/Alert.d.ts +2 -1
- 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 +2 -23
- package/build/types/button/Button.d.ts.map +1 -1
- package/build/types/button/Button.resolver.d.ts +35 -0
- package/build/types/button/Button.resolver.d.ts.map +1 -0
- package/build/types/button/Button.types.d.ts +70 -0
- package/build/types/button/Button.types.d.ts.map +1 -0
- package/build/types/button/LegacyButton.d.ts +44 -0
- package/build/types/button/LegacyButton.d.ts.map +1 -0
- package/build/types/button/index.d.ts +2 -2
- package/build/types/button/index.d.ts.map +1 -1
- package/build/types/common/action/Action.d.ts +4 -1
- package/build/types/common/action/Action.d.ts.map +1 -1
- package/build/types/common/propsValues/sentiment.d.ts +1 -0
- package/build/types/common/propsValues/sentiment.d.ts.map +1 -1
- package/build/types/criticalBanner/CriticalCommsBanner.d.ts.map +1 -1
- package/build/types/dimmer/Dimmer.d.ts.map +1 -1
- package/build/types/inputs/_BottomSheet.d.ts.map +1 -1
- package/build/types/inputs/_Popover.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 +6 -2
- 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 +5 -0
- package/build/types/statusIcon/StatusIcon.messages.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts +2 -0
- 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/types/withNextPortal/withNextPortal.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/build/withNextPortal/withNextPortal.js +2 -5
- package/build/withNextPortal/withNextPortal.js.map +1 -1
- package/build/withNextPortal/withNextPortal.mjs +2 -5
- package/build/withNextPortal/withNextPortal.mjs.map +1 -1
- package/package.json +5 -5
- package/src/alert/Alert.story.tsx +36 -0
- package/src/alert/Alert.tests.story.tsx +1 -1
- package/src/alert/Alert.tsx +37 -8
- package/src/avatarLayout/AvatarLayout.css +11 -0
- package/src/avatarLayout/AvatarLayout.less +18 -1
- package/src/avatarLayout/AvatarLayout.tsx +10 -2
- package/src/button/Button.accessibility.docs.mdx +103 -0
- package/src/button/Button.css +220 -15
- package/src/button/Button.less +228 -13
- package/src/button/Button.resolver.tsx +73 -0
- package/src/button/Button.spec.tsx +215 -226
- package/src/button/Button.story.tsx +761 -134
- package/src/button/Button.tests.story.tsx +27 -0
- package/src/button/Button.tsx +99 -132
- package/src/button/Button.types.ts +92 -0
- package/src/button/Button.vars.css +46 -0
- package/src/button/Button.vars.less +57 -0
- package/src/button/LegacyButton.css +23 -0
- package/src/button/LegacyButton.less +24 -0
- package/src/button/LegacyButton.spec.tsx +147 -0
- package/src/button/LegacyButton.story.tsx +228 -0
- package/src/button/LegacyButton.tsx +177 -0
- package/src/button/index.ts +2 -3
- package/src/common/action/Action.tsx +39 -21
- package/src/common/bottomSheet/BottomSheet.spec.tsx +3 -6
- package/src/common/bottomSheet/__snapshots__/BottomSheet.spec.tsx.snap +1 -5
- package/src/common/propsValues/sentiment.ts +1 -0
- package/src/criticalBanner/CriticalCommsBanner.css +7 -72
- package/src/criticalBanner/CriticalCommsBanner.less +12 -73
- package/src/criticalBanner/CriticalCommsBanner.story.tsx +13 -9
- package/src/criticalBanner/CriticalCommsBanner.tsx +8 -50
- package/src/dimmer/Dimmer.tsx +72 -44
- package/src/field/Field.story.tsx +1 -1
- package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +1 -2
- package/src/i18n/en.json +1 -0
- package/src/inputs/SelectInput.story.tsx +1 -1
- package/src/inputs/_BottomSheet.tsx +9 -3
- package/src/inputs/_Popover.tsx +10 -4
- package/src/label/Label.story.tsx +1 -1
- package/src/link/Link.tsx +15 -6
- package/src/main.css +250 -72
- package/src/main.less +1 -0
- package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx +2 -8
- package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.ts +7 -2
- package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +1 -3
- package/src/primitives/PrimitiveButton/src/PrimitiveButton.tsx +4 -12
- package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +16 -13
- package/src/statusIcon/StatusIcon.css +4 -0
- package/src/statusIcon/StatusIcon.less +4 -0
- package/src/statusIcon/StatusIcon.messages.ts +6 -0
- package/src/statusIcon/StatusIcon.tsx +8 -1
- package/src/test-utils/Parameters.d.ts +9 -1
- package/src/test-utils/story-config.ts +10 -1
- package/src/withNextPortal/withNextPortal.tsx +1 -10
- package/src/button/__snapshots__/Button.spec.tsx.snap +0 -309
package/build/button/Button.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var clsx = require('clsx');
|
|
4
3
|
var React = require('react');
|
|
5
|
-
var
|
|
4
|
+
var PrimitiveButton = require('../primitives/PrimitiveButton/src/PrimitiveButton.js');
|
|
5
|
+
var PrimitiveAnchor = require('../primitives/PrimitiveAnchor/src/PrimitiveAnchor.js');
|
|
6
|
+
var AvatarLayout = require('../avatarLayout/AvatarLayout.js');
|
|
7
|
+
var ProcessIndicator = require('../processIndicator/ProcessIndicator.js');
|
|
8
|
+
var clsx = require('clsx');
|
|
6
9
|
require('../common/theme.js');
|
|
7
10
|
require('../common/direction.js');
|
|
8
|
-
|
|
11
|
+
require('../common/propsValues/control.js');
|
|
9
12
|
require('../common/propsValues/breakpoint.js');
|
|
10
|
-
|
|
11
|
-
require('../common/propsValues/typography.js');
|
|
13
|
+
require('../common/propsValues/size.js');
|
|
14
|
+
var typography = require('../common/propsValues/typography.js');
|
|
12
15
|
require('../common/propsValues/width.js');
|
|
13
16
|
require('../common/propsValues/type.js');
|
|
14
17
|
require('../common/propsValues/dateMode.js');
|
|
@@ -23,90 +26,94 @@ require('../common/propsValues/scroll.js');
|
|
|
23
26
|
require('../common/propsValues/markdownNodeType.js');
|
|
24
27
|
require('../common/fileType.js');
|
|
25
28
|
require('@transferwise/icons');
|
|
29
|
+
require('react-intl');
|
|
26
30
|
require('../common/closeButton/CloseButton.messages.js');
|
|
27
31
|
var jsxRuntime = require('react/jsx-runtime');
|
|
28
|
-
var
|
|
29
|
-
var Button_messages = require('../i18n/commonMessages/Button.messages.js');
|
|
30
|
-
var classMap = require('./classMap.js');
|
|
31
|
-
var legacyUtils = require('./legacyUtils/legacyUtils.js');
|
|
32
|
+
var Body = require('../body/Body.js');
|
|
32
33
|
|
|
34
|
+
/* eslint-disable react/display-name */
|
|
35
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
33
36
|
const Button = /*#__PURE__*/React.forwardRef(({
|
|
34
|
-
as
|
|
35
|
-
block = false,
|
|
37
|
+
as,
|
|
36
38
|
children,
|
|
37
39
|
className,
|
|
38
|
-
|
|
40
|
+
size = 'lg',
|
|
41
|
+
href,
|
|
42
|
+
disabled = false,
|
|
43
|
+
priority = 'primary',
|
|
44
|
+
sentiment = 'default',
|
|
45
|
+
addonStart,
|
|
46
|
+
addonEnd,
|
|
47
|
+
// @ts-expect-error NewButtonProps has `type` prop
|
|
48
|
+
type = 'button',
|
|
39
49
|
loading = false,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
block = false,
|
|
51
|
+
v2,
|
|
52
|
+
...props
|
|
53
|
+
}, ref) => {
|
|
54
|
+
const classNames = clsx.clsx('wds-Button', {
|
|
55
|
+
[`wds-Button--block`]: block,
|
|
56
|
+
[`wds-Button--disabled`]: disabled,
|
|
57
|
+
[`wds-Button--loading`]: loading
|
|
58
|
+
}, `wds-Button--${{
|
|
59
|
+
sm: 'small',
|
|
60
|
+
md: 'medium',
|
|
61
|
+
lg: 'large'
|
|
62
|
+
}[size]}`, `wds-Button--${priority}`, `wds-Button--${sentiment}`, className);
|
|
63
|
+
const contentClassNames = clsx.clsx('wds-Button-content', {
|
|
64
|
+
[`wds-Button-content--loading`]: loading
|
|
50
65
|
});
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
66
|
+
const content = /*#__PURE__*/jsxRuntime.jsxs(Body, {
|
|
67
|
+
as: "span",
|
|
68
|
+
type: size === 'sm' ? typography.Typography.BODY_DEFAULT_BOLD : typography.Typography.BODY_LARGE_BOLD,
|
|
69
|
+
className: contentClassNames,
|
|
70
|
+
children: [loading && /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator, {
|
|
71
|
+
size: size === 'sm' ? 'xxs' : 'xs',
|
|
72
|
+
className: "wds-Button-loader",
|
|
73
|
+
"data-testid": "button-loader-indicator"
|
|
74
|
+
}), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
75
|
+
className: "wds-Button-label",
|
|
76
|
+
"aria-hidden": loading,
|
|
77
|
+
children: size === 'lg' ? children : /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
78
|
+
children: [size === 'md' && addonStart?.type === 'avatar' && addonStart.value && /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
79
|
+
className: "wds-Button-avatars",
|
|
80
|
+
children: /*#__PURE__*/jsxRuntime.jsx(AvatarLayout, {
|
|
81
|
+
orientation: "horizontal",
|
|
82
|
+
avatars: addonStart?.value,
|
|
83
|
+
size: 24
|
|
84
|
+
})
|
|
85
|
+
}), addonStart?.type === 'icon' && addonStart.value && /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
86
|
+
className: "wds-Button-icon wds-Button-icon--start",
|
|
87
|
+
children: addonStart.value
|
|
88
|
+
}), children, addonEnd?.type === 'icon' && addonEnd?.value && /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
89
|
+
className: "wds-Button-icon wds-Button-icon--end",
|
|
90
|
+
children: addonEnd.value
|
|
91
|
+
})]
|
|
92
|
+
})
|
|
93
|
+
})]
|
|
94
|
+
});
|
|
95
|
+
if (href && as !== 'button' || as === 'a') {
|
|
96
|
+
return /*#__PURE__*/jsxRuntime.jsx(PrimitiveAnchor, {
|
|
97
|
+
ref: ref,
|
|
98
|
+
...props,
|
|
99
|
+
href: href,
|
|
100
|
+
className: classNames,
|
|
101
|
+
disabled: disabled || loading,
|
|
102
|
+
"aria-busy": loading || undefined,
|
|
103
|
+
type: undefined,
|
|
104
|
+
children: content
|
|
105
|
+
});
|
|
85
106
|
}
|
|
86
|
-
|
|
87
|
-
|
|
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: reference,
|
|
99
|
-
className: classes,
|
|
100
|
-
onClick: handleClick(onClick),
|
|
107
|
+
return /*#__PURE__*/jsxRuntime.jsx(PrimitiveButton, {
|
|
108
|
+
ref: ref,
|
|
101
109
|
...props,
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
})]
|
|
110
|
+
className: classNames,
|
|
111
|
+
disabled: disabled,
|
|
112
|
+
loading: loading,
|
|
113
|
+
type: type,
|
|
114
|
+
href: undefined,
|
|
115
|
+
target: undefined,
|
|
116
|
+
children: content
|
|
110
117
|
});
|
|
111
118
|
});
|
|
112
119
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../../src/button/Button.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"Button.js","sources":["../../src/button/Button.tsx"],"sourcesContent":["/* eslint-disable react/display-name */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport { forwardRef } from 'react';\nimport { ButtonReferenceType, ButtonProps as NewButtonProps } from './Button.types';\nimport { PrimitiveAnchor, PrimitiveButton } from '../primitives';\nimport AvatarLayout from '../avatarLayout';\nimport ProcessIndicator from '../processIndicator';\nimport { clsx } from 'clsx';\nimport { Typography } from '../common';\nimport Body from '../body';\n\nconst Button = forwardRef<ButtonReferenceType, NewButtonProps>(\n (\n {\n as,\n children,\n className,\n size = 'lg',\n href,\n disabled = false,\n priority = 'primary',\n sentiment = 'default',\n addonStart,\n addonEnd,\n // @ts-expect-error NewButtonProps has `type` prop\n type = 'button',\n loading = false,\n block = false,\n v2,\n ...props\n },\n ref,\n ) => {\n const classNames = clsx(\n 'wds-Button',\n {\n [`wds-Button--block`]: block,\n [`wds-Button--disabled`]: disabled,\n [`wds-Button--loading`]: loading,\n },\n `wds-Button--${{ sm: 'small', md: 'medium', lg: 'large' }[size]}`,\n `wds-Button--${priority}`,\n `wds-Button--${sentiment}`,\n className,\n );\n\n const contentClassNames = clsx('wds-Button-content', {\n [`wds-Button-content--loading`]: loading,\n });\n\n const content = (\n <Body\n as=\"span\"\n type={size === 'sm' ? Typography.BODY_DEFAULT_BOLD : Typography.BODY_LARGE_BOLD}\n className={contentClassNames}\n >\n {loading && (\n <ProcessIndicator\n size={size === 'sm' ? 'xxs' : 'xs'}\n className=\"wds-Button-loader\"\n data-testid=\"button-loader-indicator\"\n />\n )}\n <span className=\"wds-Button-label\" aria-hidden={loading}>\n {size === 'lg' ? (\n children\n ) : (\n <>\n {size === 'md' && addonStart?.type === 'avatar' && addonStart.value && (\n <span className=\"wds-Button-avatars\">\n <AvatarLayout orientation=\"horizontal\" avatars={addonStart?.value} size={24} />\n </span>\n )}\n\n {addonStart?.type === 'icon' && addonStart.value && (\n <span className=\"wds-Button-icon wds-Button-icon--start\">{addonStart.value}</span>\n )}\n\n {children}\n\n {addonEnd?.type === 'icon' && addonEnd?.value && (\n <span className=\"wds-Button-icon wds-Button-icon--end\">{addonEnd.value}</span>\n )}\n </>\n )}\n </span>\n </Body>\n );\n\n if ((href && as !== 'button') || as === 'a') {\n return (\n <PrimitiveAnchor\n ref={ref as React.Ref<HTMLAnchorElement>}\n {...(props as any)}\n href={href}\n className={classNames}\n disabled={disabled || loading}\n aria-busy={loading || undefined}\n type={undefined}\n >\n {content}\n </PrimitiveAnchor>\n );\n }\n\n return (\n <PrimitiveButton\n ref={ref as React.Ref<HTMLButtonElement>}\n {...(props as any)}\n className={classNames}\n disabled={disabled}\n loading={loading}\n type={type}\n href={undefined}\n target={undefined}\n >\n {content}\n </PrimitiveButton>\n );\n },\n);\n\nexport default Button;\n"],"names":["Button","forwardRef","as","children","className","size","href","disabled","priority","sentiment","addonStart","addonEnd","type","loading","block","v2","props","ref","classNames","clsx","sm","md","lg","contentClassNames","content","_jsxs","Body","Typography","BODY_DEFAULT_BOLD","BODY_LARGE_BOLD","_jsx","ProcessIndicator","_Fragment","value","AvatarLayout","orientation","avatars","PrimitiveAnchor","undefined","PrimitiveButton","target"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAUA,MAAMA,MAAM,gBAAGC,gBAAU,CACvB,CACE;EACEC,EAAE;EACFC,QAAQ;EACRC,SAAS;AACTC,EAAAA,IAAI,GAAG,IAAI;EACXC,IAAI;AACJC,EAAAA,QAAQ,GAAG,KAAK;AAChBC,EAAAA,QAAQ,GAAG,SAAS;AACpBC,EAAAA,SAAS,GAAG,SAAS;EACrBC,UAAU;EACVC,QAAQ;AACR;AACAC,EAAAA,IAAI,GAAG,QAAQ;AACfC,EAAAA,OAAO,GAAG,KAAK;AACfC,EAAAA,KAAK,GAAG,KAAK;EACbC,EAAE;EACF,GAAGC,KAAAA;CACJ,EACDC,GAAG,KACD;AACF,EAAA,MAAMC,UAAU,GAAGC,SAAI,CACrB,YAAY,EACZ;IACE,CAAC,CAAA,iBAAA,CAAmB,GAAGL,KAAK;IAC5B,CAAC,CAAA,oBAAA,CAAsB,GAAGP,QAAQ;AAClC,IAAA,CAAC,qBAAqB,GAAGM,OAAAA;AAC1B,GAAA,EACD,CAAe,YAAA,EAAA;AAAEO,IAAAA,EAAE,EAAE,OAAO;A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AACjBD,IAAAA,IAAI,EAAEA,IAAK;AACXN,IAAAA,IAAI,EAAEgC,SAAU;AAChBE,IAAAA,MAAM,EAAEF,SAAU;AAAAnC,IAAAA,QAAA,EAEjBqB,OAAAA;AAAO,GACO,CAAC,CAAA;AAEtB,CAAC;;;;"}
|
package/build/button/Button.mjs
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { clsx } from 'clsx';
|
|
2
1
|
import { forwardRef } from 'react';
|
|
3
|
-
import
|
|
2
|
+
import PrimitiveButton from '../primitives/PrimitiveButton/src/PrimitiveButton.mjs';
|
|
3
|
+
import PrimitiveAnchor from '../primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs';
|
|
4
|
+
import AvatarLayout from '../avatarLayout/AvatarLayout.mjs';
|
|
5
|
+
import ProcessIndicator from '../processIndicator/ProcessIndicator.mjs';
|
|
6
|
+
import { clsx } from 'clsx';
|
|
4
7
|
import '../common/theme.mjs';
|
|
5
8
|
import '../common/direction.mjs';
|
|
6
|
-
import
|
|
9
|
+
import '../common/propsValues/control.mjs';
|
|
7
10
|
import '../common/propsValues/breakpoint.mjs';
|
|
8
|
-
import
|
|
9
|
-
import '../common/propsValues/typography.mjs';
|
|
11
|
+
import '../common/propsValues/size.mjs';
|
|
12
|
+
import { Typography } from '../common/propsValues/typography.mjs';
|
|
10
13
|
import '../common/propsValues/width.mjs';
|
|
11
14
|
import '../common/propsValues/type.mjs';
|
|
12
15
|
import '../common/propsValues/dateMode.mjs';
|
|
@@ -21,90 +24,94 @@ import '../common/propsValues/scroll.mjs';
|
|
|
21
24
|
import '../common/propsValues/markdownNodeType.mjs';
|
|
22
25
|
import '../common/fileType.mjs';
|
|
23
26
|
import '@transferwise/icons';
|
|
27
|
+
import 'react-intl';
|
|
24
28
|
import '../common/closeButton/CloseButton.messages.mjs';
|
|
25
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
26
|
-
import
|
|
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';
|
|
29
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
30
|
+
import Body from '../body/Body.mjs';
|
|
30
31
|
|
|
32
|
+
/* eslint-disable react/display-name */
|
|
33
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
31
34
|
const Button = /*#__PURE__*/forwardRef(({
|
|
32
|
-
as
|
|
33
|
-
block = false,
|
|
35
|
+
as,
|
|
34
36
|
children,
|
|
35
37
|
className,
|
|
36
|
-
|
|
38
|
+
size = 'lg',
|
|
39
|
+
href,
|
|
40
|
+
disabled = false,
|
|
41
|
+
priority = 'primary',
|
|
42
|
+
sentiment = 'default',
|
|
43
|
+
addonStart,
|
|
44
|
+
addonEnd,
|
|
45
|
+
// @ts-expect-error NewButtonProps has `type` prop
|
|
46
|
+
type = 'button',
|
|
37
47
|
loading = false,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
block = false,
|
|
49
|
+
v2,
|
|
50
|
+
...props
|
|
51
|
+
}, ref) => {
|
|
52
|
+
const classNames = clsx('wds-Button', {
|
|
53
|
+
[`wds-Button--block`]: block,
|
|
54
|
+
[`wds-Button--disabled`]: disabled,
|
|
55
|
+
[`wds-Button--loading`]: loading
|
|
56
|
+
}, `wds-Button--${{
|
|
57
|
+
sm: 'small',
|
|
58
|
+
md: 'medium',
|
|
59
|
+
lg: 'large'
|
|
60
|
+
}[size]}`, `wds-Button--${priority}`, `wds-Button--${sentiment}`, className);
|
|
61
|
+
const contentClassNames = clsx('wds-Button-content', {
|
|
62
|
+
[`wds-Button-content--loading`]: loading
|
|
48
63
|
});
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
64
|
+
const content = /*#__PURE__*/jsxs(Body, {
|
|
65
|
+
as: "span",
|
|
66
|
+
type: size === 'sm' ? Typography.BODY_DEFAULT_BOLD : Typography.BODY_LARGE_BOLD,
|
|
67
|
+
className: contentClassNames,
|
|
68
|
+
children: [loading && /*#__PURE__*/jsx(ProcessIndicator, {
|
|
69
|
+
size: size === 'sm' ? 'xxs' : 'xs',
|
|
70
|
+
className: "wds-Button-loader",
|
|
71
|
+
"data-testid": "button-loader-indicator"
|
|
72
|
+
}), /*#__PURE__*/jsx("span", {
|
|
73
|
+
className: "wds-Button-label",
|
|
74
|
+
"aria-hidden": loading,
|
|
75
|
+
children: size === 'lg' ? children : /*#__PURE__*/jsxs(Fragment, {
|
|
76
|
+
children: [size === 'md' && addonStart?.type === 'avatar' && addonStart.value && /*#__PURE__*/jsx("span", {
|
|
77
|
+
className: "wds-Button-avatars",
|
|
78
|
+
children: /*#__PURE__*/jsx(AvatarLayout, {
|
|
79
|
+
orientation: "horizontal",
|
|
80
|
+
avatars: addonStart?.value,
|
|
81
|
+
size: 24
|
|
82
|
+
})
|
|
83
|
+
}), addonStart?.type === 'icon' && addonStart.value && /*#__PURE__*/jsx("span", {
|
|
84
|
+
className: "wds-Button-icon wds-Button-icon--start",
|
|
85
|
+
children: addonStart.value
|
|
86
|
+
}), children, addonEnd?.type === 'icon' && addonEnd?.value && /*#__PURE__*/jsx("span", {
|
|
87
|
+
className: "wds-Button-icon wds-Button-icon--end",
|
|
88
|
+
children: addonEnd.value
|
|
89
|
+
})]
|
|
90
|
+
})
|
|
91
|
+
})]
|
|
92
|
+
});
|
|
93
|
+
if (href && as !== 'button' || as === 'a') {
|
|
94
|
+
return /*#__PURE__*/jsx(PrimitiveAnchor, {
|
|
95
|
+
ref: ref,
|
|
96
|
+
...props,
|
|
97
|
+
href: href,
|
|
98
|
+
className: classNames,
|
|
99
|
+
disabled: disabled || loading,
|
|
100
|
+
"aria-busy": loading || undefined,
|
|
101
|
+
type: undefined,
|
|
102
|
+
children: content
|
|
103
|
+
});
|
|
83
104
|
}
|
|
84
|
-
|
|
85
|
-
|
|
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: reference,
|
|
97
|
-
className: classes,
|
|
98
|
-
onClick: handleClick(onClick),
|
|
105
|
+
return /*#__PURE__*/jsx(PrimitiveButton, {
|
|
106
|
+
ref: ref,
|
|
99
107
|
...props,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
})]
|
|
108
|
+
className: classNames,
|
|
109
|
+
disabled: disabled,
|
|
110
|
+
loading: loading,
|
|
111
|
+
type: type,
|
|
112
|
+
href: undefined,
|
|
113
|
+
target: undefined,
|
|
114
|
+
children: content
|
|
108
115
|
});
|
|
109
116
|
});
|
|
110
117
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.mjs","sources":["../../src/button/Button.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"Button.mjs","sources":["../../src/button/Button.tsx"],"sourcesContent":["/* eslint-disable react/display-name */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport { forwardRef } from 'react';\nimport { ButtonReferenceType, ButtonProps as NewButtonProps } from './Button.types';\nimport { PrimitiveAnchor, PrimitiveButton } from '../primitives';\nimport AvatarLayout from '../avatarLayout';\nimport ProcessIndicator from '../processIndicator';\nimport { clsx } from 'clsx';\nimport { Typography } from '../common';\nimport Body from '../body';\n\nconst Button = forwardRef<ButtonReferenceType, NewButtonProps>(\n (\n {\n as,\n children,\n className,\n size = 'lg',\n href,\n disabled = false,\n priority = 'primary',\n sentiment = 'default',\n addonStart,\n addonEnd,\n // @ts-expect-error NewButtonProps has `type` prop\n type = 'button',\n loading = false,\n block = false,\n v2,\n ...props\n },\n ref,\n ) => {\n const classNames = clsx(\n 'wds-Button',\n {\n [`wds-Button--block`]: block,\n [`wds-Button--disabled`]: disabled,\n [`wds-Button--loading`]: loading,\n },\n `wds-Button--${{ sm: 'small', md: 'medium', lg: 'large' }[size]}`,\n `wds-Button--${priority}`,\n `wds-Button--${sentiment}`,\n className,\n );\n\n const contentClassNames = clsx('wds-Button-content', {\n [`wds-Button-content--loading`]: loading,\n });\n\n const content = (\n <Body\n as=\"span\"\n type={size === 'sm' ? Typography.BODY_DEFAULT_BOLD : Typography.BODY_LARGE_BOLD}\n className={contentClassNames}\n >\n {loading && (\n <ProcessIndicator\n size={size === 'sm' ? 'xxs' : 'xs'}\n className=\"wds-Button-loader\"\n data-testid=\"button-loader-indicator\"\n />\n )}\n <span className=\"wds-Button-label\" aria-hidden={loading}>\n {size === 'lg' ? (\n children\n ) : (\n <>\n {size === 'md' && addonStart?.type === 'avatar' && addonStart.value && (\n <span className=\"wds-Button-avatars\">\n <AvatarLayout orientation=\"horizontal\" avatars={addonStart?.value} size={24} />\n </span>\n )}\n\n {addonStart?.type === 'icon' && addonStart.value && (\n <span className=\"wds-Button-icon wds-Button-icon--start\">{addonStart.value}</span>\n )}\n\n {children}\n\n {addonEnd?.type === 'icon' && addonEnd?.value && (\n <span className=\"wds-Button-icon wds-Button-icon--end\">{addonEnd.value}</span>\n )}\n </>\n )}\n </span>\n </Body>\n );\n\n if ((href && as !== 'button') || as === 'a') {\n return (\n <PrimitiveAnchor\n ref={ref as React.Ref<HTMLAnchorElement>}\n {...(props as any)}\n href={href}\n className={classNames}\n disabled={disabled || loading}\n aria-busy={loading || undefined}\n type={undefined}\n >\n {content}\n </PrimitiveAnchor>\n );\n }\n\n return (\n <PrimitiveButton\n ref={ref as React.Ref<HTMLButtonElement>}\n {...(props as any)}\n className={classNames}\n disabled={disabled}\n loading={loading}\n type={type}\n href={undefined}\n target={undefined}\n >\n {content}\n </PrimitiveButton>\n );\n },\n);\n\nexport default Button;\n"],"names":["Button","forwardRef","as","children","className","size","href","disabled","priority","sentiment","addonStart","addonEnd","type","loading","block","v2","props","ref","classNames","clsx","sm","md","lg","contentClassNames","content","_jsxs","Body","Typography","BODY_DEFAULT_BOLD","BODY_LARGE_BOLD","_jsx","ProcessIndicator","_Fragment","value","AvatarLayout","orientation","avatars","PrimitiveAnchor","undefined","PrimitiveButton","target"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAUA,MAAMA,MAAM,gBAAGC,UAAU,CACvB,CACE;EACEC,EAAE;EACFC,QAAQ;EACRC,SAAS;AACTC,EAAAA,IAAI,GAAG,IAAI;EACXC,IAAI;AACJC,EAAAA,QAAQ,GAAG,KAAK;AAChBC,EAAAA,QAAQ,GAAG,SAAS;AACpBC,EAAAA,SAAS,GAAG,SAAS;EACrBC,UAAU;EACVC,QAAQ;AACR;AACAC,EAAAA,IAAI,GAAG,QAAQ;AACfC,EAAAA,OAAO,GAAG,KAAK;AACfC,EAAAA,KAAK,GAAG,KAAK;EACbC,EAAE;EACF,GAAGC,KAAAA;CACJ,EACDC,GAAG,KACD;AACF,EAAA,MAAMC,UAAU,GAAGC,IAAI,CACrB,YAAY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AAA;EAEA,oBACEM,GAAA,CAACS,eAAe,EAAA;AACdtB,IAAAA,GAAG,EAAEA,GAAoC;AAAA,IAAA,GACpCD,KAAa;AAClBZ,IAAAA,SAAS,EAAEc,UAAW;AACtBX,IAAAA,QAAQ,EAAEA,QAAS;AACnBM,IAAAA,OAAO,EAAEA,OAAQ;AACjBD,IAAAA,IAAI,EAAEA,IAAK;AACXN,IAAAA,IAAI,EAAEgC,SAAU;AAChBE,IAAAA,MAAM,EAAEF,SAAU;AAAAnC,IAAAA,QAAA,EAEjBqB,OAAAA;AAAO,GACO,CAAC,CAAA;AAEtB,CAAC;;;;"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var LegacyButton = require('./LegacyButton.js');
|
|
5
|
+
var Button$1 = require('./Button.js');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
|
|
8
|
+
const mapProps = props => {
|
|
9
|
+
const {
|
|
10
|
+
priority,
|
|
11
|
+
size,
|
|
12
|
+
type,
|
|
13
|
+
...newProps
|
|
14
|
+
} = props;
|
|
15
|
+
const priorityMapping = {
|
|
16
|
+
accent: {
|
|
17
|
+
primary: 'primary',
|
|
18
|
+
secondary: 'tertiary',
|
|
19
|
+
tertiary: 'minimal'
|
|
20
|
+
},
|
|
21
|
+
positive: {
|
|
22
|
+
primary: 'primary',
|
|
23
|
+
secondary: 'tertiary',
|
|
24
|
+
tertiary: 'tertiary'
|
|
25
|
+
},
|
|
26
|
+
negative: {
|
|
27
|
+
primary: 'primary',
|
|
28
|
+
secondary: 'secondary',
|
|
29
|
+
tertiary: 'secondary'
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const mappedPriority = type && priority ? priorityMapping[type]?.[priority] || priority : priority || undefined;
|
|
33
|
+
const mappedSentiment = type === 'negative' ? 'negative' : undefined;
|
|
34
|
+
const legacyButtonTypes = ['accent', 'negative', 'positive', 'primary', 'pay', 'secondary', 'danger', 'link'];
|
|
35
|
+
const resolveSize = () => {
|
|
36
|
+
if (size) {
|
|
37
|
+
return {
|
|
38
|
+
xs: 'sm',
|
|
39
|
+
sm: 'sm',
|
|
40
|
+
md: 'md',
|
|
41
|
+
lg: 'lg'
|
|
42
|
+
}[size] || size;
|
|
43
|
+
}
|
|
44
|
+
return size;
|
|
45
|
+
};
|
|
46
|
+
return {
|
|
47
|
+
...newProps,
|
|
48
|
+
size: resolveSize(),
|
|
49
|
+
priority: mappedPriority,
|
|
50
|
+
sentiment: mappedSentiment || ('sentiment' in props ? props.sentiment : null),
|
|
51
|
+
type: type && !legacyButtonTypes.includes(type) ? type : props.htmlType || null,
|
|
52
|
+
v2: true
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
const Button = /*#__PURE__*/React.forwardRef(({
|
|
56
|
+
v2 = false,
|
|
57
|
+
...props
|
|
58
|
+
}, ref) => {
|
|
59
|
+
if (v2) {
|
|
60
|
+
const mappedProps = mapProps(props);
|
|
61
|
+
return /*#__PURE__*/jsxRuntime.jsx(Button$1, {
|
|
62
|
+
...mappedProps,
|
|
63
|
+
ref: ref
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return /*#__PURE__*/jsxRuntime.jsx(LegacyButton, {
|
|
67
|
+
...props,
|
|
68
|
+
ref: ref
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
Button.displayName = 'Button';
|
|
72
|
+
|
|
73
|
+
module.exports = Button;
|
|
74
|
+
//# sourceMappingURL=Button.resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.resolver.js","sources":["../../src/button/Button.resolver.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport LegacyButton, { 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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