@zohodesk/utils 1.0.4 → 1.0.5
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/es/ErrorBoundary.js +0 -5
- package/es/abbreviateNumber.js +6 -9
- package/es/applyOpenToCustomize.js +2 -7
- package/es/combineCustomStyle.js +5 -4
- package/es/compileClassNames.js +3 -6
- package/es/constantProps/uiProps.js +10 -1
- package/es/contextFactory.js +0 -2
- package/es/createTemplateLiteral.js +1 -4
- package/es/dataTypes.js +0 -1
- package/es/debounce.js +0 -1
- package/es/disCustomStyleProps.js +21 -0
- package/es/getCompliedClassName.js +0 -2
- package/es/getCompliedCustomId.js +2 -2
- package/es/isTouchDevice.js +0 -1
- package/es/loadResource.js +0 -11
- package/es/mergeStyle.js +2 -7
- package/es/omit.js +0 -2
- package/es/props/customStyleProps.js +1 -1
- package/es/props/tagAttributeProps.js +1 -3
- package/es/props/tagGeneralAttributeProps.js +1 -3
- package/es/props/uiProps.js +14 -12
- package/es/reducerHandler.js +0 -3
- package/es/uniqueNumber.js +2 -2
- package/package.json +2 -2
package/es/ErrorBoundary.js
CHANGED
|
@@ -6,24 +6,19 @@ export default class ErrorBoundary extends React.Component {
|
|
|
6
6
|
hasError: false
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
|
-
|
|
10
9
|
static getDerivedStateFromError(error) {
|
|
11
10
|
return {
|
|
12
11
|
hasError: true,
|
|
13
12
|
error
|
|
14
13
|
};
|
|
15
14
|
}
|
|
16
|
-
|
|
17
15
|
componentDidCatch(error, errorInfo) {
|
|
18
16
|
console.log(error, errorInfo);
|
|
19
17
|
}
|
|
20
|
-
|
|
21
18
|
render() {
|
|
22
19
|
if (this.state.hasError) {
|
|
23
20
|
return this.props.renderFallback(this.state.error);
|
|
24
21
|
}
|
|
25
|
-
|
|
26
22
|
return this.props.children;
|
|
27
23
|
}
|
|
28
|
-
|
|
29
24
|
}
|
package/es/abbreviateNumber.js
CHANGED
|
@@ -10,20 +10,18 @@
|
|
|
10
10
|
export default function abbreviateNumber() {
|
|
11
11
|
let count = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
12
12
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
13
|
-
|
|
14
13
|
if (typeof count === "string") {
|
|
15
14
|
count = parseInt(count);
|
|
16
15
|
}
|
|
17
|
-
|
|
18
16
|
if (global.Intl && global.Intl.NumberFormat) {
|
|
19
17
|
let numberFormat = Intl.NumberFormat(options.locale || "en", {
|
|
20
|
-
notation: "compact"
|
|
21
|
-
|
|
18
|
+
notation: "compact"
|
|
19
|
+
// compactDisplay: "short",
|
|
22
20
|
});
|
|
23
|
-
return numberFormat.format(count);
|
|
24
|
-
} //Comaptibility
|
|
25
|
-
|
|
26
21
|
|
|
22
|
+
return numberFormat.format(count);
|
|
23
|
+
}
|
|
24
|
+
//Comaptibility
|
|
27
25
|
const COUNT_ABBRS = ["", "K", "M", "G", "T", "P", "E", "Z", "Y"];
|
|
28
26
|
let {
|
|
29
27
|
withAbbr = true,
|
|
@@ -31,13 +29,12 @@ export default function abbreviateNumber() {
|
|
|
31
29
|
} = options;
|
|
32
30
|
const i = 0 === count ? count : Math.floor(Math.log(count) / Math.log(1000));
|
|
33
31
|
let result = parseFloat((count / Math.pow(1000, i)).toFixed(decimals));
|
|
34
|
-
|
|
35
32
|
if (withAbbr) {
|
|
36
33
|
result += `${COUNT_ABBRS[i]}`;
|
|
37
34
|
}
|
|
38
|
-
|
|
39
35
|
return result;
|
|
40
36
|
}
|
|
37
|
+
|
|
41
38
|
/* need discussion
|
|
42
39
|
1001 => 1K+
|
|
43
40
|
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import "core-js/modules/es.array.includes";
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Opening the customization, need to addd for behaviour changes. also add only enabled.
|
|
5
3
|
* @param {*} style
|
|
@@ -10,22 +8,19 @@ import "core-js/modules/es.array.includes";
|
|
|
10
8
|
*/
|
|
11
9
|
export default function applyOpenToCustomize(style, options) {
|
|
12
10
|
let resultStyle = style;
|
|
13
|
-
|
|
14
11
|
if (options && options.prefix) {
|
|
15
|
-
resultStyle = {
|
|
12
|
+
resultStyle = {
|
|
13
|
+
...style
|
|
16
14
|
};
|
|
17
15
|
let defaultPrefix = options.prefix || "";
|
|
18
|
-
|
|
19
16
|
if (defaultPrefix) {
|
|
20
17
|
defaultPrefix = `${defaultPrefix}-`;
|
|
21
18
|
}
|
|
22
|
-
|
|
23
19
|
Object.keys(style).forEach(styleName => {
|
|
24
20
|
if (resultStyle[styleName] && !resultStyle[styleName].includes(styleName)) {
|
|
25
21
|
resultStyle[styleName] = `${resultStyle[styleName]} ${defaultPrefix}${styleName}`;
|
|
26
22
|
}
|
|
27
23
|
});
|
|
28
24
|
}
|
|
29
|
-
|
|
30
25
|
return resultStyle;
|
|
31
26
|
}
|
package/es/combineCustomStyle.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const REPLACER_SYMBOL = "$";
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
*
|
|
4
5
|
* if two is same ==> do the think if replace do, if append do.
|
|
@@ -8,13 +9,12 @@ const REPLACER_SYMBOL = "$";
|
|
|
8
9
|
* @param {*} style2
|
|
9
10
|
* @returns
|
|
10
11
|
*/
|
|
11
|
-
|
|
12
12
|
export default function combineCustomStyle(style1, style2) {
|
|
13
|
-
let resultStyle = {
|
|
13
|
+
let resultStyle = {
|
|
14
|
+
...style1
|
|
14
15
|
};
|
|
15
16
|
Object.keys(style2).forEach(styleName => {
|
|
16
17
|
let oldStyleName = style1[`$${styleName}`] ? `$${styleName}` : styleName;
|
|
17
|
-
|
|
18
18
|
if (oldStyleName.startsWith(REPLACER_SYMBOL) && styleName.startsWith(REPLACER_SYMBOL)) {
|
|
19
19
|
resultStyle[styleName] = style2[styleName];
|
|
20
20
|
} else if (!oldStyleName.startsWith(REPLACER_SYMBOL) && !styleName.startsWith(REPLACER_SYMBOL)) {
|
|
@@ -23,6 +23,7 @@ export default function combineCustomStyle(style1, style2) {
|
|
|
23
23
|
delete resultStyle[oldStyleName];
|
|
24
24
|
resultStyle[styleName] = style2[styleName];
|
|
25
25
|
}
|
|
26
|
+
|
|
26
27
|
/*else if (oldStyleName.startsWith(REPLACER_SYMBOL) && !styleName.startsWith(REPLACER_SYMBOL) ) {
|
|
27
28
|
|
|
28
29
|
delete resultStyle[oldStyleName];
|
|
@@ -33,7 +34,7 @@ export default function combineCustomStyle(style1, style2) {
|
|
|
33
34
|
delete resultStyle[oldStyleName];
|
|
34
35
|
resultStyle[styleName] = style2[styleName];
|
|
35
36
|
}*/
|
|
36
|
-
|
|
37
37
|
});
|
|
38
|
+
|
|
38
39
|
return resultStyle;
|
|
39
40
|
}
|
package/es/compileClassNames.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import dataTypes, { isDataTypeOf } from "./dataTypes";
|
|
2
2
|
import { hasOwnProperty, isToStringReferenceEqual } from "./objectUtils";
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
5
|
*
|
|
5
6
|
* @param {object} classinfoList
|
|
6
7
|
* @returns {string}
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
9
|
const collectClassNames = function (processedClassNameList) {
|
|
10
10
|
for (let index = 0; index < (arguments.length <= 1 ? 0 : arguments.length - 1); index++) {
|
|
11
11
|
let classInfo = index + 1 < 1 || arguments.length <= index + 1 ? undefined : arguments[index + 1];
|
|
12
|
-
|
|
13
12
|
if (!classInfo) {
|
|
14
13
|
continue;
|
|
15
14
|
}
|
|
16
|
-
|
|
17
15
|
if (isDataTypeOf(classInfo, dataTypes.string) || isDataTypeOf(classInfo, dataTypes.number)) {
|
|
18
16
|
processedClassNameList.push(classInfo);
|
|
19
17
|
} else if (isDataTypeOf(classInfo, dataTypes.array)) {
|
|
@@ -27,21 +25,20 @@ const collectClassNames = function (processedClassNameList) {
|
|
|
27
25
|
}
|
|
28
26
|
}
|
|
29
27
|
};
|
|
30
|
-
|
|
31
28
|
export default function compileClassNames() {
|
|
32
29
|
let resultClassNameList = [];
|
|
33
|
-
|
|
34
30
|
for (var _len = arguments.length, classinfoList = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
35
31
|
classinfoList[_key] = arguments[_key];
|
|
36
32
|
}
|
|
37
|
-
|
|
38
33
|
collectClassNames(resultClassNameList, ...classinfoList);
|
|
39
34
|
return resultClassNameList.join(' ');
|
|
40
35
|
}
|
|
41
36
|
;
|
|
37
|
+
|
|
42
38
|
/* discussion
|
|
43
39
|
passing object is enough i think. remaining option needed!!!
|
|
44
40
|
*/
|
|
41
|
+
|
|
45
42
|
//18-Nov-2021 code review changes updated.
|
|
46
43
|
|
|
47
44
|
/*
|
|
@@ -38,4 +38,13 @@ export const decorationList = {
|
|
|
38
38
|
underLine: 'decoration_underline',
|
|
39
39
|
none: 'decoration_none'
|
|
40
40
|
};
|
|
41
|
-
export const decorations = Object.values(decorationList);
|
|
41
|
+
export const decorations = Object.values(decorationList);
|
|
42
|
+
export const positionList = {
|
|
43
|
+
left: 'position_left',
|
|
44
|
+
right: 'position_right',
|
|
45
|
+
top: 'position_top',
|
|
46
|
+
bottom: 'position_bottom',
|
|
47
|
+
center: 'position_center'
|
|
48
|
+
};
|
|
49
|
+
export const positionKeys = Object.keys(positionList);
|
|
50
|
+
export const positions = Object.values(positionList);
|
package/es/contextFactory.js
CHANGED
|
@@ -2,21 +2,17 @@ export default function createTemplateLiteral(templateStrings) {
|
|
|
2
2
|
for (var _len = arguments.length, expressionKeys = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
3
3
|
expressionKeys[_key - 1] = arguments[_key];
|
|
4
4
|
}
|
|
5
|
-
|
|
6
5
|
return function () {
|
|
7
6
|
for (var _len2 = arguments.length, expressionValues = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
8
7
|
expressionValues[_key2] = arguments[_key2];
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
let resultString = [templateStrings[0]];
|
|
12
10
|
expressionKeys.forEach(function (expressionKey, i) {
|
|
13
11
|
let expressionValue = expressionValues[i];
|
|
14
12
|
let nextTemplateString = templateStrings[i + 1];
|
|
15
|
-
|
|
16
13
|
if (expressionValue === null || expressionValue === undefined || expressionValue === "") {
|
|
17
14
|
nextTemplateString = nextTemplateString.replace(/^_/, '');
|
|
18
15
|
}
|
|
19
|
-
|
|
20
16
|
resultString.push(expressionValue, nextTemplateString);
|
|
21
17
|
});
|
|
22
18
|
let resultStr = resultString.join('');
|
|
@@ -24,6 +20,7 @@ export default function createTemplateLiteral(templateStrings) {
|
|
|
24
20
|
return resultStr;
|
|
25
21
|
};
|
|
26
22
|
}
|
|
23
|
+
|
|
27
24
|
/* refer the doc https://developers.google.com/web/updates/2015/01/ES6-Template-Strings
|
|
28
25
|
|
|
29
26
|
UnderSatnd the terms - String interpolation, Embedded expressions
|
package/es/dataTypes.js
CHANGED
package/es/debounce.js
CHANGED
|
@@ -2,43 +2,64 @@
|
|
|
2
2
|
// import mergeStyle from "./mergeStyle";
|
|
3
3
|
// import { Button } from "../../base/src/Button/index";
|
|
4
4
|
// export default (props)=>{
|
|
5
|
+
|
|
5
6
|
// let { customStyle, openCustomStyle} = props;
|
|
7
|
+
|
|
6
8
|
// return {
|
|
7
9
|
// customStyle,
|
|
8
10
|
// openDefaultToCustomize
|
|
9
11
|
// };
|
|
12
|
+
|
|
10
13
|
// }
|
|
14
|
+
|
|
11
15
|
// if two is same ==> do the think replace with last , append at end
|
|
16
|
+
|
|
12
17
|
// replace vs append ==> append
|
|
13
18
|
// append vs replace ==> replace
|
|
19
|
+
|
|
14
20
|
// DotButton.js
|
|
15
21
|
// DotButton.module.css
|
|
16
22
|
// function DotButton({ customStyle }){
|
|
23
|
+
|
|
17
24
|
// dotButdefault => customStyle : {
|
|
18
25
|
// base : DotButton.style.pols
|
|
19
26
|
// }
|
|
27
|
+
|
|
20
28
|
// props => customStyle {
|
|
21
29
|
// base :
|
|
22
30
|
// }
|
|
31
|
+
|
|
23
32
|
// return <Button customStyle={}></Button>
|
|
24
33
|
// }
|
|
34
|
+
|
|
25
35
|
// Button => set of compoents
|
|
26
36
|
// DotButton => set of comepons
|
|
37
|
+
|
|
27
38
|
// function creatButtonWithIcon({Button,Icon}){
|
|
39
|
+
|
|
28
40
|
// return (props)=>{
|
|
41
|
+
|
|
29
42
|
// customStyle={}
|
|
30
43
|
// return <Button customStyle={ssss}>
|
|
44
|
+
|
|
31
45
|
// <Icon></Icon>
|
|
32
46
|
// </Button>
|
|
47
|
+
|
|
33
48
|
// }
|
|
49
|
+
|
|
34
50
|
// }
|
|
51
|
+
|
|
35
52
|
// Button1.js
|
|
36
53
|
// Icon1.js
|
|
37
54
|
// creatButtonWithIcon({
|
|
55
|
+
|
|
38
56
|
// Button : Button1,
|
|
39
57
|
// Icon : Icon1
|
|
58
|
+
|
|
40
59
|
// });
|
|
60
|
+
|
|
41
61
|
// Button1custome(props){
|
|
62
|
+
|
|
42
63
|
// props.customStyle
|
|
43
64
|
// combineCustomStyle()
|
|
44
65
|
// return Button
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import compileClassNames from "./compileClassNames";
|
|
2
2
|
export default (function (customClassName) {
|
|
3
3
|
let isPlainClassName = typeof customClassName === "string" ? true : false;
|
|
4
|
-
|
|
5
4
|
for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
6
5
|
props[_key - 1] = arguments[_key];
|
|
7
6
|
}
|
|
8
|
-
|
|
9
7
|
return compileClassNames(...props, {
|
|
10
8
|
[customClassName]: !!isPlainClassName
|
|
11
9
|
});
|
|
@@ -6,10 +6,10 @@ export default (function (_ref, defaultCustomId) {
|
|
|
6
6
|
} = _ref;
|
|
7
7
|
let otherCustomOption = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
8
8
|
let returnId = customId;
|
|
9
|
-
|
|
10
9
|
if (typeof defaultCustomId === "function") {
|
|
11
10
|
let options = ['', customIdPrefix, customIdSuffix, ...otherCustomOption];
|
|
12
|
-
returnId = defaultCustomId.apply(null, options);
|
|
11
|
+
returnId = defaultCustomId.apply(null, options);
|
|
12
|
+
//returnId = defaultCustomId`${customIdPrefix} ${customIdSuffix}`;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
return returnId ? returnId.toLowerCase() : null;
|
package/es/isTouchDevice.js
CHANGED
package/es/loadResource.js
CHANGED
|
@@ -1,55 +1,44 @@
|
|
|
1
1
|
/* eslint-disable import/prefer-default-export */
|
|
2
|
-
|
|
3
2
|
/* use promise and remove callback */
|
|
4
3
|
export default function loadResource(url, type, id, callback) {
|
|
5
4
|
let needDefer = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
6
5
|
return new Promise(resolve => {
|
|
7
6
|
let css;
|
|
8
7
|
let script;
|
|
9
|
-
|
|
10
8
|
if (id && document.getElementById(id)) {
|
|
11
9
|
resolve();
|
|
12
10
|
return;
|
|
13
11
|
}
|
|
14
|
-
|
|
15
12
|
if (type === 'css') {
|
|
16
13
|
css = document.createElement('link');
|
|
17
14
|
css.type = 'text/css';
|
|
18
15
|
css.rel = 'stylesheet';
|
|
19
16
|
css.href = url;
|
|
20
17
|
css.id = id || '';
|
|
21
|
-
|
|
22
18
|
css.onload = function () {
|
|
23
19
|
resolve();
|
|
24
20
|
};
|
|
25
|
-
|
|
26
21
|
css.onerror = function () {
|
|
27
22
|
resolve();
|
|
28
23
|
};
|
|
29
|
-
|
|
30
24
|
document.getElementsByTagName('head')[0].appendChild(css);
|
|
31
25
|
} else if (type === 'js') {
|
|
32
26
|
script = document.createElement('script');
|
|
33
27
|
script.type = 'text/javascript';
|
|
34
28
|
script.src = url;
|
|
35
29
|
script.defer = needDefer;
|
|
36
|
-
|
|
37
30
|
script.onload = function () {
|
|
38
31
|
resolve();
|
|
39
|
-
|
|
40
32
|
if (id) {
|
|
41
33
|
script.id = id;
|
|
42
34
|
}
|
|
43
|
-
|
|
44
35
|
if (typeof callback === 'function') {
|
|
45
36
|
callback();
|
|
46
37
|
}
|
|
47
38
|
};
|
|
48
|
-
|
|
49
39
|
script.onerror = function () {
|
|
50
40
|
resolve();
|
|
51
41
|
};
|
|
52
|
-
|
|
53
42
|
document.getElementsByTagName('head')[0].appendChild(script);
|
|
54
43
|
}
|
|
55
44
|
});
|
package/es/mergeStyle.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import "core-js/modules/es.array.includes";
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* REPLACER_SYMBOL used to indentify
|
|
5
3
|
*/
|
|
@@ -11,24 +9,21 @@ const REPLACER_SYMBOL = '$';
|
|
|
11
9
|
* @param {*} customStyle
|
|
12
10
|
* @returns
|
|
13
11
|
*/
|
|
14
|
-
|
|
15
12
|
export default function mergeStyle(defaultStyle, customStyle) {
|
|
16
13
|
let additionalStyle = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
17
14
|
return Object.keys(customStyle).reduce((res, next) => {
|
|
18
15
|
if (next.startsWith(REPLACER_SYMBOL)) {
|
|
19
16
|
let styleValue = customStyle[next];
|
|
20
17
|
let styleName = next.replace(REPLACER_SYMBOL, '');
|
|
21
|
-
|
|
22
18
|
if (!defaultStyle[styleName] && !additionalStyle.includes(styleName)) {
|
|
23
19
|
return res;
|
|
24
20
|
}
|
|
25
|
-
|
|
26
21
|
res[styleName] = styleValue;
|
|
27
22
|
} else if (defaultStyle[next] || additionalStyle.includes(next)) {
|
|
28
23
|
res[next] = (defaultStyle[next] || '') + ' ' + customStyle[next];
|
|
29
24
|
}
|
|
30
|
-
|
|
31
25
|
return res;
|
|
32
|
-
}, {
|
|
26
|
+
}, {
|
|
27
|
+
...defaultStyle
|
|
33
28
|
});
|
|
34
29
|
}
|
package/es/omit.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* tagAttributes - is used to spread these attributes for events customize and override few attributes.
|
|
4
5
|
*/
|
|
5
|
-
|
|
6
6
|
export const tagAttributes = "tagAttributes";
|
|
7
7
|
const attributesList = ["tabIndex"];
|
|
8
8
|
const dataAttribute = "^data|on";
|
|
@@ -10,7 +10,6 @@ export const tagAttributesPropType = function (props, propName, componentName) {
|
|
|
10
10
|
if (Object.prototype.toString.call(props) !== "[object Object]") {
|
|
11
11
|
console.error(`Warning: Failed prop type: Invalid prop \`${propName}\` of type \`${props ? typeof props : undefined}\` supplied to \`${componentName}\`, expected \`object\`.`);
|
|
12
12
|
}
|
|
13
|
-
|
|
14
13
|
let curPattern = new RegExp(`^(${attributesList.join("|")})$`);
|
|
15
14
|
let curPattern2 = new RegExp(dataAttribute);
|
|
16
15
|
Object.keys(props[propName]).forEach(keyName => {
|
|
@@ -26,7 +25,6 @@ export const tagAttributesShape = shapeOf => (props, propName, componentName) =>
|
|
|
26
25
|
console.error(`Warning: these key ( ${keyName} ) aren't allowed in ${propName}, component: ${componentName}`);
|
|
27
26
|
return;
|
|
28
27
|
}
|
|
29
|
-
|
|
30
28
|
shapeOf[keyName](propObject, keyName, `${componentName} prop: ${propName}.${keyName} `);
|
|
31
29
|
});
|
|
32
30
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* tagGeneralAttributes - is to spread the global attributes in component.
|
|
4
5
|
*/
|
|
5
|
-
|
|
6
6
|
export const tagGeneralAttributes = "tagGeneralAttributes";
|
|
7
7
|
const attributesList = ["accesskey", "contentEditable", "dir", "draggable", "hidden", "lang", "tabIndex", "title", "spellcheck", "translate"];
|
|
8
8
|
const dataAttribute = "^data|on";
|
|
@@ -10,7 +10,6 @@ export const tagGeneralAttributesPropType = function (props, propName, component
|
|
|
10
10
|
if (Object.prototype.toString.call(props) !== "[object Object]") {
|
|
11
11
|
console.error(`Warning: Failed prop type: Invalid prop \`${propName}\` of type \`${props ? typeof props : undefined}\` supplied to \`${componentName}\`, expected \`object\`.`);
|
|
12
12
|
}
|
|
13
|
-
|
|
14
13
|
let curPattern = new RegExp(`^(${attributesList.join("|")})$`);
|
|
15
14
|
let curPattern2 = new RegExp(dataAttribute);
|
|
16
15
|
Object.keys(props[propName]).forEach(keyName => {
|
|
@@ -26,7 +25,6 @@ export const tagGeneralAttributesShape = shapeOf => (props, propName, componentN
|
|
|
26
25
|
console.error(`Warning: these key ( ${keyName} ) aren't allowed in ${propName}, component: ${componentName}`);
|
|
27
26
|
return;
|
|
28
27
|
}
|
|
29
|
-
|
|
30
28
|
shapeOf[keyName](propObject, keyName, `${componentName} prop: ${propName}.${keyName} `);
|
|
31
29
|
});
|
|
32
30
|
};
|
package/es/props/uiProps.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
/* eslint-disable no-labels */
|
|
2
|
-
|
|
3
2
|
/* eslint-disable no-restricted-syntax */
|
|
4
3
|
import PropTypes from 'prop-types';
|
|
5
|
-
import { variants, colors, sizes, shapes, decorations } from '../constantProps';
|
|
4
|
+
import { variants, colors, sizes, shapes, decorations, positions } from '../constantProps';
|
|
6
5
|
export const getVariantProps = (variants, exvariant) => {
|
|
7
6
|
let variant = [];
|
|
8
|
-
|
|
9
7
|
if (exvariant) {
|
|
10
8
|
variant = [...exvariant];
|
|
11
9
|
}
|
|
12
|
-
|
|
13
10
|
variant = [...variant, ...variants];
|
|
14
11
|
return {
|
|
15
12
|
variant: PropTypes.oneOf(variant)
|
|
@@ -20,11 +17,9 @@ export const variantProps = {
|
|
|
20
17
|
};
|
|
21
18
|
export const getColorProps = (colors, excolors) => {
|
|
22
19
|
let color = [];
|
|
23
|
-
|
|
24
20
|
if (excolors) {
|
|
25
21
|
color = [...excolors];
|
|
26
22
|
}
|
|
27
|
-
|
|
28
23
|
color = [...color, ...colors];
|
|
29
24
|
return {
|
|
30
25
|
color: PropTypes.oneOf(color)
|
|
@@ -35,11 +30,9 @@ export const colorProps = {
|
|
|
35
30
|
};
|
|
36
31
|
export const getSizeProps = (sizes, exSizes) => {
|
|
37
32
|
let size = [];
|
|
38
|
-
|
|
39
33
|
if (exSizes) {
|
|
40
34
|
size = [...exSizes];
|
|
41
35
|
}
|
|
42
|
-
|
|
43
36
|
size = [...size, ...sizes];
|
|
44
37
|
return {
|
|
45
38
|
size: PropTypes.oneOf(size)
|
|
@@ -50,11 +43,9 @@ export const sizeProps = {
|
|
|
50
43
|
};
|
|
51
44
|
export const getShapeProps = (shapes, exShapes) => {
|
|
52
45
|
let shape = [];
|
|
53
|
-
|
|
54
46
|
if (exShapes) {
|
|
55
47
|
shape = [...exShapes];
|
|
56
48
|
}
|
|
57
|
-
|
|
58
49
|
shape = [...shape, ...shapes];
|
|
59
50
|
return {
|
|
60
51
|
shape: PropTypes.oneOf(shape)
|
|
@@ -65,11 +56,9 @@ export const shapeProps = {
|
|
|
65
56
|
};
|
|
66
57
|
export const getDecorationProps = (decorations, exDecorations) => {
|
|
67
58
|
let decoration = [];
|
|
68
|
-
|
|
69
59
|
if (exDecorations) {
|
|
70
60
|
decoration = [...exDecorations];
|
|
71
61
|
}
|
|
72
|
-
|
|
73
62
|
decoration = [...decoration, ...decorations];
|
|
74
63
|
return {
|
|
75
64
|
textDecoration: PropTypes.oneOf(decoration)
|
|
@@ -77,4 +66,17 @@ export const getDecorationProps = (decorations, exDecorations) => {
|
|
|
77
66
|
};
|
|
78
67
|
export const decorationProps = {
|
|
79
68
|
decoration: PropTypes.oneOf(decorations)
|
|
69
|
+
};
|
|
70
|
+
export const getPositionProps = (positions, expositions) => {
|
|
71
|
+
let position = [];
|
|
72
|
+
if (expositions) {
|
|
73
|
+
position = [...expositions];
|
|
74
|
+
}
|
|
75
|
+
position = [...position, ...positions];
|
|
76
|
+
return {
|
|
77
|
+
position: PropTypes.oneOf(position)
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
export const positionProps = {
|
|
81
|
+
position: PropTypes.oneOf(positions)
|
|
80
82
|
};
|
package/es/reducerHandler.js
CHANGED
|
@@ -2,14 +2,11 @@ import { useReducer } from "react";
|
|
|
2
2
|
export default function useCommonReducer(defaultReducer, customReducer, initialArg, init) {
|
|
3
3
|
const proxyReducer = (state, action) => {
|
|
4
4
|
let lastState = defaultReducer(state, action);
|
|
5
|
-
|
|
6
5
|
if (customReducer) {
|
|
7
6
|
return customReducer(lastState, action);
|
|
8
7
|
}
|
|
9
|
-
|
|
10
8
|
return lastState;
|
|
11
9
|
};
|
|
12
|
-
|
|
13
10
|
const [state, dispatch] = useReducer(proxyReducer, initialArg, init);
|
|
14
11
|
return {
|
|
15
12
|
state,
|
package/es/uniqueNumber.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export default function uniqueNumber() {
|
|
2
2
|
let prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
3
3
|
//let randomId = (Date.now() + Math.random()).toString(36);
|
|
4
|
-
var date = Date.now();
|
|
4
|
+
var date = Date.now();
|
|
5
5
|
|
|
6
|
+
// If created at same millisecond as previous
|
|
6
7
|
if (date <= uniqueNumber.previous) {
|
|
7
8
|
date = ++uniqueNumber.previous;
|
|
8
9
|
} else {
|
|
9
10
|
uniqueNumber.previous = date;
|
|
10
11
|
}
|
|
11
|
-
|
|
12
12
|
return prefix ? `${prefix}-${date}` : date;
|
|
13
13
|
}
|
|
14
14
|
uniqueNumber.previous = 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
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": "
|
|
25
|
+
"gitHead": "cc656e6d4c2249ad79916757b2a96828b678245b"
|
|
26
26
|
}
|