@zohodesk/components 1.6.7 → 1.6.11-exp-6
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 +15 -0
- package/assets/Appearance/dark/mode/Component_v1_DarkMode.module.css +68 -0
- package/assets/Appearance/light/mode/Component_v1_LightMode.module.css +68 -0
- package/assets/Appearance/pureDark/mode/Component_v1_PureDarkMode.module.css +68 -0
- package/es/Buttongroup/Buttongroup.module.css +10 -30
- package/es/CheckBox/CheckBox.module.css +3 -10
- package/es/DateTime/DateTime.module.css +22 -35
- package/es/DateTime/YearView.module.css +8 -10
- package/es/DropBox/DropBoxElement/css/DropBoxElement.module.css +3 -2
- package/es/DropDown/DropDown.module.css +2 -1
- package/es/DropDown/DropDownItem.module.css +1 -8
- package/es/DropDown/DropDownSeparator.module.css +2 -1
- package/es/ListItem/ListItem.module.css +4 -15
- package/es/MultiSelect/MobileHeader/MobileHeader.module.css +3 -2
- package/es/MultiSelect/MultiSelect.module.css +21 -34
- package/es/MultiSelect/SelectedOptions.module.css +6 -10
- package/es/Radio/Radio.module.css +3 -3
- package/es/ResponsiveDropBox/ResponsiveDropBox.module.css +1 -1
- package/es/Ribbon/Ribbon.module.css +9 -12
- package/es/Select/Select.module.css +22 -17
- package/es/Switch/Switch.module.css +1 -8
- package/es/Tab/Tab.module.css +8 -15
- package/es/Tab/Tabs.module.css +12 -22
- package/es/Tag/Tag.module.css +4 -3
- package/es/Tooltip/Tooltip.module.css +3 -2
- package/es/Typography/Typography.js +18 -8
- package/es/Typography/__tests__/Typography.spec.js +198 -6
- package/es/Typography/__tests__/__snapshots__/Typography.spec.js.snap +1235 -2
- package/es/Typography/css/Typography.module.css +4 -0
- package/es/Typography/css/cssJSLogic.js +53 -21
- package/es/Typography/props/defaultProps.js +4 -3
- package/es/Typography/props/propTypes.js +68 -26
- package/es/Typography/utils/textHighlighter.js +4 -2
- package/es/shared/ArrowIcon/ArrowIcon.module.css +3 -2
- package/es/v1/Button/Button.js +201 -0
- package/es/v1/Button/README.md +110 -0
- package/es/v1/Button/__tests__/Button.spec.js +272 -0
- package/es/v1/Button/__tests__/__snapshots__/Button.spec.js.snap +1160 -0
- package/es/v1/Button/_shared/Loader/Loader.js +33 -0
- package/es/v1/Button/_shared/Loader/Loader.module.css +42 -0
- package/es/v1/Button/_shared/Loader/__tests__/Loader.spec.js +21 -0
- package/es/v1/Button/_shared/Loader/__tests__/__snapshots__/Loader.spec.js.snap +49 -0
- package/es/v1/Button/_shared/Loader/props/defaultProps.js +4 -0
- package/es/v1/Button/_shared/Loader/props/propTypes.js +7 -0
- package/es/v1/Button/_shared/SuccessTick/SuccessTick.js +25 -0
- package/es/v1/Button/_shared/SuccessTick/SuccessTick.module.css +21 -0
- package/es/v1/Button/_shared/SuccessTick/__tests__/SuccessTick.spec.js +21 -0
- package/es/v1/Button/_shared/SuccessTick/__tests__/__snapshots__/SuccessTick.spec.js.snap +31 -0
- package/es/v1/Button/_shared/SuccessTick/props/defaultProps.js +4 -0
- package/es/v1/Button/_shared/SuccessTick/props/propTypes.js +7 -0
- package/es/v1/Button/constants/index.js +82 -0
- package/es/v1/Button/css/Button_v1.module.css +119 -0
- package/es/v1/Button/css/cssJSLogic.js +96 -0
- package/es/v1/Button/index.js +2 -0
- package/es/v1/Button/props/defaultProps.js +26 -0
- package/es/v1/Button/props/propTypes.js +43 -0
- package/es/v1/helpers/colorHelpers/background/backgroundColor.module.css +629 -0
- package/es/v1/helpers/colorHelpers/border/borderColor.module.css +489 -0
- package/es/v1/helpers/colorHelpers/colorHelper.js +176 -0
- package/es/v1/helpers/colorHelpers/constants/index.js +79 -0
- package/es/v1/helpers/colorHelpers/index.js +4 -0
- package/es/v1/helpers/colorHelpers/paletteUtilities.README.md +415 -0
- package/es/v1/helpers/colorHelpers/text/textColor.module.css +368 -0
- package/lib/Buttongroup/Buttongroup.module.css +10 -30
- package/lib/CheckBox/CheckBox.module.css +3 -10
- package/lib/DateTime/DateTime.module.css +22 -35
- package/lib/DateTime/YearView.module.css +8 -10
- package/lib/DropBox/DropBoxElement/css/DropBoxElement.module.css +3 -2
- package/lib/DropDown/DropDown.module.css +2 -1
- package/lib/DropDown/DropDownItem.module.css +1 -8
- package/lib/DropDown/DropDownSeparator.module.css +2 -1
- package/lib/ListItem/ListItem.module.css +4 -15
- package/lib/MultiSelect/MobileHeader/MobileHeader.module.css +3 -2
- package/lib/MultiSelect/MultiSelect.module.css +21 -34
- package/lib/MultiSelect/SelectedOptions.module.css +6 -10
- package/lib/Radio/Radio.module.css +3 -3
- package/lib/ResponsiveDropBox/ResponsiveDropBox.module.css +1 -1
- package/lib/Ribbon/Ribbon.module.css +9 -12
- package/lib/Select/Select.module.css +22 -17
- package/lib/Switch/Switch.module.css +1 -8
- package/lib/Tab/Tab.module.css +8 -15
- package/lib/Tab/Tabs.module.css +12 -22
- package/lib/Tag/Tag.module.css +4 -3
- package/lib/Tooltip/Tooltip.module.css +3 -2
- package/lib/Typography/Typography.js +15 -5
- package/lib/Typography/__tests__/Typography.spec.js +284 -92
- package/lib/Typography/__tests__/__snapshots__/Typography.spec.js.snap +1235 -2
- package/lib/Typography/css/Typography.module.css +4 -0
- package/lib/Typography/css/cssJSLogic.js +38 -6
- package/lib/Typography/props/defaultProps.js +6 -3
- package/lib/Typography/props/propTypes.js +67 -23
- package/lib/Typography/utils/textHighlighter.js +6 -3
- package/lib/shared/ArrowIcon/ArrowIcon.module.css +3 -2
- package/lib/v1/Button/Button.js +239 -0
- package/lib/v1/Button/README.md +110 -0
- package/lib/v1/Button/__tests__/Button.spec.js +293 -0
- package/lib/v1/Button/__tests__/__snapshots__/Button.spec.js.snap +1160 -0
- package/lib/v1/Button/_shared/Loader/Loader.js +43 -0
- package/lib/v1/Button/_shared/Loader/Loader.module.css +42 -0
- package/lib/v1/Button/_shared/Loader/__tests__/Loader.spec.js +28 -0
- package/lib/v1/Button/_shared/Loader/__tests__/__snapshots__/Loader.spec.js.snap +49 -0
- package/lib/v1/Button/_shared/Loader/props/defaultProps.js +11 -0
- package/lib/v1/Button/_shared/Loader/props/propTypes.js +18 -0
- package/lib/v1/Button/_shared/SuccessTick/SuccessTick.js +35 -0
- package/lib/v1/Button/_shared/SuccessTick/SuccessTick.module.css +21 -0
- package/lib/v1/Button/_shared/SuccessTick/__tests__/SuccessTick.spec.js +28 -0
- package/lib/v1/Button/_shared/SuccessTick/__tests__/__snapshots__/SuccessTick.spec.js.snap +31 -0
- package/lib/v1/Button/_shared/SuccessTick/props/defaultProps.js +11 -0
- package/lib/v1/Button/_shared/SuccessTick/props/propTypes.js +18 -0
- package/lib/v1/Button/constants/index.js +114 -0
- package/lib/v1/Button/css/Button_v1.module.css +119 -0
- package/lib/v1/Button/css/cssJSLogic.js +88 -0
- package/lib/v1/Button/index.js +21 -0
- package/lib/v1/Button/props/defaultProps.js +36 -0
- package/lib/v1/Button/props/propTypes.js +56 -0
- package/lib/v1/helpers/colorHelpers/background/backgroundColor.module.css +629 -0
- package/lib/v1/helpers/colorHelpers/border/borderColor.module.css +489 -0
- package/lib/v1/helpers/colorHelpers/colorHelper.js +190 -0
- package/lib/v1/helpers/colorHelpers/constants/index.js +87 -0
- package/lib/v1/helpers/colorHelpers/index.js +57 -0
- package/lib/v1/helpers/colorHelpers/paletteUtilities.README.md +415 -0
- package/lib/v1/helpers/colorHelpers/text/textColor.module.css +368 -0
- package/package.json +9 -9
|
@@ -7,48 +7,80 @@ export default function cssJSLogic(_ref) {
|
|
|
7
7
|
} = _ref;
|
|
8
8
|
let {
|
|
9
9
|
$flag_reset,
|
|
10
|
+
shouldReset,
|
|
10
11
|
$flag_dotted,
|
|
12
|
+
isDotted,
|
|
11
13
|
$ui_size,
|
|
14
|
+
size,
|
|
12
15
|
$ui_lineClamp,
|
|
16
|
+
lineClamp,
|
|
13
17
|
$ui_lineHeight,
|
|
18
|
+
lineHeight,
|
|
14
19
|
$ui_display,
|
|
20
|
+
display,
|
|
15
21
|
$ui_weight,
|
|
22
|
+
weight,
|
|
16
23
|
$ui_typeFace,
|
|
24
|
+
typeFace,
|
|
17
25
|
$ui_textAlign,
|
|
26
|
+
textAlign,
|
|
18
27
|
$ui_letterSpacing,
|
|
28
|
+
letterSpacing,
|
|
19
29
|
$ui_transform,
|
|
30
|
+
transform,
|
|
20
31
|
$ui_decoration,
|
|
32
|
+
decoration,
|
|
21
33
|
$ui_className,
|
|
34
|
+
customClass,
|
|
22
35
|
$ui_wordBreak,
|
|
36
|
+
wordBreak,
|
|
23
37
|
$ui_wordWrap,
|
|
24
|
-
|
|
38
|
+
wordWrap,
|
|
39
|
+
$ui_whiteSpace,
|
|
40
|
+
whiteSpace
|
|
25
41
|
} = props;
|
|
42
|
+
const finalReset = shouldReset !== undefined ? shouldReset : $flag_reset;
|
|
43
|
+
const finalDotted = isDotted !== undefined ? isDotted : $flag_dotted;
|
|
44
|
+
const finalSize = size !== undefined ? size : $ui_size;
|
|
45
|
+
const finalLineClamp = lineClamp !== undefined ? lineClamp : $ui_lineClamp;
|
|
46
|
+
const finalDisplay = display !== undefined ? display : $ui_display;
|
|
47
|
+
const finalWeight = weight !== undefined ? weight : $ui_weight;
|
|
48
|
+
const finalTypeFace = typeFace !== undefined ? typeFace : $ui_typeFace;
|
|
49
|
+
const finalTextAlign = textAlign !== undefined ? textAlign : $ui_textAlign;
|
|
50
|
+
const finalTransform = transform !== undefined ? transform : $ui_transform;
|
|
51
|
+
const finalDecoration = decoration !== undefined ? decoration : $ui_decoration;
|
|
52
|
+
const finalClassName = customClass !== undefined ? customClass : $ui_className;
|
|
53
|
+
const finalWordBreak = wordBreak !== undefined ? wordBreak : $ui_wordBreak;
|
|
54
|
+
const finalWordWrap = wordWrap !== undefined ? wordWrap : $ui_wordWrap;
|
|
55
|
+
const finalWhiteSpace = whiteSpace !== undefined ? whiteSpace : $ui_whiteSpace;
|
|
56
|
+
let finalLineHeight = lineHeight !== undefined ? lineHeight : $ui_lineHeight;
|
|
57
|
+
let finalLetterSpacing = letterSpacing !== undefined ? letterSpacing : $ui_letterSpacing;
|
|
26
58
|
|
|
27
|
-
if (
|
|
28
|
-
|
|
59
|
+
if (finalLetterSpacing) {
|
|
60
|
+
finalLetterSpacing = letterspacingMapping[finalLetterSpacing];
|
|
29
61
|
}
|
|
30
62
|
|
|
31
|
-
if (
|
|
32
|
-
|
|
63
|
+
if (finalLineHeight) {
|
|
64
|
+
finalLineHeight = lineheightMapping[finalLineHeight];
|
|
33
65
|
}
|
|
34
66
|
|
|
35
67
|
let typographyClass = compileClassNames({
|
|
36
|
-
[style.reset]:
|
|
37
|
-
[style.dotted]:
|
|
38
|
-
[style[`size${
|
|
39
|
-
[style[`lineclamp_${
|
|
40
|
-
[style[`lineheight_${
|
|
41
|
-
[style[`display_${
|
|
42
|
-
[style[`font_${
|
|
43
|
-
[style[`fontStyles_${
|
|
44
|
-
[style[`textalign_${
|
|
45
|
-
[style[`letterspacing_${
|
|
46
|
-
[style[`transform_${
|
|
47
|
-
[style[`decoration_${
|
|
48
|
-
[
|
|
49
|
-
[style[`wordBreak_${
|
|
50
|
-
[style[`wordWrap_${
|
|
51
|
-
[style[`whiteSpace_${
|
|
68
|
+
[style.reset]: finalReset,
|
|
69
|
+
[style.dotted]: finalDotted,
|
|
70
|
+
[style[`size${finalSize}`]]: !!finalSize,
|
|
71
|
+
[style[`lineclamp_${finalLineClamp}`]]: !!finalLineClamp,
|
|
72
|
+
[style[`lineheight_${finalLineHeight}`]]: !!finalLineHeight,
|
|
73
|
+
[style[`display_${finalDisplay}`]]: !!finalDisplay,
|
|
74
|
+
[style[`font_${finalWeight}`]]: !!finalWeight,
|
|
75
|
+
[style[`fontStyles_${finalTypeFace}`]]: !!finalTypeFace,
|
|
76
|
+
[style[`textalign_${finalTextAlign}`]]: !!finalTextAlign,
|
|
77
|
+
[style[`letterspacing_${finalLetterSpacing}`]]: !!finalLetterSpacing,
|
|
78
|
+
[style[`transform_${finalTransform}`]]: !!finalTransform,
|
|
79
|
+
[style[`decoration_${finalDecoration}`]]: !!finalDecoration,
|
|
80
|
+
[finalClassName]: !!finalClassName,
|
|
81
|
+
[style[`wordBreak_${finalWordBreak}`]]: !!finalWordBreak,
|
|
82
|
+
[style[`wordWrap_${finalWordWrap}`]]: !!finalWordWrap,
|
|
83
|
+
[style[`whiteSpace_${finalWhiteSpace}`]]: !!finalWhiteSpace
|
|
52
84
|
});
|
|
53
85
|
return {
|
|
54
86
|
typographyClass
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { DUMMY_OBJECT } from '@zohodesk/dotkit/es/utils/constants';
|
|
1
2
|
export const defaultProps = {
|
|
2
3
|
$ui_className: '',
|
|
3
4
|
$ui_tagName: 'div',
|
|
4
5
|
$flag_reset: false,
|
|
5
6
|
$flag_dotted: false,
|
|
6
|
-
$tagAttributes_text:
|
|
7
|
-
$a11yAttributes_text:
|
|
8
|
-
$ui_highlightConfig:
|
|
7
|
+
$tagAttributes_text: DUMMY_OBJECT,
|
|
8
|
+
$a11yAttributes_text: DUMMY_OBJECT,
|
|
9
|
+
$ui_highlightConfig: DUMMY_OBJECT
|
|
9
10
|
};
|
|
@@ -1,46 +1,88 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
1
|
+
import PropTypes from 'prop-types'; // Define prop types once to avoid duplication
|
|
2
|
+
|
|
3
|
+
const propTypeDefinitions = {
|
|
4
|
+
shouldReset: PropTypes.bool,
|
|
5
|
+
display: PropTypes.oneOf(['block', 'inlineBlock', 'inline', 'initial']),
|
|
6
|
+
weight: PropTypes.oneOf(['regular', 'light', 'semibold', 'bold']),
|
|
7
|
+
isDotted: PropTypes.bool,
|
|
8
|
+
textAlign: PropTypes.oneOf(['left', 'right', 'center', 'justify']),
|
|
9
|
+
transform: PropTypes.oneOf(['default', 'upper', 'lower', 'capital']),
|
|
10
|
+
lineClamp: PropTypes.oneOf(['1', '2', '3', '4', '5']),
|
|
11
|
+
typeFace: PropTypes.oneOf(['normal', 'italic']),
|
|
12
|
+
decoration: PropTypes.oneOf(['default', 'underline', 'strike', 'overline']),
|
|
13
|
+
size: PropTypes.oneOf(['7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '24', '25', '26', '28', '29', '30', '32', '34', '35', '36', '40', '50', 'inherit']),
|
|
14
|
+
lineHeight: PropTypes.oneOf(['0', '0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9', '1', '1.1', '1.2', '1.3', '1.4', '1.5', '1.6', '1.7', '1.8', '1.9', '2', 'normal', 'initial', 'inherit']),
|
|
15
|
+
letterSpacing: PropTypes.oneOf(['0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9', '1', '1.1', '1.2', '1.3', '1.4', '1.5', '1.6', '1.7', '1.8', '1.9', '2', 'inherit']),
|
|
16
|
+
wordBreak: PropTypes.oneOf(['breakAll', 'keepAll', 'breakWord']),
|
|
17
|
+
wordWrap: PropTypes.oneOf(['normal', 'break']),
|
|
18
|
+
whiteSpace: PropTypes.oneOf(['normal', 'noWrap', 'pre', 'preLine', 'preWrap', 'breakSpaces']),
|
|
19
|
+
customClass: PropTypes.string
|
|
20
|
+
};
|
|
2
21
|
const typoStyleProps = {
|
|
3
|
-
$flag_reset:
|
|
4
|
-
|
|
5
|
-
$
|
|
6
|
-
|
|
7
|
-
$
|
|
8
|
-
|
|
9
|
-
$
|
|
10
|
-
|
|
11
|
-
$
|
|
12
|
-
|
|
13
|
-
$
|
|
14
|
-
|
|
15
|
-
$
|
|
16
|
-
|
|
17
|
-
$
|
|
18
|
-
|
|
22
|
+
$flag_reset: propTypeDefinitions.shouldReset,
|
|
23
|
+
shouldReset: propTypeDefinitions.shouldReset,
|
|
24
|
+
$flag_dotted: propTypeDefinitions.isDotted,
|
|
25
|
+
isDotted: propTypeDefinitions.isDotted,
|
|
26
|
+
$ui_display: propTypeDefinitions.display,
|
|
27
|
+
display: propTypeDefinitions.display,
|
|
28
|
+
$ui_weight: propTypeDefinitions.weight,
|
|
29
|
+
weight: propTypeDefinitions.weight,
|
|
30
|
+
$ui_textAlign: propTypeDefinitions.textAlign,
|
|
31
|
+
textAlign: propTypeDefinitions.textAlign,
|
|
32
|
+
$ui_transform: propTypeDefinitions.transform,
|
|
33
|
+
transform: propTypeDefinitions.transform,
|
|
34
|
+
$ui_lineClamp: propTypeDefinitions.lineClamp,
|
|
35
|
+
lineClamp: propTypeDefinitions.lineClamp,
|
|
36
|
+
$ui_typeFace: propTypeDefinitions.typeFace,
|
|
37
|
+
typeFace: propTypeDefinitions.typeFace,
|
|
38
|
+
$ui_decoration: propTypeDefinitions.decoration,
|
|
39
|
+
decoration: propTypeDefinitions.decoration,
|
|
40
|
+
$ui_size: propTypeDefinitions.size,
|
|
41
|
+
size: propTypeDefinitions.size,
|
|
42
|
+
$ui_lineHeight: propTypeDefinitions.lineHeight,
|
|
43
|
+
lineHeight: propTypeDefinitions.lineHeight,
|
|
44
|
+
$ui_letterSpacing: propTypeDefinitions.letterSpacing,
|
|
45
|
+
letterSpacing: propTypeDefinitions.letterSpacing,
|
|
46
|
+
$ui_wordBreak: propTypeDefinitions.wordBreak,
|
|
47
|
+
wordBreak: propTypeDefinitions.wordBreak,
|
|
48
|
+
$ui_wordWrap: propTypeDefinitions.wordWrap,
|
|
49
|
+
wordWrap: propTypeDefinitions.wordWrap,
|
|
50
|
+
$ui_whiteSpace: propTypeDefinitions.whiteSpace,
|
|
51
|
+
whiteSpace: propTypeDefinitions.whiteSpace,
|
|
52
|
+
$ui_className: propTypeDefinitions.customClass,
|
|
53
|
+
customClass: propTypeDefinitions.customClass
|
|
19
54
|
};
|
|
20
55
|
const highlightProps = {
|
|
21
56
|
customStyle: PropTypes.object,
|
|
22
57
|
shouldExcludeIndices: PropTypes.bool,
|
|
23
58
|
isCaseSensitive: PropTypes.bool,
|
|
24
59
|
isWholeWord: PropTypes.bool,
|
|
25
|
-
|
|
60
|
+
as: PropTypes.string,
|
|
26
61
|
renderHighlight: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
27
62
|
styleConfiguration: PropTypes.shape(typoStyleProps)
|
|
28
63
|
};
|
|
64
|
+
const highlightDataItemShape = PropTypes.shape({
|
|
65
|
+
text: PropTypes.string,
|
|
66
|
+
index: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number]),
|
|
67
|
+
...highlightProps
|
|
68
|
+
});
|
|
69
|
+
const highlightConfigShape = PropTypes.shape({
|
|
70
|
+
data: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, highlightDataItemShape])),
|
|
71
|
+
...highlightProps
|
|
72
|
+
});
|
|
29
73
|
export const propTypes = { ...typoStyleProps,
|
|
30
74
|
children: PropTypes.node,
|
|
31
75
|
$ui_tagName: PropTypes.string,
|
|
76
|
+
as: PropTypes.string,
|
|
32
77
|
$i18n_dataTitle: PropTypes.string,
|
|
78
|
+
dataTitle: PropTypes.string,
|
|
33
79
|
testId: PropTypes.string,
|
|
34
80
|
customId: PropTypes.string,
|
|
35
81
|
customStyle: PropTypes.object,
|
|
36
82
|
$a11yAttributes_text: PropTypes.object,
|
|
83
|
+
a11yAttributes: PropTypes.object,
|
|
37
84
|
$tagAttributes_text: PropTypes.object,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
index: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number]),
|
|
42
|
-
...highlightProps
|
|
43
|
-
})])),
|
|
44
|
-
...highlightProps
|
|
45
|
-
})
|
|
85
|
+
tagAttributes: PropTypes.object,
|
|
86
|
+
$ui_highlightConfig: highlightConfigShape,
|
|
87
|
+
highlightConfig: highlightConfigShape
|
|
46
88
|
};
|
|
@@ -11,9 +11,11 @@ export function highlightText(config) {
|
|
|
11
11
|
shouldExcludeIndices = false,
|
|
12
12
|
isCaseSensitive: enableCaseSensitiveMatch = false,
|
|
13
13
|
isWholeWord: matchWholeWordOnly = false,
|
|
14
|
-
|
|
14
|
+
as: asTag,
|
|
15
|
+
tagName: tagNameLegacy,
|
|
15
16
|
renderHighlight: customRenderer
|
|
16
17
|
} = config;
|
|
18
|
+
const wrapperTagName = asTag ?? tagNameLegacy ?? 'span';
|
|
17
19
|
|
|
18
20
|
if (!sourceText || !highlightData?.length) {
|
|
19
21
|
return sourceText;
|
|
@@ -55,7 +57,7 @@ export function highlightText(config) {
|
|
|
55
57
|
shouldExcludeIndices: itemConfiguration.shouldExcludeIndices !== undefined ? itemConfiguration.shouldExcludeIndices : shouldExcludeIndices,
|
|
56
58
|
isCaseSensitive: itemConfiguration.isCaseSensitive !== undefined ? itemConfiguration.isCaseSensitive : enableCaseSensitiveMatch,
|
|
57
59
|
matchWholeWordOnly: itemConfiguration.isWholeWord !== undefined ? itemConfiguration.isWholeWord : matchWholeWordOnly,
|
|
58
|
-
wrapperTagName: itemConfiguration.tagName !== undefined ? itemConfiguration.tagName : wrapperTagName,
|
|
60
|
+
wrapperTagName: itemConfiguration.as !== undefined ? itemConfiguration.as : itemConfiguration.tagName !== undefined ? itemConfiguration.tagName : wrapperTagName,
|
|
59
61
|
customStyle: customStyle,
|
|
60
62
|
customRenderer: itemConfiguration.renderHighlight !== undefined ? itemConfiguration.renderHighlight : customRenderer,
|
|
61
63
|
highlightClasses: typographyClass,
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
.arrowIcon {
|
|
6
6
|
composes: varClass;
|
|
7
|
+
margin-block:0 ;
|
|
8
|
+
margin-inline: var(--zd_size5) ;
|
|
7
9
|
color: var(--local-arrowIcon-color);
|
|
8
10
|
transition: transform var(--zd_transition3);
|
|
9
|
-
margin: 0 var(--zd_size5) ;
|
|
10
11
|
}
|
|
11
12
|
.transparentContainer .arrowIcon {
|
|
12
13
|
opacity: 0;
|
|
@@ -39,4 +40,4 @@
|
|
|
39
40
|
|
|
40
41
|
.readonly {
|
|
41
42
|
composes: curdefault from '../../common/common.module.css';
|
|
42
|
-
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
import React, { forwardRef, memo, useMemo } from 'react';
|
|
4
|
+
import { withComponentRegistrar } from '@zohodesk/dotkit/es/react/ComponentRegistry';
|
|
5
|
+
import Icon from '@zohodesk/icons/es/Icon';
|
|
6
|
+
import Flex from '@zohodesk/layout/es/Flex/Flex';
|
|
7
|
+
import Typography from "../../Typography/Typography";
|
|
8
|
+
import { isRenderable } from '@zohodesk/utils/es/renderNode';
|
|
9
|
+
import renderNode from '@zohodesk/utils/es/renderNode';
|
|
10
|
+
import propTypes from "./props/propTypes";
|
|
11
|
+
import defaultProps from "./props/defaultProps";
|
|
12
|
+
import { DUMMY_OBJECT } from '@zohodesk/dotkit/es/utils/constants';
|
|
13
|
+
import { ICON_PLACEMENT, LOADER_PLACEMENT, STATUS, TYPOGRAPHY_SIZE_MAP, VARIANT } from "./constants";
|
|
14
|
+
import Loader from "./_shared/Loader/Loader";
|
|
15
|
+
import SuccessTick from "./_shared/SuccessTick/SuccessTick";
|
|
16
|
+
import cssJSLogic from "./css/cssJSLogic";
|
|
17
|
+
|
|
18
|
+
const getTypographySize = size => TYPOGRAPHY_SIZE_MAP[size] || '13';
|
|
19
|
+
|
|
20
|
+
const Button = /*#__PURE__*/forwardRef(function Button(props, ref) {
|
|
21
|
+
const {
|
|
22
|
+
palette,
|
|
23
|
+
bgAppearance,
|
|
24
|
+
borderAppearance,
|
|
25
|
+
variant,
|
|
26
|
+
status,
|
|
27
|
+
loaderPlacement,
|
|
28
|
+
size,
|
|
29
|
+
iconName,
|
|
30
|
+
iconSize,
|
|
31
|
+
iconPlacement,
|
|
32
|
+
renderIcon,
|
|
33
|
+
renderBefore,
|
|
34
|
+
renderAfter,
|
|
35
|
+
renderLoader,
|
|
36
|
+
renderSuccess,
|
|
37
|
+
children,
|
|
38
|
+
type,
|
|
39
|
+
onClick,
|
|
40
|
+
isDisabled,
|
|
41
|
+
isReadOnly,
|
|
42
|
+
isSelected,
|
|
43
|
+
shape,
|
|
44
|
+
paletteShade,
|
|
45
|
+
disabledAppearance,
|
|
46
|
+
title,
|
|
47
|
+
customProps,
|
|
48
|
+
customAttributes,
|
|
49
|
+
a11yAttributes,
|
|
50
|
+
customId,
|
|
51
|
+
testId
|
|
52
|
+
} = props;
|
|
53
|
+
const isLoading = status === STATUS.LOADING;
|
|
54
|
+
const isSuccess = status === STATUS.SUCCESS;
|
|
55
|
+
const isDisabledState = isDisabled || isLoading;
|
|
56
|
+
const isInteractionDisabled = isDisabledState || isReadOnly;
|
|
57
|
+
const overlayActive = (isLoading || isSuccess) && loaderPlacement === LOADER_PLACEMENT.OVERLAY;
|
|
58
|
+
const {
|
|
59
|
+
text: contentProps = DUMMY_OBJECT,
|
|
60
|
+
icon: iconProps = DUMMY_OBJECT
|
|
61
|
+
} = customProps;
|
|
62
|
+
const iconTagAttributes = useMemo(() => ({ ...(iconProps.tagAttributes || DUMMY_OBJECT),
|
|
63
|
+
'data-test-id': testId ? `${testId}_icon` : undefined
|
|
64
|
+
}), [iconProps.tagAttributes, testId]);
|
|
65
|
+
const classes = useMemo(() => cssJSLogic({
|
|
66
|
+
props
|
|
67
|
+
}), [palette, bgAppearance, borderAppearance, paletteShade, size, variant, status, isDisabled, isReadOnly, isSelected, shape, loaderPlacement, disabledAppearance, props.customClass]);
|
|
68
|
+
const {
|
|
69
|
+
loaderOverlayClass,
|
|
70
|
+
successOverlayClass,
|
|
71
|
+
contentWrapperClass,
|
|
72
|
+
textClassName,
|
|
73
|
+
buttonClassName
|
|
74
|
+
} = classes;
|
|
75
|
+
const showIcon = variant !== VARIANT.TEXT && (renderIcon || iconName);
|
|
76
|
+
|
|
77
|
+
const _handleClick = event => {
|
|
78
|
+
if (isInteractionDisabled) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
onClick(event);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const _renderLoader = () => {
|
|
86
|
+
if (!isLoading) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (isRenderable(renderLoader)) {
|
|
91
|
+
return renderNode(renderLoader, {
|
|
92
|
+
status
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const loaderClassName = loaderPlacement === LOADER_PLACEMENT.OVERLAY ? loaderOverlayClass : '';
|
|
97
|
+
return /*#__PURE__*/React.createElement(Flex, {
|
|
98
|
+
$ui_displayMode: "flex",
|
|
99
|
+
$ui_alignItems: "center",
|
|
100
|
+
$ui_justifyContent: "center",
|
|
101
|
+
$ui_className: loaderClassName,
|
|
102
|
+
testId: testId ? `${testId}_loader` : undefined
|
|
103
|
+
}, /*#__PURE__*/React.createElement(Loader, null));
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const _renderSuccess = () => {
|
|
107
|
+
if (!isSuccess) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (isRenderable(renderSuccess)) {
|
|
112
|
+
return renderNode(renderSuccess, {
|
|
113
|
+
status
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const successClassName = loaderPlacement === LOADER_PLACEMENT.OVERLAY ? successOverlayClass : '';
|
|
118
|
+
return /*#__PURE__*/React.createElement(Flex, {
|
|
119
|
+
$ui_displayMode: "flex",
|
|
120
|
+
$ui_alignItems: "center",
|
|
121
|
+
$ui_justifyContent: "center",
|
|
122
|
+
$ui_className: successClassName,
|
|
123
|
+
testId: testId ? `${testId}_success` : undefined
|
|
124
|
+
}, /*#__PURE__*/React.createElement(SuccessTick, null));
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const _renderIconNode = () => {
|
|
128
|
+
if (!showIcon) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (isRenderable(renderIcon)) {
|
|
133
|
+
return renderNode(renderIcon);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return /*#__PURE__*/React.createElement(Icon, _extends({}, iconProps, {
|
|
137
|
+
name: iconName,
|
|
138
|
+
size: iconSize,
|
|
139
|
+
tagAttributes: iconTagAttributes,
|
|
140
|
+
dataId: testId ? `${testId}_icon` : undefined
|
|
141
|
+
}));
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const _renderBeforeNode = () => {
|
|
145
|
+
if (!isRenderable(renderBefore)) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return renderNode(renderBefore, props);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const _renderAfterNode = () => {
|
|
153
|
+
if (!isRenderable(renderAfter)) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return renderNode(renderAfter, props);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const _renderContent = () => {
|
|
161
|
+
const shouldShowText = variant !== VARIANT.ICON && children !== undefined && children !== null;
|
|
162
|
+
const showLoaderStart = isLoading && loaderPlacement === LOADER_PLACEMENT.START;
|
|
163
|
+
const showLoaderAfter = isLoading && loaderPlacement === LOADER_PLACEMENT.END;
|
|
164
|
+
const showSuccessStart = isSuccess && loaderPlacement === LOADER_PLACEMENT.START;
|
|
165
|
+
const showSuccessAfter = isSuccess && loaderPlacement === LOADER_PLACEMENT.END;
|
|
166
|
+
return /*#__PURE__*/React.createElement(Flex, {
|
|
167
|
+
$ui_displayMode: "flex",
|
|
168
|
+
$ui_direction: "row",
|
|
169
|
+
$flag_shrink: true,
|
|
170
|
+
$ui_alignItems: "center",
|
|
171
|
+
$ui_justifyContent: "center",
|
|
172
|
+
$ui_className: contentWrapperClass
|
|
173
|
+
}, showLoaderStart ? _renderLoader() : null, showSuccessStart ? _renderSuccess() : null, _renderBeforeNode(), iconPlacement === ICON_PLACEMENT.LEFT ? _renderIconNode() : null, shouldShowText ? /*#__PURE__*/React.createElement(Typography, _extends({}, contentProps, {
|
|
174
|
+
$ui_className: textClassName,
|
|
175
|
+
$ui_size: getTypographySize(size),
|
|
176
|
+
$flag_dotted: variant !== VARIANT.ICON
|
|
177
|
+
}), children) : null, iconPlacement === ICON_PLACEMENT.RIGHT ? _renderIconNode() : null, _renderAfterNode(), showLoaderAfter ? _renderLoader() : null, showSuccessAfter ? _renderSuccess() : null);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const containerAttributes = { ...customAttributes,
|
|
181
|
+
'data-id': customId,
|
|
182
|
+
'data-test-id': testId,
|
|
183
|
+
'data-title': title
|
|
184
|
+
};
|
|
185
|
+
return /*#__PURE__*/React.createElement("button", _extends({}, containerAttributes, a11yAttributes, {
|
|
186
|
+
ref: ref,
|
|
187
|
+
type: type,
|
|
188
|
+
className: buttonClassName,
|
|
189
|
+
"aria-busy": isLoading,
|
|
190
|
+
"aria-disabled": isDisabledState,
|
|
191
|
+
"aria-readonly": isReadOnly,
|
|
192
|
+
"aria-pressed": isSelected,
|
|
193
|
+
onClick: _handleClick
|
|
194
|
+
}), _renderContent(), overlayActive ? isLoading ? _renderLoader() : _renderSuccess() : null);
|
|
195
|
+
});
|
|
196
|
+
Button.propTypes = propTypes;
|
|
197
|
+
Button.defaultProps = defaultProps;
|
|
198
|
+
Button.displayName = 'Button';
|
|
199
|
+
export default withComponentRegistrar( /*#__PURE__*/memo(Button), {
|
|
200
|
+
name: 'ZDC_V1_Button'
|
|
201
|
+
});
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Button
|
|
2
|
+
|
|
3
|
+
A composable button component with palette-based theming, loading/success status states, and flexible icon/content slots.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```jsx
|
|
8
|
+
import Button from '@zohodesk/components/es/v1/Button/Button';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Default
|
|
14
|
+
|
|
15
|
+
```jsx
|
|
16
|
+
<Button customId="saveBtn" testId="saveBtn">
|
|
17
|
+
Save changes
|
|
18
|
+
</Button>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### With Palette Variants
|
|
22
|
+
|
|
23
|
+
```jsx
|
|
24
|
+
<Button palette="primary">Save</Button>
|
|
25
|
+
<Button palette="danger">Delete</Button>
|
|
26
|
+
<Button palette="success">Confirm</Button>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### With Icon
|
|
30
|
+
|
|
31
|
+
```jsx
|
|
32
|
+
<Button variant="icon" iconName="ZD-plus" iconSize={20} />
|
|
33
|
+
|
|
34
|
+
<Button variant="iconWithText" iconName="ZD-plus" iconPlacement="left">
|
|
35
|
+
Add Item
|
|
36
|
+
</Button>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Loading State
|
|
40
|
+
|
|
41
|
+
```jsx
|
|
42
|
+
<Button status="loading" loaderPlacement="overlay">
|
|
43
|
+
Saving...
|
|
44
|
+
</Button>
|
|
45
|
+
|
|
46
|
+
<Button status="loading" loaderPlacement="start">
|
|
47
|
+
Loading
|
|
48
|
+
</Button>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Disabled / Read Only
|
|
52
|
+
|
|
53
|
+
```jsx
|
|
54
|
+
<Button isDisabled>Disabled</Button>
|
|
55
|
+
<Button isReadOnly>Read Only</Button>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Props
|
|
59
|
+
|
|
60
|
+
| Prop | Type | Default | Description |
|
|
61
|
+
|---|---|---|---|
|
|
62
|
+
| `customId` | `string` | — | `data-id` attribute for automation |
|
|
63
|
+
| `testId` | `string` | — | `data-test-id` attribute for testing |
|
|
64
|
+
| `palette` | `oneOf: default, primary, secondary, danger, success` | `default` | Color palette |
|
|
65
|
+
| `bgAppearance` | `oneOf: filled, onHover, none` | `filled` | Background behavior |
|
|
66
|
+
| `borderAppearance` | `oneOf: default, onHover, none` | `default` | Border behavior |
|
|
67
|
+
| `variant` | `oneOf: text, icon, iconWithText` | `text` | Display variant |
|
|
68
|
+
| `size` | `oneOf: small, medium, large, full` | `medium` | Size variant |
|
|
69
|
+
| `status` | `oneOf: default, loading, success` | `default` | Status state |
|
|
70
|
+
| `loaderPlacement` | `oneOf: start, end, overlay` | `overlay` | Where loader appears |
|
|
71
|
+
| `iconName` | `string` | — | Icon name from `@zohodesk/icons` |
|
|
72
|
+
| `iconSize` | `number` | `16` | Icon size in pixels |
|
|
73
|
+
| `iconPlacement` | `oneOf: left, right` | `left` | Icon position relative to text |
|
|
74
|
+
| `paletteShade` | `oneOf: default, lighter` | `default` | Shade variant |
|
|
75
|
+
| `disabledAppearance` | `oneOf: none, dull, strike` | `dull` | Disabled visual style |
|
|
76
|
+
| `renderIcon` | `node \| func` | — | Custom icon render slot |
|
|
77
|
+
| `renderBefore` | `node \| func` | — | Slot before main content |
|
|
78
|
+
| `renderAfter` | `node \| func` | — | Slot after main content |
|
|
79
|
+
| `renderLoader` | `node \| func` | — | Custom loader render slot |
|
|
80
|
+
| `renderSuccess` | `node \| func` | — | Custom success render slot |
|
|
81
|
+
| `children` | `node` | — | Button text content |
|
|
82
|
+
| `type` | `oneOf: button, submit, reset` | `button` | HTML button type |
|
|
83
|
+
| `onClick` | `func` | — | Click event handler |
|
|
84
|
+
| `isDisabled` | `bool` | `false` | Disables the button |
|
|
85
|
+
| `isReadOnly` | `bool` | `false` | Read-only state |
|
|
86
|
+
| `isSelected` | `bool` | `false` | Selected/pressed state |
|
|
87
|
+
| `isRounded` | `bool` | `false` | Rounded border radius |
|
|
88
|
+
| `title` | `string` | — | Title/tooltip text |
|
|
89
|
+
|
|
90
|
+
## Customization
|
|
91
|
+
|
|
92
|
+
### Parts
|
|
93
|
+
|
|
94
|
+
| Part | Element | Description |
|
|
95
|
+
|---|---|---|
|
|
96
|
+
| `wrapper` | `<button>` root | The outermost button element |
|
|
97
|
+
| `text` | Typography | The text label |
|
|
98
|
+
|
|
99
|
+
### CSS Custom Properties
|
|
100
|
+
|
|
101
|
+
The `.varClass` block in `Button.module.css` defines local custom properties that size variants override:
|
|
102
|
+
|
|
103
|
+
| Property | Default | Description |
|
|
104
|
+
|---|---|---|
|
|
105
|
+
| `--local-Button-radius` | `4px` | Border radius |
|
|
106
|
+
| `--local-Button-gap` | `8px` | Content gap |
|
|
107
|
+
| `--local-Button-padding-block` | `6px` | Block padding |
|
|
108
|
+
| `--local-Button-padding-inline` | `15px` | Inline padding |
|
|
109
|
+
| `--local-Button-min-width` | `90px` | Minimum width |
|
|
110
|
+
| `--local-Button-spinner-size` | `16px` | Spinner/tick size |
|