@zohodesk/components 1.0.0-temp-256.1 → 1.0.0-temp-257.1
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/README.md +2 -19
- package/assets/Appearance/dark/mode/Component_DarkMode.module.css +0 -2
- package/assets/Appearance/dark/mode/Component_v1_DarkMode.module.css +5 -20
- package/assets/Appearance/dark/themes/blue/blue_componentsCTA_DarkModifyCategory.module.css +0 -1
- package/assets/Appearance/dark/themes/green/green_componentsCTA_DarkModifyCategory.module.css +0 -1
- package/assets/Appearance/dark/themes/orange/orange_componentsCTA_DarkModifyCategory.module.css +0 -1
- package/assets/Appearance/dark/themes/red/red_componentsCTA_DarkModifyCategory.module.css +0 -1
- package/assets/Appearance/dark/themes/yellow/yellow_componentsCTA_DarkModifyCategory.module.css +0 -1
- package/assets/Appearance/light/mode/Component_LightMode.module.css +0 -2
- package/assets/Appearance/light/mode/Component_v1_LightMode.module.css +5 -20
- package/assets/Appearance/light/themes/blue/blue_componentsCTA_LightModifyCategory.module.css +0 -1
- package/assets/Appearance/light/themes/green/green_componentsCTA_LightModifyCategory.module.css +0 -1
- package/assets/Appearance/light/themes/orange/orange_componentsCTA_LightModifyCategory.module.css +0 -1
- package/assets/Appearance/light/themes/red/red_componentsCTA_LightModifyCategory.module.css +0 -1
- package/assets/Appearance/light/themes/yellow/yellow_componentsCTA_LightModifyCategory.module.css +0 -1
- package/assets/Appearance/pureDark/mode/Component_PureDarkMode.module.css +0 -2
- package/assets/Appearance/pureDark/mode/Component_v1_PureDarkMode.module.css +5 -20
- package/assets/Appearance/pureDark/themes/blue/blue_componentsCTA_PureDarkModifyCategory.module.css +0 -1
- package/assets/Appearance/pureDark/themes/green/green_componentsCTA_PureDarkModifyCategory.module.css +0 -1
- package/assets/Appearance/pureDark/themes/orange/orange_componentsCTA_PureDarkModifyCategory.module.css +0 -1
- package/assets/Appearance/pureDark/themes/red/red_componentsCTA_PureDarkModifyCategory.module.css +0 -1
- package/assets/Appearance/pureDark/themes/yellow/yellow_componentsCTA_PureDarkModifyCategory.module.css +0 -1
- package/es/ListItem/ListItem.js +1 -2
- package/es/ListItem/ListItemWithAvatar.js +3 -9
- package/es/ListItem/ListItemWithCheckBox.js +3 -9
- package/es/ListItem/ListItemWithIcon.js +2 -8
- package/es/ListItem/ListItemWithRadio.js +3 -9
- package/es/ListItem/__tests__/ListItemWithAvatar.spec.js +0 -19
- package/es/ListItem/__tests__/ListItemWithCheckBox.spec.js +0 -19
- package/es/ListItem/__tests__/ListItemWithIcon.spec.js +0 -17
- package/es/ListItem/__tests__/ListItemWithRadio.spec.js +0 -19
- package/es/ListItem/__tests__/__snapshots__/ListItemWithAvatar.spec.js.snap +0 -108
- package/es/ListItem/__tests__/__snapshots__/ListItemWithCheckBox.spec.js.snap +0 -212
- package/es/ListItem/__tests__/__snapshots__/ListItemWithIcon.spec.js.snap +0 -108
- package/es/ListItem/__tests__/__snapshots__/ListItemWithRadio.spec.js.snap +0 -210
- package/es/ListItem/props/defaultProps.js +0 -1
- package/es/ListItem/props/propTypes.js +3 -12
- package/es/Tab/Tab.js +13 -56
- package/es/Tab/Tab.module.css +4 -72
- package/es/Tab/TabWrapper.js +2 -6
- package/es/Tab/Tabs.js +14 -60
- package/es/Tab/Tabs.module.css +15 -84
- package/es/Tab/__tests__/Tab.spec.js +0 -87
- package/es/Tab/__tests__/Tabs.spec.js +0 -11
- package/es/Tab/__tests__/__snapshots__/Tab.spec.js.snap +0 -287
- package/es/Tab/__tests__/__snapshots__/Tabs.spec.js.snap +0 -32
- package/es/Tab/props/defaultProps.js +3 -10
- package/es/Tab/props/propTypes.js +4 -26
- package/es/Tab/utils/tabConfigs.js +0 -11
- package/es/v1/Button/Button.js +163 -106
- package/es/v1/Button/css/Button_v1.module.css +28 -16
- package/es/v1/Button/css/cssJSLogic.js +18 -3
- package/es/v1/Button/props/propTypes.js +14 -3
- package/es/v1/helpers/colorHelpers/background/backgroundColor.module.css +35 -35
- package/es/v1/helpers/colorHelpers/border/borderColor.module.css +20 -20
- package/es/v1/helpers/colorHelpers/text/textColor.module.css +35 -35
- package/lib/ListItem/ListItem.js +1 -3
- package/lib/ListItem/ListItemWithAvatar.js +3 -11
- package/lib/ListItem/ListItemWithCheckBox.js +3 -11
- package/lib/ListItem/ListItemWithIcon.js +2 -8
- package/lib/ListItem/ListItemWithRadio.js +3 -11
- package/lib/ListItem/__tests__/ListItemWithAvatar.spec.js +0 -23
- package/lib/ListItem/__tests__/ListItemWithCheckBox.spec.js +0 -23
- package/lib/ListItem/__tests__/ListItemWithIcon.spec.js +0 -21
- package/lib/ListItem/__tests__/ListItemWithRadio.spec.js +0 -23
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithAvatar.spec.js.snap +0 -108
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithCheckBox.spec.js.snap +0 -212
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithIcon.spec.js.snap +0 -108
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithRadio.spec.js.snap +0 -210
- package/lib/ListItem/props/defaultProps.js +0 -1
- package/lib/ListItem/props/propTypes.js +4 -12
- package/lib/Tab/Tab.js +11 -59
- package/lib/Tab/Tab.module.css +4 -72
- package/lib/Tab/TabWrapper.js +2 -6
- package/lib/Tab/Tabs.js +11 -57
- package/lib/Tab/Tabs.module.css +15 -84
- package/lib/Tab/__tests__/Tab.spec.js +0 -88
- package/lib/Tab/__tests__/Tabs.spec.js +0 -12
- package/lib/Tab/__tests__/__snapshots__/Tab.spec.js.snap +0 -287
- package/lib/Tab/__tests__/__snapshots__/Tabs.spec.js.snap +0 -32
- package/lib/Tab/props/defaultProps.js +3 -10
- package/lib/Tab/props/propTypes.js +4 -28
- package/lib/Tab/utils/tabConfigs.js +2 -15
- package/lib/v1/Button/Button.js +182 -118
- package/lib/v1/Button/css/Button_v1.module.css +28 -16
- package/lib/v1/Button/css/cssJSLogic.js +19 -7
- package/lib/v1/Button/props/propTypes.js +14 -3
- package/lib/v1/helpers/colorHelpers/background/backgroundColor.module.css +35 -35
- package/lib/v1/helpers/colorHelpers/border/borderColor.module.css +20 -20
- package/lib/v1/helpers/colorHelpers/text/textColor.module.css +35 -35
- package/package.json +7 -7
package/es/v1/Button/Button.js
CHANGED
|
@@ -6,31 +6,32 @@ import React, { forwardRef, memo, useMemo } from 'react';
|
|
|
6
6
|
import { withComponentRegistrar } from '@zohodesk/dotkit/es/react/ComponentRegistry';
|
|
7
7
|
import Icon from '@zohodesk/icons/es/Icon';
|
|
8
8
|
import Flex from '@zohodesk/layout/es/Flex/Flex';
|
|
9
|
-
import Typography from "../../Typography/Typography";
|
|
10
9
|
import { isRenderable } from '@zohodesk/utils/es/renderNode';
|
|
11
10
|
import renderNode from '@zohodesk/utils/es/renderNode';
|
|
12
|
-
import propTypes from "./props/propTypes";
|
|
13
|
-
import defaultProps from "./props/defaultProps";
|
|
14
11
|
import { DUMMY_OBJECT } from '@zohodesk/dotkit/es/utils/constants';
|
|
15
12
|
import { ICON_PLACEMENT, LOADER_PLACEMENT, STATUS, TYPOGRAPHY_SIZE_MAP, VARIANT } from "./constants";
|
|
13
|
+
import Typography from "../../Typography/Typography";
|
|
16
14
|
import Loader from "../shared/Loader/Loader";
|
|
17
15
|
import SuccessTick from "../shared/SuccessTick/SuccessTick";
|
|
18
16
|
import cssJSLogic from "./css/cssJSLogic";
|
|
17
|
+
import propTypes from "./props/propTypes";
|
|
18
|
+
import defaultProps from "./props/defaultProps";
|
|
19
19
|
|
|
20
20
|
const getTypographySize = size => TYPOGRAPHY_SIZE_MAP[size] || '13';
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
export const ButtonPresentational = /*#__PURE__*/forwardRef(function ButtonPresentational(props, ref) {
|
|
23
23
|
const {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
isLoading,
|
|
25
|
+
isSuccess,
|
|
26
|
+
isDisabled,
|
|
27
|
+
isDisabledState,
|
|
28
|
+
overlayActive,
|
|
27
29
|
variant,
|
|
28
|
-
|
|
30
|
+
iconPlacement,
|
|
29
31
|
loaderPlacement,
|
|
30
32
|
size,
|
|
31
33
|
iconName,
|
|
32
34
|
iconSize,
|
|
33
|
-
iconPlacement,
|
|
34
35
|
renderIcon,
|
|
35
36
|
renderBefore,
|
|
36
37
|
renderAfter,
|
|
@@ -38,104 +39,88 @@ const Button = /*#__PURE__*/forwardRef(function Button(props, ref) {
|
|
|
38
39
|
renderSuccess,
|
|
39
40
|
children,
|
|
40
41
|
type,
|
|
41
|
-
onClick,
|
|
42
|
-
isDisabled,
|
|
43
42
|
isReadOnly,
|
|
44
43
|
isSelected,
|
|
45
|
-
shape,
|
|
46
|
-
paletteShade,
|
|
47
|
-
disabledAppearance,
|
|
48
44
|
title,
|
|
49
45
|
customProps,
|
|
50
46
|
customAttributes,
|
|
51
47
|
a11yAttributes,
|
|
52
48
|
customId,
|
|
53
|
-
testId
|
|
49
|
+
testId,
|
|
50
|
+
dataSelectorId,
|
|
51
|
+
handleClick,
|
|
52
|
+
classNames
|
|
54
53
|
} = props;
|
|
55
|
-
const isLoading = status === STATUS.LOADING;
|
|
56
|
-
const isSuccess = status === STATUS.SUCCESS;
|
|
57
|
-
const isDisabledState = isDisabled || isLoading;
|
|
58
|
-
const isInteractionDisabled = isDisabledState || isReadOnly;
|
|
59
|
-
const overlayActive = (isLoading || isSuccess) && loaderPlacement === LOADER_PLACEMENT.OVERLAY;
|
|
60
|
-
const {
|
|
61
|
-
text: contentProps = DUMMY_OBJECT,
|
|
62
|
-
icon: iconProps = DUMMY_OBJECT
|
|
63
|
-
} = customProps;
|
|
64
|
-
const iconTagAttributes = useMemo(() => ({ ...(iconProps.tagAttributes || DUMMY_OBJECT),
|
|
65
|
-
'data-test-id': testId ? `${testId}_icon` : undefined
|
|
66
|
-
}), [iconProps.tagAttributes, testId]);
|
|
67
|
-
const classes = useMemo(() => cssJSLogic({
|
|
68
|
-
props
|
|
69
|
-
}), [palette, bgAppearance, borderAppearance, paletteShade, size, variant, status, isDisabled, isReadOnly, isSelected, shape, loaderPlacement, disabledAppearance, props.customClass]);
|
|
70
54
|
const {
|
|
71
55
|
loaderOverlayClass,
|
|
72
56
|
successOverlayClass,
|
|
73
57
|
contentWrapperClass,
|
|
74
58
|
textClassName,
|
|
75
59
|
buttonClassName,
|
|
76
|
-
iconClassName
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
60
|
+
iconClassName,
|
|
61
|
+
loaderClassName,
|
|
62
|
+
successClassName
|
|
63
|
+
} = classNames;
|
|
64
|
+
const {
|
|
65
|
+
text: contentProps = DUMMY_OBJECT,
|
|
66
|
+
icon: iconProps = DUMMY_OBJECT
|
|
67
|
+
} = customProps || DUMMY_OBJECT;
|
|
68
|
+
const {
|
|
69
|
+
button: buttonAttributes = DUMMY_OBJECT,
|
|
70
|
+
contentWrapper: contentWrapperAttributes = DUMMY_OBJECT,
|
|
71
|
+
loader: loaderAttributes = DUMMY_OBJECT,
|
|
72
|
+
success: successAttributes = DUMMY_OBJECT,
|
|
73
|
+
icon: iconAttributes = DUMMY_OBJECT,
|
|
74
|
+
text: textAttributes = DUMMY_OBJECT
|
|
75
|
+
} = customAttributes || DUMMY_OBJECT;
|
|
76
|
+
const iconTagAttributes = { ...iconAttributes,
|
|
77
|
+
'data-test-id': testId ? `${testId}_icon` : undefined
|
|
86
78
|
};
|
|
79
|
+
const showIcon = variant !== VARIANT.TEXT && (renderIcon || iconName);
|
|
87
80
|
|
|
88
81
|
const _renderLoader = () => {
|
|
89
|
-
if (!isLoading)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const loaderClassName = loaderPlacement === LOADER_PLACEMENT.OVERLAY ? loaderOverlayClass : '';
|
|
100
|
-
return /*#__PURE__*/React.createElement(Flex, {
|
|
82
|
+
if (!isLoading) return null;
|
|
83
|
+
const isOverlay = loaderPlacement === LOADER_PLACEMENT.OVERLAY;
|
|
84
|
+
const hasCustomLoader = isRenderable(renderLoader);
|
|
85
|
+
if (hasCustomLoader && !isOverlay) return renderNode(renderLoader, {
|
|
86
|
+
status: STATUS.LOADING
|
|
87
|
+
});
|
|
88
|
+
return /*#__PURE__*/React.createElement(Flex, _extends({
|
|
101
89
|
$ui_displayMode: "flex",
|
|
102
90
|
$ui_alignItems: "center",
|
|
103
91
|
$ui_justifyContent: "center",
|
|
104
|
-
$ui_className:
|
|
92
|
+
$ui_className: isOverlay ? loaderOverlayClass : '',
|
|
105
93
|
testId: testId ? `${testId}_loader` : undefined
|
|
106
|
-
},
|
|
94
|
+
}, hasCustomLoader ? undefined : loaderAttributes), hasCustomLoader ? renderNode(renderLoader, {
|
|
95
|
+
status: STATUS.LOADING
|
|
96
|
+
}) : /*#__PURE__*/React.createElement(Loader, {
|
|
97
|
+
customClass: loaderClassName
|
|
98
|
+
}));
|
|
107
99
|
};
|
|
108
100
|
|
|
109
101
|
const _renderSuccess = () => {
|
|
110
|
-
if (!isSuccess)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const successClassName = loaderPlacement === LOADER_PLACEMENT.OVERLAY ? successOverlayClass : '';
|
|
121
|
-
return /*#__PURE__*/React.createElement(Flex, {
|
|
102
|
+
if (!isSuccess) return null;
|
|
103
|
+
const isOverlay = loaderPlacement === LOADER_PLACEMENT.OVERLAY;
|
|
104
|
+
const hasCustomSuccess = isRenderable(renderSuccess);
|
|
105
|
+
if (hasCustomSuccess && !isOverlay) return renderNode(renderSuccess, {
|
|
106
|
+
status: STATUS.SUCCESS
|
|
107
|
+
});
|
|
108
|
+
return /*#__PURE__*/React.createElement(Flex, _extends({
|
|
122
109
|
$ui_displayMode: "flex",
|
|
123
110
|
$ui_alignItems: "center",
|
|
124
111
|
$ui_justifyContent: "center",
|
|
125
|
-
$ui_className:
|
|
112
|
+
$ui_className: isOverlay ? successOverlayClass : '',
|
|
126
113
|
testId: testId ? `${testId}_success` : undefined
|
|
127
|
-
},
|
|
114
|
+
}, hasCustomSuccess ? undefined : successAttributes), hasCustomSuccess ? renderNode(renderSuccess, {
|
|
115
|
+
status: STATUS.SUCCESS
|
|
116
|
+
}) : /*#__PURE__*/React.createElement(SuccessTick, {
|
|
117
|
+
customClass: successClassName
|
|
118
|
+
}));
|
|
128
119
|
};
|
|
129
120
|
|
|
130
121
|
const _renderIconNode = () => {
|
|
131
|
-
if (!showIcon)
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (isRenderable(renderIcon)) {
|
|
136
|
-
return renderNode(renderIcon);
|
|
137
|
-
}
|
|
138
|
-
|
|
122
|
+
if (!showIcon) return null;
|
|
123
|
+
if (isRenderable(renderIcon)) return renderNode(renderIcon);
|
|
139
124
|
return /*#__PURE__*/React.createElement(Icon, _extends({}, iconProps, {
|
|
140
125
|
iconClass: iconClassName,
|
|
141
126
|
name: iconName,
|
|
@@ -145,58 +130,130 @@ const Button = /*#__PURE__*/forwardRef(function Button(props, ref) {
|
|
|
145
130
|
}));
|
|
146
131
|
};
|
|
147
132
|
|
|
148
|
-
const _renderBeforeNode = () => {
|
|
149
|
-
if (!isRenderable(renderBefore)) {
|
|
150
|
-
return null;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return renderNode(renderBefore, props);
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
const _renderAfterNode = () => {
|
|
157
|
-
if (!isRenderable(renderAfter)) {
|
|
158
|
-
return null;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return renderNode(renderAfter, props);
|
|
162
|
-
};
|
|
163
|
-
|
|
164
133
|
const _renderContent = () => {
|
|
165
|
-
const shouldShowText = variant !== VARIANT.ICON && children
|
|
134
|
+
const shouldShowText = variant !== VARIANT.ICON && children != null && (typeof children !== 'string' || children.trim() !== '');
|
|
166
135
|
const showLoaderStart = isLoading && loaderPlacement === LOADER_PLACEMENT.START;
|
|
167
136
|
const showLoaderAfter = isLoading && loaderPlacement === LOADER_PLACEMENT.END;
|
|
168
137
|
const showSuccessStart = isSuccess && loaderPlacement === LOADER_PLACEMENT.START;
|
|
169
138
|
const showSuccessAfter = isSuccess && loaderPlacement === LOADER_PLACEMENT.END;
|
|
170
|
-
return /*#__PURE__*/React.createElement(Flex, {
|
|
139
|
+
return /*#__PURE__*/React.createElement(Flex, _extends({
|
|
171
140
|
$ui_displayMode: "flex",
|
|
172
141
|
$ui_direction: "row",
|
|
173
142
|
$flag_shrink: true,
|
|
174
143
|
$ui_alignItems: "center",
|
|
175
144
|
$ui_justifyContent: "center",
|
|
176
145
|
$ui_className: contentWrapperClass
|
|
177
|
-
}, showLoaderStart ? _renderLoader() : null, showSuccessStart ? _renderSuccess() : null,
|
|
146
|
+
}, contentWrapperAttributes), showLoaderStart ? _renderLoader() : null, showSuccessStart ? _renderSuccess() : null, isRenderable(renderBefore) ? renderNode(renderBefore, props) : null, iconPlacement === ICON_PLACEMENT.LEFT ? _renderIconNode() : null, shouldShowText ? typeof children === 'string' ? /*#__PURE__*/React.createElement(Typography, _extends({
|
|
147
|
+
$ui_size: getTypographySize(size)
|
|
148
|
+
}, contentProps, {
|
|
149
|
+
tagAttributes: textAttributes,
|
|
178
150
|
$ui_className: textClassName,
|
|
179
|
-
$ui_size: getTypographySize(size),
|
|
180
151
|
$flag_dotted: variant !== VARIANT.ICON
|
|
181
|
-
}), children) : null, iconPlacement === ICON_PLACEMENT.RIGHT ? _renderIconNode() : null,
|
|
152
|
+
}), children) : children : null, iconPlacement === ICON_PLACEMENT.RIGHT ? _renderIconNode() : null, isRenderable(renderAfter) ? renderNode(renderAfter, props) : null, showLoaderAfter ? _renderLoader() : null, showSuccessAfter ? _renderSuccess() : null);
|
|
182
153
|
};
|
|
183
154
|
|
|
184
|
-
const containerAttributes = { ...
|
|
185
|
-
'data-id': customId,
|
|
186
|
-
'data-test-id': testId,
|
|
155
|
+
const containerAttributes = { ...buttonAttributes,
|
|
156
|
+
'data-id': isDisabled ? `${customId}_disabled` : customId,
|
|
157
|
+
'data-test-id': isDisabled ? `${testId}_disabled` : testId,
|
|
158
|
+
'data-selector-id': dataSelectorId,
|
|
187
159
|
'data-title': title
|
|
188
160
|
};
|
|
189
|
-
return /*#__PURE__*/React.createElement("button", _extends({}, containerAttributes,
|
|
161
|
+
return /*#__PURE__*/React.createElement("button", _extends({}, containerAttributes, {
|
|
162
|
+
"aria-busy": isLoading,
|
|
163
|
+
disabled: isDisabledState,
|
|
164
|
+
"aria-readonly": isReadOnly,
|
|
165
|
+
"aria-pressed": isSelected
|
|
166
|
+
}, a11yAttributes, {
|
|
190
167
|
ref: ref,
|
|
191
168
|
type: type,
|
|
192
169
|
className: cn(buttonClassName),
|
|
193
|
-
|
|
194
|
-
"aria-disabled": isDisabledState,
|
|
195
|
-
"aria-readonly": isReadOnly,
|
|
196
|
-
"aria-pressed": isSelected,
|
|
197
|
-
onClick: _handleClick
|
|
170
|
+
onClick: handleClick
|
|
198
171
|
}), _renderContent(), overlayActive ? isLoading ? _renderLoader() : _renderSuccess() : null);
|
|
199
172
|
});
|
|
173
|
+
ButtonPresentational.displayName = 'ButtonPresentational';
|
|
174
|
+
const Button = /*#__PURE__*/forwardRef(function Button(props, ref) {
|
|
175
|
+
const {
|
|
176
|
+
palette,
|
|
177
|
+
bgAppearance,
|
|
178
|
+
borderAppearance,
|
|
179
|
+
variant,
|
|
180
|
+
status,
|
|
181
|
+
loaderPlacement,
|
|
182
|
+
size,
|
|
183
|
+
iconName,
|
|
184
|
+
iconSize,
|
|
185
|
+
iconPlacement,
|
|
186
|
+
renderIcon,
|
|
187
|
+
renderBefore,
|
|
188
|
+
renderAfter,
|
|
189
|
+
renderLoader,
|
|
190
|
+
renderSuccess,
|
|
191
|
+
children,
|
|
192
|
+
type,
|
|
193
|
+
onClick,
|
|
194
|
+
isDisabled,
|
|
195
|
+
isReadOnly,
|
|
196
|
+
isSelected,
|
|
197
|
+
shape,
|
|
198
|
+
paletteShade,
|
|
199
|
+
disabledAppearance,
|
|
200
|
+
title,
|
|
201
|
+
customProps,
|
|
202
|
+
customAttributes,
|
|
203
|
+
a11yAttributes,
|
|
204
|
+
customId,
|
|
205
|
+
testId,
|
|
206
|
+
dataSelectorId
|
|
207
|
+
} = props;
|
|
208
|
+
const isLoading = status === STATUS.LOADING;
|
|
209
|
+
const isSuccess = status === STATUS.SUCCESS;
|
|
210
|
+
const isDisabledState = isDisabled || isLoading;
|
|
211
|
+
const isInteractionDisabled = isDisabledState || isReadOnly;
|
|
212
|
+
const overlayActive = (isLoading || isSuccess) && loaderPlacement === LOADER_PLACEMENT.OVERLAY;
|
|
213
|
+
const classNames = useMemo(() => cssJSLogic({
|
|
214
|
+
props
|
|
215
|
+
}), [palette, bgAppearance, borderAppearance, paletteShade, size, variant, status, isDisabled, isReadOnly, isSelected, shape, loaderPlacement, disabledAppearance, props.customClass]);
|
|
216
|
+
|
|
217
|
+
const handleClick = event => {
|
|
218
|
+
if (isInteractionDisabled) return;
|
|
219
|
+
onClick(event);
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
const essentials = {
|
|
223
|
+
isLoading,
|
|
224
|
+
isSuccess,
|
|
225
|
+
isDisabled,
|
|
226
|
+
isDisabledState,
|
|
227
|
+
overlayActive,
|
|
228
|
+
variant,
|
|
229
|
+
iconPlacement,
|
|
230
|
+
loaderPlacement,
|
|
231
|
+
size,
|
|
232
|
+
iconName,
|
|
233
|
+
iconSize,
|
|
234
|
+
renderIcon,
|
|
235
|
+
renderBefore,
|
|
236
|
+
renderAfter,
|
|
237
|
+
renderLoader,
|
|
238
|
+
renderSuccess,
|
|
239
|
+
children,
|
|
240
|
+
type,
|
|
241
|
+
isReadOnly,
|
|
242
|
+
isSelected,
|
|
243
|
+
title,
|
|
244
|
+
customProps,
|
|
245
|
+
customAttributes,
|
|
246
|
+
a11yAttributes,
|
|
247
|
+
customId,
|
|
248
|
+
testId,
|
|
249
|
+
dataSelectorId,
|
|
250
|
+
handleClick
|
|
251
|
+
};
|
|
252
|
+
return /*#__PURE__*/React.createElement(ButtonPresentational, _extends({}, essentials, {
|
|
253
|
+
classNames: classNames,
|
|
254
|
+
ref: ref
|
|
255
|
+
}));
|
|
256
|
+
});
|
|
200
257
|
Button.propTypes = propTypes;
|
|
201
258
|
Button.defaultProps = defaultProps;
|
|
202
259
|
Button.displayName = 'Button';
|
|
@@ -5,13 +5,15 @@
|
|
|
5
5
|
--local-button-gap: var(--zd_size8);
|
|
6
6
|
--local-button-padding-block: var(--zd_size6);
|
|
7
7
|
--local-button-padding-inline: var(--zd_size15);
|
|
8
|
-
--local-button-font-size: var(--zd_font_size13);
|
|
9
8
|
--local-loader-size: 16px;
|
|
10
9
|
--local-tick-size: 16px;
|
|
11
10
|
--local-button-height: auto;
|
|
12
11
|
--local-button-width: auto;
|
|
13
|
-
--local-button-
|
|
14
|
-
--local-button-
|
|
12
|
+
--local-button-min-width: var(--zd_size90);
|
|
13
|
+
--local-button-overlay-opacity: 0.4;
|
|
14
|
+
--local-button-transition-duration: var(--zd_transition2);
|
|
15
|
+
--local-button-cursor: pointer;
|
|
16
|
+
--local-button-strike-color: currentColor;
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
.button {
|
|
@@ -19,19 +21,20 @@
|
|
|
19
21
|
composes: posrel pointer from '../../../common/common.module.css';
|
|
20
22
|
padding-block: var(--local-button-padding-block);
|
|
21
23
|
padding-inline: var(--local-button-padding-inline);
|
|
22
|
-
font-size: var(--local-button-font-size);
|
|
23
24
|
height: var(--local-button-height);
|
|
24
25
|
width: var(--local-button-width);
|
|
26
|
+
min-width: var(--local-button-min-width);
|
|
25
27
|
border-radius: var(--local-button-radius);
|
|
26
28
|
border-style: var(--local-button-border-style);
|
|
27
29
|
border-width: var(--local-button-border-width);
|
|
28
30
|
transition-duration: var(--local-button-transition-duration);
|
|
29
31
|
transition-timing-function: ease;
|
|
32
|
+
cursor: var(--local-button-cursor);
|
|
30
33
|
background-image: none;
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
.disabledPointer {
|
|
34
|
-
cursor: not-allowed;
|
|
37
|
+
--local-button-cursor: not-allowed;
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
.disabledOpac {
|
|
@@ -39,7 +42,8 @@
|
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
.loading {
|
|
42
|
-
cursor: progress;
|
|
45
|
+
--local-button-cursor: progress;
|
|
46
|
+
composes: disabledOpac;
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
.sizeSmall {
|
|
@@ -68,6 +72,18 @@
|
|
|
68
72
|
--local-button-width: 100%;
|
|
69
73
|
}
|
|
70
74
|
|
|
75
|
+
.variantText {
|
|
76
|
+
--local-button-min-width: var(--zd_size90);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.variantIcon {
|
|
80
|
+
--local-button-min-width: var(--zd_size28);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.variantIconWithText {
|
|
84
|
+
--local-button-min-width: var(--zd_size118);
|
|
85
|
+
}
|
|
86
|
+
|
|
71
87
|
.shapeRoundedRectangle {
|
|
72
88
|
--local-button-radius: 4px;
|
|
73
89
|
}
|
|
@@ -80,9 +96,11 @@
|
|
|
80
96
|
--local-button-radius: 0;
|
|
81
97
|
}
|
|
82
98
|
|
|
83
|
-
.
|
|
99
|
+
.strike::after,
|
|
100
|
+
.loaderOverlay,
|
|
101
|
+
.successOverlay {
|
|
84
102
|
inset: 0 ;
|
|
85
|
-
|
|
103
|
+
position: absolute;
|
|
86
104
|
}
|
|
87
105
|
|
|
88
106
|
.contentWrapper {
|
|
@@ -98,22 +116,16 @@
|
|
|
98
116
|
|
|
99
117
|
.strike::after {
|
|
100
118
|
content: '';
|
|
101
|
-
position: absolute;
|
|
102
|
-
inset: 0 ;
|
|
103
119
|
pointer-events: none;
|
|
104
120
|
border-radius: var(--local-button-radius);
|
|
105
121
|
}
|
|
106
122
|
|
|
107
123
|
[dir=ltr] .strike::after {
|
|
108
|
-
background-image: repeating-linear-gradient(120deg,
|
|
124
|
+
background-image: repeating-linear-gradient(120deg, var(--local-button-strike-color) 0 1px, var(--zd-bg-transparent) 1px 8px);
|
|
109
125
|
}
|
|
110
126
|
|
|
111
127
|
[dir=rtl] .strike::after {
|
|
112
|
-
background-image: repeating-linear-gradient(-120deg,
|
|
128
|
+
background-image: repeating-linear-gradient(-120deg, var(--local-button-strike-color) 0 1px, var(--zd-bg-transparent) 1px 8px);
|
|
113
129
|
}
|
|
114
130
|
|
|
115
|
-
.successOverlay {
|
|
116
|
-
inset: 0 ;
|
|
117
|
-
composes: posab from '../../../common/common.module.css';
|
|
118
|
-
}
|
|
119
131
|
|
|
@@ -16,6 +16,7 @@ export default function cssJSLogic({
|
|
|
16
16
|
borderAppearance,
|
|
17
17
|
paletteShade,
|
|
18
18
|
size,
|
|
19
|
+
variant,
|
|
19
20
|
status,
|
|
20
21
|
isDisabled,
|
|
21
22
|
isReadOnly,
|
|
@@ -28,11 +29,13 @@ export default function cssJSLogic({
|
|
|
28
29
|
const {
|
|
29
30
|
wrapper: wrapperClass = '',
|
|
30
31
|
text: textClassCustom = '',
|
|
31
|
-
icon: iconClassCustom = ''
|
|
32
|
+
icon: iconClassCustom = '',
|
|
33
|
+
loader: loaderClassCustom = '',
|
|
34
|
+
success: successClassCustom = ''
|
|
32
35
|
} = customClass;
|
|
33
36
|
const isLoading = status === STATUS.LOADING;
|
|
34
37
|
const isSuccess = status === STATUS.SUCCESS;
|
|
35
|
-
const isInteractive = !isDisabled && !isReadOnly;
|
|
38
|
+
const isInteractive = !isDisabled && !isReadOnly && !isLoading;
|
|
36
39
|
const overlayActive = (isLoading || isSuccess) && loaderPlacement === LOADER_PLACEMENT.OVERLAY;
|
|
37
40
|
const {
|
|
38
41
|
bg,
|
|
@@ -56,6 +59,7 @@ export default function cssJSLogic({
|
|
|
56
59
|
});
|
|
57
60
|
const sizeClass = size ? style[`size${capitalize(size)}`] : '';
|
|
58
61
|
const shapeClass = shape ? style[`shape${capitalize(shape)}`] : '';
|
|
62
|
+
const variantClass = variant ? style[`variant${capitalize(variant)}`] : '';
|
|
59
63
|
const shouldStrike = disabledAppearance === DISABLED_APPEARANCE.STRIKE && isDisabled;
|
|
60
64
|
const buttonClassName = compileClassNames({
|
|
61
65
|
[buttonResetStyle.buttonReset]: true,
|
|
@@ -74,6 +78,7 @@ export default function cssJSLogic({
|
|
|
74
78
|
[activeBorder]: !!activeBorder && isInteractive,
|
|
75
79
|
[sizeClass]: !!sizeClass,
|
|
76
80
|
[shapeClass]: !!shapeClass,
|
|
81
|
+
[variantClass]: !!variantClass,
|
|
77
82
|
[style.disabledOpac]: isReadOnly || isDisabled && disabledAppearance === DISABLED_APPEARANCE.DULL,
|
|
78
83
|
[style.disabledPointer]: isReadOnly || isDisabled,
|
|
79
84
|
[style.loading]: isLoading,
|
|
@@ -89,9 +94,19 @@ export default function cssJSLogic({
|
|
|
89
94
|
return {
|
|
90
95
|
buttonClassName,
|
|
91
96
|
textClassName,
|
|
97
|
+
iconClassName,
|
|
92
98
|
contentWrapperClass: overlayActive ? style.overlayHidden : style.contentWrapper,
|
|
93
99
|
loaderOverlayClass: style.loaderOverlay,
|
|
94
100
|
successOverlayClass: style.successOverlay,
|
|
95
|
-
|
|
101
|
+
loaderClassName: {
|
|
102
|
+
wrapper: compileClassNames({
|
|
103
|
+
[loaderClassCustom]: !!loaderClassCustom
|
|
104
|
+
})
|
|
105
|
+
},
|
|
106
|
+
successClassName: {
|
|
107
|
+
wrapper: compileClassNames({
|
|
108
|
+
[successClassCustom]: !!successClassCustom
|
|
109
|
+
})
|
|
110
|
+
}
|
|
96
111
|
};
|
|
97
112
|
}
|
|
@@ -29,15 +29,26 @@ const propTypes = {
|
|
|
29
29
|
title: PropTypes.string,
|
|
30
30
|
customClass: PropTypes.shape({
|
|
31
31
|
wrapper: PropTypes.string,
|
|
32
|
-
text: PropTypes.string
|
|
32
|
+
text: PropTypes.string,
|
|
33
|
+
icon: PropTypes.string,
|
|
34
|
+
loader: PropTypes.string,
|
|
35
|
+
success: PropTypes.string
|
|
33
36
|
}),
|
|
34
37
|
customProps: PropTypes.shape({
|
|
35
38
|
text: PropTypes.object,
|
|
36
39
|
icon: PropTypes.object
|
|
37
40
|
}),
|
|
38
|
-
customAttributes: PropTypes.
|
|
41
|
+
customAttributes: PropTypes.shape({
|
|
42
|
+
button: PropTypes.object,
|
|
43
|
+
contentWrapper: PropTypes.object,
|
|
44
|
+
loader: PropTypes.object,
|
|
45
|
+
success: PropTypes.object,
|
|
46
|
+
icon: PropTypes.object,
|
|
47
|
+
text: PropTypes.object
|
|
48
|
+
}),
|
|
39
49
|
a11yAttributes: PropTypes.object,
|
|
40
50
|
customId: PropTypes.string,
|
|
41
|
-
testId: PropTypes.string
|
|
51
|
+
testId: PropTypes.string,
|
|
52
|
+
dataSelectorId: PropTypes.string
|
|
42
53
|
};
|
|
43
54
|
export default propTypes;
|