@elliemae/ds-props-helpers 2.3.0-alpha.9 → 2.3.0-next.0

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 (174) hide show
  1. package/cjs/defaultProps/index.js +9 -0
  2. package/cjs/defaultProps/useMemoMergePropsWithDefault.js +48 -0
  3. package/cjs/getProps/index.js +20 -0
  4. package/cjs/globalProps/constants.js +15 -0
  5. package/cjs/globalProps/globalAttributesPropTypes.js +382 -0
  6. package/cjs/globalProps/index.js +11 -0
  7. package/cjs/globalProps/useGetGlobalAttributes.js +36 -0
  8. package/cjs/index.js +28 -0
  9. package/cjs/propTypes/PropTypes.js +130 -0
  10. package/cjs/propTypes/customPropTypes.js +21 -0
  11. package/cjs/propTypes/describe.js +64 -0
  12. package/cjs/propTypes/describeConversions.js +104 -0
  13. package/cjs/propTypes/describeGuards.js +21 -0
  14. package/cjs/propTypes/index.js +11 -0
  15. package/cjs/propTypes/toTypescript.js +160 -0
  16. package/cjs/propTypes/types.js +2 -0
  17. package/cjs/validation/errorTemplates.js +16 -0
  18. package/cjs/validation/index.js +15 -0
  19. package/cjs/validation/typescriptGuards.js +36 -0
  20. package/cjs/validation/typescriptParsers.js +45 -0
  21. package/cjs/validation/typescriptValidator.js +208 -0
  22. package/cjs/validation/validator.js +36 -0
  23. package/esm/defaultProps/index.js +1 -0
  24. package/esm/defaultProps/useMemoMergePropsWithDefault.js +39 -0
  25. package/esm/getProps/index.js +15 -0
  26. package/esm/globalProps/constants.js +11 -0
  27. package/{dist/esm → esm}/globalProps/globalAttributesPropTypes.js +67 -58
  28. package/esm/globalProps/index.js +2 -0
  29. package/esm/globalProps/useGetGlobalAttributes.js +32 -0
  30. package/esm/index.js +9 -0
  31. package/esm/propTypes/PropTypes.js +124 -0
  32. package/esm/propTypes/customPropTypes.js +17 -0
  33. package/esm/propTypes/describe.js +62 -0
  34. package/esm/propTypes/describeConversions.js +96 -0
  35. package/esm/propTypes/describeGuards.js +10 -0
  36. package/esm/propTypes/index.js +2 -0
  37. package/esm/propTypes/toTypescript.js +154 -0
  38. package/esm/propTypes/types.js +1 -0
  39. package/esm/validation/errorTemplates.js +11 -0
  40. package/esm/validation/index.js +3 -0
  41. package/esm/validation/typescriptGuards.js +23 -0
  42. package/esm/validation/typescriptParsers.js +41 -0
  43. package/esm/validation/typescriptValidator.js +203 -0
  44. package/esm/validation/validator.js +32 -0
  45. package/package.json +63 -65
  46. package/{dist/types → types}/defaultProps/index.d.ts +0 -0
  47. package/{dist/types → types}/defaultProps/useMemoMergePropsWithDefault.d.ts +0 -0
  48. package/{dist/types → types}/getProps/index.d.ts +0 -0
  49. package/{dist/types → types}/globalProps/constants.d.ts +0 -0
  50. package/{dist/types → types}/globalProps/globalAttributesPropTypes.d.ts +0 -0
  51. package/{dist/types → types}/globalProps/index.d.ts +0 -0
  52. package/{dist/types → types}/globalProps/useGetGlobalAttributes.d.ts +0 -0
  53. package/{dist/types → types}/index.d.ts +0 -0
  54. package/{dist/types → types}/propTypes/PropTypes.d.ts +0 -0
  55. package/{dist/types → types}/propTypes/customPropTypes.d.ts +0 -0
  56. package/{dist/types → types}/propTypes/describe.d.ts +0 -0
  57. package/{dist/types → types}/propTypes/describeConversions.d.ts +0 -0
  58. package/{dist/types → types}/propTypes/describeGuards.d.ts +0 -0
  59. package/{dist/types → types}/propTypes/index.d.ts +0 -0
  60. package/{dist/types → types}/propTypes/toTypescript.d.ts +0 -0
  61. package/{dist/types → types}/propTypes/types.d.ts +1 -1
  62. package/{dist/types → types}/tests/globalProps/TestComponent.d.ts +0 -0
  63. package/{dist/types → types}/tests/globalProps/globalAttributes.test.d.ts +0 -0
  64. package/{dist/types → types}/tests/validation/any.validation.test.d.ts +0 -0
  65. package/{dist/types → types}/tests/validation/array.validation.test.d.ts +0 -0
  66. package/{dist/types → types}/tests/validation/boolean.validation.test.d.ts +0 -0
  67. package/{dist/types → types}/tests/validation/function.validation.test.d.ts +0 -0
  68. package/{dist/types → types}/tests/validation/number.validation.test.d.ts +0 -0
  69. package/{dist/types → types}/tests/validation/object.validation.test.d.ts +0 -0
  70. package/{dist/types → types}/tests/validation/schema.validation.test.d.ts +0 -0
  71. package/{dist/types → types}/tests/validation/string.validation.test.d.ts +0 -0
  72. package/{dist/types → types}/tests/validation/test.schema.d.ts +0 -0
  73. package/{dist/types → types}/tests/validation/union.validation.test.d.ts +0 -0
  74. package/{dist/types → types}/validation/errorTemplates.d.ts +0 -0
  75. package/{dist/types → types}/validation/index.d.ts +0 -0
  76. package/{dist/types → types}/validation/typescriptGuards.d.ts +0 -0
  77. package/{dist/types → types}/validation/typescriptParsers.d.ts +0 -0
  78. package/{dist/types → types}/validation/typescriptValidator.d.ts +0 -0
  79. package/{dist/types → types}/validation/validator.d.ts +0 -0
  80. package/dist/cjs/defaultProps/index.js +0 -28
  81. package/dist/cjs/defaultProps/index.js.map +0 -7
  82. package/dist/cjs/defaultProps/useMemoMergePropsWithDefault.js +0 -48
  83. package/dist/cjs/defaultProps/useMemoMergePropsWithDefault.js.map +0 -7
  84. package/dist/cjs/getProps/index.js +0 -37
  85. package/dist/cjs/getProps/index.js.map +0 -7
  86. package/dist/cjs/globalProps/constants.js +0 -398
  87. package/dist/cjs/globalProps/constants.js.map +0 -7
  88. package/dist/cjs/globalProps/globalAttributesPropTypes.js +0 -398
  89. package/dist/cjs/globalProps/globalAttributesPropTypes.js.map +0 -7
  90. package/dist/cjs/globalProps/index.js +0 -29
  91. package/dist/cjs/globalProps/index.js.map +0 -7
  92. package/dist/cjs/globalProps/useGetGlobalAttributes.js +0 -56
  93. package/dist/cjs/globalProps/useGetGlobalAttributes.js.map +0 -7
  94. package/dist/cjs/index.js +0 -32
  95. package/dist/cjs/index.js.map +0 -7
  96. package/dist/cjs/propTypes/PropTypes.js +0 -136
  97. package/dist/cjs/propTypes/PropTypes.js.map +0 -7
  98. package/dist/cjs/propTypes/customPropTypes.js +0 -38
  99. package/dist/cjs/propTypes/customPropTypes.js.map +0 -7
  100. package/dist/cjs/propTypes/describe.js +0 -81
  101. package/dist/cjs/propTypes/describe.js.map +0 -7
  102. package/dist/cjs/propTypes/describeConversions.js +0 -96
  103. package/dist/cjs/propTypes/describeConversions.js.map +0 -7
  104. package/dist/cjs/propTypes/describeGuards.js +0 -49
  105. package/dist/cjs/propTypes/describeGuards.js.map +0 -7
  106. package/dist/cjs/propTypes/index.js +0 -37
  107. package/dist/cjs/propTypes/index.js.map +0 -7
  108. package/dist/cjs/propTypes/toTypescript.js +0 -139
  109. package/dist/cjs/propTypes/toTypescript.js.map +0 -7
  110. package/dist/cjs/propTypes/types.js +0 -27
  111. package/dist/cjs/propTypes/types.js.map +0 -7
  112. package/dist/cjs/tests/globalProps/TestComponent.js +0 -42
  113. package/dist/cjs/tests/globalProps/TestComponent.js.map +0 -7
  114. package/dist/cjs/tests/validation/test.schema.js +0 -67
  115. package/dist/cjs/tests/validation/test.schema.js.map +0 -7
  116. package/dist/cjs/validation/errorTemplates.js +0 -48
  117. package/dist/cjs/validation/errorTemplates.js.map +0 -7
  118. package/dist/cjs/validation/index.js +0 -30
  119. package/dist/cjs/validation/index.js.map +0 -7
  120. package/dist/cjs/validation/typescriptGuards.js +0 -65
  121. package/dist/cjs/validation/typescriptGuards.js.map +0 -7
  122. package/dist/cjs/validation/typescriptParsers.js +0 -76
  123. package/dist/cjs/validation/typescriptParsers.js.map +0 -7
  124. package/dist/cjs/validation/typescriptValidator.js +0 -171
  125. package/dist/cjs/validation/typescriptValidator.js.map +0 -7
  126. package/dist/cjs/validation/validator.js +0 -55
  127. package/dist/cjs/validation/validator.js.map +0 -7
  128. package/dist/esm/defaultProps/index.js +0 -3
  129. package/dist/esm/defaultProps/index.js.map +0 -7
  130. package/dist/esm/defaultProps/useMemoMergePropsWithDefault.js +0 -19
  131. package/dist/esm/defaultProps/useMemoMergePropsWithDefault.js.map +0 -7
  132. package/dist/esm/getProps/index.js +0 -8
  133. package/dist/esm/getProps/index.js.map +0 -7
  134. package/dist/esm/globalProps/constants.js +0 -369
  135. package/dist/esm/globalProps/constants.js.map +0 -7
  136. package/dist/esm/globalProps/globalAttributesPropTypes.js.map +0 -7
  137. package/dist/esm/globalProps/index.js +0 -4
  138. package/dist/esm/globalProps/index.js.map +0 -7
  139. package/dist/esm/globalProps/useGetGlobalAttributes.js +0 -27
  140. package/dist/esm/globalProps/useGetGlobalAttributes.js.map +0 -7
  141. package/dist/esm/index.js +0 -7
  142. package/dist/esm/index.js.map +0 -7
  143. package/dist/esm/propTypes/PropTypes.js +0 -107
  144. package/dist/esm/propTypes/PropTypes.js.map +0 -7
  145. package/dist/esm/propTypes/customPropTypes.js +0 -9
  146. package/dist/esm/propTypes/customPropTypes.js.map +0 -7
  147. package/dist/esm/propTypes/describe.js +0 -52
  148. package/dist/esm/propTypes/describe.js.map +0 -7
  149. package/dist/esm/propTypes/describeConversions.js +0 -76
  150. package/dist/esm/propTypes/describeConversions.js.map +0 -7
  151. package/dist/esm/propTypes/describeGuards.js +0 -20
  152. package/dist/esm/propTypes/describeGuards.js.map +0 -7
  153. package/dist/esm/propTypes/index.js +0 -8
  154. package/dist/esm/propTypes/index.js.map +0 -7
  155. package/dist/esm/propTypes/toTypescript.js +0 -110
  156. package/dist/esm/propTypes/toTypescript.js.map +0 -7
  157. package/dist/esm/propTypes/types.js +0 -2
  158. package/dist/esm/propTypes/types.js.map +0 -7
  159. package/dist/esm/tests/globalProps/TestComponent.js +0 -13
  160. package/dist/esm/tests/globalProps/TestComponent.js.map +0 -7
  161. package/dist/esm/tests/validation/test.schema.js +0 -38
  162. package/dist/esm/tests/validation/test.schema.js.map +0 -7
  163. package/dist/esm/validation/errorTemplates.js +0 -19
  164. package/dist/esm/validation/errorTemplates.js.map +0 -7
  165. package/dist/esm/validation/index.js +0 -5
  166. package/dist/esm/validation/index.js.map +0 -7
  167. package/dist/esm/validation/typescriptGuards.js +0 -36
  168. package/dist/esm/validation/typescriptGuards.js.map +0 -7
  169. package/dist/esm/validation/typescriptParsers.js +0 -47
  170. package/dist/esm/validation/typescriptParsers.js.map +0 -7
  171. package/dist/esm/validation/typescriptValidator.js +0 -153
  172. package/dist/esm/validation/typescriptValidator.js.map +0 -7
  173. package/dist/esm/validation/validator.js +0 -26
  174. package/dist/esm/validation/validator.js.map +0 -7
@@ -1,9 +0,0 @@
1
- import * as React from "react";
2
- const tupleValidator = (tupleShape) => {
3
- const func = (value, index, ...rest) => tupleShape[index](value, index, ...rest);
4
- return func;
5
- };
6
- export {
7
- tupleValidator
8
- };
9
- //# sourceMappingURL=customPropTypes.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/propTypes/customPropTypes.ts"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-params */\nimport { Validator } from 'prop-types';\n\nexport const tupleValidator = (tupleShape: Validator<unknown>[]): Validator<unknown> => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call\n const func: Validator<unknown> = (value, index, ...rest) =>\n tupleShape[index as unknown as number](value, index, ...rest);\n return func;\n};\n"],
5
- "mappings": "AAAA;ACGO,MAAM,iBAAiB,CAAC,eAAyD;AAEtF,QAAM,OAA2B,CAAC,OAAO,UAAU,SACjD,WAAW,OAA4B,OAAO,OAAO,GAAG;AAC1D,SAAO;AAAA;",
6
- "names": []
7
- }
@@ -1,52 +0,0 @@
1
- import * as React from "react";
2
- import { convertPropType } from "./describeConversions";
3
- import descToTypescript from "./toTypescript";
4
- function describe(ComponentInstance) {
5
- if (!ComponentInstance) {
6
- throw new Error("react-desc: component is required");
7
- }
8
- const documentation = {
9
- propTypes: {}
10
- };
11
- const DocumentedComponent = ComponentInstance;
12
- const addDocumentationProp = (propName) => {
13
- const func = (value) => {
14
- documentation[propName] = value;
15
- return DocumentedComponent;
16
- };
17
- return func;
18
- };
19
- DocumentedComponent.availableAt = addDocumentationProp("availableAt");
20
- DocumentedComponent.description = addDocumentationProp("description");
21
- DocumentedComponent.details = addDocumentationProp("details");
22
- DocumentedComponent.deprecated = addDocumentationProp("deprecated");
23
- DocumentedComponent.usage = addDocumentationProp("usage");
24
- DocumentedComponent.intrinsicElement = addDocumentationProp("intrinsicElement");
25
- DocumentedComponent.toTypescript = () => descToTypescript(ComponentInstance, documentation);
26
- Object.defineProperty(DocumentedComponent, "propTypes", {
27
- get: () => DocumentedComponent.propTypesValue,
28
- set: (value) => {
29
- if (!DocumentedComponent.propTypesValue) {
30
- DocumentedComponent.propTypesValue = {};
31
- }
32
- Object.keys(value).forEach((name) => {
33
- const propType = value[name];
34
- let realPropType;
35
- documentation.propTypes[name] = propType;
36
- realPropType = convertPropType(propType);
37
- if (value[name].reactDesc.required) {
38
- realPropType = realPropType.isRequired;
39
- }
40
- DocumentedComponent.propTypesValue[name] = realPropType;
41
- return propType;
42
- });
43
- },
44
- enumerable: true,
45
- configurable: true
46
- });
47
- return DocumentedComponent;
48
- }
49
- export {
50
- describe as default
51
- };
52
- //# sourceMappingURL=describe.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/propTypes/describe.ts"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/forbid-foreign-prop-types */\nimport { Requireable, Validator } from 'prop-types';\nimport React from 'react';\nimport { convertPropType } from './describeConversions';\nimport descToTypescript from './toTypescript';\nimport { ReactDescT, ComponentDocumentation, DocumentedReactComponent } from './types';\n\nexport default function describe<C>(ComponentInstance: React.ComponentType<C>) {\n if (!ComponentInstance) {\n throw new Error('react-desc: component is required');\n }\n\n const documentation: ComponentDocumentation = {\n propTypes: {},\n };\n\n const DocumentedComponent = ComponentInstance as DocumentedReactComponent<C>;\n\n const addDocumentationProp = <T extends keyof ComponentDocumentation>(propName: T) => {\n const func = (value: ComponentDocumentation[T]): DocumentedReactComponent<C> => {\n documentation[propName] = value;\n return DocumentedComponent;\n };\n return func;\n };\n\n DocumentedComponent.availableAt = addDocumentationProp('availableAt');\n DocumentedComponent.description = addDocumentationProp('description');\n DocumentedComponent.details = addDocumentationProp('details');\n DocumentedComponent.deprecated = addDocumentationProp('deprecated');\n DocumentedComponent.usage = addDocumentationProp('usage');\n DocumentedComponent.intrinsicElement = addDocumentationProp('intrinsicElement');\n\n DocumentedComponent.toTypescript = () => descToTypescript(ComponentInstance, documentation);\n\n Object.defineProperty(DocumentedComponent, 'propTypes', {\n get: () => DocumentedComponent.propTypesValue,\n set: (value: Record<string, ReactDescT>) => {\n if (!DocumentedComponent.propTypesValue) {\n DocumentedComponent.propTypesValue = {};\n }\n\n Object.keys(value).forEach((name) => {\n const propType: ReactDescT = value[name];\n let realPropType: Requireable<unknown> | Validator<unknown>;\n documentation.propTypes[name] = propType;\n realPropType = convertPropType(propType);\n if (value[name].reactDesc.required) {\n realPropType = (realPropType as Requireable<unknown>).isRequired;\n }\n DocumentedComponent.propTypesValue[name] = realPropType as Validator<unknown>;\n return propType;\n });\n },\n enumerable: true,\n configurable: true,\n });\n\n return DocumentedComponent;\n}\n"],
5
- "mappings": "AAAA;ACGA;AACA;AAGe,kBAAqB,mBAA2C;AAC7E,MAAI,CAAC,mBAAmB;AACtB,UAAM,IAAI,MAAM;AAAA;AAGlB,QAAM,gBAAwC;AAAA,IAC5C,WAAW;AAAA;AAGb,QAAM,sBAAsB;AAE5B,QAAM,uBAAuB,CAAyC,aAAgB;AACpF,UAAM,OAAO,CAAC,UAAkE;AAC9E,oBAAc,YAAY;AAC1B,aAAO;AAAA;AAET,WAAO;AAAA;AAGT,sBAAoB,cAAc,qBAAqB;AACvD,sBAAoB,cAAc,qBAAqB;AACvD,sBAAoB,UAAU,qBAAqB;AACnD,sBAAoB,aAAa,qBAAqB;AACtD,sBAAoB,QAAQ,qBAAqB;AACjD,sBAAoB,mBAAmB,qBAAqB;AAE5D,sBAAoB,eAAe,MAAM,iBAAiB,mBAAmB;AAE7E,SAAO,eAAe,qBAAqB,aAAa;AAAA,IACtD,KAAK,MAAM,oBAAoB;AAAA,IAC/B,KAAK,CAAC,UAAsC;AAC1C,UAAI,CAAC,oBAAoB,gBAAgB;AACvC,4BAAoB,iBAAiB;AAAA;AAGvC,aAAO,KAAK,OAAO,QAAQ,CAAC,SAAS;AACnC,cAAM,WAAuB,MAAM;AACnC,YAAI;AACJ,sBAAc,UAAU,QAAQ;AAChC,uBAAe,gBAAgB;AAC/B,YAAI,MAAM,MAAM,UAAU,UAAU;AAClC,yBAAgB,aAAsC;AAAA;AAExD,4BAAoB,eAAe,QAAQ;AAC3C,eAAO;AAAA;AAAA;AAAA,IAGX,YAAY;AAAA,IACZ,cAAc;AAAA;AAGhB,SAAO;AAAA;",
6
- "names": []
7
- }
@@ -1,76 +0,0 @@
1
- import * as React from "react";
2
- import PropTypes from "prop-types";
3
- import { tupleValidator } from "./customPropTypes";
4
- import {
5
- hasArguments,
6
- isArrayOf,
7
- isExact,
8
- isInstanceOf,
9
- isObjectOf,
10
- isOneOf,
11
- isOneOfType,
12
- isShape
13
- } from "./describeGuards";
14
- const enrichPropType = (propType, reactDesc) => {
15
- const func = (props, propName, componentName, ...rest) => {
16
- if (reactDesc && reactDesc.deprecated && propName in props && !reactDesc.warned) {
17
- const { version = "", message = "" } = reactDesc.deprecated;
18
- const warning = `"${propName}" property of "${componentName}" will be deprecated on VERSION: ${version}.
19
- ${message}`;
20
- console.warn(warning);
21
- reactDesc.warned = true;
22
- }
23
- return propType(props, propName, componentName, ...rest);
24
- };
25
- Object.defineProperty(func, "isRequired", Object.getOwnPropertyDescriptor(propType, "isRequired"));
26
- return func;
27
- };
28
- const convertArray = (array) => array.map((type) => convertPropType(type));
29
- const convertShape = (_shape) => {
30
- const result = {};
31
- Object.keys(_shape).forEach((key) => {
32
- result[key] = convertPropType(_shape[key]);
33
- });
34
- return result;
35
- };
36
- const convertPropType = (propType) => {
37
- if (!propType || !propType.type) {
38
- throw new Error(`react-desc: unknown error -- proptype is not well defined`);
39
- }
40
- if (propType.type === "tuple") {
41
- return enrichPropType(PropTypes.arrayOf(tupleValidator(convertArray(propType.args))), propType.reactDesc);
42
- }
43
- const realPropType = PropTypes[propType.type];
44
- if (!realPropType) {
45
- throw new Error(`react-desc: unknown type ${propType.type}`);
46
- }
47
- if (hasArguments(propType, realPropType)) {
48
- if (isOneOfType(propType, realPropType)) {
49
- return enrichPropType(realPropType(convertArray(propType.args)), propType.reactDesc);
50
- }
51
- if (isArrayOf(propType, realPropType)) {
52
- return enrichPropType(realPropType(convertPropType(propType.args)), propType.reactDesc);
53
- }
54
- if (isShape(propType, realPropType)) {
55
- return enrichPropType(realPropType(convertShape(propType.args)), propType.reactDesc);
56
- }
57
- if (isInstanceOf(propType, realPropType)) {
58
- return enrichPropType(realPropType(propType.args), propType.reactDesc);
59
- }
60
- if (isOneOf(propType, realPropType)) {
61
- return enrichPropType(realPropType(propType.args), propType.reactDesc);
62
- }
63
- if (isObjectOf(propType, realPropType)) {
64
- return enrichPropType(realPropType(propType.args), propType.reactDesc);
65
- }
66
- if (isExact(propType, realPropType)) {
67
- return enrichPropType(realPropType(propType.args), propType.reactDesc);
68
- }
69
- throw new Error(`react-desc: unknown error -- proptype with args is not matching`);
70
- }
71
- return enrichPropType(realPropType, propType.reactDesc);
72
- };
73
- export {
74
- convertPropType
75
- };
76
- //# sourceMappingURL=describeConversions.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/propTypes/describeConversions.ts"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-statements */\n/* eslint-disable complexity */\n/* eslint-disable max-params */\n/* eslint-disable no-console */\n/* eslint-disable @typescript-eslint/no-use-before-define */\nimport PropTypes, { ValidationMap, Requireable } from 'prop-types';\nimport { tupleValidator } from './customPropTypes';\nimport {\n hasArguments,\n isArrayOf,\n isExact,\n isInstanceOf,\n isObjectOf,\n isOneOf,\n isOneOfType,\n isShape,\n} from './describeGuards';\nimport { ReactDescT, ReactDescObjT, InstanceOfT, OneOfT, ObjectOfT, ExactT } from './types';\n\nconst enrichPropType = (propType: Requireable<unknown>, reactDesc: ReactDescObjT): Requireable<unknown> => {\n const func = (props: Record<string, unknown>, propName: string, componentName: string, ...rest: [string, string]) => {\n if (reactDesc && reactDesc.deprecated && propName in props && !reactDesc.warned) {\n const { version = '', message = '' } = reactDesc.deprecated;\n const warning = `\"${propName}\" property of \"${componentName}\" will be deprecated on VERSION: ${version}.\\n${message}`;\n console.warn(warning);\n reactDesc.warned = true;\n }\n return propType(props, propName, componentName, ...rest);\n };\n Object.defineProperty(\n func,\n 'isRequired',\n Object.getOwnPropertyDescriptor(propType, 'isRequired') as PropertyDescriptor,\n );\n return func as Requireable<unknown>;\n};\n\nconst convertArray = (array: ReactDescT[]): Requireable<unknown>[] => array.map((type) => convertPropType(type));\n\nconst convertShape = (_shape: Record<string, ReactDescT>): ValidationMap<Record<string, unknown>> => {\n const result: ValidationMap<Record<string, unknown>> = {};\n Object.keys(_shape).forEach((key) => {\n result[key] = convertPropType(_shape[key]);\n });\n return result;\n};\n\nexport const convertPropType = (propType: ReactDescT): Requireable<unknown> => {\n if (!propType || !propType.type) {\n throw new Error(`react-desc: unknown error -- proptype is not well defined`);\n }\n\n // DimSum PropTypes conversion\n if (propType.type === 'tuple') {\n return enrichPropType(\n PropTypes.arrayOf(tupleValidator(convertArray(propType.args as ReactDescT[]))),\n propType.reactDesc,\n );\n }\n\n // Default PropType conversion\n const realPropType = PropTypes[propType.type];\n\n if (!realPropType) {\n throw new Error(`react-desc: unknown type ${propType.type}`);\n }\n\n if (hasArguments(propType, realPropType)) {\n if (isOneOfType(propType, realPropType)) {\n return enrichPropType(realPropType(convertArray(propType.args as ReactDescT[])), propType.reactDesc);\n }\n if (isArrayOf(propType, realPropType)) {\n return enrichPropType(realPropType(convertPropType(propType.args as ReactDescT)), propType.reactDesc);\n }\n if (isShape(propType, realPropType)) {\n return enrichPropType(\n realPropType(convertShape(propType.args as Record<string, ReactDescT>)),\n propType.reactDesc,\n );\n }\n if (isInstanceOf(propType, realPropType)) {\n return enrichPropType(realPropType(propType.args as Parameters<InstanceOfT>[0]), propType.reactDesc);\n }\n if (isOneOf(propType, realPropType)) {\n return enrichPropType(realPropType(propType.args as Parameters<OneOfT>[0]), propType.reactDesc);\n }\n if (isObjectOf(propType, realPropType)) {\n return enrichPropType(realPropType(propType.args as Parameters<ObjectOfT>[0]), propType.reactDesc);\n }\n if (isExact(propType, realPropType)) {\n return enrichPropType(realPropType(propType.args as Parameters<ExactT>[0]), propType.reactDesc);\n }\n throw new Error(`react-desc: unknown error -- proptype with args is not matching`);\n }\n\n return enrichPropType(realPropType, propType.reactDesc);\n};\n"],
5
- "mappings": "AAAA;ACKA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,MAAM,iBAAiB,CAAC,UAAgC,cAAmD;AACzG,QAAM,OAAO,CAAC,OAAgC,UAAkB,kBAA0B,SAA2B;AACnH,QAAI,aAAa,UAAU,cAAc,YAAY,SAAS,CAAC,UAAU,QAAQ;AAC/E,YAAM,EAAE,UAAU,IAAI,UAAU,OAAO,UAAU;AACjD,YAAM,UAAU,IAAI,0BAA0B,iDAAiD;AAAA,EAAa;AAC5G,cAAQ,KAAK;AACb,gBAAU,SAAS;AAAA;AAErB,WAAO,SAAS,OAAO,UAAU,eAAe,GAAG;AAAA;AAErD,SAAO,eACL,MACA,cACA,OAAO,yBAAyB,UAAU;AAE5C,SAAO;AAAA;AAGT,MAAM,eAAe,CAAC,UAAgD,MAAM,IAAI,CAAC,SAAS,gBAAgB;AAE1G,MAAM,eAAe,CAAC,WAA+E;AACnG,QAAM,SAAiD;AACvD,SAAO,KAAK,QAAQ,QAAQ,CAAC,QAAQ;AACnC,WAAO,OAAO,gBAAgB,OAAO;AAAA;AAEvC,SAAO;AAAA;AAGF,MAAM,kBAAkB,CAAC,aAA+C;AAC7E,MAAI,CAAC,YAAY,CAAC,SAAS,MAAM;AAC/B,UAAM,IAAI,MAAM;AAAA;AAIlB,MAAI,SAAS,SAAS,SAAS;AAC7B,WAAO,eACL,UAAU,QAAQ,eAAe,aAAa,SAAS,SACvD,SAAS;AAAA;AAKb,QAAM,eAAe,UAAU,SAAS;AAExC,MAAI,CAAC,cAAc;AACjB,UAAM,IAAI,MAAM,4BAA4B,SAAS;AAAA;AAGvD,MAAI,aAAa,UAAU,eAAe;AACxC,QAAI,YAAY,UAAU,eAAe;AACvC,aAAO,eAAe,aAAa,aAAa,SAAS,QAAwB,SAAS;AAAA;AAE5F,QAAI,UAAU,UAAU,eAAe;AACrC,aAAO,eAAe,aAAa,gBAAgB,SAAS,QAAsB,SAAS;AAAA;AAE7F,QAAI,QAAQ,UAAU,eAAe;AACnC,aAAO,eACL,aAAa,aAAa,SAAS,QACnC,SAAS;AAAA;AAGb,QAAI,aAAa,UAAU,eAAe;AACxC,aAAO,eAAe,aAAa,SAAS,OAAqC,SAAS;AAAA;AAE5F,QAAI,QAAQ,UAAU,eAAe;AACnC,aAAO,eAAe,aAAa,SAAS,OAAgC,SAAS;AAAA;AAEvF,QAAI,WAAW,UAAU,eAAe;AACtC,aAAO,eAAe,aAAa,SAAS,OAAmC,SAAS;AAAA;AAE1F,QAAI,QAAQ,UAAU,eAAe;AACnC,aAAO,eAAe,aAAa,SAAS,OAAgC,SAAS;AAAA;AAEvF,UAAM,IAAI,MAAM;AAAA;AAGlB,SAAO,eAAe,cAAc,SAAS;AAAA;",
6
- "names": []
7
- }
@@ -1,20 +0,0 @@
1
- import * as React from "react";
2
- const hasArguments = (propType, realPropType) => !!propType.args;
3
- const isOneOfType = (propType, realPropType) => propType.type === "oneOfType";
4
- const isArrayOf = (propType, realPropType) => propType.type === "arrayOf";
5
- const isShape = (propType, realPropType) => propType.type === "shape";
6
- const isInstanceOf = (propType, realPropType) => propType.type === "instanceOf";
7
- const isOneOf = (propType, realPropType) => propType.type === "oneOf";
8
- const isObjectOf = (propType, realPropType) => propType.type === "objectOf";
9
- const isExact = (propType, realPropType) => propType.type === "exact";
10
- export {
11
- hasArguments,
12
- isArrayOf,
13
- isExact,
14
- isInstanceOf,
15
- isObjectOf,
16
- isOneOf,
17
- isOneOfType,
18
- isShape
19
- };
20
- //# sourceMappingURL=describeGuards.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/propTypes/describeGuards.ts"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import {\n AllPropTypes,\n ArrayOfT,\n ExactT,\n InstanceOfT,\n ObjectOfT,\n OneOfT,\n OneOfTypeT,\n ParametizedPropTypes,\n ReactDescT,\n ShapeT,\n} from './types';\n\nexport const hasArguments = (propType: ReactDescT, realPropType: AllPropTypes): realPropType is ParametizedPropTypes =>\n !!propType.args;\n\nexport const isOneOfType = (propType: ReactDescT, realPropType: AllPropTypes): realPropType is OneOfTypeT =>\n propType.type === 'oneOfType';\n\nexport const isArrayOf = (propType: ReactDescT, realPropType: AllPropTypes): realPropType is ArrayOfT =>\n propType.type === 'arrayOf';\n\nexport const isShape = (propType: ReactDescT, realPropType: AllPropTypes): realPropType is ShapeT =>\n propType.type === 'shape';\n\nexport const isInstanceOf = (propType: ReactDescT, realPropType: AllPropTypes): realPropType is InstanceOfT =>\n propType.type === 'instanceOf';\n\nexport const isOneOf = (propType: ReactDescT, realPropType: AllPropTypes): realPropType is OneOfT =>\n propType.type === 'oneOf';\n\nexport const isObjectOf = (propType: ReactDescT, realPropType: AllPropTypes): realPropType is ObjectOfT =>\n propType.type === 'objectOf';\n\nexport const isExact = (propType: ReactDescT, realPropType: AllPropTypes): realPropType is ExactT =>\n propType.type === 'exact';\n"],
5
- "mappings": "AAAA;ACaO,MAAM,eAAe,CAAC,UAAsB,iBACjD,CAAC,CAAC,SAAS;AAEN,MAAM,cAAc,CAAC,UAAsB,iBAChD,SAAS,SAAS;AAEb,MAAM,YAAY,CAAC,UAAsB,iBAC9C,SAAS,SAAS;AAEb,MAAM,UAAU,CAAC,UAAsB,iBAC5C,SAAS,SAAS;AAEb,MAAM,eAAe,CAAC,UAAsB,iBACjD,SAAS,SAAS;AAEb,MAAM,UAAU,CAAC,UAAsB,iBAC5C,SAAS,SAAS;AAEb,MAAM,aAAa,CAAC,UAAsB,iBAC/C,SAAS,SAAS;AAEb,MAAM,UAAU,CAAC,UAAsB,iBAC5C,SAAS,SAAS;",
6
- "names": []
7
- }
@@ -1,8 +0,0 @@
1
- import * as React from "react";
2
- import PropTypes from "./PropTypes";
3
- import describe from "./describe";
4
- export {
5
- PropTypes,
6
- describe
7
- };
8
- //# sourceMappingURL=index.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/propTypes/index.ts"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import PropTypes from './PropTypes';\nimport describe from './describe';\n\nexport { describe, PropTypes };\n"],
5
- "mappings": "AAAA;ACAA;AACA;",
6
- "names": []
7
- }
@@ -1,110 +0,0 @@
1
- import * as React from "react";
2
- const arrayFormat = (array) => array.map((propType) => propTypeFormat(propType));
3
- const shapeFormat = (shape) => {
4
- const props = Object.keys(shape).map((key) => {
5
- const value = shape[key];
6
- let valueFormat;
7
- if (value.type && (value.type === "arrayOf" || value.type === "oneOfType" || value.type === "oneOf") && Array.isArray(value.args)) {
8
- valueFormat = `${propTypeFormat(value)}`;
9
- } else if (value.type === "shape") {
10
- valueFormat = `${propTypeFormat(value)}`;
11
- } else {
12
- valueFormat = propTypeFormat(value);
13
- }
14
- return `${key}${value.reactDesc && value.reactDesc.required ? "" : "?"}: ${valueFormat}`;
15
- });
16
- return `{${props.join(",")}}`;
17
- };
18
- const propTypeFormat = (propType, joinWith = "") => {
19
- let result;
20
- if (Array.isArray(propType)) {
21
- result = arrayFormat(propType).join(joinWith);
22
- } else if (typeof propType !== "function" && propType.type) {
23
- switch (propType.type) {
24
- case "array":
25
- result = "any[]";
26
- break;
27
- case "arrayOf":
28
- if (propType.args.type === "oneOfType") {
29
- result = `(${propTypeFormat(propType.args, " | ")})[]`;
30
- } else {
31
- result = `${propTypeFormat(propType.args, "\n")}[]`;
32
- }
33
- break;
34
- case "tuple":
35
- result = `[${propTypeFormat(propType.args, ", ")}]`;
36
- break;
37
- case "bool":
38
- result = "boolean";
39
- break;
40
- case "func":
41
- result = "((...args: any[]) => any)";
42
- break;
43
- case "node":
44
- result = "React.ReactNode";
45
- break;
46
- case "element":
47
- result = "JSX.Element";
48
- break;
49
- case "instanceOf":
50
- result = "any";
51
- break;
52
- case "symbol":
53
- result = "any";
54
- break;
55
- case "objectOf":
56
- result = `{ [key: string]: ${propTypeFormat(propType.args)} }`;
57
- break;
58
- case "oneOf":
59
- result = propType.args.map((a) => `"${a}"`).join(" | ");
60
- break;
61
- case "oneOfType":
62
- result = `${propTypeFormat(propType.args, " | ")}`;
63
- break;
64
- case "shape":
65
- result = `${shapeFormat(propType.args)}`;
66
- break;
67
- default:
68
- result = `${propType.type}`;
69
- break;
70
- }
71
- } else {
72
- result = "any";
73
- }
74
- return result;
75
- };
76
- const propTypeAsTypescript = (propType, propName) => {
77
- const documentation = {
78
- ...propType.reactDesc,
79
- name: propName
80
- };
81
- documentation.format = propTypeFormat(propType);
82
- return documentation;
83
- };
84
- function descToTypescript(component, reactDesc) {
85
- if (!component) {
86
- throw new Error("react-desc: component is required");
87
- }
88
- const documentation = {
89
- name: component.displayName || component.name,
90
- ...reactDesc
91
- };
92
- if (reactDesc) {
93
- delete documentation.propTypes;
94
- if (reactDesc.propTypes) {
95
- const propTypes = [];
96
- Object.keys(reactDesc.propTypes).forEach((propName) => {
97
- const propType = reactDesc.propTypes[propName];
98
- propTypes.push(propTypeAsTypescript(propType, propName));
99
- });
100
- if (propTypes.length > 0) {
101
- documentation.properties = propTypes;
102
- }
103
- }
104
- }
105
- return documentation;
106
- }
107
- export {
108
- descToTypescript as default
109
- };
110
- //# sourceMappingURL=toTypescript.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/propTypes/toTypescript.ts"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/restrict-template-expressions */\n/* eslint-disable @typescript-eslint/no-use-before-define */\n/* eslint-disable complexity */\n/* eslint-disable react/forbid-foreign-prop-types */\nimport React from 'react';\nimport { ComponentDocumentation, ReactDescT, TypescriptDocumentation } from './types';\n\nconst arrayFormat = (array: ReactDescT[]) => array.map((propType) => propTypeFormat(propType));\n\nconst shapeFormat = (shape: Record<string, ReactDescT>) => {\n const props = Object.keys(shape).map((key) => {\n const value = shape[key];\n let valueFormat;\n if (\n value.type &&\n (value.type === 'arrayOf' || value.type === 'oneOfType' || value.type === 'oneOf') &&\n Array.isArray(value.args)\n ) {\n valueFormat = `${propTypeFormat(value)}`;\n } else if (value.type === 'shape') {\n valueFormat = `${propTypeFormat(value)}`;\n } else {\n valueFormat = propTypeFormat(value);\n }\n return `${key}${value.reactDesc && value.reactDesc.required ? '' : '?'}: ${valueFormat}`;\n });\n return `{${props.join(',')}}`;\n};\n\nconst propTypeFormat = (propType: ReactDescT | ReactDescT[], joinWith = ''): string => {\n let result;\n if (Array.isArray(propType)) {\n result = arrayFormat(propType).join(joinWith);\n } else if (typeof propType !== 'function' && propType.type) {\n switch (propType.type) {\n case 'array':\n result = 'any[]';\n break;\n case 'arrayOf':\n if ((propType.args as ReactDescT).type === 'oneOfType') {\n result = `(${propTypeFormat(propType.args as ReactDescT, ' | ')})[]`;\n } else {\n result = `${propTypeFormat(propType.args as ReactDescT, '\\n')}[]`;\n }\n break;\n case 'tuple':\n result = `[${propTypeFormat(propType.args as ReactDescT, ', ')}]`;\n break;\n case 'bool':\n result = 'boolean';\n break;\n case 'func':\n result = '((...args: any[]) => any)';\n break;\n case 'node':\n result = 'React.ReactNode';\n break;\n case 'element':\n result = 'JSX.Element';\n break;\n case 'instanceOf':\n result = 'any';\n break;\n case 'symbol':\n result = 'any';\n break;\n case 'objectOf':\n result = `{ [key: string]: ${propTypeFormat(propType.args as ReactDescT)} }`;\n break;\n case 'oneOf':\n result = (propType.args as unknown[]).map((a) => `\"${a}\"`).join(' | ');\n break;\n case 'oneOfType':\n result = `${propTypeFormat(propType.args as ReactDescT[], ' | ')}`;\n break;\n case 'shape':\n result = `${shapeFormat(propType.args as Record<string, ReactDescT>)}`;\n break;\n default:\n result = `${propType.type}`;\n break;\n }\n } else {\n result = 'any';\n }\n return result;\n};\n\nconst propTypeAsTypescript = (propType: ReactDescT, propName: string) => {\n const documentation = {\n ...propType.reactDesc,\n name: propName,\n };\n\n documentation.format = propTypeFormat(propType);\n\n return documentation;\n};\n\nexport default function descToTypescript<C>(component: React.ComponentType<C>, reactDesc: ComponentDocumentation) {\n if (!component) {\n throw new Error('react-desc: component is required');\n }\n\n const documentation: TypescriptDocumentation = {\n name: component.displayName || component.name,\n ...reactDesc,\n };\n if (reactDesc) {\n delete documentation.propTypes;\n\n if (reactDesc.propTypes) {\n const propTypes: TypescriptDocumentation['properties'] = [];\n Object.keys(reactDesc.propTypes).forEach((propName) => {\n const propType = reactDesc.propTypes[propName];\n propTypes.push(propTypeAsTypescript(propType, propName));\n });\n if (propTypes.length > 0) {\n documentation.properties = propTypes;\n }\n }\n }\n return documentation;\n}\n"],
5
- "mappings": "AAAA;ACOA,MAAM,cAAc,CAAC,UAAwB,MAAM,IAAI,CAAC,aAAa,eAAe;AAEpF,MAAM,cAAc,CAAC,UAAsC;AACzD,QAAM,QAAQ,OAAO,KAAK,OAAO,IAAI,CAAC,QAAQ;AAC5C,UAAM,QAAQ,MAAM;AACpB,QAAI;AACJ,QACE,MAAM,QACL,OAAM,SAAS,aAAa,MAAM,SAAS,eAAe,MAAM,SAAS,YAC1E,MAAM,QAAQ,MAAM,OACpB;AACA,oBAAc,GAAG,eAAe;AAAA,eACvB,MAAM,SAAS,SAAS;AACjC,oBAAc,GAAG,eAAe;AAAA,WAC3B;AACL,oBAAc,eAAe;AAAA;AAE/B,WAAO,GAAG,MAAM,MAAM,aAAa,MAAM,UAAU,WAAW,KAAK,QAAQ;AAAA;AAE7E,SAAO,IAAI,MAAM,KAAK;AAAA;AAGxB,MAAM,iBAAiB,CAAC,UAAqC,WAAW,OAAe;AACrF,MAAI;AACJ,MAAI,MAAM,QAAQ,WAAW;AAC3B,aAAS,YAAY,UAAU,KAAK;AAAA,aAC3B,OAAO,aAAa,cAAc,SAAS,MAAM;AAC1D,YAAQ,SAAS;AAAA,WACV;AACH,iBAAS;AACT;AAAA,WACG;AACH,YAAK,SAAS,KAAoB,SAAS,aAAa;AACtD,mBAAS,IAAI,eAAe,SAAS,MAAoB;AAAA,eACpD;AACL,mBAAS,GAAG,eAAe,SAAS,MAAoB;AAAA;AAE1D;AAAA,WACG;AACH,iBAAS,IAAI,eAAe,SAAS,MAAoB;AACzD;AAAA,WACG;AACH,iBAAS;AACT;AAAA,WACG;AACH,iBAAS;AACT;AAAA,WACG;AACH,iBAAS;AACT;AAAA,WACG;AACH,iBAAS;AACT;AAAA,WACG;AACH,iBAAS;AACT;AAAA,WACG;AACH,iBAAS;AACT;AAAA,WACG;AACH,iBAAS,oBAAoB,eAAe,SAAS;AACrD;AAAA,WACG;AACH,iBAAU,SAAS,KAAmB,IAAI,CAAC,MAAM,IAAI,MAAM,KAAK;AAChE;AAAA,WACG;AACH,iBAAS,GAAG,eAAe,SAAS,MAAsB;AAC1D;AAAA,WACG;AACH,iBAAS,GAAG,YAAY,SAAS;AACjC;AAAA;AAEA,iBAAS,GAAG,SAAS;AACrB;AAAA;AAAA,SAEC;AACL,aAAS;AAAA;AAEX,SAAO;AAAA;AAGT,MAAM,uBAAuB,CAAC,UAAsB,aAAqB;AACvE,QAAM,gBAAgB;AAAA,OACjB,SAAS;AAAA,IACZ,MAAM;AAAA;AAGR,gBAAc,SAAS,eAAe;AAEtC,SAAO;AAAA;AAGM,0BAA6B,WAAmC,WAAmC;AAChH,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM;AAAA;AAGlB,QAAM,gBAAyC;AAAA,IAC7C,MAAM,UAAU,eAAe,UAAU;AAAA,OACtC;AAAA;AAEL,MAAI,WAAW;AACb,WAAO,cAAc;AAErB,QAAI,UAAU,WAAW;AACvB,YAAM,YAAmD;AACzD,aAAO,KAAK,UAAU,WAAW,QAAQ,CAAC,aAAa;AACrD,cAAM,WAAW,UAAU,UAAU;AACrC,kBAAU,KAAK,qBAAqB,UAAU;AAAA;AAEhD,UAAI,UAAU,SAAS,GAAG;AACxB,sBAAc,aAAa;AAAA;AAAA;AAAA;AAIjC,SAAO;AAAA;",
6
- "names": []
7
- }
@@ -1,2 +0,0 @@
1
- import * as React from "react";
2
- //# sourceMappingURL=types.js.map
@@ -1,7 +0,0 @@
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
- }
@@ -1,13 +0,0 @@
1
- import * as React from "react";
2
- import React2 from "react";
3
- import { useGetGlobalAttributes } from "../../globalProps";
4
- const TestComponent = (props) => {
5
- const globalAttributes = useGetGlobalAttributes(props);
6
- return /* @__PURE__ */ React2.createElement("div", {
7
- ...globalAttributes
8
- }, "Some random div");
9
- };
10
- export {
11
- TestComponent
12
- };
13
- //# sourceMappingURL=TestComponent.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/tests/globalProps/TestComponent.js"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { useGetGlobalAttributes } from '../../globalProps';\n\nexport const TestComponent = (props) => {\n const globalAttributes = useGetGlobalAttributes(props);\n\n return <div {...globalAttributes}>Some random div</div>;\n};\n"],
5
- "mappings": "AAAA;ACAA;AACA;AAEO,MAAM,gBAAgB,CAAC,UAAU;AACtC,QAAM,mBAAmB,uBAAuB;AAEhD,SAAO,qCAAC,OAAD;AAAA,OAAS;AAAA,KAAkB;AAAA;",
6
- "names": []
7
- }
@@ -1,38 +0,0 @@
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
@@ -1,7 +0,0 @@
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
- }
@@ -1,19 +0,0 @@
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
@@ -1,7 +0,0 @@
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
- }
@@ -1,5 +0,0 @@
1
- import * as React from "react";
2
- export * from "./validator";
3
- export * from "./errorTemplates";
4
- export * from "./typescriptValidator";
5
- //# sourceMappingURL=index.js.map
@@ -1,7 +0,0 @@
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
- }
@@ -1,36 +0,0 @@
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
@@ -1,7 +0,0 @@
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
- }
@@ -1,47 +0,0 @@
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
@@ -1,7 +0,0 @@
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
- }