@duckpic/content-spec 0.1.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/components/Layout.d.ts +25 -0
- package/dist/components/Layout.js +14 -0
- package/dist/components/Quiz.d.ts +24 -0
- package/dist/components/Quiz.js +14 -0
- package/dist/components/Text.d.ts +30 -0
- package/dist/components/Text.js +11 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.js +15 -0
- package/package.json +21 -0
- package/src/components/Layout.ts +19 -0
- package/src/components/Quiz.ts +19 -0
- package/src/components/Text.ts +16 -0
- package/src/index.ts +20 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const LayoutStyleSchema: z.ZodObject<{
|
|
3
|
+
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
4
|
+
padding: z.ZodOptional<z.ZodString>;
|
|
5
|
+
borderRadius: z.ZodOptional<z.ZodString>;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
export declare const LayoutPropsSchema: z.ZodObject<{
|
|
8
|
+
style: z.ZodOptional<z.ZodObject<{
|
|
9
|
+
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
10
|
+
padding: z.ZodOptional<z.ZodString>;
|
|
11
|
+
borderRadius: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, z.core.$strip>>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export type LayoutProps = z.infer<typeof LayoutPropsSchema>;
|
|
15
|
+
export declare const LayoutComponentSpec: {
|
|
16
|
+
type: string;
|
|
17
|
+
propsSchema: z.ZodObject<{
|
|
18
|
+
style: z.ZodOptional<z.ZodObject<{
|
|
19
|
+
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
20
|
+
padding: z.ZodOptional<z.ZodString>;
|
|
21
|
+
borderRadius: z.ZodOptional<z.ZodString>;
|
|
22
|
+
}, z.core.$strip>>;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
slots: string[];
|
|
25
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const LayoutStyleSchema = z.object({
|
|
3
|
+
backgroundColor: z.string().optional(),
|
|
4
|
+
padding: z.string().optional(),
|
|
5
|
+
borderRadius: z.string().optional()
|
|
6
|
+
});
|
|
7
|
+
export const LayoutPropsSchema = z.object({
|
|
8
|
+
style: LayoutStyleSchema.optional()
|
|
9
|
+
});
|
|
10
|
+
export const LayoutComponentSpec = {
|
|
11
|
+
type: "Layout",
|
|
12
|
+
propsSchema: LayoutPropsSchema,
|
|
13
|
+
slots: ["content"] // can contain children
|
|
14
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const QuizQuestionSchema: z.ZodObject<{
|
|
3
|
+
q: z.ZodString;
|
|
4
|
+
a: z.ZodString;
|
|
5
|
+
}, z.core.$strip>;
|
|
6
|
+
export declare const QuizPropsSchema: z.ZodObject<{
|
|
7
|
+
title: z.ZodOptional<z.ZodString>;
|
|
8
|
+
questions: z.ZodArray<z.ZodObject<{
|
|
9
|
+
q: z.ZodString;
|
|
10
|
+
a: z.ZodString;
|
|
11
|
+
}, z.core.$strip>>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
export type QuizProps = z.infer<typeof QuizPropsSchema>;
|
|
14
|
+
export declare const QuizComponentSpec: {
|
|
15
|
+
type: string;
|
|
16
|
+
propsSchema: z.ZodObject<{
|
|
17
|
+
title: z.ZodOptional<z.ZodString>;
|
|
18
|
+
questions: z.ZodArray<z.ZodObject<{
|
|
19
|
+
q: z.ZodString;
|
|
20
|
+
a: z.ZodString;
|
|
21
|
+
}, z.core.$strip>>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
slots: never[];
|
|
24
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const QuizQuestionSchema = z.object({
|
|
3
|
+
q: z.string(),
|
|
4
|
+
a: z.string()
|
|
5
|
+
});
|
|
6
|
+
export const QuizPropsSchema = z.object({
|
|
7
|
+
title: z.string().optional(),
|
|
8
|
+
questions: z.array(QuizQuestionSchema).min(1)
|
|
9
|
+
});
|
|
10
|
+
export const QuizComponentSpec = {
|
|
11
|
+
type: "Quiz",
|
|
12
|
+
propsSchema: QuizPropsSchema,
|
|
13
|
+
slots: [] // quizzes don’t have child nodes
|
|
14
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const TextVariantSchema: z.ZodEnum<{
|
|
3
|
+
body: "body";
|
|
4
|
+
h1: "h1";
|
|
5
|
+
h2: "h2";
|
|
6
|
+
h3: "h3";
|
|
7
|
+
}>;
|
|
8
|
+
export declare const TextPropsSchema: z.ZodObject<{
|
|
9
|
+
variant: z.ZodEnum<{
|
|
10
|
+
body: "body";
|
|
11
|
+
h1: "h1";
|
|
12
|
+
h2: "h2";
|
|
13
|
+
h3: "h3";
|
|
14
|
+
}>;
|
|
15
|
+
text: z.ZodString;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export type TextProps = z.infer<typeof TextPropsSchema>;
|
|
18
|
+
export declare const TextComponentSpec: {
|
|
19
|
+
type: string;
|
|
20
|
+
propsSchema: z.ZodObject<{
|
|
21
|
+
variant: z.ZodEnum<{
|
|
22
|
+
body: "body";
|
|
23
|
+
h1: "h1";
|
|
24
|
+
h2: "h2";
|
|
25
|
+
h3: "h3";
|
|
26
|
+
}>;
|
|
27
|
+
text: z.ZodString;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
slots: never[];
|
|
30
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const TextVariantSchema = z.enum(["h1", "h2", "h3", "body"]);
|
|
3
|
+
export const TextPropsSchema = z.object({
|
|
4
|
+
variant: TextVariantSchema,
|
|
5
|
+
text: z.string()
|
|
6
|
+
});
|
|
7
|
+
export const TextComponentSpec = {
|
|
8
|
+
type: "Text",
|
|
9
|
+
propsSchema: TextPropsSchema,
|
|
10
|
+
slots: [] // no children
|
|
11
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export * from "./components/Text";
|
|
2
|
+
export * from "./components/Quiz";
|
|
3
|
+
export * from "./components/Layout";
|
|
4
|
+
export declare const ComponentRegistry: {
|
|
5
|
+
Text: {
|
|
6
|
+
type: string;
|
|
7
|
+
propsSchema: import("zod").ZodObject<{
|
|
8
|
+
variant: import("zod").ZodEnum<{
|
|
9
|
+
body: "body";
|
|
10
|
+
h1: "h1";
|
|
11
|
+
h2: "h2";
|
|
12
|
+
h3: "h3";
|
|
13
|
+
}>;
|
|
14
|
+
text: import("zod").ZodString;
|
|
15
|
+
}, import("zod/v4/core").$strip>;
|
|
16
|
+
slots: never[];
|
|
17
|
+
};
|
|
18
|
+
Quiz: {
|
|
19
|
+
type: string;
|
|
20
|
+
propsSchema: import("zod").ZodObject<{
|
|
21
|
+
title: import("zod").ZodOptional<import("zod").ZodString>;
|
|
22
|
+
questions: import("zod").ZodArray<import("zod").ZodObject<{
|
|
23
|
+
q: import("zod").ZodString;
|
|
24
|
+
a: import("zod").ZodString;
|
|
25
|
+
}, import("zod/v4/core").$strip>>;
|
|
26
|
+
}, import("zod/v4/core").$strip>;
|
|
27
|
+
slots: never[];
|
|
28
|
+
};
|
|
29
|
+
Layout: {
|
|
30
|
+
type: string;
|
|
31
|
+
propsSchema: import("zod").ZodObject<{
|
|
32
|
+
style: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
33
|
+
backgroundColor: import("zod").ZodOptional<import("zod").ZodString>;
|
|
34
|
+
padding: import("zod").ZodOptional<import("zod").ZodString>;
|
|
35
|
+
borderRadius: import("zod").ZodOptional<import("zod").ZodString>;
|
|
36
|
+
}, import("zod/v4/core").$strip>>;
|
|
37
|
+
}, import("zod/v4/core").$strip>;
|
|
38
|
+
slots: string[];
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export type ComponentType = keyof typeof ComponentRegistry;
|
|
42
|
+
export declare function getPropsSchema(type: ComponentType): import("zod").ZodObject<{
|
|
43
|
+
variant: import("zod").ZodEnum<{
|
|
44
|
+
body: "body";
|
|
45
|
+
h1: "h1";
|
|
46
|
+
h2: "h2";
|
|
47
|
+
h3: "h3";
|
|
48
|
+
}>;
|
|
49
|
+
text: import("zod").ZodString;
|
|
50
|
+
}, import("zod/v4/core").$strip> | import("zod").ZodObject<{
|
|
51
|
+
title: import("zod").ZodOptional<import("zod").ZodString>;
|
|
52
|
+
questions: import("zod").ZodArray<import("zod").ZodObject<{
|
|
53
|
+
q: import("zod").ZodString;
|
|
54
|
+
a: import("zod").ZodString;
|
|
55
|
+
}, import("zod/v4/core").$strip>>;
|
|
56
|
+
}, import("zod/v4/core").$strip> | import("zod").ZodObject<{
|
|
57
|
+
style: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
58
|
+
backgroundColor: import("zod").ZodOptional<import("zod").ZodString>;
|
|
59
|
+
padding: import("zod").ZodOptional<import("zod").ZodString>;
|
|
60
|
+
borderRadius: import("zod").ZodOptional<import("zod").ZodString>;
|
|
61
|
+
}, import("zod/v4/core").$strip>>;
|
|
62
|
+
}, import("zod/v4/core").$strip>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from "./components/Text";
|
|
2
|
+
export * from "./components/Quiz";
|
|
3
|
+
export * from "./components/Layout";
|
|
4
|
+
import { TextComponentSpec } from "./components/Text";
|
|
5
|
+
import { QuizComponentSpec } from "./components/Quiz";
|
|
6
|
+
import { LayoutComponentSpec } from "./components/Layout";
|
|
7
|
+
export const ComponentRegistry = {
|
|
8
|
+
Text: TextComponentSpec,
|
|
9
|
+
Quiz: QuizComponentSpec,
|
|
10
|
+
Layout: LayoutComponentSpec
|
|
11
|
+
};
|
|
12
|
+
// Helper to get a schema by type
|
|
13
|
+
export function getPropsSchema(type) {
|
|
14
|
+
return ComponentRegistry[type].propsSchema;
|
|
15
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@duckpic/content-spec",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"prepublishOnly": "npm run build"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"zod": "^3.22.0"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"typescript": "^5.6.0",
|
|
16
|
+
"@types/node": "^22.0.0"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const LayoutStyleSchema = z.object({
|
|
4
|
+
backgroundColor: z.string().optional(),
|
|
5
|
+
padding: z.string().optional(),
|
|
6
|
+
borderRadius: z.string().optional()
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export const LayoutPropsSchema = z.object({
|
|
10
|
+
style: LayoutStyleSchema.optional()
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export type LayoutProps = z.infer<typeof LayoutPropsSchema>;
|
|
14
|
+
|
|
15
|
+
export const LayoutComponentSpec = {
|
|
16
|
+
type: "Layout",
|
|
17
|
+
propsSchema: LayoutPropsSchema,
|
|
18
|
+
slots: ["content"] // can contain children
|
|
19
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const QuizQuestionSchema = z.object({
|
|
4
|
+
q: z.string(),
|
|
5
|
+
a: z.string()
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export const QuizPropsSchema = z.object({
|
|
9
|
+
title: z.string().optional(),
|
|
10
|
+
questions: z.array(QuizQuestionSchema).min(1)
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export type QuizProps = z.infer<typeof QuizPropsSchema>;
|
|
14
|
+
|
|
15
|
+
export const QuizComponentSpec = {
|
|
16
|
+
type: "Quiz",
|
|
17
|
+
propsSchema: QuizPropsSchema,
|
|
18
|
+
slots: [] // quizzes don’t have child nodes
|
|
19
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const TextVariantSchema = z.enum(["h1", "h2", "h3", "body"]);
|
|
4
|
+
|
|
5
|
+
export const TextPropsSchema = z.object({
|
|
6
|
+
variant: TextVariantSchema,
|
|
7
|
+
text: z.string()
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export type TextProps = z.infer<typeof TextPropsSchema>;
|
|
11
|
+
|
|
12
|
+
export const TextComponentSpec = {
|
|
13
|
+
type: "Text",
|
|
14
|
+
propsSchema: TextPropsSchema,
|
|
15
|
+
slots: [] // no children
|
|
16
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from "./components/Text";
|
|
2
|
+
export * from "./components/Quiz";
|
|
3
|
+
export * from "./components/Layout";
|
|
4
|
+
|
|
5
|
+
import { TextComponentSpec } from "./components/Text";
|
|
6
|
+
import { QuizComponentSpec } from "./components/Quiz";
|
|
7
|
+
import { LayoutComponentSpec } from "./components/Layout";
|
|
8
|
+
|
|
9
|
+
export const ComponentRegistry = {
|
|
10
|
+
Text: TextComponentSpec,
|
|
11
|
+
Quiz: QuizComponentSpec,
|
|
12
|
+
Layout: LayoutComponentSpec
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type ComponentType = keyof typeof ComponentRegistry;
|
|
16
|
+
|
|
17
|
+
// Helper to get a schema by type
|
|
18
|
+
export function getPropsSchema(type: ComponentType) {
|
|
19
|
+
return ComponentRegistry[type].propsSchema;
|
|
20
|
+
}
|