@jfdevelops/react-layout 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/create-config/define-layout.cjs +23 -18
- package/dist/create-config/define-layout.cjs.map +1 -1
- package/dist/create-config/define-layout.d.cts +25 -24
- package/dist/create-config/define-layout.d.cts.map +1 -1
- package/dist/create-config/define-layout.d.mts +25 -24
- package/dist/create-config/define-layout.d.mts.map +1 -1
- package/dist/create-config/define-layout.mjs +17 -12
- package/dist/create-config/define-layout.mjs.map +1 -1
- package/dist/index.cjs +81 -9
- package/dist/index.d.cts +4 -6
- package/dist/index.d.mts +4 -6
- package/dist/index.mjs +4 -5
- package/dist/props.d.cts +6 -6
- package/dist/props.d.cts.map +1 -1
- package/dist/props.d.mts +6 -6
- package/dist/props.d.mts.map +1 -1
- package/dist/resource.cjs.map +1 -1
- package/dist/resource.d.cts +1 -1
- package/dist/resource.d.cts.map +1 -1
- package/dist/resource.d.mts +1 -1
- package/dist/resource.d.mts.map +1 -1
- package/dist/resource.mjs.map +1 -1
- package/dist/utils.cjs +0 -12
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts.map +1 -1
- package/dist/utils.d.mts.map +1 -1
- package/dist/utils.mjs +1 -12
- package/dist/utils.mjs.map +1 -1
- package/package.json +5 -1
- package/dist/composable.cjs +0 -72
- package/dist/composable.cjs.map +0 -1
- package/dist/composable.d.cts +0 -44
- package/dist/composable.d.cts.map +0 -1
- package/dist/composable.d.mts +0 -44
- package/dist/composable.d.mts.map +0 -1
- package/dist/composable.mjs +0 -70
- package/dist/composable.mjs.map +0 -1
- package/dist/utils/capitalize.d.cts +0 -7
- package/dist/utils/capitalize.d.cts.map +0 -1
- package/dist/utils/capitalize.d.mts +0 -7
- package/dist/utils/capitalize.d.mts.map +0 -1
- package/dist/validators/base.cjs +0 -41
- package/dist/validators/base.cjs.map +0 -1
- package/dist/validators/base.d.cts +0 -18
- package/dist/validators/base.d.cts.map +0 -1
- package/dist/validators/base.d.mts +0 -18
- package/dist/validators/base.d.mts.map +0 -1
- package/dist/validators/base.mjs +0 -39
- package/dist/validators/base.mjs.map +0 -1
- package/dist/validators/builders.cjs +0 -137
- package/dist/validators/builders.cjs.map +0 -1
- package/dist/validators/builders.d.cts +0 -156
- package/dist/validators/builders.d.cts.map +0 -1
- package/dist/validators/builders.d.mts +0 -156
- package/dist/validators/builders.d.mts.map +0 -1
- package/dist/validators/builders.mjs +0 -136
- package/dist/validators/builders.mjs.map +0 -1
- package/dist/validators/component.cjs +0 -73
- package/dist/validators/component.cjs.map +0 -1
- package/dist/validators/component.d.cts +0 -28
- package/dist/validators/component.d.cts.map +0 -1
- package/dist/validators/component.d.mts +0 -28
- package/dist/validators/component.d.mts.map +0 -1
- package/dist/validators/component.mjs +0 -71
- package/dist/validators/component.mjs.map +0 -1
- package/dist/validators/enum.cjs +0 -27
- package/dist/validators/enum.cjs.map +0 -1
- package/dist/validators/enum.d.cts +0 -14
- package/dist/validators/enum.d.cts.map +0 -1
- package/dist/validators/enum.d.mts +0 -14
- package/dist/validators/enum.d.mts.map +0 -1
- package/dist/validators/enum.mjs +0 -27
- package/dist/validators/enum.mjs.map +0 -1
- package/dist/validators/index.d.cts +0 -10
- package/dist/validators/index.d.mts +0 -10
- package/dist/validators/literal.cjs +0 -25
- package/dist/validators/literal.cjs.map +0 -1
- package/dist/validators/literal.d.cts +0 -14
- package/dist/validators/literal.d.cts.map +0 -1
- package/dist/validators/literal.d.mts +0 -14
- package/dist/validators/literal.d.mts.map +0 -1
- package/dist/validators/literal.mjs +0 -25
- package/dist/validators/literal.mjs.map +0 -1
- package/dist/validators/object.cjs +0 -53
- package/dist/validators/object.cjs.map +0 -1
- package/dist/validators/object.d.cts +0 -14
- package/dist/validators/object.d.cts.map +0 -1
- package/dist/validators/object.d.mts +0 -14
- package/dist/validators/object.d.mts.map +0 -1
- package/dist/validators/object.mjs +0 -53
- package/dist/validators/object.mjs.map +0 -1
- package/dist/validators/primitive.cjs +0 -80
- package/dist/validators/primitive.cjs.map +0 -1
- package/dist/validators/primitive.d.cts +0 -33
- package/dist/validators/primitive.d.cts.map +0 -1
- package/dist/validators/primitive.d.mts +0 -33
- package/dist/validators/primitive.d.mts.map +0 -1
- package/dist/validators/primitive.mjs +0 -78
- package/dist/validators/primitive.mjs.map +0 -1
- package/dist/validators/types.d.cts +0 -71
- package/dist/validators/types.d.cts.map +0 -1
- package/dist/validators/types.d.mts +0 -71
- package/dist/validators/types.d.mts.map +0 -1
- package/dist/validators/union.cjs +0 -27
- package/dist/validators/union.cjs.map +0 -1
- package/dist/validators/union.d.cts +0 -14
- package/dist/validators/union.d.cts.map +0 -1
- package/dist/validators/union.d.mts +0 -14
- package/dist/validators/union.d.mts.map +0 -1
- package/dist/validators/union.mjs +0 -27
- package/dist/validators/union.mjs.map +0 -1
- package/dist/validators/validate-props.cjs +0 -22
- package/dist/validators/validate-props.cjs.map +0 -1
- package/dist/validators/validate-props.d.cts +0 -7
- package/dist/validators/validate-props.d.cts.map +0 -1
- package/dist/validators/validate-props.d.mts +0 -7
- package/dist/validators/validate-props.d.mts.map +0 -1
- package/dist/validators/validate-props.mjs +0 -21
- package/dist/validators/validate-props.mjs.map +0 -1
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { BuiltPropShape, PropVisibility, ResolveBuiltPropValue } from "./types.mjs";
|
|
2
|
-
import { BaseProp } from "./base.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/validators/object.d.ts
|
|
5
|
-
declare class ObjectProp<const Shape extends BuiltPropShape, Visibility extends PropVisibility> extends BaseProp<'object', Visibility, { [Key in keyof Shape]: ResolveBuiltPropValue<Shape[Key]> }> {
|
|
6
|
-
readonly properties: Shape;
|
|
7
|
-
constructor(properties: Shape, visibility: Visibility);
|
|
8
|
-
optional(this: ObjectProp<Shape, 'required'>): ObjectProp<Shape, "optional">;
|
|
9
|
-
validate(value: unknown): { [Key in keyof Shape]: ResolveBuiltPropValue<Shape[Key]> };
|
|
10
|
-
allows(value: unknown): value is { [Key in keyof Shape]: ResolveBuiltPropValue<Shape[Key]> };
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
13
|
-
export { ObjectProp };
|
|
14
|
-
//# sourceMappingURL=object.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"object.d.mts","names":[],"sources":["../../src/validators/object.ts"],"mappings":";;;;cAOa,UAAA,qBACS,cAAA,qBACD,cAAA,UACX,QAAA,WAER,UAAA,kBAEgB,KAAA,GAAQ,qBAAA,CAAsB,KAAA,CAAM,GAAA;EAAA,SAG3C,UAAA,EAAY,KAAA;cAET,UAAA,EAAY,KAAA,EAAO,UAAA,EAAY,UAAA;EAK3C,QAAA,CAAS,IAAA,EAAM,UAAA,CAAW,KAAA,gBAAkB,UAAA,CAAA,KAAA;EAI5C,QAAA,CAAS,KAAA,4BAED,KAAA,GAAA,qBAAA,CAAA,KAAA,CAAA,GAAA;EA6BR,MAAA,CAAO,KAAA,YAAiB,KAAA,oBACR,KAAA,GAAQ,qBAAA,CAAsB,KAAA,CAAM,GAAA;AAAA"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { BaseProp } from "./base.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/validators/object.ts
|
|
4
|
-
var ObjectProp = class ObjectProp extends BaseProp {
|
|
5
|
-
properties;
|
|
6
|
-
constructor(properties, visibility) {
|
|
7
|
-
super({
|
|
8
|
-
type: "object",
|
|
9
|
-
visibility
|
|
10
|
-
});
|
|
11
|
-
this.properties = properties;
|
|
12
|
-
}
|
|
13
|
-
optional() {
|
|
14
|
-
return new ObjectProp(this.properties, "optional");
|
|
15
|
-
}
|
|
16
|
-
validate(value) {
|
|
17
|
-
const validatedObject = {};
|
|
18
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) throw this.error;
|
|
19
|
-
const objectValue = value;
|
|
20
|
-
for (const key in this.properties) {
|
|
21
|
-
const prop = this.properties[key];
|
|
22
|
-
const propertyValue = objectValue[key];
|
|
23
|
-
if (propertyValue === void 0) {
|
|
24
|
-
if (prop.visibility !== "optional") throw new TypeError(`"${key}" is required.`);
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
validatedObject[key] = prop(propertyValue);
|
|
28
|
-
}
|
|
29
|
-
return validatedObject;
|
|
30
|
-
}
|
|
31
|
-
allows(value) {
|
|
32
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
33
|
-
const objectValue = value;
|
|
34
|
-
for (const key in this.properties) {
|
|
35
|
-
const prop = this.properties[key];
|
|
36
|
-
const propertyValue = objectValue[key];
|
|
37
|
-
if (propertyValue === void 0) {
|
|
38
|
-
if (prop.visibility !== "optional") return false;
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
try {
|
|
42
|
-
prop(propertyValue);
|
|
43
|
-
} catch {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
//#endregion
|
|
52
|
-
export { ObjectProp };
|
|
53
|
-
//# sourceMappingURL=object.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"object.mjs","names":[],"sources":["../../src/validators/object.ts"],"sourcesContent":["import type {\n BuiltPropShape,\n PropVisibility,\n ResolveBuiltPropValue,\n} from './types';\nimport { BaseProp } from './base';\n\nexport class ObjectProp<\n const Shape extends BuiltPropShape,\n Visibility extends PropVisibility,\n> extends BaseProp<\n 'object',\n Visibility,\n {\n [Key in keyof Shape]: ResolveBuiltPropValue<Shape[Key]>;\n }\n> {\n readonly properties: Shape;\n\n constructor(properties: Shape, visibility: Visibility) {\n super({ type: 'object', visibility });\n this.properties = properties;\n }\n\n optional(this: ObjectProp<Shape, 'required'>) {\n return new ObjectProp(this.properties, 'optional');\n }\n\n validate(value: unknown) {\n const validatedObject = {} as {\n [Key in keyof Shape]: ResolveBuiltPropValue<Shape[Key]>;\n };\n\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw this.error;\n }\n\n const objectValue = value as Record<string, unknown>;\n\n for (const key in this.properties) {\n const prop = this.properties[key];\n const propertyValue = objectValue[key];\n\n if (propertyValue === undefined) {\n if (prop.visibility !== 'optional') {\n throw new TypeError(`\"${key}\" is required.`);\n }\n\n continue;\n }\n\n validatedObject[key] = prop(propertyValue) as ResolveBuiltPropValue<\n Shape[typeof key]\n >;\n }\n\n return validatedObject;\n }\n\n allows(value: unknown): value is {\n [Key in keyof Shape]: ResolveBuiltPropValue<Shape[Key]>;\n } {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return false;\n }\n\n const objectValue = value as Record<string, unknown>;\n\n for (const key in this.properties) {\n const prop = this.properties[key];\n const propertyValue = objectValue[key];\n\n if (propertyValue === undefined) {\n if (prop.visibility !== 'optional') {\n return false;\n }\n\n continue;\n }\n\n try {\n prop(propertyValue);\n } catch {\n return false;\n }\n }\n\n return true;\n }\n}\n"],"mappings":";;;AAOA,IAAa,aAAb,MAAa,mBAGH,SAMR;CACA,AAAS;CAET,YAAY,YAAmB,YAAwB;EACrD,MAAM;GAAE,MAAM;GAAU;EAAW,CAAC;EACpC,KAAK,aAAa;CACpB;CAEA,WAA8C;EAC5C,OAAO,IAAI,WAAW,KAAK,YAAY,UAAU;CACnD;CAEA,SAAS,OAAgB;EACvB,MAAM,kBAAkB,CAAC;EAIzB,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,KAAK,GACpE,MAAM,KAAK;EAGb,MAAM,cAAc;EAEpB,KAAK,MAAM,OAAO,KAAK,YAAY;GACjC,MAAM,OAAO,KAAK,WAAW;GAC7B,MAAM,gBAAgB,YAAY;GAElC,IAAI,kBAAkB,QAAW;IAC/B,IAAI,KAAK,eAAe,YACtB,MAAM,IAAI,UAAU,IAAI,IAAI,eAAe;IAG7C;GACF;GAEA,gBAAgB,OAAO,KAAK,aAAa;EAG3C;EAEA,OAAO;CACT;CAEA,OAAO,OAEL;EACA,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,KAAK,GACpE,OAAO;EAGT,MAAM,cAAc;EAEpB,KAAK,MAAM,OAAO,KAAK,YAAY;GACjC,MAAM,OAAO,KAAK,WAAW;GAC7B,MAAM,gBAAgB,YAAY;GAElC,IAAI,kBAAkB,QAAW;IAC/B,IAAI,KAAK,eAAe,YACtB,OAAO;IAGT;GACF;GAEA,IAAI;IACF,KAAK,aAAa;GACpB,QAAQ;IACN,OAAO;GACT;EACF;EAEA,OAAO;CACT;AACF"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
const require_base = require('./base.cjs');
|
|
2
|
-
const require_enum = require('./enum.cjs');
|
|
3
|
-
const require_literal = require('./literal.cjs');
|
|
4
|
-
|
|
5
|
-
//#region src/validators/primitive.ts
|
|
6
|
-
var StringProp = class StringProp extends require_base.BaseProp {
|
|
7
|
-
constructor(visibility) {
|
|
8
|
-
super({
|
|
9
|
-
type: "string",
|
|
10
|
-
visibility
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
optional() {
|
|
14
|
-
return new StringProp("optional");
|
|
15
|
-
}
|
|
16
|
-
literal(value) {
|
|
17
|
-
return new require_literal.LiteralProp(value, "string", this.visibility);
|
|
18
|
-
}
|
|
19
|
-
enum(values) {
|
|
20
|
-
return new require_enum.EnumProp(values, "string", this.visibility);
|
|
21
|
-
}
|
|
22
|
-
validate(value) {
|
|
23
|
-
if (typeof value !== "string") throw this.error;
|
|
24
|
-
}
|
|
25
|
-
allows(value) {
|
|
26
|
-
return typeof value === "string";
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var NumberProp = class NumberProp extends require_base.BaseProp {
|
|
30
|
-
constructor(visibility) {
|
|
31
|
-
super({
|
|
32
|
-
type: "number",
|
|
33
|
-
visibility
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
optional() {
|
|
37
|
-
return new NumberProp("optional");
|
|
38
|
-
}
|
|
39
|
-
literal(value) {
|
|
40
|
-
return new require_literal.LiteralProp(value, "number", this.visibility);
|
|
41
|
-
}
|
|
42
|
-
enum(values) {
|
|
43
|
-
return new require_enum.EnumProp(values, "number", this.visibility);
|
|
44
|
-
}
|
|
45
|
-
validate(value) {
|
|
46
|
-
if (typeof value !== "number") throw this.error;
|
|
47
|
-
}
|
|
48
|
-
allows(value) {
|
|
49
|
-
return typeof value === "number";
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
var BooleanProp = class BooleanProp extends require_base.BaseProp {
|
|
53
|
-
constructor(visibility) {
|
|
54
|
-
super({
|
|
55
|
-
type: "boolean",
|
|
56
|
-
visibility
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
optional() {
|
|
60
|
-
return new BooleanProp("optional");
|
|
61
|
-
}
|
|
62
|
-
literal(value) {
|
|
63
|
-
return new require_literal.LiteralProp(value, "boolean", this.visibility);
|
|
64
|
-
}
|
|
65
|
-
enum(values) {
|
|
66
|
-
return new require_enum.EnumProp(values, "boolean", this.visibility);
|
|
67
|
-
}
|
|
68
|
-
validate(value) {
|
|
69
|
-
if (typeof value !== "boolean") throw this.error;
|
|
70
|
-
}
|
|
71
|
-
allows(value) {
|
|
72
|
-
return typeof value === "boolean";
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
//#endregion
|
|
77
|
-
exports.BooleanProp = BooleanProp;
|
|
78
|
-
exports.NumberProp = NumberProp;
|
|
79
|
-
exports.StringProp = StringProp;
|
|
80
|
-
//# sourceMappingURL=primitive.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"primitive.cjs","names":["BaseProp","LiteralProp","EnumProp"],"sources":["../../src/validators/primitive.ts"],"sourcesContent":["import type {\n NonEmptyReadonlyArray,\n PropVisibility,\n} from './types';\nimport { BaseProp } from './base';\nimport { EnumProp } from './enum';\nimport { LiteralProp } from './literal';\n\nexport class StringProp<Visibility extends PropVisibility> extends BaseProp<\n 'string',\n Visibility,\n string\n> {\n constructor(visibility: Visibility) {\n super({ type: 'string', visibility });\n }\n\n optional(this: StringProp<'required'>) {\n return new StringProp('optional');\n }\n\n literal<const Value extends string>(value: Value) {\n return new LiteralProp(value, 'string', this.visibility);\n }\n\n enum<const Values extends NonEmptyReadonlyArray<string>>(values: Values) {\n return new EnumProp(values, 'string', this.visibility);\n }\n\n validate(value: unknown) {\n if (typeof value !== 'string') {\n throw this.error;\n }\n }\n\n allows(value: unknown): value is string {\n return typeof value === 'string';\n }\n}\n\nexport class NumberProp<Visibility extends PropVisibility> extends BaseProp<\n 'number',\n Visibility,\n number\n> {\n constructor(visibility: Visibility) {\n super({ type: 'number', visibility });\n }\n\n optional(this: NumberProp<'required'>) {\n return new NumberProp('optional');\n }\n\n literal<const Value extends number>(value: Value) {\n return new LiteralProp(value, 'number', this.visibility);\n }\n\n enum<const Values extends NonEmptyReadonlyArray<number>>(values: Values) {\n return new EnumProp(values, 'number', this.visibility);\n }\n\n validate(value: unknown) {\n if (typeof value !== 'number') {\n throw this.error;\n }\n }\n\n allows(value: unknown): value is number {\n return typeof value === 'number';\n }\n}\n\nexport class BooleanProp<Visibility extends PropVisibility> extends BaseProp<\n 'boolean',\n Visibility,\n boolean\n> {\n constructor(visibility: Visibility) {\n super({ type: 'boolean', visibility });\n }\n\n optional(this: BooleanProp<'required'>) {\n return new BooleanProp('optional');\n }\n\n literal<const Value extends boolean>(value: Value) {\n return new LiteralProp(value, 'boolean', this.visibility);\n }\n\n enum<const Values extends NonEmptyReadonlyArray<boolean>>(values: Values) {\n return new EnumProp(values, 'boolean', this.visibility);\n }\n\n validate(value: unknown) {\n if (typeof value !== 'boolean') {\n throw this.error;\n }\n }\n\n allows(value: unknown): value is boolean {\n return typeof value === 'boolean';\n }\n}\n"],"mappings":";;;;;AAQA,IAAa,aAAb,MAAa,mBAAsDA,sBAIjE;CACA,YAAY,YAAwB;EAClC,MAAM;GAAE,MAAM;GAAU;EAAW,CAAC;CACtC;CAEA,WAAuC;EACrC,OAAO,IAAI,WAAW,UAAU;CAClC;CAEA,QAAoC,OAAc;EAChD,OAAO,IAAIC,4BAAY,OAAO,UAAU,KAAK,UAAU;CACzD;CAEA,KAAyD,QAAgB;EACvE,OAAO,IAAIC,sBAAS,QAAQ,UAAU,KAAK,UAAU;CACvD;CAEA,SAAS,OAAgB;EACvB,IAAI,OAAO,UAAU,UACnB,MAAM,KAAK;CAEf;CAEA,OAAO,OAAiC;EACtC,OAAO,OAAO,UAAU;CAC1B;AACF;AAEA,IAAa,aAAb,MAAa,mBAAsDF,sBAIjE;CACA,YAAY,YAAwB;EAClC,MAAM;GAAE,MAAM;GAAU;EAAW,CAAC;CACtC;CAEA,WAAuC;EACrC,OAAO,IAAI,WAAW,UAAU;CAClC;CAEA,QAAoC,OAAc;EAChD,OAAO,IAAIC,4BAAY,OAAO,UAAU,KAAK,UAAU;CACzD;CAEA,KAAyD,QAAgB;EACvE,OAAO,IAAIC,sBAAS,QAAQ,UAAU,KAAK,UAAU;CACvD;CAEA,SAAS,OAAgB;EACvB,IAAI,OAAO,UAAU,UACnB,MAAM,KAAK;CAEf;CAEA,OAAO,OAAiC;EACtC,OAAO,OAAO,UAAU;CAC1B;AACF;AAEA,IAAa,cAAb,MAAa,oBAAuDF,sBAIlE;CACA,YAAY,YAAwB;EAClC,MAAM;GAAE,MAAM;GAAW;EAAW,CAAC;CACvC;CAEA,WAAwC;EACtC,OAAO,IAAI,YAAY,UAAU;CACnC;CAEA,QAAqC,OAAc;EACjD,OAAO,IAAIC,4BAAY,OAAO,WAAW,KAAK,UAAU;CAC1D;CAEA,KAA0D,QAAgB;EACxE,OAAO,IAAIC,sBAAS,QAAQ,WAAW,KAAK,UAAU;CACxD;CAEA,SAAS,OAAgB;EACvB,IAAI,OAAO,UAAU,WACnB,MAAM,KAAK;CAEf;CAEA,OAAO,OAAkC;EACvC,OAAO,OAAO,UAAU;CAC1B;AACF"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { NonEmptyReadonlyArray, PropVisibility } from "./types.cjs";
|
|
2
|
-
import { BaseProp } from "./base.cjs";
|
|
3
|
-
import { EnumProp } from "./enum.cjs";
|
|
4
|
-
import { LiteralProp } from "./literal.cjs";
|
|
5
|
-
|
|
6
|
-
//#region src/validators/primitive.d.ts
|
|
7
|
-
declare class StringProp<Visibility extends PropVisibility> extends BaseProp<'string', Visibility, string> {
|
|
8
|
-
constructor(visibility: Visibility);
|
|
9
|
-
optional(this: StringProp<'required'>): StringProp<"optional">;
|
|
10
|
-
literal<const Value extends string>(value: Value): LiteralProp<Value, "string", Visibility>;
|
|
11
|
-
enum<const Values extends NonEmptyReadonlyArray<string>>(values: Values): EnumProp<Values, "string", Visibility>;
|
|
12
|
-
validate(value: unknown): void;
|
|
13
|
-
allows(value: unknown): value is string;
|
|
14
|
-
}
|
|
15
|
-
declare class NumberProp<Visibility extends PropVisibility> extends BaseProp<'number', Visibility, number> {
|
|
16
|
-
constructor(visibility: Visibility);
|
|
17
|
-
optional(this: NumberProp<'required'>): NumberProp<"optional">;
|
|
18
|
-
literal<const Value extends number>(value: Value): LiteralProp<Value, "number", Visibility>;
|
|
19
|
-
enum<const Values extends NonEmptyReadonlyArray<number>>(values: Values): EnumProp<Values, "number", Visibility>;
|
|
20
|
-
validate(value: unknown): void;
|
|
21
|
-
allows(value: unknown): value is number;
|
|
22
|
-
}
|
|
23
|
-
declare class BooleanProp<Visibility extends PropVisibility> extends BaseProp<'boolean', Visibility, boolean> {
|
|
24
|
-
constructor(visibility: Visibility);
|
|
25
|
-
optional(this: BooleanProp<'required'>): BooleanProp<"optional">;
|
|
26
|
-
literal<const Value extends boolean>(value: Value): LiteralProp<Value, "boolean", Visibility>;
|
|
27
|
-
enum<const Values extends NonEmptyReadonlyArray<boolean>>(values: Values): EnumProp<Values, "boolean", Visibility>;
|
|
28
|
-
validate(value: unknown): void;
|
|
29
|
-
allows(value: unknown): value is boolean;
|
|
30
|
-
}
|
|
31
|
-
//#endregion
|
|
32
|
-
export { BooleanProp, NumberProp, StringProp };
|
|
33
|
-
//# sourceMappingURL=primitive.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"primitive.d.cts","names":[],"sources":["../../src/validators/primitive.ts"],"mappings":";;;;;;cAQa,UAAA,oBAA8B,cAAA,UAAwB,QAAA,WAEjE,UAAA;cAGY,UAAA,EAAY,UAAA;EAIxB,QAAA,CAAS,IAAA,EAAM,UAAA,eAAsB,UAAA;EAIrC,OAAA,6BAAoC,KAAA,EAAO,KAAA,GAAK,WAAA,CAAA,KAAA,YAAA,UAAA;EAIhD,IAAA,sBAA0B,qBAAA,UAA+B,MAAA,EAAQ,MAAA,GAAM,QAAA,CAAA,MAAA,YAAA,UAAA;EAIvE,QAAA,CAAS,KAAA;EAMT,MAAA,CAAO,KAAA,YAAiB,KAAA;AAAA;AAAA,cAKb,UAAA,oBAA8B,cAAA,UAAwB,QAAA,WAEjE,UAAA;cAGY,UAAA,EAAY,UAAA;EAIxB,QAAA,CAAS,IAAA,EAAM,UAAA,eAAsB,UAAA;EAIrC,OAAA,6BAAoC,KAAA,EAAO,KAAA,GAAK,WAAA,CAAA,KAAA,YAAA,UAAA;EAIhD,IAAA,sBAA0B,qBAAA,UAA+B,MAAA,EAAQ,MAAA,GAAM,QAAA,CAAA,MAAA,YAAA,UAAA;EAIvE,QAAA,CAAS,KAAA;EAMT,MAAA,CAAO,KAAA,YAAiB,KAAA;AAAA;AAAA,cAKb,WAAA,oBAA+B,cAAA,UAAwB,QAAA,YAElE,UAAA;cAGY,UAAA,EAAY,UAAA;EAIxB,QAAA,CAAS,IAAA,EAAM,WAAA,eAAuB,WAAA;EAItC,OAAA,8BAAqC,KAAA,EAAO,KAAA,GAAK,WAAA,CAAA,KAAA,aAAA,UAAA;EAIjD,IAAA,sBAA0B,qBAAA,WAAgC,MAAA,EAAQ,MAAA,GAAM,QAAA,CAAA,MAAA,aAAA,UAAA;EAIxE,QAAA,CAAS,KAAA;EAMT,MAAA,CAAO,KAAA,YAAiB,KAAA;AAAA"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { NonEmptyReadonlyArray, PropVisibility } from "./types.mjs";
|
|
2
|
-
import { BaseProp } from "./base.mjs";
|
|
3
|
-
import { EnumProp } from "./enum.mjs";
|
|
4
|
-
import { LiteralProp } from "./literal.mjs";
|
|
5
|
-
|
|
6
|
-
//#region src/validators/primitive.d.ts
|
|
7
|
-
declare class StringProp<Visibility extends PropVisibility> extends BaseProp<'string', Visibility, string> {
|
|
8
|
-
constructor(visibility: Visibility);
|
|
9
|
-
optional(this: StringProp<'required'>): StringProp<"optional">;
|
|
10
|
-
literal<const Value extends string>(value: Value): LiteralProp<Value, "string", Visibility>;
|
|
11
|
-
enum<const Values extends NonEmptyReadonlyArray<string>>(values: Values): EnumProp<Values, "string", Visibility>;
|
|
12
|
-
validate(value: unknown): void;
|
|
13
|
-
allows(value: unknown): value is string;
|
|
14
|
-
}
|
|
15
|
-
declare class NumberProp<Visibility extends PropVisibility> extends BaseProp<'number', Visibility, number> {
|
|
16
|
-
constructor(visibility: Visibility);
|
|
17
|
-
optional(this: NumberProp<'required'>): NumberProp<"optional">;
|
|
18
|
-
literal<const Value extends number>(value: Value): LiteralProp<Value, "number", Visibility>;
|
|
19
|
-
enum<const Values extends NonEmptyReadonlyArray<number>>(values: Values): EnumProp<Values, "number", Visibility>;
|
|
20
|
-
validate(value: unknown): void;
|
|
21
|
-
allows(value: unknown): value is number;
|
|
22
|
-
}
|
|
23
|
-
declare class BooleanProp<Visibility extends PropVisibility> extends BaseProp<'boolean', Visibility, boolean> {
|
|
24
|
-
constructor(visibility: Visibility);
|
|
25
|
-
optional(this: BooleanProp<'required'>): BooleanProp<"optional">;
|
|
26
|
-
literal<const Value extends boolean>(value: Value): LiteralProp<Value, "boolean", Visibility>;
|
|
27
|
-
enum<const Values extends NonEmptyReadonlyArray<boolean>>(values: Values): EnumProp<Values, "boolean", Visibility>;
|
|
28
|
-
validate(value: unknown): void;
|
|
29
|
-
allows(value: unknown): value is boolean;
|
|
30
|
-
}
|
|
31
|
-
//#endregion
|
|
32
|
-
export { BooleanProp, NumberProp, StringProp };
|
|
33
|
-
//# sourceMappingURL=primitive.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"primitive.d.mts","names":[],"sources":["../../src/validators/primitive.ts"],"mappings":";;;;;;cAQa,UAAA,oBAA8B,cAAA,UAAwB,QAAA,WAEjE,UAAA;cAGY,UAAA,EAAY,UAAA;EAIxB,QAAA,CAAS,IAAA,EAAM,UAAA,eAAsB,UAAA;EAIrC,OAAA,6BAAoC,KAAA,EAAO,KAAA,GAAK,WAAA,CAAA,KAAA,YAAA,UAAA;EAIhD,IAAA,sBAA0B,qBAAA,UAA+B,MAAA,EAAQ,MAAA,GAAM,QAAA,CAAA,MAAA,YAAA,UAAA;EAIvE,QAAA,CAAS,KAAA;EAMT,MAAA,CAAO,KAAA,YAAiB,KAAA;AAAA;AAAA,cAKb,UAAA,oBAA8B,cAAA,UAAwB,QAAA,WAEjE,UAAA;cAGY,UAAA,EAAY,UAAA;EAIxB,QAAA,CAAS,IAAA,EAAM,UAAA,eAAsB,UAAA;EAIrC,OAAA,6BAAoC,KAAA,EAAO,KAAA,GAAK,WAAA,CAAA,KAAA,YAAA,UAAA;EAIhD,IAAA,sBAA0B,qBAAA,UAA+B,MAAA,EAAQ,MAAA,GAAM,QAAA,CAAA,MAAA,YAAA,UAAA;EAIvE,QAAA,CAAS,KAAA;EAMT,MAAA,CAAO,KAAA,YAAiB,KAAA;AAAA;AAAA,cAKb,WAAA,oBAA+B,cAAA,UAAwB,QAAA,YAElE,UAAA;cAGY,UAAA,EAAY,UAAA;EAIxB,QAAA,CAAS,IAAA,EAAM,WAAA,eAAuB,WAAA;EAItC,OAAA,8BAAqC,KAAA,EAAO,KAAA,GAAK,WAAA,CAAA,KAAA,aAAA,UAAA;EAIjD,IAAA,sBAA0B,qBAAA,WAAgC,MAAA,EAAQ,MAAA,GAAM,QAAA,CAAA,MAAA,aAAA,UAAA;EAIxE,QAAA,CAAS,KAAA;EAMT,MAAA,CAAO,KAAA,YAAiB,KAAA;AAAA"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { BaseProp } from "./base.mjs";
|
|
2
|
-
import { EnumProp } from "./enum.mjs";
|
|
3
|
-
import { LiteralProp } from "./literal.mjs";
|
|
4
|
-
|
|
5
|
-
//#region src/validators/primitive.ts
|
|
6
|
-
var StringProp = class StringProp extends BaseProp {
|
|
7
|
-
constructor(visibility) {
|
|
8
|
-
super({
|
|
9
|
-
type: "string",
|
|
10
|
-
visibility
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
optional() {
|
|
14
|
-
return new StringProp("optional");
|
|
15
|
-
}
|
|
16
|
-
literal(value) {
|
|
17
|
-
return new LiteralProp(value, "string", this.visibility);
|
|
18
|
-
}
|
|
19
|
-
enum(values) {
|
|
20
|
-
return new EnumProp(values, "string", this.visibility);
|
|
21
|
-
}
|
|
22
|
-
validate(value) {
|
|
23
|
-
if (typeof value !== "string") throw this.error;
|
|
24
|
-
}
|
|
25
|
-
allows(value) {
|
|
26
|
-
return typeof value === "string";
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var NumberProp = class NumberProp extends BaseProp {
|
|
30
|
-
constructor(visibility) {
|
|
31
|
-
super({
|
|
32
|
-
type: "number",
|
|
33
|
-
visibility
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
optional() {
|
|
37
|
-
return new NumberProp("optional");
|
|
38
|
-
}
|
|
39
|
-
literal(value) {
|
|
40
|
-
return new LiteralProp(value, "number", this.visibility);
|
|
41
|
-
}
|
|
42
|
-
enum(values) {
|
|
43
|
-
return new EnumProp(values, "number", this.visibility);
|
|
44
|
-
}
|
|
45
|
-
validate(value) {
|
|
46
|
-
if (typeof value !== "number") throw this.error;
|
|
47
|
-
}
|
|
48
|
-
allows(value) {
|
|
49
|
-
return typeof value === "number";
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
var BooleanProp = class BooleanProp extends BaseProp {
|
|
53
|
-
constructor(visibility) {
|
|
54
|
-
super({
|
|
55
|
-
type: "boolean",
|
|
56
|
-
visibility
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
optional() {
|
|
60
|
-
return new BooleanProp("optional");
|
|
61
|
-
}
|
|
62
|
-
literal(value) {
|
|
63
|
-
return new LiteralProp(value, "boolean", this.visibility);
|
|
64
|
-
}
|
|
65
|
-
enum(values) {
|
|
66
|
-
return new EnumProp(values, "boolean", this.visibility);
|
|
67
|
-
}
|
|
68
|
-
validate(value) {
|
|
69
|
-
if (typeof value !== "boolean") throw this.error;
|
|
70
|
-
}
|
|
71
|
-
allows(value) {
|
|
72
|
-
return typeof value === "boolean";
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
//#endregion
|
|
77
|
-
export { BooleanProp, NumberProp, StringProp };
|
|
78
|
-
//# sourceMappingURL=primitive.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"primitive.mjs","names":[],"sources":["../../src/validators/primitive.ts"],"sourcesContent":["import type {\n NonEmptyReadonlyArray,\n PropVisibility,\n} from './types';\nimport { BaseProp } from './base';\nimport { EnumProp } from './enum';\nimport { LiteralProp } from './literal';\n\nexport class StringProp<Visibility extends PropVisibility> extends BaseProp<\n 'string',\n Visibility,\n string\n> {\n constructor(visibility: Visibility) {\n super({ type: 'string', visibility });\n }\n\n optional(this: StringProp<'required'>) {\n return new StringProp('optional');\n }\n\n literal<const Value extends string>(value: Value) {\n return new LiteralProp(value, 'string', this.visibility);\n }\n\n enum<const Values extends NonEmptyReadonlyArray<string>>(values: Values) {\n return new EnumProp(values, 'string', this.visibility);\n }\n\n validate(value: unknown) {\n if (typeof value !== 'string') {\n throw this.error;\n }\n }\n\n allows(value: unknown): value is string {\n return typeof value === 'string';\n }\n}\n\nexport class NumberProp<Visibility extends PropVisibility> extends BaseProp<\n 'number',\n Visibility,\n number\n> {\n constructor(visibility: Visibility) {\n super({ type: 'number', visibility });\n }\n\n optional(this: NumberProp<'required'>) {\n return new NumberProp('optional');\n }\n\n literal<const Value extends number>(value: Value) {\n return new LiteralProp(value, 'number', this.visibility);\n }\n\n enum<const Values extends NonEmptyReadonlyArray<number>>(values: Values) {\n return new EnumProp(values, 'number', this.visibility);\n }\n\n validate(value: unknown) {\n if (typeof value !== 'number') {\n throw this.error;\n }\n }\n\n allows(value: unknown): value is number {\n return typeof value === 'number';\n }\n}\n\nexport class BooleanProp<Visibility extends PropVisibility> extends BaseProp<\n 'boolean',\n Visibility,\n boolean\n> {\n constructor(visibility: Visibility) {\n super({ type: 'boolean', visibility });\n }\n\n optional(this: BooleanProp<'required'>) {\n return new BooleanProp('optional');\n }\n\n literal<const Value extends boolean>(value: Value) {\n return new LiteralProp(value, 'boolean', this.visibility);\n }\n\n enum<const Values extends NonEmptyReadonlyArray<boolean>>(values: Values) {\n return new EnumProp(values, 'boolean', this.visibility);\n }\n\n validate(value: unknown) {\n if (typeof value !== 'boolean') {\n throw this.error;\n }\n }\n\n allows(value: unknown): value is boolean {\n return typeof value === 'boolean';\n }\n}\n"],"mappings":";;;;;AAQA,IAAa,aAAb,MAAa,mBAAsD,SAIjE;CACA,YAAY,YAAwB;EAClC,MAAM;GAAE,MAAM;GAAU;EAAW,CAAC;CACtC;CAEA,WAAuC;EACrC,OAAO,IAAI,WAAW,UAAU;CAClC;CAEA,QAAoC,OAAc;EAChD,OAAO,IAAI,YAAY,OAAO,UAAU,KAAK,UAAU;CACzD;CAEA,KAAyD,QAAgB;EACvE,OAAO,IAAI,SAAS,QAAQ,UAAU,KAAK,UAAU;CACvD;CAEA,SAAS,OAAgB;EACvB,IAAI,OAAO,UAAU,UACnB,MAAM,KAAK;CAEf;CAEA,OAAO,OAAiC;EACtC,OAAO,OAAO,UAAU;CAC1B;AACF;AAEA,IAAa,aAAb,MAAa,mBAAsD,SAIjE;CACA,YAAY,YAAwB;EAClC,MAAM;GAAE,MAAM;GAAU;EAAW,CAAC;CACtC;CAEA,WAAuC;EACrC,OAAO,IAAI,WAAW,UAAU;CAClC;CAEA,QAAoC,OAAc;EAChD,OAAO,IAAI,YAAY,OAAO,UAAU,KAAK,UAAU;CACzD;CAEA,KAAyD,QAAgB;EACvE,OAAO,IAAI,SAAS,QAAQ,UAAU,KAAK,UAAU;CACvD;CAEA,SAAS,OAAgB;EACvB,IAAI,OAAO,UAAU,UACnB,MAAM,KAAK;CAEf;CAEA,OAAO,OAAiC;EACtC,OAAO,OAAO,UAAU;CAC1B;AACF;AAEA,IAAa,cAAb,MAAa,oBAAuD,SAIlE;CACA,YAAY,YAAwB;EAClC,MAAM;GAAE,MAAM;GAAW;EAAW,CAAC;CACvC;CAEA,WAAwC;EACtC,OAAO,IAAI,YAAY,UAAU;CACnC;CAEA,QAAqC,OAAc;EACjD,OAAO,IAAI,YAAY,OAAO,WAAW,KAAK,UAAU;CAC1D;CAEA,KAA0D,QAAgB;EACxE,OAAO,IAAI,SAAS,QAAQ,WAAW,KAAK,UAAU;CACxD;CAEA,SAAS,OAAgB;EACvB,IAAI,OAAO,UAAU,WACnB,MAAM,KAAK;CAEf;CAEA,OAAO,OAAkC;EACvC,OAAO,OAAO,UAAU;CAC1B;AACF"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { BaseProp } from "./base.cjs";
|
|
2
|
-
import { JSX, ReactNode } from "react";
|
|
3
|
-
|
|
4
|
-
//#region src/validators/types.d.ts
|
|
5
|
-
type PrimitiveTypesMap = PrimitiveValueTypes & {
|
|
6
|
-
object: object;
|
|
7
|
-
array: unknown[];
|
|
8
|
-
date: Date;
|
|
9
|
-
regex: RegExp;
|
|
10
|
-
error: Error;
|
|
11
|
-
symbol: symbol;
|
|
12
|
-
bigint: bigint;
|
|
13
|
-
};
|
|
14
|
-
type PrimitiveValueTypes = {
|
|
15
|
-
string: string;
|
|
16
|
-
number: number;
|
|
17
|
-
boolean: boolean;
|
|
18
|
-
};
|
|
19
|
-
type PropVisibility = 'optional' | 'required';
|
|
20
|
-
type PrimitivePropType = keyof PrimitiveValueTypes;
|
|
21
|
-
type NonEmptyReadonlyArray<Value> = readonly [Value, ...Value[]];
|
|
22
|
-
type PropConfig = Record<string, unknown>;
|
|
23
|
-
type ComponentPropType = 'ReactNode' | 'JSX.Element';
|
|
24
|
-
type ComponentPropTypeMap = {
|
|
25
|
-
ReactNode: ReactNode;
|
|
26
|
-
'JSX.Element': JSX.Element;
|
|
27
|
-
};
|
|
28
|
-
type PropType = keyof PrimitiveTypesMap | ComponentPropType | 'union' | 'function';
|
|
29
|
-
type BasePropOptions<Type extends PropType, Visibility extends PropVisibility, Value = unknown> = {
|
|
30
|
-
type: Type;
|
|
31
|
-
visibility: Visibility;
|
|
32
|
-
value?: Value;
|
|
33
|
-
};
|
|
34
|
-
type AnyBaseProp = BaseProp<PropType, PropVisibility, unknown>;
|
|
35
|
-
type ExtractPropValue<Prop extends AnyBaseProp> = Prop extends BaseProp<any, any, infer V> ? V : never;
|
|
36
|
-
interface AnyBuiltPropDefinition {
|
|
37
|
-
(value: unknown): unknown;
|
|
38
|
-
visibility: PropVisibility;
|
|
39
|
-
_baseProp?: AnyBaseProp;
|
|
40
|
-
}
|
|
41
|
-
interface BuiltPropShape {
|
|
42
|
-
[key: string]: AnyBuiltPropDefinition;
|
|
43
|
-
}
|
|
44
|
-
type ResolveBuiltPropValue<Definition extends AnyBuiltPropDefinition> = ReturnType<Definition>;
|
|
45
|
-
type ExtractDefinitionValue<D extends AnyBuiltPropDefinition> = D extends {
|
|
46
|
-
_baseProp: infer P extends AnyBaseProp;
|
|
47
|
-
} ? ExtractPropValue<P> : ReturnType<D>;
|
|
48
|
-
type ResolvedBuiltPropShape<Shape extends BuiltPropShape> = { [Key in keyof Shape as Shape[Key]['visibility'] extends 'required' ? Key : never]: ExtractDefinitionValue<Shape[Key]> } & { [Key in keyof Shape as Shape[Key]['visibility'] extends 'required' ? never : Key]?: ExtractDefinitionValue<Shape[Key]> };
|
|
49
|
-
type IsJSXElementProp<D extends AnyBuiltPropDefinition> = D extends {
|
|
50
|
-
type: 'JSX.Element';
|
|
51
|
-
} ? true : false;
|
|
52
|
-
type ResolvedPropKey<K extends string, D extends AnyBuiltPropDefinition> = IsJSXElementProp<D> extends true ? Capitalize<K> : K;
|
|
53
|
-
type ResolveProps<Shape extends Record<string, AnyBuiltPropDefinition>> = { [K in keyof Shape & string as Shape[K]['visibility'] extends 'required' ? ResolvedPropKey<K, Shape[K]> : never]: ExtractDefinitionValue<Shape[K]> } & { [K in keyof Shape & string as Shape[K]['visibility'] extends 'required' ? never : ResolvedPropKey<K, Shape[K]>]?: ExtractDefinitionValue<Shape[K]> };
|
|
54
|
-
type ExtractLayoutMemberValue<P extends AnyBaseProp> = P extends {
|
|
55
|
-
type: 'JSX.Element';
|
|
56
|
-
properties: infer Shape extends Record<string, AnyBuiltPropDefinition>;
|
|
57
|
-
} ? (props: ResolveProps<Shape>) => JSX.Element : P extends {
|
|
58
|
-
type: 'JSX.Element';
|
|
59
|
-
} ? () => JSX.Element : ExtractPropValue<P>;
|
|
60
|
-
type ExtractLayoutDefinitionValue<D extends AnyBuiltPropDefinition> = D extends {
|
|
61
|
-
type: 'JSX.Element';
|
|
62
|
-
properties: infer Shape extends Record<string, AnyBuiltPropDefinition>;
|
|
63
|
-
} ? (props: ResolveProps<Shape>) => JSX.Element : D extends {
|
|
64
|
-
type: 'JSX.Element';
|
|
65
|
-
} ? () => JSX.Element : D extends {
|
|
66
|
-
members: infer Members extends readonly AnyBaseProp[];
|
|
67
|
-
} ? ExtractLayoutMemberValue<Members[number]> : ExtractDefinitionValue<D>;
|
|
68
|
-
type ResolveLayoutProps<Shape extends Record<string, AnyBuiltPropDefinition>> = { [K in keyof Shape & string as Shape[K]['visibility'] extends 'required' ? ResolvedPropKey<K, Shape[K]> : never]: ExtractLayoutDefinitionValue<Shape[K]> } & { [K in keyof Shape & string as Shape[K]['visibility'] extends 'required' ? never : ResolvedPropKey<K, Shape[K]>]?: ExtractLayoutDefinitionValue<Shape[K]> };
|
|
69
|
-
//#endregion
|
|
70
|
-
export { AnyBaseProp, AnyBuiltPropDefinition, BasePropOptions, BuiltPropShape, ComponentPropType, ComponentPropTypeMap, ExtractPropValue, NonEmptyReadonlyArray, PrimitivePropType, PrimitiveTypesMap, PrimitiveValueTypes, PropConfig, PropType, PropVisibility, ResolveBuiltPropValue, ResolveLayoutProps, ResolveProps, ResolvedBuiltPropShape };
|
|
71
|
-
//# sourceMappingURL=types.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/validators/types.ts"],"mappings":"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"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { BaseProp } from "./base.mjs";
|
|
2
|
-
import { JSX, ReactNode } from "react";
|
|
3
|
-
|
|
4
|
-
//#region src/validators/types.d.ts
|
|
5
|
-
type PrimitiveTypesMap = PrimitiveValueTypes & {
|
|
6
|
-
object: object;
|
|
7
|
-
array: unknown[];
|
|
8
|
-
date: Date;
|
|
9
|
-
regex: RegExp;
|
|
10
|
-
error: Error;
|
|
11
|
-
symbol: symbol;
|
|
12
|
-
bigint: bigint;
|
|
13
|
-
};
|
|
14
|
-
type PrimitiveValueTypes = {
|
|
15
|
-
string: string;
|
|
16
|
-
number: number;
|
|
17
|
-
boolean: boolean;
|
|
18
|
-
};
|
|
19
|
-
type PropVisibility = 'optional' | 'required';
|
|
20
|
-
type PrimitivePropType = keyof PrimitiveValueTypes;
|
|
21
|
-
type NonEmptyReadonlyArray<Value> = readonly [Value, ...Value[]];
|
|
22
|
-
type PropConfig = Record<string, unknown>;
|
|
23
|
-
type ComponentPropType = 'ReactNode' | 'JSX.Element';
|
|
24
|
-
type ComponentPropTypeMap = {
|
|
25
|
-
ReactNode: ReactNode;
|
|
26
|
-
'JSX.Element': JSX.Element;
|
|
27
|
-
};
|
|
28
|
-
type PropType = keyof PrimitiveTypesMap | ComponentPropType | 'union' | 'function';
|
|
29
|
-
type BasePropOptions<Type extends PropType, Visibility extends PropVisibility, Value = unknown> = {
|
|
30
|
-
type: Type;
|
|
31
|
-
visibility: Visibility;
|
|
32
|
-
value?: Value;
|
|
33
|
-
};
|
|
34
|
-
type AnyBaseProp = BaseProp<PropType, PropVisibility, unknown>;
|
|
35
|
-
type ExtractPropValue<Prop extends AnyBaseProp> = Prop extends BaseProp<any, any, infer V> ? V : never;
|
|
36
|
-
interface AnyBuiltPropDefinition {
|
|
37
|
-
(value: unknown): unknown;
|
|
38
|
-
visibility: PropVisibility;
|
|
39
|
-
_baseProp?: AnyBaseProp;
|
|
40
|
-
}
|
|
41
|
-
interface BuiltPropShape {
|
|
42
|
-
[key: string]: AnyBuiltPropDefinition;
|
|
43
|
-
}
|
|
44
|
-
type ResolveBuiltPropValue<Definition extends AnyBuiltPropDefinition> = ReturnType<Definition>;
|
|
45
|
-
type ExtractDefinitionValue<D extends AnyBuiltPropDefinition> = D extends {
|
|
46
|
-
_baseProp: infer P extends AnyBaseProp;
|
|
47
|
-
} ? ExtractPropValue<P> : ReturnType<D>;
|
|
48
|
-
type ResolvedBuiltPropShape<Shape extends BuiltPropShape> = { [Key in keyof Shape as Shape[Key]['visibility'] extends 'required' ? Key : never]: ExtractDefinitionValue<Shape[Key]> } & { [Key in keyof Shape as Shape[Key]['visibility'] extends 'required' ? never : Key]?: ExtractDefinitionValue<Shape[Key]> };
|
|
49
|
-
type IsJSXElementProp<D extends AnyBuiltPropDefinition> = D extends {
|
|
50
|
-
type: 'JSX.Element';
|
|
51
|
-
} ? true : false;
|
|
52
|
-
type ResolvedPropKey<K extends string, D extends AnyBuiltPropDefinition> = IsJSXElementProp<D> extends true ? Capitalize<K> : K;
|
|
53
|
-
type ResolveProps<Shape extends Record<string, AnyBuiltPropDefinition>> = { [K in keyof Shape & string as Shape[K]['visibility'] extends 'required' ? ResolvedPropKey<K, Shape[K]> : never]: ExtractDefinitionValue<Shape[K]> } & { [K in keyof Shape & string as Shape[K]['visibility'] extends 'required' ? never : ResolvedPropKey<K, Shape[K]>]?: ExtractDefinitionValue<Shape[K]> };
|
|
54
|
-
type ExtractLayoutMemberValue<P extends AnyBaseProp> = P extends {
|
|
55
|
-
type: 'JSX.Element';
|
|
56
|
-
properties: infer Shape extends Record<string, AnyBuiltPropDefinition>;
|
|
57
|
-
} ? (props: ResolveProps<Shape>) => JSX.Element : P extends {
|
|
58
|
-
type: 'JSX.Element';
|
|
59
|
-
} ? () => JSX.Element : ExtractPropValue<P>;
|
|
60
|
-
type ExtractLayoutDefinitionValue<D extends AnyBuiltPropDefinition> = D extends {
|
|
61
|
-
type: 'JSX.Element';
|
|
62
|
-
properties: infer Shape extends Record<string, AnyBuiltPropDefinition>;
|
|
63
|
-
} ? (props: ResolveProps<Shape>) => JSX.Element : D extends {
|
|
64
|
-
type: 'JSX.Element';
|
|
65
|
-
} ? () => JSX.Element : D extends {
|
|
66
|
-
members: infer Members extends readonly AnyBaseProp[];
|
|
67
|
-
} ? ExtractLayoutMemberValue<Members[number]> : ExtractDefinitionValue<D>;
|
|
68
|
-
type ResolveLayoutProps<Shape extends Record<string, AnyBuiltPropDefinition>> = { [K in keyof Shape & string as Shape[K]['visibility'] extends 'required' ? ResolvedPropKey<K, Shape[K]> : never]: ExtractLayoutDefinitionValue<Shape[K]> } & { [K in keyof Shape & string as Shape[K]['visibility'] extends 'required' ? never : ResolvedPropKey<K, Shape[K]>]?: ExtractLayoutDefinitionValue<Shape[K]> };
|
|
69
|
-
//#endregion
|
|
70
|
-
export { AnyBaseProp, AnyBuiltPropDefinition, BasePropOptions, BuiltPropShape, ComponentPropType, ComponentPropTypeMap, ExtractPropValue, NonEmptyReadonlyArray, PrimitivePropType, PrimitiveTypesMap, PrimitiveValueTypes, PropConfig, PropType, PropVisibility, ResolveBuiltPropValue, ResolveLayoutProps, ResolveProps, ResolvedBuiltPropShape };
|
|
71
|
-
//# sourceMappingURL=types.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/validators/types.ts"],"mappings":";;;;KAGY,iBAAA,GAAoB,mBAAA;EAC9B,MAAA;EACA,KAAA;EACA,IAAA,EAAM,IAAA;EACN,KAAA,EAAO,MAAA;EACP,KAAA,EAAO,KAAA;EACP,MAAA;EACA,MAAA;AAAA;AAAA,KAGU,mBAAA;EACV,MAAA;EACA,MAAA;EACA,OAAA;AAAA;AAAA,KAGU,cAAA;AAAA,KACA,iBAAA,SAA0B,mBAAmB;AAAA,KAC7C,qBAAA,oBAAyC,KAAA,KAAU,KAAK;AAAA,KACxD,UAAA,GAAa,MAAM;AAAA,KACnB,iBAAA;AAAA,KACA,oBAAA;EACV,SAAA,EAAW,SAAA;EACX,aAAA,EAAe,GAAA,CAAI,OAAO;AAAA;AAAA,KAGhB,QAAA,SACF,iBAAA,GACN,iBAAiB;AAAA,KAIT,eAAA,cACG,QAAA,qBACM,cAAA;EAGnB,IAAA,EAAM,IAAA;EACN,UAAA,EAAY,UAAA;EACZ,KAAA,GAAQ,KAAA;AAAA;AAAA,KAGE,WAAA,GAAc,QAAA,CAAS,QAAA,EAAU,cAAA;AAAA,KAEjC,gBAAA,cAA8B,WAAA,IACxC,IAAA,SAAa,QAAA,sBAA8B,CAAA;AAAA,UAE5B,sBAAA;EAAA,CACd,KAAA;EACD,UAAA,EAAY,cAAA;EACZ,SAAA,GAAY,WAAW;AAAA;AAAA,UAGR,cAAA;EAAA,CACd,GAAA,WAAc,sBAAsB;AAAA;AAAA,KAG3B,qBAAA,oBAAyC,sBAAA,IACnD,UAAA,CAAW,UAAA;AAAA,KAER,sBAAA,WAAiC,sBAAA,IAA0B,CAAA;EAC9D,SAAA,kBAA2B,WAAA;AAAA,IAEzB,gBAAA,CAAiB,CAAA,IACjB,UAAA,CAAW,CAAA;AAAA,KAEH,sBAAA,eAAqC,cAAA,oBACjC,KAAA,IAAS,KAAA,CAAM,GAAA,qCACzB,GAAA,WACQ,sBAAA,CAAuB,KAAA,CAAM,GAAA,uBAE3B,KAAA,IAAS,KAAA,CAAM,GAAA,6CAEzB,GAAA,IAAO,sBAAA,CAAuB,KAAA,CAAM,GAAA;AAAA,KAGrC,gBAAA,WAA2B,sBAAA,IAA0B,CAAC;EACzD,IAAA;AAAA;AAAA,KAKG,eAAA,6BAA4C,sBAAA,IAC/C,gBAAA,CAAiB,CAAA,iBAAkB,UAAA,CAAW,CAAA,IAAK,CAAA;AAAA,KAEzC,YAAA,eAA2B,MAAA,SAAe,sBAAA,mBAEtC,KAAA,aAAkB,KAAA,CAAM,CAAA,qCAChC,eAAA,CAAgB,CAAA,EAAG,KAAA,CAAM,CAAA,aACjB,sBAAA,CAAuB,KAAA,CAAM,CAAA,qBAE7B,KAAA,aAAkB,KAAA,CAAM,CAAA,6CAEhC,eAAA,CAAgB,CAAA,EAAG,KAAA,CAAM,CAAA,MAAO,sBAAA,CAAuB,KAAA,CAAM,CAAA;AAAA,KAGhE,wBAAA,WAAmC,WAAA,IAAe,CAAA;EACrD,IAAA;EACA,UAAA,sBAAgC,MAAA,SAAe,sBAAA;AAAA,KAE5C,KAAA,EAAO,YAAA,CAAa,KAAA,MAAW,GAAA,CAAI,OAAA,GACpC,CAAA;EAAY,IAAA;AAAA,UACJ,GAAA,CAAI,OAAA,GACV,gBAAA,CAAiB,CAAA;AAAA,KAElB,4BAAA,WAAuC,sBAAA,IAC1C,CAAA;EACE,IAAA;EACA,UAAA,sBAAgC,MAAA,SAAe,sBAAA;AAAA,KAE5C,KAAA,EAAO,YAAA,CAAa,KAAA,MAAW,GAAA,CAAI,OAAA,GACpC,CAAA;EAAY,IAAA;AAAA,UACJ,GAAA,CAAI,OAAA,GACV,CAAA;EAAY,OAAA,iCAAwC,WAAA;AAAA,IAClD,wBAAA,CAAyB,OAAA,YACzB,sBAAA,CAAuB,CAAA;AAAA,KAErB,kBAAA,eACI,MAAA,SAAe,sBAAA,mBAEjB,KAAA,aAAkB,KAAA,CAAM,CAAA,qCAChC,eAAA,CAAgB,CAAA,EAAG,KAAA,CAAM,CAAA,aACjB,4BAAA,CAA6B,KAAA,CAAM,CAAA,qBAEnC,KAAA,aAAkB,KAAA,CAAM,CAAA,6CAEhC,eAAA,CAAgB,CAAA,EAAG,KAAA,CAAM,CAAA,MAAO,4BAAA,CAA6B,KAAA,CAAM,CAAA"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const require_base = require('./base.cjs');
|
|
2
|
-
|
|
3
|
-
//#region src/validators/union.ts
|
|
4
|
-
var UnionProp = class UnionProp extends require_base.BaseProp {
|
|
5
|
-
members;
|
|
6
|
-
constructor(members, visibility) {
|
|
7
|
-
super({
|
|
8
|
-
type: "union",
|
|
9
|
-
visibility
|
|
10
|
-
});
|
|
11
|
-
this.members = members;
|
|
12
|
-
}
|
|
13
|
-
optional() {
|
|
14
|
-
return new UnionProp(this.members, "optional");
|
|
15
|
-
}
|
|
16
|
-
validate(value) {
|
|
17
|
-
for (const member of this.members) if (member.allows(value)) return;
|
|
18
|
-
throw this.error;
|
|
19
|
-
}
|
|
20
|
-
allows(value) {
|
|
21
|
-
return this.members.some((member) => member.allows(value));
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
//#endregion
|
|
26
|
-
exports.UnionProp = UnionProp;
|
|
27
|
-
//# sourceMappingURL=union.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"union.cjs","names":["BaseProp"],"sources":["../../src/validators/union.ts"],"sourcesContent":["import type { AnyBaseProp, ExtractPropValue, PropVisibility } from './types';\nimport { BaseProp } from './base';\n\nexport class UnionProp<\n const Members extends readonly AnyBaseProp[],\n Visibility extends PropVisibility,\n> extends BaseProp<'union', Visibility, ExtractPropValue<Members[number]>> {\n readonly members: Members;\n\n constructor(members: Members, visibility: Visibility) {\n super({ type: 'union', visibility });\n this.members = members;\n }\n\n optional(this: UnionProp<Members, 'required'>) {\n return new UnionProp(this.members, 'optional');\n }\n\n validate(value: unknown) {\n for (const member of this.members) {\n if (member.allows(value)) return;\n }\n\n throw this.error;\n }\n\n allows(value: unknown): value is ExtractPropValue<Members[number]> {\n return this.members.some((member) => member.allows(value));\n }\n}\n"],"mappings":";;;AAGA,IAAa,YAAb,MAAa,kBAGHA,sBAAiE;CACzE,AAAS;CAET,YAAY,SAAkB,YAAwB;EACpD,MAAM;GAAE,MAAM;GAAS;EAAW,CAAC;EACnC,KAAK,UAAU;CACjB;CAEA,WAA+C;EAC7C,OAAO,IAAI,UAAU,KAAK,SAAS,UAAU;CAC/C;CAEA,SAAS,OAAgB;EACvB,KAAK,MAAM,UAAU,KAAK,SACxB,IAAI,OAAO,OAAO,KAAK,GAAG;EAG5B,MAAM,KAAK;CACb;CAEA,OAAO,OAA4D;EACjE,OAAO,KAAK,QAAQ,MAAM,WAAW,OAAO,OAAO,KAAK,CAAC;CAC3D;AACF"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { AnyBaseProp, ExtractPropValue, PropVisibility } from "./types.cjs";
|
|
2
|
-
import { BaseProp } from "./base.cjs";
|
|
3
|
-
|
|
4
|
-
//#region src/validators/union.d.ts
|
|
5
|
-
declare class UnionProp<const Members extends readonly AnyBaseProp[], Visibility extends PropVisibility> extends BaseProp<'union', Visibility, ExtractPropValue<Members[number]>> {
|
|
6
|
-
readonly members: Members;
|
|
7
|
-
constructor(members: Members, visibility: Visibility);
|
|
8
|
-
optional(this: UnionProp<Members, 'required'>): UnionProp<Members, "optional">;
|
|
9
|
-
validate(value: unknown): void;
|
|
10
|
-
allows(value: unknown): value is ExtractPropValue<Members[number]>;
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
13
|
-
export { UnionProp };
|
|
14
|
-
//# sourceMappingURL=union.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"union.d.cts","names":[],"sources":["../../src/validators/union.ts"],"mappings":";;;;cAGa,SAAA,gCACoB,WAAA,uBACZ,cAAA,UACX,QAAA,UAAkB,UAAA,EAAY,gBAAA,CAAiB,OAAA;EAAA,SAC9C,OAAA,EAAS,OAAA;cAEN,OAAA,EAAS,OAAA,EAAS,UAAA,EAAY,UAAA;EAK1C,QAAA,CAAS,IAAA,EAAM,SAAA,CAAU,OAAA,gBAAoB,SAAA,CAAA,OAAA;EAI7C,QAAA,CAAS,KAAA;EAQT,MAAA,CAAO,KAAA,YAAiB,KAAA,IAAS,gBAAA,CAAiB,OAAA;AAAA"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { AnyBaseProp, ExtractPropValue, PropVisibility } from "./types.mjs";
|
|
2
|
-
import { BaseProp } from "./base.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/validators/union.d.ts
|
|
5
|
-
declare class UnionProp<const Members extends readonly AnyBaseProp[], Visibility extends PropVisibility> extends BaseProp<'union', Visibility, ExtractPropValue<Members[number]>> {
|
|
6
|
-
readonly members: Members;
|
|
7
|
-
constructor(members: Members, visibility: Visibility);
|
|
8
|
-
optional(this: UnionProp<Members, 'required'>): UnionProp<Members, "optional">;
|
|
9
|
-
validate(value: unknown): void;
|
|
10
|
-
allows(value: unknown): value is ExtractPropValue<Members[number]>;
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
13
|
-
export { UnionProp };
|
|
14
|
-
//# sourceMappingURL=union.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"union.d.mts","names":[],"sources":["../../src/validators/union.ts"],"mappings":";;;;cAGa,SAAA,gCACoB,WAAA,uBACZ,cAAA,UACX,QAAA,UAAkB,UAAA,EAAY,gBAAA,CAAiB,OAAA;EAAA,SAC9C,OAAA,EAAS,OAAA;cAEN,OAAA,EAAS,OAAA,EAAS,UAAA,EAAY,UAAA;EAK1C,QAAA,CAAS,IAAA,EAAM,SAAA,CAAU,OAAA,gBAAoB,SAAA,CAAA,OAAA;EAI7C,QAAA,CAAS,KAAA;EAQT,MAAA,CAAO,KAAA,YAAiB,KAAA,IAAS,gBAAA,CAAiB,OAAA;AAAA"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { BaseProp } from "./base.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/validators/union.ts
|
|
4
|
-
var UnionProp = class UnionProp extends BaseProp {
|
|
5
|
-
members;
|
|
6
|
-
constructor(members, visibility) {
|
|
7
|
-
super({
|
|
8
|
-
type: "union",
|
|
9
|
-
visibility
|
|
10
|
-
});
|
|
11
|
-
this.members = members;
|
|
12
|
-
}
|
|
13
|
-
optional() {
|
|
14
|
-
return new UnionProp(this.members, "optional");
|
|
15
|
-
}
|
|
16
|
-
validate(value) {
|
|
17
|
-
for (const member of this.members) if (member.allows(value)) return;
|
|
18
|
-
throw this.error;
|
|
19
|
-
}
|
|
20
|
-
allows(value) {
|
|
21
|
-
return this.members.some((member) => member.allows(value));
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
//#endregion
|
|
26
|
-
export { UnionProp };
|
|
27
|
-
//# sourceMappingURL=union.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"union.mjs","names":[],"sources":["../../src/validators/union.ts"],"sourcesContent":["import type { AnyBaseProp, ExtractPropValue, PropVisibility } from './types';\nimport { BaseProp } from './base';\n\nexport class UnionProp<\n const Members extends readonly AnyBaseProp[],\n Visibility extends PropVisibility,\n> extends BaseProp<'union', Visibility, ExtractPropValue<Members[number]>> {\n readonly members: Members;\n\n constructor(members: Members, visibility: Visibility) {\n super({ type: 'union', visibility });\n this.members = members;\n }\n\n optional(this: UnionProp<Members, 'required'>) {\n return new UnionProp(this.members, 'optional');\n }\n\n validate(value: unknown) {\n for (const member of this.members) {\n if (member.allows(value)) return;\n }\n\n throw this.error;\n }\n\n allows(value: unknown): value is ExtractPropValue<Members[number]> {\n return this.members.some((member) => member.allows(value));\n }\n}\n"],"mappings":";;;AAGA,IAAa,YAAb,MAAa,kBAGH,SAAiE;CACzE,AAAS;CAET,YAAY,SAAkB,YAAwB;EACpD,MAAM;GAAE,MAAM;GAAS;EAAW,CAAC;EACnC,KAAK,UAAU;CACjB;CAEA,WAA+C;EAC7C,OAAO,IAAI,UAAU,KAAK,SAAS,UAAU;CAC/C;CAEA,SAAS,OAAgB;EACvB,KAAK,MAAM,UAAU,KAAK,SACxB,IAAI,OAAO,OAAO,KAAK,GAAG;EAG5B,MAAM,KAAK;CACb;CAEA,OAAO,OAA4D;EACjE,OAAO,KAAK,QAAQ,MAAM,WAAW,OAAO,OAAO,KAAK,CAAC;CAC3D;AACF"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/validators/validate-props.ts
|
|
3
|
-
var MissingRequiredPropError = class extends Error {
|
|
4
|
-
constructor(key) {
|
|
5
|
-
super(`Property "${key}" is required but not provided.`);
|
|
6
|
-
}
|
|
7
|
-
};
|
|
8
|
-
function validateProps(shape, props) {
|
|
9
|
-
for (const key in shape) {
|
|
10
|
-
const prop = shape[key];
|
|
11
|
-
if (prop.visibility === "required" && !(key in props)) throw new MissingRequiredPropError(key);
|
|
12
|
-
if (prop.visibility === "optional" && !(key in props)) continue;
|
|
13
|
-
const value = props[key];
|
|
14
|
-
if ("type" in prop && prop.type === "JSX.Element" && typeof value === "function") continue;
|
|
15
|
-
prop(value);
|
|
16
|
-
}
|
|
17
|
-
return props;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
//#endregion
|
|
21
|
-
exports.validateProps = validateProps;
|
|
22
|
-
//# sourceMappingURL=validate-props.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate-props.cjs","names":[],"sources":["../../src/validators/validate-props.ts"],"sourcesContent":["import type { AnyBuiltPropDefinition } from './types';\n\nexport class MissingRequiredPropError extends Error {\n constructor(key: string) {\n super(`Property \"${key}\" is required but not provided.`);\n }\n}\n\nexport function validateProps<T extends object>(\n shape: Record<string, AnyBuiltPropDefinition>,\n props: T,\n) {\n for (const key in shape) {\n const prop = shape[key];\n\n if (prop.visibility === 'required' && !(key in props)) {\n throw new MissingRequiredPropError(key);\n }\n\n if (prop.visibility === 'optional' && !(key in props)) {\n continue;\n }\n\n const value = (props as Record<string, unknown>)[key];\n\n if (\n 'type' in prop &&\n prop.type === 'JSX.Element' &&\n typeof value === 'function'\n ) {\n continue;\n }\n\n prop(value);\n }\n\n return props;\n}\n"],"mappings":";;AAEA,IAAa,2BAAb,cAA8C,MAAM;CAClD,YAAY,KAAa;EACvB,MAAM,aAAa,IAAI,gCAAgC;CACzD;AACF;AAEA,SAAgB,cACd,OACA,OACA;CACA,KAAK,MAAM,OAAO,OAAO;EACvB,MAAM,OAAO,MAAM;EAEnB,IAAI,KAAK,eAAe,cAAc,EAAE,OAAO,QAC7C,MAAM,IAAI,yBAAyB,GAAG;EAGxC,IAAI,KAAK,eAAe,cAAc,EAAE,OAAO,QAC7C;EAGF,MAAM,QAAS,MAAkC;EAEjD,IACE,UAAU,QACV,KAAK,SAAS,iBACd,OAAO,UAAU,YAEjB;EAGF,KAAK,KAAK;CACZ;CAEA,OAAO;AACT"}
|