@elliemae/ds-props-helpers 2.2.0-next.3 → 2.3.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/defaultProps/index.js +28 -9
- package/cjs/defaultProps/index.js.map +7 -0
- package/cjs/defaultProps/useMemoMergePropsWithDefault.js +44 -44
- package/cjs/defaultProps/useMemoMergePropsWithDefault.js.map +7 -0
- package/cjs/getProps/index.js +37 -20
- package/cjs/getProps/index.js.map +7 -0
- package/cjs/index.js +30 -24
- package/cjs/index.js.map +7 -0
- package/cjs/tests/test.schema.js +67 -0
- package/cjs/tests/test.schema.js.map +7 -0
- package/cjs/validation/errorTemplates.js +44 -12
- package/cjs/validation/errorTemplates.js.map +7 -0
- package/cjs/validation/index.js +30 -15
- package/cjs/validation/index.js.map +7 -0
- package/cjs/validation/typescriptGuards.js +60 -31
- package/cjs/validation/typescriptGuards.js.map +7 -0
- package/cjs/validation/typescriptParsers.js +65 -34
- package/cjs/validation/typescriptParsers.js.map +7 -0
- package/cjs/validation/typescriptValidator.js +99 -135
- package/cjs/validation/typescriptValidator.js.map +7 -0
- package/cjs/validation/validator.js +43 -24
- package/cjs/validation/validator.js.map +7 -0
- package/esm/defaultProps/index.js +3 -1
- package/esm/defaultProps/index.js.map +7 -0
- package/esm/defaultProps/useMemoMergePropsWithDefault.js +14 -34
- package/esm/defaultProps/useMemoMergePropsWithDefault.js.map +7 -0
- package/esm/getProps/index.js +8 -15
- package/esm/getProps/index.js.map +7 -0
- package/esm/index.js +5 -7
- package/esm/index.js.map +7 -0
- package/esm/tests/test.schema.js +38 -0
- package/esm/tests/test.schema.js.map +7 -0
- package/esm/validation/errorTemplates.js +15 -7
- package/esm/validation/errorTemplates.js.map +7 -0
- package/esm/validation/index.js +5 -3
- package/esm/validation/index.js.map +7 -0
- package/esm/validation/typescriptGuards.js +31 -18
- package/esm/validation/typescriptGuards.js.map +7 -0
- package/esm/validation/typescriptParsers.js +36 -30
- package/esm/validation/typescriptParsers.js.map +7 -0
- package/esm/validation/typescriptValidator.js +57 -106
- package/esm/validation/typescriptValidator.js.map +7 -0
- package/esm/validation/validator.js +12 -18
- package/esm/validation/validator.js.map +7 -0
- package/package.json +1 -17
- package/types/index.d.ts +0 -1
- package/types/validation/typescriptValidator.d.ts +2 -2
- package/cjs/globalProps/constants.js +0 -15
- package/cjs/globalProps/globalAttributesPropTypes.js +0 -372
- package/cjs/globalProps/index.js +0 -11
- package/cjs/globalProps/useGetGlobalAttributes.js +0 -36
- package/esm/globalProps/constants.js +0 -11
- package/esm/globalProps/globalAttributesPropTypes.js +0 -368
- package/esm/globalProps/index.js +0 -2
- package/esm/globalProps/useGetGlobalAttributes.js +0 -32
- package/types/globalProps/constants.d.ts +0 -3
- package/types/globalProps/globalAttributesPropTypes.d.ts +0 -2169
- package/types/globalProps/index.d.ts +0 -2
- package/types/globalProps/useGetGlobalAttributes.d.ts +0 -5
|
@@ -1,9 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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 __reExport = (target, module2, copyDefault, desc) => {
|
|
9
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(module2))
|
|
11
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
12
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return target;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (module2, isNodeMode) => {
|
|
17
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
20
|
+
return (module2, temp) => {
|
|
21
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
22
|
+
};
|
|
23
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
24
|
+
var defaultProps_exports = {};
|
|
25
|
+
var React = __toESM(require("react"));
|
|
26
|
+
__reExport(defaultProps_exports, require("./useMemoMergePropsWithDefault"));
|
|
27
|
+
module.exports = __toCommonJS(defaultProps_exports);
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/defaultProps/index.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["export * from './useMemoMergePropsWithDefault';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA,YAAuB;ADAvB,iCAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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 useMemoMergePropsWithDefault_exports = {};
|
|
29
|
+
__export(useMemoMergePropsWithDefault_exports, {
|
|
30
|
+
useMemoMergePropsWithDefault: () => useMemoMergePropsWithDefault
|
|
31
|
+
});
|
|
32
|
+
var React = __toESM(require("react"));
|
|
33
|
+
var import_react = require("react");
|
|
34
|
+
var import_react2 = __toESM(require("fast-deep-equal/react"));
|
|
24
35
|
const useMemoCompare = (next, compare) => {
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const isEqual = compare(previous, next); // If not equal update previousRef to next value.
|
|
31
|
-
// We only update if not equal so that this hook continues to return
|
|
32
|
-
// the same old value if compare keeps returning true.
|
|
33
|
-
|
|
34
|
-
if (!isEqual) previousRef.current = next; // Finally, if equal then return the previous value
|
|
35
|
-
|
|
36
|
+
const previousRef = (0, import_react.useRef)(next);
|
|
37
|
+
const previous = previousRef.current;
|
|
38
|
+
const isEqual = compare(previous, next);
|
|
39
|
+
if (!isEqual)
|
|
40
|
+
previousRef.current = next;
|
|
36
41
|
return isEqual ? previous : next;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const useMemoMergePropsWithDefault = function (props, defaultProps) {
|
|
41
|
-
let compare = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : deepequal__default["default"];
|
|
42
|
-
|
|
43
|
-
const mergedProps = _objectSpread(_objectSpread({}, defaultProps), props);
|
|
44
|
-
|
|
42
|
+
};
|
|
43
|
+
const useMemoMergePropsWithDefault = (props, defaultProps, compare = import_react2.default) => {
|
|
44
|
+
const mergedProps = { ...defaultProps, ...props };
|
|
45
45
|
return useMemoCompare(mergedProps, compare);
|
|
46
46
|
};
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
module.exports = __toCommonJS(useMemoMergePropsWithDefault_exports);
|
|
48
|
+
//# sourceMappingURL=useMemoMergePropsWithDefault.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/defaultProps/useMemoMergePropsWithDefault.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { useRef } from 'react';\nimport deepequal from 'fast-deep-equal/react';\n\n// Hook\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst useMemoCompare = <T = any>(next: T, compare: (prevToCompare: T, nextToCompare: T) => boolean): T => {\n // Ref for storing previous value\n const previousRef = useRef(next);\n const previous = previousRef.current;\n // Pass previous and next value to compare function\n // to determine whether to consider them equal.\n const isEqual = compare(previous, next);\n // If not equal update previousRef to next value.\n // We only update if not equal so that this hook continues to return\n // the same old value if compare keeps returning true.\n if (!isEqual) previousRef.current = next;\n // Finally, if equal then return the previous value\n return isEqual ? previous : next;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const useMemoMergePropsWithDefault = <T = Record<string, any>>(\n props: Partial<T>,\n defaultProps: Partial<T>,\n compare = deepequal,\n): T => {\n const mergedProps = { ...defaultProps, ...props } as T;\n\n return useMemoCompare<T>(mergedProps, compare);\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAuB;AACvB,oBAAsB;AAItB,MAAM,iBAAiB,CAAU,MAAS,YAAgE;AAExG,QAAM,cAAc,yBAAO;AAC3B,QAAM,WAAW,YAAY;AAG7B,QAAM,UAAU,QAAQ,UAAU;AAIlC,MAAI,CAAC;AAAS,gBAAY,UAAU;AAEpC,SAAO,UAAU,WAAW;AAAA;AAIvB,MAAM,+BAA+B,CAC1C,OACA,cACA,UAAU,0BACJ;AACN,QAAM,cAAc,KAAK,iBAAiB;AAE1C,SAAO,eAAkB,aAAa;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/cjs/getProps/index.js
CHANGED
|
@@ -1,20 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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 getProps_exports = {};
|
|
29
|
+
__export(getProps_exports, {
|
|
30
|
+
getAriaProps: () => getAriaProps,
|
|
31
|
+
getDataProps: () => getDataProps
|
|
32
|
+
});
|
|
33
|
+
var React = __toESM(require("react"));
|
|
34
|
+
const getAriaProps = (props) => Object.fromEntries(Object.entries(props).filter(([key]) => key.includes("aria-")));
|
|
35
|
+
const getDataProps = (props) => Object.fromEntries(Object.entries(props).filter(([key]) => key.includes("data-")));
|
|
36
|
+
module.exports = __toCommonJS(getProps_exports);
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/getProps/index.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["export const getAriaProps = (props: Record<string, unknown>): Record<string, unknown> =>\n Object.fromEntries(Object.entries(props).filter(([key]) => key.includes('aria-')));\n\nexport const getDataProps = (props: Record<string, unknown>): Record<string, unknown> =>\n Object.fromEntries(Object.entries(props).filter(([key]) => key.includes('data-')));\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAhB,MAAM,eAAe,CAAC,UAC3B,OAAO,YAAY,OAAO,QAAQ,OAAO,OAAO,CAAC,CAAC,SAAS,IAAI,SAAS;AAEnE,MAAM,eAAe,CAAC,UAC3B,OAAO,YAAY,OAAO,QAAQ,OAAO,OAAO,CAAC,CAAC,SAAS,IAAI,SAAS;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/cjs/index.js
CHANGED
|
@@ -1,24 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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 __reExport = (target, module2, copyDefault, desc) => {
|
|
9
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(module2))
|
|
11
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
12
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return target;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (module2, isNodeMode) => {
|
|
17
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
20
|
+
return (module2, temp) => {
|
|
21
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
22
|
+
};
|
|
23
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
24
|
+
var src_exports = {};
|
|
25
|
+
var React = __toESM(require("react"));
|
|
26
|
+
__reExport(src_exports, require("./defaultProps"));
|
|
27
|
+
__reExport(src_exports, require("./validation"));
|
|
28
|
+
__reExport(src_exports, require("./getProps"));
|
|
29
|
+
module.exports = __toCommonJS(src_exports);
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["export * from './defaultProps';\nexport * from './validation';\nexport * from './getProps';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA,YAAuB;ADAvB,wBAAc;AACd,wBAAc;AACd,wBAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
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 test_schema_exports = {};
|
|
29
|
+
__export(test_schema_exports, {
|
|
30
|
+
TypescriptSchema: () => TypescriptSchema
|
|
31
|
+
});
|
|
32
|
+
var React = __toESM(require("react"));
|
|
33
|
+
var import_react_desc = require("react-desc");
|
|
34
|
+
const TestSchema = {
|
|
35
|
+
string: import_react_desc.PropTypes.string.description("String"),
|
|
36
|
+
number: import_react_desc.PropTypes.number.description("Number"),
|
|
37
|
+
boolean: import_react_desc.PropTypes.bool.description("Boolean"),
|
|
38
|
+
any: import_react_desc.PropTypes.any.description("Any"),
|
|
39
|
+
union: import_react_desc.PropTypes.oneOfType([import_react_desc.PropTypes.string, import_react_desc.PropTypes.number]).description("Union"),
|
|
40
|
+
union2: import_react_desc.PropTypes.oneOf(["A", "B"]).description("Union 2"),
|
|
41
|
+
union3: import_react_desc.PropTypes.oneOfType([
|
|
42
|
+
import_react_desc.PropTypes.string,
|
|
43
|
+
import_react_desc.PropTypes.arrayOf(import_react_desc.PropTypes.string),
|
|
44
|
+
import_react_desc.PropTypes.shape({ string: import_react_desc.PropTypes.string })
|
|
45
|
+
]).description("Union 3"),
|
|
46
|
+
array: import_react_desc.PropTypes.arrayOf(import_react_desc.PropTypes.string).description("Array"),
|
|
47
|
+
object: import_react_desc.PropTypes.object.description("Object"),
|
|
48
|
+
shape: import_react_desc.PropTypes.shape({
|
|
49
|
+
string: import_react_desc.PropTypes.string.description("String").isRequired,
|
|
50
|
+
number: import_react_desc.PropTypes.number.description("Number"),
|
|
51
|
+
boolean: import_react_desc.PropTypes.bool.description("Boolean"),
|
|
52
|
+
anotherShape: import_react_desc.PropTypes.shape({
|
|
53
|
+
string: import_react_desc.PropTypes.string.description("String").isRequired,
|
|
54
|
+
number: import_react_desc.PropTypes.number.description("Number"),
|
|
55
|
+
boolean: import_react_desc.PropTypes.bool.description("Boolean")
|
|
56
|
+
}).description("Another shape")
|
|
57
|
+
}).description("Shape"),
|
|
58
|
+
function: import_react_desc.PropTypes.func.description("Function"),
|
|
59
|
+
jsx: import_react_desc.PropTypes.element.description("JSX"),
|
|
60
|
+
node: import_react_desc.PropTypes.node.description("Node")
|
|
61
|
+
};
|
|
62
|
+
const TestComponent = () => null;
|
|
63
|
+
const TestComponentWithSchema = (0, import_react_desc.describe)(TestComponent).description("Test Component");
|
|
64
|
+
TestComponentWithSchema.propTypes = TestSchema;
|
|
65
|
+
const TypescriptSchema = TestComponentWithSchema.toTypescript();
|
|
66
|
+
module.exports = __toCommonJS(test_schema_exports);
|
|
67
|
+
//# sourceMappingURL=test.schema.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/tests/test.schema.js", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { PropTypes, describe } from 'react-desc';\n\nconst TestSchema = {\n string: PropTypes.string.description('String'),\n number: PropTypes.number.description('Number'),\n boolean: PropTypes.bool.description('Boolean'),\n any: PropTypes.any.description('Any'),\n union: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description('Union'),\n union2: PropTypes.oneOf(['A', 'B']).description('Union 2'),\n union3: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.arrayOf(PropTypes.string),\n PropTypes.shape({ string: PropTypes.string }),\n ]).description('Union 3'),\n array: PropTypes.arrayOf(PropTypes.string).description('Array'),\n object: PropTypes.object.description('Object'),\n shape: PropTypes.shape({\n string: PropTypes.string.description('String').isRequired,\n number: PropTypes.number.description('Number'),\n boolean: PropTypes.bool.description('Boolean'),\n anotherShape: PropTypes.shape({\n string: PropTypes.string.description('String').isRequired,\n number: PropTypes.number.description('Number'),\n boolean: PropTypes.bool.description('Boolean'),\n }).description('Another shape'),\n }).description('Shape'),\n function: PropTypes.func.description('Function'),\n jsx: PropTypes.element.description('JSX'),\n node: PropTypes.node.description('Node'),\n};\n\nconst TestComponent = () => null;\n\nconst TestComponentWithSchema = describe(TestComponent).description('Test Component');\n\nTestComponentWithSchema.propTypes = TestSchema;\n\nexport const TypescriptSchema = TestComponentWithSchema.toTypescript();\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAAoC;AAEpC,MAAM,aAAa;AAAA,EACjB,QAAQ,4BAAU,OAAO,YAAY;AAAA,EACrC,QAAQ,4BAAU,OAAO,YAAY;AAAA,EACrC,SAAS,4BAAU,KAAK,YAAY;AAAA,EACpC,KAAK,4BAAU,IAAI,YAAY;AAAA,EAC/B,OAAO,4BAAU,UAAU,CAAC,4BAAU,QAAQ,4BAAU,SAAS,YAAY;AAAA,EAC7E,QAAQ,4BAAU,MAAM,CAAC,KAAK,MAAM,YAAY;AAAA,EAChD,QAAQ,4BAAU,UAAU;AAAA,IAC1B,4BAAU;AAAA,IACV,4BAAU,QAAQ,4BAAU;AAAA,IAC5B,4BAAU,MAAM,EAAE,QAAQ,4BAAU;AAAA,KACnC,YAAY;AAAA,EACf,OAAO,4BAAU,QAAQ,4BAAU,QAAQ,YAAY;AAAA,EACvD,QAAQ,4BAAU,OAAO,YAAY;AAAA,EACrC,OAAO,4BAAU,MAAM;AAAA,IACrB,QAAQ,4BAAU,OAAO,YAAY,UAAU;AAAA,IAC/C,QAAQ,4BAAU,OAAO,YAAY;AAAA,IACrC,SAAS,4BAAU,KAAK,YAAY;AAAA,IACpC,cAAc,4BAAU,MAAM;AAAA,MAC5B,QAAQ,4BAAU,OAAO,YAAY,UAAU;AAAA,MAC/C,QAAQ,4BAAU,OAAO,YAAY;AAAA,MACrC,SAAS,4BAAU,KAAK,YAAY;AAAA,OACnC,YAAY;AAAA,KACd,YAAY;AAAA,EACf,UAAU,4BAAU,KAAK,YAAY;AAAA,EACrC,KAAK,4BAAU,QAAQ,YAAY;AAAA,EACnC,MAAM,4BAAU,KAAK,YAAY;AAAA;AAGnC,MAAM,gBAAgB,MAAM;AAE5B,MAAM,0BAA0B,gCAAS,eAAe,YAAY;AAEpE,wBAAwB,YAAY;AAE7B,MAAM,mBAAmB,wBAAwB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,16 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 errorTemplates_exports = {};
|
|
29
|
+
__export(errorTemplates_exports, {
|
|
30
|
+
throwRequiredError: () => throwRequiredError,
|
|
31
|
+
throwTypeError: () => throwTypeError
|
|
32
|
+
});
|
|
33
|
+
var React = __toESM(require("react"));
|
|
8
34
|
const throwTypeError = (componentName, validPropKey, invalidProp, validFormat) => {
|
|
9
|
-
throw new Error(
|
|
35
|
+
throw new Error(`${componentName}:: You are trying to pass a not valid "${validPropKey}" property,
|
|
36
|
+
please provide a valid type.
|
|
37
|
+
|
|
38
|
+
Received: ${invalidProp} (${typeof invalidProp})
|
|
39
|
+
Expected: (${validFormat.replace("\n", " or ")})
|
|
40
|
+
`);
|
|
10
41
|
};
|
|
11
42
|
const throwRequiredError = (componentName, validPropKey) => {
|
|
12
|
-
throw new Error(
|
|
43
|
+
throw new Error(`${componentName}:: Please provide a/an "${validPropKey}" property to use this component.
|
|
44
|
+
This property is required.
|
|
45
|
+
`);
|
|
13
46
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
exports.throwTypeError = throwTypeError;
|
|
47
|
+
module.exports = __toCommonJS(errorTemplates_exports);
|
|
48
|
+
//# sourceMappingURL=errorTemplates.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/validation/errorTemplates.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-params */\nexport const throwTypeError = (\n componentName: string,\n validPropKey: string,\n invalidProp: unknown,\n validFormat: string,\n): void => {\n throw new Error(\n `${componentName}:: You are trying to pass a not valid \"${validPropKey}\" property, \n please provide a valid type.\n\n Received: ${invalidProp} (${typeof invalidProp})\n Expected: (${validFormat.replace('\\n', ' or ')})\n `,\n );\n};\n\nexport const throwRequiredError = (componentName: string, validPropKey: string): void => {\n throw new Error(\n `${componentName}:: Please provide a/an \"${validPropKey}\" property to use this component. \n This property is required.\n `,\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADChB,MAAM,iBAAiB,CAC5B,eACA,cACA,aACA,gBACS;AACT,QAAM,IAAI,MACR,GAAG,uDAAuD;AAAA;AAAA;AAAA,cAGhD,gBAAgB,OAAO;AAAA,eACtB,YAAY,QAAQ,MAAM;AAAA;AAAA;AAKlC,MAAM,qBAAqB,CAAC,eAAuB,iBAA+B;AACvF,QAAM,IAAI,MACR,GAAG,wCAAwC;AAAA;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/cjs/validation/index.js
CHANGED
|
@@ -1,15 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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 __reExport = (target, module2, copyDefault, desc) => {
|
|
9
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(module2))
|
|
11
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
12
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return target;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (module2, isNodeMode) => {
|
|
17
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
20
|
+
return (module2, temp) => {
|
|
21
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
22
|
+
};
|
|
23
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
24
|
+
var validation_exports = {};
|
|
25
|
+
var React = __toESM(require("react"));
|
|
26
|
+
__reExport(validation_exports, require("./validator"));
|
|
27
|
+
__reExport(validation_exports, require("./errorTemplates"));
|
|
28
|
+
__reExport(validation_exports, require("./typescriptValidator"));
|
|
29
|
+
module.exports = __toCommonJS(validation_exports);
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/validation/index.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["export * from './validator';\nexport * from './errorTemplates';\nexport * from './typescriptValidator';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA,YAAuB;ADAvB,+BAAc;AACd,+BAAc;AACd,+BAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,36 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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 typescriptGuards_exports = {};
|
|
29
|
+
__export(typescriptGuards_exports, {
|
|
30
|
+
isArray: () => isArray,
|
|
31
|
+
isFunction: () => isFunction,
|
|
32
|
+
isJSXorNode: () => isJSXorNode,
|
|
33
|
+
isNull: () => isNull,
|
|
34
|
+
isObject: () => isObject,
|
|
35
|
+
isPrimitiveType: () => isPrimitiveType,
|
|
36
|
+
isSomethingWithParenthesis: () => isSomethingWithParenthesis,
|
|
37
|
+
isString: () => isString,
|
|
38
|
+
isUndefined: () => isUndefined,
|
|
39
|
+
isUnion: () => isUnion
|
|
40
|
+
});
|
|
41
|
+
var React = __toESM(require("react"));
|
|
42
|
+
const isPrimitiveType = (format) => ["string", "number", "boolean"].includes(format);
|
|
43
|
+
const isUndefined = (format) => format === '"undefined"';
|
|
44
|
+
const isNull = (format) => format === '"null"';
|
|
45
|
+
const isUnion = (format) => {
|
|
13
46
|
let depth = 0;
|
|
14
47
|
let satisfies = false;
|
|
15
|
-
format.split(
|
|
16
|
-
if ([
|
|
48
|
+
format.split("").forEach((char) => {
|
|
49
|
+
if (["{", "("].includes(char))
|
|
50
|
+
depth += 1;
|
|
51
|
+
else if (["}", ")"].includes(char))
|
|
52
|
+
depth -= 1;
|
|
53
|
+
else if (char === "|" && depth === 0)
|
|
54
|
+
satisfies = true;
|
|
17
55
|
});
|
|
18
56
|
return satisfies;
|
|
19
57
|
};
|
|
20
|
-
const isString = format => !isUnion(format) && format[0] === '"' && format.slice(-1) === '"';
|
|
21
|
-
const isArray = format => !isUnion(format) && format.slice(-2) ===
|
|
22
|
-
const isObject = format => format ===
|
|
23
|
-
const isFunction = format => !isUnion(format) && format ===
|
|
24
|
-
const isJSXorNode = format => !isUnion(format) && [
|
|
25
|
-
const isSomethingWithParenthesis = format => !isUnion(format) && format[0] ===
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
exports.isFunction = isFunction;
|
|
29
|
-
exports.isJSXorNode = isJSXorNode;
|
|
30
|
-
exports.isNull = isNull;
|
|
31
|
-
exports.isObject = isObject;
|
|
32
|
-
exports.isPrimitiveType = isPrimitiveType;
|
|
33
|
-
exports.isSomethingWithParenthesis = isSomethingWithParenthesis;
|
|
34
|
-
exports.isString = isString;
|
|
35
|
-
exports.isUndefined = isUndefined;
|
|
36
|
-
exports.isUnion = isUnion;
|
|
58
|
+
const isString = (format) => !isUnion(format) && format[0] === '"' && format.slice(-1) === '"';
|
|
59
|
+
const isArray = (format) => !isUnion(format) && format.slice(-2) === "[]";
|
|
60
|
+
const isObject = (format) => format === "object" || !isUnion(format) && format[0] === "{" && format.slice(-1) === "}";
|
|
61
|
+
const isFunction = (format) => !isUnion(format) && format === "((...args: any[]) => any)";
|
|
62
|
+
const isJSXorNode = (format) => !isUnion(format) && ["React.ReactNode", "JSX.Element"].includes(format);
|
|
63
|
+
const isSomethingWithParenthesis = (format) => !isUnion(format) && format[0] === "(" && format.slice(-1) === ")";
|
|
64
|
+
module.exports = __toCommonJS(typescriptGuards_exports);
|
|
65
|
+
//# sourceMappingURL=typescriptGuards.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/validation/typescriptGuards.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["type GuardFn = (format: string) => boolean;\n\nexport const isPrimitiveType: GuardFn = (format) => ['string', 'number', 'boolean'].includes(format);\nexport const isUndefined: GuardFn = (format) => format === '\"undefined\"';\nexport const isNull: GuardFn = (format) => format === '\"null\"';\nexport const isUnion: GuardFn = (format) => {\n let depth = 0;\n let satisfies = false;\n format.split('').forEach((char) => {\n if (['{', '('].includes(char)) depth += 1;\n else if (['}', ')'].includes(char)) depth -= 1;\n else if (char === '|' && depth === 0) satisfies = true;\n });\n return satisfies;\n};\n\nexport const isString: GuardFn = (format) => !isUnion(format) && format[0] === '\"' && format.slice(-1) === '\"';\n\nexport const isArray: GuardFn = (format) => !isUnion(format) && format.slice(-2) === '[]';\n\nexport const isObject: GuardFn = (format) =>\n format === 'object' || (!isUnion(format) && format[0] === '{' && format.slice(-1) === '}');\n\nexport const isFunction: GuardFn = (format) => !isUnion(format) && format === '((...args: any[]) => any)';\n\nexport const isJSXorNode: GuardFn = (format) => !isUnion(format) && ['React.ReactNode', 'JSX.Element'].includes(format);\n\nexport const isSomethingWithParenthesis: GuardFn = (format) =>\n !isUnion(format) && format[0] === '(' && format.slice(-1) === ')';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEhB,MAAM,kBAA2B,CAAC,WAAW,CAAC,UAAU,UAAU,WAAW,SAAS;AACtF,MAAM,cAAuB,CAAC,WAAW,WAAW;AACpD,MAAM,SAAkB,CAAC,WAAW,WAAW;AAC/C,MAAM,UAAmB,CAAC,WAAW;AAC1C,MAAI,QAAQ;AACZ,MAAI,YAAY;AAChB,SAAO,MAAM,IAAI,QAAQ,CAAC,SAAS;AACjC,QAAI,CAAC,KAAK,KAAK,SAAS;AAAO,eAAS;AAAA,aAC/B,CAAC,KAAK,KAAK,SAAS;AAAO,eAAS;AAAA,aACpC,SAAS,OAAO,UAAU;AAAG,kBAAY;AAAA;AAEpD,SAAO;AAAA;AAGF,MAAM,WAAoB,CAAC,WAAW,CAAC,QAAQ,WAAW,OAAO,OAAO,OAAO,OAAO,MAAM,QAAQ;AAEpG,MAAM,UAAmB,CAAC,WAAW,CAAC,QAAQ,WAAW,OAAO,MAAM,QAAQ;AAE9E,MAAM,WAAoB,CAAC,WAChC,WAAW,YAAa,CAAC,QAAQ,WAAW,OAAO,OAAO,OAAO,OAAO,MAAM,QAAQ;AAEjF,MAAM,aAAsB,CAAC,WAAW,CAAC,QAAQ,WAAW,WAAW;AAEvE,MAAM,cAAuB,CAAC,WAAW,CAAC,QAAQ,WAAW,CAAC,mBAAmB,eAAe,SAAS;AAEzG,MAAM,6BAAsC,CAAC,WAClD,CAAC,QAAQ,WAAW,OAAO,OAAO,OAAO,OAAO,MAAM,QAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|