@zohodesk/utils 1.0.2-alpha.4 → 1.0.3-alpha.0

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.
@@ -31,4 +31,11 @@ export const shapeList = {
31
31
  roundedRect: 'shape_roundedRect',
32
32
  rounded: 'shape_rounded'
33
33
  };
34
- export const shapes = Object.values(shapeList);
34
+ export const shapes = Object.values(shapeList);
35
+ export const decorationList = {
36
+ overLine: 'decoration_overline',
37
+ lineThrough: 'decoration_linethrough',
38
+ underLine: 'decoration_underline',
39
+ none: 'decoration_none'
40
+ };
41
+ export const decorations = Object.values(decorationList);
package/es/mergeStyle.js CHANGED
@@ -1,28 +1,31 @@
1
+ import "core-js/modules/es.array.includes";
2
+
1
3
  /**
2
- * REPLACER_SYMBOL used to indentify
4
+ * REPLACER_SYMBOL used to indentify
3
5
  */
4
- const REPLACER_SYMBOL = "$";
6
+ const REPLACER_SYMBOL = '$';
5
7
  /**
6
8
  * $ startWith is used for replace the existing style.
7
9
  * all other will be append
8
- * @param {*} defaultStyle
10
+ * @param {*} defaultStyle
9
11
  * @param {*} customStyle
10
12
  * @returns
11
13
  */
12
14
 
13
15
  export default function mergeStyle(defaultStyle, customStyle) {
16
+ let additionalStyle = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
14
17
  return Object.keys(customStyle).reduce((res, next) => {
15
18
  if (next.startsWith(REPLACER_SYMBOL)) {
16
19
  let styleValue = customStyle[next];
17
- let styleName = next.replace(REPLACER_SYMBOL, "");
20
+ let styleName = next.replace(REPLACER_SYMBOL, '');
18
21
 
19
- if (!defaultStyle[styleName]) {
22
+ if (!defaultStyle[styleName] && !additionalStyle.includes(styleName)) {
20
23
  return res;
21
24
  }
22
25
 
23
26
  res[styleName] = styleValue;
24
- } else if (defaultStyle[next]) {
25
- res[next] = defaultStyle[next] + " " + customStyle[next];
27
+ } else if (defaultStyle[next] || additionalStyle.includes(next)) {
28
+ res[next] = (defaultStyle[next] || '') + ' ' + customStyle[next];
26
29
  }
27
30
 
28
31
  return res;
@@ -2,7 +2,7 @@
2
2
 
3
3
  /* eslint-disable no-restricted-syntax */
4
4
  import PropTypes from 'prop-types';
5
- import { variants, colors, sizes, shapes } from "../constantProps";
5
+ import { variants, colors, sizes, shapes, decorations } from '../constantProps';
6
6
  export const getVariantProps = (variants, exvariant) => {
7
7
  let variant = [];
8
8
 
@@ -48,11 +48,11 @@ export const getSizeProps = (sizes, exSizes) => {
48
48
  export const sizeProps = {
49
49
  size: PropTypes.oneOf(sizes)
50
50
  };
51
- export const getShapeProps = (shapes, exshapes) => {
51
+ export const getShapeProps = (shapes, exShapes) => {
52
52
  let shape = [];
53
53
 
54
- if (exshapes) {
55
- shape = [...exshapes];
54
+ if (exShapes) {
55
+ shape = [...exShapes];
56
56
  }
57
57
 
58
58
  shape = [...shape, ...shapes];
@@ -62,4 +62,19 @@ export const getShapeProps = (shapes, exshapes) => {
62
62
  };
63
63
  export const shapeProps = {
64
64
  shape: PropTypes.oneOf(shapes)
65
+ };
66
+ export const getDecorationProps = (decorations, exDecorations) => {
67
+ let decoration = [];
68
+
69
+ if (exDecorations) {
70
+ decoration = [...exDecorations];
71
+ }
72
+
73
+ decoration = [...decoration, ...decorations];
74
+ return {
75
+ textDecoration: PropTypes.oneOf(decoration)
76
+ };
77
+ };
78
+ export const decorationProps = {
79
+ decoration: PropTypes.oneOf(decorations)
65
80
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/utils",
3
- "version": "1.0.2-alpha.4",
3
+ "version": "1.0.3-alpha.0",
4
4
  "description": "",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -22,5 +22,5 @@
22
22
  ],
23
23
  "author": "",
24
24
  "license": "ISC",
25
- "gitHead": "b67155519d8631c1e4674a1199e6051361db1b03"
25
+ "gitHead": "da782dc40951b76af85d2091c4c72dd2a6bf6969"
26
26
  }