@elliemae/ds-props-helpers 3.0.0-alpha.2 → 3.0.0-next.10
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/index.js +1 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/propTypes/PropTypes.js +1 -1
- package/dist/cjs/propTypes/PropTypes.js.map +1 -1
- package/dist/cjs/propTypes/describe.js.map +2 -2
- package/dist/cjs/propTypes/describeConversions.js +2 -2
- package/dist/cjs/propTypes/describeConversions.js.map +2 -2
- package/dist/cjs/propTypes/toTypescript.js.map +2 -2
- package/dist/cjs/propTypes/types.js.map +1 -1
- package/dist/cjs/tests/xstyledProps/TestComponent.js +60 -0
- package/dist/cjs/tests/xstyledProps/TestComponent.js.map +7 -0
- package/dist/cjs/useDeprecateComponent/index.js +40 -0
- package/dist/cjs/useDeprecateComponent/index.js.map +7 -0
- package/dist/cjs/validation/typescriptValidator.js.map +2 -2
- package/dist/cjs/xstyledProps/constants.js.map +1 -1
- package/dist/cjs/xstyledProps/useGetXstyledProps.js.map +3 -3
- package/dist/cjs/xstyledProps/xstyledPropTypes.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/propTypes/PropTypes.js +1 -1
- package/dist/esm/propTypes/PropTypes.js.map +1 -1
- package/dist/esm/propTypes/describe.js.map +2 -2
- package/dist/esm/propTypes/describeConversions.js +2 -2
- package/dist/esm/propTypes/describeConversions.js.map +2 -2
- package/dist/esm/propTypes/toTypescript.js.map +2 -2
- package/dist/esm/tests/xstyledProps/TestComponent.js +33 -0
- package/dist/esm/tests/xstyledProps/TestComponent.js.map +7 -0
- package/dist/esm/useDeprecateComponent/index.js +11 -0
- package/dist/esm/useDeprecateComponent/index.js.map +7 -0
- package/dist/esm/validation/typescriptValidator.js.map +2 -2
- package/dist/esm/xstyledProps/constants.js.map +1 -1
- package/dist/esm/xstyledProps/useGetXstyledProps.js.map +3 -3
- package/dist/esm/xstyledProps/xstyledPropTypes.js.map +1 -1
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -29,5 +29,6 @@ __reExport(src_exports, require("./globalProps"));
|
|
|
29
29
|
__reExport(src_exports, require("./propTypes"));
|
|
30
30
|
__reExport(src_exports, require("./validation"));
|
|
31
31
|
__reExport(src_exports, require("./xstyledProps"));
|
|
32
|
+
__reExport(src_exports, require("./useDeprecateComponent"));
|
|
32
33
|
module.exports = __toCommonJS(src_exports);
|
|
33
34
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["export * from './defaultProps';\nexport * from './getProps';\nexport * from './globalProps';\nexport * from './propTypes';\nexport * from './validation';\nexport * from './xstyledProps';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA,YAAuB;ADAvB,wBAAc;AACd,wBAAc;AACd,wBAAc;AACd,wBAAc;AACd,wBAAc;AACd,wBAAc;",
|
|
4
|
+
"sourcesContent": ["export * from './defaultProps';\nexport * from './getProps';\nexport * from './globalProps';\nexport * from './propTypes';\nexport * from './validation';\nexport * from './xstyledProps';\nexport * from './useDeprecateComponent';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA,YAAuB;ADAvB,wBAAc;AACd,wBAAc;AACd,wBAAc;AACd,wBAAc;AACd,wBAAc;AACd,wBAAc;AACd,wBAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -61,7 +61,7 @@ const documentedPropType = {
|
|
|
61
61
|
format: addPropTypeDocumentationField("format"),
|
|
62
62
|
global: addPropTypeDocumentationField("global"),
|
|
63
63
|
hidden: addPropTypeDocumentationField("hidden"),
|
|
64
|
-
xstyled: addPropTypeDocumentationField("
|
|
64
|
+
xstyled: addPropTypeDocumentationField("xstyled")
|
|
65
65
|
};
|
|
66
66
|
const createPropType = (type) => {
|
|
67
67
|
const propTypeObj = __spreadValues({
|
|
@@ -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 { PropTypesTypes, DocumentedPropType, ReactDescObjT, PropTypesObj } from './types';\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 (fieldName === 'global' || fieldName === 'hidden' || fieldName === 'xstyled') 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 global: addPropTypeDocumentationField('global'),\n hidden: addPropTypeDocumentationField('hidden'),\n xstyled: addPropTypeDocumentationField('
|
|
4
|
+
"sourcesContent": ["import { PropTypesTypes, DocumentedPropType, ReactDescObjT, PropTypesObj } from './types';\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 (fieldName === 'global' || fieldName === 'hidden' || fieldName === 'xstyled') 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 global: addPropTypeDocumentationField('global'),\n hidden: addPropTypeDocumentationField('hidden'),\n xstyled: addPropTypeDocumentationField('xstyled'),\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
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,MAAM,gCAAgC,CAAgC,cACpE,6BAAuD,OAA6C;AAClG,MAAI,CAAC,KAAK,WAAW;AACnB,SAAK,YAAY;AAAA;AAEnB,MAAI,YAAY;AAChB,MAAI,cAAc,YAAY,cAAc,YAAY,cAAc;AAAW,gBAAY;AAE7F,OAAK,UAAU,aAAa;AAC5B,SAAO;AAAA;AAGX,MAAM,qBAAoF;AAAA,EACxF,cAAc,8BAA8B;AAAA,EAC5C,aAAa,8BAA8B;AAAA,EAC3C,YAAY,8BAA8B;AAAA,EAC1C,QAAQ,8BAA8B;AAAA,EACtC,QAAQ,8BAA8B;AAAA,EACtC,QAAQ,8BAA8B;AAAA,EACtC,SAAS,8BAA8B;AAAA;AAGzC,MAAM,iBAAiB,CAAC,SAAyB;AAC/C,QAAM,cAAc;AAAA,IAClB;AAAA,KACG;AAEL,SAAO,eAAe,aAAa,cAAc;AAAA,IAC/C,KAAK,uBAA+C;AAClD,UAAI,CAAC,KAAK,WAAW;AACnB,aAAK,YAAY;AAAA;AAEnB,WAAK,UAAU,WAAW;AAC1B,aAAO;AAAA;AAAA,IAET,YAAY;AAAA,IACZ,cAAc;AAAA;AAGhB,SAAO;AAAA;AAGT,MAAM,yBAAyB,CAAC,SAAyB,CA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sourcesContent": ["/* eslint-disable react/forbid-foreign-prop-types */\nimport { Requireable, Validator } from 'prop-types';\nimport React from 'react';\nimport { convertPropType } from './describeConversions';\nimport descToTypescript from './toTypescript';\nimport { ReactDescT, ComponentDocumentation, DocumentedReactComponent } from './types';\n\nexport default function describe<C>(ComponentInstance: React.ComponentType<C>) {\n if (!ComponentInstance) {\n throw new Error('react-desc: component is required');\n }\n\n const documentation: ComponentDocumentation = {\n propTypes: {},\n };\n\n const DocumentedComponent = ComponentInstance as DocumentedReactComponent<C>;\n\n const addDocumentationProp = <T extends keyof ComponentDocumentation>(propName: T) => {\n const func = (value: ComponentDocumentation[T]): DocumentedReactComponent<C> => {\n documentation[propName] = value;\n return DocumentedComponent;\n };\n return func;\n };\n\n DocumentedComponent.availableAt = addDocumentationProp('availableAt');\n DocumentedComponent.description = addDocumentationProp('description');\n DocumentedComponent.details = addDocumentationProp('details');\n DocumentedComponent.deprecated = addDocumentationProp('deprecated');\n DocumentedComponent.usage = addDocumentationProp('usage');\n DocumentedComponent.intrinsicElement = addDocumentationProp('intrinsicElement');\n\n DocumentedComponent.toTypescript = () => descToTypescript(ComponentInstance, documentation);\n\n Object.defineProperty(DocumentedComponent, 'propTypes', {\n get: () => DocumentedComponent.propTypesValue,\n set: (value: Record<string, ReactDescT>) => {\n if (!DocumentedComponent.propTypesValue) {\n DocumentedComponent.propTypesValue = {};\n }\n\n Object.keys(value).forEach((name) => {\n const propType: ReactDescT = value[name];\n let realPropType: Requireable<unknown> | Validator<unknown>;\n documentation.propTypes[name] = propType;\n realPropType = convertPropType(propType);\n if (value[name].reactDesc.required) {\n realPropType = (realPropType as Requireable<unknown>).isRequired;\n }\n DocumentedComponent.propTypesValue[name] = realPropType as Validator<unknown>;\n return propType;\n });\n },\n enumerable: true,\n configurable: true,\n });\n\n return DocumentedComponent;\n}\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,iCAAgC;AAChC,0BAA6B;AAGd,
|
|
4
|
+
"sourcesContent": ["/* eslint-disable react/forbid-foreign-prop-types */\nimport { Requireable, Validator } from 'prop-types';\nimport React from 'react';\nimport { convertPropType } from './describeConversions';\nimport descToTypescript from './toTypescript';\nimport { ReactDescT, Hook, ComponentDocumentation, DocumentedReactComponent } from './types';\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 if (value[name].reactDesc.required) {\n realPropType = (realPropType as Requireable<unknown>).isRequired;\n }\n DocumentedComponent.propTypesValue[name] = realPropType as Validator<unknown>;\n return propType;\n });\n },\n enumerable: true,\n configurable: true,\n });\n\n return DocumentedComponent;\n}\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,iCAAgC;AAChC,0BAA6B;AAGd,kBAAwB,mBAAwD;AAC7F,MAAI,CAAC,mBAAmB;AACtB,UAAM,IAAI,MAAM;AAAA;AAGlB,QAAM,gBAAwC;AAAA,IAC5C,WAAW;AAAA;AAGb,QAAM,sBAAsB;AAE5B,QAAM,uBAAuB,CAAyC,aAAgB;AACpF,UAAM,OAAO,CAAC,UAAkE;AAC9E,oBAAc,YAAY;AAC1B,aAAO;AAAA;AAET,WAAO;AAAA;AAGT,sBAAoB,cAAc,qBAAqB;AACvD,sBAAoB,cAAc,qBAAqB;AACvD,sBAAoB,UAAU,qBAAqB;AACnD,sBAAoB,aAAa,qBAAqB;AACtD,sBAAoB,QAAQ,qBAAqB;AACjD,sBAAoB,mBAAmB,qBAAqB;AAE5D,sBAAoB,eAAe,MAAM,iCAAiB,mBAAmB;AAE7E,SAAO,eAAe,qBAAqB,aAAa;AAAA,IACtD,KAAK,MAAM,oBAAoB;AAAA,IAC/B,KAAK,CAAC,UAAsC;AAC1C,UAAI,CAAC,oBAAoB,gBAAgB;AACvC,4BAAoB,iBAAiB;AAAA;AAGvC,aAAO,KAAK,OAAO,QAAQ,CAAC,SAAS;AACnC,cAAM,WAAuB,MAAM;AACnC,YAAI;AACJ,sBAAc,UAAU,QAAQ;AAChC,uBAAe,gDAAgB;AAC/B,YAAI,MAAM,MAAM,UAAU,UAAU;AAClC,yBAAgB,aAAsC;AAAA;AAExD,4BAAoB,eAAe,QAAQ;AAC3C,eAAO;AAAA;AAAA;AAAA,IAGX,YAAY;AAAA,IACZ,cAAc;AAAA;AAGhB,SAAO;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -37,9 +37,9 @@ const enrichPropType = (propType, reactDesc) => {
|
|
|
37
37
|
const func = (props, propName, componentName, ...rest) => {
|
|
38
38
|
if (reactDesc && reactDesc.deprecated && propName in props && !reactDesc.warned) {
|
|
39
39
|
const { version = "", message = "" } = reactDesc.deprecated;
|
|
40
|
-
const
|
|
40
|
+
const error = `Warning: "${propName}" property of "${componentName}" will be deprecated in version: ${version}.
|
|
41
41
|
${message}`;
|
|
42
|
-
console.
|
|
42
|
+
console.error(error);
|
|
43
43
|
reactDesc.warned = true;
|
|
44
44
|
}
|
|
45
45
|
return propType(props, propName, componentName, ...rest);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/propTypes/describeConversions.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable max-statements */\n/* eslint-disable complexity */\n/* eslint-disable max-params */\n/* eslint-disable no-console */\n/* eslint-disable @typescript-eslint/no-use-before-define */\nimport PropTypes, { ValidationMap, Requireable } from 'prop-types';\nimport { tupleValidator } from './customPropTypes';\nimport {\n hasArguments,\n isArrayOf,\n isExact,\n isInstanceOf,\n isObjectOf,\n isOneOf,\n isOneOfType,\n isShape,\n} from './describeGuards';\nimport { ReactDescT, ReactDescObjT, InstanceOfT, OneOfT, ObjectOfT, ExactT } from './types';\n\nconst enrichPropType = (propType: Requireable<unknown>, reactDesc: ReactDescObjT): Requireable<unknown> => {\n const func = (props: Record<string, unknown>, propName: string, componentName: string, ...rest: [string, string]) => {\n if (reactDesc && reactDesc.deprecated && propName in props && !reactDesc.warned) {\n const { version = '', message = '' } = reactDesc.deprecated;\n const
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADKvB,wBAAsD;AACtD,6BAA+B;AAC/B,4BASO;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,OAAO,UAAU;AACjD,YAAM,
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-statements */\n/* eslint-disable complexity */\n/* eslint-disable max-params */\n/* eslint-disable no-console */\n/* eslint-disable @typescript-eslint/no-use-before-define */\nimport PropTypes, { ValidationMap, Requireable } from 'prop-types';\nimport { tupleValidator } from './customPropTypes';\nimport {\n hasArguments,\n isArrayOf,\n isExact,\n isInstanceOf,\n isObjectOf,\n isOneOf,\n isOneOfType,\n isShape,\n} from './describeGuards';\nimport { ReactDescT, ReactDescObjT, InstanceOfT, OneOfT, ObjectOfT, ExactT } from './types';\n\nconst enrichPropType = (propType: Requireable<unknown>, reactDesc: ReactDescObjT): Requireable<unknown> => {\n const func = (props: Record<string, unknown>, propName: string, componentName: string, ...rest: [string, string]) => {\n if (reactDesc && reactDesc.deprecated && propName in props && !reactDesc.warned) {\n const { version = '', message = '' } = reactDesc.deprecated;\n const error = `Warning: \"${propName}\" property of \"${componentName}\" will be deprecated in version: ${version}.\\n${message}`;\n console.error(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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADKvB,wBAAsD;AACtD,6BAA+B;AAC/B,4BASO;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,OAAO,UAAU;AACjD,YAAM,QAAQ,aAAa,0BAA0B,iDAAiD;AA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AAA;AAE1F,QAAI,mCAAQ,UAAU,eAAe;AACnC,aAAO,eAAe,aAAa,SAAS,OAAgC,SAAS;AAAA;AAEvF,UAAM,IAAI,MAAM;AAAA;AAGlB,SAAO,eAAe,cAAc,SAAS;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -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 React from 'react';\nimport { ComponentDocumentation, ReactDescT, TypescriptDocumentation } from './types';\n\nconst arrayFormat = (array: ReactDescT[]) => array.map((propType) => propTypeFormat(propType));\n\nconst shapeFormat = (shape: Record<string, ReactDescT>) => {\n const props = Object.keys(shape).map((key) => {\n const value = shape[key];\n let valueFormat;\n if (\n value.type &&\n (value.type === 'arrayOf' || value.type === 'oneOfType' || value.type === 'oneOf') &&\n Array.isArray(value.args)\n ) {\n valueFormat = `${propTypeFormat(value)}`;\n } else if (value.type === 'shape') {\n valueFormat = `${propTypeFormat(value)}`;\n } else {\n valueFormat = propTypeFormat(value);\n }\n return `${key}${value.reactDesc && value.reactDesc.required ? '' : '?'}: ${valueFormat}`;\n });\n return `{${props.join(',')}}`;\n};\n\nconst propTypeFormat = (propType: ReactDescT | ReactDescT[], joinWith = ''): string => {\n let result;\n if (Array.isArray(propType)) {\n result = arrayFormat(propType).join(joinWith);\n } else if (typeof propType !== 'function' && propType.type) {\n switch (propType.type) {\n case 'array':\n result = 'any[]';\n break;\n case 'arrayOf':\n if ((propType.args as ReactDescT).type === 'oneOfType') {\n result = `(${propTypeFormat(propType.args as ReactDescT, ' | ')})[]`;\n } else {\n result = `${propTypeFormat(propType.args as ReactDescT, '\\n')}[]`;\n }\n break;\n case 'tuple':\n result = `[${propTypeFormat(propType.args as ReactDescT, ', ')}]`;\n break;\n case 'bool':\n result = 'boolean';\n break;\n case 'func':\n result = '((...args: any[]) => any)';\n break;\n case 'node':\n result = 'React.ReactNode';\n break;\n case 'element':\n result = 'JSX.Element';\n break;\n case 'instanceOf':\n result = 'any';\n break;\n case 'symbol':\n result = 'any';\n break;\n case 'objectOf':\n result = `{ [key: string]: ${propTypeFormat(propType.args as ReactDescT)} }`;\n break;\n case 'oneOf':\n result = (propType.args as unknown[]).map((a) => `\"${a}\"`).join(' | ');\n break;\n case 'oneOfType':\n result = `${propTypeFormat(propType.args as ReactDescT[], ' | ')}`;\n break;\n case 'shape':\n result = `${shapeFormat(propType.args as Record<string, ReactDescT>)}`;\n break;\n default:\n result = `${propType.type}`;\n break;\n }\n } else {\n result = 'any';\n }\n return result;\n};\n\nconst propTypeAsTypescript = (propType: ReactDescT, propName: string) => {\n const documentation = {\n ...propType.reactDesc,\n name: propName,\n };\n\n documentation.format = propTypeFormat(propType);\n\n return documentation;\n};\n\nexport default function descToTypescript<C>(component: React.ComponentType<C
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADOvB,MAAM,cAAc,CAAC,UAAwB,MAAM,IAAI,CAAC,aAAa,eAAe;AAEpF,MAAM,cAAc,CAAC,UAAsC;AACzD,QAAM,QAAQ,OAAO,KAAK,OAAO,IAAI,CAAC,QAAQ;AAC5C,UAAM,QAAQ,MAAM;AACpB,QAAI;AACJ,QACE,MAAM,QACL,OAAM,SAAS,aAAa,MAAM,SAAS,eAAe,MAAM,SAAS,YAC1E,MAAM,QAAQ,MAAM,OACpB;AACA,oBAAc,GAAG,eAAe;AAAA,eACvB,MAAM,SAAS,SAAS;AACjC,oBAAc,GAAG,eAAe;AAAA,WAC3B;AACL,oBAAc,eAAe;AAAA;AAE/B,WAAO,GAAG,MAAM,MAAM,aAAa,MAAM,UAAU,WAAW,KAAK,QAAQ;AAAA;AAE7E,SAAO,IAAI,MAAM,KAAK;AAAA;AAGxB,MAAM,iBAAiB,CAAC,UAAqC,WAAW,OAAe;AACrF,MAAI;AACJ,MAAI,MAAM,QAAQ,WAAW;AAC3B,aAAS,YAAY,UAAU,KAAK;AAAA,aAC3B,OAAO,aAAa,cAAc,SAAS,MAAM;AAC1D,YAAQ,SAAS;AAAA,WACV;AACH,iBAAS;AACT;AAAA,WACG;AACH,YAAK,SAAS,KAAoB,SAAS,aAAa;AACtD,mBAAS,IAAI,eAAe,SAAS,MAAoB;AAAA,eACpD;AACL,mBAAS,GAAG,eAAe,SAAS,MAAoB;AAAA;AAE1D;AAAA,WACG;AACH,iBAAS,IAAI,eAAe,SAAS,MAAoB;AACzD;AAAA,WACG;AACH,iBAAS;AACT;AAAA,WACG;AACH,iBAAS;AACT;AAAA,WACG;AACH,iBAAS;AACT;AAAA,WACG;AACH,iBAAS;AACT;AAAA,WACG;AACH,iBAAS;AACT;AAAA,WACG;AACH,iBAAS;AACT;AAAA,WACG;AACH,iBAAS,oBAAoB,eAAe,SAAS;AACrD;AAAA,WACG;AACH,iBAAU,SAAS,KAAmB,IAAI,CAAC,MAAM,IAAI,MAAM,KAAK;AAChE;AAAA,WACG;AACH,iBAAS,GAAG,eAAe,SAAS,MAAsB;AAC1D;AAAA,WACG;AACH,iBAAS,GAAG,YAAY,SAAS;AACjC;AAAA;AAEA,iBAAS,GAAG,SAAS;AACrB;AAAA;AAAA,SAEC;AACL,aAAS;AAAA;AAEX,SAAO;AAAA;AAGT,MAAM,uBAAuB,CAAC,UAAsB,aAAqB;AACvE,QAAM,gBAAgB,iCACjB,SAAS,YADQ;AAAA,IAEpB,MAAM;AAAA;AAGR,gBAAc,SAAS,eAAe;AAEtC,SAAO;AAAA;AAGM,
|
|
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 React from 'react';\nimport { 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 = '((...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: TypescriptDocumentation = {\n name: component.displayName || component.name,\n ...reactDesc,\n };\n if (reactDesc) {\n delete documentation.propTypes;\n\n if (reactDesc.propTypes) {\n const propTypes: TypescriptDocumentation['properties'] = [];\n Object.keys(reactDesc.propTypes).forEach((propName) => {\n const propType = reactDesc.propTypes[propName];\n propTypes.push(propTypeAsTypescript(propType, propName));\n });\n if (propTypes.length > 0) {\n documentation.properties = propTypes;\n }\n }\n }\n return documentation;\n}\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADOvB,MAAM,cAAc,CAAC,UAAwB,MAAM,IAAI,CAAC,aAAa,eAAe;AAEpF,MAAM,cAAc,CAAC,UAAsC;AACzD,QAAM,QAAQ,OAAO,KAAK,OAAO,IAAI,CAAC,QAAQ;AAC5C,UAAM,QAAQ,MAAM;AACpB,QAAI;AACJ,QACE,MAAM,QACL,OAAM,SAAS,aAAa,MAAM,SAAS,eAAe,MAAM,SAAS,YAC1E,MAAM,QAAQ,MAAM,OACpB;AACA,oBAAc,GAAG,eAAe;AAAA,eACvB,MAAM,SAAS,SAAS;AACjC,oBAAc,GAAG,eAAe;AAAA,WAC3B;AACL,oBAAc,eAAe;AAAA;AAE/B,WAA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,QAAM,gBAAyC;AAAA,IAC7C,MAAM,UAAU,eAAe,UAAU;AAAA,KACtC;AAEL,MAAI,WAAW;AACb,WAAO,cAAc;AAErB,QAAI,UAAU,WAAW;AACvB,YAAM,YAAmD;AACzD,aAAO,KAAK,UAAU,WAAW,QAAQ,CAAC,aAAa;AACrD,cAAM,WAAW,UAAU,UAAU;AACrC,kBAAU,KAAK,qBAAqB,UAAU;AAAA;AAEhD,UAAI,UAAU,SAAS,GAAG;AACxB,sBAAc,aAAa;AAAA;AAAA;AAAA;AAIjC,SAAO;AAAA;",
|
|
6
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 {\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 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 warned?: 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 hidden: (this: ReactDescT) => ReactDescT;\n global: (this: ReactDescT) => ReactDescT;\n xstyled: (this: ReactDescT) => ReactDescT;\n isRequired: 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?: unknown;\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 properties?: {\n name: string;\n required?: boolean | undefined;\n deprecated?: Record<string, string> | undefined;\n description?: string | undefined;\n format?: string | undefined;\n warned?: boolean | undefined;\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: unknown;\n propTypesValue: ValidationMap<Record<string, unknown>>;\n};\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", "import * as React from 'react';\nexport { React };\n"],
|
|
4
|
+
"sourcesContent": ["import {\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 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 warned?: 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 hidden: (this: ReactDescT) => ReactDescT;\n global: (this: ReactDescT) => ReactDescT;\n xstyled: (this: ReactDescT) => ReactDescT;\n isRequired: 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?: unknown;\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 properties?: {\n name: string;\n required?: boolean | undefined;\n deprecated?: Record<string, string> | undefined;\n description?: string | undefined;\n format?: string | undefined;\n warned?: boolean | undefined;\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: unknown;\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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA,YAAuB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
25
|
+
var __export = (target, all) => {
|
|
26
|
+
for (var name in all)
|
|
27
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
28
|
+
};
|
|
29
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
30
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
31
|
+
for (let key of __getOwnPropNames(module2))
|
|
32
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
33
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
37
|
+
var __toESM = (module2, isNodeMode) => {
|
|
38
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
39
|
+
};
|
|
40
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
41
|
+
return (module2, temp) => {
|
|
42
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
43
|
+
};
|
|
44
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
45
|
+
var TestComponent_exports = {};
|
|
46
|
+
__export(TestComponent_exports, {
|
|
47
|
+
TestComponent: () => TestComponent
|
|
48
|
+
});
|
|
49
|
+
var React = __toESM(require("react"));
|
|
50
|
+
var import_react = __toESM(require("react"));
|
|
51
|
+
var import_xstyledProps = require("../../xstyledProps");
|
|
52
|
+
const TestComponent = (props) => {
|
|
53
|
+
const xstyledProps = (0, import_xstyledProps.useGetXstyledProps)(props);
|
|
54
|
+
props.signal(xstyledProps);
|
|
55
|
+
return /* @__PURE__ */ import_react.default.createElement("div", __spreadProps(__spreadValues({}, xstyledProps), {
|
|
56
|
+
"data-testid": "xstyled-div"
|
|
57
|
+
}), "Some random div");
|
|
58
|
+
};
|
|
59
|
+
module.exports = __toCommonJS(TestComponent_exports);
|
|
60
|
+
//# sourceMappingURL=TestComponent.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/tests/xstyledProps/TestComponent.js", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable react/prop-types */\nimport React from 'react';\nimport { useGetXstyledProps } from '../../xstyledProps';\n\nexport const TestComponent = (props) => {\n const xstyledProps = useGetXstyledProps(props);\n\n props.signal(xstyledProps);\n\n return (\n <div {...xstyledProps} data-testid=\"xstyled-div\">\n Some random div\n </div>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAkB;AAClB,0BAAmC;AAE5B,MAAM,gBAAgB,CAAC,UAAU;AACtC,QAAM,eAAe,4CAAmB;AAExC,QAAM,OAAO;AAEb,SACE,mDAAC,OAAD,iCAAS,eAAT;AAAA,IAAuB,eAAY;AAAA,MAAc;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (module2, isNodeMode) => {
|
|
21
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
+
return (module2, temp) => {
|
|
25
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
+
};
|
|
27
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
+
var useDeprecateComponent_exports = {};
|
|
29
|
+
__export(useDeprecateComponent_exports, {
|
|
30
|
+
useDeprecateComponent: () => useDeprecateComponent
|
|
31
|
+
});
|
|
32
|
+
var React = __toESM(require("react"));
|
|
33
|
+
var import_react = require("react");
|
|
34
|
+
const useDeprecateComponent = ({ componentName, version }) => {
|
|
35
|
+
(0, import_react.useEffect)(() => {
|
|
36
|
+
console.error(`Warning: ${componentName}:: this component will be deprecated in version: ${version}.`);
|
|
37
|
+
}, [componentName, version]);
|
|
38
|
+
};
|
|
39
|
+
module.exports = __toCommonJS(useDeprecateComponent_exports);
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/useDeprecateComponent/index.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable no-console */\nimport { useEffect } from 'react';\n\ninterface Props {\n componentName: string;\n version: string;\n}\n\nexport const useDeprecateComponent = ({ componentName, version }: Props) => {\n useEffect(() => {\n console.error(`Warning: ${componentName}:: this component will be deprecated in version: ${version}.`);\n }, [componentName, version]);\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAA0B;AAOnB,MAAM,wBAAwB,CAAC,EAAE,eAAe,cAAqB;AAC1E,8BAAU,MAAM;AACd,YAAQ,MAAM,YAAY,iEAAiE;AAAA,KAC1F,CAAC,eAAe;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/validation/typescriptValidator.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable complexity */\n/* eslint-disable max-lines */\n/* eslint-disable max-params */\nimport React, { PropsWithChildren, useMemo, useState } from 'react';\nimport { describe } from '../propTypes';\nimport { throwRequiredError, throwTypeError } from './errorTemplates';\nimport {\n isArray,\n isFunction,\n isJSXorNode,\n isObject,\n isPrimitiveType,\n isSomethingWithParenthesis,\n isString,\n isUnion,\n isUndefined,\n isNull,\n} from './typescriptGuards';\nimport { typescriptObjectParser } from './typescriptParsers';\n\ninterface TypescriptSchema {\n description: string;\n name: string;\n properties: { name: string; description: string; defaultValue?: unknown; format: string; required?: boolean }[];\n}\n\ntype ValidatorFn = (\n schemaName: string,\n key: string,\n value: unknown,\n format: string,\n validationsMemo: Record<symbol, string>,\n nextValidationsMemo: Record<symbol, string>,\n) => void;\n\n// =============================================================================\n// Atom Validators\n// =============================================================================\n\n// This functions will validate something from the data\n// and optionally recursively apply `validateValueWithFormat`\n// in smaller parts\n\nconst validateUndefined: ValidatorFn = (schemaName, key, value, format) => {\n if (value !== undefined || value === 'undefined') {\n throwTypeError(schemaName, key, value, format);\n }\n};\nconst validateNull: ValidatorFn = (schemaName, key, value, format) => {\n if (value !== null || value === 'null') {\n throwTypeError(schemaName, key, value, format);\n }\n};\nconst validatePrimitiveType: ValidatorFn = (schemaName, key, value, format) => {\n if (typeof value !== format) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nconst validateString: ValidatorFn = (schemaName, key, value, format) => {\n if (value !== format.slice(1, -1)) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nconst validateArray: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n // Check that we have an array\n if (!Array.isArray(value)) {\n throwTypeError(schemaName, key, value, format);\n }\n\n // Check that each element inside satisfies the format\n (value as unknown[]).forEach((val, index) => {\n // this is a recursive func, we need to invoke it before it's defined.\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n validateValueWithFormat(\n schemaName,\n `${key}[${index}]`,\n val,\n format.slice(0, -2),\n validationsMemo,\n nextValidationsMemo,\n );\n });\n};\nfunction isObjectType(value: unknown | Record<string, unknown>): value is Record<string, unknown> {\n return !(typeof value !== 'object' || Array.isArray(value));\n}\nconst validateObject: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n const valuesIsObject = isObjectType(value);\n // Check that we have an object\n if (!valuesIsObject) {\n throwTypeError(schemaName, key, value, format);\n return;\n }\n\n if (format === 'object') return;\n\n const keyValuePairs = typescriptObjectParser(format);\n // Now we have the key - value pairs\n // Each key could either be required or not\n // Just recursively check the object\n\n keyValuePairs.forEach(([objectKey, objectValue]) => {\n const trueKey = objectKey.slice(-1) === '?' ? objectKey.slice(0, -1) : objectKey;\n\n if (trueKey === objectKey && !(trueKey in value)) {\n throwRequiredError(schemaName, key);\n }\n\n if (trueKey in value) {\n // this is a recursive func, we need to invoke it before it's defined.\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n validateValueWithFormat(\n schemaName,\n `${key}[${trueKey}]`,\n value[trueKey],\n objectValue,\n validationsMemo,\n nextValidationsMemo,\n );\n }\n });\n};\n\nconst validateUnion: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n const possibilities = format.split(/\\s?\\|\\s?/);\n\n const errors = [];\n\n possibilities.forEach((possibility) => {\n try {\n // this is a recursive func, we need to invoke it before it's defined.\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n validateValueWithFormat(schemaName, key, value, possibility, validationsMemo, nextValidationsMemo);\n } catch (e) {\n errors.push(e);\n }\n });\n\n if (errors.length === possibilities.length) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nconst validateFunction: ValidatorFn = (schemaName, key, value, format) => {\n // Check that we have a function\n if (typeof value !== 'function') {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nfunction isJSXElement(value: unknown | JSX.Element): value is JSX.Element {\n return value === null || (typeof value === 'object' && value !== null && '$$typeof' in value);\n}\nconst validateJSXorNode: ValidatorFn = (schemaName, key, value, format) => {\n const valueIsJSX = isJSXElement(value);\n if (format === 'JSX.Element' && !valueIsJSX) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\n// =============================================================================\n// Schema validator\n// =============================================================================\n\nconst validateValueWithFormat: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n nextValidationsMemo[value as symbol] = format;\n\n if ((value as symbol) in validationsMemo) {\n // We already validated this value on this format\n return;\n }\n\n if (isUndefined(format)) {\n validateUndefined(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isNull(format)) {\n validateNull(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isPrimitiveType(format)) {\n validatePrimitiveType(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isUnion(format)) {\n validateUnion(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isString(format)) {\n validateString(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isArray(format)) {\n validateArray(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isObject(format)) {\n validateObject(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isFunction(format)) {\n validateFunction(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isJSXorNode(format)) {\n validateJSXorNode(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isSomethingWithParenthesis(format)) {\n validateValueWithFormat(schemaName, key, value, format.slice(1, -1), validationsMemo, nextValidationsMemo);\n }\n};\n\nexport const validateTypescriptPropTypesImplementation = (\n props: PropsWithChildren<Record<string, unknown>>,\n schema: TypescriptSchema,\n validationsMemo: Record<string, string> = {},\n nextValidationsMemo: Record<string, string> = {},\n): void => {\n const { properties, name: schemaName } = schema;\n\n properties.forEach((property) => {\n const { name, format, required } = property;\n\n if (required && !(name in props)) {\n throwRequiredError(schema.name, name);\n }\n\n if (name in props && (props[name] !== undefined || required)) {\n validateValueWithFormat(schemaName, name, props[name], format, validationsMemo, nextValidationsMemo);\n }\n });\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const useValidateTypescriptPropTypes = <T = Record<string, any>>(\n props: PropsWithChildren<T>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n propTypes: any,\n): void => {\n const [validationsMemo, setValidationsMemo] = useState({});\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const ComponentWithSchema = useMemo(() => {\n const Component = () => {};\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call\n return describe(Component);\n }, []);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment\n ComponentWithSchema.propTypes = propTypes;\n\n useMemo(() => {\n const nextValidationsMemo = {};\n\n validateTypescriptPropTypesImplementation(\n props,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n ComponentWithSchema.toTypescript(),\n validationsMemo,\n nextValidationsMemo,\n );\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,mBAA4D;AAC5D,uBAAyB;AACzB,4BAAmD;AACnD,8BAWO;AACP,+BAAuC;AAyBvC,MAAM,oBAAiC,CAAC,YAAY,KAAK,OAAO,WAAW;AACzE,MAAI,UAAU,UAAa,UAAU,aAAa;AAChD,8CAAe,YAAY,KAAK,OAAO;AAAA;AAAA;AAG3C,MAAM,eAA4B,CAAC,YAAY,KAAK,OAAO,WAAW;AACpE,MAAI,UAAU,QAAQ,UAAU,QAAQ;AACtC,8CAAe,YAAY,KAAK,OAAO;AAAA;AAAA;AAG3C,MAAM,wBAAqC,CAAC,YAAY,KAAK,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,aACvD,wCAAW,SAAS;AAC7B,qBAAiB,YAAY,KAAK,OAAO,QAAQ,iBAAiB;AAAA,aACzD,yCAAY,SAAS;AAC9B,sBAAkB,YAAY,KAAK,OAAO,QAAQ,iBAAiB;AAAA,aAC1D,wDAA2B,SAAS;AAC7C,4BAAwB,YAAY,KAAK,OAAO,OAAO,MAAM,GAAG,KAAK,iBAAiB;AAAA;AAAA;AAInF,MAAM,4CAA4C,CACvD,OACA,QACA,kBAA0C,IAC1C,sBAA8C,OACrC;AACT,QAAM,EAAE,YAAY,MAAM,eAAe;AAEzC,aAAW,QAAQ,CAAC,aAAa;AAC/B,UAAM,EAAE,MAAM,QAAQ,aAAa;AAEnC,QAAI,YAAY,CAAE,SAAQ,QAAQ;AAChC,oDAAmB,OAAO,MAAM;AAAA;AAGlC,QAAI,QAAQ,SAAU,OAAM,UAAU,UAAa,WAAW;AAC5D,8BAAwB,YAAY,MAAM,MAAM,OAAO,QAAQ,iBAAiB;AAAA;AAAA;AAAA;AAM/E,MAAM,iCAAiC,CAC5C,OAEA,cACS;AACT,QAAM,CAAC,iBAAiB,sBAAsB,2BAAS;AAGvD,QAAM,sBAAsB,0BAAQ,MAAM;AACxC,UAAM,YAAY,MAAM;AAAA;AAGxB,WAAO,+BAAS;AAAA,KACf;AAGH,sBAAoB,YAAY;AAEhC,4BAAQ,MAAM;AACZ,UAAM,sBAAsB;AAE5B,8CACE,OAEA,oBAAoB,gBACpB,iBACA;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable complexity */\n/* eslint-disable max-lines */\n/* eslint-disable max-params */\nimport React, { PropsWithChildren, useMemo, useState } from 'react';\nimport { describe } from '../propTypes';\nimport { throwRequiredError, throwTypeError } from './errorTemplates';\nimport {\n isArray,\n isFunction,\n isJSXorNode,\n isObject,\n isPrimitiveType,\n isSomethingWithParenthesis,\n isString,\n isUnion,\n isUndefined,\n isNull,\n} from './typescriptGuards';\nimport { typescriptObjectParser } from './typescriptParsers';\n\ninterface TypescriptSchema {\n description: string;\n name: string;\n properties: { name: string; description: string; defaultValue?: unknown; format: string; required?: boolean }[];\n}\n\ntype ValidatorFn = (\n schemaName: string,\n key: string,\n value: unknown,\n format: string,\n validationsMemo: Record<symbol, string>,\n nextValidationsMemo: Record<symbol, string>,\n) => void;\n\n// =============================================================================\n// Atom Validators\n// =============================================================================\n\n// This functions will validate something from the data\n// and optionally recursively apply `validateValueWithFormat`\n// in smaller parts\n\nconst validateUndefined: ValidatorFn = (schemaName, key, value, format) => {\n if (value !== undefined || value === 'undefined') {\n throwTypeError(schemaName, key, value, format);\n }\n};\nconst validateNull: ValidatorFn = (schemaName, key, value, format) => {\n if (value !== null || value === 'null') {\n throwTypeError(schemaName, key, value, format);\n }\n};\nconst validatePrimitiveType: ValidatorFn = (schemaName, key, value, format) => {\n if (typeof value !== format) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nconst validateString: ValidatorFn = (schemaName, key, value, format) => {\n if (value !== format.slice(1, -1)) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nconst validateArray: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n // Check that we have an array\n if (!Array.isArray(value)) {\n throwTypeError(schemaName, key, value, format);\n }\n\n // Check that each element inside satisfies the format\n (value as unknown[]).forEach((val, index) => {\n // this is a recursive func, we need to invoke it before it's defined.\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n validateValueWithFormat(\n schemaName,\n `${key}[${index}]`,\n val,\n format.slice(0, -2),\n validationsMemo,\n nextValidationsMemo,\n );\n });\n};\nfunction isObjectType(value: unknown | Record<string, unknown>): value is Record<string, unknown> {\n return !(typeof value !== 'object' || Array.isArray(value));\n}\nconst validateObject: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n const valuesIsObject = isObjectType(value);\n // Check that we have an object\n if (!valuesIsObject) {\n throwTypeError(schemaName, key, value, format);\n return;\n }\n\n if (format === 'object') return;\n\n const keyValuePairs = typescriptObjectParser(format);\n // Now we have the key - value pairs\n // Each key could either be required or not\n // Just recursively check the object\n\n keyValuePairs.forEach(([objectKey, objectValue]) => {\n const trueKey = objectKey.slice(-1) === '?' ? objectKey.slice(0, -1) : objectKey;\n\n if (trueKey === objectKey && !(trueKey in value)) {\n throwRequiredError(schemaName, key);\n }\n\n if (trueKey in value) {\n // this is a recursive func, we need to invoke it before it's defined.\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n validateValueWithFormat(\n schemaName,\n `${key}[${trueKey}]`,\n value[trueKey],\n objectValue,\n validationsMemo,\n nextValidationsMemo,\n );\n }\n });\n};\n\nconst validateUnion: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n const possibilities = format.split(/\\s?\\|\\s?/);\n\n const errors = [];\n\n possibilities.forEach((possibility) => {\n try {\n // this is a recursive func, we need to invoke it before it's defined.\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n validateValueWithFormat(schemaName, key, value, possibility, validationsMemo, nextValidationsMemo);\n } catch (e) {\n errors.push(e);\n }\n });\n\n if (errors.length === possibilities.length) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nconst validateFunction: ValidatorFn = (schemaName, key, value, format) => {\n // Check that we have a function\n if (typeof value !== 'function') {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nfunction isJSXElement(value: unknown | JSX.Element): value is JSX.Element {\n return value === null || (typeof value === 'object' && value !== null && '$$typeof' in value);\n}\nconst validateJSXorNode: ValidatorFn = (schemaName, key, value, format) => {\n const valueIsJSX = isJSXElement(value);\n if (format === 'JSX.Element' && !valueIsJSX) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\n// =============================================================================\n// Schema validator\n// =============================================================================\n\nconst validateValueWithFormat: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n nextValidationsMemo[value as symbol] = format;\n\n if ((value as symbol) in validationsMemo) {\n // We already validated this value on this format\n return;\n }\n\n if (isUndefined(format)) {\n validateUndefined(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isNull(format)) {\n validateNull(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isPrimitiveType(format)) {\n validatePrimitiveType(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isUnion(format)) {\n validateUnion(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isString(format)) {\n validateString(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isArray(format)) {\n validateArray(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isObject(format)) {\n validateObject(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isFunction(format)) {\n validateFunction(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isJSXorNode(format)) {\n validateJSXorNode(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isSomethingWithParenthesis(format)) {\n validateValueWithFormat(schemaName, key, value, format.slice(1, -1), validationsMemo, nextValidationsMemo);\n }\n};\n\nexport const validateTypescriptPropTypesImplementation = (\n props: PropsWithChildren<Record<string, unknown>>,\n schema: TypescriptSchema,\n validationsMemo: Record<string, string> = {},\n nextValidationsMemo: Record<string, string> = {},\n): void => {\n const { properties, name: schemaName } = schema;\n\n properties.forEach((property) => {\n const { name, format, required } = property;\n\n if (required && !(name in props)) {\n throwRequiredError(schema.name, name);\n }\n\n if (name in props && (props[name] !== undefined || required)) {\n validateValueWithFormat(schemaName, name, props[name], format, validationsMemo, nextValidationsMemo);\n }\n });\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const useValidateTypescriptPropTypes = <T = Record<string, any>>(\n props: PropsWithChildren<T>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n propTypes: any,\n): void => {\n const [validationsMemo, setValidationsMemo] = useState({});\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const ComponentWithSchema = useMemo(() => {\n const Component = () => {};\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call\n return describe(Component);\n }, []);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment\n ComponentWithSchema.propTypes = propTypes;\n\n useMemo(() => {\n const nextValidationsMemo = {};\n\n validateTypescriptPropTypesImplementation(\n props,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n ComponentWithSchema.toTypescript(),\n validationsMemo,\n nextValidationsMemo,\n );\n setValidationsMemo(nextValidationsMemo);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [props]);\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,mBAA4D;AAC5D,uBAAyB;AACzB,4BAAmD;AACnD,8BAWO;AACP,+BAAuC;AAyBvC,MAAM,oBAAiC,CAAC,YAAY,KAAK,OAAO,WAAW;AACzE,MAAI,UAAU,UAAa,UAAU,aAAa;AAChD,8CAAe,YAAY,KAAK,OAAO;AAAA;AAAA;AAG3C,MAAM,eAA4B,CAAC,YAAY,KAAK,OAAO,WAAW;AACpE,MAAI,UAAU,QAAQ,UAAU,QAAQ;AACtC,8CAAe,YAAY,KAAK,OAAO;AAAA;AAAA;AAG3C,MAAM,wBAAqC,CAAC,YAAY,KAAK,OAAO,WAAW;AAC7E,MAAI,OAAO,UAAU,QAAQ;AAC3B,8CAAe,YAAY,KAAK,OAAO;AAAA;AAAA;AAI3C,MAAM,iBAA8B,CAAC,YAAY,KAAK,OAAO,WAAW;AACtE,MAAI,UAAU,OAAO,MAAM,GAAG,KAAK;AACjC,8CAAe,YAAY,KAAK,OAAO;AAAA;AAAA;AAI3C,MAAM,gBAA6B,CAAC,YAAY,KAAK,OAAO,QAAQ,iBAAiB,wBAAwB;AAE3G,MAAI,CAAC,MAAM,QAAQ,QAAQ;AAC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,MAAM,eAAe;AAEzC,aAAW,QAAQ,CAAC,aAAa;AAC/B,UAAM,EAAE,MAAM,QAAQ,aAAa;AAEnC,QAAI,YAAY,CAAE,SAAQ,QAAQ;AAChC,oDAAmB,OAAO,MAAM;AAAA;AAGlC,QAAI,QAAQ,SAAU,OAAM,UAAU,UAAa,WAAW;AAC5D,8BAAwB,YAAY,MAAM,MAAM,OAAO,QAAQ,iBAAiB;AAAA;AAAA;AAAA;AAM/E,MAAM,iCAAiC,CAC5C,OAEA,cACS;AACT,QAAM,CAAC,iBAAiB,sBAAsB,2BAAS;AAGvD,QAAM,sBAAsB,0BAAQ,MAAM;AACxC,UAAM,YAAY,MAAM;AAAA;AAGxB,WAAO,+BAAS;AAAA,KACf;AAGH,sBAAoB,YAAY;AAEhC,4BAAQ,MAAM;AACZ,UAAM,sBAAsB;AAE5B,8CACE,OAEA,oBAAoB,gBACpB,iBACA;AAEF,uBAAmB;AAAA,KAElB,CAAC;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/xstyledProps/constants.
|
|
3
|
+
"sources": ["../../../src/xstyledProps/constants.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["const marginKeys = [\n 'margin',\n 'marginTop',\n 'marginRight',\n 'marginBottom',\n 'marginLeft',\n 'm',\n 'mt',\n 'mr',\n 'mb',\n 'ml',\n 'mx',\n 'my',\n];\n\nconst paddingKeys = [\n 'padding',\n 'p',\n 'paddingTop',\n 'pt',\n 'paddingRight',\n 'pr',\n 'paddingBottom',\n 'pb',\n 'paddingLeft',\n 'pl',\n 'px',\n 'py',\n];\n\nconst spaceKeys = ['spaceY', 'spaceX', 'spaceXReverse', 'spaceYReverse'];\n\nconst widthKeys = ['w', 'maxWidth', 'maxW', 'minWidth', 'minW'];\n\nconst heightKeys = ['h', 'maxHeight', 'maxH', 'minHeight', 'minH'];\n\nconst maskSizeKeys = ['maskSize'];\n\nconst spacingKeys = [...marginKeys, ...paddingKeys, ...spaceKeys];\nconst sizingKeys = [...widthKeys, ...heightKeys, ...maskSizeKeys];\nexport const layoutKeys = [\n 'display',\n 'float',\n 'boxSizing',\n 'container',\n 'overflow',\n 'overflowX',\n 'overflowY',\n 'zIndex',\n 'position',\n 'top',\n 'right',\n 'bottom',\n 'left',\n 'visibility',\n 'overscrollBehavior',\n 'objectFit',\n];\n\nexport const xstyledKeys = Object.fromEntries(\n [...spacingKeys, ...sizingKeys, ...layoutKeys].map((item) => [item, true]),\n) as Record<string, true>;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,MAAM,aAAa;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAGF,MAAM,cAAc;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAGF,MAAM,YAAY,CAAC,UAAU,UAAU,iBAAiB;AAExD,MAAM,YAAY,CAAC,KAAK,YAAY,QAAQ,YAAY;AAExD,MAAM,aAAa,CAAC,KAAK,aAAa,QAAQ,aAAa;AAE3D,MAAM,eAAe,CAAC;AAEtB,MAAM,cAAc,CAAC,GAAG,YAAY,GAAG,aAAa,GAAG;AACvD,MAAM,aAAa,CAAC,GAAG,WAAW,GAAG,YAAY,GAAG;AAC7C,MAAM,aAAa;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAGK,MAAM,cAAc,OAAO,YAChC,CAAC,GAAG,aAAa,GAAG,YAAY,GAAG,YAAY,IAAI,CAAC,SAAS,CAAC,MAAM;",
|
|
6
6
|
"names": []
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/xstyledProps/useGetXstyledProps.
|
|
4
|
-
"sourcesContent": ["import { useMemo } from 'react';\nimport type { SizingProps, SpaceProps, LayoutProps } from '@xstyled/styled-components';\nimport { xstyledKeys } from './constants';\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAwB;AAExB,uBAA4B;AAMrB,MAAM,qBAAqB,
|
|
3
|
+
"sources": ["../../../src/xstyledProps/useGetXstyledProps.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { useMemo } from 'react';\nimport type { SizingProps, SpaceProps, LayoutProps } from '@xstyled/styled-components';\nimport { xstyledKeys } from './constants';\n\nexport type XstyledProps = SpaceProps & SizingProps & LayoutProps;\n\ntype PropsWithXstyled<T> = T & XstyledProps;\n\nexport const useGetXstyledProps = <T,>(props: PropsWithXstyled<T>): XstyledProps => {\n const componentXstyledProps = useMemo(() => {\n const xstyledPropsObject: Record<string, unknown> = {};\n Object.entries(props).forEach(([key, value]) => {\n if (key in xstyledKeys) {\n xstyledPropsObject[key] = value;\n }\n });\n return xstyledPropsObject;\n }, [props]);\n\n return componentXstyledProps as XstyledProps;\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAwB;AAExB,uBAA4B;AAMrB,MAAM,qBAAqB,CAAK,UAA6C;AAClF,QAAM,wBAAwB,0BAAQ,MAAM;AAC1C,UAAM,qBAA8C;AACpD,WAAO,QAAQ,OAAO,QAAQ,CAAC,CAAC,KAAK,WAAW;AAC9C,UAAI,OAAO,8BAAa;AACtB,2BAAmB,OAAO;AAAA;AAAA;AAG9B,WAAO;AAAA,KACN,CAAC;AAEJ,SAAO;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/xstyledProps/xstyledPropTypes.
|
|
3
|
+
"sources": ["../../../src/xstyledProps/xstyledPropTypes.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["import { PropTypes } from '../propTypes';\n\nexport const xstyledPropTypes = {\n margin: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n m: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n marginTop: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n mt: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n marginRight: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n mr: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n marginBottom: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n mb: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n marginLeft: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n ml: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n mx: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n my: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n padding: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n p: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n paddingTop: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n pt: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n paddingRight: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n pr: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n paddingBottom: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n pb: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n paddingLeft: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n pl: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n px: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n py: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n spaceY: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n spaceX: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n spaceXReverse: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n spaceYReverse: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n w: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n maxWidth: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n maxW: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n minWidth: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n minW: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n h: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n maxHeight: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n maxH: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n minHeight: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n minH: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n maskSize: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n display: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n float: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n boxSizing: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n container: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n overflow: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n overflowX: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n overflowY: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n zIndex: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n position: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n top: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n right: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n bottom: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n left: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n visibility: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n overscrollBehavior: PropTypes.any\n .description('Applies to the root container. For more info read xstyled docs')\n .xstyled(),\n objectFit: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAA0B;AAEnB,MAAM,mBAAmB;AAAA,EAC9B,QAAQ,2BAAU,IAAI,YAAY,kEAAkE;AAAA,EACpG,GAAG,2BAAU,IAAI,YAAY,kEAAkE;AAAA,EAC/F,WAAW,2BAAU,IAAI,YAAY,kEAAkE;AAAA,EACvG,IAAI,2BAAU,IAAI,YAAY,kEAAkE;AAAA,EAChG,aAAa,2BAAU,IAAI,YAAY,kEAAkE;AAAA,EACzG,IAAI,2BAAU,IAAI,YAAY,kEAAkE;AAAA,EA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AkE;AAAA,EAClG,GAAG,2BAAU,IAAI,YAAY,kEAAkE;AAAA,EAC/F,WAAW,2BAAU,IAAI,YAAY,kEAAkE;AAAA,EACvG,MAAM,2BAAU,IAAI,YAAY,kEAAkE;AAAA,EAClG,WAAW,2BAAU,IAAI,YAAY,kEAAkE;AAAA,EACvG,MAAM,2BAAU,IAAI,YAAY,kEAAkE;AAAA,EAClG,UAAU,2BAAU,IAAI,YAAY,kEAAkE;AAAA,EACtG,SAAS,2BAAU,IAAI,YAAY,kEAAkE;AAAA,EACrG,OAAO,2BAAU,IAAI,YAAY,kEAAkE;AAAA,EACnG,WAAW,2BAAU,IAAI,YAAY,kEAAkE;AAAA,EACvG,WAAW,2BAAU,IAAI,YAAY,kEAAkE;AAAA,EACvG,UAAU,2BAAU,IAAI,YAAY,kEAAkE;AAAA,EACtG,WAAW,2BAAU,IAAI,YAAY,kEAAkE;AAAA,EACvG,WAAW,2BAAU,IAAI,YAAY,kEAAkE;AAAA,EACvG,QAAQ,2BAAU,IAAI,YAAY,kEAAkE;AAAA,EACpG,UAAU,2BAAU,IAAI,YAAY,kEAAkE;AAAA,EACtG,KAAK,2BAAU,IAAI,YAAY,kEAAkE;AAAA,EACjG,OAAO,2BAAU,IAAI,YAAY,kEAAkE;AAAA,EACnG,QAAQ,2BAAU,IAAI,YAAY,kEAAkE;AAAA,EACpG,MAAM,2BAAU,IAAI,YAAY,kEAAkE;AAAA,EAClG,YAAY,2BAAU,IAAI,YAAY,kEAAkE;AAAA,EACxG,oBAAoB,2BAAU,IAC3B,YAAY,kEACZ;AAAA,EACH,WAAW,2BAAU,IAAI,YAAY,kEAAkE;AAAA;",
|
|
6
6
|
"names": []
|
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export * from './defaultProps';\nexport * from './getProps';\nexport * from './globalProps';\nexport * from './propTypes';\nexport * from './validation';\nexport * from './xstyledProps';\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;",
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export * from './defaultProps';\nexport * from './getProps';\nexport * from './globalProps';\nexport * from './propTypes';\nexport * from './validation';\nexport * from './xstyledProps';\nexport * from './useDeprecateComponent';\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -32,7 +32,7 @@ const documentedPropType = {
|
|
|
32
32
|
format: addPropTypeDocumentationField("format"),
|
|
33
33
|
global: addPropTypeDocumentationField("global"),
|
|
34
34
|
hidden: addPropTypeDocumentationField("hidden"),
|
|
35
|
-
xstyled: addPropTypeDocumentationField("
|
|
35
|
+
xstyled: addPropTypeDocumentationField("xstyled")
|
|
36
36
|
};
|
|
37
37
|
const createPropType = (type) => {
|
|
38
38
|
const propTypeObj = __spreadValues({
|
|
@@ -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 { PropTypesTypes, DocumentedPropType, ReactDescObjT, PropTypesObj } from './types';\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 (fieldName === 'global' || fieldName === 'hidden' || fieldName === 'xstyled') 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 global: addPropTypeDocumentationField('global'),\n hidden: addPropTypeDocumentationField('hidden'),\n xstyled: addPropTypeDocumentationField('
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { PropTypesTypes, DocumentedPropType, ReactDescObjT, PropTypesObj } from './types';\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 (fieldName === 'global' || fieldName === 'hidden' || fieldName === 'xstyled') 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 global: addPropTypeDocumentationField('global'),\n hidden: addPropTypeDocumentationField('hidden'),\n xstyled: addPropTypeDocumentationField('xstyled'),\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
5
|
"mappings": ";;;;;;;;;;;;;;;;AAAA;ACEA,MAAM,gCAAgC,CAAgC,cACpE,6BAAuD,OAA6C;AAClG,MAAI,CAAC,KAAK,WAAW;AACnB,SAAK,YAAY;AAAA;AAEnB,MAAI,YAAY;AAChB,MAAI,cAAc,YAAY,cAAc,YAAY,cAAc;AAAW,gBAAY;AAE7F,OAAK,UAAU,aAAa;AAC5B,SAAO;AAAA;AAGX,MAAM,qBAAoF;AAAA,EACxF,cAAc,8BAA8B;AAAA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uBAAuB;AAC1B,aAAO,uBAAuB;AAAA;AAAA,IAEhC,YAAY;AAAA,IACZ,cAAc;AAAA;AAAA;AAIlB,eAAe;AACf,eAAe;AACf,eAAe;AACf,eAAe;AACf,eAAe;AACf,eAAe;AACf,eAAe;AACf,eAAe;AACf,eAAe;AACf,eAAe;AAEf,uBAAuB;AACvB,uBAAuB;AACvB,uBAAuB;AACvB,uBAAuB;AACvB,uBAAuB;AACvB,uBAAuB;AACvB,uBAAuB;AAEvB,IAAO,oBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/propTypes/describe.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/forbid-foreign-prop-types */\nimport { Requireable, Validator } from 'prop-types';\nimport React from 'react';\nimport { convertPropType } from './describeConversions';\nimport descToTypescript from './toTypescript';\nimport { ReactDescT, ComponentDocumentation, DocumentedReactComponent } from './types';\n\nexport default function describe<C>(ComponentInstance: React.ComponentType<C>) {\n if (!ComponentInstance) {\n throw new Error('react-desc: component is required');\n }\n\n const documentation: ComponentDocumentation = {\n propTypes: {},\n };\n\n const DocumentedComponent = ComponentInstance as DocumentedReactComponent<C>;\n\n const addDocumentationProp = <T extends keyof ComponentDocumentation>(propName: T) => {\n const func = (value: ComponentDocumentation[T]): DocumentedReactComponent<C> => {\n documentation[propName] = value;\n return DocumentedComponent;\n };\n return func;\n };\n\n DocumentedComponent.availableAt = addDocumentationProp('availableAt');\n DocumentedComponent.description = addDocumentationProp('description');\n DocumentedComponent.details = addDocumentationProp('details');\n DocumentedComponent.deprecated = addDocumentationProp('deprecated');\n DocumentedComponent.usage = addDocumentationProp('usage');\n DocumentedComponent.intrinsicElement = addDocumentationProp('intrinsicElement');\n\n DocumentedComponent.toTypescript = () => descToTypescript(ComponentInstance, documentation);\n\n Object.defineProperty(DocumentedComponent, 'propTypes', {\n get: () => DocumentedComponent.propTypesValue,\n set: (value: Record<string, ReactDescT>) => {\n if (!DocumentedComponent.propTypesValue) {\n DocumentedComponent.propTypesValue = {};\n }\n\n Object.keys(value).forEach((name) => {\n const propType: ReactDescT = value[name];\n let realPropType: Requireable<unknown> | Validator<unknown>;\n documentation.propTypes[name] = propType;\n realPropType = convertPropType(propType);\n if (value[name].reactDesc.required) {\n realPropType = (realPropType as Requireable<unknown>).isRequired;\n }\n DocumentedComponent.propTypesValue[name] = realPropType as Validator<unknown>;\n return propType;\n });\n },\n enumerable: true,\n configurable: true,\n });\n\n return DocumentedComponent;\n}\n"],
|
|
5
|
-
"mappings": "AAAA;ACGA;AACA;AAGe,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/forbid-foreign-prop-types */\nimport { Requireable, Validator } from 'prop-types';\nimport React from 'react';\nimport { convertPropType } from './describeConversions';\nimport descToTypescript from './toTypescript';\nimport { ReactDescT, Hook, ComponentDocumentation, DocumentedReactComponent } from './types';\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 if (value[name].reactDesc.required) {\n realPropType = (realPropType as Requireable<unknown>).isRequired;\n }\n DocumentedComponent.propTypesValue[name] = realPropType as Validator<unknown>;\n return propType;\n });\n },\n enumerable: true,\n configurable: true,\n });\n\n return DocumentedComponent;\n}\n"],
|
|
5
|
+
"mappings": "AAAA;ACGA;AACA;AAGe,kBAAwB,mBAAwD;AAC7F,MAAI,CAAC,mBAAmB;AACtB,UAAM,IAAI,MAAM;AAAA;AAGlB,QAAM,gBAAwC;AAAA,IAC5C,WAAW;AAAA;AAGb,QAAM,sBAAsB;AAE5B,QAAM,uBAAuB,CAAyC,aAAgB;AACpF,UAAM,OAAO,CAAC,UAAkE;AAC9E,oBAAc,YAAY;AAC1B,aAAO;AAAA;AAET,WAAO;AAAA;AAGT,sBAAoB,cAAc,qBAAqB;AACvD,sBAAoB,cAAc,qBAAqB;AACvD,sBAAoB,UAAU,qBAAqB;AACnD,sBAAoB,aAAa,qBAAqB;AACtD,sBAAoB,QAAQ,qBAAqB;AACjD,sBAAoB,mBAAmB,qBAAqB;AAE5D,sBAAoB,eAAe,MAAM,iBAAiB,mBAAmB;AAE7E,SAAO,eAAe,qBAAqB,aAAa;AAAA,IACtD,KAAK,MAAM,oBAAoB;AAAA,IAC/B,KAAK,CAAC,UAAsC;AAC1C,UAAI,CAAC,oBAAoB,gBAAgB;AACvC,4BAAoB,iBAAiB;AAAA;AAGvC,aAAO,KAAK,OAAO,QAAQ,CAAC,SAAS;AACnC,cAAM,WAAuB,MAAM;AACnC,YAAI;AACJ,sBAAc,UAAU,QAAQ;AAChC,uBAAe,gBAAgB;AAC/B,YAAI,MAAM,MAAM,UAAU,UAAU;AAClC,yBAAgB,aAAsC;AAAA;AAExD,4BAAoB,eAAe,QAAQ;AAC3C,eAAO;AAAA;AAAA;AAAA,IAGX,YAAY;AAAA,IACZ,cAAc;AAAA;AAGhB,SAAO;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -15,9 +15,9 @@ const enrichPropType = (propType, reactDesc) => {
|
|
|
15
15
|
const func = (props, propName, componentName, ...rest) => {
|
|
16
16
|
if (reactDesc && reactDesc.deprecated && propName in props && !reactDesc.warned) {
|
|
17
17
|
const { version = "", message = "" } = reactDesc.deprecated;
|
|
18
|
-
const
|
|
18
|
+
const error = `Warning: "${propName}" property of "${componentName}" will be deprecated in version: ${version}.
|
|
19
19
|
${message}`;
|
|
20
|
-
console.
|
|
20
|
+
console.error(error);
|
|
21
21
|
reactDesc.warned = true;
|
|
22
22
|
}
|
|
23
23
|
return propType(props, propName, componentName, ...rest);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/propTypes/describeConversions.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-statements */\n/* eslint-disable complexity */\n/* eslint-disable max-params */\n/* eslint-disable no-console */\n/* eslint-disable @typescript-eslint/no-use-before-define */\nimport PropTypes, { ValidationMap, Requireable } from 'prop-types';\nimport { tupleValidator } from './customPropTypes';\nimport {\n hasArguments,\n isArrayOf,\n isExact,\n isInstanceOf,\n isObjectOf,\n isOneOf,\n isOneOfType,\n isShape,\n} from './describeGuards';\nimport { ReactDescT, ReactDescObjT, InstanceOfT, OneOfT, ObjectOfT, ExactT } from './types';\n\nconst enrichPropType = (propType: Requireable<unknown>, reactDesc: ReactDescObjT): Requireable<unknown> => {\n const func = (props: Record<string, unknown>, propName: string, componentName: string, ...rest: [string, string]) => {\n if (reactDesc && reactDesc.deprecated && propName in props && !reactDesc.warned) {\n const { version = '', message = '' } = reactDesc.deprecated;\n const
|
|
5
|
-
"mappings": "AAAA;ACKA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,MAAM,iBAAiB,CAAC,UAAgC,cAAmD;AACzG,QAAM,OAAO,CAAC,OAAgC,UAAkB,kBAA0B,SAA2B;AACnH,QAAI,aAAa,UAAU,cAAc,YAAY,SAAS,CAAC,UAAU,QAAQ;AAC/E,YAAM,EAAE,UAAU,IAAI,UAAU,OAAO,UAAU;AACjD,YAAM,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-statements */\n/* eslint-disable complexity */\n/* eslint-disable max-params */\n/* eslint-disable no-console */\n/* eslint-disable @typescript-eslint/no-use-before-define */\nimport PropTypes, { ValidationMap, Requireable } from 'prop-types';\nimport { tupleValidator } from './customPropTypes';\nimport {\n hasArguments,\n isArrayOf,\n isExact,\n isInstanceOf,\n isObjectOf,\n isOneOf,\n isOneOfType,\n isShape,\n} from './describeGuards';\nimport { ReactDescT, ReactDescObjT, InstanceOfT, OneOfT, ObjectOfT, ExactT } from './types';\n\nconst enrichPropType = (propType: Requireable<unknown>, reactDesc: ReactDescObjT): Requireable<unknown> => {\n const func = (props: Record<string, unknown>, propName: string, componentName: string, ...rest: [string, string]) => {\n if (reactDesc && reactDesc.deprecated && propName in props && !reactDesc.warned) {\n const { version = '', message = '' } = reactDesc.deprecated;\n const error = `Warning: \"${propName}\" property of \"${componentName}\" will be deprecated in version: ${version}.\\n${message}`;\n console.error(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;ACKA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;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,aAAa,SAAS,QACnC,SAAS;AAAA;AAGb,QAAI,aAAa,UAAU,eAAe;AACxC,aAAO,eAAe,aAAa,SAAS,OAAqC,SAAS;AAAA;AAE5F,QAAI,QAAQ,UAAU,eAAe;AACnC,aAAO,eAAe,aAAa,SAAS,OAAgC,SAAS;AAAA;AAEvF,QAAI,WAAW,UAAU,eAAe;AACtC,aAAO,eAAe,aAAa,SAAS,OAAmC,SAAS;AAAA;AAE1F,QAAI,QAAQ,UAAU,eAAe;AACnC,aAAO,eAAe,aAAa,SAAS,OAAgC,SAAS;AAAA;AAEvF,UAAM,IAAI,MAAM;AAAA;AAGlB,SAAO,eAAe,cAAc,SAAS;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -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 React from 'react';\nimport { ComponentDocumentation, ReactDescT, TypescriptDocumentation } from './types';\n\nconst arrayFormat = (array: ReactDescT[]) => array.map((propType) => propTypeFormat(propType));\n\nconst shapeFormat = (shape: Record<string, ReactDescT>) => {\n const props = Object.keys(shape).map((key) => {\n const value = shape[key];\n let valueFormat;\n if (\n value.type &&\n (value.type === 'arrayOf' || value.type === 'oneOfType' || value.type === 'oneOf') &&\n Array.isArray(value.args)\n ) {\n valueFormat = `${propTypeFormat(value)}`;\n } else if (value.type === 'shape') {\n valueFormat = `${propTypeFormat(value)}`;\n } else {\n valueFormat = propTypeFormat(value);\n }\n return `${key}${value.reactDesc && value.reactDesc.required ? '' : '?'}: ${valueFormat}`;\n });\n return `{${props.join(',')}}`;\n};\n\nconst propTypeFormat = (propType: ReactDescT | ReactDescT[], joinWith = ''): string => {\n let result;\n if (Array.isArray(propType)) {\n result = arrayFormat(propType).join(joinWith);\n } else if (typeof propType !== 'function' && propType.type) {\n switch (propType.type) {\n case 'array':\n result = 'any[]';\n break;\n case 'arrayOf':\n if ((propType.args as ReactDescT).type === 'oneOfType') {\n result = `(${propTypeFormat(propType.args as ReactDescT, ' | ')})[]`;\n } else {\n result = `${propTypeFormat(propType.args as ReactDescT, '\\n')}[]`;\n }\n break;\n case 'tuple':\n result = `[${propTypeFormat(propType.args as ReactDescT, ', ')}]`;\n break;\n case 'bool':\n result = 'boolean';\n break;\n case 'func':\n result = '((...args: any[]) => any)';\n break;\n case 'node':\n result = 'React.ReactNode';\n break;\n case 'element':\n result = 'JSX.Element';\n break;\n case 'instanceOf':\n result = 'any';\n break;\n case 'symbol':\n result = 'any';\n break;\n case 'objectOf':\n result = `{ [key: string]: ${propTypeFormat(propType.args as ReactDescT)} }`;\n break;\n case 'oneOf':\n result = (propType.args as unknown[]).map((a) => `\"${a}\"`).join(' | ');\n break;\n case 'oneOfType':\n result = `${propTypeFormat(propType.args as ReactDescT[], ' | ')}`;\n break;\n case 'shape':\n result = `${shapeFormat(propType.args as Record<string, ReactDescT>)}`;\n break;\n default:\n result = `${propType.type}`;\n break;\n }\n } else {\n result = 'any';\n }\n return result;\n};\n\nconst propTypeAsTypescript = (propType: ReactDescT, propName: string) => {\n const documentation = {\n ...propType.reactDesc,\n name: propName,\n };\n\n documentation.format = propTypeFormat(propType);\n\n return documentation;\n};\n\nexport default function descToTypescript<C>(component: React.ComponentType<C
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACOA,MAAM,cAAc,CAAC,UAAwB,MAAM,IAAI,CAAC,aAAa,eAAe;AAEpF,MAAM,cAAc,CAAC,UAAsC;AACzD,QAAM,QAAQ,OAAO,KAAK,OAAO,IAAI,CAAC,QAAQ;AAC5C,UAAM,QAAQ,MAAM;AACpB,QAAI;AACJ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T,MAAM,uBAAuB,CAAC,UAAsB,aAAqB;AACvE,QAAM,gBAAgB,iCACjB,SAAS,YADQ;AAAA,IAEpB,MAAM;AAAA;AAGR,gBAAc,SAAS,eAAe;AAEtC,SAAO;AAAA;AAGM,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/restrict-template-expressions */\n/* eslint-disable @typescript-eslint/no-use-before-define */\n/* eslint-disable complexity */\n/* eslint-disable react/forbid-foreign-prop-types */\nimport React from 'react';\nimport { ComponentDocumentation, 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 = '((...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: TypescriptDocumentation = {\n name: component.displayName || component.name,\n ...reactDesc,\n };\n if (reactDesc) {\n delete documentation.propTypes;\n\n if (reactDesc.propTypes) {\n const propTypes: TypescriptDocumentation['properties'] = [];\n Object.keys(reactDesc.propTypes).forEach((propName) => {\n const propType = reactDesc.propTypes[propName];\n propTypes.push(propTypeAsTypescript(propType, propName));\n });\n if (propTypes.length > 0) {\n documentation.properties = propTypes;\n }\n }\n }\n return documentation;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACOA,MAAM,cAAc,CAAC,UAAwB,MAAM,IAAI,CAAC,aAAa,eAAe;AAEpF,MAAM,cAAc,CAAC,UAAsC;AACzD,QAAM,QAAQ,OAAO,KAAK,OAAO,IAAI,CAAC,QAAQ;AAC5C,UAAM,QAAQ,MAAM;AACpB,QAAI;AACJ,QACE,MAAM,QACL,OAAM,SAAS,aAAa,MAAM,SAAS,eAAe,MAAM,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ACjB,SAAS,YADQ;AAAA,IAEpB,MAAM;AAAA;AAGR,gBAAc,SAAS,eAAe;AAEtC,SAAO;AAAA;AAGM,0BACb,WACA,WACA;AACA,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM;AAAA;AAGlB,QAAM,gBAAyC;AAAA,IAC7C,MAAM,UAAU,eAAe,UAAU;AAAA,KACtC;AAEL,MAAI,WAAW;AACb,WAAO,cAAc;AAErB,QAAI,UAAU,WAAW;AACvB,YAAM,YAAmD;AACzD,aAAO,KAAK,UAAU,WAAW,QAAQ,CAAC,aAAa;AACrD,cAAM,WAAW,UAAU,UAAU;AACrC,kBAAU,KAAK,qBAAqB,UAAU;AAAA;AAEhD,UAAI,UAAU,SAAS,GAAG;AACxB,sBAAc,aAAa;AAAA;AAAA;AAAA;AAIjC,SAAO;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import * as React from "react";
|
|
21
|
+
import React2 from "react";
|
|
22
|
+
import { useGetXstyledProps } from "../../xstyledProps";
|
|
23
|
+
const TestComponent = (props) => {
|
|
24
|
+
const xstyledProps = useGetXstyledProps(props);
|
|
25
|
+
props.signal(xstyledProps);
|
|
26
|
+
return /* @__PURE__ */ React2.createElement("div", __spreadProps(__spreadValues({}, xstyledProps), {
|
|
27
|
+
"data-testid": "xstyled-div"
|
|
28
|
+
}), "Some random div");
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
TestComponent
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=TestComponent.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/tests/xstyledProps/TestComponent.js"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/prop-types */\nimport React from 'react';\nimport { useGetXstyledProps } from '../../xstyledProps';\n\nexport const TestComponent = (props) => {\n const xstyledProps = useGetXstyledProps(props);\n\n props.signal(xstyledProps);\n\n return (\n <div {...xstyledProps} data-testid=\"xstyled-div\">\n Some random div\n </div>\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACCA;AACA;AAEO,MAAM,gBAAgB,CAAC,UAAU;AACtC,QAAM,eAAe,mBAAmB;AAExC,QAAM,OAAO;AAEb,SACE,qCAAC,OAAD,iCAAS,eAAT;AAAA,IAAuB,eAAY;AAAA,MAAc;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
const useDeprecateComponent = ({ componentName, version }) => {
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
console.error(`Warning: ${componentName}:: this component will be deprecated in version: ${version}.`);
|
|
6
|
+
}, [componentName, version]);
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
useDeprecateComponent
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/useDeprecateComponent/index.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable no-console */\nimport { useEffect } from 'react';\n\ninterface Props {\n componentName: string;\n version: string;\n}\n\nexport const useDeprecateComponent = ({ componentName, version }: Props) => {\n useEffect(() => {\n console.error(`Warning: ${componentName}:: this component will be deprecated in version: ${version}.`);\n }, [componentName, version]);\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACCA;AAOO,MAAM,wBAAwB,CAAC,EAAE,eAAe,cAAqB;AAC1E,YAAU,MAAM;AACd,YAAQ,MAAM,YAAY,iEAAiE;AAAA,KAC1F,CAAC,eAAe;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/validation/typescriptValidator.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\n/* eslint-disable max-lines */\n/* eslint-disable max-params */\nimport React, { PropsWithChildren, useMemo, useState } from 'react';\nimport { describe } from '../propTypes';\nimport { throwRequiredError, throwTypeError } from './errorTemplates';\nimport {\n isArray,\n isFunction,\n isJSXorNode,\n isObject,\n isPrimitiveType,\n isSomethingWithParenthesis,\n isString,\n isUnion,\n isUndefined,\n isNull,\n} from './typescriptGuards';\nimport { typescriptObjectParser } from './typescriptParsers';\n\ninterface TypescriptSchema {\n description: string;\n name: string;\n properties: { name: string; description: string; defaultValue?: unknown; format: string; required?: boolean }[];\n}\n\ntype ValidatorFn = (\n schemaName: string,\n key: string,\n value: unknown,\n format: string,\n validationsMemo: Record<symbol, string>,\n nextValidationsMemo: Record<symbol, string>,\n) => void;\n\n// =============================================================================\n// Atom Validators\n// =============================================================================\n\n// This functions will validate something from the data\n// and optionally recursively apply `validateValueWithFormat`\n// in smaller parts\n\nconst validateUndefined: ValidatorFn = (schemaName, key, value, format) => {\n if (value !== undefined || value === 'undefined') {\n throwTypeError(schemaName, key, value, format);\n }\n};\nconst validateNull: ValidatorFn = (schemaName, key, value, format) => {\n if (value !== null || value === 'null') {\n throwTypeError(schemaName, key, value, format);\n }\n};\nconst validatePrimitiveType: ValidatorFn = (schemaName, key, value, format) => {\n if (typeof value !== format) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nconst validateString: ValidatorFn = (schemaName, key, value, format) => {\n if (value !== format.slice(1, -1)) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nconst validateArray: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n // Check that we have an array\n if (!Array.isArray(value)) {\n throwTypeError(schemaName, key, value, format);\n }\n\n // Check that each element inside satisfies the format\n (value as unknown[]).forEach((val, index) => {\n // this is a recursive func, we need to invoke it before it's defined.\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n validateValueWithFormat(\n schemaName,\n `${key}[${index}]`,\n val,\n format.slice(0, -2),\n validationsMemo,\n nextValidationsMemo,\n );\n });\n};\nfunction isObjectType(value: unknown | Record<string, unknown>): value is Record<string, unknown> {\n return !(typeof value !== 'object' || Array.isArray(value));\n}\nconst validateObject: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n const valuesIsObject = isObjectType(value);\n // Check that we have an object\n if (!valuesIsObject) {\n throwTypeError(schemaName, key, value, format);\n return;\n }\n\n if (format === 'object') return;\n\n const keyValuePairs = typescriptObjectParser(format);\n // Now we have the key - value pairs\n // Each key could either be required or not\n // Just recursively check the object\n\n keyValuePairs.forEach(([objectKey, objectValue]) => {\n const trueKey = objectKey.slice(-1) === '?' ? objectKey.slice(0, -1) : objectKey;\n\n if (trueKey === objectKey && !(trueKey in value)) {\n throwRequiredError(schemaName, key);\n }\n\n if (trueKey in value) {\n // this is a recursive func, we need to invoke it before it's defined.\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n validateValueWithFormat(\n schemaName,\n `${key}[${trueKey}]`,\n value[trueKey],\n objectValue,\n validationsMemo,\n nextValidationsMemo,\n );\n }\n });\n};\n\nconst validateUnion: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n const possibilities = format.split(/\\s?\\|\\s?/);\n\n const errors = [];\n\n possibilities.forEach((possibility) => {\n try {\n // this is a recursive func, we need to invoke it before it's defined.\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n validateValueWithFormat(schemaName, key, value, possibility, validationsMemo, nextValidationsMemo);\n } catch (e) {\n errors.push(e);\n }\n });\n\n if (errors.length === possibilities.length) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nconst validateFunction: ValidatorFn = (schemaName, key, value, format) => {\n // Check that we have a function\n if (typeof value !== 'function') {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nfunction isJSXElement(value: unknown | JSX.Element): value is JSX.Element {\n return value === null || (typeof value === 'object' && value !== null && '$$typeof' in value);\n}\nconst validateJSXorNode: ValidatorFn = (schemaName, key, value, format) => {\n const valueIsJSX = isJSXElement(value);\n if (format === 'JSX.Element' && !valueIsJSX) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\n// =============================================================================\n// Schema validator\n// =============================================================================\n\nconst validateValueWithFormat: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n nextValidationsMemo[value as symbol] = format;\n\n if ((value as symbol) in validationsMemo) {\n // We already validated this value on this format\n return;\n }\n\n if (isUndefined(format)) {\n validateUndefined(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isNull(format)) {\n validateNull(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isPrimitiveType(format)) {\n validatePrimitiveType(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isUnion(format)) {\n validateUnion(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isString(format)) {\n validateString(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isArray(format)) {\n validateArray(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isObject(format)) {\n validateObject(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isFunction(format)) {\n validateFunction(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isJSXorNode(format)) {\n validateJSXorNode(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isSomethingWithParenthesis(format)) {\n validateValueWithFormat(schemaName, key, value, format.slice(1, -1), validationsMemo, nextValidationsMemo);\n }\n};\n\nexport const validateTypescriptPropTypesImplementation = (\n props: PropsWithChildren<Record<string, unknown>>,\n schema: TypescriptSchema,\n validationsMemo: Record<string, string> = {},\n nextValidationsMemo: Record<string, string> = {},\n): void => {\n const { properties, name: schemaName } = schema;\n\n properties.forEach((property) => {\n const { name, format, required } = property;\n\n if (required && !(name in props)) {\n throwRequiredError(schema.name, name);\n }\n\n if (name in props && (props[name] !== undefined || required)) {\n validateValueWithFormat(schemaName, name, props[name], format, validationsMemo, nextValidationsMemo);\n }\n });\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const useValidateTypescriptPropTypes = <T = Record<string, any>>(\n props: PropsWithChildren<T>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n propTypes: any,\n): void => {\n const [validationsMemo, setValidationsMemo] = useState({});\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const ComponentWithSchema = useMemo(() => {\n const Component = () => {};\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call\n return describe(Component);\n }, []);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment\n ComponentWithSchema.propTypes = propTypes;\n\n useMemo(() => {\n const nextValidationsMemo = {};\n\n validateTypescriptPropTypesImplementation(\n props,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n ComponentWithSchema.toTypescript(),\n validationsMemo,\n nextValidationsMemo,\n );\n
|
|
5
|
-
"mappings": "AAAA;ACGA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA;AAyBA,MAAM,oBAAiC,CAAC,YAAY,KAAK,OAAO,WAAW;AACzE,MAAI,UAAU,UAAa,UAAU,aAAa;AAChD,mBAAe,YAAY,KAAK,OAAO;AAAA;AAAA;AAG3C,MAAM,eAA4B,CAAC,YAAY,KAAK,OAAO,WAAW;AACpE,MAAI,UAAU,QAAQ,UAAU,QAAQ;AACtC,mBAAe,YAAY,KAAK,OAAO;AAAA;AAAA;AAG3C,MAAM,wBAAqC,CAAC,YAAY,KAAK,OAAO,WAAW;AAC7E,MAAI,OAAO,UAAU,QAAQ;AAC3B,mBAAe,YAAY,KAAK,OAAO;AAAA;AAAA;AAI3C,MAAM,iBAA8B,CAAC,YAAY,KAAK,OAAO,WAAW;AACtE,MAAI,UAAU,OAAO,MAAM,GAAG,KAAK;AACjC,mBAAe,YAAY,KAAK,OAAO;AAAA;AAAA;AAI3C,MAAM,gBAA6B,CAAC,YAAY,KAAK,OAAO,QAAQ,iBAAiB,wBAAwB;AAE3G,MAAI,CAAC,MAAM,QAAQ,QAAQ;AACzB,mBAAe,YAAY,KAAK,OAAO;AAAA;AAIzC,EAAC,MAAoB,QAAQ,CAAC,KAAK,UAAU;AAG3C,4BACE,YACA,GAAG,OAAO,UACV,KACA,OAAO,MAAM,GAAG,KAChB,iBACA;A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C,QAAI,QAAQ,SAAU,OAAM,UAAU,UAAa,WAAW;AAC5D,8BAAwB,YAAY,MAAM,MAAM,OAAO,QAAQ,iBAAiB;AAAA;AAAA;AAAA;AAM/E,MAAM,iCAAiC,CAC5C,OAEA,cACS;AACT,QAAM,CAAC,iBAAiB,sBAAsB,SAAS;AAGvD,QAAM,sBAAsB,QAAQ,MAAM;AACxC,UAAM,YAAY,MAAM;AAAA;AAGxB,WAAO,SAAS;AAAA,KACf;AAGH,sBAAoB,YAAY;AAEhC,UAAQ,MAAM;AACZ,UAAM,sBAAsB;AAE5B,8CACE,OAEA,oBAAoB,gBACpB,iBACA;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\n/* eslint-disable max-lines */\n/* eslint-disable max-params */\nimport React, { PropsWithChildren, useMemo, useState } from 'react';\nimport { describe } from '../propTypes';\nimport { throwRequiredError, throwTypeError } from './errorTemplates';\nimport {\n isArray,\n isFunction,\n isJSXorNode,\n isObject,\n isPrimitiveType,\n isSomethingWithParenthesis,\n isString,\n isUnion,\n isUndefined,\n isNull,\n} from './typescriptGuards';\nimport { typescriptObjectParser } from './typescriptParsers';\n\ninterface TypescriptSchema {\n description: string;\n name: string;\n properties: { name: string; description: string; defaultValue?: unknown; format: string; required?: boolean }[];\n}\n\ntype ValidatorFn = (\n schemaName: string,\n key: string,\n value: unknown,\n format: string,\n validationsMemo: Record<symbol, string>,\n nextValidationsMemo: Record<symbol, string>,\n) => void;\n\n// =============================================================================\n// Atom Validators\n// =============================================================================\n\n// This functions will validate something from the data\n// and optionally recursively apply `validateValueWithFormat`\n// in smaller parts\n\nconst validateUndefined: ValidatorFn = (schemaName, key, value, format) => {\n if (value !== undefined || value === 'undefined') {\n throwTypeError(schemaName, key, value, format);\n }\n};\nconst validateNull: ValidatorFn = (schemaName, key, value, format) => {\n if (value !== null || value === 'null') {\n throwTypeError(schemaName, key, value, format);\n }\n};\nconst validatePrimitiveType: ValidatorFn = (schemaName, key, value, format) => {\n if (typeof value !== format) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nconst validateString: ValidatorFn = (schemaName, key, value, format) => {\n if (value !== format.slice(1, -1)) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nconst validateArray: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n // Check that we have an array\n if (!Array.isArray(value)) {\n throwTypeError(schemaName, key, value, format);\n }\n\n // Check that each element inside satisfies the format\n (value as unknown[]).forEach((val, index) => {\n // this is a recursive func, we need to invoke it before it's defined.\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n validateValueWithFormat(\n schemaName,\n `${key}[${index}]`,\n val,\n format.slice(0, -2),\n validationsMemo,\n nextValidationsMemo,\n );\n });\n};\nfunction isObjectType(value: unknown | Record<string, unknown>): value is Record<string, unknown> {\n return !(typeof value !== 'object' || Array.isArray(value));\n}\nconst validateObject: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n const valuesIsObject = isObjectType(value);\n // Check that we have an object\n if (!valuesIsObject) {\n throwTypeError(schemaName, key, value, format);\n return;\n }\n\n if (format === 'object') return;\n\n const keyValuePairs = typescriptObjectParser(format);\n // Now we have the key - value pairs\n // Each key could either be required or not\n // Just recursively check the object\n\n keyValuePairs.forEach(([objectKey, objectValue]) => {\n const trueKey = objectKey.slice(-1) === '?' ? objectKey.slice(0, -1) : objectKey;\n\n if (trueKey === objectKey && !(trueKey in value)) {\n throwRequiredError(schemaName, key);\n }\n\n if (trueKey in value) {\n // this is a recursive func, we need to invoke it before it's defined.\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n validateValueWithFormat(\n schemaName,\n `${key}[${trueKey}]`,\n value[trueKey],\n objectValue,\n validationsMemo,\n nextValidationsMemo,\n );\n }\n });\n};\n\nconst validateUnion: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n const possibilities = format.split(/\\s?\\|\\s?/);\n\n const errors = [];\n\n possibilities.forEach((possibility) => {\n try {\n // this is a recursive func, we need to invoke it before it's defined.\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n validateValueWithFormat(schemaName, key, value, possibility, validationsMemo, nextValidationsMemo);\n } catch (e) {\n errors.push(e);\n }\n });\n\n if (errors.length === possibilities.length) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nconst validateFunction: ValidatorFn = (schemaName, key, value, format) => {\n // Check that we have a function\n if (typeof value !== 'function') {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nfunction isJSXElement(value: unknown | JSX.Element): value is JSX.Element {\n return value === null || (typeof value === 'object' && value !== null && '$$typeof' in value);\n}\nconst validateJSXorNode: ValidatorFn = (schemaName, key, value, format) => {\n const valueIsJSX = isJSXElement(value);\n if (format === 'JSX.Element' && !valueIsJSX) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\n// =============================================================================\n// Schema validator\n// =============================================================================\n\nconst validateValueWithFormat: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n nextValidationsMemo[value as symbol] = format;\n\n if ((value as symbol) in validationsMemo) {\n // We already validated this value on this format\n return;\n }\n\n if (isUndefined(format)) {\n validateUndefined(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isNull(format)) {\n validateNull(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isPrimitiveType(format)) {\n validatePrimitiveType(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isUnion(format)) {\n validateUnion(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isString(format)) {\n validateString(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isArray(format)) {\n validateArray(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isObject(format)) {\n validateObject(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isFunction(format)) {\n validateFunction(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isJSXorNode(format)) {\n validateJSXorNode(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isSomethingWithParenthesis(format)) {\n validateValueWithFormat(schemaName, key, value, format.slice(1, -1), validationsMemo, nextValidationsMemo);\n }\n};\n\nexport const validateTypescriptPropTypesImplementation = (\n props: PropsWithChildren<Record<string, unknown>>,\n schema: TypescriptSchema,\n validationsMemo: Record<string, string> = {},\n nextValidationsMemo: Record<string, string> = {},\n): void => {\n const { properties, name: schemaName } = schema;\n\n properties.forEach((property) => {\n const { name, format, required } = property;\n\n if (required && !(name in props)) {\n throwRequiredError(schema.name, name);\n }\n\n if (name in props && (props[name] !== undefined || required)) {\n validateValueWithFormat(schemaName, name, props[name], format, validationsMemo, nextValidationsMemo);\n }\n });\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const useValidateTypescriptPropTypes = <T = Record<string, any>>(\n props: PropsWithChildren<T>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n propTypes: any,\n): void => {\n const [validationsMemo, setValidationsMemo] = useState({});\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const ComponentWithSchema = useMemo(() => {\n const Component = () => {};\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call\n return describe(Component);\n }, []);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment\n ComponentWithSchema.propTypes = propTypes;\n\n useMemo(() => {\n const nextValidationsMemo = {};\n\n validateTypescriptPropTypesImplementation(\n props,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n ComponentWithSchema.toTypescript(),\n validationsMemo,\n nextValidationsMemo,\n );\n setValidationsMemo(nextValidationsMemo);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [props]);\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACGA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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BAAmB;AAAA,KAElB,CAAC;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/xstyledProps/constants.
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/xstyledProps/constants.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "const marginKeys = [\n 'margin',\n 'marginTop',\n 'marginRight',\n 'marginBottom',\n 'marginLeft',\n 'm',\n 'mt',\n 'mr',\n 'mb',\n 'ml',\n 'mx',\n 'my',\n];\n\nconst paddingKeys = [\n 'padding',\n 'p',\n 'paddingTop',\n 'pt',\n 'paddingRight',\n 'pr',\n 'paddingBottom',\n 'pb',\n 'paddingLeft',\n 'pl',\n 'px',\n 'py',\n];\n\nconst spaceKeys = ['spaceY', 'spaceX', 'spaceXReverse', 'spaceYReverse'];\n\nconst widthKeys = ['w', 'maxWidth', 'maxW', 'minWidth', 'minW'];\n\nconst heightKeys = ['h', 'maxHeight', 'maxH', 'minHeight', 'minH'];\n\nconst maskSizeKeys = ['maskSize'];\n\nconst spacingKeys = [...marginKeys, ...paddingKeys, ...spaceKeys];\nconst sizingKeys = [...widthKeys, ...heightKeys, ...maskSizeKeys];\nexport const layoutKeys = [\n 'display',\n 'float',\n 'boxSizing',\n 'container',\n 'overflow',\n 'overflowX',\n 'overflowY',\n 'zIndex',\n 'position',\n 'top',\n 'right',\n 'bottom',\n 'left',\n 'visibility',\n 'overscrollBehavior',\n 'objectFit',\n];\n\nexport const xstyledKeys = Object.fromEntries(\n [...spacingKeys, ...sizingKeys, ...layoutKeys].map((item) => [item, true]),\n) as Record<string, true>;\n"],
|
|
5
5
|
"mappings": "AAAA;ACAA,MAAM,aAAa;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAGF,MAAM,cAAc;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAGF,MAAM,YAAY,CAAC,UAAU,UAAU,iBAAiB;AAExD,MAAM,YAAY,CAAC,KAAK,YAAY,QAAQ,YAAY;AAExD,MAAM,aAAa,CAAC,KAAK,aAAa,QAAQ,aAAa;AAE3D,MAAM,eAAe,CAAC;AAEtB,MAAM,cAAc,CAAC,GAAG,YAAY,GAAG,aAAa,GAAG;AACvD,MAAM,aAAa,CAAC,GAAG,WAAW,GAAG,YAAY,GAAG;AAC7C,MAAM,aAAa;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAGK,MAAM,cAAc,OAAO,YAChC,CAAC,GAAG,aAAa,GAAG,YAAY,GAAG,YAAY,IAAI,CAAC,SAAS,CAAC,MAAM;",
|
|
6
6
|
"names": []
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/xstyledProps/useGetXstyledProps.
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useMemo } from 'react';\nimport type { SizingProps, SpaceProps, LayoutProps } from '@xstyled/styled-components';\nimport { xstyledKeys } from './constants';\n\
|
|
5
|
-
"mappings": "AAAA;ACAA;AAEA;AAMO,MAAM,qBAAqB,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/xstyledProps/useGetXstyledProps.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useMemo } from 'react';\nimport type { SizingProps, SpaceProps, LayoutProps } from '@xstyled/styled-components';\nimport { xstyledKeys } from './constants';\n\nexport type XstyledProps = SpaceProps & SizingProps & LayoutProps;\n\ntype PropsWithXstyled<T> = T & XstyledProps;\n\nexport const useGetXstyledProps = <T,>(props: PropsWithXstyled<T>): XstyledProps => {\n const componentXstyledProps = useMemo(() => {\n const xstyledPropsObject: Record<string, unknown> = {};\n Object.entries(props).forEach(([key, value]) => {\n if (key in xstyledKeys) {\n xstyledPropsObject[key] = value;\n }\n });\n return xstyledPropsObject;\n }, [props]);\n\n return componentXstyledProps as XstyledProps;\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AAEA;AAMO,MAAM,qBAAqB,CAAK,UAA6C;AAClF,QAAM,wBAAwB,QAAQ,MAAM;AAC1C,UAAM,qBAA8C;AACpD,WAAO,QAAQ,OAAO,QAAQ,CAAC,CAAC,KAAK,WAAW;AAC9C,UAAI,OAAO,aAAa;AACtB,2BAAmB,OAAO;AAAA;AAAA;AAG9B,WAAO;AAAA,KACN,CAAC;AAEJ,SAAO;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/xstyledProps/xstyledPropTypes.
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/xstyledProps/xstyledPropTypes.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { PropTypes } from '../propTypes';\n\nexport const xstyledPropTypes = {\n margin: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n m: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n marginTop: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n mt: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n marginRight: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n mr: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n marginBottom: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n mb: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n marginLeft: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n ml: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n mx: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n my: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n padding: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n p: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n paddingTop: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n pt: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n paddingRight: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n pr: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n paddingBottom: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n pb: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n paddingLeft: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n pl: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n px: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n py: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n spaceY: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n spaceX: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n spaceXReverse: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n spaceYReverse: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n w: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n maxWidth: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n maxW: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n minWidth: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n minW: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n h: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n maxHeight: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n maxH: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n minHeight: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n minH: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n maskSize: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n display: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n float: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n boxSizing: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n container: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n overflow: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n overflowX: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n overflowY: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n zIndex: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n position: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n top: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n right: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n bottom: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n left: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n visibility: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n overscrollBehavior: PropTypes.any\n .description('Applies to the root container. For more info read xstyled docs')\n .xstyled(),\n objectFit: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),\n};\n"],
|
|
5
5
|
"mappings": "AAAA;ACAA;AAEO,MAAM,mBAAmB;AAAA,EAC9B,QAAQ,UAAU,IAAI,YAAY,kEAAkE;AAAA,EACpG,GAAG,UAAU,IAAI,YAAY,kEAAkE;AAAA,EAC/F,WAAW,UAAU,IAAI,YAAY,kEAAkE;AAAA,EACvG,IAAI,UAAU,IAAI,YAAY,kEAAkE;AAAA,EAChG,aAAa,UAAU,IAAI,YAAY,kEAAkE;AAAA,EACzG,IAAI,UAAU,IAAI,YAAY,kEAAkE;AAAA,EAChG,cAAc,UAAU,IAAI,YAAY,kEAAkE;AAAA,EAC1G,IAAI,UAAU,IAAI,YAAY,kEAAkE;AAAA,EAChG,YAAY,UAAU,IAAI,YAAY,kEAAkE;AAAA,EACxG,IAAI,UAAU,IAAI,YAAY,kEAAkE;AAAA,EAChG,IAAI,UAAU,IAAI,YAAY,kEAAkE;AAAA,EAChG,IAAI,UAAU,IAAI,YAAY,kEAAkE;AAAA,EAChG,SAAS,UAAU,IAAI,YAAY,kEAAkE;AAAA,EACrG,GAAG,UAAU,IAAI,YAAY,kEAAkE;AAAA,EAC/F,YAAY,UAAU,IAAI,YAAY,kEAAkE;AAAA,EACxG,IAAI,UAAU,IAAI,YAAY,kEAAkE;AAAA,EAChG,cAAc,UAAU,IAAI,YAAY,kEAAkE;AAAA,EAC1G,IAAI,UAAU,IAAI,YAAY,kEAAkE;AAAA,EAChG,eAAe,UAAU,IAAI,YAAY,kEAAkE;AAAA,EAC3G,IAAI,UAAU,IAAI,YAAY,kEAAkE;AAAA,EAChG,aAAa,UAAU,IAAI,YAAY,kEAAkE;AAAA,EACzG,IAAI,UAAU,IAAI,YAAY,kEAAkE;AAAA,EAChG,IAAI,UAAU,IAAI,YAAY,kEAAkE;AAAA,EAChG,IAAI,UAAU,IAAI,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EACpG,MAAM,UAAU,IAAI,YAAY,kEAAkE;AAAA,EAClG,YAAY,UAAU,IAAI,YAAY,kEAAkE;AAAA,EACxG,oBAAoB,UAAU,IAC3B,YAAY,kEACZ;AAAA,EACH,WAAW,UAAU,IAAI,YAAY,kEAAkE;AAAA;",
|
|
6
6
|
"names": []
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-props-helpers",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-next.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Props Helpers",
|
|
6
6
|
"files": [
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
"react-desc": "^4.1.3"
|
|
132
132
|
},
|
|
133
133
|
"devDependencies": {
|
|
134
|
-
"@testing-library/jest-dom": "~5.
|
|
134
|
+
"@testing-library/jest-dom": "~5.16.2"
|
|
135
135
|
},
|
|
136
136
|
"peerDependencies": {
|
|
137
137
|
"react": "~17.0.2",
|