@elliemae/ds-props-helpers 3.16.0-next.8 → 3.16.0-next.9
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/propTypes/PropTypes.js +2 -1
- package/dist/cjs/propTypes/PropTypes.js.map +2 -2
- package/dist/cjs/propTypes/toTypescript.js +11 -0
- package/dist/cjs/propTypes/toTypescript.js.map +2 -2
- package/dist/cjs/propTypes/types.js.map +1 -1
- package/dist/cjs/propsPerDataTestId/getPropsPerDatatestIdPropTypes.js +1 -1
- package/dist/cjs/propsPerDataTestId/getPropsPerDatatestIdPropTypes.js.map +2 -2
- package/dist/esm/propTypes/PropTypes.js +2 -1
- package/dist/esm/propTypes/PropTypes.js.map +2 -2
- package/dist/esm/propTypes/toTypescript.js +11 -0
- package/dist/esm/propTypes/toTypescript.js.map +2 -2
- package/dist/esm/propsPerDataTestId/getPropsPerDatatestIdPropTypes.js +1 -1
- package/dist/esm/propsPerDataTestId/getPropsPerDatatestIdPropTypes.js.map +2 -2
- package/dist/types/propTypes/types.d.ts +2 -0
- package/package.json +2 -2
|
@@ -33,7 +33,7 @@ const addPropTypeDocumentationField = (fieldName) => function addFieldToReactDes
|
|
|
33
33
|
this.reactDesc = {};
|
|
34
34
|
}
|
|
35
35
|
let realValue = value;
|
|
36
|
-
if (fieldName === "global" || fieldName === "hidden" || fieldName === "xstyled" || fieldName === "omitValidation")
|
|
36
|
+
if (fieldName === "global" || fieldName === "dataTestId" || fieldName === "hidden" || fieldName === "xstyled" || fieldName === "omitValidation")
|
|
37
37
|
realValue = true;
|
|
38
38
|
this.reactDesc[fieldName] = realValue;
|
|
39
39
|
return this;
|
|
@@ -47,6 +47,7 @@ const documentedPropType = {
|
|
|
47
47
|
global: addPropTypeDocumentationField("global"),
|
|
48
48
|
omitValidation: addPropTypeDocumentationField("omitValidation"),
|
|
49
49
|
hidden: addPropTypeDocumentationField("hidden"),
|
|
50
|
+
dataTestId: addPropTypeDocumentationField("dataTestId"),
|
|
50
51
|
xstyled: addPropTypeDocumentationField("xstyled"),
|
|
51
52
|
isRequiredIf: addPropTypeDocumentationField("isRequiredIf")
|
|
52
53
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/propTypes/PropTypes.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import type { PropTypesTypes, DocumentedPropType, ReactDescObjT, PropTypesObj } from './types';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["import type { PropTypesTypes, DocumentedPropType, ReactDescObjT, PropTypesObj } from './types';\nconst addPropTypeDocumentationField = <T extends keyof ReactDescObjT>(fieldName: T) =>\n function addFieldToReactDesc(this: DocumentedPropType, value: ReactDescObjT[T]): DocumentedPropType {\n if (!this.reactDesc) {\n this.reactDesc = {};\n }\n let realValue = value;\n if (\n fieldName === 'global' ||\n fieldName === 'dataTestId' ||\n fieldName === 'hidden' ||\n fieldName === 'xstyled' ||\n fieldName === 'omitValidation'\n )\n realValue = true;\n\n this.reactDesc[fieldName] = realValue;\n return this;\n };\n\nconst documentedPropType: Omit<DocumentedPropType, 'type' | 'isRequired' | 'reactDesc'> = {\n defaultValue: addPropTypeDocumentationField('defaultValue'),\n description: addPropTypeDocumentationField('description'),\n deprecated: addPropTypeDocumentationField('deprecated'),\n format: addPropTypeDocumentationField('format'),\n signature: addPropTypeDocumentationField('signature'),\n global: addPropTypeDocumentationField('global'),\n omitValidation: addPropTypeDocumentationField('omitValidation'),\n hidden: addPropTypeDocumentationField('hidden'),\n dataTestId: addPropTypeDocumentationField('dataTestId'),\n xstyled: addPropTypeDocumentationField('xstyled'),\n isRequiredIf: addPropTypeDocumentationField('isRequiredIf'),\n};\n\nconst createPropType = (type: PropTypesTypes) => {\n const propTypeObj = {\n type,\n ...documentedPropType,\n };\n Object.defineProperty(propTypeObj, 'isRequired', {\n get: function getRequired(this: DocumentedPropType) {\n if (!this.reactDesc) {\n this.reactDesc = {};\n }\n this.reactDesc.required = true;\n return this;\n },\n enumerable: true,\n configurable: true,\n });\n\n return propTypeObj;\n};\n\nconst createPropTypeWithArgs = (type: PropTypesTypes) => (args: unknown) => {\n const propTypeObj = {\n args,\n type,\n ...documentedPropType,\n };\n Object.defineProperty(propTypeObj, 'isRequired', {\n get: function getRequired(this: DocumentedPropType) {\n if (!this.reactDesc) {\n this.reactDesc = {};\n }\n this.reactDesc.required = true;\n return this;\n },\n enumerable: true,\n configurable: true,\n });\n return propTypeObj;\n};\n\nconst PropTypes = {\n custom: (callback: CallableFunction) => {\n const target = callback.bind(null) as CallableFunction & DocumentedPropType;\n target.type = 'func';\n Object.keys(documentedPropType).forEach((fieldName) => {\n const fieldNameCasted = fieldName as keyof DocumentedPropType;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n (target[fieldNameCasted] as unknown) = documentedPropType[fieldNameCasted] as unknown;\n });\n return target;\n },\n} as unknown as PropTypesObj;\n\nfunction definePropType(type: PropTypesTypes) {\n Object.defineProperty(PropTypes, type, {\n get: function getPropType() {\n return createPropType(type);\n },\n enumerable: true,\n configurable: true,\n });\n}\n\nfunction definePropTypeWithArgs(type: PropTypesTypes) {\n Object.defineProperty(PropTypes, type, {\n get: function getPropType() {\n return createPropTypeWithArgs(type);\n },\n enumerable: true,\n configurable: true,\n });\n}\n\ndefinePropType('any');\ndefinePropType('array');\ndefinePropType('bool');\ndefinePropType('element');\ndefinePropType('func');\ndefinePropType('node');\ndefinePropType('number');\ndefinePropType('object');\ndefinePropType('symbol');\ndefinePropType('string');\n\ndefinePropTypeWithArgs('arrayOf');\ndefinePropTypeWithArgs('instanceOf');\ndefinePropTypeWithArgs('objectOf');\ndefinePropTypeWithArgs('oneOfType');\ndefinePropTypeWithArgs('oneOf');\ndefinePropTypeWithArgs('shape');\ndefinePropTypeWithArgs('tuple');\n\nexport default PropTypes;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,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,aAAa;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,WAAK,UAAU,WAAW;AAC1B,aAAO;AAAA,IACT;AAAA,IACA,YAAY;AAAA,IACZ,cAAc;AAAA,EAChB,CAAC;AAED,SAAO;AACT;AAEA,MAAM,yBAAyB,CAAC,SAAyB,CAAC,SAAkB;AAC1E,QAAM,cAAc;AAA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uBAAuB,OAAO;AAE9B,IAAO,oBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -124,6 +124,17 @@ function descToTypescript(component, reactDesc) {
|
|
|
124
124
|
const propTypes = [];
|
|
125
125
|
Object.keys(reactDesc.propTypes).forEach((propName) => {
|
|
126
126
|
const propType = reactDesc.propTypes[propName];
|
|
127
|
+
if (propType.type === "shape") {
|
|
128
|
+
propType.reactDesc.group = {};
|
|
129
|
+
Object.keys(propType.args).forEach((prop) => {
|
|
130
|
+
if (!propType.reactDesc.group)
|
|
131
|
+
return;
|
|
132
|
+
propType.reactDesc.group[prop] = propTypeAsTypescript(
|
|
133
|
+
propType.args[prop],
|
|
134
|
+
prop
|
|
135
|
+
);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
127
138
|
propTypes.push(propTypeAsTypescript(propType, propName));
|
|
128
139
|
});
|
|
129
140
|
if (propTypes.length > 0) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/propTypes/toTypescript.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable @typescript-eslint/restrict-template-expressions */\n/* eslint-disable @typescript-eslint/no-use-before-define */\n/* eslint-disable complexity */\n/* eslint-disable react/forbid-foreign-prop-types */\nimport type React from 'react';\nimport type { ComponentDocumentation, Hook, ReactDescT, TypescriptDocumentation } from './types';\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 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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADOvB,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;AACpB,QAAI;AACJ,QACE,MAAM,SACL,MAAM,SAAS,aAAa,MAAM,SAAS,eAAe,MAAM,SAAS,YAC1E,MAAM,QAAQ,MAAM,IAAI,GACxB;AACA,oBAAc,GAAG,eAAe,KAAK;AAAA,IACvC,WAAW,MAAM,SAAS,SAAS;AACjC,oBAAc,GAAG,eAAe,KAAK;AAAA,IACvC,OAAO;AACL,oBAAc,eAAe,KAAK;AAAA,IACpC;AACA,WAAO,GAAG,MAAM,MAAM,aAAa,MAAM,UAAU,WAAW,KAAK,QAAQ;AAAA,EAC7E,CAAC;AACD,SAAO,IAAI,MAAM,KAAK,GAAG;AAC3B;AAEA,MAAM,iBAAiB,CAAC,UAAqC,WAAW,OAAe;AACrF,MAAI;AACJ,MAAI,MAAM,QAAQ,QAAQ,GAAG;AAC3B,aAAS,YAAY,QAAQ,EAAE,KAAK,QAAQ;AAAA,EAC9C,WAAW,OAAO,aAAa,cAAc,SAAS,MAAM;AAC1D,YAAQ,SAAS,MAAM;AAAA,MACrB,KAAK;AACH,iBAAS;AACT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,cAAc;AAErB,QAAI,UAAU,WAAW;AACvB,YAAM,YAAmD,CAAC;AAC1D,aAAO,KAAK,UAAU,SAAS,EAAE,QAAQ,CAAC,aAAa;AACrD,cAAM,WAAW,UAAU,UAAU;AACrC,kBAAU,KAAK,qBAAqB,UAAU,QAAQ,CAAC;AAAA,MACzD,CAAC;AACD,UAAI,UAAU,SAAS,GAAG;AACxB,sBAAc,aAAa;AAAA,MAC7B;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;",
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/restrict-template-expressions */\n/* eslint-disable @typescript-eslint/no-use-before-define */\n/* eslint-disable complexity */\n/* eslint-disable react/forbid-foreign-prop-types */\nimport type React from 'react';\nimport type { ComponentDocumentation, Hook, ReactDescT, TypescriptDocumentation } from './types';\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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADOvB,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;AACpB,QAAI;AACJ,QACE,MAAM,SACL,MAAM,SAAS,aAAa,MAAM,SAAS,eAAe,MAAM,SAAS,YAC1E,MAAM,QAAQ,MAAM,IAAI,GACxB;AACA,oBAAc,GAAG,eAAe,KAAK;AAAA,IACvC,WAAW,MAAM,SAAS,SAAS;AACjC,oBAAc,GAAG,eAAe,KAAK;AAAA,IACvC,OAAO;AACL,oBAAc,eAAe,KAAK;AAAA,IACpC;AACA,WAAO,GAAG,MAAM,MAAM,aAAa,MAAM,UAAU,WAAW,KAAK,QAAQ;AAAA,EAC7E,CAAC;AACD,SAAO,IAAI,MAAM,KAAK,GAAG;AAC3B;AAEA,MAAM,iBAAiB,CAAC,UAAqC,WAAW,OAAe;AACrF,MAAI;AACJ,MAAI,MAAM,QAAQ,QAAQ,GAAG;AAC3B,aAAS,YAAY,QAAQ,EAAE,KAAK,QAAQ;AAAA,EAC9C,WAAW,OAAO,aAAa,cAAc,SAAS,MAAM;AAC1D,YAAQ,SAAS,MAAM;AAAA,MACrB,KAAK;AACH,iBAAS;AACT;AAAA,MACF,KAAK;AACH,YAAK,SAAS,KAAoB,SAAS,aAAa;AACtD,mBAAS,IAAI,eAAe,SAAS,MAAoB,KAAK;AAAA,QAChE,OAAO;AACL,mBAAS,GAAG,eAAe,SAAS,MAAoB,IAAI;AAAA,QAC9D;AACA;AAAA,MACF,KAAK;AACH,iBAAS,IAAI,e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iBAAO,KAAK,SAAS,IAAkC,EAAE,QAAQ,CAAC,SAAS;AACzE,gBAAI,CAAC,SAAS,UAAU;AAAO;AAC/B,qBAAS,UAAU,MAAM,QAAQ;AAAA,cAC9B,SAAS,KAAoC;AAAA,cAC9C;AAAA,YACF;AAAA,UACF,CAAC;AAAA,QACH;AACA,kBAAU,KAAK,qBAAqB,UAAU,QAAQ,CAAC;AAAA,MACzD,CAAC;AACD,UAAI,UAAU,SAAS,GAAG;AACxB,sBAAc,aAAa;AAAA,MAC7B;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/propTypes/types.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import type {\n any,\n array,\n bool,\n func,\n number,\n object,\n string,\n node,\n element,\n symbol,\n elementType,\n instanceOf,\n oneOf,\n oneOfType,\n arrayOf,\n objectOf,\n shape,\n exact,\n ValidationMap,\n} from 'prop-types';\nimport type React from 'react';\n\nexport interface ReactDescObjT {\n [key: string]: unknown;\n required?: boolean;\n deprecated?: Record<string, string>;\n description?: string;\n defaultValue?: unknown;\n format?: string;\n signature?: string;\n warned?: boolean;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n isRequiredIf?: (props: any) => boolean;\n}\n\nexport type InstanceOfT = typeof instanceOf;\nexport type OneOfT = typeof oneOf;\nexport type ObjectOfT = typeof objectOf;\nexport type ExactT = typeof exact;\nexport type OneOfTypeT = typeof oneOfType;\nexport type ArrayOfT = typeof arrayOf;\nexport type ShapeT = typeof shape;\nexport type AnyT = typeof any;\nexport type ArrayT = typeof array;\nexport type BoolT = typeof bool;\nexport type FuncT = typeof func;\nexport type NumberT = typeof number;\nexport type ObjectT = typeof object;\nexport type StringT = typeof string;\nexport type NodeT = typeof node;\nexport type ElementT = typeof element;\nexport type SymbolT = typeof symbol;\nexport type ElementTypeT = typeof elementType;\n\nexport type ParametizedPropTypes = InstanceOfT | OneOfT | ObjectOfT | ExactT | OneOfTypeT | ArrayOfT | ShapeT;\n\nexport type AllPropTypes =\n | AnyT\n | ArrayT\n | BoolT\n | FuncT\n | NumberT\n | ObjectT\n | StringT\n | NodeT\n | ElementT\n | SymbolT\n | ElementTypeT\n | ParametizedPropTypes;\n\nexport type PropTypesTypes =\n | 'any'\n | 'array'\n | 'bool'\n | 'func'\n | 'number'\n | 'object'\n | 'string'\n | 'node'\n | 'element'\n | 'symbol'\n | 'elementType'\n | 'instanceOf'\n | 'oneOf'\n | 'oneOfType'\n | 'arrayOf'\n | 'objectOf'\n | 'shape'\n | 'exact'\n | 'tuple';\n\nexport interface ReactDescT {\n [key: string]: unknown;\n type: PropTypesTypes;\n defaultValue: (this: ReactDescT, dfault: unknown) => ReactDescT;\n deprecated: (this: ReactDescT, info: Record<string, string>) => ReactDescT;\n description: (this: ReactDescT, descr: string) => ReactDescT;\n format: (this: ReactDescT, format: string) => ReactDescT;\n signature: (this: ReactDescT, format: string) => ReactDescT;\n hidden: (this: ReactDescT) => ReactDescT;\n global: (this: ReactDescT) => ReactDescT;\n xstyled: (this: ReactDescT) => ReactDescT;\n omitValidation: (this: ReactDescT) => ReactDescT;\n isRequired: ReactDescT;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n isRequiredIf: (this: ReactDescT, isRequiredIf: (props: any) => boolean) => ReactDescT;\n reactDesc: ReactDescObjT;\n args?:\n | ReactDescT\n | ReactDescT[]\n | Record<string, ReactDescT>\n | unknown[]\n | Parameters<InstanceOfT>[0]\n | Parameters<OneOfT>[0]\n | Parameters<ObjectOfT>[0]\n | Parameters<ExactT>[0];\n}\n\nexport interface ComponentDocumentation {\n propTypes: Record<string, ReactDescT>;\n availableAt?: unknown;\n description?: string;\n details?: unknown;\n deprecated?: unknown;\n usage?: unknown;\n intrinsicElement?: unknown;\n toTypescript?: unknown;\n}\n\nexport interface TypescriptDocumentation extends Partial<ComponentDocumentation> {\n name: string;\n description: string;\n properties: {\n name: string;\n required?: boolean | undefined;\n deprecated?: Record<string, string> | undefined;\n description?: string;\n format?: string;\n signature?: string;\n warned?: boolean;\n defaultValue?: unknown;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n isRequiredIf?: (props: any) => boolean;\n omitValidation?: boolean;\n }[];\n}\n\nexport type DocumentedReactComponent<T> = React.ComponentType<T> & {\n availableAt: unknown;\n description: (descr: string) => DocumentedReactComponent<T>;\n details: unknown;\n deprecated: unknown;\n usage: unknown;\n intrinsicElement: unknown;\n toTypescript: () => TypescriptDocumentation;\n propTypesValue: ValidationMap<Record<string, unknown>>;\n};\n\nexport type Hook<T = unknown, S = unknown> = ((props: T) => S) & { displayName?: string; name?: string };\n\nexport type DocumentedPropType = ReactDescT;\n\nexport type PropTypesObj = {\n any: DocumentedPropType;\n array: DocumentedPropType;\n bool: DocumentedPropType;\n func: DocumentedPropType;\n number: DocumentedPropType;\n object: DocumentedPropType;\n string: DocumentedPropType;\n node: DocumentedPropType;\n element: DocumentedPropType;\n symbol: DocumentedPropType;\n elementType: DocumentedPropType;\n instanceOf: (cls: unknown) => DocumentedPropType;\n oneOf: (arr: unknown[]) => DocumentedPropType;\n oneOfType: (arr: DocumentedPropType[]) => DocumentedPropType;\n arrayOf: (smth: DocumentedPropType) => DocumentedPropType;\n objectOf: (smth: DocumentedPropType) => DocumentedPropType;\n shape: (obj: Record<string, DocumentedPropType>) => DocumentedPropType;\n exact: (obj: Record<string, DocumentedPropType>) => DocumentedPropType;\n tuple: (arr: DocumentedPropType[]) => DocumentedPropType;\n};\n\nexport type DSPropTypesSchema<T> = Required<{ [key in keyof T]: ReactDescT }>;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
4
|
+
"sourcesContent": ["import type {\n any,\n array,\n bool,\n func,\n number,\n object,\n string,\n node,\n element,\n symbol,\n elementType,\n instanceOf,\n oneOf,\n oneOfType,\n arrayOf,\n objectOf,\n shape,\n exact,\n ValidationMap,\n} from 'prop-types';\nimport type React from 'react';\n\nexport interface ReactDescObjT {\n [key: string]: unknown;\n required?: boolean;\n deprecated?: Record<string, string>;\n description?: string;\n defaultValue?: unknown;\n format?: string;\n signature?: string;\n warned?: boolean;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n isRequiredIf?: (props: any) => boolean;\n group?: Record<string, unknown>;\n}\n\nexport type InstanceOfT = typeof instanceOf;\nexport type OneOfT = typeof oneOf;\nexport type ObjectOfT = typeof objectOf;\nexport type ExactT = typeof exact;\nexport type OneOfTypeT = typeof oneOfType;\nexport type ArrayOfT = typeof arrayOf;\nexport type ShapeT = typeof shape;\nexport type AnyT = typeof any;\nexport type ArrayT = typeof array;\nexport type BoolT = typeof bool;\nexport type FuncT = typeof func;\nexport type NumberT = typeof number;\nexport type ObjectT = typeof object;\nexport type StringT = typeof string;\nexport type NodeT = typeof node;\nexport type ElementT = typeof element;\nexport type SymbolT = typeof symbol;\nexport type ElementTypeT = typeof elementType;\n\nexport type ParametizedPropTypes = InstanceOfT | OneOfT | ObjectOfT | ExactT | OneOfTypeT | ArrayOfT | ShapeT;\n\nexport type AllPropTypes =\n | AnyT\n | ArrayT\n | BoolT\n | FuncT\n | NumberT\n | ObjectT\n | StringT\n | NodeT\n | ElementT\n | SymbolT\n | ElementTypeT\n | ParametizedPropTypes;\n\nexport type PropTypesTypes =\n | 'any'\n | 'array'\n | 'bool'\n | 'func'\n | 'number'\n | 'object'\n | 'string'\n | 'node'\n | 'element'\n | 'symbol'\n | 'elementType'\n | 'instanceOf'\n | 'oneOf'\n | 'oneOfType'\n | 'arrayOf'\n | 'objectOf'\n | 'shape'\n | 'exact'\n | 'tuple';\n\nexport interface ReactDescT {\n [key: string]: unknown;\n type: PropTypesTypes;\n defaultValue: (this: ReactDescT, dfault: unknown) => ReactDescT;\n deprecated: (this: ReactDescT, info: Record<string, string>) => ReactDescT;\n description: (this: ReactDescT, descr: string) => ReactDescT;\n format: (this: ReactDescT, format: string) => ReactDescT;\n signature: (this: ReactDescT, format: string) => ReactDescT;\n hidden: (this: ReactDescT) => ReactDescT;\n dataTestId: (this: ReactDescT) => ReactDescT;\n global: (this: ReactDescT) => ReactDescT;\n xstyled: (this: ReactDescT) => ReactDescT;\n omitValidation: (this: ReactDescT) => ReactDescT;\n isRequired: ReactDescT;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n isRequiredIf: (this: ReactDescT, isRequiredIf: (props: any) => boolean) => ReactDescT;\n reactDesc: ReactDescObjT;\n args?:\n | ReactDescT\n | ReactDescT[]\n | Record<string, ReactDescT>\n | unknown[]\n | Parameters<InstanceOfT>[0]\n | Parameters<OneOfT>[0]\n | Parameters<ObjectOfT>[0]\n | Parameters<ExactT>[0];\n}\n\nexport interface ComponentDocumentation {\n propTypes: Record<string, ReactDescT>;\n availableAt?: unknown;\n description?: string;\n details?: unknown;\n deprecated?: unknown;\n usage?: unknown;\n intrinsicElement?: unknown;\n toTypescript?: unknown;\n}\n\nexport interface TypescriptDocumentation extends Partial<ComponentDocumentation> {\n name: string;\n description: string;\n properties: {\n name: string;\n required?: boolean | undefined;\n deprecated?: Record<string, string> | undefined;\n description?: string;\n format?: string;\n signature?: string;\n warned?: boolean;\n defaultValue?: unknown;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n isRequiredIf?: (props: any) => boolean;\n omitValidation?: boolean;\n }[];\n}\n\nexport type DocumentedReactComponent<T> = React.ComponentType<T> & {\n availableAt: unknown;\n description: (descr: string) => DocumentedReactComponent<T>;\n details: unknown;\n deprecated: unknown;\n usage: unknown;\n intrinsicElement: unknown;\n toTypescript: () => TypescriptDocumentation;\n propTypesValue: ValidationMap<Record<string, unknown>>;\n};\n\nexport type Hook<T = unknown, S = unknown> = ((props: T) => S) & { displayName?: string; name?: string };\n\nexport type DocumentedPropType = ReactDescT;\n\nexport type PropTypesObj = {\n any: DocumentedPropType;\n array: DocumentedPropType;\n bool: DocumentedPropType;\n func: DocumentedPropType;\n number: DocumentedPropType;\n object: DocumentedPropType;\n string: DocumentedPropType;\n node: DocumentedPropType;\n element: DocumentedPropType;\n symbol: DocumentedPropType;\n elementType: DocumentedPropType;\n instanceOf: (cls: unknown) => DocumentedPropType;\n oneOf: (arr: unknown[]) => DocumentedPropType;\n oneOfType: (arr: DocumentedPropType[]) => DocumentedPropType;\n arrayOf: (smth: DocumentedPropType) => DocumentedPropType;\n objectOf: (smth: DocumentedPropType) => DocumentedPropType;\n shape: (obj: Record<string, DocumentedPropType>) => DocumentedPropType;\n exact: (obj: Record<string, DocumentedPropType>) => DocumentedPropType;\n tuple: (arr: DocumentedPropType[]) => DocumentedPropType;\n};\n\nexport type DSPropTypesSchema<T> = Required<{ [key in keyof T]: ReactDescT }>;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;ACAA,YAAuB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -51,7 +51,7 @@ const getPropsPerDatatestIdPropTypes = (dataTestIdObj) => {
|
|
|
51
51
|
propsPerDataTestIdPropTypes[leafValue] = import_propTypes.PropTypes.shape({
|
|
52
52
|
"aria-*": import_propTypes.PropTypes.string.description("Aria related properties"),
|
|
53
53
|
"data-*": import_propTypes.PropTypes.string.description("Any data property to attach to the root container")
|
|
54
|
-
}).description(`an object containing the definitions for ${leafValue} aria and data props`);
|
|
54
|
+
}).description(`an object containing the definitions for ${leafValue} aria and data props`).dataTestId();
|
|
55
55
|
});
|
|
56
56
|
return propsPerDataTestIdPropTypes;
|
|
57
57
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/propsPerDataTestId/getPropsPerDatatestIdPropTypes.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable indent */\nimport { PropTypes } from '../propTypes';\nimport type { ReactDescT } from '../propTypes/types';\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 }).description(`an object containing the definitions for ${leafValue} aria and data props`);\n });\n return propsPerDataTestIdPropTypes;\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,uBAA0B;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;AAClB,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,aAAa,2BAAU,MAAM;AAAA,MACvD,UAAU,2BAAU,OAAO,YAAY,yBAAyB;AAAA,MAChE,UAAU,2BAAU,OAAO,YAAY,mDAAmD;AAAA,IAC5F,CAAC,
|
|
4
|
+
"sourcesContent": ["/* eslint-disable indent */\nimport { PropTypes } from '../propTypes';\nimport type { ReactDescT } from '../propTypes/types';\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 })\n .description(`an object containing the definitions for ${leafValue} aria and data props`)\n .dataTestId();\n });\n return propsPerDataTestIdPropTypes;\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,uBAA0B;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;AAClB,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,aAAa,2BAAU,MAAM;AAAA,MACvD,UAAU,2BAAU,OAAO,YAAY,yBAAyB;AAAA,MAChE,UAAU,2BAAU,OAAO,YAAY,mDAAmD;AAAA,IAC5F,CAAC,EACE,YAAY,4CAA4C,+BAA+B,EACvF,WAAW;AAAA,EAChB,CAAC;AACD,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -4,7 +4,7 @@ const addPropTypeDocumentationField = (fieldName) => function addFieldToReactDes
|
|
|
4
4
|
this.reactDesc = {};
|
|
5
5
|
}
|
|
6
6
|
let realValue = value;
|
|
7
|
-
if (fieldName === "global" || fieldName === "hidden" || fieldName === "xstyled" || fieldName === "omitValidation")
|
|
7
|
+
if (fieldName === "global" || fieldName === "dataTestId" || fieldName === "hidden" || fieldName === "xstyled" || fieldName === "omitValidation")
|
|
8
8
|
realValue = true;
|
|
9
9
|
this.reactDesc[fieldName] = realValue;
|
|
10
10
|
return this;
|
|
@@ -18,6 +18,7 @@ const documentedPropType = {
|
|
|
18
18
|
global: addPropTypeDocumentationField("global"),
|
|
19
19
|
omitValidation: addPropTypeDocumentationField("omitValidation"),
|
|
20
20
|
hidden: addPropTypeDocumentationField("hidden"),
|
|
21
|
+
dataTestId: addPropTypeDocumentationField("dataTestId"),
|
|
21
22
|
xstyled: addPropTypeDocumentationField("xstyled"),
|
|
22
23
|
isRequiredIf: addPropTypeDocumentationField("isRequiredIf")
|
|
23
24
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/propTypes/PropTypes.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { PropTypesTypes, DocumentedPropType, ReactDescObjT, PropTypesObj } from './types';\
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { PropTypesTypes, DocumentedPropType, ReactDescObjT, PropTypesObj } from './types';\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;ACCvB,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,aAAa;AAC5B,SAAO;AACT;AAEF,MAAM,qBAAoF;AAAA,EACxF,cAAc,8BAA8B,cAAc;AAAA,EA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BAA+B,mBAAmB;AAAA,IAC5D,CAAC;AACD,WAAO;AAAA,EACT;AACF;AAEA,SAAS,eAAe,MAAsB;AAC5C,SAAO,eAAe,WAAW,MAAM;AAAA,IACrC,KAAK,SAAS,cAAc;AAC1B,aAAO,eAAe,IAAI;AAAA,IAC5B;AAAA,IACA,YAAY;AAAA,IACZ,cAAc;AAAA,EAChB,CAAC;AACH;AAEA,SAAS,uBAAuB,MAAsB;AACpD,SAAO,eAAe,WAAW,MAAM;AAAA,IACrC,KAAK,SAAS,cAAc;AAC1B,aAAO,uBAAuB,IAAI;AAAA,IACpC;AAAA,IACA,YAAY;AAAA,IACZ,cAAc;AAAA,EAChB,CAAC;AACH;AAEA,eAAe,KAAK;AACpB,eAAe,OAAO;AACtB,eAAe,MAAM;AACrB,eAAe,SAAS;AACxB,eAAe,MAAM;AACrB,eAAe,MAAM;AACrB,eAAe,QAAQ;AACvB,eAAe,QAAQ;AACvB,eAAe,QAAQ;AACvB,eAAe,QAAQ;AAEvB,uBAAuB,SAAS;AAChC,uBAAuB,YAAY;AACnC,uBAAuB,UAAU;AACjC,uBAAuB,WAAW;AAClC,uBAAuB,OAAO;AAC9B,uBAAuB,OAAO;AAC9B,uBAAuB,OAAO;AAE9B,IAAO,oBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -95,6 +95,17 @@ function descToTypescript(component, reactDesc) {
|
|
|
95
95
|
const propTypes = [];
|
|
96
96
|
Object.keys(reactDesc.propTypes).forEach((propName) => {
|
|
97
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
|
+
}
|
|
98
109
|
propTypes.push(propTypeAsTypescript(propType, propName));
|
|
99
110
|
});
|
|
100
111
|
if (propTypes.length > 0) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/propTypes/toTypescript.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/restrict-template-expressions */\n/* eslint-disable @typescript-eslint/no-use-before-define */\n/* eslint-disable complexity */\n/* eslint-disable react/forbid-foreign-prop-types */\nimport type React from 'react';\nimport type { ComponentDocumentation, Hook, ReactDescT, TypescriptDocumentation } from './types';\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 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,IAA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F,KAAK;AACH,iBAAU,SAAS,KAAmB,IAAI,CAAC,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK;AACrE;AAAA,MACF,KAAK;AACH,iBAAS,GAAG,eAAe,SAAS,MAAsB,KAAK;AAC/D;AAAA,MACF,KAAK;AACH,iBAAS,GAAG,YAAY,SAAS,IAAkC;AACnE;AAAA,MACF;AACE,iBAAS,GAAG,SAAS;AACrB;AAAA,IACJ;AAAA,EACF,OAAO;AACL,aAAS;AAAA,EACX;AACA,SAAO;AACT;AAEA,MAAM,uBAAuB,CAAC,UAAsB,aAAqB;AACvE,QAAM,gBAAgB;AAAA,IACpB,GAAG,SAAS;AAAA,IACZ,MAAM;AAAA,EACR;AAEA,gBAAc,SAAS,eAAe,QAAQ;AAE9C,SAAO;AACT;AAEe,SAAR,iBACL,WACA,WACA;AACA,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,mCAAmC;AAAA,EACrD;AAEA,QAAM,gBAAkD;AAAA,IACtD,MAAM,UAAU,eAAe,UAAU;AAAA,IACzC,GAAG;AAAA,EACL;AACA,MAAI,WAAW;AACb,WAAO,cAAc;AAErB,QAAI,UAAU,WAAW;AACvB,YAAM,YAAmD,CAAC;AAC1D,aAAO,KAAK,UAAU,SAAS,EAAE,QAAQ,CAAC,aAAa;AACrD,cAAM,WAAW,UAAU,UAAU;AACrC,kBAAU,KAAK,qBAAqB,UAAU,QAAQ,CAAC;AAAA,MACzD,CAAC;AACD,UAAI,UAAU,SAAS,GAAG;AACxB,sBAAc,aAAa;AAAA,MAC7B;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;",
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/restrict-template-expressions */\n/* eslint-disable @typescript-eslint/no-use-before-define */\n/* eslint-disable complexity */\n/* eslint-disable react/forbid-foreign-prop-types */\nimport type React from 'react';\nimport type { ComponentDocumentation, Hook, ReactDescT, TypescriptDocumentation } from './types';\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;AACpB,QAAI;AACJ,QACE,MAAM,SACL,MAAM,SAAS,aAAa,MAAM,SAAS,eAAe,MAAM,SAAS,YAC1E,MAAM,QAAQ,MAAM,IAAI,GACxB;AACA,oBAAc,GAAG,eAAe,KAAK;AAAA,IACvC,WAAW,MAAM,SAAS,SAAS;AACjC,oBAAc,GAAG,eAAe,KAAK;AAAA,IAC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AAAA,EACF,OAAO;AACL,aAAS;AAAA,EACX;AACA,SAAO;AACT;AAEA,MAAM,uBAAuB,CAAC,UAAsB,aAAqB;AACvE,QAAM,gBAAgB;AAAA,IACpB,GAAG,SAAS;AAAA,IACZ,MAAM;AAAA,EACR;AAEA,gBAAc,SAAS,eAAe,QAAQ;AAE9C,SAAO;AACT;AAEe,SAAR,iBACL,WACA,WACA;AACA,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,mCAAmC;AAAA,EACrD;AAEA,QAAM,gBAAkD;AAAA,IACtD,MAAM,UAAU,eAAe,UAAU;AAAA,IACzC,GAAG;AAAA,EACL;AACA,MAAI,WAAW;AACb,WAAO,cAAc;AAErB,QAAI,UAAU,WAAW;AACvB,YAAM,YAAmD,CAAC;AAC1D,aAAO,KAAK,UAAU,SAAS,EAAE,QAAQ,CAAC,aAAa;AACrD,cAAM,WAAW,UAAU,UAAU;AACrC,YAAI,SAAS,SAAS,SAAS;AAC7B,mBAAS,UAAU,QAAQ,CAAC;AAE5B,iBAAO,KAAK,SAAS,IAAkC,EAAE,QAAQ,CAAC,SAAS;AACzE,gBAAI,CAAC,SAAS,UAAU;AAAO;AAC/B,qBAAS,UAAU,MAAM,QAAQ;AAAA,cAC9B,SAAS,KAAoC;AAAA,cAC9C;AAAA,YACF;AAAA,UACF,CAAC;AAAA,QACH;AACA,kBAAU,KAAK,qBAAqB,UAAU,QAAQ,CAAC;AAAA,MACzD,CAAC;AACD,UAAI,UAAU,SAAS,GAAG;AACxB,sBAAc,aAAa;AAAA,MAC7B;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -22,7 +22,7 @@ const getPropsPerDatatestIdPropTypes = (dataTestIdObj) => {
|
|
|
22
22
|
propsPerDataTestIdPropTypes[leafValue] = PropTypes.shape({
|
|
23
23
|
"aria-*": PropTypes.string.description("Aria related properties"),
|
|
24
24
|
"data-*": PropTypes.string.description("Any data property to attach to the root container")
|
|
25
|
-
}).description(`an object containing the definitions for ${leafValue} aria and data props`);
|
|
25
|
+
}).description(`an object containing the definitions for ${leafValue} aria and data props`).dataTestId();
|
|
26
26
|
});
|
|
27
27
|
return propsPerDataTestIdPropTypes;
|
|
28
28
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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';\nimport type { ReactDescT } from '../propTypes/types';\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 }).description(`an object containing the definitions for ${leafValue} aria and data props`);\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;AAClB,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,aAAa,UAAU,MAAM;AAAA,MACvD,UAAU,UAAU,OAAO,YAAY,yBAAyB;AAAA,MAChE,UAAU,UAAU,OAAO,YAAY,mDAAmD;AAAA,IAC5F,CAAC,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable indent */\nimport { PropTypes } from '../propTypes';\nimport type { ReactDescT } from '../propTypes/types';\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 })\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;AAClB,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,aAAa,UAAU,MAAM;AAAA,MACvD,UAAU,UAAU,OAAO,YAAY,yBAAyB;AAAA,MAChE,UAAU,UAAU,OAAO,YAAY,mDAAmD;AAAA,IAC5F,CAAC,EACE,YAAY,4CAA4C,+BAA+B,EACvF,WAAW;AAAA,EAChB,CAAC;AACD,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -10,6 +10,7 @@ export interface ReactDescObjT {
|
|
|
10
10
|
signature?: string;
|
|
11
11
|
warned?: boolean;
|
|
12
12
|
isRequiredIf?: (props: any) => boolean;
|
|
13
|
+
group?: Record<string, unknown>;
|
|
13
14
|
}
|
|
14
15
|
export type InstanceOfT = typeof instanceOf;
|
|
15
16
|
export type OneOfT = typeof oneOf;
|
|
@@ -41,6 +42,7 @@ export interface ReactDescT {
|
|
|
41
42
|
format: (this: ReactDescT, format: string) => ReactDescT;
|
|
42
43
|
signature: (this: ReactDescT, format: string) => ReactDescT;
|
|
43
44
|
hidden: (this: ReactDescT) => ReactDescT;
|
|
45
|
+
dataTestId: (this: ReactDescT) => ReactDescT;
|
|
44
46
|
global: (this: ReactDescT) => ReactDescT;
|
|
45
47
|
xstyled: (this: ReactDescT) => ReactDescT;
|
|
46
48
|
omitValidation: (this: ReactDescT) => ReactDescT;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-props-helpers",
|
|
3
|
-
"version": "3.16.0-next.
|
|
3
|
+
"version": "3.16.0-next.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Props Helpers",
|
|
6
6
|
"files": [
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"indent": 4
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@elliemae/ds-system": "3.16.0-next.
|
|
35
|
+
"@elliemae/ds-system": "3.16.0-next.9"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@testing-library/jest-dom": "~5.16.4",
|