@elliemae/ds-props-helpers 3.70.0-next.4 → 3.70.0-next.41

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 (38) hide show
  1. package/dist/cjs/propTypes/PropTypes.js +1 -0
  2. package/dist/cjs/propTypes/PropTypes.js.map +2 -2
  3. package/dist/cjs/propTypes/toTypescript.js +5 -1
  4. package/dist/cjs/propTypes/toTypescript.js.map +2 -2
  5. package/dist/cjs/validation/typescriptGuards.js +2 -0
  6. package/dist/cjs/validation/typescriptGuards.js.map +2 -2
  7. package/dist/cjs/validation/typescriptValidator.js +2 -0
  8. package/dist/cjs/validation/typescriptValidator.js.map +2 -2
  9. package/dist/esm/propTypes/PropTypes.js +1 -0
  10. package/dist/esm/propTypes/PropTypes.js.map +2 -2
  11. package/dist/esm/propTypes/toTypescript.js +5 -1
  12. package/dist/esm/propTypes/toTypescript.js.map +2 -2
  13. package/dist/esm/validation/typescriptGuards.js +2 -0
  14. package/dist/esm/validation/typescriptGuards.js.map +2 -2
  15. package/dist/esm/validation/typescriptValidator.js +3 -0
  16. package/dist/esm/validation/typescriptValidator.js.map +2 -2
  17. package/dist/types/validation/typescriptGuards.d.ts +1 -0
  18. package/package.json +5 -5
  19. package/dist/types/tests/globalProps/TestComponent.d.ts +0 -1
  20. package/dist/types/tests/globalProps/globalAttributes.test.d.ts +0 -1
  21. package/dist/types/tests/propsPerDataTestId/getPropsPerDatatestIdPropTypes.test.d.ts +0 -1
  22. package/dist/types/tests/propsPerDataTestId/getPropsPerDatatestid.test.d.ts +0 -1
  23. package/dist/types/tests/validation/any.validation.test.d.ts +0 -1
  24. package/dist/types/tests/validation/array.validation.test.d.ts +0 -1
  25. package/dist/types/tests/validation/boolean.validation.test.d.ts +0 -1
  26. package/dist/types/tests/validation/function.validation.test.d.ts +0 -1
  27. package/dist/types/tests/validation/isRequiredIf.validation.test.d.ts +0 -1
  28. package/dist/types/tests/validation/number.validation.test.d.ts +0 -1
  29. package/dist/types/tests/validation/object.validation.test.d.ts +0 -1
  30. package/dist/types/tests/validation/objectOf.validation.test.d.ts +0 -1
  31. package/dist/types/tests/validation/schema.validation.test.d.ts +0 -1
  32. package/dist/types/tests/validation/shapeWithObjectOf.validation.test.d.ts +0 -1
  33. package/dist/types/tests/validation/shapeWithObjectOfAndSignature.validation.test.d.ts +0 -1
  34. package/dist/types/tests/validation/string.validation.test.d.ts +0 -1
  35. package/dist/types/tests/validation/test.schema.d.ts +0 -1
  36. package/dist/types/tests/validation/union.validation.test.d.ts +0 -1
  37. package/dist/types/tests/xstyledProps/TestComponent.d.ts +0 -1
  38. package/dist/types/tests/xstyledProps/xstyledProps.test.d.ts +0 -1
@@ -125,6 +125,7 @@ definePropType("any");
125
125
  definePropType("array");
126
126
  definePropType("bool");
127
127
  definePropType("element");
128
+ definePropType("elementType");
128
129
  definePropType("func");
129
130
  definePropType("node");
130
131
  definePropType("number");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/propTypes/PropTypes.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import type { PropTypesTypes, DocumentedPropType, ReactDescObjT, PropTypesObj } from './types.js';\n\nconst addPropTypeDocumentationField = <T extends keyof ReactDescObjT>(fieldName: T) =>\n function addFieldToReactDesc(this: DocumentedPropType, value: ReactDescObjT[T]): DocumentedPropType {\n if (!this.reactDesc) {\n this.reactDesc = {};\n }\n let realValue = value;\n if (\n fieldName === 'global' ||\n fieldName === 'dataTestId' ||\n fieldName === 'hidden' ||\n fieldName === 'xstyled' ||\n fieldName === 'omitValidation'\n )\n realValue = true;\n\n this.reactDesc[fieldName] = realValue;\n return this;\n };\n\nconst documentedPropType: Omit<DocumentedPropType, 'type' | 'isRequired' | 'reactDesc'> = {\n defaultValue: addPropTypeDocumentationField('defaultValue'),\n description: addPropTypeDocumentationField('description'),\n deprecated: addPropTypeDocumentationField('deprecated'),\n format: addPropTypeDocumentationField('format'),\n signature: addPropTypeDocumentationField('signature'),\n global: addPropTypeDocumentationField('global'),\n omitValidation: addPropTypeDocumentationField('omitValidation'),\n hidden: addPropTypeDocumentationField('hidden'),\n dataTestId: addPropTypeDocumentationField('dataTestId'),\n xstyled: addPropTypeDocumentationField('xstyled'),\n isRequiredIf: addPropTypeDocumentationField('isRequiredIf'),\n};\n\nconst createPropType = (type: PropTypesTypes) => {\n const propTypeObj = {\n type,\n ...documentedPropType,\n };\n Object.defineProperty(propTypeObj, 'isRequired', {\n get: function getRequired(this: DocumentedPropType) {\n if (!this.reactDesc) {\n this.reactDesc = {};\n }\n this.reactDesc.required = true;\n return this;\n },\n enumerable: true,\n configurable: true,\n });\n\n return propTypeObj;\n};\n\nconst createPropTypeWithArgs = (type: PropTypesTypes) => (args: unknown) => {\n const propTypeObj = {\n args,\n type,\n ...documentedPropType,\n };\n Object.defineProperty(propTypeObj, 'isRequired', {\n get: function getRequired(this: DocumentedPropType) {\n if (!this.reactDesc) {\n this.reactDesc = {};\n }\n this.reactDesc.required = true;\n return this;\n },\n enumerable: true,\n configurable: true,\n });\n return propTypeObj;\n};\n\nconst PropTypes = {\n custom: (callback: CallableFunction) => {\n const target = callback.bind(null) as CallableFunction & DocumentedPropType;\n target.type = 'func';\n Object.keys(documentedPropType).forEach((fieldName) => {\n const fieldNameCasted = fieldName as keyof DocumentedPropType;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n (target[fieldNameCasted] as unknown) = documentedPropType[fieldNameCasted] as unknown;\n });\n return target;\n },\n} as unknown as PropTypesObj;\n\nfunction definePropType(type: PropTypesTypes) {\n Object.defineProperty(PropTypes, type, {\n get: function getPropType() {\n return createPropType(type);\n },\n enumerable: true,\n configurable: true,\n });\n}\n\nfunction definePropTypeWithArgs(type: PropTypesTypes) {\n Object.defineProperty(PropTypes, type, {\n get: function getPropType() {\n return createPropTypeWithArgs(type);\n },\n enumerable: true,\n configurable: true,\n });\n}\n\ndefinePropType('any');\ndefinePropType('array');\ndefinePropType('bool');\ndefinePropType('element');\ndefinePropType('func');\ndefinePropType('node');\ndefinePropType('number');\ndefinePropType('object');\ndefinePropType('symbol');\ndefinePropType('string');\n\ndefinePropTypeWithArgs('arrayOf');\ndefinePropTypeWithArgs('instanceOf');\ndefinePropTypeWithArgs('objectOf');\ndefinePropTypeWithArgs('oneOfType');\ndefinePropTypeWithArgs('oneOf');\ndefinePropTypeWithArgs('shape');\ndefinePropTypeWithArgs('tuple');\n\nexport default PropTypes;\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,MAAM,gCAAgC,CAAgC,cACpE,SAAS,oBAA8C,OAA6C;AAClG,MAAI,CAAC,KAAK,WAAW;AACnB,SAAK,YAAY,CAAC;AAAA,EACpB;AACA,MAAI,YAAY;AAChB,MACE,cAAc,YACd,cAAc,gBACd,cAAc,YACd,cAAc,aACd,cAAc;AAEd,gBAAY;AAEd,OAAK,UAAU,SAAS,IAAI;AAC5B,SAAO;AACT;AAEF,MAAM,qBAAoF;AAAA,EACxF,cAAc,8BAA8B,cAAc;AAAA,EAC1D,aAAa,8BAA8B,aAAa;AAAA,EACxD,YAAY,8BAA8B,YAAY;AAAA,EACtD,QAAQ,8BAA8B,QAAQ;AAAA,EAC9C,WAAW,8BAA8B,WAAW;AAAA,EACpD,QAAQ,8BAA8B,QAAQ;AAAA,EAC9C,gBAAgB,8BAA8B,gBAAgB;AAAA,EAC9D,QAAQ,8BAA8B,QAAQ;AAAA,EAC9C,YAAY,8BAA8B,YAAY;AAAA,EACtD,SAAS,8BAA8B,SAAS;AAAA,EAChD,cAAc,8BAA8B,cAAc;AAC5D;AAEA,MAAM,iBAAiB,CAAC,SAAyB;AAC/C,QAAM,cAAc;AAAA,IAClB;AAAA,IACA,GAAG;AAAA,EACL;AACA,SAAO,eAAe,aAAa,cAAc;AAAA,IAC/C,KAA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B,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,QAAQ;AACvB,eAAe,QAAQ;AACvB,eAAe,QAAQ;AACvB,eAAe,QAAQ;AAEvB,uBAAuB,SAAS;AAChC,uBAAuB,YAAY;AACnC,uBAAuB,UAAU;AACjC,uBAAuB,WAAW;AAClC,uBAAuB,OAAO;AAC9B,uBAAuB,OAAO;AAC9B,uBAAuB,OAAO;AAE9B,IAAO,oBAAQ;",
4
+ "sourcesContent": ["import type { PropTypesTypes, DocumentedPropType, ReactDescObjT, PropTypesObj } from './types.js';\n\nconst addPropTypeDocumentationField = <T extends keyof ReactDescObjT>(fieldName: T) =>\n function addFieldToReactDesc(this: DocumentedPropType, value: ReactDescObjT[T]): DocumentedPropType {\n if (!this.reactDesc) {\n this.reactDesc = {};\n }\n let realValue = value;\n if (\n fieldName === 'global' ||\n fieldName === 'dataTestId' ||\n fieldName === 'hidden' ||\n fieldName === 'xstyled' ||\n fieldName === 'omitValidation'\n )\n realValue = true;\n\n this.reactDesc[fieldName] = realValue;\n return this;\n };\n\nconst documentedPropType: Omit<DocumentedPropType, 'type' | 'isRequired' | 'reactDesc'> = {\n defaultValue: addPropTypeDocumentationField('defaultValue'),\n description: addPropTypeDocumentationField('description'),\n deprecated: addPropTypeDocumentationField('deprecated'),\n format: addPropTypeDocumentationField('format'),\n signature: addPropTypeDocumentationField('signature'),\n global: addPropTypeDocumentationField('global'),\n omitValidation: addPropTypeDocumentationField('omitValidation'),\n hidden: addPropTypeDocumentationField('hidden'),\n dataTestId: addPropTypeDocumentationField('dataTestId'),\n xstyled: addPropTypeDocumentationField('xstyled'),\n isRequiredIf: addPropTypeDocumentationField('isRequiredIf'),\n};\n\nconst createPropType = (type: PropTypesTypes) => {\n const propTypeObj = {\n type,\n ...documentedPropType,\n };\n Object.defineProperty(propTypeObj, 'isRequired', {\n get: function getRequired(this: DocumentedPropType) {\n if (!this.reactDesc) {\n this.reactDesc = {};\n }\n this.reactDesc.required = true;\n return this;\n },\n enumerable: true,\n configurable: true,\n });\n\n return propTypeObj;\n};\n\nconst createPropTypeWithArgs = (type: PropTypesTypes) => (args: unknown) => {\n const propTypeObj = {\n args,\n type,\n ...documentedPropType,\n };\n Object.defineProperty(propTypeObj, 'isRequired', {\n get: function getRequired(this: DocumentedPropType) {\n if (!this.reactDesc) {\n this.reactDesc = {};\n }\n this.reactDesc.required = true;\n return this;\n },\n enumerable: true,\n configurable: true,\n });\n return propTypeObj;\n};\n\nconst PropTypes = {\n custom: (callback: CallableFunction) => {\n const target = callback.bind(null) as CallableFunction & DocumentedPropType;\n target.type = 'func';\n Object.keys(documentedPropType).forEach((fieldName) => {\n const fieldNameCasted = fieldName as keyof DocumentedPropType;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n (target[fieldNameCasted] as unknown) = documentedPropType[fieldNameCasted] as unknown;\n });\n return target;\n },\n} as unknown as PropTypesObj;\n\nfunction definePropType(type: PropTypesTypes) {\n Object.defineProperty(PropTypes, type, {\n get: function getPropType() {\n return createPropType(type);\n },\n enumerable: true,\n configurable: true,\n });\n}\n\nfunction definePropTypeWithArgs(type: PropTypesTypes) {\n Object.defineProperty(PropTypes, type, {\n get: function getPropType() {\n return createPropTypeWithArgs(type);\n },\n enumerable: true,\n configurable: true,\n });\n}\n\ndefinePropType('any');\ndefinePropType('array');\ndefinePropType('bool');\ndefinePropType('element');\ndefinePropType('elementType');\ndefinePropType('func');\ndefinePropType('node');\ndefinePropType('number');\ndefinePropType('object');\ndefinePropType('symbol');\ndefinePropType('string');\n\ndefinePropTypeWithArgs('arrayOf');\ndefinePropTypeWithArgs('instanceOf');\ndefinePropTypeWithArgs('objectOf');\ndefinePropTypeWithArgs('oneOfType');\ndefinePropTypeWithArgs('oneOf');\ndefinePropTypeWithArgs('shape');\ndefinePropTypeWithArgs('tuple');\n\nexport default PropTypes;\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;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@ -45,7 +45,8 @@ const shapeFormat = (shape) => {
45
45
  } else {
46
46
  valueFormat = propTypeFormat(value);
47
47
  }
48
- return `${key}${value.reactDesc && value.reactDesc.required ? "" : "?"}: ${valueFormat}`;
48
+ const deprecatedMarker = value.reactDesc?.deprecated ? `/** @deprecated v${value.reactDesc.deprecated.version} */ ` : "";
49
+ return `${deprecatedMarker}${key}${value.reactDesc && value.reactDesc.required ? "" : "?"}: ${valueFormat}`;
49
50
  });
50
51
  return `{${props.join(",")}}`;
51
52
  };
@@ -80,6 +81,9 @@ const propTypeFormat = (propType, joinWith = "") => {
80
81
  case "element":
81
82
  result = "JSX.Element";
82
83
  break;
84
+ case "elementType":
85
+ result = "React.ComponentType<Record<string,unknown>>";
86
+ break;
83
87
  case "instanceOf":
84
88
  result = "any";
85
89
  break;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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 type React from 'react';\nimport type { ComponentDocumentation, Hook, ReactDescT, TypescriptDocumentation } from './types.js';\nimport { isReactDesc } from './describeGuards.js';\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 = propType?.reactDesc?.signature ?? '((...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, R>(\n component: React.ComponentType<C> | Hook<C, R>,\n reactDesc: ComponentDocumentation,\n) {\n if (!component) {\n throw new Error('react-desc: component is required');\n }\n\n const documentation: Partial<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 if (propType.type === 'shape') {\n propType.reactDesc.group = {};\n\n Object.keys(propType.args as Record<string, ReactDescT>).forEach((prop) => {\n if (!propType.reactDesc.group) return;\n propType.reactDesc.group[prop] = propTypeAsTypescript(\n (propType.args as Record<string, ReactDescT>)[prop],\n prop,\n );\n });\n }\n propTypes.push(propTypeAsTypescript(propType, propName));\n });\n if (propTypes.length > 0) {\n documentation.properties = propTypes;\n }\n }\n if (reactDesc.returnType) {\n if (isReactDesc(reactDesc.returnType)) {\n documentation.returns = propTypeAsTypescript(reactDesc.returnType, 'returns');\n } else {\n documentation.returns = Object.entries(reactDesc.returnType).map(([propName, propType]) =>\n propTypeAsTypescript(propType, propName),\n );\n }\n }\n }\n return documentation as TypescriptDocumentation;\n}\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADMvB,4BAA4B;AAE5B,MAAM,cAAc,CAAC,UAAwB,MAAM,IAAI,CAAC,aAAa,eAAe,QAAQ,CAAC;AAE7F,MAAM,cAAc,CAAC,UAAsC;AACzD,QAAM,QAAQ,OAAO,KAAK,KAAK,EAAE,IAAI,CAAC,QAAQ;AAC5C,UAAM,QAAQ,MAAM,GAAG;AACvB,QAAI;AACJ,QACE,MAAM,SACL,MAAM,SAAS,aAAa,MAAM,SAAS,eAAe,MAAM,SAAS,YAC1E,MAAM,QAAQ,MAAM,IAAI,GACxB;AACA,oBAAc,GAAG,eAAe,KAAK,CAAC;AAAA,IACxC,WAAW,MAAM,SAAS,SAAS;AACjC,oBAAc,GAAG,eAAe,KAAK,CAAC;AAAA,IACxC,OAAO;AACL,oBAAc,eAAe,KAAK;AAAA,IACpC;AACA,WAAO,GAAG,GAAG,GAAG,MAAM,aAAa,MAAM,UAAU,WAAW,KAAK,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ACF;AACA,SAAO;AACT;",
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 type React from 'react';\nimport type { ComponentDocumentation, Hook, ReactDescT, TypescriptDocumentation } from './types.js';\nimport { isReactDesc } from './describeGuards.js';\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 const deprecatedMarker = value.reactDesc?.deprecated\n ? `/** @deprecated v${value.reactDesc.deprecated.version} */ `\n : '';\n return `${deprecatedMarker}${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 = propType?.reactDesc?.signature ?? '((...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 'elementType':\n result = 'React.ComponentType<Record<string,unknown>>';\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, R>(\n component: React.ComponentType<C> | Hook<C, R>,\n reactDesc: ComponentDocumentation,\n) {\n if (!component) {\n throw new Error('react-desc: component is required');\n }\n\n const documentation: Partial<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 if (propType.type === 'shape') {\n propType.reactDesc.group = {};\n\n Object.keys(propType.args as Record<string, ReactDescT>).forEach((prop) => {\n if (!propType.reactDesc.group) return;\n propType.reactDesc.group[prop] = propTypeAsTypescript(\n (propType.args as Record<string, ReactDescT>)[prop],\n prop,\n );\n });\n }\n propTypes.push(propTypeAsTypescript(propType, propName));\n });\n if (propTypes.length > 0) {\n documentation.properties = propTypes;\n }\n }\n if (reactDesc.returnType) {\n if (isReactDesc(reactDesc.returnType)) {\n documentation.returns = propTypeAsTypescript(reactDesc.returnType, 'returns');\n } else {\n documentation.returns = Object.entries(reactDesc.returnType).map(([propName, propType]) =>\n propTypeAsTypescript(propType, propName),\n );\n }\n }\n }\n return documentation as TypescriptDocumentation;\n}\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADMvB,4BAA4B;AAE5B,MAAM,cAAc,CAAC,UAAwB,MAAM,IAAI,CAAC,aAAa,eAAe,QAAQ,CAAC;AAE7F,MAAM,cAAc,CAAC,UAAsC;AACzD,QAAM,QAAQ,OAAO,KAAK,KAAK,EAAE,IAAI,CAAC,QAAQ;AAC5C,UAAM,QAAQ,MAAM,GAAG;AACvB,QAAI;AACJ,QACE,MAAM,SACL,MAAM,SAAS,aAAa,MAAM,SAAS,eAAe,MAAM,SAAS,YAC1E,MAAM,QAAQ,MAAM,IAAI,GACxB;AACA,oBAAc,GAAG,eAAe,KAAK,CAAC;AAAA,IACxC,WAAW,MAAM,SAAS,SAAS;AACjC,oBAAc,GAAG,eAAe,KAAK,CAAC;AAAA,IACxC,OAAO;AACL,oBAAc,eAAe,KAAK;AAAA,IACpC;AACA,UAAM,mBAAmB,MAAM,WAAW,aACtC,oBAAoB,MAAM,UAAU,WAAW,OAAO,SACtD;AACJ,WAAO,GAAG,gBAAgB,GAAG,GAAG,GAAG,MAAM,aAAa,MAAM,UAAU,WAAW,KAAK,GAAG,KAAK,WAAW;AAAA,EAC3G,CAAC;AACD,SAAO,IAAI,MAAM,KAAK,GAAG,CAAC;AAC5B;AAEA,MAAM,iBAAiB,CAAC,UAAqC,WAAW,OAAe;AACrF,MAAI;AACJ,MAAI,MAAM,QAAQ,QAAQ,GAAG;AAC3B,aAAS,YAAY,QAAQ,EAAE,KAAK,QAAQ;AAAA,EAC9C,WAAW,OAAO,aAAa,cAAc,SAAS,MAAM;AAC1D,YAAQ,SAAS,MAAM;AAAA,MACrB,KAAK;AACH,iBAAS;AACT;AAAA,MACF,KAAK;AACH,YAAK,S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,IACzC,GAAG;AAAA,EACL;AACA,MAAI,WAAW;AACb,WAAO,cAAc;AAErB,QAAI,UAAU,WAAW;AACvB,YAAM,YAAmD,CAAC;AAC1D,aAAO,KAAK,UAAU,SAAS,EAAE,QAAQ,CAAC,aAAa;AACrD,cAAM,WAAW,UAAU,UAAU,QAAQ;AAC7C,YAAI,SAAS,SAAS,SAAS;AAC7B,mBAAS,UAAU,QAAQ,CAAC;AAE5B,iBAAO,KAAK,SAAS,IAAkC,EAAE,QAAQ,CAAC,SAAS;AACzE,gBAAI,CAAC,SAAS,UAAU,MAAO;AAC/B,qBAAS,UAAU,MAAM,IAAI,IAAI;AAAA,cAC9B,SAAS,KAAoC,IAAI;AAAA,cAClD;AAAA,YACF;AAAA,UACF,CAAC;AAAA,QACH;AACA,kBAAU,KAAK,qBAAqB,UAAU,QAAQ,CAAC;AAAA,MACzD,CAAC;AACD,UAAI,UAAU,SAAS,GAAG;AACxB,sBAAc,aAAa;AAAA,MAC7B;AAAA,IACF;AACA,QAAI,UAAU,YAAY;AACxB,cAAI,mCAAY,UAAU,UAAU,GAAG;AACrC,sBAAc,UAAU,qBAAqB,UAAU,YAAY,SAAS;AAAA,MAC9E,OAAO;AACL,sBAAc,UAAU,OAAO,QAAQ,UAAU,UAAU,EAAE;AAAA,UAAI,CAAC,CAAC,UAAU,QAAQ,MACnF,qBAAqB,UAAU,QAAQ;AAAA,QACzC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -35,6 +35,7 @@ __export(typescriptGuards_exports, {
35
35
  isObject: () => isObject,
36
36
  isObjectOf: () => isObjectOf,
37
37
  isPrimitiveType: () => isPrimitiveType,
38
+ isReactComponentType: () => isReactComponentType,
38
39
  isSomethingWithParenthesis: () => isSomethingWithParenthesis,
39
40
  isString: () => isString,
40
41
  isUndefined: () => isUndefined,
@@ -75,5 +76,6 @@ const isFunction = (format) => {
75
76
  return arrowOccursAtDepth1;
76
77
  };
77
78
  const isJSXorNode = (format) => !isUnion(format) && ["React.ReactNode", "JSX.Element"].includes(format);
79
+ const isReactComponentType = (format) => !isUnion(format) && format === "React.ComponentType<Record<string,unknown>>";
78
80
  const isSomethingWithParenthesis = (format) => !isUnion(format) && format[0] === "(" && format.slice(-1) === ")";
79
81
  //# sourceMappingURL=typescriptGuards.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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 isObjectOf: GuardFn = (format) =>\n format !== 'object' && !isUnion(format) && format.startsWith('{ [key: string]: ');\n\nexport const isObject: GuardFn = (format) =>\n format === 'object' || (!isUnion(format) && format[0] === '{' && format.slice(-1) === '}');\n\nexport const isFunction: GuardFn = (format) => {\n // It's isn't an union\n if (isUnion(format)) return false;\n // Has to start with (( and end with )\n if (!format.startsWith('((') && format.slice(-1) !== ')') return false;\n\n // The arrow MUST occur at depth 1 (when couting parenthesis)\n // Otherwise the only possibility is that we have \"something with parenthesis\" (look down below)\n let depth = 0;\n let arrowOccursAtDepth1 = false;\n for (let i = 0; i < format.length; i += 1) {\n const char = format[i];\n if (['{', '('].includes(char)) depth += 1;\n else if (['}', ')'].includes(char)) depth -= 1;\n else if (i < format.length - 1 && format.slice(i, i + 2) === '=>') {\n arrowOccursAtDepth1 = arrowOccursAtDepth1 || depth === 1;\n }\n }\n return arrowOccursAtDepth1;\n};\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;AAAA;AAAA;ACAA,YAAuB;ADEhB,MAAM,kBAA2B,CAAC,WAAW,CAAC,UAAU,UAAU,SAAS,EAAE,SAAS,MAAM;AAC5F,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,EAAE,EAAE,QAAQ,CAAC,SAAS;AACjC,QAAI,CAAC,KAAK,GAAG,EAAE,SAAS,IAAI,EAAG,UAAS;AAAA,aAC/B,CAAC,KAAK,GAAG,EAAE,SAAS,IAAI,EAAG,UAAS;AAAA,aACpC,SAAS,OAAO,UAAU,EAAG,aAAY;AAAA,EACpD,CAAC;AACD,SAAO;AACT;AAEO,MAAM,WAAoB,CAAC,WAAW,CAAC,QAAQ,MAAM,KAAK,OAAO,CAAC,MAAM,OAAO,OAAO,MAAM,EAAE,MAAM;AAEpG,MAAM,UAAmB,CAAC,WAAW,CAAC,QAAQ,MAAM,KAAK,OAAO,MAAM,EAAE,MAAM;AAE9E,MAAM,aAAsB,CAAC,WAClC,WAAW,YAAY,CAAC,QAAQ,MAAM,KAAK,OAAO,WAAW,mBAAmB;AAE3E,MAAM,WAAoB,CAAC,WAChC,WAAW,YAAa,CAAC,QAAQ,MAAM,KAAK,OAAO,CAAC,MAAM,OAAO,OAAO,MAAM,EAAE,MAAM;AAEjF,MAAM,aAAsB,CAAC,WAAW;AAE7C,MAAI,QAAQ,MAAM,EAAG,QAAO;AAE5B,MAAI,CAAC,OAAO,WAAW,IAAI,KAAK,OAAO,MAAM,EAAE,MAAM,IAAK,QAAO;AAIjE,MAAI,QAAQ;AACZ,MAAI,sBAAsB;AAC1B,WAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK,GAAG;AACzC,UAAM,OAAO,OAAO,CAAC;AACrB,QAAI,CAAC,KAAK,GAAG,EAAE,SAAS,IAAI,EAAG,UAAS;AAAA,aAC/B,CAAC,KAAK,GAAG,EAAE,SAAS,IAAI,EAAG,UAAS;AAAA,aACpC,IAAI,OAAO,SAAS,KAAK,OAAO,MAAM,GAAG,IAAI,CAAC,MAAM,MAAM;AACjE,4BAAsB,uBAAuB,UAAU;AAAA,IACzD;AAAA,EACF;AACA,SAAO;AACT;AAEO,MAAM,cAAuB,CAAC,WAAW,CAAC,QAAQ,MAAM,KAAK,CAAC,mBAAmB,aAAa,EAAE,SAAS,MAAM;AAE/G,MAAM,6BAAsC,CAAC,WAClD,CAAC,QAAQ,MAAM,KAAK,OAAO,CAAC,MAAM,OAAO,OAAO,MAAM,EAAE,MAAM;",
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 isObjectOf: GuardFn = (format) =>\n format !== 'object' && !isUnion(format) && format.startsWith('{ [key: string]: ');\n\nexport const isObject: GuardFn = (format) =>\n format === 'object' || (!isUnion(format) && format[0] === '{' && format.slice(-1) === '}');\n\nexport const isFunction: GuardFn = (format) => {\n // It's isn't an union\n if (isUnion(format)) return false;\n // Has to start with (( and end with )\n if (!format.startsWith('((') && format.slice(-1) !== ')') return false;\n\n // The arrow MUST occur at depth 1 (when couting parenthesis)\n // Otherwise the only possibility is that we have \"something with parenthesis\" (look down below)\n let depth = 0;\n let arrowOccursAtDepth1 = false;\n for (let i = 0; i < format.length; i += 1) {\n const char = format[i];\n if (['{', '('].includes(char)) depth += 1;\n else if (['}', ')'].includes(char)) depth -= 1;\n else if (i < format.length - 1 && format.slice(i, i + 2) === '=>') {\n arrowOccursAtDepth1 = arrowOccursAtDepth1 || depth === 1;\n }\n }\n return arrowOccursAtDepth1;\n};\n\nexport const isJSXorNode: GuardFn = (format) => !isUnion(format) && ['React.ReactNode', 'JSX.Element'].includes(format);\n\nexport const isReactComponentType: GuardFn = (format) =>\n !isUnion(format) && format === 'React.ComponentType<Record<string,unknown>>';\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;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEhB,MAAM,kBAA2B,CAAC,WAAW,CAAC,UAAU,UAAU,SAAS,EAAE,SAAS,MAAM;AAC5F,MAAM,cAAuB,CAAC,WAAW,WAAW;AACpD,MAAM,SAAkB,CAAC,WAAW,WAAW;AAC/C,MAAM,UAAmB,CAAC,WAAW;AAC1C,MAAI,QAAQ;AACZ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CAAC,QAAQ,MAAM,KAAK,CAAC,mBAAmB,aAAa,EAAE,SAAS,MAAM;AAE/G,MAAM,uBAAgC,CAAC,WAC5C,CAAC,QAAQ,MAAM,KAAK,WAAW;AAE1B,MAAM,6BAAsC,CAAC,WAClD,CAAC,QAAQ,MAAM,KAAK,OAAO,CAAC,MAAM,OAAO,OAAO,MAAM,EAAE,MAAM;",
6
6
  "names": []
7
7
  }
@@ -170,6 +170,8 @@ const validateValueWithFormat = (schemaName, key, value, format, validationsMemo
170
170
  validateObject(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
171
171
  } else if ((0, import_typescriptGuards.isFunction)(format)) {
172
172
  validateFunction(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
173
+ } else if ((0, import_typescriptGuards.isReactComponentType)(format)) {
174
+ validateFunction(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
173
175
  } else if ((0, import_typescriptGuards.isJSXorNode)(format)) {
174
176
  validateJSXorNode(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
175
177
  } else if ((0, import_typescriptGuards.isSomethingWithParenthesis)(format)) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/validation/typescriptValidator.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* eslint-disable complexity */\n/* eslint-disable max-lines */\n/* eslint-disable max-params */\nimport type { PropsWithChildren, WeakValidationMap } from 'react';\nimport { useMemo, useRef } from 'react';\nimport type { TypescriptDocumentation } from '../propTypes/types.js';\nimport { describe } from '../propTypes/index.js';\nimport { throwRequiredError, throwTypeError } from './errorTemplates.js';\nimport {\n isArray,\n isFunction,\n isJSXorNode,\n isObject,\n isPrimitiveType,\n isSomethingWithParenthesis,\n isString,\n isUnion,\n isUndefined,\n isNull,\n isObjectOf,\n} from './typescriptGuards.js';\nimport { typescriptObjectParser } from './typescriptParsers.js';\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): value is Record<string, unknown> {\n return !(typeof value !== 'object' || Array.isArray(value));\n}\n\nconst validateObjectOf: 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 const valuesFormat = format.slice('{ [key: string]: '.length, -2);\n\n Object.keys(value).forEach((objectKey) => {\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}[${objectKey}]`,\n value[objectKey],\n valuesFormat,\n validationsMemo,\n nextValidationsMemo,\n );\n });\n};\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, trueKey);\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): 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 (isObjectOf(format)) {\n validateObjectOf(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: TypescriptDocumentation,\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, isRequiredIf, omitValidation } = property;\n\n const requiredConditionally = isRequiredIf && isRequiredIf(props);\n\n if (omitValidation) {\n return;\n }\n\n if (required && !(name in props)) {\n throwRequiredError(schema.name, name);\n }\n\n if (requiredConditionally && !(name in props)) {\n throwRequiredError(schema.name, name);\n }\n\n const shouldValidateProperty = props[name] !== undefined || required || requiredConditionally;\n\n if (name in props && format && shouldValidateProperty) {\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 propTypes: WeakValidationMap<unknown>,\n componentDisplayName: string,\n): void => {\n if (!componentDisplayName) {\n throw new Error('Provide display name for the component to use for validation');\n }\n\n const validationsMemo = useRef<Record<string, string>>({});\n\n const typescriptSchema = useMemo(() => {\n const Component = () => {};\n\n const DescribedComponent = describe(Component);\n DescribedComponent.propTypes = propTypes;\n DescribedComponent.displayName = componentDisplayName;\n return DescribedComponent.toTypescript();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [propTypes]);\n\n useMemo(() => {\n const nextValidationsMemo = {};\n\n validateTypescriptPropTypesImplementation(props, typescriptSchema, validationsMemo.current, nextValidationsMemo);\n validationsMemo.current = nextValidationsMemo;\n return 'WE DONT NEED RETURN just the memo';\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [props]);\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADIvB,mBAAgC;AAEhC,uBAAyB;AACzB,4BAAmD;AACnD,8BAYO;AACP,+BAAuC;AAmBvC,MAAM,oBAAiC,CAAC,YAAY,KAAK,OAAO,WAAW;AACzE,MAAI,UAAU,UAAa,UAAU,aAAa;AAChD,8CAAe,YAAY,KAAK,OAAO,MAAM;AAAA,EAC/C;AACF;AACA,MAAM,eAA4B,CAAC,YAAY,KAAK,OAAO,WAAW;AACpE,MAAI,UAAU,QAAQ,UAAU,QAAQ;AACtC,8CAAe,YAAY,KAAK,OAAO,MAAM;A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0C,OAAO,kBAAkB,gBAAgB,SAAS,mBAAmB;AAC/G,oBAAgB,UAAU;AAC1B,WAAO;AAAA,EAET,GAAG,CAAC,KAAK,CAAC;AACZ;",
4
+ "sourcesContent": ["/* eslint-disable complexity */\n/* eslint-disable max-lines */\n/* eslint-disable max-params */\nimport type { PropsWithChildren, WeakValidationMap } from 'react';\nimport { useMemo, useRef } from 'react';\nimport type { TypescriptDocumentation } from '../propTypes/types.js';\nimport { describe } from '../propTypes/index.js';\nimport { throwRequiredError, throwTypeError } from './errorTemplates.js';\nimport {\n isArray,\n isFunction,\n isJSXorNode,\n isObject,\n isReactComponentType,\n isPrimitiveType,\n isSomethingWithParenthesis,\n isString,\n isUnion,\n isUndefined,\n isNull,\n isObjectOf,\n} from './typescriptGuards.js';\nimport { typescriptObjectParser } from './typescriptParsers.js';\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): value is Record<string, unknown> {\n return !(typeof value !== 'object' || Array.isArray(value));\n}\n\nconst validateObjectOf: 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 const valuesFormat = format.slice('{ [key: string]: '.length, -2);\n\n Object.keys(value).forEach((objectKey) => {\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}[${objectKey}]`,\n value[objectKey],\n valuesFormat,\n validationsMemo,\n nextValidationsMemo,\n );\n });\n};\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, trueKey);\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): 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 (isObjectOf(format)) {\n validateObjectOf(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 (isReactComponentType(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: TypescriptDocumentation,\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, isRequiredIf, omitValidation } = property;\n\n const requiredConditionally = isRequiredIf && isRequiredIf(props);\n\n if (omitValidation) {\n return;\n }\n\n if (required && !(name in props)) {\n throwRequiredError(schema.name, name);\n }\n\n if (requiredConditionally && !(name in props)) {\n throwRequiredError(schema.name, name);\n }\n\n const shouldValidateProperty = props[name] !== undefined || required || requiredConditionally;\n\n if (name in props && format && shouldValidateProperty) {\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 propTypes: WeakValidationMap<unknown>,\n componentDisplayName: string,\n): void => {\n if (!componentDisplayName) {\n throw new Error('Provide display name for the component to use for validation');\n }\n\n const validationsMemo = useRef<Record<string, string>>({});\n\n const typescriptSchema = useMemo(() => {\n const Component = () => {};\n\n const DescribedComponent = describe(Component);\n DescribedComponent.propTypes = propTypes;\n DescribedComponent.displayName = componentDisplayName;\n return DescribedComponent.toTypescript();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [propTypes]);\n\n useMemo(() => {\n const nextValidationsMemo = {};\n\n validateTypescriptPropTypesImplementation(props, typescriptSchema, validationsMemo.current, nextValidationsMemo);\n validationsMemo.current = nextValidationsMemo;\n return 'WE DONT NEED RETURN just the memo';\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [props]);\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADIvB,mBAAgC;AAEhC,uBAAyB;AACzB,4BAAmD;AACnD,8BAaO;AACP,+BAAuC;AAmBvC,MAAM,oBAAiC,CAAC,YAAY,KAAK,OAAO,WAAW;AACzE,MAAI,UAAU,UAAa,UAAU,aAAa;AAChD,8CAAe,YAAY,KAAK,OAAO,MAAM;AAAA,EAC/C;AACF;AACA,MAAM,eAA4B,CAAC,YAAY,KAAK,OAAO,WAAW;AACpE,MAAI,UAAU,QAAQ,UAAU,QAAQ;AACtC,8CAAe,YAAY,KAAK,OAAO,MAAM;AAAA,EAC/C;AACF;AACA,MAAM,wBAAqC,CAAC,YAAY,KAAK,OAAO,WAAW;AAC7E,MAAI,OAAO,UAAU,QAAQ;AAC3B,8CAAe,YAAY,KAAK,OAAO,MAAM;AAAA,EAC/C;AACF;AAEA,MAAM,iBAA8B,CAAC,YAAY,KAAK,OAAO,WAAW;AACtE,MAAI,UAAU,OAAO,MAAM,GAAG,EAAE,GAAG;AACjC,8CAAe,YAAY,KAAK,OAAO,MAAM;AAAA,EAC/C;AACF;AAEA,MAAM,gBAA6B,CAAC,YAAY,KAAK,OAAO,QAAQ,iBAAiB,wBAAwB;AAE3G,MAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;AACzB,8CAAe,YAAY,KAAK,OAAO,MAAM;AAAA,EAC/C;AAGA,EAAC,MAAoB,QAAQ,CAAC,KAAK,UAAU;AAG3C;AAAA,MACE;AAAA,MACA,GAAG,GAAG,IAAI,KAAK;AAAA,MACf;AAAA,MACA,OA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O,MAAM,IAAI;AAAA,IACtC;AAEA,QAAI,yBAAyB,EAAE,QAAQ,QAAQ;AAC7C,oDAAmB,OAAO,MAAM,IAAI;AAAA,IACtC;AAEA,UAAM,yBAAyB,MAAM,IAAI,MAAM,UAAa,YAAY;AAExE,QAAI,QAAQ,SAAS,UAAU,wBAAwB;AACrD,8BAAwB,YAAY,MAAM,MAAM,IAAI,GAAG,QAAQ,iBAAiB,mBAAmB;AAAA,IACrG;AAAA,EACF,CAAC;AACH;AAGO,MAAM,iCAAiC,CAC5C,OACA,WACA,yBACS;AACT,MAAI,CAAC,sBAAsB;AACzB,UAAM,IAAI,MAAM,8DAA8D;AAAA,EAChF;AAEA,QAAM,sBAAkB,qBAA+B,CAAC,CAAC;AAEzD,QAAM,uBAAmB,sBAAQ,MAAM;AACrC,UAAM,YAAY,MAAM;AAAA,IAAC;AAEzB,UAAM,yBAAqB,2BAAS,SAAS;AAC7C,uBAAmB,YAAY;AAC/B,uBAAmB,cAAc;AACjC,WAAO,mBAAmB,aAAa;AAAA,EAEzC,GAAG,CAAC,SAAS,CAAC;AAEd,4BAAQ,MAAM;AACZ,UAAM,sBAAsB,CAAC;AAE7B,8CAA0C,OAAO,kBAAkB,gBAAgB,SAAS,mBAAmB;AAC/G,oBAAgB,UAAU;AAC1B,WAAO;AAAA,EAET,GAAG,CAAC,KAAK,CAAC;AACZ;",
6
6
  "names": []
7
7
  }
@@ -92,6 +92,7 @@ definePropType("any");
92
92
  definePropType("array");
93
93
  definePropType("bool");
94
94
  definePropType("element");
95
+ definePropType("elementType");
95
96
  definePropType("func");
96
97
  definePropType("node");
97
98
  definePropType("number");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/propTypes/PropTypes.ts"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { PropTypesTypes, DocumentedPropType, ReactDescObjT, PropTypesObj } from './types.js';\n\nconst addPropTypeDocumentationField = <T extends keyof ReactDescObjT>(fieldName: T) =>\n function addFieldToReactDesc(this: DocumentedPropType, value: ReactDescObjT[T]): DocumentedPropType {\n if (!this.reactDesc) {\n this.reactDesc = {};\n }\n let realValue = value;\n if (\n fieldName === 'global' ||\n fieldName === 'dataTestId' ||\n fieldName === 'hidden' ||\n fieldName === 'xstyled' ||\n fieldName === 'omitValidation'\n )\n realValue = true;\n\n this.reactDesc[fieldName] = realValue;\n return this;\n };\n\nconst documentedPropType: Omit<DocumentedPropType, 'type' | 'isRequired' | 'reactDesc'> = {\n defaultValue: addPropTypeDocumentationField('defaultValue'),\n description: addPropTypeDocumentationField('description'),\n deprecated: addPropTypeDocumentationField('deprecated'),\n format: addPropTypeDocumentationField('format'),\n signature: addPropTypeDocumentationField('signature'),\n global: addPropTypeDocumentationField('global'),\n omitValidation: addPropTypeDocumentationField('omitValidation'),\n hidden: addPropTypeDocumentationField('hidden'),\n dataTestId: addPropTypeDocumentationField('dataTestId'),\n xstyled: addPropTypeDocumentationField('xstyled'),\n isRequiredIf: addPropTypeDocumentationField('isRequiredIf'),\n};\n\nconst createPropType = (type: PropTypesTypes) => {\n const propTypeObj = {\n type,\n ...documentedPropType,\n };\n Object.defineProperty(propTypeObj, 'isRequired', {\n get: function getRequired(this: DocumentedPropType) {\n if (!this.reactDesc) {\n this.reactDesc = {};\n }\n this.reactDesc.required = true;\n return this;\n },\n enumerable: true,\n configurable: true,\n });\n\n return propTypeObj;\n};\n\nconst createPropTypeWithArgs = (type: PropTypesTypes) => (args: unknown) => {\n const propTypeObj = {\n args,\n type,\n ...documentedPropType,\n };\n Object.defineProperty(propTypeObj, 'isRequired', {\n get: function getRequired(this: DocumentedPropType) {\n if (!this.reactDesc) {\n this.reactDesc = {};\n }\n this.reactDesc.required = true;\n return this;\n },\n enumerable: true,\n configurable: true,\n });\n return propTypeObj;\n};\n\nconst PropTypes = {\n custom: (callback: CallableFunction) => {\n const target = callback.bind(null) as CallableFunction & DocumentedPropType;\n target.type = 'func';\n Object.keys(documentedPropType).forEach((fieldName) => {\n const fieldNameCasted = fieldName as keyof DocumentedPropType;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n (target[fieldNameCasted] as unknown) = documentedPropType[fieldNameCasted] as unknown;\n });\n return target;\n },\n} as unknown as PropTypesObj;\n\nfunction definePropType(type: PropTypesTypes) {\n Object.defineProperty(PropTypes, type, {\n get: function getPropType() {\n return createPropType(type);\n },\n enumerable: true,\n configurable: true,\n });\n}\n\nfunction definePropTypeWithArgs(type: PropTypesTypes) {\n Object.defineProperty(PropTypes, type, {\n get: function getPropType() {\n return createPropTypeWithArgs(type);\n },\n enumerable: true,\n configurable: true,\n });\n}\n\ndefinePropType('any');\ndefinePropType('array');\ndefinePropType('bool');\ndefinePropType('element');\ndefinePropType('func');\ndefinePropType('node');\ndefinePropType('number');\ndefinePropType('object');\ndefinePropType('symbol');\ndefinePropType('string');\n\ndefinePropTypeWithArgs('arrayOf');\ndefinePropTypeWithArgs('instanceOf');\ndefinePropTypeWithArgs('objectOf');\ndefinePropTypeWithArgs('oneOfType');\ndefinePropTypeWithArgs('oneOf');\ndefinePropTypeWithArgs('shape');\ndefinePropTypeWithArgs('tuple');\n\nexport default PropTypes;\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACEvB,MAAM,gCAAgC,CAAgC,cACpE,SAAS,oBAA8C,OAA6C;AAClG,MAAI,CAAC,KAAK,WAAW;AACnB,SAAK,YAAY,CAAC;AAAA,EACpB;AACA,MAAI,YAAY;AAChB,MACE,cAAc,YACd,cAAc,gBACd,cAAc,YACd,cAAc,aACd,cAAc;AAEd,gBAAY;AAEd,OAAK,UAAU,SAAS,IAAI;AAC5B,SAAO;AACT;AAEF,MAAM,qBAAoF;AAAA,EACxF,cAAc,8BAA8B,cAAc;AAAA,EAC1D,aAAa,8BAA8B,aAAa;AAAA,EACxD,YAAY,8BAA8B,YAAY;AAAA,EACtD,QAAQ,8BAA8B,QAAQ;AAAA,EAC9C,WA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O,eAAe,WAAW,MAAM;AAAA,IACrC,KAAK,SAAS,cAAc;AAC1B,aAAO,eAAe,IAAI;AAAA,IAC5B;AAAA,IACA,YAAY;AAAA,IACZ,cAAc;AAAA,EAChB,CAAC;AACH;AAEA,SAAS,uBAAuB,MAAsB;AACpD,SAAO,eAAe,WAAW,MAAM;AAAA,IACrC,KAAK,SAAS,cAAc;AAC1B,aAAO,uBAAuB,IAAI;AAAA,IACpC;AAAA,IACA,YAAY;AAAA,IACZ,cAAc;AAAA,EAChB,CAAC;AACH;AAEA,eAAe,KAAK;AACpB,eAAe,OAAO;AACtB,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,QAAQ;AACvB,eAAe,QAAQ;AACvB,eAAe,QAAQ;AACvB,eAAe,QAAQ;AAEvB,uBAAuB,SAAS;AAChC,uBAAuB,YAAY;AACnC,uBAAuB,UAAU;AACjC,uBAAuB,WAAW;AAClC,uBAAuB,OAAO;AAC9B,uBAAuB,OAAO;AAC9B,uBAAuB,OAAO;AAE9B,IAAO,oBAAQ;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { PropTypesTypes, DocumentedPropType, ReactDescObjT, PropTypesObj } from './types.js';\n\nconst addPropTypeDocumentationField = <T extends keyof ReactDescObjT>(fieldName: T) =>\n function addFieldToReactDesc(this: DocumentedPropType, value: ReactDescObjT[T]): DocumentedPropType {\n if (!this.reactDesc) {\n this.reactDesc = {};\n }\n let realValue = value;\n if (\n fieldName === 'global' ||\n fieldName === 'dataTestId' ||\n fieldName === 'hidden' ||\n fieldName === 'xstyled' ||\n fieldName === 'omitValidation'\n )\n realValue = true;\n\n this.reactDesc[fieldName] = realValue;\n return this;\n };\n\nconst documentedPropType: Omit<DocumentedPropType, 'type' | 'isRequired' | 'reactDesc'> = {\n defaultValue: addPropTypeDocumentationField('defaultValue'),\n description: addPropTypeDocumentationField('description'),\n deprecated: addPropTypeDocumentationField('deprecated'),\n format: addPropTypeDocumentationField('format'),\n signature: addPropTypeDocumentationField('signature'),\n global: addPropTypeDocumentationField('global'),\n omitValidation: addPropTypeDocumentationField('omitValidation'),\n hidden: addPropTypeDocumentationField('hidden'),\n dataTestId: addPropTypeDocumentationField('dataTestId'),\n xstyled: addPropTypeDocumentationField('xstyled'),\n isRequiredIf: addPropTypeDocumentationField('isRequiredIf'),\n};\n\nconst createPropType = (type: PropTypesTypes) => {\n const propTypeObj = {\n type,\n ...documentedPropType,\n };\n Object.defineProperty(propTypeObj, 'isRequired', {\n get: function getRequired(this: DocumentedPropType) {\n if (!this.reactDesc) {\n this.reactDesc = {};\n }\n this.reactDesc.required = true;\n return this;\n },\n enumerable: true,\n configurable: true,\n });\n\n return propTypeObj;\n};\n\nconst createPropTypeWithArgs = (type: PropTypesTypes) => (args: unknown) => {\n const propTypeObj = {\n args,\n type,\n ...documentedPropType,\n };\n Object.defineProperty(propTypeObj, 'isRequired', {\n get: function getRequired(this: DocumentedPropType) {\n if (!this.reactDesc) {\n this.reactDesc = {};\n }\n this.reactDesc.required = true;\n return this;\n },\n enumerable: true,\n configurable: true,\n });\n return propTypeObj;\n};\n\nconst PropTypes = {\n custom: (callback: CallableFunction) => {\n const target = callback.bind(null) as CallableFunction & DocumentedPropType;\n target.type = 'func';\n Object.keys(documentedPropType).forEach((fieldName) => {\n const fieldNameCasted = fieldName as keyof DocumentedPropType;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n (target[fieldNameCasted] as unknown) = documentedPropType[fieldNameCasted] as unknown;\n });\n return target;\n },\n} as unknown as PropTypesObj;\n\nfunction definePropType(type: PropTypesTypes) {\n Object.defineProperty(PropTypes, type, {\n get: function getPropType() {\n return createPropType(type);\n },\n enumerable: true,\n configurable: true,\n });\n}\n\nfunction definePropTypeWithArgs(type: PropTypesTypes) {\n Object.defineProperty(PropTypes, type, {\n get: function getPropType() {\n return createPropTypeWithArgs(type);\n },\n enumerable: true,\n configurable: true,\n });\n}\n\ndefinePropType('any');\ndefinePropType('array');\ndefinePropType('bool');\ndefinePropType('element');\ndefinePropType('elementType');\ndefinePropType('func');\ndefinePropType('node');\ndefinePropType('number');\ndefinePropType('object');\ndefinePropType('symbol');\ndefinePropType('string');\n\ndefinePropTypeWithArgs('arrayOf');\ndefinePropTypeWithArgs('instanceOf');\ndefinePropTypeWithArgs('objectOf');\ndefinePropTypeWithArgs('oneOfType');\ndefinePropTypeWithArgs('oneOf');\ndefinePropTypeWithArgs('shape');\ndefinePropTypeWithArgs('tuple');\n\nexport default PropTypes;\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACEvB,MAAM,gCAAgC,CAAgC,cACpE,SAAS,oBAA8C,OAA6C;AAClG,MAAI,CAAC,KAAK,WAAW;AACnB,SAAK,YAAY,CAAC;AAAA,EACpB;AACA,MAAI,YAAY;AAChB,MACE,cAAc,YACd,cAAc,gBACd,cAAc,YACd,cAAc,aACd,cAAc;AAEd,gBAAY;AAEd,OAAK,UAAU,SAAS,IAAI;AAC5B,SAAO;AACT;AAEF,MAAM,qBAAoF;AAAA,EACxF,cAAc,8BAA8B,cAAc;AAAA,EAC1D,aAAa,8BAA8B,aAAa;AAAA,EACxD,YAAY,8BAA8B,YAAY;AAAA,EACtD,QAAQ,8BAA8B,QAAQ;AAAA,EAC9C,WAAW,8BAA8B,WAAW;AAAA,EACpD,QAAQ,8BAA8B,QAAQ;AAAA,EAC9C,gBAAgB,8BAA8B,gBAAgB;AAAA,EAC9D,QAAQ,8BAA8B,QAAQ;AAAA,EAC9C,YAAY,8BAA8B,YAAY;AAAA,EACtD,SAAS,8BAA8B,SAAS;AAAA,EAChD,cAAc,8BAA8B,cAAc;AAC5D;AAEA,MAAM,iBAAiB,CAAC,SAAyB;AAC/C,QAAM,cAAc;AAAA,IAClB;AAAA,IACA,GAAG;AAAA,EACL;AACA,SAAO,eAAe,aAAa,cAAc;AAAA,IAC/C,KAAK,SAAS,cAAsC;AAClD,UAAI,CAAC,KAAK,WAAW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aAAa;AAC5B,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,QAAQ;AACvB,eAAe,QAAQ;AACvB,eAAe,QAAQ;AACvB,eAAe,QAAQ;AAEvB,uBAAuB,SAAS;AAChC,uBAAuB,YAAY;AACnC,uBAAuB,UAAU;AACjC,uBAAuB,WAAW;AAClC,uBAAuB,OAAO;AAC9B,uBAAuB,OAAO;AAC9B,uBAAuB,OAAO;AAE9B,IAAO,oBAAQ;",
6
6
  "names": []
7
7
  }
@@ -12,7 +12,8 @@ const shapeFormat = (shape) => {
12
12
  } else {
13
13
  valueFormat = propTypeFormat(value);
14
14
  }
15
- return `${key}${value.reactDesc && value.reactDesc.required ? "" : "?"}: ${valueFormat}`;
15
+ const deprecatedMarker = value.reactDesc?.deprecated ? `/** @deprecated v${value.reactDesc.deprecated.version} */ ` : "";
16
+ return `${deprecatedMarker}${key}${value.reactDesc && value.reactDesc.required ? "" : "?"}: ${valueFormat}`;
16
17
  });
17
18
  return `{${props.join(",")}}`;
18
19
  };
@@ -47,6 +48,9 @@ const propTypeFormat = (propType, joinWith = "") => {
47
48
  case "element":
48
49
  result = "JSX.Element";
49
50
  break;
51
+ case "elementType":
52
+ result = "React.ComponentType<Record<string,unknown>>";
53
+ break;
50
54
  case "instanceOf":
51
55
  result = "any";
52
56
  break;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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 type React from 'react';\nimport type { ComponentDocumentation, Hook, ReactDescT, TypescriptDocumentation } from './types.js';\nimport { isReactDesc } from './describeGuards.js';\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 = propType?.reactDesc?.signature ?? '((...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, R>(\n component: React.ComponentType<C> | Hook<C, R>,\n reactDesc: ComponentDocumentation,\n) {\n if (!component) {\n throw new Error('react-desc: component is required');\n }\n\n const documentation: Partial<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 if (propType.type === 'shape') {\n propType.reactDesc.group = {};\n\n Object.keys(propType.args as Record<string, ReactDescT>).forEach((prop) => {\n if (!propType.reactDesc.group) return;\n propType.reactDesc.group[prop] = propTypeAsTypescript(\n (propType.args as Record<string, ReactDescT>)[prop],\n prop,\n );\n });\n }\n propTypes.push(propTypeAsTypescript(propType, propName));\n });\n if (propTypes.length > 0) {\n documentation.properties = propTypes;\n }\n }\n if (reactDesc.returnType) {\n if (isReactDesc(reactDesc.returnType)) {\n documentation.returns = propTypeAsTypescript(reactDesc.returnType, 'returns');\n } else {\n documentation.returns = Object.entries(reactDesc.returnType).map(([propName, propType]) =>\n propTypeAsTypescript(propType, propName),\n );\n }\n }\n }\n return documentation as TypescriptDocumentation;\n}\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACMvB,SAAS,mBAAmB;AAE5B,MAAM,cAAc,CAAC,UAAwB,MAAM,IAAI,CAAC,aAAa,eAAe,QAAQ,CAAC;AAE7F,MAAM,cAAc,CAAC,UAAsC;AACzD,QAAM,QAAQ,OAAO,KAAK,KAAK,EAAE,IAAI,CAAC,QAAQ;AAC5C,UAAM,QAAQ,MAAM,GAAG;AACvB,QAAI;AACJ,QACE,MAAM,SACL,MAAM,SAAS,aAAa,MAAM,SAAS,eAAe,MAAM,SAAS,YAC1E,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Y;AACxB,UAAI,YAAY,UAAU,UAAU,GAAG;AACrC,sBAAc,UAAU,qBAAqB,UAAU,YAAY,SAAS;AAAA,MAC9E,OAAO;AACL,sBAAc,UAAU,OAAO,QAAQ,UAAU,UAAU,EAAE;AAAA,UAAI,CAAC,CAAC,UAAU,QAAQ,MACnF,qBAAqB,UAAU,QAAQ;AAAA,QACzC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;",
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 type React from 'react';\nimport type { ComponentDocumentation, Hook, ReactDescT, TypescriptDocumentation } from './types.js';\nimport { isReactDesc } from './describeGuards.js';\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 const deprecatedMarker = value.reactDesc?.deprecated\n ? `/** @deprecated v${value.reactDesc.deprecated.version} */ `\n : '';\n return `${deprecatedMarker}${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 = propType?.reactDesc?.signature ?? '((...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 'elementType':\n result = 'React.ComponentType<Record<string,unknown>>';\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, R>(\n component: React.ComponentType<C> | Hook<C, R>,\n reactDesc: ComponentDocumentation,\n) {\n if (!component) {\n throw new Error('react-desc: component is required');\n }\n\n const documentation: Partial<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 if (propType.type === 'shape') {\n propType.reactDesc.group = {};\n\n Object.keys(propType.args as Record<string, ReactDescT>).forEach((prop) => {\n if (!propType.reactDesc.group) return;\n propType.reactDesc.group[prop] = propTypeAsTypescript(\n (propType.args as Record<string, ReactDescT>)[prop],\n prop,\n );\n });\n }\n propTypes.push(propTypeAsTypescript(propType, propName));\n });\n if (propTypes.length > 0) {\n documentation.properties = propTypes;\n }\n }\n if (reactDesc.returnType) {\n if (isReactDesc(reactDesc.returnType)) {\n documentation.returns = propTypeAsTypescript(reactDesc.returnType, 'returns');\n } else {\n documentation.returns = Object.entries(reactDesc.returnType).map(([propName, propType]) =>\n propTypeAsTypescript(propType, propName),\n );\n }\n }\n }\n return documentation as TypescriptDocumentation;\n}\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACMvB,SAAS,mBAAmB;AAE5B,MAAM,cAAc,CAAC,UAAwB,MAAM,IAAI,CAAC,aAAa,eAAe,QAAQ,CAAC;AAE7F,MAAM,cAAc,CAAC,UAAsC;AACzD,QAAM,QAAQ,OAAO,KAAK,KAAK,EAAE,IAAI,CAAC,QAAQ;AAC5C,UAAM,QAAQ,MAAM,GAAG;AACvB,QAAI;AACJ,QACE,MAAM,SACL,MAAM,SAAS,aAAa,MAAM,SAAS,eAAe,MAAM,SAAS,YAC1E,MAAM,QAAQ,MAAM,IAAI,GACxB;AACA,oBAAc,GAAG,eAAe,KAAK,CAAC;AAAA,IACxC,WAAW,MAAM,SAAS,SAAS;AACjC,oBAAc,GAAG,eAAe,KAAK,CAAC;AAAA,IACxC,OAAO;AACL,oBAAc,eAAe,KAAK;AAAA,IACpC;AACA,UAAM,mBAAmB,MAAM,WAAW,aACtC,oBAAoB,MAAM,UAAU,WAAW,OAAO,SACtD;AACJ,WAAO,GAAG,gBAAgB,GAAG,GAAG,GAAG,MAAM,aAAa,MAAM,UAAU,WAAW,KAAK,GAAG,KAAK,WAAW;AAAA,EAC3G,CAAC;AACD,SAAO,IAAI,MAAM,KAAK,GAAG,CAAC;AAC5B;AAEA,MAAM,iBAAiB,CAAC,UAAqC,WAAW,OAAe;AACrF,MAAI;AACJ,MAAI,MAAM,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) => !isUnion(format) && ["React.ReactNode", "JSX.Element"].includes(format);
35
+ const isReactComponentType = (format) => !isUnion(format) && format === "React.ComponentType<Record<string,unknown>>";
35
36
  const isSomethingWithParenthesis = (format) => !isUnion(format) && format[0] === "(" && format.slice(-1) === ")";
36
37
  export {
37
38
  isArray,
@@ -41,6 +42,7 @@ export {
41
42
  isObject,
42
43
  isObjectOf,
43
44
  isPrimitiveType,
45
+ isReactComponentType,
44
46
  isSomethingWithParenthesis,
45
47
  isString,
46
48
  isUndefined,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/validation/typescriptGuards.ts"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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 isObjectOf: GuardFn = (format) =>\n format !== 'object' && !isUnion(format) && format.startsWith('{ [key: string]: ');\n\nexport const isObject: GuardFn = (format) =>\n format === 'object' || (!isUnion(format) && format[0] === '{' && format.slice(-1) === '}');\n\nexport const isFunction: GuardFn = (format) => {\n // It's isn't an union\n if (isUnion(format)) return false;\n // Has to start with (( and end with )\n if (!format.startsWith('((') && format.slice(-1) !== ')') return false;\n\n // The arrow MUST occur at depth 1 (when couting parenthesis)\n // Otherwise the only possibility is that we have \"something with parenthesis\" (look down below)\n let depth = 0;\n let arrowOccursAtDepth1 = false;\n for (let i = 0; i < format.length; i += 1) {\n const char = format[i];\n if (['{', '('].includes(char)) depth += 1;\n else if (['}', ')'].includes(char)) depth -= 1;\n else if (i < format.length - 1 && format.slice(i, i + 2) === '=>') {\n arrowOccursAtDepth1 = arrowOccursAtDepth1 || depth === 1;\n }\n }\n return arrowOccursAtDepth1;\n};\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"],
5
- "mappings": "AAAA,YAAY,WAAW;ACEhB,MAAM,kBAA2B,CAAC,WAAW,CAAC,UAAU,UAAU,SAAS,EAAE,SAAS,MAAM;AAC5F,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,EAAE,EAAE,QAAQ,CAAC,SAAS;AACjC,QAAI,CAAC,KAAK,GAAG,EAAE,SAAS,IAAI,EAAG,UAAS;AAAA,aAC/B,CAAC,KAAK,GAAG,EAAE,SAAS,IAAI,EAAG,UAAS;AAAA,aACpC,SAAS,OAAO,UAAU,EAAG,aAAY;AAAA,EACpD,CAAC;AACD,SAAO;AACT;AAEO,MAAM,WAAoB,CAAC,WAAW,CAAC,QAAQ,MAAM,KAAK,OAAO,CAAC,MAAM,OAAO,OAAO,MAAM,EAAE,MAAM;AAEpG,MAAM,UAAmB,CAAC,WAAW,CAAC,QAAQ,MAAM,KAAK,OAAO,MAAM,EAAE,MAAM;AAE9E,MAAM,aAAsB,CAAC,WAClC,WAAW,YAAY,CAAC,QAAQ,MAAM,KAAK,OAAO,WAAW,mBAAmB;AAE3E,MAAM,WAAoB,CAAC,WAChC,WAAW,YAAa,CAAC,QAAQ,MAAM,KAAK,OAAO,CAAC,MAAM,OAAO,OAAO,MAAM,EAAE,MAAM;AAEjF,MAAM,aAAsB,CAAC,WAAW;AAE7C,MAAI,QAAQ,MAAM,EAAG,QAAO;AAE5B,MAAI,CAAC,OAAO,WAAW,IAAI,KAAK,OAAO,MAAM,EAAE,MAAM,IAAK,QAAO;AAIjE,MAAI,QAAQ;AACZ,MAAI,sBAAsB;AAC1B,WAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK,GAAG;AACzC,UAAM,OAAO,OAAO,CAAC;AACrB,QAAI,CAAC,KAAK,GAAG,EAAE,SAAS,IAAI,EAAG,UAAS;AAAA,aAC/B,CAAC,KAAK,GAAG,EAAE,SAAS,IAAI,EAAG,UAAS;AAAA,aACpC,IAAI,OAAO,SAAS,KAAK,OAAO,MAAM,GAAG,IAAI,CAAC,MAAM,MAAM;AACjE,4BAAsB,uBAAuB,UAAU;AAAA,IACzD;AAAA,EACF;AACA,SAAO;AACT;AAEO,MAAM,cAAuB,CAAC,WAAW,CAAC,QAAQ,MAAM,KAAK,CAAC,mBAAmB,aAAa,EAAE,SAAS,MAAM;AAE/G,MAAM,6BAAsC,CAAC,WAClD,CAAC,QAAQ,MAAM,KAAK,OAAO,CAAC,MAAM,OAAO,OAAO,MAAM,EAAE,MAAM;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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 isObjectOf: GuardFn = (format) =>\n format !== 'object' && !isUnion(format) && format.startsWith('{ [key: string]: ');\n\nexport const isObject: GuardFn = (format) =>\n format === 'object' || (!isUnion(format) && format[0] === '{' && format.slice(-1) === '}');\n\nexport const isFunction: GuardFn = (format) => {\n // It's isn't an union\n if (isUnion(format)) return false;\n // Has to start with (( and end with )\n if (!format.startsWith('((') && format.slice(-1) !== ')') return false;\n\n // The arrow MUST occur at depth 1 (when couting parenthesis)\n // Otherwise the only possibility is that we have \"something with parenthesis\" (look down below)\n let depth = 0;\n let arrowOccursAtDepth1 = false;\n for (let i = 0; i < format.length; i += 1) {\n const char = format[i];\n if (['{', '('].includes(char)) depth += 1;\n else if (['}', ')'].includes(char)) depth -= 1;\n else if (i < format.length - 1 && format.slice(i, i + 2) === '=>') {\n arrowOccursAtDepth1 = arrowOccursAtDepth1 || depth === 1;\n }\n }\n return arrowOccursAtDepth1;\n};\n\nexport const isJSXorNode: GuardFn = (format) => !isUnion(format) && ['React.ReactNode', 'JSX.Element'].includes(format);\n\nexport const isReactComponentType: GuardFn = (format) =>\n !isUnion(format) && format === 'React.ComponentType<Record<string,unknown>>';\n\nexport const isSomethingWithParenthesis: GuardFn = (format) =>\n !isUnion(format) && format[0] === '(' && format.slice(-1) === ')';\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACEhB,MAAM,kBAA2B,CAAC,WAAW,CAAC,UAAU,UAAU,SAAS,EAAE,SAAS,MAAM;AAC5F,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,EAAE,EAAE,QAAQ,CAAC,SAAS;AACjC,QAAI,CAAC,KAAK,GAAG,EAAE,SAAS,IAAI,EAAG,UAAS;AAAA,aAC/B,CAAC,K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BAAsC,CAAC,WAClD,CAAC,QAAQ,MAAM,KAAK,OAAO,CAAC,MAAM,OAAO,OAAO,MAAM,EAAE,MAAM;",
6
6
  "names": []
7
7
  }
@@ -7,6 +7,7 @@ import {
7
7
  isFunction,
8
8
  isJSXorNode,
9
9
  isObject,
10
+ isReactComponentType,
10
11
  isPrimitiveType,
11
12
  isSomethingWithParenthesis,
12
13
  isString,
@@ -148,6 +149,8 @@ const validateValueWithFormat = (schemaName, key, value, format, validationsMemo
148
149
  validateObject(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
149
150
  } else if (isFunction(format)) {
150
151
  validateFunction(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
152
+ } else if (isReactComponentType(format)) {
153
+ validateFunction(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
151
154
  } else if (isJSXorNode(format)) {
152
155
  validateJSXorNode(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
153
156
  } else if (isSomethingWithParenthesis(format)) {
@@ -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 type { PropsWithChildren, WeakValidationMap } from 'react';\nimport { useMemo, useRef } from 'react';\nimport type { TypescriptDocumentation } from '../propTypes/types.js';\nimport { describe } from '../propTypes/index.js';\nimport { throwRequiredError, throwTypeError } from './errorTemplates.js';\nimport {\n isArray,\n isFunction,\n isJSXorNode,\n isObject,\n isPrimitiveType,\n isSomethingWithParenthesis,\n isString,\n isUnion,\n isUndefined,\n isNull,\n isObjectOf,\n} from './typescriptGuards.js';\nimport { typescriptObjectParser } from './typescriptParsers.js';\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): value is Record<string, unknown> {\n return !(typeof value !== 'object' || Array.isArray(value));\n}\n\nconst validateObjectOf: 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 const valuesFormat = format.slice('{ [key: string]: '.length, -2);\n\n Object.keys(value).forEach((objectKey) => {\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}[${objectKey}]`,\n value[objectKey],\n valuesFormat,\n validationsMemo,\n nextValidationsMemo,\n );\n });\n};\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, trueKey);\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): 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 (isObjectOf(format)) {\n validateObjectOf(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: TypescriptDocumentation,\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, isRequiredIf, omitValidation } = property;\n\n const requiredConditionally = isRequiredIf && isRequiredIf(props);\n\n if (omitValidation) {\n return;\n }\n\n if (required && !(name in props)) {\n throwRequiredError(schema.name, name);\n }\n\n if (requiredConditionally && !(name in props)) {\n throwRequiredError(schema.name, name);\n }\n\n const shouldValidateProperty = props[name] !== undefined || required || requiredConditionally;\n\n if (name in props && format && shouldValidateProperty) {\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 propTypes: WeakValidationMap<unknown>,\n componentDisplayName: string,\n): void => {\n if (!componentDisplayName) {\n throw new Error('Provide display name for the component to use for validation');\n }\n\n const validationsMemo = useRef<Record<string, string>>({});\n\n const typescriptSchema = useMemo(() => {\n const Component = () => {};\n\n const DescribedComponent = describe(Component);\n DescribedComponent.propTypes = propTypes;\n DescribedComponent.displayName = componentDisplayName;\n return DescribedComponent.toTypescript();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [propTypes]);\n\n useMemo(() => {\n const nextValidationsMemo = {};\n\n validateTypescriptPropTypesImplementation(props, typescriptSchema, validationsMemo.current, nextValidationsMemo);\n validationsMemo.current = nextValidationsMemo;\n return 'WE DONT NEED RETURN just the memo';\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [props]);\n};\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACIvB,SAAS,SAAS,cAAc;AAEhC,SAAS,gBAAgB;AACzB,SAAS,oBAAoB,sBAAsB;AACnD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,8BAA8B;AAmBvC,MAAM,oBAAiC,CAAC,YAAY,KAAK,OAAO,WAAW;AACzE,MAAI,UAAU,UAAa,UAAU,aAAa;AAChD,mBAAe,YAAY,KAAK,OAAO,MAAM;AAAA,EAC/C;AACF;AACA,MAAM,eAA4B,CAAC,YAAY,KAAK,OAAO,WAAW;AACpE,MAAI,UAAU,QAAQ,UAAU,QAAQ;AACtC,mBAAe,YAAY,KAAK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C,OAAO,kBAAkB,gBAAgB,SAAS,mBAAmB;AAC/G,oBAAgB,UAAU;AAC1B,WAAO;AAAA,EAET,GAAG,CAAC,KAAK,CAAC;AACZ;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\n/* eslint-disable max-lines */\n/* eslint-disable max-params */\nimport type { PropsWithChildren, WeakValidationMap } from 'react';\nimport { useMemo, useRef } from 'react';\nimport type { TypescriptDocumentation } from '../propTypes/types.js';\nimport { describe } from '../propTypes/index.js';\nimport { throwRequiredError, throwTypeError } from './errorTemplates.js';\nimport {\n isArray,\n isFunction,\n isJSXorNode,\n isObject,\n isReactComponentType,\n isPrimitiveType,\n isSomethingWithParenthesis,\n isString,\n isUnion,\n isUndefined,\n isNull,\n isObjectOf,\n} from './typescriptGuards.js';\nimport { typescriptObjectParser } from './typescriptParsers.js';\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): value is Record<string, unknown> {\n return !(typeof value !== 'object' || Array.isArray(value));\n}\n\nconst validateObjectOf: 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 const valuesFormat = format.slice('{ [key: string]: '.length, -2);\n\n Object.keys(value).forEach((objectKey) => {\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}[${objectKey}]`,\n value[objectKey],\n valuesFormat,\n validationsMemo,\n nextValidationsMemo,\n );\n });\n};\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, trueKey);\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): 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 (isObjectOf(format)) {\n validateObjectOf(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 (isReactComponentType(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: TypescriptDocumentation,\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, isRequiredIf, omitValidation } = property;\n\n const requiredConditionally = isRequiredIf && isRequiredIf(props);\n\n if (omitValidation) {\n return;\n }\n\n if (required && !(name in props)) {\n throwRequiredError(schema.name, name);\n }\n\n if (requiredConditionally && !(name in props)) {\n throwRequiredError(schema.name, name);\n }\n\n const shouldValidateProperty = props[name] !== undefined || required || requiredConditionally;\n\n if (name in props && format && shouldValidateProperty) {\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 propTypes: WeakValidationMap<unknown>,\n componentDisplayName: string,\n): void => {\n if (!componentDisplayName) {\n throw new Error('Provide display name for the component to use for validation');\n }\n\n const validationsMemo = useRef<Record<string, string>>({});\n\n const typescriptSchema = useMemo(() => {\n const Component = () => {};\n\n const DescribedComponent = describe(Component);\n DescribedComponent.propTypes = propTypes;\n DescribedComponent.displayName = componentDisplayName;\n return DescribedComponent.toTypescript();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [propTypes]);\n\n useMemo(() => {\n const nextValidationsMemo = {};\n\n validateTypescriptPropTypesImplementation(props, typescriptSchema, validationsMemo.current, nextValidationsMemo);\n validationsMemo.current = nextValidationsMemo;\n return 'WE DONT NEED RETURN just the memo';\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [props]);\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACIvB,SAAS,SAAS,cAAc;AAEhC,SAAS,gBAAgB;AACzB,SAAS,oBAAoB,sBAAsB;AACnD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,8BAA8B;AAmBvC,MAAM,oBAAiC,CAAC,YAAY,KAAK,OAAO,WAAW;AACzE,MAAI,UAAU,UAAa,UAAU,aAAa;AAChD,mBAAe,YAAY,KAAK,OAAO,MAAM;AAAA,EAC/C;AACF;AACA,MAAM,eAA4B,CAAC,YAAY,KAAK,OAAO,WAAW;AACpE,MAAI,UAAU,QAAQ,UAAU,QAAQ;AACtC,mBAAe,YAAY,KAAK,OAAO,MAAM;AAAA,EAC/C;AACF;AACA,MAAM,wBAAqC,CAAC,YAAY,KAAK,OAAO,WAAW;AAC7E,MAAI,OAAO,UAAU,QAAQ;AAC3B,mBAAe,YAAY,KAAK,OAAO,MAAM;AAAA,EAC/C;AACF;AAEA,MAAM,iBAA8B,CAAC,YAAY,KAAK,OAAO,WAAW;AACtE,MAAI,UAAU,OAAO,MAAM,GAAG,EAAE,GAAG;AACjC,mBAAe,YAAY,KAAK,OAAO,MAAM;AAAA,EAC/C;AACF;AAEA,MAAM,gBAA6B,CAAC,YAAY,KAAK,OAAO,QAAQ,iBAAiB,wBAAwB;AAE3G,MAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;AACzB,mBAAe,YAAY,KAAK,OAAO,MAAM;AAAA,EAC/C;AAGA,EAAC,MAAoB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EhE,QAAI,gBAAgB;AAClB;AAAA,IACF;AAEA,QAAI,YAAY,EAAE,QAAQ,QAAQ;AAChC,yBAAmB,OAAO,MAAM,IAAI;AAAA,IACtC;AAEA,QAAI,yBAAyB,EAAE,QAAQ,QAAQ;AAC7C,yBAAmB,OAAO,MAAM,IAAI;AAAA,IACtC;AAEA,UAAM,yBAAyB,MAAM,IAAI,MAAM,UAAa,YAAY;AAExE,QAAI,QAAQ,SAAS,UAAU,wBAAwB;AACrD,8BAAwB,YAAY,MAAM,MAAM,IAAI,GAAG,QAAQ,iBAAiB,mBAAmB;AAAA,IACrG;AAAA,EACF,CAAC;AACH;AAGO,MAAM,iCAAiC,CAC5C,OACA,WACA,yBACS;AACT,MAAI,CAAC,sBAAsB;AACzB,UAAM,IAAI,MAAM,8DAA8D;AAAA,EAChF;AAEA,QAAM,kBAAkB,OAA+B,CAAC,CAAC;AAEzD,QAAM,mBAAmB,QAAQ,MAAM;AACrC,UAAM,YAAY,MAAM;AAAA,IAAC;AAEzB,UAAM,qBAAqB,SAAS,SAAS;AAC7C,uBAAmB,YAAY;AAC/B,uBAAmB,cAAc;AACjC,WAAO,mBAAmB,aAAa;AAAA,EAEzC,GAAG,CAAC,SAAS,CAAC;AAEd,UAAQ,MAAM;AACZ,UAAM,sBAAsB,CAAC;AAE7B,8CAA0C,OAAO,kBAAkB,gBAAgB,SAAS,mBAAmB;AAC/G,oBAAgB,UAAU;AAC1B,WAAO;AAAA,EAET,GAAG,CAAC,KAAK,CAAC;AACZ;",
6
6
  "names": []
7
7
  }
@@ -9,5 +9,6 @@ export declare const isObjectOf: GuardFn;
9
9
  export declare const isObject: GuardFn;
10
10
  export declare const isFunction: GuardFn;
11
11
  export declare const isJSXorNode: GuardFn;
12
+ export declare const isReactComponentType: GuardFn;
12
13
  export declare const isSomethingWithParenthesis: GuardFn;
13
14
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-props-helpers",
3
- "version": "3.70.0-next.4",
3
+ "version": "3.70.0-next.41",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Props Helpers",
6
6
  "files": [
@@ -35,15 +35,15 @@
35
35
  "dependencies": {
36
36
  "fast-deep-equal": "~3.1.3",
37
37
  "prop-types": "~15.8.1",
38
- "@elliemae/ds-system": "3.70.0-next.4",
39
- "@elliemae/ds-typescript-helpers": "3.70.0-next.4"
38
+ "@elliemae/ds-system": "3.70.0-next.41",
39
+ "@elliemae/ds-typescript-helpers": "3.70.0-next.41"
40
40
  },
41
41
  "devDependencies": {
42
42
  "jest": "^30.0.0",
43
- "@elliemae/ds-monorepo-devops": "3.70.0-next.4"
43
+ "@elliemae/ds-monorepo-devops": "3.70.0-next.41"
44
44
  },
45
45
  "peerDependencies": {
46
- "lodash-es": "^4.17.21",
46
+ "lodash-es": "^4.18.1",
47
47
  "react": "^18.3.1",
48
48
  "react-dom": "^18.3.1"
49
49
  },
@@ -1 +0,0 @@
1
- export function TestComponent(props: any): import("react/jsx-runtime").JSX.Element;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export const TypescriptSchema: import("../../propTypes/types.js").TypescriptDocumentation;
@@ -1 +0,0 @@
1
- export function TestComponent(props: any): import("react/jsx-runtime").JSX.Element;
@@ -1 +0,0 @@
1
- export {};