@elliemae/ds-props-helpers 2.3.0-alpha.8 → 2.3.0-next.10
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/defaultProps/index.js +9 -0
- package/cjs/defaultProps/useMemoMergePropsWithDefault.js +48 -0
- package/cjs/getProps/index.js +20 -0
- package/cjs/globalProps/constants.js +16 -0
- package/cjs/globalProps/globalAttributesPropTypes.js +382 -0
- package/cjs/globalProps/index.js +11 -0
- package/cjs/globalProps/useGetGlobalAttributes.js +37 -0
- package/cjs/index.js +32 -0
- package/cjs/propTypes/PropTypes.js +131 -0
- package/cjs/propTypes/customPropTypes.js +21 -0
- package/cjs/propTypes/describe.js +64 -0
- package/cjs/propTypes/describeConversions.js +104 -0
- package/cjs/propTypes/describeGuards.js +21 -0
- package/cjs/propTypes/index.js +11 -0
- package/cjs/propTypes/toTypescript.js +160 -0
- package/cjs/propTypes/types.js +2 -0
- package/cjs/validation/errorTemplates.js +16 -0
- package/cjs/validation/index.js +15 -0
- package/cjs/validation/typescriptGuards.js +36 -0
- package/cjs/validation/typescriptParsers.js +45 -0
- package/cjs/validation/typescriptValidator.js +208 -0
- package/cjs/validation/validator.js +36 -0
- package/cjs/xstyledProps/constants.js +21 -0
- package/cjs/xstyledProps/index.js +11 -0
- package/cjs/xstyledProps/useGetXstyledProps.js +27 -0
- package/cjs/xstyledProps/xstyledPropTypes.js +75 -0
- package/esm/defaultProps/index.js +1 -0
- package/esm/defaultProps/useMemoMergePropsWithDefault.js +39 -0
- package/esm/getProps/index.js +15 -0
- package/esm/globalProps/constants.js +12 -0
- package/{dist/esm → esm}/globalProps/globalAttributesPropTypes.js +67 -58
- package/esm/globalProps/index.js +2 -0
- package/esm/globalProps/useGetGlobalAttributes.js +33 -0
- package/esm/index.js +11 -0
- package/esm/propTypes/PropTypes.js +125 -0
- package/esm/propTypes/customPropTypes.js +17 -0
- package/esm/propTypes/describe.js +62 -0
- package/esm/propTypes/describeConversions.js +96 -0
- package/esm/propTypes/describeGuards.js +10 -0
- package/esm/propTypes/index.js +2 -0
- package/esm/propTypes/toTypescript.js +154 -0
- package/esm/propTypes/types.js +1 -0
- package/esm/validation/errorTemplates.js +11 -0
- package/esm/validation/index.js +3 -0
- package/esm/validation/typescriptGuards.js +23 -0
- package/esm/validation/typescriptParsers.js +41 -0
- package/esm/validation/typescriptValidator.js +203 -0
- package/esm/validation/validator.js +32 -0
- package/esm/xstyledProps/constants.js +16 -0
- package/esm/xstyledProps/index.js +2 -0
- package/esm/xstyledProps/useGetXstyledProps.js +23 -0
- package/esm/xstyledProps/xstyledPropTypes.js +71 -0
- package/package.json +80 -65
- package/types/defaultProps/index.d.ts +1 -0
- package/types/defaultProps/useMemoMergePropsWithDefault.d.ts +1 -0
- package/types/getProps/index.d.ts +2 -0
- package/types/globalProps/constants.d.ts +3 -0
- package/types/globalProps/globalAttributesPropTypes.d.ts +363 -0
- package/types/globalProps/index.d.ts +2 -0
- package/types/globalProps/useGetGlobalAttributes.d.ts +4 -0
- package/types/index.d.ts +6 -0
- package/types/propTypes/PropTypes.d.ts +3 -0
- package/types/propTypes/customPropTypes.d.ts +2 -0
- package/types/propTypes/describe.d.ts +3 -0
- package/types/propTypes/describeConversions.d.ts +3 -0
- package/types/propTypes/describeGuards.d.ts +9 -0
- package/types/propTypes/index.d.ts +3 -0
- package/types/propTypes/toTypescript.d.ts +3 -0
- package/types/propTypes/types.d.ts +99 -0
- package/types/tests/globalProps/TestComponent.d.ts +1 -0
- package/types/tests/globalProps/globalAttributes.test.d.ts +1 -0
- package/types/tests/validation/any.validation.test.d.ts +1 -0
- package/types/tests/validation/array.validation.test.d.ts +1 -0
- package/types/tests/validation/boolean.validation.test.d.ts +1 -0
- package/types/tests/validation/function.validation.test.d.ts +1 -0
- package/types/tests/validation/number.validation.test.d.ts +1 -0
- package/types/tests/validation/object.validation.test.d.ts +1 -0
- package/types/tests/validation/schema.validation.test.d.ts +1 -0
- package/types/tests/validation/string.validation.test.d.ts +1 -0
- package/types/tests/validation/test.schema.d.ts +1 -0
- package/types/tests/validation/union.validation.test.d.ts +1 -0
- package/types/validation/errorTemplates.d.ts +2 -0
- package/types/validation/index.d.ts +3 -0
- package/types/validation/typescriptGuards.d.ts +12 -0
- package/types/validation/typescriptParsers.d.ts +1 -0
- package/types/validation/typescriptValidator.d.ts +15 -0
- package/types/validation/validator.d.ts +1 -0
- package/types/xstyledProps/constants.d.ts +2 -0
- package/types/xstyledProps/index.d.ts +2 -0
- package/types/xstyledProps/useGetXstyledProps.d.ts +5 -0
- package/types/xstyledProps/xstyledPropTypes.d.ts +57 -0
- package/dist/cjs/defaultProps/index.js +0 -28
- package/dist/cjs/defaultProps/index.js.map +0 -7
- package/dist/cjs/defaultProps/useMemoMergePropsWithDefault.js +0 -48
- package/dist/cjs/defaultProps/useMemoMergePropsWithDefault.js.map +0 -7
- package/dist/cjs/getProps/index.js +0 -37
- package/dist/cjs/getProps/index.js.map +0 -7
- package/dist/cjs/globalProps/constants.js +0 -398
- package/dist/cjs/globalProps/constants.js.map +0 -7
- package/dist/cjs/globalProps/globalAttributesPropTypes.js +0 -398
- package/dist/cjs/globalProps/globalAttributesPropTypes.js.map +0 -7
- package/dist/cjs/globalProps/index.js +0 -29
- package/dist/cjs/globalProps/index.js.map +0 -7
- package/dist/cjs/globalProps/useGetGlobalAttributes.js +0 -56
- package/dist/cjs/globalProps/useGetGlobalAttributes.js.map +0 -7
- package/dist/cjs/index.js +0 -32
- package/dist/cjs/index.js.map +0 -7
- package/dist/cjs/propTypes/PropTypes.js +0 -136
- package/dist/cjs/propTypes/PropTypes.js.map +0 -7
- package/dist/cjs/propTypes/customPropTypes.js +0 -38
- package/dist/cjs/propTypes/customPropTypes.js.map +0 -7
- package/dist/cjs/propTypes/describe.js +0 -81
- package/dist/cjs/propTypes/describe.js.map +0 -7
- package/dist/cjs/propTypes/describeConversions.js +0 -96
- package/dist/cjs/propTypes/describeConversions.js.map +0 -7
- package/dist/cjs/propTypes/describeGuards.js +0 -49
- package/dist/cjs/propTypes/describeGuards.js.map +0 -7
- package/dist/cjs/propTypes/index.js +0 -37
- package/dist/cjs/propTypes/index.js.map +0 -7
- package/dist/cjs/propTypes/toTypescript.js +0 -139
- package/dist/cjs/propTypes/toTypescript.js.map +0 -7
- package/dist/cjs/propTypes/types.js +0 -27
- package/dist/cjs/propTypes/types.js.map +0 -7
- package/dist/cjs/tests/globalProps/TestComponent.js +0 -42
- package/dist/cjs/tests/globalProps/TestComponent.js.map +0 -7
- package/dist/cjs/tests/validation/test.schema.js +0 -67
- package/dist/cjs/tests/validation/test.schema.js.map +0 -7
- package/dist/cjs/validation/errorTemplates.js +0 -48
- package/dist/cjs/validation/errorTemplates.js.map +0 -7
- package/dist/cjs/validation/index.js +0 -30
- package/dist/cjs/validation/index.js.map +0 -7
- package/dist/cjs/validation/typescriptGuards.js +0 -65
- package/dist/cjs/validation/typescriptGuards.js.map +0 -7
- package/dist/cjs/validation/typescriptParsers.js +0 -76
- package/dist/cjs/validation/typescriptParsers.js.map +0 -7
- package/dist/cjs/validation/typescriptValidator.js +0 -171
- package/dist/cjs/validation/typescriptValidator.js.map +0 -7
- package/dist/cjs/validation/validator.js +0 -55
- package/dist/cjs/validation/validator.js.map +0 -7
- package/dist/esm/defaultProps/index.js +0 -3
- package/dist/esm/defaultProps/index.js.map +0 -7
- package/dist/esm/defaultProps/useMemoMergePropsWithDefault.js +0 -19
- package/dist/esm/defaultProps/useMemoMergePropsWithDefault.js.map +0 -7
- package/dist/esm/getProps/index.js +0 -8
- package/dist/esm/getProps/index.js.map +0 -7
- package/dist/esm/globalProps/constants.js +0 -369
- package/dist/esm/globalProps/constants.js.map +0 -7
- package/dist/esm/globalProps/globalAttributesPropTypes.js.map +0 -7
- package/dist/esm/globalProps/index.js +0 -4
- package/dist/esm/globalProps/index.js.map +0 -7
- package/dist/esm/globalProps/useGetGlobalAttributes.js +0 -27
- package/dist/esm/globalProps/useGetGlobalAttributes.js.map +0 -7
- package/dist/esm/index.js +0 -7
- package/dist/esm/index.js.map +0 -7
- package/dist/esm/propTypes/PropTypes.js +0 -107
- package/dist/esm/propTypes/PropTypes.js.map +0 -7
- package/dist/esm/propTypes/customPropTypes.js +0 -9
- package/dist/esm/propTypes/customPropTypes.js.map +0 -7
- package/dist/esm/propTypes/describe.js +0 -52
- package/dist/esm/propTypes/describe.js.map +0 -7
- package/dist/esm/propTypes/describeConversions.js +0 -76
- package/dist/esm/propTypes/describeConversions.js.map +0 -7
- package/dist/esm/propTypes/describeGuards.js +0 -20
- package/dist/esm/propTypes/describeGuards.js.map +0 -7
- package/dist/esm/propTypes/index.js +0 -8
- package/dist/esm/propTypes/index.js.map +0 -7
- package/dist/esm/propTypes/toTypescript.js +0 -110
- package/dist/esm/propTypes/toTypescript.js.map +0 -7
- package/dist/esm/propTypes/types.js +0 -2
- package/dist/esm/propTypes/types.js.map +0 -7
- package/dist/esm/tests/globalProps/TestComponent.js +0 -13
- package/dist/esm/tests/globalProps/TestComponent.js.map +0 -7
- package/dist/esm/tests/validation/test.schema.js +0 -38
- package/dist/esm/tests/validation/test.schema.js.map +0 -7
- package/dist/esm/validation/errorTemplates.js +0 -19
- package/dist/esm/validation/errorTemplates.js.map +0 -7
- package/dist/esm/validation/index.js +0 -5
- package/dist/esm/validation/index.js.map +0 -7
- package/dist/esm/validation/typescriptGuards.js +0 -36
- package/dist/esm/validation/typescriptGuards.js.map +0 -7
- package/dist/esm/validation/typescriptParsers.js +0 -47
- package/dist/esm/validation/typescriptParsers.js.map +0 -7
- package/dist/esm/validation/typescriptValidator.js +0 -153
- package/dist/esm/validation/typescriptValidator.js.map +0 -7
- package/dist/esm/validation/validator.js +0 -26
- package/dist/esm/validation/validator.js.map +0 -7
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
4
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
5
|
+
import { useState, useMemo } from 'react';
|
|
6
|
+
import '../propTypes/PropTypes.js';
|
|
7
|
+
import describe from '../propTypes/describe.js';
|
|
8
|
+
import { throwRequiredError, throwTypeError } from './errorTemplates.js';
|
|
9
|
+
import { isUndefined, isNull, isPrimitiveType, isUnion, isString, isArray, isObject, isFunction, isJSXorNode, isSomethingWithParenthesis } from './typescriptGuards.js';
|
|
10
|
+
import { typescriptObjectParser } from './typescriptParsers.js';
|
|
11
|
+
|
|
12
|
+
// =============================================================================
|
|
13
|
+
// Atom Validators
|
|
14
|
+
// =============================================================================
|
|
15
|
+
// This functions will validate something from the data
|
|
16
|
+
// and optionally recursively apply `validateValueWithFormat`
|
|
17
|
+
// in smaller parts
|
|
18
|
+
const validateUndefined = (schemaName, key, value, format) => {
|
|
19
|
+
if (value !== undefined || value === 'undefined') {
|
|
20
|
+
throwTypeError(schemaName, key, value, format);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const validateNull = (schemaName, key, value, format) => {
|
|
25
|
+
if (value !== null || value === 'null') {
|
|
26
|
+
throwTypeError(schemaName, key, value, format);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const validatePrimitiveType = (schemaName, key, value, format) => {
|
|
31
|
+
if (typeof value !== format) {
|
|
32
|
+
throwTypeError(schemaName, key, value, format);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const validateString = (schemaName, key, value, format) => {
|
|
37
|
+
if (value !== format.slice(1, -1)) {
|
|
38
|
+
throwTypeError(schemaName, key, value, format);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const validateArray = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {
|
|
43
|
+
// Check that we have an array
|
|
44
|
+
if (!Array.isArray(value)) {
|
|
45
|
+
throwTypeError(schemaName, key, value, format);
|
|
46
|
+
} // Check that each element inside satisfies the format
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
value.forEach((val, index) => {
|
|
50
|
+
// this is a recursive func, we need to invoke it before it's defined.
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
52
|
+
validateValueWithFormat(schemaName, "".concat(key, "[").concat(index, "]"), val, format.slice(0, -2), validationsMemo, nextValidationsMemo);
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
function isObjectType(value) {
|
|
57
|
+
return !(typeof value !== 'object' || Array.isArray(value));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const validateObject = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {
|
|
61
|
+
const valuesIsObject = isObjectType(value); // Check that we have an object
|
|
62
|
+
|
|
63
|
+
if (!valuesIsObject) {
|
|
64
|
+
throwTypeError(schemaName, key, value, format);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (format === 'object') return;
|
|
69
|
+
const keyValuePairs = typescriptObjectParser(format); // Now we have the key - value pairs
|
|
70
|
+
// Each key could either be required or not
|
|
71
|
+
// Just recursively check the object
|
|
72
|
+
|
|
73
|
+
keyValuePairs.forEach(_ref => {
|
|
74
|
+
let [objectKey, objectValue] = _ref;
|
|
75
|
+
const trueKey = objectKey.slice(-1) === '?' ? objectKey.slice(0, -1) : objectKey;
|
|
76
|
+
|
|
77
|
+
if (trueKey === objectKey && !(trueKey in value)) {
|
|
78
|
+
throwRequiredError(schemaName, key);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (trueKey in value) {
|
|
82
|
+
// this is a recursive func, we need to invoke it before it's defined.
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
84
|
+
validateValueWithFormat(schemaName, "".concat(key, "[").concat(trueKey, "]"), value[trueKey], objectValue, validationsMemo, nextValidationsMemo);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const validateUnion = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {
|
|
90
|
+
const possibilities = format.split(/\s?\|\s?/);
|
|
91
|
+
const errors = [];
|
|
92
|
+
possibilities.forEach(possibility => {
|
|
93
|
+
try {
|
|
94
|
+
// this is a recursive func, we need to invoke it before it's defined.
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
96
|
+
validateValueWithFormat(schemaName, key, value, possibility, validationsMemo, nextValidationsMemo);
|
|
97
|
+
} catch (e) {
|
|
98
|
+
errors.push(e);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
if (errors.length === possibilities.length) {
|
|
103
|
+
throwTypeError(schemaName, key, value, format);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const validateFunction = (schemaName, key, value, format) => {
|
|
108
|
+
// Check that we have a function
|
|
109
|
+
if (typeof value !== 'function') {
|
|
110
|
+
throwTypeError(schemaName, key, value, format);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
function isJSXElement(value) {
|
|
115
|
+
return value === null || typeof value === 'object' && value !== null && '$$typeof' in value;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const validateJSXorNode = (schemaName, key, value, format) => {
|
|
119
|
+
const valueIsJSX = isJSXElement(value);
|
|
120
|
+
|
|
121
|
+
if (format === 'JSX.Element' && !valueIsJSX) {
|
|
122
|
+
throwTypeError(schemaName, key, value, format);
|
|
123
|
+
}
|
|
124
|
+
}; // =============================================================================
|
|
125
|
+
// Schema validator
|
|
126
|
+
// =============================================================================
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
const validateValueWithFormat = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {
|
|
130
|
+
nextValidationsMemo[value] = format;
|
|
131
|
+
|
|
132
|
+
if (value in validationsMemo) {
|
|
133
|
+
// We already validated this value on this format
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (isUndefined(format)) {
|
|
138
|
+
validateUndefined(schemaName, key, value, format);
|
|
139
|
+
} else if (isNull(format)) {
|
|
140
|
+
validateNull(schemaName, key, value, format);
|
|
141
|
+
} else if (isPrimitiveType(format)) {
|
|
142
|
+
validatePrimitiveType(schemaName, key, value, format);
|
|
143
|
+
} else if (isUnion(format)) {
|
|
144
|
+
validateUnion(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
|
|
145
|
+
} else if (isString(format)) {
|
|
146
|
+
validateString(schemaName, key, value, format);
|
|
147
|
+
} else if (isArray(format)) {
|
|
148
|
+
validateArray(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
|
|
149
|
+
} else if (isObject(format)) {
|
|
150
|
+
validateObject(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
|
|
151
|
+
} else if (isFunction(format)) {
|
|
152
|
+
validateFunction(schemaName, key, value, format);
|
|
153
|
+
} else if (isJSXorNode(format)) {
|
|
154
|
+
validateJSXorNode(schemaName, key, value, format);
|
|
155
|
+
} else if (isSomethingWithParenthesis(format)) {
|
|
156
|
+
validateValueWithFormat(schemaName, key, value, format.slice(1, -1), validationsMemo, nextValidationsMemo);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const validateTypescriptPropTypesImplementation = function (props, schema) {
|
|
161
|
+
let validationsMemo = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
162
|
+
let nextValidationsMemo = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
163
|
+
const {
|
|
164
|
+
properties,
|
|
165
|
+
name: schemaName
|
|
166
|
+
} = schema;
|
|
167
|
+
properties.forEach(property => {
|
|
168
|
+
const {
|
|
169
|
+
name,
|
|
170
|
+
format,
|
|
171
|
+
required
|
|
172
|
+
} = property;
|
|
173
|
+
|
|
174
|
+
if (required && !(name in props)) {
|
|
175
|
+
throwRequiredError(schema.name, name);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (name in props && (props[name] !== undefined || required)) {
|
|
179
|
+
validateValueWithFormat(schemaName, name, props[name], format, validationsMemo, nextValidationsMemo);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
183
|
+
|
|
184
|
+
const useValidateTypescriptPropTypes = (props, propTypes) => {
|
|
185
|
+
const [validationsMemo, setValidationsMemo] = useState({}); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
186
|
+
|
|
187
|
+
const ComponentWithSchema = useMemo(() => {
|
|
188
|
+
const Component = () => {}; // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
return describe(Component);
|
|
192
|
+
}, []); // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
|
|
193
|
+
|
|
194
|
+
ComponentWithSchema.propTypes = propTypes;
|
|
195
|
+
useMemo(() => {
|
|
196
|
+
const nextValidationsMemo = {};
|
|
197
|
+
validateTypescriptPropTypesImplementation(props, // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
|
|
198
|
+
ComponentWithSchema.toTypescript(), validationsMemo, nextValidationsMemo);
|
|
199
|
+
setValidationsMemo(nextValidationsMemo); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
200
|
+
}, [props]);
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
export { useValidateTypescriptPropTypes, validateTypescriptPropTypesImplementation };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
4
|
+
import { throwRequiredError, throwTypeError } from './errorTemplates.js';
|
|
5
|
+
|
|
6
|
+
const useValidatePropTypes = (props, schema) => {
|
|
7
|
+
schema.properties.forEach(property => {
|
|
8
|
+
const propertyName = property.name;
|
|
9
|
+
const currentProp = props[propertyName];
|
|
10
|
+
const currentPropTypeOf = typeof currentProp; // eslint-disable-next-line max-len
|
|
11
|
+
|
|
12
|
+
const currentFormat = property.format; // this is csv representing types e.g.: "string"/"string,number"/"[object],string"
|
|
13
|
+
|
|
14
|
+
let isValidReactElement = false; // this depends on react desc definition
|
|
15
|
+
|
|
16
|
+
if (property.required && !Object.prototype.hasOwnProperty.call(props, property.name)) {
|
|
17
|
+
throwRequiredError(schema.name, property.name);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (currentPropTypeOf !== 'undefined' && currentProp !== null) {
|
|
21
|
+
if (currentPropTypeOf === 'object' && Object.prototype.hasOwnProperty.call(currentProp, '$$typeof') && (currentFormat.includes('node') || currentFormat.includes('element'))) {
|
|
22
|
+
isValidReactElement = true;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!currentFormat.includes(currentPropTypeOf) && !currentFormat.includes(currentProp) && !isValidReactElement) {
|
|
26
|
+
throwTypeError(schema.name, propertyName, currentProp, currentFormat);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { useValidatePropTypes };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
4
|
+
|
|
5
|
+
const marginKeys = ['margin', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft', 'm', 'mt', 'mr', 'mb', 'ml', 'mx', 'my'];
|
|
6
|
+
const paddingKeys = ['padding', 'p', 'paddingTop', 'pt', 'paddingRight', 'pr', 'paddingBottom', 'pb', 'paddingLeft', 'pl', 'px', 'py'];
|
|
7
|
+
const spaceKeys = ['spaceY', 'spaceX', 'spaceXReverse', 'spaceYReverse'];
|
|
8
|
+
const widthKeys = ['w', 'maxWidth', 'maxW', 'minWidth', 'minW'];
|
|
9
|
+
const heightKeys = ['h', 'maxHeight', 'maxH', 'minHeight', 'minH'];
|
|
10
|
+
const maskSizeKeys = ['maskSize'];
|
|
11
|
+
const spacingKeys = [...marginKeys, ...paddingKeys, ...spaceKeys];
|
|
12
|
+
const sizingKeys = [...widthKeys, ...heightKeys, ...maskSizeKeys];
|
|
13
|
+
const layoutKeys = ['display', 'float', 'boxSizing', 'container', 'overflow', 'overflowX', 'overflowY', 'zIndex', 'position', 'top', 'right', 'bottom', 'left', 'visibility', 'overscrollBehavior', 'objectFit'];
|
|
14
|
+
const xstyledKeys = Object.fromEntries([...spacingKeys, ...sizingKeys, ...layoutKeys].map(item => [item, true]));
|
|
15
|
+
|
|
16
|
+
export { layoutKeys, xstyledKeys };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
4
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
import { xstyledKeys } from './constants.js';
|
|
7
|
+
|
|
8
|
+
const useGetXstyledProps = props => {
|
|
9
|
+
const componentXstyledProps = useMemo(() => {
|
|
10
|
+
const xstyledPropsObject = {};
|
|
11
|
+
Object.entries(props).forEach(_ref => {
|
|
12
|
+
let [key, value] = _ref;
|
|
13
|
+
|
|
14
|
+
if (key in xstyledKeys) {
|
|
15
|
+
xstyledPropsObject[key] = value;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return xstyledPropsObject;
|
|
19
|
+
}, [props]);
|
|
20
|
+
return componentXstyledProps;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { useGetXstyledProps };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import PropTypes from '../propTypes/PropTypes.js';
|
|
2
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
4
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
6
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
7
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
8
|
+
import 'prop-types';
|
|
9
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
10
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
11
|
+
import '@babel/runtime/helpers/esm/defineProperty';
|
|
12
|
+
|
|
13
|
+
const xstyledPropTypes = {
|
|
14
|
+
margin: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
15
|
+
m: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
16
|
+
marginTop: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
17
|
+
mt: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
18
|
+
marginRight: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
19
|
+
mr: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
20
|
+
marginBottom: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
21
|
+
mb: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
22
|
+
marginLeft: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
23
|
+
ml: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
24
|
+
mx: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
25
|
+
my: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
26
|
+
padding: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
27
|
+
p: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
28
|
+
paddingTop: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
29
|
+
pt: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
30
|
+
paddingRight: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
31
|
+
pr: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
32
|
+
paddingBottom: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
33
|
+
pb: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
34
|
+
paddingLeft: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
35
|
+
pl: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
36
|
+
px: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
37
|
+
py: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
38
|
+
spaceY: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
39
|
+
spaceX: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
40
|
+
spaceXReverse: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
41
|
+
spaceYReverse: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
42
|
+
w: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
43
|
+
maxWidth: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
44
|
+
maxW: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
45
|
+
minWidth: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
46
|
+
minW: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
47
|
+
h: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
48
|
+
maxHeight: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
49
|
+
maxH: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
50
|
+
minHeight: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
51
|
+
minH: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
52
|
+
maskSize: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
53
|
+
display: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
54
|
+
float: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
55
|
+
boxSizing: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
56
|
+
container: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
57
|
+
overflow: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
58
|
+
overflowX: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
59
|
+
overflowY: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
60
|
+
zIndex: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
61
|
+
position: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
62
|
+
top: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
63
|
+
right: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
64
|
+
bottom: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
65
|
+
left: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
66
|
+
visibility: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
67
|
+
overscrollBehavior: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
68
|
+
objectFit: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled()
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export { xstyledPropTypes };
|
package/package.json
CHANGED
|
@@ -1,110 +1,123 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-props-helpers",
|
|
3
|
-
"version": "2.3.0-
|
|
3
|
+
"version": "2.3.0-next.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Props Helpers",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"module": "./dist/esm/index.js",
|
|
10
|
-
"main": "./dist/cjs/index.js",
|
|
11
|
-
"types": "./dist/types/index.d.ts",
|
|
6
|
+
"module": "./esm/index.js",
|
|
7
|
+
"main": "./cjs/index.js",
|
|
8
|
+
"types": "./types/index.d.ts",
|
|
12
9
|
"exports": {
|
|
13
10
|
".": {
|
|
14
|
-
"import": "./
|
|
15
|
-
"require": "./
|
|
11
|
+
"import": "./esm/index.js",
|
|
12
|
+
"require": "./cjs/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./xstyledProps/xstyledPropTypes": {
|
|
15
|
+
"import": "./esm/xstyledProps/xstyledPropTypes.js",
|
|
16
|
+
"require": "./cjs/xstyledProps/xstyledPropTypes.js"
|
|
17
|
+
},
|
|
18
|
+
"./xstyledProps/useGetXstyledProps": {
|
|
19
|
+
"import": "./esm/xstyledProps/useGetXstyledProps.js",
|
|
20
|
+
"require": "./cjs/xstyledProps/useGetXstyledProps.js"
|
|
21
|
+
},
|
|
22
|
+
"./xstyledProps": {
|
|
23
|
+
"import": "./esm/xstyledProps/index.js",
|
|
24
|
+
"require": "./cjs/xstyledProps/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./xstyledProps/constants": {
|
|
27
|
+
"import": "./esm/xstyledProps/constants.js",
|
|
28
|
+
"require": "./cjs/xstyledProps/constants.js"
|
|
16
29
|
},
|
|
17
30
|
"./validation/validator": {
|
|
18
|
-
"import": "./
|
|
19
|
-
"require": "./
|
|
31
|
+
"import": "./esm/validation/validator.js",
|
|
32
|
+
"require": "./cjs/validation/validator.js"
|
|
20
33
|
},
|
|
21
34
|
"./validation/typescriptValidator": {
|
|
22
|
-
"import": "./
|
|
23
|
-
"require": "./
|
|
35
|
+
"import": "./esm/validation/typescriptValidator.js",
|
|
36
|
+
"require": "./cjs/validation/typescriptValidator.js"
|
|
24
37
|
},
|
|
25
38
|
"./validation/typescriptParsers": {
|
|
26
|
-
"import": "./
|
|
27
|
-
"require": "./
|
|
39
|
+
"import": "./esm/validation/typescriptParsers.js",
|
|
40
|
+
"require": "./cjs/validation/typescriptParsers.js"
|
|
28
41
|
},
|
|
29
42
|
"./validation/typescriptGuards": {
|
|
30
|
-
"import": "./
|
|
31
|
-
"require": "./
|
|
43
|
+
"import": "./esm/validation/typescriptGuards.js",
|
|
44
|
+
"require": "./cjs/validation/typescriptGuards.js"
|
|
32
45
|
},
|
|
33
46
|
"./validation": {
|
|
34
|
-
"import": "./
|
|
35
|
-
"require": "./
|
|
47
|
+
"import": "./esm/validation/index.js",
|
|
48
|
+
"require": "./cjs/validation/index.js"
|
|
36
49
|
},
|
|
37
50
|
"./validation/errorTemplates": {
|
|
38
|
-
"import": "./
|
|
39
|
-
"require": "./
|
|
51
|
+
"import": "./esm/validation/errorTemplates.js",
|
|
52
|
+
"require": "./cjs/validation/errorTemplates.js"
|
|
40
53
|
},
|
|
41
54
|
"./tests/validation/test.schema": {
|
|
42
|
-
"import": "./
|
|
43
|
-
"require": "./
|
|
55
|
+
"import": "./esm/tests/validation/test.schema.js",
|
|
56
|
+
"require": "./cjs/tests/validation/test.schema.js"
|
|
44
57
|
},
|
|
45
58
|
"./tests/globalProps/TestComponent": {
|
|
46
|
-
"import": "./
|
|
47
|
-
"require": "./
|
|
59
|
+
"import": "./esm/tests/globalProps/TestComponent.js",
|
|
60
|
+
"require": "./cjs/tests/globalProps/TestComponent.js"
|
|
48
61
|
},
|
|
49
62
|
"./propTypes/types": {
|
|
50
|
-
"import": "./
|
|
51
|
-
"require": "./
|
|
63
|
+
"import": "./esm/propTypes/types.js",
|
|
64
|
+
"require": "./cjs/propTypes/types.js"
|
|
52
65
|
},
|
|
53
66
|
"./propTypes/toTypescript": {
|
|
54
|
-
"import": "./
|
|
55
|
-
"require": "./
|
|
67
|
+
"import": "./esm/propTypes/toTypescript.js",
|
|
68
|
+
"require": "./cjs/propTypes/toTypescript.js"
|
|
56
69
|
},
|
|
57
70
|
"./propTypes/PropTypes": {
|
|
58
|
-
"import": "./
|
|
59
|
-
"require": "./
|
|
71
|
+
"import": "./esm/propTypes/PropTypes.js",
|
|
72
|
+
"require": "./cjs/propTypes/PropTypes.js"
|
|
60
73
|
},
|
|
61
74
|
"./propTypes": {
|
|
62
|
-
"import": "./
|
|
63
|
-
"require": "./
|
|
75
|
+
"import": "./esm/propTypes/index.js",
|
|
76
|
+
"require": "./cjs/propTypes/index.js"
|
|
64
77
|
},
|
|
65
78
|
"./propTypes/describeGuards": {
|
|
66
|
-
"import": "./
|
|
67
|
-
"require": "./
|
|
79
|
+
"import": "./esm/propTypes/describeGuards.js",
|
|
80
|
+
"require": "./cjs/propTypes/describeGuards.js"
|
|
68
81
|
},
|
|
69
82
|
"./propTypes/describeConversions": {
|
|
70
|
-
"import": "./
|
|
71
|
-
"require": "./
|
|
83
|
+
"import": "./esm/propTypes/describeConversions.js",
|
|
84
|
+
"require": "./cjs/propTypes/describeConversions.js"
|
|
72
85
|
},
|
|
73
86
|
"./propTypes/describe": {
|
|
74
|
-
"import": "./
|
|
75
|
-
"require": "./
|
|
87
|
+
"import": "./esm/propTypes/describe.js",
|
|
88
|
+
"require": "./cjs/propTypes/describe.js"
|
|
76
89
|
},
|
|
77
90
|
"./propTypes/customPropTypes": {
|
|
78
|
-
"import": "./
|
|
79
|
-
"require": "./
|
|
91
|
+
"import": "./esm/propTypes/customPropTypes.js",
|
|
92
|
+
"require": "./cjs/propTypes/customPropTypes.js"
|
|
80
93
|
},
|
|
81
94
|
"./globalProps/useGetGlobalAttributes": {
|
|
82
|
-
"import": "./
|
|
83
|
-
"require": "./
|
|
95
|
+
"import": "./esm/globalProps/useGetGlobalAttributes.js",
|
|
96
|
+
"require": "./cjs/globalProps/useGetGlobalAttributes.js"
|
|
84
97
|
},
|
|
85
98
|
"./globalProps": {
|
|
86
|
-
"import": "./
|
|
87
|
-
"require": "./
|
|
99
|
+
"import": "./esm/globalProps/index.js",
|
|
100
|
+
"require": "./cjs/globalProps/index.js"
|
|
88
101
|
},
|
|
89
102
|
"./globalProps/globalAttributesPropTypes": {
|
|
90
|
-
"import": "./
|
|
91
|
-
"require": "./
|
|
103
|
+
"import": "./esm/globalProps/globalAttributesPropTypes.js",
|
|
104
|
+
"require": "./cjs/globalProps/globalAttributesPropTypes.js"
|
|
92
105
|
},
|
|
93
106
|
"./globalProps/constants": {
|
|
94
|
-
"import": "./
|
|
95
|
-
"require": "./
|
|
107
|
+
"import": "./esm/globalProps/constants.js",
|
|
108
|
+
"require": "./cjs/globalProps/constants.js"
|
|
96
109
|
},
|
|
97
110
|
"./getProps": {
|
|
98
|
-
"import": "./
|
|
99
|
-
"require": "./
|
|
111
|
+
"import": "./esm/getProps/index.js",
|
|
112
|
+
"require": "./cjs/getProps/index.js"
|
|
100
113
|
},
|
|
101
114
|
"./defaultProps/useMemoMergePropsWithDefault": {
|
|
102
|
-
"import": "./
|
|
103
|
-
"require": "./
|
|
115
|
+
"import": "./esm/defaultProps/useMemoMergePropsWithDefault.js",
|
|
116
|
+
"require": "./cjs/defaultProps/useMemoMergePropsWithDefault.js"
|
|
104
117
|
},
|
|
105
118
|
"./defaultProps": {
|
|
106
|
-
"import": "./
|
|
107
|
-
"require": "./
|
|
119
|
+
"import": "./esm/defaultProps/index.js",
|
|
120
|
+
"require": "./cjs/defaultProps/index.js"
|
|
108
121
|
}
|
|
109
122
|
},
|
|
110
123
|
"sideEffects": [
|
|
@@ -116,15 +129,22 @@
|
|
|
116
129
|
"url": "https://git.elliemae.io/platform-ui/dimsum.git"
|
|
117
130
|
},
|
|
118
131
|
"engines": {
|
|
119
|
-
"
|
|
120
|
-
"node": ">=
|
|
132
|
+
"npm": ">=7",
|
|
133
|
+
"node": ">=14"
|
|
134
|
+
},
|
|
135
|
+
"scripts": {
|
|
136
|
+
"dev": "cross-env NODE_ENV=development && node ../../scripts/build/build.js -w",
|
|
137
|
+
"prebuild": "exit 0",
|
|
138
|
+
"predev": "exit 0",
|
|
139
|
+
"build": "node ../../scripts/build/build.js"
|
|
121
140
|
},
|
|
122
141
|
"dependencies": {
|
|
123
142
|
"fast-deep-equal": "~3.1.3",
|
|
124
143
|
"react-desc": "^4.1.3"
|
|
125
144
|
},
|
|
126
145
|
"devDependencies": {
|
|
127
|
-
"@testing-library/jest-dom": "~5.15.
|
|
146
|
+
"@testing-library/jest-dom": "~5.15.0",
|
|
147
|
+
"@xstyled/styled-components": "~3.5.1"
|
|
128
148
|
},
|
|
129
149
|
"peerDependencies": {
|
|
130
150
|
"react": "~17.0.2",
|
|
@@ -132,12 +152,7 @@
|
|
|
132
152
|
},
|
|
133
153
|
"publishConfig": {
|
|
134
154
|
"access": "public",
|
|
135
|
-
"
|
|
136
|
-
|
|
137
|
-
"scripts": {
|
|
138
|
-
"dev": "cross-env NODE_ENV=development && node ../../scripts/build/build.js -w",
|
|
139
|
-
"prebuild": "exit 0",
|
|
140
|
-
"predev": "exit 0",
|
|
141
|
-
"build": "node ../../scripts/build/build.js"
|
|
155
|
+
"directory": "dist",
|
|
156
|
+
"generateSubmodules": true
|
|
142
157
|
}
|
|
143
158
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useMemoMergePropsWithDefault';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useMemoMergePropsWithDefault: <T = Record<string, any>>(props: Partial<T>, defaultProps: Partial<T>, compare?: (a: any, b: any) => boolean) => T;
|