@elliemae/ds-legacy-props-helpers 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/defaultProps/index.js +36 -0
- package/dist/cjs/defaultProps/index.js.map +7 -0
- package/dist/cjs/defaultProps/useMemoMergePropsWithDefault.js +49 -0
- package/dist/cjs/defaultProps/useMemoMergePropsWithDefault.js.map +7 -0
- package/dist/cjs/getProps/index.js +42 -0
- package/dist/cjs/getProps/index.js.map +7 -0
- package/dist/cjs/globalProps/constants.js +401 -0
- package/dist/cjs/globalProps/constants.js.map +7 -0
- package/dist/cjs/globalProps/getGlobalAttributes.js +53 -0
- package/dist/cjs/globalProps/getGlobalAttributes.js.map +7 -0
- package/dist/cjs/globalProps/globalAttributesPropTypes.js +408 -0
- package/dist/cjs/globalProps/globalAttributesPropTypes.js.map +7 -0
- package/dist/cjs/globalProps/index.js +40 -0
- package/dist/cjs/globalProps/index.js.map +7 -0
- package/dist/cjs/globalProps/useGetGlobalAttributes.js +44 -0
- package/dist/cjs/globalProps/useGetGlobalAttributes.js.map +7 -0
- package/dist/cjs/index.js +59 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/package.json +4 -0
- package/dist/cjs/propTypes/PropTypes.js +142 -0
- package/dist/cjs/propTypes/PropTypes.js.map +7 -0
- package/dist/cjs/propTypes/customPropTypes.js +39 -0
- package/dist/cjs/propTypes/customPropTypes.js.map +7 -0
- package/dist/cjs/propTypes/describe.js +79 -0
- package/dist/cjs/propTypes/describe.js.map +7 -0
- package/dist/cjs/propTypes/describeConversions.js +107 -0
- package/dist/cjs/propTypes/describeConversions.js.map +7 -0
- package/dist/cjs/propTypes/describeGuards.js +50 -0
- package/dist/cjs/propTypes/describeGuards.js.map +7 -0
- package/dist/cjs/propTypes/index.js +38 -0
- package/dist/cjs/propTypes/index.js.map +7 -0
- package/dist/cjs/propTypes/toTypescript.js +151 -0
- package/dist/cjs/propTypes/toTypescript.js.map +7 -0
- package/dist/cjs/propTypes/types.js +28 -0
- package/dist/cjs/propTypes/types.js.map +7 -0
- package/dist/cjs/propsPerDataTestId/getPropsPerDatatestIdPropTypes.js +66 -0
- package/dist/cjs/propsPerDataTestId/getPropsPerDatatestIdPropTypes.js.map +7 -0
- package/dist/cjs/propsPerDataTestId/getPropsPerDatatestid.js +45 -0
- package/dist/cjs/propsPerDataTestId/getPropsPerDatatestid.js.map +7 -0
- package/dist/cjs/propsPerDataTestId/index.js +38 -0
- package/dist/cjs/propsPerDataTestId/index.js.map +7 -0
- package/dist/cjs/tests/globalProps/TestComponent.js +42 -0
- package/dist/cjs/tests/globalProps/TestComponent.js.map +7 -0
- package/dist/cjs/tests/validation/test.schema.js +72 -0
- package/dist/cjs/tests/validation/test.schema.js.map +7 -0
- package/dist/cjs/tests/xstyledProps/TestComponent.js +43 -0
- package/dist/cjs/tests/xstyledProps/TestComponent.js.map +7 -0
- package/dist/cjs/useDeprecateComponent/index.js +42 -0
- package/dist/cjs/useDeprecateComponent/index.js.map +7 -0
- package/dist/cjs/validation/errorTemplates.js +53 -0
- package/dist/cjs/validation/errorTemplates.js.map +7 -0
- package/dist/cjs/validation/index.js +40 -0
- package/dist/cjs/validation/index.js.map +7 -0
- package/dist/cjs/validation/typescriptGuards.js +86 -0
- package/dist/cjs/validation/typescriptGuards.js.map +7 -0
- package/dist/cjs/validation/typescriptParsers.js +77 -0
- package/dist/cjs/validation/typescriptParsers.js.map +7 -0
- package/dist/cjs/validation/typescriptValidator.js +220 -0
- package/dist/cjs/validation/typescriptValidator.js.map +7 -0
- package/dist/cjs/xstyledProps/constants.js +132 -0
- package/dist/cjs/xstyledProps/constants.js.map +7 -0
- package/dist/cjs/xstyledProps/index.js +38 -0
- package/dist/cjs/xstyledProps/index.js.map +7 -0
- package/dist/cjs/xstyledProps/useGetXstyledProps.js +49 -0
- package/dist/cjs/xstyledProps/useGetXstyledProps.js.map +7 -0
- package/dist/cjs/xstyledProps/xstyledPropTypes.js +127 -0
- package/dist/cjs/xstyledProps/xstyledPropTypes.js.map +7 -0
- package/dist/esm/defaultProps/index.js +6 -0
- package/dist/esm/defaultProps/index.js.map +7 -0
- package/dist/esm/defaultProps/useMemoMergePropsWithDefault.js +19 -0
- package/dist/esm/defaultProps/useMemoMergePropsWithDefault.js.map +7 -0
- package/dist/esm/getProps/index.js +12 -0
- package/dist/esm/getProps/index.js.map +7 -0
- package/dist/esm/globalProps/constants.js +371 -0
- package/dist/esm/globalProps/constants.js.map +7 -0
- package/dist/esm/globalProps/getGlobalAttributes.js +23 -0
- package/dist/esm/globalProps/getGlobalAttributes.js.map +7 -0
- package/dist/esm/globalProps/globalAttributesPropTypes.js +378 -0
- package/dist/esm/globalProps/globalAttributesPropTypes.js.map +7 -0
- package/dist/esm/globalProps/index.js +10 -0
- package/dist/esm/globalProps/index.js.map +7 -0
- package/dist/esm/globalProps/useGetGlobalAttributes.js +14 -0
- package/dist/esm/globalProps/useGetGlobalAttributes.js.map +7 -0
- package/dist/esm/index.js +38 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/package.json +4 -0
- package/dist/esm/propTypes/PropTypes.js +112 -0
- package/dist/esm/propTypes/PropTypes.js.map +7 -0
- package/dist/esm/propTypes/customPropTypes.js +9 -0
- package/dist/esm/propTypes/customPropTypes.js.map +7 -0
- package/dist/esm/propTypes/describe.js +49 -0
- package/dist/esm/propTypes/describe.js.map +7 -0
- package/dist/esm/propTypes/describeConversions.js +86 -0
- package/dist/esm/propTypes/describeConversions.js.map +7 -0
- package/dist/esm/propTypes/describeGuards.js +20 -0
- package/dist/esm/propTypes/describeGuards.js.map +7 -0
- package/dist/esm/propTypes/index.js +8 -0
- package/dist/esm/propTypes/index.js.map +7 -0
- package/dist/esm/propTypes/toTypescript.js +121 -0
- package/dist/esm/propTypes/toTypescript.js.map +7 -0
- package/dist/esm/propTypes/types.js +2 -0
- package/dist/esm/propTypes/types.js.map +7 -0
- package/dist/esm/propsPerDataTestId/getPropsPerDatatestIdPropTypes.js +36 -0
- package/dist/esm/propsPerDataTestId/getPropsPerDatatestIdPropTypes.js.map +7 -0
- package/dist/esm/propsPerDataTestId/getPropsPerDatatestid.js +15 -0
- package/dist/esm/propsPerDataTestId/getPropsPerDatatestid.js.map +7 -0
- package/dist/esm/propsPerDataTestId/index.js +8 -0
- package/dist/esm/propsPerDataTestId/index.js.map +7 -0
- package/dist/esm/tests/globalProps/TestComponent.js +12 -0
- package/dist/esm/tests/globalProps/TestComponent.js.map +7 -0
- package/dist/esm/tests/validation/test.schema.js +42 -0
- package/dist/esm/tests/validation/test.schema.js.map +7 -0
- package/dist/esm/tests/xstyledProps/TestComponent.js +13 -0
- package/dist/esm/tests/xstyledProps/TestComponent.js.map +7 -0
- package/dist/esm/useDeprecateComponent/index.js +12 -0
- package/dist/esm/useDeprecateComponent/index.js.map +7 -0
- package/dist/esm/validation/errorTemplates.js +23 -0
- package/dist/esm/validation/errorTemplates.js.map +7 -0
- package/dist/esm/validation/index.js +10 -0
- package/dist/esm/validation/index.js.map +7 -0
- package/dist/esm/validation/typescriptGuards.js +56 -0
- package/dist/esm/validation/typescriptGuards.js.map +7 -0
- package/dist/esm/validation/typescriptParsers.js +47 -0
- package/dist/esm/validation/typescriptParsers.js.map +7 -0
- package/dist/esm/validation/typescriptValidator.js +202 -0
- package/dist/esm/validation/typescriptValidator.js.map +7 -0
- package/dist/esm/xstyledProps/constants.js +102 -0
- package/dist/esm/xstyledProps/constants.js.map +7 -0
- package/dist/esm/xstyledProps/index.js +8 -0
- package/dist/esm/xstyledProps/index.js.map +7 -0
- package/dist/esm/xstyledProps/useGetXstyledProps.js +19 -0
- package/dist/esm/xstyledProps/useGetXstyledProps.js.map +7 -0
- package/dist/esm/xstyledProps/xstyledPropTypes.js +97 -0
- package/dist/esm/xstyledProps/xstyledPropTypes.js.map +7 -0
- package/dist/types/defaultProps/index.d.ts +1 -0
- package/dist/types/defaultProps/useMemoMergePropsWithDefault.d.ts +1 -0
- package/dist/types/getProps/index.d.ts +3 -0
- package/dist/types/globalProps/constants.d.ts +3 -0
- package/dist/types/globalProps/getGlobalAttributes.d.ts +6 -0
- package/dist/types/globalProps/globalAttributesPropTypes.d.ts +372 -0
- package/dist/types/globalProps/index.d.ts +3 -0
- package/dist/types/globalProps/useGetGlobalAttributes.d.ts +3 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/propTypes/PropTypes.d.ts +3 -0
- package/dist/types/propTypes/customPropTypes.d.ts +2 -0
- package/dist/types/propTypes/describe.d.ts +3 -0
- package/dist/types/propTypes/describeConversions.d.ts +3 -0
- package/dist/types/propTypes/describeGuards.d.ts +9 -0
- package/dist/types/propTypes/index.d.ts +4 -0
- package/dist/types/propTypes/toTypescript.d.ts +3 -0
- package/dist/types/propTypes/types.d.ts +118 -0
- package/dist/types/propsPerDataTestId/getPropsPerDatatestIdPropTypes.d.ts +39 -0
- package/dist/types/propsPerDataTestId/getPropsPerDatatestid.d.ts +43 -0
- package/dist/types/propsPerDataTestId/index.d.ts +2 -0
- package/dist/types/tests/globalProps/TestComponent.d.ts +1 -0
- package/dist/types/tests/globalProps/globalAttributes.test.d.ts +1 -0
- package/dist/types/tests/propsPerDataTestId/getPropsPerDatatestIdPropTypes.test.d.ts +1 -0
- package/dist/types/tests/propsPerDataTestId/getPropsPerDatatestid.test.d.ts +1 -0
- package/dist/types/tests/validation/any.validation.test.d.ts +1 -0
- package/dist/types/tests/validation/array.validation.test.d.ts +1 -0
- package/dist/types/tests/validation/boolean.validation.test.d.ts +1 -0
- package/dist/types/tests/validation/function.validation.test.d.ts +1 -0
- package/dist/types/tests/validation/isRequiredIf.validation.test.d.ts +1 -0
- package/dist/types/tests/validation/number.validation.test.d.ts +1 -0
- package/dist/types/tests/validation/object.validation.test.d.ts +1 -0
- package/dist/types/tests/validation/objectOf.validation.test.d.ts +1 -0
- package/dist/types/tests/validation/schema.validation.test.d.ts +1 -0
- package/dist/types/tests/validation/string.validation.test.d.ts +1 -0
- package/dist/types/tests/validation/test.schema.d.ts +1 -0
- package/dist/types/tests/validation/union.validation.test.d.ts +1 -0
- package/dist/types/tests/xstyledProps/TestComponent.d.ts +1 -0
- package/dist/types/tests/xstyledProps/xstyledProps.test.d.ts +1 -0
- package/dist/types/useDeprecateComponent/index.d.ts +6 -0
- package/dist/types/validation/errorTemplates.d.ts +2 -0
- package/dist/types/validation/index.d.ts +2 -0
- package/dist/types/validation/typescriptGuards.d.ts +13 -0
- package/dist/types/validation/typescriptParsers.d.ts +1 -0
- package/dist/types/validation/typescriptValidator.d.ts +4 -0
- package/dist/types/xstyledProps/constants.d.ts +7 -0
- package/dist/types/xstyledProps/index.d.ts +2 -0
- package/dist/types/xstyledProps/useGetXstyledProps.d.ts +6 -0
- package/dist/types/xstyledProps/xstyledPropTypes.d.ts +84 -0
- package/package.json +64 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/propTypes/PropTypes.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { PropTypesTypes, DocumentedPropType, ReactDescObjT, PropTypesObj } from './types.js';\n\nconst addPropTypeDocumentationField = <T extends keyof ReactDescObjT>(fieldName: T) =>\n function addFieldToReactDesc(this: DocumentedPropType, value: ReactDescObjT[T]): DocumentedPropType {\n if (!this.reactDesc) {\n this.reactDesc = {};\n }\n let realValue = value;\n if (\n fieldName === 'global' ||\n fieldName === 'dataTestId' ||\n fieldName === 'hidden' ||\n fieldName === 'xstyled' ||\n fieldName === 'omitValidation'\n )\n realValue = true;\n\n this.reactDesc[fieldName] = realValue;\n return this;\n };\n\nconst documentedPropType: Omit<DocumentedPropType, 'type' | 'isRequired' | 'reactDesc'> = {\n defaultValue: addPropTypeDocumentationField('defaultValue'),\n description: addPropTypeDocumentationField('description'),\n deprecated: addPropTypeDocumentationField('deprecated'),\n format: addPropTypeDocumentationField('format'),\n signature: addPropTypeDocumentationField('signature'),\n global: addPropTypeDocumentationField('global'),\n omitValidation: addPropTypeDocumentationField('omitValidation'),\n hidden: addPropTypeDocumentationField('hidden'),\n dataTestId: addPropTypeDocumentationField('dataTestId'),\n xstyled: addPropTypeDocumentationField('xstyled'),\n isRequiredIf: addPropTypeDocumentationField('isRequiredIf'),\n};\n\nconst createPropType = (type: PropTypesTypes) => {\n const propTypeObj = {\n type,\n ...documentedPropType,\n };\n Object.defineProperty(propTypeObj, 'isRequired', {\n get: function getRequired(this: DocumentedPropType) {\n if (!this.reactDesc) {\n this.reactDesc = {};\n }\n this.reactDesc.required = true;\n return this;\n },\n enumerable: true,\n configurable: true,\n });\n\n return propTypeObj;\n};\n\nconst createPropTypeWithArgs = (type: PropTypesTypes) => (args: unknown) => {\n const propTypeObj = {\n args,\n type,\n ...documentedPropType,\n };\n Object.defineProperty(propTypeObj, 'isRequired', {\n get: function getRequired(this: DocumentedPropType) {\n if (!this.reactDesc) {\n this.reactDesc = {};\n }\n this.reactDesc.required = true;\n return this;\n },\n enumerable: true,\n configurable: true,\n });\n return propTypeObj;\n};\n\nconst PropTypes = {\n custom: (callback: CallableFunction) => {\n const target = callback.bind(null) as CallableFunction & DocumentedPropType;\n target.type = 'func';\n Object.keys(documentedPropType).forEach((fieldName) => {\n const fieldNameCasted = fieldName as keyof DocumentedPropType;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n (target[fieldNameCasted] as unknown) = documentedPropType[fieldNameCasted] as unknown;\n });\n return target;\n },\n} as unknown as PropTypesObj;\n\nfunction definePropType(type: PropTypesTypes) {\n Object.defineProperty(PropTypes, type, {\n get: function getPropType() {\n return createPropType(type);\n },\n enumerable: true,\n configurable: true,\n });\n}\n\nfunction definePropTypeWithArgs(type: PropTypesTypes) {\n Object.defineProperty(PropTypes, type, {\n get: function getPropType() {\n return createPropTypeWithArgs(type);\n },\n enumerable: true,\n configurable: true,\n });\n}\n\ndefinePropType('any');\ndefinePropType('array');\ndefinePropType('bool');\ndefinePropType('element');\ndefinePropType('func');\ndefinePropType('node');\ndefinePropType('number');\ndefinePropType('object');\ndefinePropType('symbol');\ndefinePropType('string');\n\ndefinePropTypeWithArgs('arrayOf');\ndefinePropTypeWithArgs('instanceOf');\ndefinePropTypeWithArgs('objectOf');\ndefinePropTypeWithArgs('oneOfType');\ndefinePropTypeWithArgs('oneOf');\ndefinePropTypeWithArgs('shape');\ndefinePropTypeWithArgs('tuple');\n\nexport default PropTypes;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACEvB,MAAM,gCAAgC,CAAgC,cACpE,SAAS,oBAA8C,OAA6C;AAClG,MAAI,CAAC,KAAK,WAAW;AACnB,SAAK,YAAY,CAAC;AAAA,EACpB;AACA,MAAI,YAAY;AAChB,MACE,cAAc,YACd,cAAc,gBACd,cAAc,YACd,cAAc,aACd,cAAc;AAEd,gBAAY;AAEd,OAAK,UAAU,SAAS,IAAI;AAC5B,SAAO;AACT;AAEF,MAAM,qBAAoF;AAAA,EACxF,cAAc,8BAA8B,cAAc;AAAA,EAC1D,aAAa,8BAA8B,aAAa;AAAA,EACxD,YAAY,8BAA8B,YAAY;AAAA,EACtD,QAAQ,8BAA8B,QAAQ;AAAA,EAC9C,WAAW,8BAA8B,WAAW;AAAA,EACpD,QAAQ,8BAA8B,QAAQ;AAAA,EAC9C,gBAAgB,8BAA8B,gBAAgB;AAAA,EAC9D,QAAQ,8BAA8B,QAAQ;AAAA,EAC9C,YAAY,8BAA8B,YAAY;AAAA,EACtD,SAAS,8BAA8B,SAAS;AAAA,EAChD,cAAc,8BAA8B,cAAc;AAC5D;AAEA,MAAM,iBAAiB,CAAC,SAAyB;AAC/C,QAAM,cAAc;AAAA,IAClB;AAAA,IACA,GAAG;AAAA,EACL;AACA,SAAO,eAAe,aAAa,cAAc;AAAA,IAC/C,KAAK,SAAS,cAAsC;AAClD,UAAI,CAAC,KAAK,WAAW;AACnB,aAAK,YAAY,CAAC;AAAA,MACpB;AACA,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;AACvB,eAAe,QAAQ;AACvB,eAAe,QAAQ;AACvB,eAAe,QAAQ;AAEvB,uBAAuB,SAAS;AAChC,uBAAuB,YAAY;AACnC,uBAAuB,UAAU;AACjC,uBAAuB,WAAW;AAClC,uBAAuB,OAAO;AAC9B,uBAAuB,OAAO;AAC9B,uBAAuB,OAAO;AAE9B,IAAO,oBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
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 type { 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,YAAY,WAAW;ACGhB,MAAM,iBAAiB,CAAC,eAAyD;AAEtF,QAAM,OAA2B,CAAC,OAAO,UAAU,SACjD,WAAW,KAA0B,EAAE,OAAO,OAAO,GAAG,IAAI;AAC9D,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { convertPropType } from "./describeConversions.js";
|
|
3
|
+
import descToTypescript from "./toTypescript.js";
|
|
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
|
+
DocumentedComponent.propTypesValue[name] = realPropType;
|
|
38
|
+
return propType;
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
enumerable: true,
|
|
42
|
+
configurable: true
|
|
43
|
+
});
|
|
44
|
+
return DocumentedComponent;
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
describe as default
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=describe.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/propTypes/describe.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/forbid-foreign-prop-types */\nimport type { Requireable, Validator } from 'prop-types';\nimport type React from 'react';\nimport { convertPropType } from './describeConversions.js';\nimport descToTypescript from './toTypescript.js';\nimport type { ReactDescT, Hook, ComponentDocumentation, DocumentedReactComponent } from './types.js';\n\nexport default function describe<C, R>(ComponentInstance: React.ComponentType<C> | Hook<C, R>) {\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 // We don't need to rely on the isRequired from prop-types package\n // So no need to invoke (realPropType).isRequired if our own proptype is required\n // Validation will handle that case for us\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,YAAY,WAAW;ACGvB,SAAS,uBAAuB;AAChC,OAAO,sBAAsB;AAGd,SAAR,SAAgC,mBAAwD;AAC7F,MAAI,CAAC,mBAAmB;AACtB,UAAM,IAAI,MAAM,mCAAmC;AAAA,EACrD;AAEA,QAAM,gBAAwC;AAAA,IAC5C,WAAW,CAAC;AAAA,EACd;AAEA,QAAM,sBAAsB;AAE5B,QAAM,uBAAuB,CAAyC,aAAgB;AACpF,UAAM,OAAO,CAAC,UAAkE;AAC9E,oBAAc,QAAQ,IAAI;AAC1B,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AAEA,sBAAoB,cAAc,qBAAqB,aAAa;AACpE,sBAAoB,cAAc,qBAAqB,aAAa;AACpE,sBAAoB,UAAU,qBAAqB,SAAS;AAC5D,sBAAoB,aAAa,qBAAqB,YAAY;AAClE,sBAAoB,QAAQ,qBAAqB,OAAO;AACxD,sBAAoB,mBAAmB,qBAAqB,kBAAkB;AAE9E,sBAAoB,eAAe,MAAM,iBAAiB,mBAAmB,aAAa;AAE1F,SAAO,eAAe,qBAAqB,aAAa;AAAA,IACtD,KAAK,MAAM,oBAAoB;AAAA,IAC/B,KAAK,CAAC,UAAsC;AAC1C,UAAI,CAAC,oBAAoB,gBAAgB;AACvC,4BAAoB,iBAAiB,CAAC;AAAA,MACxC;AAEA,aAAO,KAAK,KAAK,EAAE,QAAQ,CAAC,SAAS;AACnC,cAAM,WAAuB,MAAM,IAAI;AACvC,YAAI;AACJ,sBAAc,UAAU,IAAI,IAAI;AAChC,uBAAe,gBAAgB,QAAQ;AAIvC,4BAAoB,eAAe,IAAI,IAAI;AAC3C,eAAO;AAAA,MACT,CAAC;AAAA,IACH;AAAA,IACA,YAAY;AAAA,IACZ,cAAc;AAAA,EAChB,CAAC;AAED,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import { tupleValidator } from "./customPropTypes.js";
|
|
4
|
+
import {
|
|
5
|
+
hasArguments,
|
|
6
|
+
isArrayOf,
|
|
7
|
+
isExact,
|
|
8
|
+
isInstanceOf,
|
|
9
|
+
isObjectOf,
|
|
10
|
+
isOneOf,
|
|
11
|
+
isOneOfType,
|
|
12
|
+
isShape
|
|
13
|
+
} from "./describeGuards.js";
|
|
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 error = `Warning: "${propName}" property of "${componentName}" will be deprecated in version: ${version}.
|
|
19
|
+
${message}`;
|
|
20
|
+
console.warn(error);
|
|
21
|
+
reactDesc.warned = true;
|
|
22
|
+
}
|
|
23
|
+
return propType(props, propName, componentName, ...rest);
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(
|
|
26
|
+
func,
|
|
27
|
+
"isRequired",
|
|
28
|
+
Object.getOwnPropertyDescriptor(propType, "isRequired")
|
|
29
|
+
);
|
|
30
|
+
return func;
|
|
31
|
+
};
|
|
32
|
+
const convertArray = (array) => array.map((type) => convertPropType(type));
|
|
33
|
+
const convertShape = (_shape) => {
|
|
34
|
+
const result = {};
|
|
35
|
+
Object.keys(_shape).forEach((key) => {
|
|
36
|
+
result[key] = convertPropType(_shape[key]);
|
|
37
|
+
});
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
const convertPropType = (propType) => {
|
|
41
|
+
if (!propType || !propType.type) {
|
|
42
|
+
throw new Error(`react-desc: unknown error -- proptype is not well defined`);
|
|
43
|
+
}
|
|
44
|
+
if (propType.type === "tuple") {
|
|
45
|
+
return enrichPropType(
|
|
46
|
+
PropTypes.arrayOf(tupleValidator(convertArray(propType.args))),
|
|
47
|
+
propType.reactDesc
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
const realPropType = PropTypes[propType.type];
|
|
51
|
+
if (!realPropType) {
|
|
52
|
+
throw new Error(`react-desc: unknown type ${propType.type}`);
|
|
53
|
+
}
|
|
54
|
+
if (hasArguments(propType, realPropType)) {
|
|
55
|
+
if (isOneOfType(propType, realPropType)) {
|
|
56
|
+
return enrichPropType(realPropType(convertArray(propType.args)), propType.reactDesc);
|
|
57
|
+
}
|
|
58
|
+
if (isArrayOf(propType, realPropType)) {
|
|
59
|
+
return enrichPropType(realPropType(convertPropType(propType.args)), propType.reactDesc);
|
|
60
|
+
}
|
|
61
|
+
if (isShape(propType, realPropType)) {
|
|
62
|
+
return enrichPropType(
|
|
63
|
+
realPropType(convertShape(propType.args)),
|
|
64
|
+
propType.reactDesc
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
if (isInstanceOf(propType, realPropType)) {
|
|
68
|
+
return enrichPropType(realPropType(propType.args), propType.reactDesc);
|
|
69
|
+
}
|
|
70
|
+
if (isOneOf(propType, realPropType)) {
|
|
71
|
+
return enrichPropType(realPropType(propType.args), propType.reactDesc);
|
|
72
|
+
}
|
|
73
|
+
if (isObjectOf(propType, realPropType)) {
|
|
74
|
+
return enrichPropType(realPropType(propType.args), propType.reactDesc);
|
|
75
|
+
}
|
|
76
|
+
if (isExact(propType, realPropType)) {
|
|
77
|
+
return enrichPropType(realPropType(propType.args), propType.reactDesc);
|
|
78
|
+
}
|
|
79
|
+
throw new Error(`react-desc: unknown error -- proptype with args is not matching`);
|
|
80
|
+
}
|
|
81
|
+
return enrichPropType(realPropType, propType.reactDesc);
|
|
82
|
+
};
|
|
83
|
+
export {
|
|
84
|
+
convertPropType
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=describeConversions.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/propTypes/describeConversions.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-statements */\n/* eslint-disable complexity */\n/* eslint-disable max-params */\n/* eslint-disable no-console */\n/* eslint-disable @typescript-eslint/no-use-before-define */\nimport type { ValidationMap, Requireable } from 'prop-types';\nimport PropTypes from 'prop-types';\nimport { tupleValidator } from './customPropTypes.js';\nimport {\n hasArguments,\n isArrayOf,\n isExact,\n isInstanceOf,\n isObjectOf,\n isOneOf,\n isOneOfType,\n isShape,\n} from './describeGuards.js';\nimport type { ReactDescT, ReactDescObjT, InstanceOfT, OneOfT, ObjectOfT, ExactT } from './types.js';\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 error = `Warning: \"${propName}\" property of \"${componentName}\" will be deprecated in version: ${version}.\\n${message}`;\n console.warn(error);\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,YAAY,WAAW;ACMvB,OAAO,eAAe;AACtB,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,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,GAAG,IAAI,UAAU;AACjD,YAAM,QAAQ,aAAa,0BAA0B,iDAAiD;AAAA,EAAa;AACnH,cAAQ,KAAK,KAAK;AAClB,gBAAU,SAAS;AAAA,IACrB;AACA,WAAO,SAAS,O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xC,aAAO,eAAe,aAAa,SAAS,IAAkC,GAAG,SAAS,SAAS;AAAA,IACrG;AACA,QAAI,QAAQ,UAAU,YAAY,GAAG;AACnC,aAAO,eAAe,aAAa,SAAS,IAA6B,GAAG,SAAS,SAAS;AAAA,IAChG;AACA,QAAI,WAAW,UAAU,YAAY,GAAG;AACtC,aAAO,eAAe,aAAa,SAAS,IAAgC,GAAG,SAAS,SAAS;AAAA,IACnG;AACA,QAAI,QAAQ,UAAU,YAAY,GAAG;AACnC,aAAO,eAAe,aAAa,SAAS,IAA6B,GAAG,SAAS,SAAS;AAAA,IAChG;AACA,UAAM,IAAI,MAAM,iEAAiE;AAAA,EACnF;AAEA,SAAO,eAAe,cAAc,SAAS,SAAS;AACxD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const hasArguments = (propType, realPropType) => !!propType.args;
|
|
3
|
+
const isOneOfType = (propType, realPropType) => propType.type === "oneOfType";
|
|
4
|
+
const isArrayOf = (propType, realPropType) => propType.type === "arrayOf";
|
|
5
|
+
const isShape = (propType, realPropType) => propType.type === "shape";
|
|
6
|
+
const isInstanceOf = (propType, realPropType) => propType.type === "instanceOf";
|
|
7
|
+
const isOneOf = (propType, realPropType) => propType.type === "oneOf";
|
|
8
|
+
const isObjectOf = (propType, realPropType) => propType.type === "objectOf";
|
|
9
|
+
const isExact = (propType, realPropType) => propType.type === "exact";
|
|
10
|
+
export {
|
|
11
|
+
hasArguments,
|
|
12
|
+
isArrayOf,
|
|
13
|
+
isExact,
|
|
14
|
+
isInstanceOf,
|
|
15
|
+
isObjectOf,
|
|
16
|
+
isOneOf,
|
|
17
|
+
isOneOfType,
|
|
18
|
+
isShape
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=describeGuards.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/propTypes/describeGuards.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type {\n AllPropTypes,\n ArrayOfT,\n ExactT,\n InstanceOfT,\n ObjectOfT,\n OneOfT,\n OneOfTypeT,\n ParametizedPropTypes,\n ReactDescT,\n ShapeT,\n} from './types.js';\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,YAAY,WAAW;ACahB,MAAM,eAAe,CAAC,UAAsB,iBACjD,CAAC,CAAC,SAAS;AAEN,MAAM,cAAc,CAAC,UAAsB,iBAChD,SAAS,SAAS;AAEb,MAAM,YAAY,CAAC,UAAsB,iBAC9C,SAAS,SAAS;AAEb,MAAM,UAAU,CAAC,UAAsB,iBAC5C,SAAS,SAAS;AAEb,MAAM,eAAe,CAAC,UAAsB,iBACjD,SAAS,SAAS;AAEb,MAAM,UAAU,CAAC,UAAsB,iBAC5C,SAAS,SAAS;AAEb,MAAM,aAAa,CAAC,UAAsB,iBAC/C,SAAS,SAAS;AAEb,MAAM,UAAU,CAAC,UAAsB,iBAC5C,SAAS,SAAS;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/propTypes/index.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import PropTypes from './PropTypes.js';\nimport describe from './describe.js';\n\nexport { describe, PropTypes };\nexport type { DSPropTypesSchema } from './types.js';\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,OAAO,eAAe;AACtB,OAAO,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
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 = propType?.reactDesc?.signature ?? "((...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
|
+
if (propType.type === "shape") {
|
|
99
|
+
propType.reactDesc.group = {};
|
|
100
|
+
Object.keys(propType.args).forEach((prop) => {
|
|
101
|
+
if (!propType.reactDesc.group)
|
|
102
|
+
return;
|
|
103
|
+
propType.reactDesc.group[prop] = propTypeAsTypescript(
|
|
104
|
+
propType.args[prop],
|
|
105
|
+
prop
|
|
106
|
+
);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
propTypes.push(propTypeAsTypescript(propType, propName));
|
|
110
|
+
});
|
|
111
|
+
if (propTypes.length > 0) {
|
|
112
|
+
documentation.properties = propTypes;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return documentation;
|
|
117
|
+
}
|
|
118
|
+
export {
|
|
119
|
+
descToTypescript as default
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=toTypescript.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/propTypes/toTypescript.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/restrict-template-expressions */\n/* eslint-disable @typescript-eslint/no-use-before-define */\n/* eslint-disable complexity */\n/* eslint-disable react/forbid-foreign-prop-types */\nimport type React from 'react';\nimport type { ComponentDocumentation, Hook, ReactDescT, TypescriptDocumentation } from './types.js';\n\nconst arrayFormat = (array: ReactDescT[]) => array.map((propType) => propTypeFormat(propType));\n\nconst shapeFormat = (shape: Record<string, ReactDescT>) => {\n const props = Object.keys(shape).map((key) => {\n const value = shape[key];\n let valueFormat;\n if (\n value.type &&\n (value.type === 'arrayOf' || value.type === 'oneOfType' || value.type === 'oneOf') &&\n Array.isArray(value.args)\n ) {\n valueFormat = `${propTypeFormat(value)}`;\n } else if (value.type === 'shape') {\n valueFormat = `${propTypeFormat(value)}`;\n } else {\n valueFormat = propTypeFormat(value);\n }\n return `${key}${value.reactDesc && value.reactDesc.required ? '' : '?'}: ${valueFormat}`;\n });\n return `{${props.join(',')}}`;\n};\n\nconst propTypeFormat = (propType: ReactDescT | ReactDescT[], joinWith = ''): string => {\n let result;\n if (Array.isArray(propType)) {\n result = arrayFormat(propType).join(joinWith);\n } else if (typeof propType !== 'function' && propType.type) {\n switch (propType.type) {\n case 'array':\n result = 'any[]';\n break;\n case 'arrayOf':\n if ((propType.args as ReactDescT).type === 'oneOfType') {\n result = `(${propTypeFormat(propType.args as ReactDescT, ' | ')})[]`;\n } else {\n result = `${propTypeFormat(propType.args as ReactDescT, '\\n')}[]`;\n }\n break;\n case 'tuple':\n result = `[${propTypeFormat(propType.args as ReactDescT, ', ')}]`;\n break;\n case 'bool':\n result = 'boolean';\n break;\n case 'func':\n result = propType?.reactDesc?.signature ?? '((...args: any[]) => any)';\n break;\n case 'node':\n result = 'React.ReactNode';\n break;\n case 'element':\n result = 'JSX.Element';\n break;\n case 'instanceOf':\n result = 'any';\n break;\n case 'symbol':\n result = 'any';\n break;\n case 'objectOf':\n result = `{ [key: string]: ${propTypeFormat(propType.args as ReactDescT)} }`;\n break;\n case 'oneOf':\n result = (propType.args as unknown[]).map((a) => `\"${a}\"`).join(' | ');\n break;\n case 'oneOfType':\n result = `${propTypeFormat(propType.args as ReactDescT[], ' | ')}`;\n break;\n case 'shape':\n result = `${shapeFormat(propType.args as Record<string, ReactDescT>)}`;\n break;\n default:\n result = `${propType.type}`;\n break;\n }\n } else {\n result = 'any';\n }\n return result;\n};\n\nconst propTypeAsTypescript = (propType: ReactDescT, propName: string) => {\n const documentation = {\n ...propType.reactDesc,\n name: propName,\n };\n\n documentation.format = propTypeFormat(propType);\n\n return documentation;\n};\n\nexport default function descToTypescript<C, R>(\n component: React.ComponentType<C> | Hook<C, R>,\n reactDesc: ComponentDocumentation,\n) {\n if (!component) {\n throw new Error('react-desc: component is required');\n }\n\n const documentation: Partial<TypescriptDocumentation> = {\n name: component.displayName || component.name,\n ...reactDesc,\n };\n if (reactDesc) {\n delete documentation.propTypes;\n\n if (reactDesc.propTypes) {\n const propTypes: TypescriptDocumentation['properties'] = [];\n Object.keys(reactDesc.propTypes).forEach((propName) => {\n const propType = reactDesc.propTypes[propName];\n if (propType.type === 'shape') {\n propType.reactDesc.group = {};\n\n Object.keys(propType.args as Record<string, ReactDescT>).forEach((prop) => {\n if (!propType.reactDesc.group) return;\n propType.reactDesc.group[prop] = propTypeAsTypescript(\n (propType.args as Record<string, ReactDescT>)[prop],\n prop,\n );\n });\n }\n propTypes.push(propTypeAsTypescript(propType, propName));\n });\n if (propTypes.length > 0) {\n documentation.properties = propTypes;\n }\n }\n }\n return documentation as TypescriptDocumentation;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACOvB,MAAM,cAAc,CAAC,UAAwB,MAAM,IAAI,CAAC,aAAa,eAAe,QAAQ,CAAC;AAE7F,MAAM,cAAc,CAAC,UAAsC;AACzD,QAAM,QAAQ,OAAO,KAAK,KAAK,EAAE,IAAI,CAAC,QAAQ;AAC5C,UAAM,QAAQ,MAAM,GAAG;AACvB,QAAI;AACJ,QACE,MAAM,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"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { PropTypes } from "../propTypes/index.js";
|
|
3
|
+
const isString = (value) => typeof value === "string";
|
|
4
|
+
const isDataTestId = (value) => typeof value === "object";
|
|
5
|
+
const getLeafValues = (obj) => {
|
|
6
|
+
const keys = Object.keys(obj);
|
|
7
|
+
const leafValues = keys.reduce((acc, key) => {
|
|
8
|
+
const value = obj[key];
|
|
9
|
+
if (isString(value)) {
|
|
10
|
+
acc.push(`${value}`);
|
|
11
|
+
} else if (isDataTestId(value)) {
|
|
12
|
+
acc.push(...getLeafValues(value));
|
|
13
|
+
}
|
|
14
|
+
return acc;
|
|
15
|
+
}, []);
|
|
16
|
+
return leafValues;
|
|
17
|
+
};
|
|
18
|
+
const getPropsPerDatatestIdPropTypes = (dataTestIdObj) => {
|
|
19
|
+
const leafValues = getLeafValues(dataTestIdObj);
|
|
20
|
+
const propsPerDataTestIdPropTypes = {};
|
|
21
|
+
leafValues.forEach((leafValue) => {
|
|
22
|
+
propsPerDataTestIdPropTypes[leafValue] = PropTypes.shape({
|
|
23
|
+
"aria-*": PropTypes.string.description("Aria related properties"),
|
|
24
|
+
"data-*": PropTypes.string.description("Any data property to attach to the root container"),
|
|
25
|
+
"on-*": PropTypes.func.description("Any supported React event"),
|
|
26
|
+
"all HTML attributes": PropTypes.any.description(
|
|
27
|
+
"HTML attributes such as id, className, autoComplete, href and so on"
|
|
28
|
+
)
|
|
29
|
+
}).description(`an object containing the definitions for ${leafValue} aria and data props`).dataTestId();
|
|
30
|
+
});
|
|
31
|
+
return propsPerDataTestIdPropTypes;
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
getPropsPerDatatestIdPropTypes
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=getPropsPerDatatestIdPropTypes.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/propsPerDataTestId/getPropsPerDatatestIdPropTypes.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable indent */\nimport { PropTypes } from '../propTypes/index.js';\nimport type { ReactDescT } from '../propTypes/types.js';\n\n// recursive type where the key is a string and the value it's the either a string or a recursive type\ntype DataTestId = {\n [key: string]: string | DataTestId;\n};\n// typescript typeguard to check if the value is a string\nconst isString = (value: string | DataTestId): value is string => typeof value === 'string';\n// typescript typeguard to check if the value is a DataTestId\nconst isDataTestId = (value: string | DataTestId): value is DataTestId => typeof value === 'object';\n\ntype PropsPerDataTestIdPropTypes = {\n [key: string]: ReactDescT['shape'];\n};\n// implementation of a helper function that retrieves the nested values of the input object\n// and returns an array of strings, each string is the value of a leaf of the input object\n/**\n *\n * @param {object} obj - object in which the values rapresent the keys of the output object\n * @returns {string[]} an array of strings, each string is the value of a leaf of the input object\n * @example\n * const obj = {\n * WHATEVER: 'data-testid',\n * NESTED:{\n * WHATEVER2: 'data-testid-2',\n * WHATEVER3: 'data-testid-3',\n * }\n * }\n * const leafValues = getLeafValues(obj);\n * leafValues === ['data-testid', 'data-testid-2', 'data-testid-3']\n */\nconst getLeafValues = (obj: DataTestId): string[] => {\n const keys = Object.keys(obj);\n const leafValues = keys.reduce((acc, key) => {\n const value = obj[key];\n if (isString(value)) {\n acc.push(`${value}`);\n } else if (isDataTestId(value)) {\n acc.push(...getLeafValues(value));\n }\n return acc;\n }, [] as string[]);\n return leafValues;\n};\n\n/**\n * @param {object} dataTestIdObj - object in which the values rapresent the keys of the output object\n * @returns {object} output - an object in which for each leaf value of the input object there is a key with aria-* and data-* props.shape definition\n * @example\n * const dataTestIdObj = {\n * WHATEVER: 'data-testid',\n * NESTED:{\n * WHATEVER2: 'data-testid-2',\n * WHATEVER3: 'data-testid-3',\n * }\n * }\n *\n * const propsPerDataTestIdPropTypes = getPropsPerDatatestIdPropTypes(dataTestIdObj);\n * // propsPerDataTestIdPropTypes will be\n * {\n * 'data-testid': PropTypes.shape({\n * 'aria-*': PropTypes.string,\n * 'data-*': PropTypes.string,\n * }),\n * 'data-testid-2': PropTypes.shape({\n * 'aria-*': PropTypes.string,\n * 'data-*': PropTypes.string,\n * })\n * 'data-testid-3': PropTypes.shape({\n * 'aria-*': PropTypes.string,\n * 'data-*': PropTypes.string,\n * })\n * }\n * @fires getLeafValues\n */\nexport const getPropsPerDatatestIdPropTypes = (dataTestIdObj: DataTestId): PropsPerDataTestIdPropTypes => {\n const leafValues = getLeafValues(dataTestIdObj);\n const propsPerDataTestIdPropTypes = {} as PropsPerDataTestIdPropTypes;\n leafValues.forEach((leafValue) => {\n propsPerDataTestIdPropTypes[leafValue] = PropTypes.shape({\n 'aria-*': PropTypes.string.description('Aria related properties'),\n 'data-*': PropTypes.string.description('Any data property to attach to the root container'),\n 'on-*': PropTypes.func.description('Any supported React event'),\n 'all HTML attributes': PropTypes.any.description(\n 'HTML attributes such as id, className, autoComplete, href and so on',\n ),\n })\n .description(`an object containing the definitions for ${leafValue} aria and data props`)\n .dataTestId();\n });\n return propsPerDataTestIdPropTypes;\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACCvB,SAAS,iBAAiB;AAQ1B,MAAM,WAAW,CAAC,UAAgD,OAAO,UAAU;AAEnF,MAAM,eAAe,CAAC,UAAoD,OAAO,UAAU;AAsB3F,MAAM,gBAAgB,CAAC,QAA8B;AACnD,QAAM,OAAO,OAAO,KAAK,GAAG;AAC5B,QAAM,aAAa,KAAK,OAAO,CAAC,KAAK,QAAQ;AAC3C,UAAM,QAAQ,IAAI,GAAG;AACrB,QAAI,SAAS,KAAK,GAAG;AACnB,UAAI,KAAK,GAAG,OAAO;AAAA,IACrB,WAAW,aAAa,KAAK,GAAG;AAC9B,UAAI,KAAK,GAAG,cAAc,KAAK,CAAC;AAAA,IAClC;AACA,WAAO;AAAA,EACT,GAAG,CAAC,CAAa;AACjB,SAAO;AACT;AAgCO,MAAM,iCAAiC,CAAC,kBAA2D;AACxG,QAAM,aAAa,cAAc,aAAa;AAC9C,QAAM,8BAA8B,CAAC;AACrC,aAAW,QAAQ,CAAC,cAAc;AAChC,gCAA4B,SAAS,IAAI,UAAU,MAAM;AAAA,MACvD,UAAU,UAAU,OAAO,YAAY,yBAAyB;AAAA,MAChE,UAAU,UAAU,OAAO,YAAY,mDAAmD;AAAA,MAC1F,QAAQ,UAAU,KAAK,YAAY,2BAA2B;AAAA,MAC9D,uBAAuB,UAAU,IAAI;AAAA,QACnC;AAAA,MACF;AAAA,IACF,CAAC,EACE,YAAY,4CAA4C,+BAA+B,EACvF,WAAW;AAAA,EAChB,CAAC;AACD,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { getAriaOrDataProps } from "../getProps/index.js";
|
|
3
|
+
const getPropsPerDatatestid = (userProps) => {
|
|
4
|
+
if (userProps === void 0 || userProps === null || typeof userProps !== "object" && typeof userProps !== "function")
|
|
5
|
+
return {};
|
|
6
|
+
if (typeof userProps === "function") {
|
|
7
|
+
const values = getAriaOrDataProps(userProps());
|
|
8
|
+
return values;
|
|
9
|
+
}
|
|
10
|
+
return getAriaOrDataProps(userProps);
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
getPropsPerDatatestid
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=getPropsPerDatatestid.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/propsPerDataTestId/getPropsPerDatatestid.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable indent */\n/* eslint-disable complexity */\nimport { getAriaOrDataProps } from '../getProps/index.js';\n\n/**\n * Returns the props for a given dataTestId.\n * props are going to be filtered so only aria related and data-* props are going to be returned.\n * @param {Record<string, string> | (() => Record<string, string>)} userProps - The props passed by the user.\n * @returns The props for the given dataTestId.\n * @example\n * const userProps = {\n * 'ds-controlled-date-time-picker-month-input': {\n * 'aria-label': 'month-input-aria-label',\n * 'data-test': 'month-input-data-test',\n * somethingElse: 'this will not be returned',\n * },\n * 'ds-controlled-date-time-picker-day-input': {\n * 'aria-label': 'day-aria-label',\n * 'data-test': 'day-data-test',\n * },\n * };\n * const dataTestIdProps = getDataTestIdProps(userProps['ds-controlled-date-time-picker-day-input']);\n * // dataTestIdProps = {\n * // 'aria-label': 'day-aria-label',\n * // 'data-test': 'day-data-test',\n * // }\n * @example\n * const userProps = {\n * 'ds-controlled-date-time-picker-month-input': {\n * 'aria-label': 'month-input-aria-label',\n * 'data-test': 'month-input-data-test',\n * },\n * 'ds-controlled-date-time-picker-day-input': (props) => ({ // notice that this is a function that returns an object\n * 'aria-label': 'day-aria-label',\n * 'data-test': 'day-data-test',\n * somethingElse: 'this will not be returned',\n * }),\n * };\n * const dataTestIdProps = getDataTestIdProps(userProps['ds-controlled-date-time-picker-day-input']);\n * // dataTestIdProps = {\n * // 'aria-label': 'day-aria-label',\n * // 'data-test': 'day-data-test',\n * // }\n * @fires getAriaOrDataProps\n */\nconst getPropsPerDatatestid = (userProps: AriaAndDataPropsOrPropsGetter | undefined) => {\n if (\n userProps === undefined ||\n userProps === null ||\n (typeof userProps !== 'object' && typeof userProps !== 'function')\n )\n return {};\n\n if (typeof userProps === 'function') {\n const values = getAriaOrDataProps(userProps());\n return values;\n }\n return getAriaOrDataProps(userProps);\n};\n\nexport { getPropsPerDatatestid };\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACEvB,SAAS,0BAA0B;AA2CnC,MAAM,wBAAwB,CAAC,cAAyD;AACtF,MACE,cAAc,UACd,cAAc,QACb,OAAO,cAAc,YAAY,OAAO,cAAc;AAEvD,WAAO,CAAC;AAEV,MAAI,OAAO,cAAc,YAAY;AACnC,UAAM,SAAS,mBAAmB,UAAU,CAAC;AAC7C,WAAO;AAAA,EACT;AACA,SAAO,mBAAmB,SAAS;AACrC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { getPropsPerDatatestid } from "./getPropsPerDatatestid.js";
|
|
3
|
+
import { getPropsPerDatatestIdPropTypes } from "./getPropsPerDatatestIdPropTypes.js";
|
|
4
|
+
export {
|
|
5
|
+
getPropsPerDatatestIdPropTypes,
|
|
6
|
+
getPropsPerDatatestid
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/propsPerDataTestId/index.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { getPropsPerDatatestid } from './getPropsPerDatatestid.js';\nexport { getPropsPerDatatestIdPropTypes } from './getPropsPerDatatestIdPropTypes.js';\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,6BAA6B;AACtC,SAAS,sCAAsC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import React2 from "react";
|
|
4
|
+
import { useGetGlobalAttributes } from "../../globalProps";
|
|
5
|
+
const TestComponent = (props) => {
|
|
6
|
+
const globalAttributes = useGetGlobalAttributes(props);
|
|
7
|
+
return /* @__PURE__ */ jsx("div", { ...globalAttributes, children: "Some random div" });
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
TestComponent
|
|
11
|
+
};
|
|
12
|
+
//# 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,YAAY,WAAW;ACMd;AANT,OAAOA,YAAW;AAClB,SAAS,8BAA8B;AAEhC,MAAM,gBAAgB,CAAC,UAAU;AACtC,QAAM,mBAAmB,uBAAuB,KAAK;AAErD,SAAO,oBAAC,SAAK,GAAG,kBAAkB,6BAAe;AACnD;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { PropTypes, describe } from "../../propTypes/index.ts";
|
|
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
|
+
something: PropTypes.oneOf(["thing", "object"]).description("something"),
|
|
31
|
+
isRequiredIf: PropTypes.string.description("isRequiredIf").isRequiredIf((props) => props.something === "thing"),
|
|
32
|
+
objectOf: PropTypes.objectOf(PropTypes.string).description("Object of"),
|
|
33
|
+
objectOfArray: PropTypes.objectOf(PropTypes.arrayOf(PropTypes.string)).description("Object of array")
|
|
34
|
+
};
|
|
35
|
+
const TestComponent = () => null;
|
|
36
|
+
const TestComponentWithSchema = describe(TestComponent).description("Test Component");
|
|
37
|
+
TestComponentWithSchema.propTypes = TestSchema;
|
|
38
|
+
const TypescriptSchema = TestComponentWithSchema.toTypescript();
|
|
39
|
+
export {
|
|
40
|
+
TypescriptSchema
|
|
41
|
+
};
|
|
42
|
+
//# 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 '../../propTypes/index.ts';\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 something: PropTypes.oneOf(['thing', 'object']).description('something'),\n isRequiredIf: PropTypes.string.description('isRequiredIf').isRequiredIf((props) => props.something === 'thing'),\n objectOf: PropTypes.objectOf(PropTypes.string).description('Object of'),\n objectOfArray: PropTypes.objectOf(PropTypes.arrayOf(PropTypes.string)).description('Object of array'),\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,YAAY,WAAW;ACAvB,SAAS,WAAW,gBAAgB;AAEpC,MAAM,aAAa;AAAA,EACjB,QAAQ,UAAU,OAAO,YAAY,QAAQ;AAAA,EAC7C,QAAQ,UAAU,OAAO,YAAY,QAAQ;AAAA,EAC7C,SAAS,UAAU,KAAK,YAAY,SAAS;AAAA,EAC7C,KAAK,UAAU,IAAI,YAAY,KAAK;AAAA,EACpC,OAAO,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC,EAAE,YAAY,OAAO;AAAA,EACpF,QAAQ,UAAU,MAAM,CAAC,KAAK,GAAG,CAAC,EAAE,YAAY,SAAS;AAAA,EACzD,QAAQ,UAAU,UAAU;AAAA,IAC1B,UAAU;AAAA,IACV,UA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
|
|
7
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import React2 from "react";
|
|
4
|
+
import { useGetXstyledProps } from "../../xstyledProps";
|
|
5
|
+
const TestComponent = (props) => {
|
|
6
|
+
const xstyledProps = useGetXstyledProps(props);
|
|
7
|
+
props.signal(xstyledProps);
|
|
8
|
+
return /* @__PURE__ */ jsx("div", { ...xstyledProps, "data-testid": "xstyled-div", children: "Some random div" });
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
TestComponent
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=TestComponent.js.map
|