@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.
@@ -0,0 +1,6 @@
1
+ export default function jsonToQueryString(json) {
2
+ var str = Object.keys(json).map(function (key) {
3
+ return encodeURIComponent(key) + '=' + encodeURIComponent(json[key]);
4
+ }).join('&');
5
+ return str != '' ? '?' + str : str;
6
+ }
@@ -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 name ${keyName} are not allowed in ${propName}`);
18
+ console.warn(`Warning: these attributes ( ${keyName} ) aren't mentioned in ${propName}, component: ${componentName}`);
14
19
  }
15
20
  });
16
21
  };
17
- export default {
18
- tagAttributes: tagAttributesPropType
19
- };
20
- /**
21
- * tagAttributes - is used to spread these attributes for events customize and override few attributes.
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
- export const tagAttributes = "tagAttributes";
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 name ${keyName} are not allowed in tagGeneralAttributes`);
18
+ console.warn(`Warning: these attributes ( ${keyName} ) aren't mentioned in tagGeneralAttributes, component: ${componentName}`);
14
19
  }
15
20
  });
16
21
  };
17
- export default {
18
- tagGeneralAttributes: tagGeneralAttributesPropType
19
- };
20
- /**
21
- * tagGeneralAttributes - is to spread the global attributes in component.
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
- export const tagGeneralAttributes = "tagGeneralAttributes";
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-alpha.1",
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": "8dd4468a961c6ecb48c312f72825b33f482be736"
25
+ "gitHead": "e57c562c44c9b82f9e2fa2df1e3c97d106efb72d"
26
26
  }