@elliemae/ds-props-helpers 2.2.0 → 2.3.0-alpha.3
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 +28 -9
- package/cjs/defaultProps/index.js.map +7 -0
- package/cjs/defaultProps/useMemoMergePropsWithDefault.js +44 -44
- package/cjs/defaultProps/useMemoMergePropsWithDefault.js.map +7 -0
- package/cjs/getProps/index.js +37 -20
- package/cjs/getProps/index.js.map +7 -0
- package/cjs/globalProps/constants.js +398 -0
- package/cjs/globalProps/constants.js.map +7 -0
- package/cjs/globalProps/globalAttributesPropTypes.js +398 -0
- package/cjs/globalProps/globalAttributesPropTypes.js.map +7 -0
- package/cjs/globalProps/index.js +29 -0
- package/cjs/globalProps/index.js.map +7 -0
- package/cjs/globalProps/useGetGlobalAttributes.js +56 -0
- package/cjs/globalProps/useGetGlobalAttributes.js.map +7 -0
- package/cjs/index.js +32 -20
- package/cjs/index.js.map +7 -0
- package/cjs/propTypes/PropTypes.js +136 -0
- package/cjs/propTypes/PropTypes.js.map +7 -0
- package/cjs/propTypes/customPropTypes.js +38 -0
- package/cjs/propTypes/customPropTypes.js.map +7 -0
- package/cjs/propTypes/describe.js +81 -0
- package/cjs/propTypes/describe.js.map +7 -0
- package/cjs/propTypes/describeConversions.js +96 -0
- package/cjs/propTypes/describeConversions.js.map +7 -0
- package/cjs/propTypes/describeGuards.js +49 -0
- package/cjs/propTypes/describeGuards.js.map +7 -0
- package/cjs/propTypes/index.js +37 -0
- package/cjs/propTypes/index.js.map +7 -0
- package/cjs/propTypes/toTypescript.js +139 -0
- package/cjs/propTypes/toTypescript.js.map +7 -0
- package/cjs/propTypes/types.js +27 -0
- package/cjs/propTypes/types.js.map +7 -0
- package/cjs/tests/globalProps/TestComponent.js +42 -0
- package/cjs/tests/globalProps/TestComponent.js.map +7 -0
- package/cjs/tests/validation/test.schema.js +67 -0
- package/cjs/tests/validation/test.schema.js.map +7 -0
- package/cjs/validation/errorTemplates.js +44 -12
- package/cjs/validation/errorTemplates.js.map +7 -0
- package/cjs/validation/index.js +30 -15
- package/cjs/validation/index.js.map +7 -0
- package/cjs/validation/typescriptGuards.js +60 -31
- package/cjs/validation/typescriptGuards.js.map +7 -0
- package/cjs/validation/typescriptParsers.js +65 -34
- package/cjs/validation/typescriptParsers.js.map +7 -0
- package/cjs/validation/typescriptValidator.js +99 -135
- package/cjs/validation/typescriptValidator.js.map +7 -0
- package/cjs/validation/validator.js +43 -24
- package/cjs/validation/validator.js.map +7 -0
- package/esm/defaultProps/index.js +3 -1
- package/esm/defaultProps/index.js.map +7 -0
- package/esm/defaultProps/useMemoMergePropsWithDefault.js +14 -34
- package/esm/defaultProps/useMemoMergePropsWithDefault.js.map +7 -0
- package/esm/getProps/index.js +8 -15
- package/esm/getProps/index.js.map +7 -0
- package/esm/globalProps/constants.js +369 -0
- package/esm/globalProps/constants.js.map +7 -0
- package/esm/globalProps/globalAttributesPropTypes.js +369 -0
- package/esm/globalProps/globalAttributesPropTypes.js.map +7 -0
- package/esm/globalProps/index.js +4 -0
- package/esm/globalProps/index.js.map +7 -0
- package/esm/globalProps/useGetGlobalAttributes.js +27 -0
- package/esm/globalProps/useGetGlobalAttributes.js.map +7 -0
- package/esm/index.js +7 -5
- package/esm/index.js.map +7 -0
- package/esm/propTypes/PropTypes.js +107 -0
- package/esm/propTypes/PropTypes.js.map +7 -0
- package/esm/propTypes/customPropTypes.js +9 -0
- package/esm/propTypes/customPropTypes.js.map +7 -0
- package/esm/propTypes/describe.js +52 -0
- package/esm/propTypes/describe.js.map +7 -0
- package/esm/propTypes/describeConversions.js +76 -0
- package/esm/propTypes/describeConversions.js.map +7 -0
- package/esm/propTypes/describeGuards.js +20 -0
- package/esm/propTypes/describeGuards.js.map +7 -0
- package/esm/propTypes/index.js +8 -0
- package/esm/propTypes/index.js.map +7 -0
- package/esm/propTypes/toTypescript.js +110 -0
- package/esm/propTypes/toTypescript.js.map +7 -0
- package/esm/propTypes/types.js +2 -0
- package/esm/propTypes/types.js.map +7 -0
- package/esm/tests/globalProps/TestComponent.js +13 -0
- package/esm/tests/globalProps/TestComponent.js.map +7 -0
- package/esm/tests/validation/test.schema.js +38 -0
- package/esm/tests/validation/test.schema.js.map +7 -0
- package/esm/validation/errorTemplates.js +15 -7
- package/esm/validation/errorTemplates.js.map +7 -0
- package/esm/validation/index.js +5 -3
- package/esm/validation/index.js.map +7 -0
- package/esm/validation/typescriptGuards.js +31 -18
- package/esm/validation/typescriptGuards.js.map +7 -0
- package/esm/validation/typescriptParsers.js +36 -30
- package/esm/validation/typescriptParsers.js.map +7 -0
- package/esm/validation/typescriptValidator.js +57 -106
- package/esm/validation/typescriptValidator.js.map +7 -0
- package/esm/validation/validator.js +12 -18
- package/esm/validation/validator.js.map +7 -0
- package/package.json +56 -4
- 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 +5 -0
- package/types/index.d.ts +2 -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 +96 -0
- package/types/tests/globalProps/TestComponent.d.ts +1 -0
- package/types/tests/{any.validation.test.d.ts → globalProps/globalAttributes.test.d.ts} +0 -0
- package/types/tests/{array.validation.test.d.ts → validation/any.validation.test.d.ts} +0 -0
- package/types/tests/{boolean.validation.test.d.ts → validation/array.validation.test.d.ts} +0 -0
- package/types/tests/{function.validation.test.d.ts → validation/boolean.validation.test.d.ts} +0 -0
- package/types/tests/{number.validation.test.d.ts → validation/function.validation.test.d.ts} +0 -0
- package/types/tests/{object.validation.test.d.ts → validation/number.validation.test.d.ts} +0 -0
- package/types/tests/{schema.validation.test.d.ts → validation/object.validation.test.d.ts} +0 -0
- package/types/tests/{string.validation.test.d.ts → validation/schema.validation.test.d.ts} +0 -0
- package/types/tests/{union.validation.test.d.ts → validation/string.validation.test.d.ts} +0 -0
- package/types/tests/{test.schema.d.ts → validation/test.schema.d.ts} +0 -0
- package/types/tests/validation/union.validation.test.d.ts +1 -0
- package/types/validation/typescriptValidator.d.ts +2 -2
|
@@ -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,OAAO,aAAa,cAAc,SAAS,MAAM;AAC1D,YAAQ,SAAS;AAAA,WACV;AACH,iBAAS;AACT;AAAA,WACG;AACH,YAAK,SAAS,KAAoB,SAAS,aAAa;AACtD,mBAAS,IAAI,eAAe,SAAS,MAAoB;AAAA,eACpD;AACL,mBAAS,GAAG,eAAe,SAAS,MAAoB;AAAA;AAE1D;AAAA,WACG;AACH,iBAAS,IAAI,eAAe,SAAS,MAAoB;AACzD;AAAA,WACG;AACH,iBAAS;AACT;AAAA,WACG;AACH,iBAAS;AACT;AAAA,WACG;AACH,iBAAS;AACT;AAAA,WACG;AACH,iBAAS;AACT;AAAA,WACG;AACH,iBAAS;AACT;AAAA,WACG;AACH,iBAAS;AACT;AAAA,WACG;AACH,iBAAS,oBAAoB,eAAe,SAAS;AACrD;AAAA,WACG;AACH,iBAAU,SAAS,KAAmB,IAAI,CAAC,MAAM,IAAI,MAAM,KAAK;AAChE;AAAA,WACG;AACH,iBAAS,GAAG,eAAe,SAAS,MAAsB;AAC1D;AAAA,WACG;AACH,iBAAS,GAAG,YAAY,SAAS;AACjC;AAAA;AAEA,iBAAS,GAAG,SAAS;AACrB;AAAA;AAAA,SAEC;AACL,aAAS;AAAA;AAEX,SAAO;AAAA;AAGT,MAAM,uBAAuB,CAAC,UAAsB,aAAqB;AACvE,QAAM,gBAAgB;AAAA,OACjB,SAAS;AAAA,IACZ,MAAM;AAAA;AAGR,gBAAc,SAAS,eAAe;AAEtC,SAAO;AAAA;AAGM,0BAA6B,WAAmC,WAAmC;AAChH,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM;AAAA;AAGlB,QAAM,gBAAyC;AAAA,IAC7C,MAAM,UAAU,eAAe,UAAU;AAAA,OACtC;AAAA;AAEL,MAAI,WAAW;AACb,WAAO,cAAc;AAErB,QAAI,UAAU,WAAW;AACvB,YAAM,YAAmD;AACzD,aAAO,KAAK,UAAU,WAAW,QAAQ,CAAC,aAAa;AACrD,cAAM,WAAW,UAAU,UAAU;AACrC,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
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
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 test_schema_exports = {};
|
|
29
|
+
__export(test_schema_exports, {
|
|
30
|
+
TypescriptSchema: () => TypescriptSchema
|
|
31
|
+
});
|
|
32
|
+
var React = __toESM(require("react"));
|
|
33
|
+
var import_react_desc = require("react-desc");
|
|
34
|
+
const TestSchema = {
|
|
35
|
+
string: import_react_desc.PropTypes.string.description("String"),
|
|
36
|
+
number: import_react_desc.PropTypes.number.description("Number"),
|
|
37
|
+
boolean: import_react_desc.PropTypes.bool.description("Boolean"),
|
|
38
|
+
any: import_react_desc.PropTypes.any.description("Any"),
|
|
39
|
+
union: import_react_desc.PropTypes.oneOfType([import_react_desc.PropTypes.string, import_react_desc.PropTypes.number]).description("Union"),
|
|
40
|
+
union2: import_react_desc.PropTypes.oneOf(["A", "B"]).description("Union 2"),
|
|
41
|
+
union3: import_react_desc.PropTypes.oneOfType([
|
|
42
|
+
import_react_desc.PropTypes.string,
|
|
43
|
+
import_react_desc.PropTypes.arrayOf(import_react_desc.PropTypes.string),
|
|
44
|
+
import_react_desc.PropTypes.shape({ string: import_react_desc.PropTypes.string })
|
|
45
|
+
]).description("Union 3"),
|
|
46
|
+
array: import_react_desc.PropTypes.arrayOf(import_react_desc.PropTypes.string).description("Array"),
|
|
47
|
+
object: import_react_desc.PropTypes.object.description("Object"),
|
|
48
|
+
shape: import_react_desc.PropTypes.shape({
|
|
49
|
+
string: import_react_desc.PropTypes.string.description("String").isRequired,
|
|
50
|
+
number: import_react_desc.PropTypes.number.description("Number"),
|
|
51
|
+
boolean: import_react_desc.PropTypes.bool.description("Boolean"),
|
|
52
|
+
anotherShape: import_react_desc.PropTypes.shape({
|
|
53
|
+
string: import_react_desc.PropTypes.string.description("String").isRequired,
|
|
54
|
+
number: import_react_desc.PropTypes.number.description("Number"),
|
|
55
|
+
boolean: import_react_desc.PropTypes.bool.description("Boolean")
|
|
56
|
+
}).description("Another shape")
|
|
57
|
+
}).description("Shape"),
|
|
58
|
+
function: import_react_desc.PropTypes.func.description("Function"),
|
|
59
|
+
jsx: import_react_desc.PropTypes.element.description("JSX"),
|
|
60
|
+
node: import_react_desc.PropTypes.node.description("Node")
|
|
61
|
+
};
|
|
62
|
+
const TestComponent = () => null;
|
|
63
|
+
const TestComponentWithSchema = (0, import_react_desc.describe)(TestComponent).description("Test Component");
|
|
64
|
+
TestComponentWithSchema.propTypes = TestSchema;
|
|
65
|
+
const TypescriptSchema = TestComponentWithSchema.toTypescript();
|
|
66
|
+
module.exports = __toCommonJS(test_schema_exports);
|
|
67
|
+
//# sourceMappingURL=test.schema.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/tests/validation/test.schema.js", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
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
|
+
"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
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,16 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 errorTemplates_exports = {};
|
|
29
|
+
__export(errorTemplates_exports, {
|
|
30
|
+
throwRequiredError: () => throwRequiredError,
|
|
31
|
+
throwTypeError: () => throwTypeError
|
|
32
|
+
});
|
|
33
|
+
var React = __toESM(require("react"));
|
|
8
34
|
const throwTypeError = (componentName, validPropKey, invalidProp, validFormat) => {
|
|
9
|
-
throw new Error(
|
|
35
|
+
throw new Error(`${componentName}:: You are trying to pass a not valid "${validPropKey}" property,
|
|
36
|
+
please provide a valid type.
|
|
37
|
+
|
|
38
|
+
Received: ${invalidProp} (${typeof invalidProp})
|
|
39
|
+
Expected: (${validFormat.replace("\n", " or ")})
|
|
40
|
+
`);
|
|
10
41
|
};
|
|
11
42
|
const throwRequiredError = (componentName, validPropKey) => {
|
|
12
|
-
throw new Error(
|
|
43
|
+
throw new Error(`${componentName}:: Please provide a/an "${validPropKey}" property to use this component.
|
|
44
|
+
This property is required.
|
|
45
|
+
`);
|
|
13
46
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
exports.throwTypeError = throwTypeError;
|
|
47
|
+
module.exports = __toCommonJS(errorTemplates_exports);
|
|
48
|
+
//# sourceMappingURL=errorTemplates.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/validation/errorTemplates.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-params */\nexport const throwTypeError = (\n componentName: string,\n validPropKey: string,\n invalidProp: unknown,\n validFormat: string,\n): void => {\n throw new Error(\n `${componentName}:: You are trying to pass a not valid \"${validPropKey}\" property, \n please provide a valid type.\n\n Received: ${invalidProp} (${typeof invalidProp})\n Expected: (${validFormat.replace('\\n', ' or ')})\n `,\n );\n};\n\nexport const throwRequiredError = (componentName: string, validPropKey: string): void => {\n throw new Error(\n `${componentName}:: Please provide a/an \"${validPropKey}\" property to use this component. \n This property is required.\n `,\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADChB,MAAM,iBAAiB,CAC5B,eACA,cACA,aACA,gBACS;AACT,QAAM,IAAI,MACR,GAAG,uDAAuD;AAAA;AAAA;AAAA,cAGhD,gBAAgB,OAAO;AAAA,eACtB,YAAY,QAAQ,MAAM;AAAA;AAAA;AAKlC,MAAM,qBAAqB,CAAC,eAAuB,iBAA+B;AACvF,QAAM,IAAI,MACR,GAAG,wCAAwC;AAAA;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/cjs/validation/index.js
CHANGED
|
@@ -1,15 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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 validation_exports = {};
|
|
25
|
+
var React = __toESM(require("react"));
|
|
26
|
+
__reExport(validation_exports, require("./validator"));
|
|
27
|
+
__reExport(validation_exports, require("./errorTemplates"));
|
|
28
|
+
__reExport(validation_exports, require("./typescriptValidator"));
|
|
29
|
+
module.exports = __toCommonJS(validation_exports);
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/validation/index.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["export * from './validator';\nexport * from './errorTemplates';\nexport * from './typescriptValidator';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA,YAAuB;ADAvB,+BAAc;AACd,+BAAc;AACd,+BAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,36 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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 typescriptGuards_exports = {};
|
|
29
|
+
__export(typescriptGuards_exports, {
|
|
30
|
+
isArray: () => isArray,
|
|
31
|
+
isFunction: () => isFunction,
|
|
32
|
+
isJSXorNode: () => isJSXorNode,
|
|
33
|
+
isNull: () => isNull,
|
|
34
|
+
isObject: () => isObject,
|
|
35
|
+
isPrimitiveType: () => isPrimitiveType,
|
|
36
|
+
isSomethingWithParenthesis: () => isSomethingWithParenthesis,
|
|
37
|
+
isString: () => isString,
|
|
38
|
+
isUndefined: () => isUndefined,
|
|
39
|
+
isUnion: () => isUnion
|
|
40
|
+
});
|
|
41
|
+
var React = __toESM(require("react"));
|
|
42
|
+
const isPrimitiveType = (format) => ["string", "number", "boolean"].includes(format);
|
|
43
|
+
const isUndefined = (format) => format === '"undefined"';
|
|
44
|
+
const isNull = (format) => format === '"null"';
|
|
45
|
+
const isUnion = (format) => {
|
|
13
46
|
let depth = 0;
|
|
14
47
|
let satisfies = false;
|
|
15
|
-
format.split(
|
|
16
|
-
if ([
|
|
48
|
+
format.split("").forEach((char) => {
|
|
49
|
+
if (["{", "("].includes(char))
|
|
50
|
+
depth += 1;
|
|
51
|
+
else if (["}", ")"].includes(char))
|
|
52
|
+
depth -= 1;
|
|
53
|
+
else if (char === "|" && depth === 0)
|
|
54
|
+
satisfies = true;
|
|
17
55
|
});
|
|
18
56
|
return satisfies;
|
|
19
57
|
};
|
|
20
|
-
const isString = format => !isUnion(format) && format[0] === '"' && format.slice(-1) === '"';
|
|
21
|
-
const isArray = format => !isUnion(format) && format.slice(-2) ===
|
|
22
|
-
const isObject = format => format ===
|
|
23
|
-
const isFunction = format => !isUnion(format) && format ===
|
|
24
|
-
const isJSXorNode = format => !isUnion(format) && [
|
|
25
|
-
const isSomethingWithParenthesis = format => !isUnion(format) && format[0] ===
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
exports.isFunction = isFunction;
|
|
29
|
-
exports.isJSXorNode = isJSXorNode;
|
|
30
|
-
exports.isNull = isNull;
|
|
31
|
-
exports.isObject = isObject;
|
|
32
|
-
exports.isPrimitiveType = isPrimitiveType;
|
|
33
|
-
exports.isSomethingWithParenthesis = isSomethingWithParenthesis;
|
|
34
|
-
exports.isString = isString;
|
|
35
|
-
exports.isUndefined = isUndefined;
|
|
36
|
-
exports.isUnion = isUnion;
|
|
58
|
+
const isString = (format) => !isUnion(format) && format[0] === '"' && format.slice(-1) === '"';
|
|
59
|
+
const isArray = (format) => !isUnion(format) && format.slice(-2) === "[]";
|
|
60
|
+
const isObject = (format) => format === "object" || !isUnion(format) && format[0] === "{" && format.slice(-1) === "}";
|
|
61
|
+
const isFunction = (format) => !isUnion(format) && format === "((...args: any[]) => any)";
|
|
62
|
+
const isJSXorNode = (format) => !isUnion(format) && ["React.ReactNode", "JSX.Element"].includes(format);
|
|
63
|
+
const isSomethingWithParenthesis = (format) => !isUnion(format) && format[0] === "(" && format.slice(-1) === ")";
|
|
64
|
+
module.exports = __toCommonJS(typescriptGuards_exports);
|
|
65
|
+
//# sourceMappingURL=typescriptGuards.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/validation/typescriptGuards.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["type GuardFn = (format: string) => boolean;\n\nexport const isPrimitiveType: GuardFn = (format) => ['string', 'number', 'boolean'].includes(format);\nexport const isUndefined: GuardFn = (format) => format === '\"undefined\"';\nexport const isNull: GuardFn = (format) => format === '\"null\"';\nexport const isUnion: GuardFn = (format) => {\n let depth = 0;\n let satisfies = false;\n format.split('').forEach((char) => {\n if (['{', '('].includes(char)) depth += 1;\n else if (['}', ')'].includes(char)) depth -= 1;\n else if (char === '|' && depth === 0) satisfies = true;\n });\n return satisfies;\n};\n\nexport const isString: GuardFn = (format) => !isUnion(format) && format[0] === '\"' && format.slice(-1) === '\"';\n\nexport const isArray: GuardFn = (format) => !isUnion(format) && format.slice(-2) === '[]';\n\nexport const isObject: GuardFn = (format) =>\n format === 'object' || (!isUnion(format) && format[0] === '{' && format.slice(-1) === '}');\n\nexport const isFunction: GuardFn = (format) => !isUnion(format) && format === '((...args: any[]) => any)';\n\nexport const isJSXorNode: GuardFn = (format) => !isUnion(format) && ['React.ReactNode', 'JSX.Element'].includes(format);\n\nexport const isSomethingWithParenthesis: GuardFn = (format) =>\n !isUnion(format) && format[0] === '(' && format.slice(-1) === ')';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEhB,MAAM,kBAA2B,CAAC,WAAW,CAAC,UAAU,UAAU,WAAW,SAAS;AACtF,MAAM,cAAuB,CAAC,WAAW,WAAW;AACpD,MAAM,SAAkB,CAAC,WAAW,WAAW;AAC/C,MAAM,UAAmB,CAAC,WAAW;AAC1C,MAAI,QAAQ;AACZ,MAAI,YAAY;AAChB,SAAO,MAAM,IAAI,QAAQ,CAAC,SAAS;AACjC,QAAI,CAAC,KAAK,KAAK,SAAS;AAAO,eAAS;AAAA,aAC/B,CAAC,KAAK,KAAK,SAAS;AAAO,eAAS;AAAA,aACpC,SAAS,OAAO,UAAU;AAAG,kBAAY;AAAA;AAEpD,SAAO;AAAA;AAGF,MAAM,WAAoB,CAAC,WAAW,CAAC,QAAQ,WAAW,OAAO,OAAO,OAAO,OAAO,MAAM,QAAQ;AAEpG,MAAM,UAAmB,CAAC,WAAW,CAAC,QAAQ,WAAW,OAAO,MAAM,QAAQ;AAE9E,MAAM,WAAoB,CAAC,WAChC,WAAW,YAAa,CAAC,QAAQ,WAAW,OAAO,OAAO,OAAO,OAAO,MAAM,QAAQ;AAEjF,MAAM,aAAsB,CAAC,WAAW,CAAC,QAAQ,WAAW,WAAW;AAEvE,MAAM,cAAuB,CAAC,WAAW,CAAC,QAAQ,WAAW,CAAC,mBAAmB,eAAe,SAAS;AAEzG,MAAM,6BAAsC,CAAC,WAClD,CAAC,QAAQ,WAAW,OAAO,OAAO,OAAO,OAAO,MAAM,QAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|