@elliemae/ds-props-helpers 2.3.1 → 3.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/dist/cjs/defaultProps/index.js +28 -0
  2. package/dist/cjs/defaultProps/index.js.map +7 -0
  3. package/dist/cjs/defaultProps/useMemoMergePropsWithDefault.js +62 -0
  4. package/dist/cjs/defaultProps/useMemoMergePropsWithDefault.js.map +7 -0
  5. package/dist/cjs/getProps/index.js +37 -0
  6. package/dist/cjs/getProps/index.js.map +7 -0
  7. package/dist/cjs/globalProps/constants.js +397 -0
  8. package/dist/cjs/globalProps/constants.js.map +7 -0
  9. package/dist/cjs/globalProps/globalAttributesPropTypes.js +398 -0
  10. package/dist/cjs/globalProps/globalAttributesPropTypes.js.map +7 -0
  11. package/dist/cjs/globalProps/index.js +29 -0
  12. package/dist/cjs/globalProps/index.js.map +7 -0
  13. package/dist/cjs/globalProps/useGetGlobalAttributes.js +56 -0
  14. package/dist/cjs/globalProps/useGetGlobalAttributes.js.map +7 -0
  15. package/dist/cjs/index.js +33 -0
  16. package/dist/cjs/index.js.map +7 -0
  17. package/dist/cjs/propTypes/PropTypes.js +149 -0
  18. package/dist/cjs/propTypes/PropTypes.js.map +7 -0
  19. package/dist/cjs/propTypes/customPropTypes.js +38 -0
  20. package/dist/cjs/propTypes/customPropTypes.js.map +7 -0
  21. package/dist/cjs/propTypes/describe.js +81 -0
  22. package/dist/cjs/propTypes/describe.js.map +7 -0
  23. package/dist/cjs/propTypes/describeConversions.js +96 -0
  24. package/dist/cjs/propTypes/describeConversions.js.map +7 -0
  25. package/dist/cjs/propTypes/describeGuards.js +49 -0
  26. package/dist/cjs/propTypes/describeGuards.js.map +7 -0
  27. package/dist/cjs/propTypes/index.js +37 -0
  28. package/dist/cjs/propTypes/index.js.map +7 -0
  29. package/dist/cjs/propTypes/toTypescript.js +154 -0
  30. package/dist/cjs/propTypes/toTypescript.js.map +7 -0
  31. package/dist/cjs/propTypes/types.js +27 -0
  32. package/dist/cjs/propTypes/types.js.map +7 -0
  33. package/dist/cjs/tests/globalProps/TestComponent.js +54 -0
  34. package/dist/cjs/tests/globalProps/TestComponent.js.map +7 -0
  35. package/dist/cjs/tests/validation/test.schema.js +67 -0
  36. package/dist/cjs/tests/validation/test.schema.js.map +7 -0
  37. package/dist/cjs/validation/errorTemplates.js +48 -0
  38. package/dist/cjs/validation/errorTemplates.js.map +7 -0
  39. package/dist/cjs/validation/index.js +30 -0
  40. package/dist/cjs/validation/index.js.map +7 -0
  41. package/dist/cjs/validation/typescriptGuards.js +65 -0
  42. package/dist/cjs/validation/typescriptGuards.js.map +7 -0
  43. package/dist/cjs/validation/typescriptParsers.js +76 -0
  44. package/dist/cjs/validation/typescriptParsers.js.map +7 -0
  45. package/dist/cjs/validation/typescriptValidator.js +171 -0
  46. package/dist/cjs/validation/typescriptValidator.js.map +7 -0
  47. package/dist/cjs/validation/validator.js +55 -0
  48. package/dist/cjs/validation/validator.js.map +7 -0
  49. package/dist/cjs/xstyledProps/constants.js +88 -0
  50. package/dist/cjs/xstyledProps/constants.js.map +7 -0
  51. package/dist/cjs/xstyledProps/index.js +29 -0
  52. package/dist/cjs/xstyledProps/index.js.map +7 -0
  53. package/dist/cjs/xstyledProps/useGetXstyledProps.js +48 -0
  54. package/dist/cjs/xstyledProps/useGetXstyledProps.js.map +7 -0
  55. package/dist/cjs/xstyledProps/xstyledPropTypes.js +92 -0
  56. package/dist/cjs/xstyledProps/xstyledPropTypes.js.map +7 -0
  57. package/dist/esm/defaultProps/index.js +3 -0
  58. package/dist/esm/defaultProps/index.js.map +7 -0
  59. package/dist/esm/defaultProps/useMemoMergePropsWithDefault.js +35 -0
  60. package/dist/esm/defaultProps/useMemoMergePropsWithDefault.js.map +7 -0
  61. package/dist/esm/getProps/index.js +8 -0
  62. package/dist/esm/getProps/index.js.map +7 -0
  63. package/dist/esm/globalProps/constants.js +368 -0
  64. package/dist/esm/globalProps/constants.js.map +7 -0
  65. package/{esm → dist/esm}/globalProps/globalAttributesPropTypes.js +58 -67
  66. package/dist/esm/globalProps/globalAttributesPropTypes.js.map +7 -0
  67. package/dist/esm/globalProps/index.js +4 -0
  68. package/dist/esm/globalProps/index.js.map +7 -0
  69. package/dist/esm/globalProps/useGetGlobalAttributes.js +27 -0
  70. package/dist/esm/globalProps/useGetGlobalAttributes.js.map +7 -0
  71. package/dist/esm/index.js +8 -0
  72. package/dist/esm/index.js.map +7 -0
  73. package/dist/esm/propTypes/PropTypes.js +122 -0
  74. package/dist/esm/propTypes/PropTypes.js.map +7 -0
  75. package/dist/esm/propTypes/customPropTypes.js +9 -0
  76. package/dist/esm/propTypes/customPropTypes.js.map +7 -0
  77. package/dist/esm/propTypes/describe.js +52 -0
  78. package/dist/esm/propTypes/describe.js.map +7 -0
  79. package/dist/esm/propTypes/describeConversions.js +76 -0
  80. package/dist/esm/propTypes/describeConversions.js.map +7 -0
  81. package/dist/esm/propTypes/describeGuards.js +20 -0
  82. package/dist/esm/propTypes/describeGuards.js.map +7 -0
  83. package/dist/esm/propTypes/index.js +8 -0
  84. package/dist/esm/propTypes/index.js.map +7 -0
  85. package/dist/esm/propTypes/toTypescript.js +127 -0
  86. package/dist/esm/propTypes/toTypescript.js.map +7 -0
  87. package/dist/esm/propTypes/types.js +2 -0
  88. package/dist/esm/propTypes/types.js.map +7 -0
  89. package/dist/esm/tests/globalProps/TestComponent.js +27 -0
  90. package/dist/esm/tests/globalProps/TestComponent.js.map +7 -0
  91. package/dist/esm/tests/validation/test.schema.js +38 -0
  92. package/dist/esm/tests/validation/test.schema.js.map +7 -0
  93. package/dist/esm/validation/errorTemplates.js +19 -0
  94. package/dist/esm/validation/errorTemplates.js.map +7 -0
  95. package/dist/esm/validation/index.js +5 -0
  96. package/dist/esm/validation/index.js.map +7 -0
  97. package/dist/esm/validation/typescriptGuards.js +36 -0
  98. package/dist/esm/validation/typescriptGuards.js.map +7 -0
  99. package/dist/esm/validation/typescriptParsers.js +47 -0
  100. package/dist/esm/validation/typescriptParsers.js.map +7 -0
  101. package/dist/esm/validation/typescriptValidator.js +153 -0
  102. package/dist/esm/validation/typescriptValidator.js.map +7 -0
  103. package/dist/esm/validation/validator.js +26 -0
  104. package/dist/esm/validation/validator.js.map +7 -0
  105. package/dist/esm/xstyledProps/constants.js +59 -0
  106. package/dist/esm/xstyledProps/constants.js.map +7 -0
  107. package/dist/esm/xstyledProps/index.js +4 -0
  108. package/dist/esm/xstyledProps/index.js.map +7 -0
  109. package/dist/esm/xstyledProps/useGetXstyledProps.js +19 -0
  110. package/dist/esm/xstyledProps/useGetXstyledProps.js.map +7 -0
  111. package/dist/esm/xstyledProps/xstyledPropTypes.js +63 -0
  112. package/dist/esm/xstyledProps/xstyledPropTypes.js.map +7 -0
  113. package/package.json +72 -81
  114. package/cjs/defaultProps/index.js +0 -9
  115. package/cjs/defaultProps/useMemoMergePropsWithDefault.js +0 -48
  116. package/cjs/getProps/index.js +0 -20
  117. package/cjs/globalProps/constants.js +0 -16
  118. package/cjs/globalProps/globalAttributesPropTypes.js +0 -382
  119. package/cjs/globalProps/index.js +0 -11
  120. package/cjs/globalProps/useGetGlobalAttributes.js +0 -37
  121. package/cjs/index.js +0 -32
  122. package/cjs/propTypes/PropTypes.js +0 -131
  123. package/cjs/propTypes/customPropTypes.js +0 -21
  124. package/cjs/propTypes/describe.js +0 -64
  125. package/cjs/propTypes/describeConversions.js +0 -104
  126. package/cjs/propTypes/describeGuards.js +0 -21
  127. package/cjs/propTypes/index.js +0 -11
  128. package/cjs/propTypes/toTypescript.js +0 -160
  129. package/cjs/propTypes/types.js +0 -2
  130. package/cjs/validation/errorTemplates.js +0 -16
  131. package/cjs/validation/index.js +0 -15
  132. package/cjs/validation/typescriptGuards.js +0 -36
  133. package/cjs/validation/typescriptParsers.js +0 -45
  134. package/cjs/validation/typescriptValidator.js +0 -208
  135. package/cjs/validation/validator.js +0 -36
  136. package/cjs/xstyledProps/constants.js +0 -21
  137. package/cjs/xstyledProps/index.js +0 -11
  138. package/cjs/xstyledProps/useGetXstyledProps.js +0 -27
  139. package/cjs/xstyledProps/xstyledPropTypes.js +0 -75
  140. package/esm/defaultProps/index.js +0 -1
  141. package/esm/defaultProps/useMemoMergePropsWithDefault.js +0 -39
  142. package/esm/getProps/index.js +0 -15
  143. package/esm/globalProps/constants.js +0 -12
  144. package/esm/globalProps/index.js +0 -2
  145. package/esm/globalProps/useGetGlobalAttributes.js +0 -33
  146. package/esm/index.js +0 -11
  147. package/esm/propTypes/PropTypes.js +0 -125
  148. package/esm/propTypes/customPropTypes.js +0 -17
  149. package/esm/propTypes/describe.js +0 -62
  150. package/esm/propTypes/describeConversions.js +0 -96
  151. package/esm/propTypes/describeGuards.js +0 -10
  152. package/esm/propTypes/index.js +0 -2
  153. package/esm/propTypes/toTypescript.js +0 -154
  154. package/esm/propTypes/types.js +0 -1
  155. package/esm/validation/errorTemplates.js +0 -11
  156. package/esm/validation/index.js +0 -3
  157. package/esm/validation/typescriptGuards.js +0 -23
  158. package/esm/validation/typescriptParsers.js +0 -41
  159. package/esm/validation/typescriptValidator.js +0 -203
  160. package/esm/validation/validator.js +0 -32
  161. package/esm/xstyledProps/constants.js +0 -16
  162. package/esm/xstyledProps/index.js +0 -2
  163. package/esm/xstyledProps/useGetXstyledProps.js +0 -23
  164. package/esm/xstyledProps/xstyledPropTypes.js +0 -71
  165. package/types/defaultProps/index.d.ts +0 -1
  166. package/types/defaultProps/useMemoMergePropsWithDefault.d.ts +0 -1
  167. package/types/getProps/index.d.ts +0 -2
  168. package/types/globalProps/constants.d.ts +0 -3
  169. package/types/globalProps/globalAttributesPropTypes.d.ts +0 -363
  170. package/types/globalProps/index.d.ts +0 -2
  171. package/types/globalProps/useGetGlobalAttributes.d.ts +0 -4
  172. package/types/index.d.ts +0 -6
  173. package/types/propTypes/PropTypes.d.ts +0 -3
  174. package/types/propTypes/customPropTypes.d.ts +0 -2
  175. package/types/propTypes/describe.d.ts +0 -3
  176. package/types/propTypes/describeConversions.d.ts +0 -3
  177. package/types/propTypes/describeGuards.d.ts +0 -9
  178. package/types/propTypes/index.d.ts +0 -3
  179. package/types/propTypes/toTypescript.d.ts +0 -3
  180. package/types/propTypes/types.d.ts +0 -99
  181. package/types/tests/globalProps/TestComponent.d.ts +0 -1
  182. package/types/tests/globalProps/globalAttributes.test.d.ts +0 -1
  183. package/types/tests/validation/any.validation.test.d.ts +0 -1
  184. package/types/tests/validation/array.validation.test.d.ts +0 -1
  185. package/types/tests/validation/boolean.validation.test.d.ts +0 -1
  186. package/types/tests/validation/function.validation.test.d.ts +0 -1
  187. package/types/tests/validation/number.validation.test.d.ts +0 -1
  188. package/types/tests/validation/object.validation.test.d.ts +0 -1
  189. package/types/tests/validation/schema.validation.test.d.ts +0 -1
  190. package/types/tests/validation/string.validation.test.d.ts +0 -1
  191. package/types/tests/validation/test.schema.d.ts +0 -1
  192. package/types/tests/validation/union.validation.test.d.ts +0 -1
  193. package/types/validation/errorTemplates.d.ts +0 -2
  194. package/types/validation/index.d.ts +0 -3
  195. package/types/validation/typescriptGuards.d.ts +0 -12
  196. package/types/validation/typescriptParsers.d.ts +0 -1
  197. package/types/validation/typescriptValidator.d.ts +0 -15
  198. package/types/validation/validator.d.ts +0 -1
  199. package/types/xstyledProps/constants.d.ts +0 -2
  200. package/types/xstyledProps/index.d.ts +0 -2
  201. package/types/xstyledProps/useGetXstyledProps.d.ts +0 -5
  202. package/types/xstyledProps/xstyledPropTypes.d.ts +0 -57
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/propTypes/toTypescript.ts"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/restrict-template-expressions */\n/* eslint-disable @typescript-eslint/no-use-before-define */\n/* eslint-disable complexity */\n/* eslint-disable react/forbid-foreign-prop-types */\nimport React from 'react';\nimport { ComponentDocumentation, ReactDescT, TypescriptDocumentation } from './types';\n\nconst arrayFormat = (array: ReactDescT[]) => array.map((propType) => propTypeFormat(propType));\n\nconst shapeFormat = (shape: Record<string, ReactDescT>) => {\n const props = Object.keys(shape).map((key) => {\n const value = shape[key];\n let valueFormat;\n if (\n value.type &&\n (value.type === 'arrayOf' || value.type === 'oneOfType' || value.type === 'oneOf') &&\n Array.isArray(value.args)\n ) {\n valueFormat = `${propTypeFormat(value)}`;\n } else if (value.type === 'shape') {\n valueFormat = `${propTypeFormat(value)}`;\n } else {\n valueFormat = propTypeFormat(value);\n }\n return `${key}${value.reactDesc && value.reactDesc.required ? '' : '?'}: ${valueFormat}`;\n });\n return `{${props.join(',')}}`;\n};\n\nconst propTypeFormat = (propType: ReactDescT | ReactDescT[], joinWith = ''): string => {\n let result;\n if (Array.isArray(propType)) {\n result = arrayFormat(propType).join(joinWith);\n } else if (typeof propType !== 'function' && propType.type) {\n switch (propType.type) {\n case 'array':\n result = 'any[]';\n break;\n case 'arrayOf':\n if ((propType.args as ReactDescT).type === 'oneOfType') {\n result = `(${propTypeFormat(propType.args as ReactDescT, ' | ')})[]`;\n } else {\n result = `${propTypeFormat(propType.args as ReactDescT, '\\n')}[]`;\n }\n break;\n case 'tuple':\n result = `[${propTypeFormat(propType.args as ReactDescT, ', ')}]`;\n break;\n case 'bool':\n result = 'boolean';\n break;\n case 'func':\n result = '((...args: any[]) => any)';\n break;\n case 'node':\n result = 'React.ReactNode';\n break;\n case 'element':\n result = 'JSX.Element';\n break;\n case 'instanceOf':\n result = 'any';\n break;\n case 'symbol':\n result = 'any';\n break;\n case 'objectOf':\n result = `{ [key: string]: ${propTypeFormat(propType.args as ReactDescT)} }`;\n break;\n case 'oneOf':\n result = (propType.args as unknown[]).map((a) => `\"${a}\"`).join(' | ');\n break;\n case 'oneOfType':\n result = `${propTypeFormat(propType.args as ReactDescT[], ' | ')}`;\n break;\n case 'shape':\n result = `${shapeFormat(propType.args as Record<string, ReactDescT>)}`;\n break;\n default:\n result = `${propType.type}`;\n break;\n }\n } else {\n result = 'any';\n }\n return result;\n};\n\nconst propTypeAsTypescript = (propType: ReactDescT, propName: string) => {\n const documentation = {\n ...propType.reactDesc,\n name: propName,\n };\n\n documentation.format = propTypeFormat(propType);\n\n return documentation;\n};\n\nexport default function descToTypescript<C>(component: React.ComponentType<C>, reactDesc: ComponentDocumentation) {\n if (!component) {\n throw new Error('react-desc: component is required');\n }\n\n const documentation: TypescriptDocumentation = {\n name: component.displayName || component.name,\n ...reactDesc,\n };\n if (reactDesc) {\n delete documentation.propTypes;\n\n if (reactDesc.propTypes) {\n const propTypes: TypescriptDocumentation['properties'] = [];\n Object.keys(reactDesc.propTypes).forEach((propName) => {\n const propType = reactDesc.propTypes[propName];\n propTypes.push(propTypeAsTypescript(propType, propName));\n });\n if (propTypes.length > 0) {\n documentation.properties = propTypes;\n }\n }\n }\n return documentation;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACOA,MAAM,cAAc,CAAC,UAAwB,MAAM,IAAI,CAAC,aAAa,eAAe;AAEpF,MAAM,cAAc,CAAC,UAAsC;AACzD,QAAM,QAAQ,OAAO,KAAK,OAAO,IAAI,CAAC,QAAQ;AAC5C,UAAM,QAAQ,MAAM;AACpB,QAAI;AACJ,QACE,MAAM,QACL,OAAM,SAAS,aAAa,MAAM,SAAS,eAAe,MAAM,SAAS,YAC1E,MAAM,QAAQ,MAAM,OACpB;AACA,oBAAc,GAAG,eAAe;AAAA,eACvB,MAAM,SAAS,SAAS;AACjC,oBAAc,GAAG,eAAe;AAAA,WAC3B;AACL,oBAAc,eAAe;AAAA;AAE/B,WAAO,GAAG,MAAM,MAAM,aAAa,MAAM,UAAU,WAAW,KAAK,QAAQ;AAAA;AAE7E,SAAO,IAAI,MAAM,KAAK;AAAA;AAGxB,MAAM,iBAAiB,CAAC,UAAqC,WAAW,OAAe;AACrF,MAAI;AACJ,MAAI,MAAM,QAAQ,WAAW;AAC3B,aAAS,YAAY,UAAU,KAAK;AAAA,aAC3B,OAAO,aAAa,cAAc,SAAS,MAAM;AAC1D,YAAQ,SAAS;AAAA,WACV;AACH,iBAAS;AACT;AAAA,WACG;AACH,YAAK,SAAS,KAAoB,SAAS,aAAa;AACtD,mBAAS,IAAI,eAAe,SAAS,MAAoB;AAAA,eACpD;AACL,mBAAS,GAAG,eAAe,SAAS,MAAoB;AAAA;AAE1D;AAAA,WACG;AACH,iBAAS,IAAI,eAAe,SAAS,MAAoB;AACzD;AAAA,WACG;AACH,iBAAS;AACT;AAAA,WACG;AACH,iBAAS;AACT;AAAA,WACG;AACH,iBAAS;AACT;AAAA,WACG;AACH,iBAAS;AACT;AAAA,WACG;AACH,iBAAS;AACT;AAAA,WACG;AACH,iBAAS;AACT;AAAA,WACG;AACH,iBAAS,oBAAoB,eAAe,SAAS;AACrD;AAAA,WACG;AACH,iBAAU,SAAS,KAAmB,IAAI,CAAC,MAAM,IAAI,MAAM,KAAK;AAChE;AAAA,WACG;AACH,iBAAS,GAAG,eAAe,SAAS,MAAsB;AAC1D;AAAA,WACG;AACH,iBAAS,GAAG,YAAY,SAAS;AACjC;AAAA;AAEA,iBAAS,GAAG,SAAS;AACrB;AAAA;AAAA,SAEC;AACL,aAAS;AAAA;AAEX,SAAO;AAAA;AAGT,MAAM,uBAAuB,CAAC,UAAsB,aAAqB;AACvE,QAAM,gBAAgB,iCACjB,SAAS,YADQ;AAAA,IAEpB,MAAM;AAAA;AAGR,gBAAc,SAAS,eAAe;AAEtC,SAAO;AAAA;AAGM,0BAA6B,WAAmC,WAAmC;AAChH,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM;AAAA;AAGlB,QAAM,gBAAyC;AAAA,IAC7C,MAAM,UAAU,eAAe,UAAU;AAAA,KACtC;AAEL,MAAI,WAAW;AACb,WAAO,cAAc;AAErB,QAAI,UAAU,WAAW;AACvB,YAAM,YAAmD;AACzD,aAAO,KAAK,UAAU,WAAW,QAAQ,CAAC,aAAa;AACrD,cAAM,WAAW,UAAU,UAAU;AACrC,kBAAU,KAAK,qBAAqB,UAAU;AAAA;AAEhD,UAAI,UAAU,SAAS,GAAG;AACxB,sBAAc,aAAa;AAAA;AAAA;AAAA;AAIjC,SAAO;AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ import * as React from "react";
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": "AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,27 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ import * as React from "react";
18
+ import React2 from "react";
19
+ import { useGetGlobalAttributes } from "../../globalProps";
20
+ const TestComponent = (props) => {
21
+ const globalAttributes = useGetGlobalAttributes(props);
22
+ return /* @__PURE__ */ React2.createElement("div", __spreadValues({}, globalAttributes), "Some random div");
23
+ };
24
+ export {
25
+ TestComponent
26
+ };
27
+ //# sourceMappingURL=TestComponent.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/tests/globalProps/TestComponent.js"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { useGetGlobalAttributes } from '../../globalProps';\n\nexport const TestComponent = (props) => {\n const globalAttributes = useGetGlobalAttributes(props);\n\n return <div {...globalAttributes}>Some random div</div>;\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;AAAA;ACAA;AACA;AAEO,MAAM,gBAAgB,CAAC,UAAU;AACtC,QAAM,mBAAmB,uBAAuB;AAEhD,SAAO,qCAAC,OAAD,mBAAS,mBAAkB;AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,38 @@
1
+ import * as React from "react";
2
+ import { PropTypes, describe } from "react-desc";
3
+ const TestSchema = {
4
+ string: PropTypes.string.description("String"),
5
+ number: PropTypes.number.description("Number"),
6
+ boolean: PropTypes.bool.description("Boolean"),
7
+ any: PropTypes.any.description("Any"),
8
+ union: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description("Union"),
9
+ union2: PropTypes.oneOf(["A", "B"]).description("Union 2"),
10
+ union3: PropTypes.oneOfType([
11
+ PropTypes.string,
12
+ PropTypes.arrayOf(PropTypes.string),
13
+ PropTypes.shape({ string: PropTypes.string })
14
+ ]).description("Union 3"),
15
+ array: PropTypes.arrayOf(PropTypes.string).description("Array"),
16
+ object: PropTypes.object.description("Object"),
17
+ shape: PropTypes.shape({
18
+ string: PropTypes.string.description("String").isRequired,
19
+ number: PropTypes.number.description("Number"),
20
+ boolean: PropTypes.bool.description("Boolean"),
21
+ anotherShape: PropTypes.shape({
22
+ string: PropTypes.string.description("String").isRequired,
23
+ number: PropTypes.number.description("Number"),
24
+ boolean: PropTypes.bool.description("Boolean")
25
+ }).description("Another shape")
26
+ }).description("Shape"),
27
+ function: PropTypes.func.description("Function"),
28
+ jsx: PropTypes.element.description("JSX"),
29
+ node: PropTypes.node.description("Node")
30
+ };
31
+ const TestComponent = () => null;
32
+ const TestComponentWithSchema = describe(TestComponent).description("Test Component");
33
+ TestComponentWithSchema.propTypes = TestSchema;
34
+ const TypescriptSchema = TestComponentWithSchema.toTypescript();
35
+ export {
36
+ TypescriptSchema
37
+ };
38
+ //# sourceMappingURL=test.schema.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/tests/validation/test.schema.js"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { PropTypes, describe } from 'react-desc';\n\nconst TestSchema = {\n string: PropTypes.string.description('String'),\n number: PropTypes.number.description('Number'),\n boolean: PropTypes.bool.description('Boolean'),\n any: PropTypes.any.description('Any'),\n union: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description('Union'),\n union2: PropTypes.oneOf(['A', 'B']).description('Union 2'),\n union3: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.arrayOf(PropTypes.string),\n PropTypes.shape({ string: PropTypes.string }),\n ]).description('Union 3'),\n array: PropTypes.arrayOf(PropTypes.string).description('Array'),\n object: PropTypes.object.description('Object'),\n shape: PropTypes.shape({\n string: PropTypes.string.description('String').isRequired,\n number: PropTypes.number.description('Number'),\n boolean: PropTypes.bool.description('Boolean'),\n anotherShape: PropTypes.shape({\n string: PropTypes.string.description('String').isRequired,\n number: PropTypes.number.description('Number'),\n boolean: PropTypes.bool.description('Boolean'),\n }).description('Another shape'),\n }).description('Shape'),\n function: PropTypes.func.description('Function'),\n jsx: PropTypes.element.description('JSX'),\n node: PropTypes.node.description('Node'),\n};\n\nconst TestComponent = () => null;\n\nconst TestComponentWithSchema = describe(TestComponent).description('Test Component');\n\nTestComponentWithSchema.propTypes = TestSchema;\n\nexport const TypescriptSchema = TestComponentWithSchema.toTypescript();\n"],
5
+ "mappings": "AAAA;ACAA;AAEA,MAAM,aAAa;AAAA,EACjB,QAAQ,UAAU,OAAO,YAAY;AAAA,EACrC,QAAQ,UAAU,OAAO,YAAY;AAAA,EACrC,SAAS,UAAU,KAAK,YAAY;AAAA,EACpC,KAAK,UAAU,IAAI,YAAY;AAAA,EAC/B,OAAO,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,SAAS,YAAY;AAAA,EAC7E,QAAQ,UAAU,MAAM,CAAC,KAAK,MAAM,YAAY;AAAA,EAChD,QAAQ,UAAU,UAAU;AAAA,IAC1B,UAAU;AAAA,IACV,UAAU,QAAQ,UAAU;AAAA,IAC5B,UAAU,MAAM,EAAE,QAAQ,UAAU;AAAA,KACnC,YAAY;AAAA,EACf,OAAO,UAAU,QAAQ,UAAU,QAAQ,YAAY;AAAA,EACvD,QAAQ,UAAU,OAAO,YAAY;AAAA,EACrC,OAAO,UAAU,MAAM;AAAA,IACrB,QAAQ,UAAU,OAAO,YAAY,UAAU;AAAA,IAC/C,QAAQ,UAAU,OAAO,YAAY;AAAA,IACrC,SAAS,UAAU,KAAK,YAAY;AAAA,IACpC,cAAc,UAAU,MAAM;AAAA,MAC5B,QAAQ,UAAU,OAAO,YAAY,UAAU;AAAA,MAC/C,QAAQ,UAAU,OAAO,YAAY;AAAA,MACrC,SAAS,UAAU,KAAK,YAAY;AAAA,OACnC,YAAY;AAAA,KACd,YAAY;AAAA,EACf,UAAU,UAAU,KAAK,YAAY;AAAA,EACrC,KAAK,UAAU,QAAQ,YAAY;AAAA,EACnC,MAAM,UAAU,KAAK,YAAY;AAAA;AAGnC,MAAM,gBAAgB,MAAM;AAE5B,MAAM,0BAA0B,SAAS,eAAe,YAAY;AAEpE,wBAAwB,YAAY;AAE7B,MAAM,mBAAmB,wBAAwB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,19 @@
1
+ import * as React from "react";
2
+ const throwTypeError = (componentName, validPropKey, invalidProp, validFormat) => {
3
+ throw new Error(`${componentName}:: You are trying to pass a not valid "${validPropKey}" property,
4
+ please provide a valid type.
5
+
6
+ Received: ${invalidProp} (${typeof invalidProp})
7
+ Expected: (${validFormat.replace("\n", " or ")})
8
+ `);
9
+ };
10
+ const throwRequiredError = (componentName, validPropKey) => {
11
+ throw new Error(`${componentName}:: Please provide a/an "${validPropKey}" property to use this component.
12
+ This property is required.
13
+ `);
14
+ };
15
+ export {
16
+ throwRequiredError,
17
+ throwTypeError
18
+ };
19
+ //# sourceMappingURL=errorTemplates.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/validation/errorTemplates.ts"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-params */\nexport const throwTypeError = (\n componentName: string,\n validPropKey: string,\n invalidProp: unknown,\n validFormat: string,\n): void => {\n throw new Error(\n `${componentName}:: You are trying to pass a not valid \"${validPropKey}\" property, \n please provide a valid type.\n\n Received: ${invalidProp} (${typeof invalidProp})\n Expected: (${validFormat.replace('\\n', ' or ')})\n `,\n );\n};\n\nexport const throwRequiredError = (componentName: string, validPropKey: string): void => {\n throw new Error(\n `${componentName}:: Please provide a/an \"${validPropKey}\" property to use this component. \n This property is required.\n `,\n );\n};\n"],
5
+ "mappings": "AAAA;ACCO,MAAM,iBAAiB,CAC5B,eACA,cACA,aACA,gBACS;AACT,QAAM,IAAI,MACR,GAAG,uDAAuD;AAAA;AAAA;AAAA,cAGhD,gBAAgB,OAAO;AAAA,eACtB,YAAY,QAAQ,MAAM;AAAA;AAAA;AAKlC,MAAM,qBAAqB,CAAC,eAAuB,iBAA+B;AACvF,QAAM,IAAI,MACR,GAAG,wCAAwC;AAAA;AAAA;AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,5 @@
1
+ import * as React from "react";
2
+ export * from "./validator";
3
+ export * from "./errorTemplates";
4
+ export * from "./typescriptValidator";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/validation/index.ts"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export * from './validator';\nexport * from './errorTemplates';\nexport * from './typescriptValidator';\n"],
5
+ "mappings": "AAAA;ACAA;AACA;AACA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,36 @@
1
+ import * as React from "react";
2
+ const isPrimitiveType = (format) => ["string", "number", "boolean"].includes(format);
3
+ const isUndefined = (format) => format === '"undefined"';
4
+ const isNull = (format) => format === '"null"';
5
+ const isUnion = (format) => {
6
+ let depth = 0;
7
+ let satisfies = false;
8
+ format.split("").forEach((char) => {
9
+ if (["{", "("].includes(char))
10
+ depth += 1;
11
+ else if (["}", ")"].includes(char))
12
+ depth -= 1;
13
+ else if (char === "|" && depth === 0)
14
+ satisfies = true;
15
+ });
16
+ return satisfies;
17
+ };
18
+ const isString = (format) => !isUnion(format) && format[0] === '"' && format.slice(-1) === '"';
19
+ const isArray = (format) => !isUnion(format) && format.slice(-2) === "[]";
20
+ const isObject = (format) => format === "object" || !isUnion(format) && format[0] === "{" && format.slice(-1) === "}";
21
+ const isFunction = (format) => !isUnion(format) && format === "((...args: any[]) => any)";
22
+ const isJSXorNode = (format) => !isUnion(format) && ["React.ReactNode", "JSX.Element"].includes(format);
23
+ const isSomethingWithParenthesis = (format) => !isUnion(format) && format[0] === "(" && format.slice(-1) === ")";
24
+ export {
25
+ isArray,
26
+ isFunction,
27
+ isJSXorNode,
28
+ isNull,
29
+ isObject,
30
+ isPrimitiveType,
31
+ isSomethingWithParenthesis,
32
+ isString,
33
+ isUndefined,
34
+ isUnion
35
+ };
36
+ //# sourceMappingURL=typescriptGuards.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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 isObject: GuardFn = (format) =>\n format === 'object' || (!isUnion(format) && format[0] === '{' && format.slice(-1) === '}');\n\nexport const isFunction: GuardFn = (format) => !isUnion(format) && format === '((...args: any[]) => any)';\n\nexport const isJSXorNode: GuardFn = (format) => !isUnion(format) && ['React.ReactNode', 'JSX.Element'].includes(format);\n\nexport const isSomethingWithParenthesis: GuardFn = (format) =>\n !isUnion(format) && format[0] === '(' && format.slice(-1) === ')';\n"],
5
+ "mappings": "AAAA;ACEO,MAAM,kBAA2B,CAAC,WAAW,CAAC,UAAU,UAAU,WAAW,SAAS;AACtF,MAAM,cAAuB,CAAC,WAAW,WAAW;AACpD,MAAM,SAAkB,CAAC,WAAW,WAAW;AAC/C,MAAM,UAAmB,CAAC,WAAW;AAC1C,MAAI,QAAQ;AACZ,MAAI,YAAY;AAChB,SAAO,MAAM,IAAI,QAAQ,CAAC,SAAS;AACjC,QAAI,CAAC,KAAK,KAAK,SAAS;AAAO,eAAS;AAAA,aAC/B,CAAC,KAAK,KAAK,SAAS;AAAO,eAAS;AAAA,aACpC,SAAS,OAAO,UAAU;AAAG,kBAAY;AAAA;AAEpD,SAAO;AAAA;AAGF,MAAM,WAAoB,CAAC,WAAW,CAAC,QAAQ,WAAW,OAAO,OAAO,OAAO,OAAO,MAAM,QAAQ;AAEpG,MAAM,UAAmB,CAAC,WAAW,CAAC,QAAQ,WAAW,OAAO,MAAM,QAAQ;AAE9E,MAAM,WAAoB,CAAC,WAChC,WAAW,YAAa,CAAC,QAAQ,WAAW,OAAO,OAAO,OAAO,OAAO,MAAM,QAAQ;AAEjF,MAAM,aAAsB,CAAC,WAAW,CAAC,QAAQ,WAAW,WAAW;AAEvE,MAAM,cAAuB,CAAC,WAAW,CAAC,QAAQ,WAAW,CAAC,mBAAmB,eAAe,SAAS;AAEzG,MAAM,6BAAsC,CAAC,WAClD,CAAC,QAAQ,WAAW,OAAO,OAAO,OAAO,OAAO,MAAM,QAAQ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,47 @@
1
+ import * as React from "react";
2
+ const typescriptObjectParser = (format) => {
3
+ const keyValuePairs = [];
4
+ let lastKey = "";
5
+ let lastValue = "";
6
+ let shouldAppendToKey = true;
7
+ const pushPair = () => {
8
+ if (lastKey)
9
+ keyValuePairs.push([lastKey, lastValue]);
10
+ lastKey = "";
11
+ lastValue = "";
12
+ shouldAppendToKey = true;
13
+ };
14
+ let depth = 0;
15
+ format.split("").forEach((char) => {
16
+ if (char === "{") {
17
+ depth += 1;
18
+ if (depth > 1)
19
+ lastValue += char;
20
+ } else if (char === "}") {
21
+ if (depth > 1)
22
+ lastValue += char;
23
+ depth -= 1;
24
+ if (depth === 1)
25
+ pushPair();
26
+ } else if (char === ":") {
27
+ shouldAppendToKey = false;
28
+ if (depth > 1)
29
+ lastValue += char;
30
+ } else if (char === ",") {
31
+ if (depth === 1)
32
+ pushPair();
33
+ else
34
+ lastValue += char;
35
+ } else if (char === " ") {
36
+ } else if (shouldAppendToKey)
37
+ lastKey += char;
38
+ else
39
+ lastValue += char;
40
+ });
41
+ pushPair();
42
+ return keyValuePairs;
43
+ };
44
+ export {
45
+ typescriptObjectParser
46
+ };
47
+ //# sourceMappingURL=typescriptParsers.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/validation/typescriptParsers.ts"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\nexport const typescriptObjectParser = (format: string): [string, string][] => {\n const keyValuePairs: [string, string][] = [];\n\n // State of the algorithm\n let lastKey = '';\n let lastValue = '';\n let shouldAppendToKey = true;\n\n const pushPair = () => {\n if (lastKey) keyValuePairs.push([lastKey, lastValue]);\n lastKey = '';\n lastValue = '';\n shouldAppendToKey = true;\n };\n\n // Complex -- but working -- logic\n let depth = 0;\n format.split('').forEach((char) => {\n if (char === '{') {\n depth += 1;\n if (depth > 1) lastValue += char;\n } else if (char === '}') {\n if (depth > 1) lastValue += char;\n depth -= 1;\n if (depth === 1) pushPair();\n } else if (char === ':') {\n shouldAppendToKey = false;\n if (depth > 1) lastValue += char;\n } else if (char === ',') {\n if (depth === 1) pushPair();\n else lastValue += char;\n } else if (char === ' ') {\n // Do nothing\n } else if (shouldAppendToKey) lastKey += char;\n else lastValue += char;\n });\n pushPair();\n\n return keyValuePairs;\n};\n"],
5
+ "mappings": "AAAA;ACCO,MAAM,yBAAyB,CAAC,WAAuC;AAC5E,QAAM,gBAAoC;AAG1C,MAAI,UAAU;AACd,MAAI,YAAY;AAChB,MAAI,oBAAoB;AAExB,QAAM,WAAW,MAAM;AACrB,QAAI;AAAS,oBAAc,KAAK,CAAC,SAAS;AAC1C,cAAU;AACV,gBAAY;AACZ,wBAAoB;AAAA;AAItB,MAAI,QAAQ;AACZ,SAAO,MAAM,IAAI,QAAQ,CAAC,SAAS;AACjC,QAAI,SAAS,KAAK;AAChB,eAAS;AACT,UAAI,QAAQ;AAAG,qBAAa;AAAA,eACnB,SAAS,KAAK;AACvB,UAAI,QAAQ;AAAG,qBAAa;AAC5B,eAAS;AACT,UAAI,UAAU;AAAG;AAAA,eACR,SAAS,KAAK;AACvB,0BAAoB;AACpB,UAAI,QAAQ;AAAG,qBAAa;AAAA,eACnB,SAAS,KAAK;AACvB,UAAI,UAAU;AAAG;AAAA;AACZ,qBAAa;AAAA,eACT,SAAS,KAAK;AAAA,eAEd;AAAmB,iBAAW;AAAA;AACpC,mBAAa;AAAA;AAEpB;AAEA,SAAO;AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,153 @@
1
+ import * as React from "react";
2
+ import { useMemo, useState } from "react";
3
+ import { describe } from "../propTypes";
4
+ import { throwRequiredError, throwTypeError } from "./errorTemplates";
5
+ import {
6
+ isArray,
7
+ isFunction,
8
+ isJSXorNode,
9
+ isObject,
10
+ isPrimitiveType,
11
+ isSomethingWithParenthesis,
12
+ isString,
13
+ isUnion,
14
+ isUndefined,
15
+ isNull
16
+ } from "./typescriptGuards";
17
+ import { typescriptObjectParser } from "./typescriptParsers";
18
+ const validateUndefined = (schemaName, key, value, format) => {
19
+ if (value !== void 0 || value === "undefined") {
20
+ throwTypeError(schemaName, key, value, format);
21
+ }
22
+ };
23
+ const validateNull = (schemaName, key, value, format) => {
24
+ if (value !== null || value === "null") {
25
+ throwTypeError(schemaName, key, value, format);
26
+ }
27
+ };
28
+ const validatePrimitiveType = (schemaName, key, value, format) => {
29
+ if (typeof value !== format) {
30
+ throwTypeError(schemaName, key, value, format);
31
+ }
32
+ };
33
+ const validateString = (schemaName, key, value, format) => {
34
+ if (value !== format.slice(1, -1)) {
35
+ throwTypeError(schemaName, key, value, format);
36
+ }
37
+ };
38
+ const validateArray = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {
39
+ if (!Array.isArray(value)) {
40
+ throwTypeError(schemaName, key, value, format);
41
+ }
42
+ value.forEach((val, index) => {
43
+ validateValueWithFormat(schemaName, `${key}[${index}]`, val, format.slice(0, -2), validationsMemo, nextValidationsMemo);
44
+ });
45
+ };
46
+ function isObjectType(value) {
47
+ return !(typeof value !== "object" || Array.isArray(value));
48
+ }
49
+ const validateObject = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {
50
+ const valuesIsObject = isObjectType(value);
51
+ if (!valuesIsObject) {
52
+ throwTypeError(schemaName, key, value, format);
53
+ return;
54
+ }
55
+ if (format === "object")
56
+ return;
57
+ const keyValuePairs = typescriptObjectParser(format);
58
+ keyValuePairs.forEach(([objectKey, objectValue]) => {
59
+ const trueKey = objectKey.slice(-1) === "?" ? objectKey.slice(0, -1) : objectKey;
60
+ if (trueKey === objectKey && !(trueKey in value)) {
61
+ throwRequiredError(schemaName, key);
62
+ }
63
+ if (trueKey in value) {
64
+ validateValueWithFormat(schemaName, `${key}[${trueKey}]`, value[trueKey], objectValue, validationsMemo, nextValidationsMemo);
65
+ }
66
+ });
67
+ };
68
+ const validateUnion = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {
69
+ const possibilities = format.split(/\s?\|\s?/);
70
+ const errors = [];
71
+ possibilities.forEach((possibility) => {
72
+ try {
73
+ validateValueWithFormat(schemaName, key, value, possibility, validationsMemo, nextValidationsMemo);
74
+ } catch (e) {
75
+ errors.push(e);
76
+ }
77
+ });
78
+ if (errors.length === possibilities.length) {
79
+ throwTypeError(schemaName, key, value, format);
80
+ }
81
+ };
82
+ const validateFunction = (schemaName, key, value, format) => {
83
+ if (typeof value !== "function") {
84
+ throwTypeError(schemaName, key, value, format);
85
+ }
86
+ };
87
+ function isJSXElement(value) {
88
+ return value === null || typeof value === "object" && value !== null && "$$typeof" in value;
89
+ }
90
+ const validateJSXorNode = (schemaName, key, value, format) => {
91
+ const valueIsJSX = isJSXElement(value);
92
+ if (format === "JSX.Element" && !valueIsJSX) {
93
+ throwTypeError(schemaName, key, value, format);
94
+ }
95
+ };
96
+ const validateValueWithFormat = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {
97
+ nextValidationsMemo[value] = format;
98
+ if (value in validationsMemo) {
99
+ return;
100
+ }
101
+ if (isUndefined(format)) {
102
+ validateUndefined(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
103
+ } else if (isNull(format)) {
104
+ validateNull(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
105
+ } else if (isPrimitiveType(format)) {
106
+ validatePrimitiveType(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
107
+ } else if (isUnion(format)) {
108
+ validateUnion(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
109
+ } else if (isString(format)) {
110
+ validateString(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
111
+ } else if (isArray(format)) {
112
+ validateArray(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
113
+ } else if (isObject(format)) {
114
+ validateObject(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
115
+ } else if (isFunction(format)) {
116
+ validateFunction(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
117
+ } else if (isJSXorNode(format)) {
118
+ validateJSXorNode(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
119
+ } else if (isSomethingWithParenthesis(format)) {
120
+ validateValueWithFormat(schemaName, key, value, format.slice(1, -1), validationsMemo, nextValidationsMemo);
121
+ }
122
+ };
123
+ const validateTypescriptPropTypesImplementation = (props, schema, validationsMemo = {}, nextValidationsMemo = {}) => {
124
+ const { properties, name: schemaName } = schema;
125
+ properties.forEach((property) => {
126
+ const { name, format, required } = property;
127
+ if (required && !(name in props)) {
128
+ throwRequiredError(schema.name, name);
129
+ }
130
+ if (name in props && (props[name] !== void 0 || required)) {
131
+ validateValueWithFormat(schemaName, name, props[name], format, validationsMemo, nextValidationsMemo);
132
+ }
133
+ });
134
+ };
135
+ const useValidateTypescriptPropTypes = (props, propTypes) => {
136
+ const [validationsMemo, setValidationsMemo] = useState({});
137
+ const ComponentWithSchema = useMemo(() => {
138
+ const Component = () => {
139
+ };
140
+ return describe(Component);
141
+ }, []);
142
+ ComponentWithSchema.propTypes = propTypes;
143
+ useMemo(() => {
144
+ const nextValidationsMemo = {};
145
+ validateTypescriptPropTypesImplementation(props, ComponentWithSchema.toTypescript(), validationsMemo, nextValidationsMemo);
146
+ setValidationsMemo(nextValidationsMemo);
147
+ }, [props]);
148
+ };
149
+ export {
150
+ useValidateTypescriptPropTypes,
151
+ validateTypescriptPropTypesImplementation
152
+ };
153
+ //# sourceMappingURL=typescriptValidator.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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 React, { PropsWithChildren, useMemo, useState } from 'react';\nimport { describe } from '../propTypes';\nimport { throwRequiredError, throwTypeError } from './errorTemplates';\nimport {\n isArray,\n isFunction,\n isJSXorNode,\n isObject,\n isPrimitiveType,\n isSomethingWithParenthesis,\n isString,\n isUnion,\n isUndefined,\n isNull,\n} from './typescriptGuards';\nimport { typescriptObjectParser } from './typescriptParsers';\n\ninterface TypescriptSchema {\n description: string;\n name: string;\n properties: { name: string; description: string; defaultValue?: unknown; format: string; required?: boolean }[];\n}\n\ntype ValidatorFn = (\n schemaName: string,\n key: string,\n value: unknown,\n format: string,\n validationsMemo: Record<symbol, string>,\n nextValidationsMemo: Record<symbol, string>,\n) => void;\n\n// =============================================================================\n// Atom Validators\n// =============================================================================\n\n// This functions will validate something from the data\n// and optionally recursively apply `validateValueWithFormat`\n// in smaller parts\n\nconst validateUndefined: ValidatorFn = (schemaName, key, value, format) => {\n if (value !== undefined || value === 'undefined') {\n throwTypeError(schemaName, key, value, format);\n }\n};\nconst validateNull: ValidatorFn = (schemaName, key, value, format) => {\n if (value !== null || value === 'null') {\n throwTypeError(schemaName, key, value, format);\n }\n};\nconst validatePrimitiveType: ValidatorFn = (schemaName, key, value, format) => {\n if (typeof value !== format) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nconst validateString: ValidatorFn = (schemaName, key, value, format) => {\n if (value !== format.slice(1, -1)) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nconst validateArray: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n // Check that we have an array\n if (!Array.isArray(value)) {\n throwTypeError(schemaName, key, value, format);\n }\n\n // Check that each element inside satisfies the format\n (value as unknown[]).forEach((val, index) => {\n // this is a recursive func, we need to invoke it before it's defined.\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n validateValueWithFormat(\n schemaName,\n `${key}[${index}]`,\n val,\n format.slice(0, -2),\n validationsMemo,\n nextValidationsMemo,\n );\n });\n};\nfunction isObjectType(value: unknown | Record<string, unknown>): value is Record<string, unknown> {\n return !(typeof value !== 'object' || Array.isArray(value));\n}\nconst validateObject: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n const valuesIsObject = isObjectType(value);\n // Check that we have an object\n if (!valuesIsObject) {\n throwTypeError(schemaName, key, value, format);\n return;\n }\n\n if (format === 'object') return;\n\n const keyValuePairs = typescriptObjectParser(format);\n // Now we have the key - value pairs\n // Each key could either be required or not\n // Just recursively check the object\n\n keyValuePairs.forEach(([objectKey, objectValue]) => {\n const trueKey = objectKey.slice(-1) === '?' ? objectKey.slice(0, -1) : objectKey;\n\n if (trueKey === objectKey && !(trueKey in value)) {\n throwRequiredError(schemaName, key);\n }\n\n if (trueKey in value) {\n // this is a recursive func, we need to invoke it before it's defined.\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n validateValueWithFormat(\n schemaName,\n `${key}[${trueKey}]`,\n value[trueKey],\n objectValue,\n validationsMemo,\n nextValidationsMemo,\n );\n }\n });\n};\n\nconst validateUnion: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n const possibilities = format.split(/\\s?\\|\\s?/);\n\n const errors = [];\n\n possibilities.forEach((possibility) => {\n try {\n // this is a recursive func, we need to invoke it before it's defined.\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n validateValueWithFormat(schemaName, key, value, possibility, validationsMemo, nextValidationsMemo);\n } catch (e) {\n errors.push(e);\n }\n });\n\n if (errors.length === possibilities.length) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nconst validateFunction: ValidatorFn = (schemaName, key, value, format) => {\n // Check that we have a function\n if (typeof value !== 'function') {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nfunction isJSXElement(value: unknown | JSX.Element): value is JSX.Element {\n return value === null || (typeof value === 'object' && value !== null && '$$typeof' in value);\n}\nconst validateJSXorNode: ValidatorFn = (schemaName, key, value, format) => {\n const valueIsJSX = isJSXElement(value);\n if (format === 'JSX.Element' && !valueIsJSX) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\n// =============================================================================\n// Schema validator\n// =============================================================================\n\nconst validateValueWithFormat: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n nextValidationsMemo[value as symbol] = format;\n\n if ((value as symbol) in validationsMemo) {\n // We already validated this value on this format\n return;\n }\n\n if (isUndefined(format)) {\n validateUndefined(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isNull(format)) {\n validateNull(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isPrimitiveType(format)) {\n validatePrimitiveType(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isUnion(format)) {\n validateUnion(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isString(format)) {\n validateString(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isArray(format)) {\n validateArray(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isObject(format)) {\n validateObject(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isFunction(format)) {\n validateFunction(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isJSXorNode(format)) {\n validateJSXorNode(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isSomethingWithParenthesis(format)) {\n validateValueWithFormat(schemaName, key, value, format.slice(1, -1), validationsMemo, nextValidationsMemo);\n }\n};\n\nexport const validateTypescriptPropTypesImplementation = (\n props: PropsWithChildren<Record<string, unknown>>,\n schema: TypescriptSchema,\n validationsMemo: Record<string, string> = {},\n nextValidationsMemo: Record<string, string> = {},\n): void => {\n const { properties, name: schemaName } = schema;\n\n properties.forEach((property) => {\n const { name, format, required } = property;\n\n if (required && !(name in props)) {\n throwRequiredError(schema.name, name);\n }\n\n if (name in props && (props[name] !== undefined || required)) {\n validateValueWithFormat(schemaName, name, props[name], format, validationsMemo, nextValidationsMemo);\n }\n });\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const useValidateTypescriptPropTypes = <T = Record<string, any>>(\n props: PropsWithChildren<T>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n propTypes: any,\n): void => {\n const [validationsMemo, setValidationsMemo] = useState({});\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const ComponentWithSchema = useMemo(() => {\n const Component = () => {};\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call\n return describe(Component);\n }, []);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment\n ComponentWithSchema.propTypes = propTypes;\n\n useMemo(() => {\n const nextValidationsMemo = {};\n\n validateTypescriptPropTypesImplementation(\n props,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n ComponentWithSchema.toTypescript(),\n validationsMemo,\n nextValidationsMemo,\n );\n\n setValidationsMemo(nextValidationsMemo);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [props]);\n};\n"],
5
+ "mappings": "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",
6
+ "names": []
7
+ }
@@ -0,0 +1,26 @@
1
+ import * as React from "react";
2
+ import { throwRequiredError, throwTypeError } from "./errorTemplates";
3
+ const useValidatePropTypes = (props, schema) => {
4
+ schema.properties.forEach((property) => {
5
+ const propertyName = property.name;
6
+ const currentProp = props[propertyName];
7
+ const currentPropTypeOf = typeof currentProp;
8
+ const currentFormat = property.format;
9
+ let isValidReactElement = false;
10
+ if (property.required && !Object.prototype.hasOwnProperty.call(props, property.name)) {
11
+ throwRequiredError(schema.name, property.name);
12
+ }
13
+ if (currentPropTypeOf !== "undefined" && currentProp !== null) {
14
+ if (currentPropTypeOf === "object" && Object.prototype.hasOwnProperty.call(currentProp, "$$typeof") && (currentFormat.includes("node") || currentFormat.includes("element"))) {
15
+ isValidReactElement = true;
16
+ }
17
+ if (!currentFormat.includes(currentPropTypeOf) && !currentFormat.includes(currentProp) && !isValidReactElement) {
18
+ throwTypeError(schema.name, propertyName, currentProp, currentFormat);
19
+ }
20
+ }
21
+ });
22
+ };
23
+ export {
24
+ useValidatePropTypes
25
+ };
26
+ //# sourceMappingURL=validator.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/validation/validator.ts"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\nimport { throwRequiredError, throwTypeError } from './errorTemplates';\n\nexport const useValidatePropTypes = (props: Record<string, unknown>, schema): void => {\n schema.properties.forEach((property) => {\n const propertyName = property.name;\n const currentProp = props[propertyName];\n const currentPropTypeOf = typeof currentProp;\n // eslint-disable-next-line max-len\n const currentFormat = property.format; // this is csv representing types e.g.: \"string\"/\"string,number\"/\"[object],string\"\n let isValidReactElement = false;\n // this depends on react desc definition\n if (property.required && !Object.prototype.hasOwnProperty.call(props, property.name)) {\n throwRequiredError(schema.name, property.name);\n }\n if (currentPropTypeOf !== 'undefined' && currentProp !== null) {\n if (\n currentPropTypeOf === 'object' &&\n Object.prototype.hasOwnProperty.call(currentProp, '$$typeof') &&\n (currentFormat.includes('node') || currentFormat.includes('element'))\n ) {\n isValidReactElement = true;\n }\n\n if (!currentFormat.includes(currentPropTypeOf) && !currentFormat.includes(currentProp) && !isValidReactElement) {\n throwTypeError(schema.name, propertyName, currentProp, currentFormat);\n }\n }\n });\n};\n"],
5
+ "mappings": "AAAA;ACEA;AAEO,MAAM,uBAAuB,CAAC,OAAgC,WAAiB;AACpF,SAAO,WAAW,QAAQ,CAAC,aAAa;AACtC,UAAM,eAAe,SAAS;AAC9B,UAAM,cAAc,MAAM;AAC1B,UAAM,oBAAoB,OAAO;AAEjC,UAAM,gBAAgB,SAAS;AAC/B,QAAI,sBAAsB;AAE1B,QAAI,SAAS,YAAY,CAAC,OAAO,UAAU,eAAe,KAAK,OAAO,SAAS,OAAO;AACpF,yBAAmB,OAAO,MAAM,SAAS;AAAA;AAE3C,QAAI,sBAAsB,eAAe,gBAAgB,MAAM;AAC7D,UACE,sBAAsB,YACtB,OAAO,UAAU,eAAe,KAAK,aAAa,eACjD,eAAc,SAAS,WAAW,cAAc,SAAS,aAC1D;AACA,8BAAsB;AAAA;AAGxB,UAAI,CAAC,cAAc,SAAS,sBAAsB,CAAC,cAAc,SAAS,gBAAgB,CAAC,qBAAqB;AAC9G,uBAAe,OAAO,MAAM,cAAc,aAAa;AAAA;AAAA;AAAA;AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,59 @@
1
+ import * as React from "react";
2
+ const marginKeys = [
3
+ "margin",
4
+ "marginTop",
5
+ "marginRight",
6
+ "marginBottom",
7
+ "marginLeft",
8
+ "m",
9
+ "mt",
10
+ "mr",
11
+ "mb",
12
+ "ml",
13
+ "mx",
14
+ "my"
15
+ ];
16
+ const paddingKeys = [
17
+ "padding",
18
+ "p",
19
+ "paddingTop",
20
+ "pt",
21
+ "paddingRight",
22
+ "pr",
23
+ "paddingBottom",
24
+ "pb",
25
+ "paddingLeft",
26
+ "pl",
27
+ "px",
28
+ "py"
29
+ ];
30
+ const spaceKeys = ["spaceY", "spaceX", "spaceXReverse", "spaceYReverse"];
31
+ const widthKeys = ["w", "maxWidth", "maxW", "minWidth", "minW"];
32
+ const heightKeys = ["h", "maxHeight", "maxH", "minHeight", "minH"];
33
+ const maskSizeKeys = ["maskSize"];
34
+ const spacingKeys = [...marginKeys, ...paddingKeys, ...spaceKeys];
35
+ const sizingKeys = [...widthKeys, ...heightKeys, ...maskSizeKeys];
36
+ const layoutKeys = [
37
+ "display",
38
+ "float",
39
+ "boxSizing",
40
+ "container",
41
+ "overflow",
42
+ "overflowX",
43
+ "overflowY",
44
+ "zIndex",
45
+ "position",
46
+ "top",
47
+ "right",
48
+ "bottom",
49
+ "left",
50
+ "visibility",
51
+ "overscrollBehavior",
52
+ "objectFit"
53
+ ];
54
+ const xstyledKeys = Object.fromEntries([...spacingKeys, ...sizingKeys, ...layoutKeys].map((item) => [item, true]));
55
+ export {
56
+ layoutKeys,
57
+ xstyledKeys
58
+ };
59
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/xstyledProps/constants.ts"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "const marginKeys = [\n 'margin',\n 'marginTop',\n 'marginRight',\n 'marginBottom',\n 'marginLeft',\n 'm',\n 'mt',\n 'mr',\n 'mb',\n 'ml',\n 'mx',\n 'my',\n];\n\nconst paddingKeys = [\n 'padding',\n 'p',\n 'paddingTop',\n 'pt',\n 'paddingRight',\n 'pr',\n 'paddingBottom',\n 'pb',\n 'paddingLeft',\n 'pl',\n 'px',\n 'py',\n];\n\nconst spaceKeys = ['spaceY', 'spaceX', 'spaceXReverse', 'spaceYReverse'];\n\nconst widthKeys = ['w', 'maxWidth', 'maxW', 'minWidth', 'minW'];\n\nconst heightKeys = ['h', 'maxHeight', 'maxH', 'minHeight', 'minH'];\n\nconst maskSizeKeys = ['maskSize'];\n\nconst spacingKeys = [...marginKeys, ...paddingKeys, ...spaceKeys];\nconst sizingKeys = [...widthKeys, ...heightKeys, ...maskSizeKeys];\nexport const layoutKeys = [\n 'display',\n 'float',\n 'boxSizing',\n 'container',\n 'overflow',\n 'overflowX',\n 'overflowY',\n 'zIndex',\n 'position',\n 'top',\n 'right',\n 'bottom',\n 'left',\n 'visibility',\n 'overscrollBehavior',\n 'objectFit',\n];\n\nexport const xstyledKeys = Object.fromEntries(\n [...spacingKeys, ...sizingKeys, ...layoutKeys].map((item) => [item, true]),\n) as Record<string, true>;\n"],
5
+ "mappings": "AAAA;ACAA,MAAM,aAAa;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAGF,MAAM,cAAc;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAGF,MAAM,YAAY,CAAC,UAAU,UAAU,iBAAiB;AAExD,MAAM,YAAY,CAAC,KAAK,YAAY,QAAQ,YAAY;AAExD,MAAM,aAAa,CAAC,KAAK,aAAa,QAAQ,aAAa;AAE3D,MAAM,eAAe,CAAC;AAEtB,MAAM,cAAc,CAAC,GAAG,YAAY,GAAG,aAAa,GAAG;AACvD,MAAM,aAAa,CAAC,GAAG,WAAW,GAAG,YAAY,GAAG;AAC7C,MAAM,aAAa;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAGK,MAAM,cAAc,OAAO,YAChC,CAAC,GAAG,aAAa,GAAG,YAAY,GAAG,YAAY,IAAI,CAAC,SAAS,CAAC,MAAM;",
6
+ "names": []
7
+ }
@@ -0,0 +1,4 @@
1
+ import * as React from "react";
2
+ export * from "./useGetXstyledProps";
3
+ export * from "./xstyledPropTypes";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/xstyledProps/index.ts"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export * from './useGetXstyledProps';\nexport * from './xstyledPropTypes';\n"],
5
+ "mappings": "AAAA;ACAA;AACA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,19 @@
1
+ import * as React from "react";
2
+ import { useMemo } from "react";
3
+ import { xstyledKeys } from "./constants";
4
+ const useGetXstyledProps = (props) => {
5
+ const componentXstyledProps = useMemo(() => {
6
+ const xstyledPropsObject = {};
7
+ Object.entries(props).forEach(([key, value]) => {
8
+ if (key in xstyledKeys) {
9
+ xstyledPropsObject[key] = value;
10
+ }
11
+ });
12
+ return xstyledPropsObject;
13
+ }, [props]);
14
+ return componentXstyledProps;
15
+ };
16
+ export {
17
+ useGetXstyledProps
18
+ };
19
+ //# sourceMappingURL=useGetXstyledProps.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/xstyledProps/useGetXstyledProps.ts"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useMemo } from 'react';\nimport type { SizingProps, SpaceProps, LayoutProps } from '@xstyled/styled-components';\nimport { xstyledKeys } from './constants';\n\ntype XstyledProps = SpaceProps & SizingProps & LayoutProps;\n\ntype PropsWithXstyled<T> = T & XstyledProps;\n\nexport const useGetXstyledProps = <T>(props: PropsWithXstyled<T>): XstyledProps => {\n const componentXstyledProps = useMemo(() => {\n const xstyledPropsObject: Record<string, unknown> = {};\n Object.entries(props).forEach(([key, value]) => {\n if (key in xstyledKeys) {\n xstyledPropsObject[key] = value;\n }\n });\n return xstyledPropsObject;\n }, [props]);\n\n return componentXstyledProps as XstyledProps;\n};\n"],
5
+ "mappings": "AAAA;ACAA;AAEA;AAMO,MAAM,qBAAqB,CAAI,UAA6C;AACjF,QAAM,wBAAwB,QAAQ,MAAM;AAC1C,UAAM,qBAA8C;AACpD,WAAO,QAAQ,OAAO,QAAQ,CAAC,CAAC,KAAK,WAAW;AAC9C,UAAI,OAAO,aAAa;AACtB,2BAAmB,OAAO;AAAA;AAAA;AAG9B,WAAO;AAAA,KACN,CAAC;AAEJ,SAAO;AAAA;",
6
+ "names": []
7
+ }