@elliemae/ds-props-helpers 2.3.0-alpha.1 → 2.3.0-alpha.6
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 → dist/cjs}/defaultProps/index.js +0 -0
- package/{cjs → dist/cjs}/defaultProps/index.js.map +0 -0
- package/{cjs → dist/cjs}/defaultProps/useMemoMergePropsWithDefault.js +0 -0
- package/{cjs → dist/cjs}/defaultProps/useMemoMergePropsWithDefault.js.map +0 -0
- package/{cjs → dist/cjs}/getProps/index.js +0 -0
- package/{cjs → dist/cjs}/getProps/index.js.map +0 -0
- package/dist/cjs/globalProps/constants.js +398 -0
- package/dist/cjs/globalProps/constants.js.map +7 -0
- package/dist/cjs/globalProps/globalAttributesPropTypes.js +398 -0
- package/dist/cjs/globalProps/globalAttributesPropTypes.js.map +7 -0
- package/dist/cjs/globalProps/index.js +29 -0
- package/dist/cjs/globalProps/index.js.map +7 -0
- package/dist/cjs/globalProps/useGetGlobalAttributes.js +56 -0
- package/dist/cjs/globalProps/useGetGlobalAttributes.js.map +7 -0
- package/{cjs → dist/cjs}/index.js +2 -0
- package/{cjs → dist/cjs}/index.js.map +2 -2
- package/dist/cjs/propTypes/PropTypes.js +136 -0
- package/dist/cjs/propTypes/PropTypes.js.map +7 -0
- package/dist/cjs/propTypes/customPropTypes.js +38 -0
- package/dist/cjs/propTypes/customPropTypes.js.map +7 -0
- package/dist/cjs/propTypes/describe.js +81 -0
- package/dist/cjs/propTypes/describe.js.map +7 -0
- package/dist/cjs/propTypes/describeConversions.js +96 -0
- package/dist/cjs/propTypes/describeConversions.js.map +7 -0
- package/dist/cjs/propTypes/describeGuards.js +49 -0
- package/dist/cjs/propTypes/describeGuards.js.map +7 -0
- package/dist/cjs/propTypes/index.js +37 -0
- package/dist/cjs/propTypes/index.js.map +7 -0
- package/dist/cjs/propTypes/toTypescript.js +139 -0
- package/dist/cjs/propTypes/toTypescript.js.map +7 -0
- package/dist/cjs/propTypes/types.js +27 -0
- package/dist/cjs/propTypes/types.js.map +7 -0
- package/dist/cjs/tests/globalProps/TestComponent.js +42 -0
- package/dist/cjs/tests/globalProps/TestComponent.js.map +7 -0
- package/{cjs/tests → dist/cjs/tests/validation}/test.schema.js +0 -0
- package/{cjs/tests → dist/cjs/tests/validation}/test.schema.js.map +1 -1
- package/{cjs → dist/cjs}/validation/errorTemplates.js +0 -0
- package/{cjs → dist/cjs}/validation/errorTemplates.js.map +0 -0
- package/{cjs → dist/cjs}/validation/index.js +0 -0
- package/{cjs → dist/cjs}/validation/index.js.map +0 -0
- package/{cjs → dist/cjs}/validation/typescriptGuards.js +0 -0
- package/{cjs → dist/cjs}/validation/typescriptGuards.js.map +0 -0
- package/{cjs → dist/cjs}/validation/typescriptParsers.js +0 -0
- package/{cjs → dist/cjs}/validation/typescriptParsers.js.map +0 -0
- package/{cjs → dist/cjs}/validation/typescriptValidator.js +2 -2
- package/dist/cjs/validation/typescriptValidator.js.map +7 -0
- package/{cjs → dist/cjs}/validation/validator.js +0 -0
- package/{cjs → dist/cjs}/validation/validator.js.map +0 -0
- package/{esm → dist/esm}/defaultProps/index.js +0 -0
- package/{esm → dist/esm}/defaultProps/index.js.map +0 -0
- package/{esm → dist/esm}/defaultProps/useMemoMergePropsWithDefault.js +0 -0
- package/{esm → dist/esm}/defaultProps/useMemoMergePropsWithDefault.js.map +0 -0
- package/{esm → dist/esm}/getProps/index.js +0 -0
- package/{esm → dist/esm}/getProps/index.js.map +0 -0
- package/dist/esm/globalProps/constants.js +369 -0
- package/dist/esm/globalProps/constants.js.map +7 -0
- package/dist/esm/globalProps/globalAttributesPropTypes.js +369 -0
- package/dist/esm/globalProps/globalAttributesPropTypes.js.map +7 -0
- package/dist/esm/globalProps/index.js +4 -0
- package/dist/esm/globalProps/index.js.map +7 -0
- package/dist/esm/globalProps/useGetGlobalAttributes.js +27 -0
- package/dist/esm/globalProps/useGetGlobalAttributes.js.map +7 -0
- package/{esm → dist/esm}/index.js +2 -0
- package/{esm → dist/esm}/index.js.map +2 -2
- package/dist/esm/propTypes/PropTypes.js +107 -0
- package/dist/esm/propTypes/PropTypes.js.map +7 -0
- package/dist/esm/propTypes/customPropTypes.js +9 -0
- package/dist/esm/propTypes/customPropTypes.js.map +7 -0
- package/dist/esm/propTypes/describe.js +52 -0
- package/dist/esm/propTypes/describe.js.map +7 -0
- package/dist/esm/propTypes/describeConversions.js +76 -0
- package/dist/esm/propTypes/describeConversions.js.map +7 -0
- package/dist/esm/propTypes/describeGuards.js +20 -0
- package/dist/esm/propTypes/describeGuards.js.map +7 -0
- package/dist/esm/propTypes/index.js +8 -0
- package/dist/esm/propTypes/index.js.map +7 -0
- package/dist/esm/propTypes/toTypescript.js +110 -0
- package/dist/esm/propTypes/toTypescript.js.map +7 -0
- package/dist/esm/propTypes/types.js +2 -0
- package/dist/esm/propTypes/types.js.map +7 -0
- package/dist/esm/tests/globalProps/TestComponent.js +13 -0
- package/dist/esm/tests/globalProps/TestComponent.js.map +7 -0
- package/{esm/tests → dist/esm/tests/validation}/test.schema.js +0 -0
- package/{esm/tests → dist/esm/tests/validation}/test.schema.js.map +1 -1
- package/{esm → dist/esm}/validation/errorTemplates.js +0 -0
- package/{esm → dist/esm}/validation/errorTemplates.js.map +0 -0
- package/{esm → dist/esm}/validation/index.js +0 -0
- package/{esm → dist/esm}/validation/index.js.map +0 -0
- package/{esm → dist/esm}/validation/typescriptGuards.js +0 -0
- package/{esm → dist/esm}/validation/typescriptGuards.js.map +0 -0
- package/{esm → dist/esm}/validation/typescriptParsers.js +0 -0
- package/{esm → dist/esm}/validation/typescriptParsers.js.map +0 -0
- package/{esm → dist/esm}/validation/typescriptValidator.js +1 -1
- package/dist/esm/validation/typescriptValidator.js.map +7 -0
- package/{esm → dist/esm}/validation/validator.js +0 -0
- package/{esm → dist/esm}/validation/validator.js.map +0 -0
- package/package.json +92 -38
- package/cjs/validation/typescriptValidator.js.map +0 -7
- package/esm/validation/typescriptValidator.js.map +0 -7
- package/types/defaultProps/index.d.ts +0 -1
- package/types/defaultProps/useMemoMergePropsWithDefault.d.ts +0 -1
- package/types/getProps/index.d.ts +0 -2
- package/types/index.d.ts +0 -3
- package/types/tests/any.validation.test.d.ts +0 -1
- package/types/tests/array.validation.test.d.ts +0 -1
- package/types/tests/boolean.validation.test.d.ts +0 -1
- package/types/tests/function.validation.test.d.ts +0 -1
- package/types/tests/number.validation.test.d.ts +0 -1
- package/types/tests/object.validation.test.d.ts +0 -1
- package/types/tests/schema.validation.test.d.ts +0 -1
- package/types/tests/string.validation.test.d.ts +0 -1
- package/types/tests/test.schema.d.ts +0 -1
- package/types/tests/union.validation.test.d.ts +0 -1
- package/types/validation/errorTemplates.d.ts +0 -2
- package/types/validation/index.d.ts +0 -3
- package/types/validation/typescriptGuards.d.ts +0 -12
- package/types/validation/typescriptParsers.d.ts +0 -1
- package/types/validation/typescriptValidator.d.ts +0 -15
- package/types/validation/validator.d.ts +0 -1
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (module2, isNodeMode) => {
|
|
21
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
+
return (module2, temp) => {
|
|
25
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
+
};
|
|
27
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
+
var toTypescript_exports = {};
|
|
29
|
+
__export(toTypescript_exports, {
|
|
30
|
+
default: () => descToTypescript
|
|
31
|
+
});
|
|
32
|
+
var React = __toESM(require("react"));
|
|
33
|
+
const arrayFormat = (array) => array.map((propType) => propTypeFormat(propType));
|
|
34
|
+
const shapeFormat = (shape) => {
|
|
35
|
+
const props = Object.keys(shape).map((key) => {
|
|
36
|
+
const value = shape[key];
|
|
37
|
+
let valueFormat;
|
|
38
|
+
if (value.type && (value.type === "arrayOf" || value.type === "oneOfType" || value.type === "oneOf") && Array.isArray(value.args)) {
|
|
39
|
+
valueFormat = `${propTypeFormat(value)}`;
|
|
40
|
+
} else if (value.type === "shape") {
|
|
41
|
+
valueFormat = `${propTypeFormat(value)}`;
|
|
42
|
+
} else {
|
|
43
|
+
valueFormat = propTypeFormat(value);
|
|
44
|
+
}
|
|
45
|
+
return `${key}${value.reactDesc && value.reactDesc.required ? "" : "?"}: ${valueFormat}`;
|
|
46
|
+
});
|
|
47
|
+
return `{${props.join(",")}}`;
|
|
48
|
+
};
|
|
49
|
+
const propTypeFormat = (propType, joinWith = "") => {
|
|
50
|
+
let result;
|
|
51
|
+
if (Array.isArray(propType)) {
|
|
52
|
+
result = arrayFormat(propType).join(joinWith);
|
|
53
|
+
} else if (typeof propType !== "function" && propType.type) {
|
|
54
|
+
switch (propType.type) {
|
|
55
|
+
case "array":
|
|
56
|
+
result = "any[]";
|
|
57
|
+
break;
|
|
58
|
+
case "arrayOf":
|
|
59
|
+
if (propType.args.type === "oneOfType") {
|
|
60
|
+
result = `(${propTypeFormat(propType.args, " | ")})[]`;
|
|
61
|
+
} else {
|
|
62
|
+
result = `${propTypeFormat(propType.args, "\n")}[]`;
|
|
63
|
+
}
|
|
64
|
+
break;
|
|
65
|
+
case "tuple":
|
|
66
|
+
result = `[${propTypeFormat(propType.args, ", ")}]`;
|
|
67
|
+
break;
|
|
68
|
+
case "bool":
|
|
69
|
+
result = "boolean";
|
|
70
|
+
break;
|
|
71
|
+
case "func":
|
|
72
|
+
result = "((...args: any[]) => any)";
|
|
73
|
+
break;
|
|
74
|
+
case "node":
|
|
75
|
+
result = "React.ReactNode";
|
|
76
|
+
break;
|
|
77
|
+
case "element":
|
|
78
|
+
result = "JSX.Element";
|
|
79
|
+
break;
|
|
80
|
+
case "instanceOf":
|
|
81
|
+
result = "any";
|
|
82
|
+
break;
|
|
83
|
+
case "symbol":
|
|
84
|
+
result = "any";
|
|
85
|
+
break;
|
|
86
|
+
case "objectOf":
|
|
87
|
+
result = `{ [key: string]: ${propTypeFormat(propType.args)} }`;
|
|
88
|
+
break;
|
|
89
|
+
case "oneOf":
|
|
90
|
+
result = propType.args.map((a) => `"${a}"`).join(" | ");
|
|
91
|
+
break;
|
|
92
|
+
case "oneOfType":
|
|
93
|
+
result = `${propTypeFormat(propType.args, " | ")}`;
|
|
94
|
+
break;
|
|
95
|
+
case "shape":
|
|
96
|
+
result = `${shapeFormat(propType.args)}`;
|
|
97
|
+
break;
|
|
98
|
+
default:
|
|
99
|
+
result = `${propType.type}`;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
result = "any";
|
|
104
|
+
}
|
|
105
|
+
return result;
|
|
106
|
+
};
|
|
107
|
+
const propTypeAsTypescript = (propType, propName) => {
|
|
108
|
+
const documentation = {
|
|
109
|
+
...propType.reactDesc,
|
|
110
|
+
name: propName
|
|
111
|
+
};
|
|
112
|
+
documentation.format = propTypeFormat(propType);
|
|
113
|
+
return documentation;
|
|
114
|
+
};
|
|
115
|
+
function descToTypescript(component, reactDesc) {
|
|
116
|
+
if (!component) {
|
|
117
|
+
throw new Error("react-desc: component is required");
|
|
118
|
+
}
|
|
119
|
+
const documentation = {
|
|
120
|
+
name: component.displayName || component.name,
|
|
121
|
+
...reactDesc
|
|
122
|
+
};
|
|
123
|
+
if (reactDesc) {
|
|
124
|
+
delete documentation.propTypes;
|
|
125
|
+
if (reactDesc.propTypes) {
|
|
126
|
+
const propTypes = [];
|
|
127
|
+
Object.keys(reactDesc.propTypes).forEach((propName) => {
|
|
128
|
+
const propType = reactDesc.propTypes[propName];
|
|
129
|
+
propTypes.push(propTypeAsTypescript(propType, propName));
|
|
130
|
+
});
|
|
131
|
+
if (propTypes.length > 0) {
|
|
132
|
+
documentation.properties = propTypes;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return documentation;
|
|
137
|
+
}
|
|
138
|
+
module.exports = __toCommonJS(toTypescript_exports);
|
|
139
|
+
//# sourceMappingURL=toTypescript.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/propTypes/toTypescript.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/restrict-template-expressions */\n/* eslint-disable @typescript-eslint/no-use-before-define */\n/* eslint-disable complexity */\n/* eslint-disable react/forbid-foreign-prop-types */\nimport React from 'react';\nimport { ComponentDocumentation, ReactDescT, TypescriptDocumentation } from './types';\n\nconst arrayFormat = (array: ReactDescT[]) => array.map((propType) => propTypeFormat(propType));\n\nconst shapeFormat = (shape: Record<string, ReactDescT>) => {\n const props = Object.keys(shape).map((key) => {\n const value = shape[key];\n let valueFormat;\n if (\n value.type &&\n (value.type === 'arrayOf' || value.type === 'oneOfType' || value.type === 'oneOf') &&\n Array.isArray(value.args)\n ) {\n valueFormat = `${propTypeFormat(value)}`;\n } else if (value.type === 'shape') {\n valueFormat = `${propTypeFormat(value)}`;\n } else {\n valueFormat = propTypeFormat(value);\n }\n return `${key}${value.reactDesc && value.reactDesc.required ? '' : '?'}: ${valueFormat}`;\n });\n return `{${props.join(',')}}`;\n};\n\nconst propTypeFormat = (propType: ReactDescT | ReactDescT[], joinWith = ''): string => {\n let result;\n if (Array.isArray(propType)) {\n result = arrayFormat(propType).join(joinWith);\n } else if (typeof propType !== 'function' && propType.type) {\n switch (propType.type) {\n case 'array':\n result = 'any[]';\n break;\n case 'arrayOf':\n if ((propType.args as ReactDescT).type === 'oneOfType') {\n result = `(${propTypeFormat(propType.args as ReactDescT, ' | ')})[]`;\n } else {\n result = `${propTypeFormat(propType.args as ReactDescT, '\\n')}[]`;\n }\n break;\n case 'tuple':\n result = `[${propTypeFormat(propType.args as ReactDescT, ', ')}]`;\n break;\n case 'bool':\n result = 'boolean';\n break;\n case 'func':\n result = '((...args: any[]) => any)';\n break;\n case 'node':\n result = 'React.ReactNode';\n break;\n case 'element':\n result = 'JSX.Element';\n break;\n case 'instanceOf':\n result = 'any';\n break;\n case 'symbol':\n result = 'any';\n break;\n case 'objectOf':\n result = `{ [key: string]: ${propTypeFormat(propType.args as ReactDescT)} }`;\n break;\n case 'oneOf':\n result = (propType.args as unknown[]).map((a) => `\"${a}\"`).join(' | ');\n break;\n case 'oneOfType':\n result = `${propTypeFormat(propType.args as ReactDescT[], ' | ')}`;\n break;\n case 'shape':\n result = `${shapeFormat(propType.args as Record<string, ReactDescT>)}`;\n break;\n default:\n result = `${propType.type}`;\n break;\n }\n } else {\n result = 'any';\n }\n return result;\n};\n\nconst propTypeAsTypescript = (propType: ReactDescT, propName: string) => {\n const documentation = {\n ...propType.reactDesc,\n name: propName,\n };\n\n documentation.format = propTypeFormat(propType);\n\n return documentation;\n};\n\nexport default function descToTypescript<C>(component: React.ComponentType<C>, reactDesc: ComponentDocumentation) {\n if (!component) {\n throw new Error('react-desc: component is required');\n }\n\n const documentation: TypescriptDocumentation = {\n name: component.displayName || component.name,\n ...reactDesc,\n };\n if (reactDesc) {\n delete documentation.propTypes;\n\n if (reactDesc.propTypes) {\n const propTypes: TypescriptDocumentation['properties'] = [];\n Object.keys(reactDesc.propTypes).forEach((propName) => {\n const propType = reactDesc.propTypes[propName];\n propTypes.push(propTypeAsTypescript(propType, propName));\n });\n if (propTypes.length > 0) {\n documentation.properties = propTypes;\n }\n }\n }\n return documentation;\n}\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADOvB,MAAM,cAAc,CAAC,UAAwB,MAAM,IAAI,CAAC,aAAa,eAAe;AAEpF,MAAM,cAAc,CAAC,UAAsC;AACzD,QAAM,QAAQ,OAAO,KAAK,OAAO,IAAI,CAAC,QAAQ;AAC5C,UAAM,QAAQ,MAAM;AACpB,QAAI;AACJ,QACE,MAAM,QACL,OAAM,SAAS,aAAa,MAAM,SAAS,eAAe,MAAM,SAAS,YAC1E,MAAM,QAAQ,MAAM,OACpB;AACA,oBAAc,GAAG,eAAe;AAAA,eACvB,MAAM,SAAS,SAAS;AACjC,oBAAc,GAAG,eAAe;AAAA,WAC3B;AACL,oBAAc,eAAe;AAAA;AAE/B,WAAO,GAAG,MAAM,MAAM,aAAa,MAAM,UAAU,WAAW,KAAK,QAAQ;AAAA;AAE7E,SAAO,IAAI,MAAM,KAAK;AAAA;AAGxB,MAAM,iBAAiB,CAAC,UAAqC,WAAW,OAAe;AACrF,MAAI;AACJ,MAAI,MAAM,QAAQ,WAAW;AAC3B,aAAS,YAAY,UAAU,KAAK;AAAA,aAC3B,OA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C,kBAAU,KAAK,qBAAqB,UAAU;AAAA;AAEhD,UAAI,UAAU,SAAS,GAAG;AACxB,sBAAc,aAAa;AAAA;AAAA;AAAA;AAIjC,SAAO;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
9
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(module2))
|
|
11
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
12
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return target;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (module2, isNodeMode) => {
|
|
17
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
20
|
+
return (module2, temp) => {
|
|
21
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
22
|
+
};
|
|
23
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
24
|
+
var types_exports = {};
|
|
25
|
+
var React = __toESM(require("react"));
|
|
26
|
+
module.exports = __toCommonJS(types_exports);
|
|
27
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/propTypes/types.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import {\n any,\n array,\n bool,\n func,\n number,\n object,\n string,\n node,\n element,\n symbol,\n elementType,\n instanceOf,\n oneOf,\n oneOfType,\n arrayOf,\n objectOf,\n shape,\n exact,\n ValidationMap,\n} from 'prop-types';\nimport React from 'react';\n\nexport interface ReactDescObjT {\n [key: string]: unknown;\n required?: boolean;\n deprecated?: Record<string, string>;\n description?: string;\n defaultValue?: unknown;\n format?: string;\n warned?: boolean;\n}\n\nexport type InstanceOfT = typeof instanceOf;\nexport type OneOfT = typeof oneOf;\nexport type ObjectOfT = typeof objectOf;\nexport type ExactT = typeof exact;\nexport type OneOfTypeT = typeof oneOfType;\nexport type ArrayOfT = typeof arrayOf;\nexport type ShapeT = typeof shape;\nexport type AnyT = typeof any;\nexport type ArrayT = typeof array;\nexport type BoolT = typeof bool;\nexport type FuncT = typeof func;\nexport type NumberT = typeof number;\nexport type ObjectT = typeof object;\nexport type StringT = typeof string;\nexport type NodeT = typeof node;\nexport type ElementT = typeof element;\nexport type SymbolT = typeof symbol;\nexport type ElementTypeT = typeof elementType;\n\nexport type ParametizedPropTypes = InstanceOfT | OneOfT | ObjectOfT | ExactT | OneOfTypeT | ArrayOfT | ShapeT;\n\nexport type AllPropTypes =\n | AnyT\n | ArrayT\n | BoolT\n | FuncT\n | NumberT\n | ObjectT\n | StringT\n | NodeT\n | ElementT\n | SymbolT\n | ElementTypeT\n | ParametizedPropTypes;\n\nexport type PropTypesTypes =\n | 'any'\n | 'array'\n | 'bool'\n | 'func'\n | 'number'\n | 'object'\n | 'string'\n | 'node'\n | 'element'\n | 'symbol'\n | 'elementType'\n | 'instanceOf'\n | 'oneOf'\n | 'oneOfType'\n | 'arrayOf'\n | 'objectOf'\n | 'shape'\n | 'exact'\n | 'tuple';\n\nexport interface ReactDescT {\n [key: string]: unknown;\n type: PropTypesTypes;\n defaultValue: (this: ReactDescT, dfault: unknown) => ReactDescT;\n deprecated: (this: ReactDescT, info: Record<string, string>) => ReactDescT;\n description: (this: ReactDescT, descr: string) => ReactDescT;\n format: (this: ReactDescT, format: string) => ReactDescT;\n isRequired: ReactDescT;\n reactDesc: ReactDescObjT;\n args?:\n | ReactDescT\n | ReactDescT[]\n | Record<string, ReactDescT>\n | unknown[]\n | Parameters<InstanceOfT>[0]\n | Parameters<OneOfT>[0]\n | Parameters<ObjectOfT>[0]\n | Parameters<ExactT>[0];\n}\n\nexport interface ComponentDocumentation {\n propTypes: Record<string, ReactDescT>;\n availableAt?: unknown;\n description?: unknown;\n details?: unknown;\n deprecated?: unknown;\n usage?: unknown;\n intrinsicElement?: unknown;\n toTypescript?: unknown;\n}\n\nexport interface TypescriptDocumentation extends Partial<ComponentDocumentation> {\n name: string;\n properties?: {\n name: string;\n required?: boolean | undefined;\n deprecated?: Record<string, string> | undefined;\n description?: string | undefined;\n format?: string | undefined;\n warned?: boolean | undefined;\n }[];\n}\n\nexport type DocumentedReactComponent<T> = React.ComponentType<T> & {\n availableAt: unknown;\n description: unknown;\n details: unknown;\n deprecated: unknown;\n usage: unknown;\n intrinsicElement: unknown;\n toTypescript: unknown;\n propTypesValue: ValidationMap<Record<string, unknown>>;\n};\n\nexport type DocumentedPropType = ReactDescT;\n\nexport type PropTypesObj = {\n any: DocumentedPropType;\n array: DocumentedPropType;\n bool: DocumentedPropType;\n func: DocumentedPropType;\n number: DocumentedPropType;\n object: DocumentedPropType;\n string: DocumentedPropType;\n node: DocumentedPropType;\n element: DocumentedPropType;\n symbol: DocumentedPropType;\n elementType: DocumentedPropType;\n instanceOf: (cls: unknown) => DocumentedPropType;\n oneOf: (arr: unknown[]) => DocumentedPropType;\n oneOfType: (arr: DocumentedPropType[]) => DocumentedPropType;\n arrayOf: (smth: DocumentedPropType) => DocumentedPropType;\n objectOf: (smth: DocumentedPropType) => DocumentedPropType;\n shape: (obj: Record<string, DocumentedPropType>) => DocumentedPropType;\n exact: (obj: Record<string, DocumentedPropType>) => DocumentedPropType;\n tuple: (arr: DocumentedPropType[]) => DocumentedPropType;\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA,YAAuB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (module2, isNodeMode) => {
|
|
21
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
+
return (module2, temp) => {
|
|
25
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
+
};
|
|
27
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
+
var TestComponent_exports = {};
|
|
29
|
+
__export(TestComponent_exports, {
|
|
30
|
+
TestComponent: () => TestComponent
|
|
31
|
+
});
|
|
32
|
+
var React = __toESM(require("react"));
|
|
33
|
+
var import_react = __toESM(require("react"));
|
|
34
|
+
var import_globalProps = require("../../globalProps");
|
|
35
|
+
const TestComponent = (props) => {
|
|
36
|
+
const globalAttributes = (0, import_globalProps.useGetGlobalAttributes)(props);
|
|
37
|
+
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
38
|
+
...globalAttributes
|
|
39
|
+
}, "Some random div");
|
|
40
|
+
};
|
|
41
|
+
module.exports = __toCommonJS(TestComponent_exports);
|
|
42
|
+
//# sourceMappingURL=TestComponent.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/tests/globalProps/TestComponent.js", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport { useGetGlobalAttributes } from '../../globalProps';\n\nexport const TestComponent = (props) => {\n const globalAttributes = useGetGlobalAttributes(props);\n\n return <div {...globalAttributes}>Some random div</div>;\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkB;AAClB,yBAAuC;AAEhC,MAAM,gBAAgB,CAAC,UAAU;AACtC,QAAM,mBAAmB,+CAAuB;AAEhD,SAAO,mDAAC,OAAD;AAAA,OAAS;AAAA,KAAkB;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["
|
|
3
|
+
"sources": ["../../../../src/tests/validation/test.schema.js", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["import { PropTypes, describe } from 'react-desc';\n\nconst TestSchema = {\n string: PropTypes.string.description('String'),\n number: PropTypes.number.description('Number'),\n boolean: PropTypes.bool.description('Boolean'),\n any: PropTypes.any.description('Any'),\n union: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description('Union'),\n union2: PropTypes.oneOf(['A', 'B']).description('Union 2'),\n union3: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.arrayOf(PropTypes.string),\n PropTypes.shape({ string: PropTypes.string }),\n ]).description('Union 3'),\n array: PropTypes.arrayOf(PropTypes.string).description('Array'),\n object: PropTypes.object.description('Object'),\n shape: PropTypes.shape({\n string: PropTypes.string.description('String').isRequired,\n number: PropTypes.number.description('Number'),\n boolean: PropTypes.bool.description('Boolean'),\n anotherShape: PropTypes.shape({\n string: PropTypes.string.description('String').isRequired,\n number: PropTypes.number.description('Number'),\n boolean: PropTypes.bool.description('Boolean'),\n }).description('Another shape'),\n }).description('Shape'),\n function: PropTypes.func.description('Function'),\n jsx: PropTypes.element.description('JSX'),\n node: PropTypes.node.description('Node'),\n};\n\nconst TestComponent = () => null;\n\nconst TestComponentWithSchema = describe(TestComponent).description('Test Component');\n\nTestComponentWithSchema.propTypes = TestSchema;\n\nexport const TypescriptSchema = TestComponentWithSchema.toTypescript();\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAAoC;AAEpC,MAAM,aAAa;AAAA,EACjB,QAAQ,4BAAU,OAAO,YAAY;AAAA,EACrC,QAAQ,4BAAU,OAAO,YAAY;AAAA,EACrC,SAAS,4BAAU,KAAK,YAAY;AAAA,EACpC,KAAK,4BAAU,IAAI,YAAY;AAAA,EAC/B,OAAO,4BAAU,UAAU,CAAC,4BAAU,QAAQ,4BAAU,SAAS,YAAY;AAAA,EAC7E,QAAQ,4BAAU,MAAM,CAAC,KAAK,MAAM,YAAY;AAAA,EAChD,QAAQ,4BAAU,UAAU;AAAA,IAC1B,4BAAU;AAAA,IACV,4BAAU,QAAQ,4BAAU;AAAA,IAC5B,4BAAU,MAAM,EAAE,QAAQ,4BAAU;AAAA,KACnC,YAAY;AAAA,EACf,OAAO,4BAAU,QAAQ,4BAAU,QAAQ,YAAY;AAAA,EACvD,QAAQ,4BAAU,OAAO,YAAY;AAAA,EACrC,OAAO,4BAAU,MAAM;AAAA,IACrB,QAAQ,4BAAU,OAAO,YAAY,UAAU;AAAA,IAC/C,QAAQ,4BAAU,OAAO,YAAY;AAAA,IACrC,SAAS,4BAAU,KAAK,YAAY;AAAA,IACpC,cAAc,4BAAU,MAAM;AAAA,MAC5B,QAAQ,4BAAU,OAAO,YAAY,UAAU;AAAA,MAC/C,QAAQ,4BAAU,OAAO,YAAY;AAAA,MACrC,SAAS,4BAAU,KAAK,YAAY;AAAA,OACnC,YAAY;AAAA,KACd,YAAY;AAAA,EACf,UAAU,4BAAU,KAAK,YAAY;AAAA,EACrC,KAAK,4BAAU,QAAQ,YAAY;AAAA,EACnC,MAAM,4BAAU,KAAK,YAAY;AAAA;AAGnC,MAAM,gBAAgB,MAAM;AAE5B,MAAM,0BAA0B,gCAAS,eAAe,YAAY;AAEpE,wBAAwB,YAAY;AAE7B,MAAM,mBAAmB,wBAAwB;",
|
|
6
6
|
"names": []
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -31,8 +31,8 @@ __export(typescriptValidator_exports, {
|
|
|
31
31
|
validateTypescriptPropTypesImplementation: () => validateTypescriptPropTypesImplementation
|
|
32
32
|
});
|
|
33
33
|
var React = __toESM(require("react"));
|
|
34
|
-
var import_react_desc = require("react-desc");
|
|
35
34
|
var import_react = require("react");
|
|
35
|
+
var import_propTypes = require("../propTypes");
|
|
36
36
|
var import_errorTemplates = require("./errorTemplates");
|
|
37
37
|
var import_typescriptGuards = require("./typescriptGuards");
|
|
38
38
|
var import_typescriptParsers = require("./typescriptParsers");
|
|
@@ -158,7 +158,7 @@ const useValidateTypescriptPropTypes = (props, propTypes) => {
|
|
|
158
158
|
const ComponentWithSchema = (0, import_react.useMemo)(() => {
|
|
159
159
|
const Component = () => {
|
|
160
160
|
};
|
|
161
|
-
return (0,
|
|
161
|
+
return (0, import_propTypes.describe)(Component);
|
|
162
162
|
}, []);
|
|
163
163
|
ComponentWithSchema.propTypes = propTypes;
|
|
164
164
|
(0, import_react.useMemo)(() => {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/validation/typescriptValidator.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable complexity */\n/* eslint-disable max-lines */\n/* eslint-disable max-params */\nimport React, { PropsWithChildren, useMemo, useState } from 'react';\nimport { describe } from '../propTypes';\nimport { throwRequiredError, throwTypeError } from './errorTemplates';\nimport {\n isArray,\n isFunction,\n isJSXorNode,\n isObject,\n isPrimitiveType,\n isSomethingWithParenthesis,\n isString,\n isUnion,\n isUndefined,\n isNull,\n} from './typescriptGuards';\nimport { typescriptObjectParser } from './typescriptParsers';\n\ninterface TypescriptSchema {\n description: string;\n name: string;\n properties: { name: string; description: string; defaultValue?: unknown; format: string; required?: boolean }[];\n}\n\ntype ValidatorFn = (\n schemaName: string,\n key: string,\n value: unknown,\n format: string,\n validationsMemo: Record<symbol, string>,\n nextValidationsMemo: Record<symbol, string>,\n) => void;\n\n// =============================================================================\n// Atom Validators\n// =============================================================================\n\n// This functions will validate something from the data\n// and optionally recursively apply `validateValueWithFormat`\n// in smaller parts\n\nconst validateUndefined: ValidatorFn = (schemaName, key, value, format) => {\n if (value !== undefined || value === 'undefined') {\n throwTypeError(schemaName, key, value, format);\n }\n};\nconst validateNull: ValidatorFn = (schemaName, key, value, format) => {\n if (value !== null || value === 'null') {\n throwTypeError(schemaName, key, value, format);\n }\n};\nconst validatePrimitiveType: ValidatorFn = (schemaName, key, value, format) => {\n if (typeof value !== format) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nconst validateString: ValidatorFn = (schemaName, key, value, format) => {\n if (value !== format.slice(1, -1)) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nconst validateArray: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n // Check that we have an array\n if (!Array.isArray(value)) {\n throwTypeError(schemaName, key, value, format);\n }\n\n // Check that each element inside satisfies the format\n (value as unknown[]).forEach((val, index) => {\n // this is a recursive func, we need to invoke it before it's defined.\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n validateValueWithFormat(\n schemaName,\n `${key}[${index}]`,\n val,\n format.slice(0, -2),\n validationsMemo,\n nextValidationsMemo,\n );\n });\n};\nfunction isObjectType(value: unknown | Record<string, unknown>): value is Record<string, unknown> {\n return !(typeof value !== 'object' || Array.isArray(value));\n}\nconst validateObject: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n const valuesIsObject = isObjectType(value);\n // Check that we have an object\n if (!valuesIsObject) {\n throwTypeError(schemaName, key, value, format);\n return;\n }\n\n if (format === 'object') return;\n\n const keyValuePairs = typescriptObjectParser(format);\n // Now we have the key - value pairs\n // Each key could either be required or not\n // Just recursively check the object\n\n keyValuePairs.forEach(([objectKey, objectValue]) => {\n const trueKey = objectKey.slice(-1) === '?' ? objectKey.slice(0, -1) : objectKey;\n\n if (trueKey === objectKey && !(trueKey in value)) {\n throwRequiredError(schemaName, key);\n }\n\n if (trueKey in value) {\n // this is a recursive func, we need to invoke it before it's defined.\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n validateValueWithFormat(\n schemaName,\n `${key}[${trueKey}]`,\n value[trueKey],\n objectValue,\n validationsMemo,\n nextValidationsMemo,\n );\n }\n });\n};\n\nconst validateUnion: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n const possibilities = format.split(/\\s?\\|\\s?/);\n\n const errors = [];\n\n possibilities.forEach((possibility) => {\n try {\n // this is a recursive func, we need to invoke it before it's defined.\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n validateValueWithFormat(schemaName, key, value, possibility, validationsMemo, nextValidationsMemo);\n } catch (e) {\n errors.push(e);\n }\n });\n\n if (errors.length === possibilities.length) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nconst validateFunction: ValidatorFn = (schemaName, key, value, format) => {\n // Check that we have a function\n if (typeof value !== 'function') {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nfunction isJSXElement(value: unknown | JSX.Element): value is JSX.Element {\n return value === null || (typeof value === 'object' && value !== null && '$$typeof' in value);\n}\nconst validateJSXorNode: ValidatorFn = (schemaName, key, value, format) => {\n const valueIsJSX = isJSXElement(value);\n if (format === 'JSX.Element' && !valueIsJSX) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\n// =============================================================================\n// Schema validator\n// =============================================================================\n\nconst validateValueWithFormat: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n nextValidationsMemo[value as symbol] = format;\n\n if ((value as symbol) in validationsMemo) {\n // We already validated this value on this format\n return;\n }\n\n if (isUndefined(format)) {\n validateUndefined(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isNull(format)) {\n validateNull(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isPrimitiveType(format)) {\n validatePrimitiveType(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isUnion(format)) {\n validateUnion(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isString(format)) {\n validateString(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isArray(format)) {\n validateArray(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isObject(format)) {\n validateObject(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isFunction(format)) {\n validateFunction(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isJSXorNode(format)) {\n validateJSXorNode(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isSomethingWithParenthesis(format)) {\n validateValueWithFormat(schemaName, key, value, format.slice(1, -1), validationsMemo, nextValidationsMemo);\n }\n};\n\nexport const validateTypescriptPropTypesImplementation = (\n props: PropsWithChildren<Record<string, unknown>>,\n schema: TypescriptSchema,\n validationsMemo: Record<string, string> = {},\n nextValidationsMemo: Record<string, string> = {},\n): void => {\n const { properties, name: schemaName } = schema;\n\n properties.forEach((property) => {\n const { name, format, required } = property;\n\n if (required && !(name in props)) {\n throwRequiredError(schema.name, name);\n }\n\n if (name in props && (props[name] !== undefined || required)) {\n validateValueWithFormat(schemaName, name, props[name], format, validationsMemo, nextValidationsMemo);\n }\n });\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const useValidateTypescriptPropTypes = <T = Record<string, any>>(\n props: PropsWithChildren<T>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n propTypes: any,\n): void => {\n const [validationsMemo, setValidationsMemo] = useState({});\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const ComponentWithSchema = useMemo(() => {\n const Component = () => {};\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call\n return describe(Component);\n }, []);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment\n ComponentWithSchema.propTypes = propTypes;\n\n useMemo(() => {\n const nextValidationsMemo = {};\n\n validateTypescriptPropTypesImplementation(\n props,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n ComponentWithSchema.toTypescript(),\n validationsMemo,\n nextValidationsMemo,\n );\n\n setValidationsMemo(nextValidationsMemo);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [props]);\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,mBAA4D;AAC5D,uBAAyB;AACzB,4BAAmD;AACnD,8BAWO;AACP,+BAAuC;AAyBvC,MAAM,oBAAiC,CAAC,YAAY,KAAK,OAAO,WAAW;AACzE,MAAI,UAAU,UAAa,UAAU,aAAa;AAChD,8CAAe,YAAY,KAAK,OAAO;AAAA;AAAA;AAG3C,MAAM,eAA4B,CAAC,YAAY,KAAK,OAAO,WAAW;AACpE,MAAI,UAAU,QAAQ,UAAU,QAAQ;AACtC,8CAAe,YAAY,KAAK,OAAO;AAAA;AAAA;AAG3C,MAAM,wBAAqC,CAAC,YAAY,KAAK,OAAO,WAAW;AAC7E,MAAI,OAAO,UAAU,QAAQ;AAC3B,8CAAe,YAAY,KAAK,OAAO;AAAA;AAAA;AAI3C,MAAM,iBAA8B,CAAC,YAAY,KAAK,OAAO,WAAW;AACtE,MAAI,UAAU,OAAO,MAAM,GAAG,KAAK;AACjC,8CAAe,YAAY,KAAK,OAAO;AAAA;AAAA;AAI3C,MAAM,gBAA6B,CAAC,YAAY,KAAK,OAAO,QAAQ,iBAAiB,wBAAwB;AAE3G,MAAI,CAAC,MAAM,QAAQ,QAAQ;AACzB,8CAAe,YAAY,KAAK,OAAO;AAAA;AAIzC,EAAC,MAAoB,QAAQ,CAAC,KAAK,UAAU;AAG3C,4BACE,YACA,GAAG,OAAO,UACV,KACA,OAAO,MAAM,GAAG,KAChB,iBACA;AAAA;AAAA;AAIN,sBAAsB,OAA4E;AAChG,SAAO,CAAE,QAAO,UAAU,YA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AAwB,YAAY,MAAM,MAAM,OAAO,QAAQ,iBAAiB;AAAA;AAAA;AAAA;AAM/E,MAAM,iCAAiC,CAC5C,OAEA,cACS;AACT,QAAM,CAAC,iBAAiB,sBAAsB,2BAAS;AAGvD,QAAM,sBAAsB,0BAAQ,MAAM;AACxC,UAAM,YAAY,MAAM;AAAA;AAGxB,WAAO,+BAAS;AAAA,KACf;AAGH,sBAAoB,YAAY;AAEhC,4BAAQ,MAAM;AACZ,UAAM,sBAAsB;AAE5B,8CACE,OAEA,oBAAoB,gBACpB,iBACA;AAGF,uBAAmB;AAAA,KAElB,CAAC;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|