@elliemae/ds-props-helpers 2.0.0-next.3 → 2.0.0-next.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.
- package/cjs/getProps/index.js +2 -0
- package/cjs/validation/errorTemplates.js +2 -9
- package/cjs/validation/typescriptValidator.js +3 -4
- package/esm/getProps/index.js +2 -0
- package/esm/validation/errorTemplates.js +2 -9
- package/esm/validation/typescriptValidator.js +3 -4
- package/package.json +1 -1
- package/cjs/package.json +0 -7
- package/esm/package.json +0 -7
package/cjs/getProps/index.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
6
|
+
|
|
5
7
|
const getAriaProps = props => Object.fromEntries(Object.entries(props).filter(([key]) => key.includes('aria-')));
|
|
6
8
|
const getDataProps = props => Object.fromEntries(Object.entries(props).filter(([key]) => key.includes('data-')));
|
|
7
9
|
|
|
@@ -6,17 +6,10 @@ require('core-js/modules/es.string.replace.js');
|
|
|
6
6
|
|
|
7
7
|
/* eslint-disable max-params */
|
|
8
8
|
const throwTypeError = (componentName, validPropKey, invalidProp, validFormat) => {
|
|
9
|
-
throw new Error(
|
|
10
|
-
please provide a valid type.
|
|
11
|
-
|
|
12
|
-
Received: ${invalidProp} (${typeof invalidProp})
|
|
13
|
-
Expected: (${validFormat.replace('\n', ' or ')})
|
|
14
|
-
`);
|
|
9
|
+
throw new Error("".concat(componentName, ":: You are trying to pass a not valid \"").concat(validPropKey, "\" property, \n please provide a valid type.\n\n Received: ").concat(invalidProp, " (").concat(typeof invalidProp, ")\n Expected: (").concat(validFormat.replace('\n', ' or '), ")\n "));
|
|
15
10
|
};
|
|
16
11
|
const throwRequiredError = (componentName, validPropKey) => {
|
|
17
|
-
throw new Error(
|
|
18
|
-
This property is required.
|
|
19
|
-
`);
|
|
12
|
+
throw new Error("".concat(componentName, ":: Please provide a/an \"").concat(validPropKey, "\" property to use this component. \n This property is required.\n "));
|
|
20
13
|
};
|
|
21
14
|
|
|
22
15
|
exports.throwRequiredError = throwRequiredError;
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
5
6
|
var react = require('react');
|
|
6
7
|
var errorTemplates = require('./errorTemplates.js');
|
|
7
8
|
var typescriptGuards = require('./typescriptGuards.js');
|
|
8
9
|
var typescriptParsers = require('./typescriptParsers.js');
|
|
9
10
|
|
|
10
|
-
/* eslint-disable complexity */
|
|
11
|
-
|
|
12
11
|
// =============================================================================
|
|
13
12
|
// Atom Validators
|
|
14
13
|
// =============================================================================
|
|
@@ -41,7 +40,7 @@ const validateArray = (schemaName, key, value, format, validationsMemo, nextVali
|
|
|
41
40
|
|
|
42
41
|
|
|
43
42
|
value.forEach((val, index) => {
|
|
44
|
-
validateValueWithFormat(schemaName,
|
|
43
|
+
validateValueWithFormat(schemaName, "".concat(key, "[").concat(index, "]"), val, format.slice(0, -2), validationsMemo, nextValidationsMemo);
|
|
45
44
|
});
|
|
46
45
|
};
|
|
47
46
|
|
|
@@ -64,7 +63,7 @@ const validateObject = (schemaName, key, value, format, validationsMemo, nextVal
|
|
|
64
63
|
}
|
|
65
64
|
|
|
66
65
|
if (trueKey in value) {
|
|
67
|
-
validateValueWithFormat(schemaName,
|
|
66
|
+
validateValueWithFormat(schemaName, "".concat(key, "[").concat(trueKey, "]"), value[trueKey], objectValue, validationsMemo, nextValidationsMemo);
|
|
68
67
|
}
|
|
69
68
|
});
|
|
70
69
|
};
|
package/esm/getProps/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
|
+
|
|
1
3
|
const getAriaProps = props => Object.fromEntries(Object.entries(props).filter(([key]) => key.includes('aria-')));
|
|
2
4
|
const getDataProps = props => Object.fromEntries(Object.entries(props).filter(([key]) => key.includes('data-')));
|
|
3
5
|
|
|
@@ -2,17 +2,10 @@ import 'core-js/modules/es.string.replace.js';
|
|
|
2
2
|
|
|
3
3
|
/* eslint-disable max-params */
|
|
4
4
|
const throwTypeError = (componentName, validPropKey, invalidProp, validFormat) => {
|
|
5
|
-
throw new Error(
|
|
6
|
-
please provide a valid type.
|
|
7
|
-
|
|
8
|
-
Received: ${invalidProp} (${typeof invalidProp})
|
|
9
|
-
Expected: (${validFormat.replace('\n', ' or ')})
|
|
10
|
-
`);
|
|
5
|
+
throw new Error("".concat(componentName, ":: You are trying to pass a not valid \"").concat(validPropKey, "\" property, \n please provide a valid type.\n\n Received: ").concat(invalidProp, " (").concat(typeof invalidProp, ")\n Expected: (").concat(validFormat.replace('\n', ' or '), ")\n "));
|
|
11
6
|
};
|
|
12
7
|
const throwRequiredError = (componentName, validPropKey) => {
|
|
13
|
-
throw new Error(
|
|
14
|
-
This property is required.
|
|
15
|
-
`);
|
|
8
|
+
throw new Error("".concat(componentName, ":: Please provide a/an \"").concat(validPropKey, "\" property to use this component. \n This property is required.\n "));
|
|
16
9
|
};
|
|
17
10
|
|
|
18
11
|
export { throwRequiredError, throwTypeError };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
1
2
|
import { useState, useMemo } from 'react';
|
|
2
3
|
import { throwRequiredError, throwTypeError } from './errorTemplates.js';
|
|
3
4
|
import { isUndefined, isPrimitiveType, isUnion, isString, isArray, isObject, isFunction, isJSXorNode, isSomethingWithParenthesis } from './typescriptGuards.js';
|
|
4
5
|
import { typescriptObjectParser } from './typescriptParsers.js';
|
|
5
6
|
|
|
6
|
-
/* eslint-disable complexity */
|
|
7
|
-
|
|
8
7
|
// =============================================================================
|
|
9
8
|
// Atom Validators
|
|
10
9
|
// =============================================================================
|
|
@@ -37,7 +36,7 @@ const validateArray = (schemaName, key, value, format, validationsMemo, nextVali
|
|
|
37
36
|
|
|
38
37
|
|
|
39
38
|
value.forEach((val, index) => {
|
|
40
|
-
validateValueWithFormat(schemaName,
|
|
39
|
+
validateValueWithFormat(schemaName, "".concat(key, "[").concat(index, "]"), val, format.slice(0, -2), validationsMemo, nextValidationsMemo);
|
|
41
40
|
});
|
|
42
41
|
};
|
|
43
42
|
|
|
@@ -60,7 +59,7 @@ const validateObject = (schemaName, key, value, format, validationsMemo, nextVal
|
|
|
60
59
|
}
|
|
61
60
|
|
|
62
61
|
if (trueKey in value) {
|
|
63
|
-
validateValueWithFormat(schemaName,
|
|
62
|
+
validateValueWithFormat(schemaName, "".concat(key, "[").concat(trueKey, "]"), value[trueKey], objectValue, validationsMemo, nextValidationsMemo);
|
|
64
63
|
}
|
|
65
64
|
});
|
|
66
65
|
};
|
package/package.json
CHANGED
package/cjs/package.json
DELETED