@elliemae/ds-props-helpers 2.3.0-alpha.2 → 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.
Files changed (90) hide show
  1. package/cjs/globalProps/constants.js +398 -0
  2. package/cjs/globalProps/constants.js.map +7 -0
  3. package/cjs/globalProps/globalAttributesPropTypes.js +398 -0
  4. package/cjs/globalProps/globalAttributesPropTypes.js.map +7 -0
  5. package/cjs/globalProps/index.js +29 -0
  6. package/cjs/globalProps/index.js.map +7 -0
  7. package/cjs/globalProps/useGetGlobalAttributes.js +56 -0
  8. package/cjs/globalProps/useGetGlobalAttributes.js.map +7 -0
  9. package/cjs/index.js +2 -0
  10. package/cjs/index.js.map +2 -2
  11. package/cjs/propTypes/PropTypes.js +136 -0
  12. package/cjs/propTypes/PropTypes.js.map +7 -0
  13. package/cjs/propTypes/customPropTypes.js +38 -0
  14. package/cjs/propTypes/customPropTypes.js.map +7 -0
  15. package/cjs/propTypes/describe.js +81 -0
  16. package/cjs/propTypes/describe.js.map +7 -0
  17. package/cjs/propTypes/describeConversions.js +96 -0
  18. package/cjs/propTypes/describeConversions.js.map +7 -0
  19. package/cjs/propTypes/describeGuards.js +49 -0
  20. package/cjs/propTypes/describeGuards.js.map +7 -0
  21. package/cjs/propTypes/index.js +37 -0
  22. package/cjs/propTypes/index.js.map +7 -0
  23. package/cjs/propTypes/toTypescript.js +139 -0
  24. package/cjs/propTypes/toTypescript.js.map +7 -0
  25. package/cjs/propTypes/types.js +27 -0
  26. package/cjs/propTypes/types.js.map +7 -0
  27. package/cjs/tests/globalProps/TestComponent.js +42 -0
  28. package/cjs/tests/globalProps/TestComponent.js.map +7 -0
  29. package/cjs/tests/{test.schema.js → validation/test.schema.js} +0 -0
  30. package/cjs/tests/{test.schema.js.map → validation/test.schema.js.map} +1 -1
  31. package/cjs/validation/typescriptValidator.js +2 -2
  32. package/cjs/validation/typescriptValidator.js.map +2 -2
  33. package/esm/globalProps/constants.js +369 -0
  34. package/esm/globalProps/constants.js.map +7 -0
  35. package/esm/globalProps/globalAttributesPropTypes.js +369 -0
  36. package/esm/globalProps/globalAttributesPropTypes.js.map +7 -0
  37. package/esm/globalProps/index.js +4 -0
  38. package/esm/globalProps/index.js.map +7 -0
  39. package/esm/globalProps/useGetGlobalAttributes.js +27 -0
  40. package/esm/globalProps/useGetGlobalAttributes.js.map +7 -0
  41. package/esm/index.js +2 -0
  42. package/esm/index.js.map +2 -2
  43. package/esm/propTypes/PropTypes.js +107 -0
  44. package/esm/propTypes/PropTypes.js.map +7 -0
  45. package/esm/propTypes/customPropTypes.js +9 -0
  46. package/esm/propTypes/customPropTypes.js.map +7 -0
  47. package/esm/propTypes/describe.js +52 -0
  48. package/esm/propTypes/describe.js.map +7 -0
  49. package/esm/propTypes/describeConversions.js +76 -0
  50. package/esm/propTypes/describeConversions.js.map +7 -0
  51. package/esm/propTypes/describeGuards.js +20 -0
  52. package/esm/propTypes/describeGuards.js.map +7 -0
  53. package/esm/propTypes/index.js +8 -0
  54. package/esm/propTypes/index.js.map +7 -0
  55. package/esm/propTypes/toTypescript.js +110 -0
  56. package/esm/propTypes/toTypescript.js.map +7 -0
  57. package/esm/propTypes/types.js +2 -0
  58. package/esm/propTypes/types.js.map +7 -0
  59. package/esm/tests/globalProps/TestComponent.js +13 -0
  60. package/esm/tests/globalProps/TestComponent.js.map +7 -0
  61. package/esm/tests/{test.schema.js → validation/test.schema.js} +0 -0
  62. package/esm/tests/{test.schema.js.map → validation/test.schema.js.map} +1 -1
  63. package/esm/validation/typescriptValidator.js +1 -1
  64. package/esm/validation/typescriptValidator.js.map +1 -1
  65. package/package.json +56 -4
  66. package/types/globalProps/constants.d.ts +3 -0
  67. package/types/globalProps/globalAttributesPropTypes.d.ts +363 -0
  68. package/types/globalProps/index.d.ts +2 -0
  69. package/types/globalProps/useGetGlobalAttributes.d.ts +5 -0
  70. package/types/index.d.ts +2 -0
  71. package/types/propTypes/PropTypes.d.ts +3 -0
  72. package/types/propTypes/customPropTypes.d.ts +2 -0
  73. package/types/propTypes/describe.d.ts +3 -0
  74. package/types/propTypes/describeConversions.d.ts +3 -0
  75. package/types/propTypes/describeGuards.d.ts +9 -0
  76. package/types/propTypes/index.d.ts +3 -0
  77. package/types/propTypes/toTypescript.d.ts +3 -0
  78. package/types/propTypes/types.d.ts +96 -0
  79. package/types/tests/globalProps/TestComponent.d.ts +1 -0
  80. package/types/tests/{any.validation.test.d.ts → globalProps/globalAttributes.test.d.ts} +0 -0
  81. package/types/tests/{array.validation.test.d.ts → validation/any.validation.test.d.ts} +0 -0
  82. package/types/tests/{boolean.validation.test.d.ts → validation/array.validation.test.d.ts} +0 -0
  83. package/types/tests/{function.validation.test.d.ts → validation/boolean.validation.test.d.ts} +0 -0
  84. package/types/tests/{number.validation.test.d.ts → validation/function.validation.test.d.ts} +0 -0
  85. package/types/tests/{object.validation.test.d.ts → validation/number.validation.test.d.ts} +0 -0
  86. package/types/tests/{schema.validation.test.d.ts → validation/object.validation.test.d.ts} +0 -0
  87. package/types/tests/{string.validation.test.d.ts → validation/schema.validation.test.d.ts} +0 -0
  88. package/types/tests/{union.validation.test.d.ts → validation/string.validation.test.d.ts} +0 -0
  89. package/types/tests/{test.schema.d.ts → validation/test.schema.d.ts} +0 -0
  90. package/types/tests/validation/union.validation.test.d.ts +1 -0
@@ -0,0 +1,52 @@
1
+ import * as React from "react";
2
+ import { convertPropType } from "./describeConversions";
3
+ import descToTypescript from "./toTypescript";
4
+ function describe(ComponentInstance) {
5
+ if (!ComponentInstance) {
6
+ throw new Error("react-desc: component is required");
7
+ }
8
+ const documentation = {
9
+ propTypes: {}
10
+ };
11
+ const DocumentedComponent = ComponentInstance;
12
+ const addDocumentationProp = (propName) => {
13
+ const func = (value) => {
14
+ documentation[propName] = value;
15
+ return DocumentedComponent;
16
+ };
17
+ return func;
18
+ };
19
+ DocumentedComponent.availableAt = addDocumentationProp("availableAt");
20
+ DocumentedComponent.description = addDocumentationProp("description");
21
+ DocumentedComponent.details = addDocumentationProp("details");
22
+ DocumentedComponent.deprecated = addDocumentationProp("deprecated");
23
+ DocumentedComponent.usage = addDocumentationProp("usage");
24
+ DocumentedComponent.intrinsicElement = addDocumentationProp("intrinsicElement");
25
+ DocumentedComponent.toTypescript = () => descToTypescript(ComponentInstance, documentation);
26
+ Object.defineProperty(DocumentedComponent, "propTypes", {
27
+ get: () => DocumentedComponent.propTypesValue,
28
+ set: (value) => {
29
+ if (!DocumentedComponent.propTypesValue) {
30
+ DocumentedComponent.propTypesValue = {};
31
+ }
32
+ Object.keys(value).forEach((name) => {
33
+ const propType = value[name];
34
+ let realPropType;
35
+ documentation.propTypes[name] = propType;
36
+ realPropType = convertPropType(propType);
37
+ if (value[name].reactDesc.required) {
38
+ realPropType = realPropType.isRequired;
39
+ }
40
+ DocumentedComponent.propTypesValue[name] = realPropType;
41
+ return propType;
42
+ });
43
+ },
44
+ enumerable: true,
45
+ configurable: true
46
+ });
47
+ return DocumentedComponent;
48
+ }
49
+ export {
50
+ describe as default
51
+ };
52
+ //# sourceMappingURL=describe.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/propTypes/describe.ts"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/forbid-foreign-prop-types */\nimport { Requireable, Validator } from 'prop-types';\nimport React from 'react';\nimport { convertPropType } from './describeConversions';\nimport descToTypescript from './toTypescript';\nimport { ReactDescT, ComponentDocumentation, DocumentedReactComponent } from './types';\n\nexport default function describe<C>(ComponentInstance: React.ComponentType<C>) {\n if (!ComponentInstance) {\n throw new Error('react-desc: component is required');\n }\n\n const documentation: ComponentDocumentation = {\n propTypes: {},\n };\n\n const DocumentedComponent = ComponentInstance as DocumentedReactComponent<C>;\n\n const addDocumentationProp = <T extends keyof ComponentDocumentation>(propName: T) => {\n const func = (value: ComponentDocumentation[T]): DocumentedReactComponent<C> => {\n documentation[propName] = value;\n return DocumentedComponent;\n };\n return func;\n };\n\n DocumentedComponent.availableAt = addDocumentationProp('availableAt');\n DocumentedComponent.description = addDocumentationProp('description');\n DocumentedComponent.details = addDocumentationProp('details');\n DocumentedComponent.deprecated = addDocumentationProp('deprecated');\n DocumentedComponent.usage = addDocumentationProp('usage');\n DocumentedComponent.intrinsicElement = addDocumentationProp('intrinsicElement');\n\n DocumentedComponent.toTypescript = () => descToTypescript(ComponentInstance, documentation);\n\n Object.defineProperty(DocumentedComponent, 'propTypes', {\n get: () => DocumentedComponent.propTypesValue,\n set: (value: Record<string, ReactDescT>) => {\n if (!DocumentedComponent.propTypesValue) {\n DocumentedComponent.propTypesValue = {};\n }\n\n Object.keys(value).forEach((name) => {\n const propType: ReactDescT = value[name];\n let realPropType: Requireable<unknown> | Validator<unknown>;\n documentation.propTypes[name] = propType;\n realPropType = convertPropType(propType);\n if (value[name].reactDesc.required) {\n realPropType = (realPropType as Requireable<unknown>).isRequired;\n }\n DocumentedComponent.propTypesValue[name] = realPropType as Validator<unknown>;\n return propType;\n });\n },\n enumerable: true,\n configurable: true,\n });\n\n return DocumentedComponent;\n}\n"],
5
+ "mappings": "AAAA;ACGA;AACA;AAGe,kBAAqB,mBAA2C;AAC7E,MAAI,CAAC,mBAAmB;AACtB,UAAM,IAAI,MAAM;AAAA;AAGlB,QAAM,gBAAwC;AAAA,IAC5C,WAAW;AAAA;AAGb,QAAM,sBAAsB;AAE5B,QAAM,uBAAuB,CAAyC,aAAgB;AACpF,UAAM,OAAO,CAAC,UAAkE;AAC9E,oBAAc,YAAY;AAC1B,aAAO;AAAA;AAET,WAAO;AAAA;AAGT,sBAAoB,cAAc,qBAAqB;AACvD,sBAAoB,cAAc,qBAAqB;AACvD,sBAAoB,UAAU,qBAAqB;AACnD,sBAAoB,aAAa,qBAAqB;AACtD,sBAAoB,QAAQ,qBAAqB;AACjD,sBAAoB,mBAAmB,qBAAqB;AAE5D,sBAAoB,eAAe,MAAM,iBAAiB,mBAAmB;AAE7E,SAAO,eAAe,qBAAqB,aAAa;AAAA,IACtD,KAAK,MAAM,oBAAoB;AAAA,IAC/B,KAAK,CAAC,UAAsC;AAC1C,UAAI,CAAC,oBAAoB,gBAAgB;AACvC,4BAAoB,iBAAiB;AAAA;AAGvC,aAAO,KAAK,OAAO,QAAQ,CAAC,SAAS;AACnC,cAAM,WAAuB,MAAM;AACnC,YAAI;AACJ,sBAAc,UAAU,QAAQ;AAChC,uBAAe,gBAAgB;AAC/B,YAAI,MAAM,MAAM,UAAU,UAAU;AAClC,yBAAgB,aAAsC;AAAA;AAExD,4BAAoB,eAAe,QAAQ;AAC3C,eAAO;AAAA;AAAA;AAAA,IAGX,YAAY;AAAA,IACZ,cAAc;AAAA;AAGhB,SAAO;AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,76 @@
1
+ import * as React from "react";
2
+ import PropTypes from "prop-types";
3
+ import { tupleValidator } from "./customPropTypes";
4
+ import {
5
+ hasArguments,
6
+ isArrayOf,
7
+ isExact,
8
+ isInstanceOf,
9
+ isObjectOf,
10
+ isOneOf,
11
+ isOneOfType,
12
+ isShape
13
+ } from "./describeGuards";
14
+ const enrichPropType = (propType, reactDesc) => {
15
+ const func = (props, propName, componentName, ...rest) => {
16
+ if (reactDesc && reactDesc.deprecated && propName in props && !reactDesc.warned) {
17
+ const { version = "", message = "" } = reactDesc.deprecated;
18
+ const warning = `"${propName}" property of "${componentName}" will be deprecated on VERSION: ${version}.
19
+ ${message}`;
20
+ console.warn(warning);
21
+ reactDesc.warned = true;
22
+ }
23
+ return propType(props, propName, componentName, ...rest);
24
+ };
25
+ Object.defineProperty(func, "isRequired", Object.getOwnPropertyDescriptor(propType, "isRequired"));
26
+ return func;
27
+ };
28
+ const convertArray = (array) => array.map((type) => convertPropType(type));
29
+ const convertShape = (_shape) => {
30
+ const result = {};
31
+ Object.keys(_shape).forEach((key) => {
32
+ result[key] = convertPropType(_shape[key]);
33
+ });
34
+ return result;
35
+ };
36
+ const convertPropType = (propType) => {
37
+ if (!propType || !propType.type) {
38
+ throw new Error(`react-desc: unknown error -- proptype is not well defined`);
39
+ }
40
+ if (propType.type === "tuple") {
41
+ return enrichPropType(PropTypes.arrayOf(tupleValidator(convertArray(propType.args))), propType.reactDesc);
42
+ }
43
+ const realPropType = PropTypes[propType.type];
44
+ if (!realPropType) {
45
+ throw new Error(`react-desc: unknown type ${propType.type}`);
46
+ }
47
+ if (hasArguments(propType, realPropType)) {
48
+ if (isOneOfType(propType, realPropType)) {
49
+ return enrichPropType(realPropType(convertArray(propType.args)), propType.reactDesc);
50
+ }
51
+ if (isArrayOf(propType, realPropType)) {
52
+ return enrichPropType(realPropType(convertPropType(propType.args)), propType.reactDesc);
53
+ }
54
+ if (isShape(propType, realPropType)) {
55
+ return enrichPropType(realPropType(convertShape(propType.args)), propType.reactDesc);
56
+ }
57
+ if (isInstanceOf(propType, realPropType)) {
58
+ return enrichPropType(realPropType(propType.args), propType.reactDesc);
59
+ }
60
+ if (isOneOf(propType, realPropType)) {
61
+ return enrichPropType(realPropType(propType.args), propType.reactDesc);
62
+ }
63
+ if (isObjectOf(propType, realPropType)) {
64
+ return enrichPropType(realPropType(propType.args), propType.reactDesc);
65
+ }
66
+ if (isExact(propType, realPropType)) {
67
+ return enrichPropType(realPropType(propType.args), propType.reactDesc);
68
+ }
69
+ throw new Error(`react-desc: unknown error -- proptype with args is not matching`);
70
+ }
71
+ return enrichPropType(realPropType, propType.reactDesc);
72
+ };
73
+ export {
74
+ convertPropType
75
+ };
76
+ //# sourceMappingURL=describeConversions.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/propTypes/describeConversions.ts"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-statements */\n/* eslint-disable complexity */\n/* eslint-disable max-params */\n/* eslint-disable no-console */\n/* eslint-disable @typescript-eslint/no-use-before-define */\nimport PropTypes, { ValidationMap, Requireable } from 'prop-types';\nimport { tupleValidator } from './customPropTypes';\nimport {\n hasArguments,\n isArrayOf,\n isExact,\n isInstanceOf,\n isObjectOf,\n isOneOf,\n isOneOfType,\n isShape,\n} from './describeGuards';\nimport { ReactDescT, ReactDescObjT, InstanceOfT, OneOfT, ObjectOfT, ExactT } from './types';\n\nconst enrichPropType = (propType: Requireable<unknown>, reactDesc: ReactDescObjT): Requireable<unknown> => {\n const func = (props: Record<string, unknown>, propName: string, componentName: string, ...rest: [string, string]) => {\n if (reactDesc && reactDesc.deprecated && propName in props && !reactDesc.warned) {\n const { version = '', message = '' } = reactDesc.deprecated;\n const warning = `\"${propName}\" property of \"${componentName}\" will be deprecated on VERSION: ${version}.\\n${message}`;\n console.warn(warning);\n reactDesc.warned = true;\n }\n return propType(props, propName, componentName, ...rest);\n };\n Object.defineProperty(\n func,\n 'isRequired',\n Object.getOwnPropertyDescriptor(propType, 'isRequired') as PropertyDescriptor,\n );\n return func as Requireable<unknown>;\n};\n\nconst convertArray = (array: ReactDescT[]): Requireable<unknown>[] => array.map((type) => convertPropType(type));\n\nconst convertShape = (_shape: Record<string, ReactDescT>): ValidationMap<Record<string, unknown>> => {\n const result: ValidationMap<Record<string, unknown>> = {};\n Object.keys(_shape).forEach((key) => {\n result[key] = convertPropType(_shape[key]);\n });\n return result;\n};\n\nexport const convertPropType = (propType: ReactDescT): Requireable<unknown> => {\n if (!propType || !propType.type) {\n throw new Error(`react-desc: unknown error -- proptype is not well defined`);\n }\n\n // DimSum PropTypes conversion\n if (propType.type === 'tuple') {\n return enrichPropType(\n PropTypes.arrayOf(tupleValidator(convertArray(propType.args as ReactDescT[]))),\n propType.reactDesc,\n );\n }\n\n // Default PropType conversion\n const realPropType = PropTypes[propType.type];\n\n if (!realPropType) {\n throw new Error(`react-desc: unknown type ${propType.type}`);\n }\n\n if (hasArguments(propType, realPropType)) {\n if (isOneOfType(propType, realPropType)) {\n return enrichPropType(realPropType(convertArray(propType.args as ReactDescT[])), propType.reactDesc);\n }\n if (isArrayOf(propType, realPropType)) {\n return enrichPropType(realPropType(convertPropType(propType.args as ReactDescT)), propType.reactDesc);\n }\n if (isShape(propType, realPropType)) {\n return enrichPropType(\n realPropType(convertShape(propType.args as Record<string, ReactDescT>)),\n propType.reactDesc,\n );\n }\n if (isInstanceOf(propType, realPropType)) {\n return enrichPropType(realPropType(propType.args as Parameters<InstanceOfT>[0]), propType.reactDesc);\n }\n if (isOneOf(propType, realPropType)) {\n return enrichPropType(realPropType(propType.args as Parameters<OneOfT>[0]), propType.reactDesc);\n }\n if (isObjectOf(propType, realPropType)) {\n return enrichPropType(realPropType(propType.args as Parameters<ObjectOfT>[0]), propType.reactDesc);\n }\n if (isExact(propType, realPropType)) {\n return enrichPropType(realPropType(propType.args as Parameters<ExactT>[0]), propType.reactDesc);\n }\n throw new Error(`react-desc: unknown error -- proptype with args is not matching`);\n }\n\n return enrichPropType(realPropType, propType.reactDesc);\n};\n"],
5
+ "mappings": "AAAA;ACKA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,MAAM,iBAAiB,CAAC,UAAgC,cAAmD;AACzG,QAAM,OAAO,CAAC,OAAgC,UAAkB,kBAA0B,SAA2B;AACnH,QAAI,aAAa,UAAU,cAAc,YAAY,SAAS,CAAC,UAAU,QAAQ;AAC/E,YAAM,EAAE,UAAU,IAAI,UAAU,OAAO,UAAU;AACjD,YAAM,UAAU,IAAI,0BAA0B,iDAAiD;AAAA,EAAa;AAC5G,cAAQ,KAAK;AACb,gBAAU,SAAS;AAAA;AAErB,WAAO,SAAS,OAAO,UAAU,eAAe,GAAG;AAAA;AAErD,SAAO,eACL,MACA,cACA,OAAO,yBAAyB,UAAU;AAE5C,SAAO;AAAA;AAGT,MAAM,eAAe,CAAC,UAAgD,MAAM,IAAI,CAAC,SAAS,gBAAgB;AAE1G,MAAM,eAAe,CAAC,WAA+E;AACnG,QAAM,SAAiD;AACvD,SAAO,KAAK,QAAQ,QAAQ,CAAC,QAAQ;AACnC,WAAO,OAAO,gBAAgB,OAAO;AAAA;AAEvC,SAAO;AAAA;AAGF,MAAM,kBAAkB,CAAC,aAA+C;AAC7E,MAAI,CAAC,YAAY,CAAC,SAAS,MAAM;AAC/B,UAAM,IAAI,MAAM;AAAA;AAIlB,MAAI,SAAS,SAAS,SAAS;AAC7B,WAAO,eACL,UAAU,QAAQ,eAAe,aAAa,SAAS,SACvD,SAAS;AAAA;AAKb,QAAM,eAAe,UAAU,SAAS;AAExC,MAAI,CAAC,cAAc;AACjB,UAAM,IAAI,MAAM,4BAA4B,SAAS;AAAA;AAGvD,MAAI,aAAa,UAAU,eAAe;AACxC,QAAI,YAAY,UAAU,eAAe;AACvC,aAAO,eAAe,aAAa,aAAa,SAAS,QAAwB,SAAS;AAAA;AAE5F,QAAI,UAAU,UAAU,eAAe;AACrC,aAAO,eAAe,aAAa,gBAAgB,SAAS,QAAsB,SAAS;AAAA;AAE7F,QAAI,QAAQ,UAAU,eAAe;AACnC,aAAO,eACL,aAAa,aAAa,SAAS,QACnC,SAAS;AAAA;AAGb,QAAI,aAAa,UAAU,eAAe;AACxC,aAAO,eAAe,aAAa,SAAS,OAAqC,SAAS;AAAA;AAE5F,QAAI,QAAQ,UAAU,eAAe;AACnC,aAAO,eAAe,aAAa,SAAS,OAAgC,SAAS;AAAA;AAEvF,QAAI,WAAW,UAAU,eAAe;AACtC,aAAO,eAAe,aAAa,SAAS,OAAmC,SAAS;AAAA;AAE1F,QAAI,QAAQ,UAAU,eAAe;AACnC,aAAO,eAAe,aAAa,SAAS,OAAgC,SAAS;AAAA;AAEvF,UAAM,IAAI,MAAM;AAAA;AAGlB,SAAO,eAAe,cAAc,SAAS;AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+ const hasArguments = (propType, realPropType) => !!propType.args;
3
+ const isOneOfType = (propType, realPropType) => propType.type === "oneOfType";
4
+ const isArrayOf = (propType, realPropType) => propType.type === "arrayOf";
5
+ const isShape = (propType, realPropType) => propType.type === "shape";
6
+ const isInstanceOf = (propType, realPropType) => propType.type === "instanceOf";
7
+ const isOneOf = (propType, realPropType) => propType.type === "oneOf";
8
+ const isObjectOf = (propType, realPropType) => propType.type === "objectOf";
9
+ const isExact = (propType, realPropType) => propType.type === "exact";
10
+ export {
11
+ hasArguments,
12
+ isArrayOf,
13
+ isExact,
14
+ isInstanceOf,
15
+ isObjectOf,
16
+ isOneOf,
17
+ isOneOfType,
18
+ isShape
19
+ };
20
+ //# sourceMappingURL=describeGuards.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/propTypes/describeGuards.ts"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import {\n AllPropTypes,\n ArrayOfT,\n ExactT,\n InstanceOfT,\n ObjectOfT,\n OneOfT,\n OneOfTypeT,\n ParametizedPropTypes,\n ReactDescT,\n ShapeT,\n} from './types';\n\nexport const hasArguments = (propType: ReactDescT, realPropType: AllPropTypes): realPropType is ParametizedPropTypes =>\n !!propType.args;\n\nexport const isOneOfType = (propType: ReactDescT, realPropType: AllPropTypes): realPropType is OneOfTypeT =>\n propType.type === 'oneOfType';\n\nexport const isArrayOf = (propType: ReactDescT, realPropType: AllPropTypes): realPropType is ArrayOfT =>\n propType.type === 'arrayOf';\n\nexport const isShape = (propType: ReactDescT, realPropType: AllPropTypes): realPropType is ShapeT =>\n propType.type === 'shape';\n\nexport const isInstanceOf = (propType: ReactDescT, realPropType: AllPropTypes): realPropType is InstanceOfT =>\n propType.type === 'instanceOf';\n\nexport const isOneOf = (propType: ReactDescT, realPropType: AllPropTypes): realPropType is OneOfT =>\n propType.type === 'oneOf';\n\nexport const isObjectOf = (propType: ReactDescT, realPropType: AllPropTypes): realPropType is ObjectOfT =>\n propType.type === 'objectOf';\n\nexport const isExact = (propType: ReactDescT, realPropType: AllPropTypes): realPropType is ExactT =>\n propType.type === 'exact';\n"],
5
+ "mappings": "AAAA;ACaO,MAAM,eAAe,CAAC,UAAsB,iBACjD,CAAC,CAAC,SAAS;AAEN,MAAM,cAAc,CAAC,UAAsB,iBAChD,SAAS,SAAS;AAEb,MAAM,YAAY,CAAC,UAAsB,iBAC9C,SAAS,SAAS;AAEb,MAAM,UAAU,CAAC,UAAsB,iBAC5C,SAAS,SAAS;AAEb,MAAM,eAAe,CAAC,UAAsB,iBACjD,SAAS,SAAS;AAEb,MAAM,UAAU,CAAC,UAAsB,iBAC5C,SAAS,SAAS;AAEb,MAAM,aAAa,CAAC,UAAsB,iBAC/C,SAAS,SAAS;AAEb,MAAM,UAAU,CAAC,UAAsB,iBAC5C,SAAS,SAAS;",
6
+ "names": []
7
+ }
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ import PropTypes from "./PropTypes";
3
+ import describe from "./describe";
4
+ export {
5
+ PropTypes,
6
+ describe
7
+ };
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/propTypes/index.ts"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import PropTypes from './PropTypes';\nimport describe from './describe';\n\nexport { describe, PropTypes };\n"],
5
+ "mappings": "AAAA;ACAA;AACA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,110 @@
1
+ import * as React from "react";
2
+ const arrayFormat = (array) => array.map((propType) => propTypeFormat(propType));
3
+ const shapeFormat = (shape) => {
4
+ const props = Object.keys(shape).map((key) => {
5
+ const value = shape[key];
6
+ let valueFormat;
7
+ if (value.type && (value.type === "arrayOf" || value.type === "oneOfType" || value.type === "oneOf") && Array.isArray(value.args)) {
8
+ valueFormat = `${propTypeFormat(value)}`;
9
+ } else if (value.type === "shape") {
10
+ valueFormat = `${propTypeFormat(value)}`;
11
+ } else {
12
+ valueFormat = propTypeFormat(value);
13
+ }
14
+ return `${key}${value.reactDesc && value.reactDesc.required ? "" : "?"}: ${valueFormat}`;
15
+ });
16
+ return `{${props.join(",")}}`;
17
+ };
18
+ const propTypeFormat = (propType, joinWith = "") => {
19
+ let result;
20
+ if (Array.isArray(propType)) {
21
+ result = arrayFormat(propType).join(joinWith);
22
+ } else if (typeof propType !== "function" && propType.type) {
23
+ switch (propType.type) {
24
+ case "array":
25
+ result = "any[]";
26
+ break;
27
+ case "arrayOf":
28
+ if (propType.args.type === "oneOfType") {
29
+ result = `(${propTypeFormat(propType.args, " | ")})[]`;
30
+ } else {
31
+ result = `${propTypeFormat(propType.args, "\n")}[]`;
32
+ }
33
+ break;
34
+ case "tuple":
35
+ result = `[${propTypeFormat(propType.args, ", ")}]`;
36
+ break;
37
+ case "bool":
38
+ result = "boolean";
39
+ break;
40
+ case "func":
41
+ result = "((...args: any[]) => any)";
42
+ break;
43
+ case "node":
44
+ result = "React.ReactNode";
45
+ break;
46
+ case "element":
47
+ result = "JSX.Element";
48
+ break;
49
+ case "instanceOf":
50
+ result = "any";
51
+ break;
52
+ case "symbol":
53
+ result = "any";
54
+ break;
55
+ case "objectOf":
56
+ result = `{ [key: string]: ${propTypeFormat(propType.args)} }`;
57
+ break;
58
+ case "oneOf":
59
+ result = propType.args.map((a) => `"${a}"`).join(" | ");
60
+ break;
61
+ case "oneOfType":
62
+ result = `${propTypeFormat(propType.args, " | ")}`;
63
+ break;
64
+ case "shape":
65
+ result = `${shapeFormat(propType.args)}`;
66
+ break;
67
+ default:
68
+ result = `${propType.type}`;
69
+ break;
70
+ }
71
+ } else {
72
+ result = "any";
73
+ }
74
+ return result;
75
+ };
76
+ const propTypeAsTypescript = (propType, propName) => {
77
+ const documentation = {
78
+ ...propType.reactDesc,
79
+ name: propName
80
+ };
81
+ documentation.format = propTypeFormat(propType);
82
+ return documentation;
83
+ };
84
+ function descToTypescript(component, reactDesc) {
85
+ if (!component) {
86
+ throw new Error("react-desc: component is required");
87
+ }
88
+ const documentation = {
89
+ name: component.displayName || component.name,
90
+ ...reactDesc
91
+ };
92
+ if (reactDesc) {
93
+ delete documentation.propTypes;
94
+ if (reactDesc.propTypes) {
95
+ const propTypes = [];
96
+ Object.keys(reactDesc.propTypes).forEach((propName) => {
97
+ const propType = reactDesc.propTypes[propName];
98
+ propTypes.push(propTypeAsTypescript(propType, propName));
99
+ });
100
+ if (propTypes.length > 0) {
101
+ documentation.properties = propTypes;
102
+ }
103
+ }
104
+ }
105
+ return documentation;
106
+ }
107
+ export {
108
+ descToTypescript as default
109
+ };
110
+ //# sourceMappingURL=toTypescript.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/propTypes/toTypescript.ts"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* 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"],
5
+ "mappings": "AAAA;ACOA,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,2 @@
1
+ import * as React from "react";
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": "AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,13 @@
1
+ import * as React from "react";
2
+ import React2 from "react";
3
+ import { useGetGlobalAttributes } from "../../globalProps";
4
+ const TestComponent = (props) => {
5
+ const globalAttributes = useGetGlobalAttributes(props);
6
+ return /* @__PURE__ */ React2.createElement("div", {
7
+ ...globalAttributes
8
+ }, "Some random div");
9
+ };
10
+ export {
11
+ TestComponent
12
+ };
13
+ //# sourceMappingURL=TestComponent.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/tests/globalProps/TestComponent.js"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
5
+ "mappings": "AAAA;ACAA;AACA;AAEO,MAAM,gBAAgB,CAAC,UAAU;AACtC,QAAM,mBAAmB,uBAAuB;AAEhD,SAAO,qCAAC,OAAD;AAAA,OAAS;AAAA,KAAkB;AAAA;",
6
+ "names": []
7
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/tests/test.schema.js"],
3
+ "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/tests/validation/test.schema.js"],
4
4
  "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
5
5
  "mappings": "AAAA;ACAA;AAEA,MAAM,aAAa;AAAA,EACjB,QAAQ,UAAU,OAAO,YAAY;AAAA,EACrC,QAAQ,UAAU,OAAO,YAAY;AAAA,EACrC,SAAS,UAAU,KAAK,YAAY;AAAA,EACpC,KAAK,UAAU,IAAI,YAAY;AAAA,EAC/B,OAAO,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,SAAS,YAAY;AAAA,EAC7E,QAAQ,UAAU,MAAM,CAAC,KAAK,MAAM,YAAY;AAAA,EAChD,QAAQ,UAAU,UAAU;AAAA,IAC1B,UAAU;AAAA,IACV,UAAU,QAAQ,UAAU;AAAA,IAC5B,UAAU,MAAM,EAAE,QAAQ,UAAU;AAAA,KACnC,YAAY;AAAA,EACf,OAAO,UAAU,QAAQ,UAAU,QAAQ,YAAY;AAAA,EACvD,QAAQ,UAAU,OAAO,YAAY;AAAA,EACrC,OAAO,UAAU,MAAM;AAAA,IACrB,QAAQ,UAAU,OAAO,YAAY,UAAU;AAAA,IAC/C,QAAQ,UAAU,OAAO,YAAY;AAAA,IACrC,SAAS,UAAU,KAAK,YAAY;AAAA,IACpC,cAAc,UAAU,MAAM;AAAA,MAC5B,QAAQ,UAAU,OAAO,YAAY,UAAU;AAAA,MAC/C,QAAQ,UAAU,OAAO,YAAY;AAAA,MACrC,SAAS,UAAU,KAAK,YAAY;AAAA,OACnC,YAAY;AAAA,KACd,YAAY;AAAA,EACf,UAAU,UAAU,KAAK,YAAY;AAAA,EACrC,KAAK,UAAU,QAAQ,YAAY;AAAA,EACnC,MAAM,UAAU,KAAK,YAAY;AAAA;AAGnC,MAAM,gBAAgB,MAAM;AAE5B,MAAM,0BAA0B,SAAS,eAAe,YAAY;AAEpE,wBAAwB,YAAY;AAE7B,MAAM,mBAAmB,wBAAwB;",
6
6
  "names": []
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
- import { describe } from "react-desc";
3
2
  import { useMemo, useState } from "react";
3
+ import { describe } from "../propTypes";
4
4
  import { throwRequiredError, throwTypeError } from "./errorTemplates";
5
5
  import {
6
6
  isArray,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/validation/typescriptValidator.ts"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\n/* eslint-disable max-lines */\n/* eslint-disable max-params */\nimport { describe } from 'react-desc';\nimport React, { PropsWithChildren, useMemo, useState } from 'react';\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"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* 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"],
5
5
  "mappings": "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",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-props-helpers",
3
- "version": "2.3.0-alpha.2",
3
+ "version": "2.3.0-alpha.3",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Props Helpers",
6
6
  "module": "./esm/index.js",
@@ -35,9 +35,61 @@
35
35
  "import": "./esm/validation/errorTemplates.js",
36
36
  "require": "./cjs/validation/errorTemplates.js"
37
37
  },
38
- "./tests/test.schema": {
39
- "import": "./esm/tests/test.schema.js",
40
- "require": "./cjs/tests/test.schema.js"
38
+ "./tests/validation/test.schema": {
39
+ "import": "./esm/tests/validation/test.schema.js",
40
+ "require": "./cjs/tests/validation/test.schema.js"
41
+ },
42
+ "./tests/globalProps/TestComponent": {
43
+ "import": "./esm/tests/globalProps/TestComponent.js",
44
+ "require": "./cjs/tests/globalProps/TestComponent.js"
45
+ },
46
+ "./propTypes/types": {
47
+ "import": "./esm/propTypes/types.js",
48
+ "require": "./cjs/propTypes/types.js"
49
+ },
50
+ "./propTypes/toTypescript": {
51
+ "import": "./esm/propTypes/toTypescript.js",
52
+ "require": "./cjs/propTypes/toTypescript.js"
53
+ },
54
+ "./propTypes/PropTypes": {
55
+ "import": "./esm/propTypes/PropTypes.js",
56
+ "require": "./cjs/propTypes/PropTypes.js"
57
+ },
58
+ "./propTypes": {
59
+ "import": "./esm/propTypes/index.js",
60
+ "require": "./cjs/propTypes/index.js"
61
+ },
62
+ "./propTypes/describeGuards": {
63
+ "import": "./esm/propTypes/describeGuards.js",
64
+ "require": "./cjs/propTypes/describeGuards.js"
65
+ },
66
+ "./propTypes/describeConversions": {
67
+ "import": "./esm/propTypes/describeConversions.js",
68
+ "require": "./cjs/propTypes/describeConversions.js"
69
+ },
70
+ "./propTypes/describe": {
71
+ "import": "./esm/propTypes/describe.js",
72
+ "require": "./cjs/propTypes/describe.js"
73
+ },
74
+ "./propTypes/customPropTypes": {
75
+ "import": "./esm/propTypes/customPropTypes.js",
76
+ "require": "./cjs/propTypes/customPropTypes.js"
77
+ },
78
+ "./globalProps/useGetGlobalAttributes": {
79
+ "import": "./esm/globalProps/useGetGlobalAttributes.js",
80
+ "require": "./cjs/globalProps/useGetGlobalAttributes.js"
81
+ },
82
+ "./globalProps": {
83
+ "import": "./esm/globalProps/index.js",
84
+ "require": "./cjs/globalProps/index.js"
85
+ },
86
+ "./globalProps/globalAttributesPropTypes": {
87
+ "import": "./esm/globalProps/globalAttributesPropTypes.js",
88
+ "require": "./cjs/globalProps/globalAttributesPropTypes.js"
89
+ },
90
+ "./globalProps/constants": {
91
+ "import": "./esm/globalProps/constants.js",
92
+ "require": "./cjs/globalProps/constants.js"
41
93
  },
42
94
  "./getProps": {
43
95
  "import": "./esm/getProps/index.js",
@@ -0,0 +1,3 @@
1
+ import { AriaAttributes, DOMAttributes, HTMLAttributes } from 'react';
2
+ export declare type GlobalAttributes<T = true> = Record<keyof (AriaAttributes & DOMAttributes<Element> & HTMLAttributes<Element>), T>;
3
+ export declare const globalAttributes: GlobalAttributes<true>;