@zohodesk/utils 1.0.3-alpha.1 → 1.0.4
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.
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
|
+
/**
|
|
3
|
+
* tagAttributes - is used to spread these attributes for events customize and override few attributes.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export const tagAttributes = "tagAttributes";
|
|
2
7
|
const attributesList = ["tabIndex"];
|
|
3
8
|
const dataAttribute = "^data|on";
|
|
4
9
|
export const tagAttributesPropType = function (props, propName, componentName) {
|
|
@@ -10,15 +15,21 @@ export const tagAttributesPropType = function (props, propName, componentName) {
|
|
|
10
15
|
let curPattern2 = new RegExp(dataAttribute);
|
|
11
16
|
Object.keys(props[propName]).forEach(keyName => {
|
|
12
17
|
if (!(curPattern.test(keyName) || curPattern2.test(keyName))) {
|
|
13
|
-
console.warn(`Warning: these attributes
|
|
18
|
+
console.warn(`Warning: these attributes ( ${keyName} ) aren't mentioned in ${propName}, component: ${componentName}`);
|
|
14
19
|
}
|
|
15
20
|
});
|
|
16
21
|
};
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
export const tagAttributesShape = shapeOf => (props, propName, componentName) => {
|
|
23
|
+
let propObject = props[propName];
|
|
24
|
+
propObject && Object.keys(propObject).forEach(keyName => {
|
|
25
|
+
if (!shapeOf.hasOwnProperty(keyName)) {
|
|
26
|
+
console.error(`Warning: these key ( ${keyName} ) aren't allowed in ${propName}, component: ${componentName}`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
23
29
|
|
|
24
|
-
|
|
30
|
+
shapeOf[keyName](propObject, keyName, `${componentName} prop: ${propName}.${keyName} `);
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
export default {
|
|
34
|
+
[tagAttributes]: tagAttributesPropType
|
|
35
|
+
};
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
|
+
/**
|
|
3
|
+
* tagGeneralAttributes - is to spread the global attributes in component.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export const tagGeneralAttributes = "tagGeneralAttributes";
|
|
2
7
|
const attributesList = ["accesskey", "contentEditable", "dir", "draggable", "hidden", "lang", "tabIndex", "title", "spellcheck", "translate"];
|
|
3
8
|
const dataAttribute = "^data|on";
|
|
4
9
|
export const tagGeneralAttributesPropType = function (props, propName, componentName) {
|
|
@@ -10,15 +15,21 @@ export const tagGeneralAttributesPropType = function (props, propName, component
|
|
|
10
15
|
let curPattern2 = new RegExp(dataAttribute);
|
|
11
16
|
Object.keys(props[propName]).forEach(keyName => {
|
|
12
17
|
if (!(curPattern.test(keyName) || curPattern2.test(keyName))) {
|
|
13
|
-
console.warn(`Warning: these attributes
|
|
18
|
+
console.warn(`Warning: these attributes ( ${keyName} ) aren't mentioned in tagGeneralAttributes, component: ${componentName}`);
|
|
14
19
|
}
|
|
15
20
|
});
|
|
16
21
|
};
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
export const tagGeneralAttributesShape = shapeOf => (props, propName, componentName) => {
|
|
23
|
+
let propObject = props[propName];
|
|
24
|
+
propObject && Object.keys(propObject).forEach(keyName => {
|
|
25
|
+
if (!shapeOf.hasOwnProperty(keyName)) {
|
|
26
|
+
console.error(`Warning: these key ( ${keyName} ) aren't allowed in ${propName}, component: ${componentName}`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
23
29
|
|
|
24
|
-
|
|
30
|
+
shapeOf[keyName](propObject, keyName, `${componentName} prop: ${propName}.${keyName} `);
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
export default {
|
|
34
|
+
[tagGeneralAttributes]: tagGeneralAttributesPropType
|
|
35
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
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": "e57c562c44c9b82f9e2fa2df1e3c97d106efb72d"
|
|
26
26
|
}
|