@zohodesk/components 1.6.7 → 1.6.8
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 +8 -0
- 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/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/package.json +6 -6
|
@@ -17,31 +17,63 @@ function cssJSLogic(_ref) {
|
|
|
17
17
|
var props = _ref.props,
|
|
18
18
|
style = _ref.style;
|
|
19
19
|
var $flag_reset = props.$flag_reset,
|
|
20
|
+
shouldReset = props.shouldReset,
|
|
20
21
|
$flag_dotted = props.$flag_dotted,
|
|
22
|
+
isDotted = props.isDotted,
|
|
21
23
|
$ui_size = props.$ui_size,
|
|
24
|
+
size = props.size,
|
|
22
25
|
$ui_lineClamp = props.$ui_lineClamp,
|
|
26
|
+
lineClamp = props.lineClamp,
|
|
23
27
|
$ui_lineHeight = props.$ui_lineHeight,
|
|
28
|
+
lineHeight = props.lineHeight,
|
|
24
29
|
$ui_display = props.$ui_display,
|
|
30
|
+
display = props.display,
|
|
25
31
|
$ui_weight = props.$ui_weight,
|
|
32
|
+
weight = props.weight,
|
|
26
33
|
$ui_typeFace = props.$ui_typeFace,
|
|
34
|
+
typeFace = props.typeFace,
|
|
27
35
|
$ui_textAlign = props.$ui_textAlign,
|
|
36
|
+
textAlign = props.textAlign,
|
|
28
37
|
$ui_letterSpacing = props.$ui_letterSpacing,
|
|
38
|
+
letterSpacing = props.letterSpacing,
|
|
29
39
|
$ui_transform = props.$ui_transform,
|
|
40
|
+
transform = props.transform,
|
|
30
41
|
$ui_decoration = props.$ui_decoration,
|
|
42
|
+
decoration = props.decoration,
|
|
31
43
|
$ui_className = props.$ui_className,
|
|
44
|
+
customClass = props.customClass,
|
|
32
45
|
$ui_wordBreak = props.$ui_wordBreak,
|
|
46
|
+
wordBreak = props.wordBreak,
|
|
33
47
|
$ui_wordWrap = props.$ui_wordWrap,
|
|
34
|
-
|
|
48
|
+
wordWrap = props.wordWrap,
|
|
49
|
+
$ui_whiteSpace = props.$ui_whiteSpace,
|
|
50
|
+
whiteSpace = props.whiteSpace;
|
|
51
|
+
var finalReset = shouldReset !== undefined ? shouldReset : $flag_reset;
|
|
52
|
+
var finalDotted = isDotted !== undefined ? isDotted : $flag_dotted;
|
|
53
|
+
var finalSize = size !== undefined ? size : $ui_size;
|
|
54
|
+
var finalLineClamp = lineClamp !== undefined ? lineClamp : $ui_lineClamp;
|
|
55
|
+
var finalDisplay = display !== undefined ? display : $ui_display;
|
|
56
|
+
var finalWeight = weight !== undefined ? weight : $ui_weight;
|
|
57
|
+
var finalTypeFace = typeFace !== undefined ? typeFace : $ui_typeFace;
|
|
58
|
+
var finalTextAlign = textAlign !== undefined ? textAlign : $ui_textAlign;
|
|
59
|
+
var finalTransform = transform !== undefined ? transform : $ui_transform;
|
|
60
|
+
var finalDecoration = decoration !== undefined ? decoration : $ui_decoration;
|
|
61
|
+
var finalClassName = customClass !== undefined ? customClass : $ui_className;
|
|
62
|
+
var finalWordBreak = wordBreak !== undefined ? wordBreak : $ui_wordBreak;
|
|
63
|
+
var finalWordWrap = wordWrap !== undefined ? wordWrap : $ui_wordWrap;
|
|
64
|
+
var finalWhiteSpace = whiteSpace !== undefined ? whiteSpace : $ui_whiteSpace;
|
|
65
|
+
var finalLineHeight = lineHeight !== undefined ? lineHeight : $ui_lineHeight;
|
|
66
|
+
var finalLetterSpacing = letterSpacing !== undefined ? letterSpacing : $ui_letterSpacing;
|
|
35
67
|
|
|
36
|
-
if (
|
|
37
|
-
|
|
68
|
+
if (finalLetterSpacing) {
|
|
69
|
+
finalLetterSpacing = _utils2.letterspacingMapping[finalLetterSpacing];
|
|
38
70
|
}
|
|
39
71
|
|
|
40
|
-
if (
|
|
41
|
-
|
|
72
|
+
if (finalLineHeight) {
|
|
73
|
+
finalLineHeight = _utils2.lineheightMapping[finalLineHeight];
|
|
42
74
|
}
|
|
43
75
|
|
|
44
|
-
var typographyClass = (0, _utils.compileClassNames)((_compileClassNames = {}, _defineProperty(_compileClassNames, style.reset,
|
|
76
|
+
var typographyClass = (0, _utils.compileClassNames)((_compileClassNames = {}, _defineProperty(_compileClassNames, style.reset, finalReset), _defineProperty(_compileClassNames, style.dotted, finalDotted), _defineProperty(_compileClassNames, style["size".concat(finalSize)], !!finalSize), _defineProperty(_compileClassNames, style["lineclamp_".concat(finalLineClamp)], !!finalLineClamp), _defineProperty(_compileClassNames, style["lineheight_".concat(finalLineHeight)], !!finalLineHeight), _defineProperty(_compileClassNames, style["display_".concat(finalDisplay)], !!finalDisplay), _defineProperty(_compileClassNames, style["font_".concat(finalWeight)], !!finalWeight), _defineProperty(_compileClassNames, style["fontStyles_".concat(finalTypeFace)], !!finalTypeFace), _defineProperty(_compileClassNames, style["textalign_".concat(finalTextAlign)], !!finalTextAlign), _defineProperty(_compileClassNames, style["letterspacing_".concat(finalLetterSpacing)], !!finalLetterSpacing), _defineProperty(_compileClassNames, style["transform_".concat(finalTransform)], !!finalTransform), _defineProperty(_compileClassNames, style["decoration_".concat(finalDecoration)], !!finalDecoration), _defineProperty(_compileClassNames, finalClassName, !!finalClassName), _defineProperty(_compileClassNames, style["wordBreak_".concat(finalWordBreak)], !!finalWordBreak), _defineProperty(_compileClassNames, style["wordWrap_".concat(finalWordWrap)], !!finalWordWrap), _defineProperty(_compileClassNames, style["whiteSpace_".concat(finalWhiteSpace)], !!finalWhiteSpace), _compileClassNames));
|
|
45
77
|
return {
|
|
46
78
|
typographyClass: typographyClass
|
|
47
79
|
};
|
|
@@ -4,13 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.defaultProps = void 0;
|
|
7
|
+
|
|
8
|
+
var _constants = require("@zohodesk/dotkit/es/utils/constants");
|
|
9
|
+
|
|
7
10
|
var defaultProps = {
|
|
8
11
|
$ui_className: '',
|
|
9
12
|
$ui_tagName: 'div',
|
|
10
13
|
$flag_reset: false,
|
|
11
14
|
$flag_dotted: false,
|
|
12
|
-
$tagAttributes_text:
|
|
13
|
-
$a11yAttributes_text:
|
|
14
|
-
$ui_highlightConfig:
|
|
15
|
+
$tagAttributes_text: _constants.DUMMY_OBJECT,
|
|
16
|
+
$a11yAttributes_text: _constants.DUMMY_OBJECT,
|
|
17
|
+
$ui_highlightConfig: _constants.DUMMY_OBJECT
|
|
15
18
|
};
|
|
16
19
|
exports.defaultProps = defaultProps;
|
|
@@ -15,49 +15,93 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
15
15
|
|
|
16
16
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
17
|
|
|
18
|
+
// Define prop types once to avoid duplication
|
|
19
|
+
var propTypeDefinitions = {
|
|
20
|
+
shouldReset: _propTypes["default"].bool,
|
|
21
|
+
display: _propTypes["default"].oneOf(['block', 'inlineBlock', 'inline', 'initial']),
|
|
22
|
+
weight: _propTypes["default"].oneOf(['regular', 'light', 'semibold', 'bold']),
|
|
23
|
+
isDotted: _propTypes["default"].bool,
|
|
24
|
+
textAlign: _propTypes["default"].oneOf(['left', 'right', 'center', 'justify']),
|
|
25
|
+
transform: _propTypes["default"].oneOf(['default', 'upper', 'lower', 'capital']),
|
|
26
|
+
lineClamp: _propTypes["default"].oneOf(['1', '2', '3', '4', '5']),
|
|
27
|
+
typeFace: _propTypes["default"].oneOf(['normal', 'italic']),
|
|
28
|
+
decoration: _propTypes["default"].oneOf(['default', 'underline', 'strike', 'overline']),
|
|
29
|
+
size: _propTypes["default"].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']),
|
|
30
|
+
lineHeight: _propTypes["default"].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']),
|
|
31
|
+
letterSpacing: _propTypes["default"].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']),
|
|
32
|
+
wordBreak: _propTypes["default"].oneOf(['breakAll', 'keepAll', 'breakWord']),
|
|
33
|
+
wordWrap: _propTypes["default"].oneOf(['normal', 'break']),
|
|
34
|
+
whiteSpace: _propTypes["default"].oneOf(['normal', 'noWrap', 'pre', 'preLine', 'preWrap', 'breakSpaces']),
|
|
35
|
+
customClass: _propTypes["default"].string
|
|
36
|
+
};
|
|
18
37
|
var typoStyleProps = {
|
|
19
|
-
$flag_reset:
|
|
20
|
-
|
|
21
|
-
$
|
|
22
|
-
|
|
23
|
-
$
|
|
24
|
-
|
|
25
|
-
$
|
|
26
|
-
|
|
27
|
-
$
|
|
28
|
-
|
|
29
|
-
$
|
|
30
|
-
|
|
31
|
-
$
|
|
32
|
-
|
|
33
|
-
$
|
|
34
|
-
|
|
38
|
+
$flag_reset: propTypeDefinitions.shouldReset,
|
|
39
|
+
shouldReset: propTypeDefinitions.shouldReset,
|
|
40
|
+
$flag_dotted: propTypeDefinitions.isDotted,
|
|
41
|
+
isDotted: propTypeDefinitions.isDotted,
|
|
42
|
+
$ui_display: propTypeDefinitions.display,
|
|
43
|
+
display: propTypeDefinitions.display,
|
|
44
|
+
$ui_weight: propTypeDefinitions.weight,
|
|
45
|
+
weight: propTypeDefinitions.weight,
|
|
46
|
+
$ui_textAlign: propTypeDefinitions.textAlign,
|
|
47
|
+
textAlign: propTypeDefinitions.textAlign,
|
|
48
|
+
$ui_transform: propTypeDefinitions.transform,
|
|
49
|
+
transform: propTypeDefinitions.transform,
|
|
50
|
+
$ui_lineClamp: propTypeDefinitions.lineClamp,
|
|
51
|
+
lineClamp: propTypeDefinitions.lineClamp,
|
|
52
|
+
$ui_typeFace: propTypeDefinitions.typeFace,
|
|
53
|
+
typeFace: propTypeDefinitions.typeFace,
|
|
54
|
+
$ui_decoration: propTypeDefinitions.decoration,
|
|
55
|
+
decoration: propTypeDefinitions.decoration,
|
|
56
|
+
$ui_size: propTypeDefinitions.size,
|
|
57
|
+
size: propTypeDefinitions.size,
|
|
58
|
+
$ui_lineHeight: propTypeDefinitions.lineHeight,
|
|
59
|
+
lineHeight: propTypeDefinitions.lineHeight,
|
|
60
|
+
$ui_letterSpacing: propTypeDefinitions.letterSpacing,
|
|
61
|
+
letterSpacing: propTypeDefinitions.letterSpacing,
|
|
62
|
+
$ui_wordBreak: propTypeDefinitions.wordBreak,
|
|
63
|
+
wordBreak: propTypeDefinitions.wordBreak,
|
|
64
|
+
$ui_wordWrap: propTypeDefinitions.wordWrap,
|
|
65
|
+
wordWrap: propTypeDefinitions.wordWrap,
|
|
66
|
+
$ui_whiteSpace: propTypeDefinitions.whiteSpace,
|
|
67
|
+
whiteSpace: propTypeDefinitions.whiteSpace,
|
|
68
|
+
$ui_className: propTypeDefinitions.customClass,
|
|
69
|
+
customClass: propTypeDefinitions.customClass
|
|
35
70
|
};
|
|
36
71
|
var highlightProps = {
|
|
37
72
|
customStyle: _propTypes["default"].object,
|
|
38
73
|
shouldExcludeIndices: _propTypes["default"].bool,
|
|
39
74
|
isCaseSensitive: _propTypes["default"].bool,
|
|
40
75
|
isWholeWord: _propTypes["default"].bool,
|
|
41
|
-
|
|
76
|
+
as: _propTypes["default"].string,
|
|
42
77
|
renderHighlight: _propTypes["default"].oneOfType([_propTypes["default"].func, _propTypes["default"].node]),
|
|
43
78
|
styleConfiguration: _propTypes["default"].shape(typoStyleProps)
|
|
44
79
|
};
|
|
45
80
|
|
|
81
|
+
var highlightDataItemShape = _propTypes["default"].shape(_objectSpread({
|
|
82
|
+
text: _propTypes["default"].string,
|
|
83
|
+
index: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].number), _propTypes["default"].number])
|
|
84
|
+
}, highlightProps));
|
|
85
|
+
|
|
86
|
+
var highlightConfigShape = _propTypes["default"].shape(_objectSpread({
|
|
87
|
+
data: _propTypes["default"].arrayOf(_propTypes["default"].oneOfType([_propTypes["default"].string, highlightDataItemShape]))
|
|
88
|
+
}, highlightProps));
|
|
89
|
+
|
|
46
90
|
var propTypes = _objectSpread(_objectSpread({}, typoStyleProps), {}, {
|
|
47
91
|
children: _propTypes["default"].node,
|
|
48
92
|
$ui_tagName: _propTypes["default"].string,
|
|
93
|
+
as: _propTypes["default"].string,
|
|
49
94
|
$i18n_dataTitle: _propTypes["default"].string,
|
|
95
|
+
dataTitle: _propTypes["default"].string,
|
|
50
96
|
testId: _propTypes["default"].string,
|
|
51
97
|
customId: _propTypes["default"].string,
|
|
52
98
|
customStyle: _propTypes["default"].object,
|
|
53
99
|
$a11yAttributes_text: _propTypes["default"].object,
|
|
100
|
+
a11yAttributes: _propTypes["default"].object,
|
|
54
101
|
$tagAttributes_text: _propTypes["default"].object,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
index: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].number), _propTypes["default"].number])
|
|
59
|
-
}, highlightProps))]))
|
|
60
|
-
}, highlightProps))
|
|
102
|
+
tagAttributes: _propTypes["default"].object,
|
|
103
|
+
$ui_highlightConfig: highlightConfigShape,
|
|
104
|
+
highlightConfig: highlightConfigShape
|
|
61
105
|
});
|
|
62
106
|
|
|
63
107
|
exports.propTypes = propTypes;
|
|
@@ -24,6 +24,8 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
24
24
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
25
25
|
|
|
26
26
|
function highlightText(config) {
|
|
27
|
+
var _ref;
|
|
28
|
+
|
|
27
29
|
var sourceText = config.text,
|
|
28
30
|
highlightData = config.data,
|
|
29
31
|
_config$styleConfigur = config.styleConfiguration,
|
|
@@ -34,9 +36,10 @@ function highlightText(config) {
|
|
|
34
36
|
enableCaseSensitiveMatch = _config$isCaseSensiti === void 0 ? false : _config$isCaseSensiti,
|
|
35
37
|
_config$isWholeWord = config.isWholeWord,
|
|
36
38
|
matchWholeWordOnly = _config$isWholeWord === void 0 ? false : _config$isWholeWord,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
asTag = config.as,
|
|
40
|
+
tagNameLegacy = config.tagName,
|
|
39
41
|
customRenderer = config.renderHighlight;
|
|
42
|
+
var wrapperTagName = (_ref = asTag !== null && asTag !== void 0 ? asTag : tagNameLegacy) !== null && _ref !== void 0 ? _ref : 'span';
|
|
40
43
|
|
|
41
44
|
if (!sourceText || !(highlightData !== null && highlightData !== void 0 && highlightData.length)) {
|
|
42
45
|
return sourceText;
|
|
@@ -78,7 +81,7 @@ function highlightText(config) {
|
|
|
78
81
|
shouldExcludeIndices: itemConfiguration.shouldExcludeIndices !== undefined ? itemConfiguration.shouldExcludeIndices : shouldExcludeIndices,
|
|
79
82
|
isCaseSensitive: itemConfiguration.isCaseSensitive !== undefined ? itemConfiguration.isCaseSensitive : enableCaseSensitiveMatch,
|
|
80
83
|
matchWholeWordOnly: itemConfiguration.isWholeWord !== undefined ? itemConfiguration.isWholeWord : matchWholeWordOnly,
|
|
81
|
-
wrapperTagName: itemConfiguration.tagName !== undefined ? itemConfiguration.tagName : wrapperTagName,
|
|
84
|
+
wrapperTagName: itemConfiguration.as !== undefined ? itemConfiguration.as : itemConfiguration.tagName !== undefined ? itemConfiguration.tagName : wrapperTagName,
|
|
82
85
|
customStyle: customStyle,
|
|
83
86
|
customRenderer: itemConfiguration.renderHighlight !== undefined ? itemConfiguration.renderHighlight : customRenderer,
|
|
84
87
|
highlightClasses: typographyClass,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/components",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.8",
|
|
4
4
|
"main": "es/index.js",
|
|
5
5
|
"module": "es/index.js",
|
|
6
6
|
"private": false,
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"build:external": "npm run clean && npm run init && npm run docsjs:build && npm run build:externalDocCopy && npm run externalDocHTMLChange",
|
|
45
45
|
"download": "npm run download_only && cd ../ && npm run download",
|
|
46
46
|
"download_only": "react-cli clean ./node_modules ./package-lock.json && npm install --legacy-peer-deps",
|
|
47
|
-
"expublish": "
|
|
47
|
+
"expublish": "node ../publish.js -- exp",
|
|
48
48
|
"css:lineheight:validate": "node ./node_modules/@zohodesk-private/node-plugins/es/lineheight_automation/lineHeightErrorCheck.js ./src/",
|
|
49
49
|
"variable:addignore": "node ./node_modules/@zohodesk-private/css-variable-migrator/es/variableIgnore.js ./src",
|
|
50
50
|
"variable:convert": "node ./node_modules/@zohodesk-private/css-variable-migrator/es/pxParserPostcss.js ./src",
|
|
@@ -83,9 +83,9 @@
|
|
|
83
83
|
"@zohodesk/hooks": "2.0.8",
|
|
84
84
|
"@zohodesk/icons": "1.2.8",
|
|
85
85
|
"@zohodesk/layout": "3.1.0",
|
|
86
|
-
"@zohodesk/svg": "1.3.
|
|
86
|
+
"@zohodesk/svg": "1.3.5",
|
|
87
87
|
"@zohodesk/utils": "1.3.16",
|
|
88
|
-
"@zohodesk/variables": "1.3.
|
|
88
|
+
"@zohodesk/variables": "1.3.1",
|
|
89
89
|
"@zohodesk/virtualizer": "1.0.13",
|
|
90
90
|
"react-sortable-hoc": "^0.8.3",
|
|
91
91
|
"velocity-react": "1.4.3",
|
|
@@ -101,8 +101,8 @@
|
|
|
101
101
|
},
|
|
102
102
|
"peerDependencies": {
|
|
103
103
|
"@zohodesk/icons": "1.2.8",
|
|
104
|
-
"@zohodesk/variables": "1.3.
|
|
105
|
-
"@zohodesk/svg": "1.3.
|
|
104
|
+
"@zohodesk/variables": "1.3.1",
|
|
105
|
+
"@zohodesk/svg": "1.3.5",
|
|
106
106
|
"@zohodesk/virtualizer": "1.0.13",
|
|
107
107
|
"velocity-react": "1.4.3",
|
|
108
108
|
"react-sortable-hoc": "^0.8.3",
|