@cntrl-site/sdk 1.12.2 → 1.12.4-alpha.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/lib/schemas/article/Article.schema.js +3 -1
- package/lib/schemas/article/Interaction.schema.js +17 -0
- package/lib/schemas/article/Item.schema.js +13 -10
- package/lib/schemas/article/ItemState.schema.js +48 -48
- package/lib/schemas/article/RichTextItem.schema.js +1 -1
- package/lib/types/article/Interaction.js +2 -0
- package/package.json +1 -1
- package/src/index.ts +2 -2
- package/src/schemas/article/Article.schema.ts +3 -1
- package/src/schemas/article/Interaction.schema.ts +18 -0
- package/src/schemas/article/Item.schema.ts +18 -14
- package/src/schemas/article/ItemState.schema.ts +53 -50
- package/src/schemas/article/RichTextItem.schema.ts +2 -2
- package/src/types/article/Interaction.ts +17 -0
- package/src/types/article/Item.ts +6 -1
- package/src/types/article/ItemState.ts +46 -48
- package/cntrl-site-sdk-1.12.2.tgz +0 -0
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ArticleSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const Section_schema_1 = require("./Section.schema");
|
|
6
|
+
const Interaction_schema_1 = require("./Interaction.schema");
|
|
6
7
|
exports.ArticleSchema = zod_1.z.object({
|
|
7
8
|
id: zod_1.z.string().min(1),
|
|
8
|
-
sections: zod_1.z.array(Section_schema_1.SectionSchema)
|
|
9
|
+
sections: zod_1.z.array(Section_schema_1.SectionSchema),
|
|
10
|
+
interactions: zod_1.z.array(Interaction_schema_1.InteractionSchema)
|
|
9
11
|
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InteractionSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const TriggerSchema = zod_1.z.object({
|
|
6
|
+
itemId: zod_1.z.string(),
|
|
7
|
+
type: zod_1.z.enum(['hover-on', 'hover-on-off', 'click']),
|
|
8
|
+
to: zod_1.z.string()
|
|
9
|
+
});
|
|
10
|
+
const StateSchema = zod_1.z.object({
|
|
11
|
+
id: zod_1.z.string()
|
|
12
|
+
});
|
|
13
|
+
exports.InteractionSchema = zod_1.z.object({
|
|
14
|
+
id: zod_1.z.string(),
|
|
15
|
+
triggers: zod_1.z.array(TriggerSchema),
|
|
16
|
+
states: zod_1.z.array(StateSchema)
|
|
17
|
+
});
|
|
@@ -49,13 +49,14 @@ const ImageItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
|
49
49
|
blur: zod_1.z.number()
|
|
50
50
|
})),
|
|
51
51
|
state: zod_1.z.object({
|
|
52
|
-
hover: zod_1.z.record(ItemState_schema_1.
|
|
52
|
+
hover: zod_1.z.record(ItemState_schema_1.MediaStateParamsSchema)
|
|
53
53
|
})
|
|
54
54
|
});
|
|
55
55
|
const VideoItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
56
56
|
type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.Video),
|
|
57
57
|
commonParams: zod_1.z.object({
|
|
58
|
-
url: zod_1.z.string().min(1)
|
|
58
|
+
url: zod_1.z.string().min(1),
|
|
59
|
+
coverUrl: zod_1.z.string().nullable()
|
|
59
60
|
}),
|
|
60
61
|
sticky: zod_1.z.record(zod_1.z.object({
|
|
61
62
|
from: zod_1.z.number(),
|
|
@@ -74,7 +75,7 @@ const VideoItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
|
74
75
|
blur: zod_1.z.number()
|
|
75
76
|
})),
|
|
76
77
|
state: zod_1.z.object({
|
|
77
|
-
hover: zod_1.z.record(ItemState_schema_1.
|
|
78
|
+
hover: zod_1.z.record(ItemState_schema_1.MediaStateParamsSchema)
|
|
78
79
|
})
|
|
79
80
|
});
|
|
80
81
|
const RectangleItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
@@ -96,7 +97,7 @@ const RectangleItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
|
96
97
|
blurMode: zod_1.z.enum(['default', 'backdrop'])
|
|
97
98
|
})),
|
|
98
99
|
state: zod_1.z.object({
|
|
99
|
-
hover: zod_1.z.record(ItemState_schema_1.
|
|
100
|
+
hover: zod_1.z.record(ItemState_schema_1.RectangleStateParamsSchema)
|
|
100
101
|
})
|
|
101
102
|
});
|
|
102
103
|
const CustomItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
@@ -110,7 +111,7 @@ const CustomItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
|
110
111
|
}).nullable()),
|
|
111
112
|
layoutParams: zod_1.z.record(zod_1.z.object({})),
|
|
112
113
|
state: zod_1.z.object({
|
|
113
|
-
hover: zod_1.z.record(ItemState_schema_1.
|
|
114
|
+
hover: zod_1.z.record(ItemState_schema_1.CustomItemStateParamsSchema)
|
|
114
115
|
})
|
|
115
116
|
});
|
|
116
117
|
const VimeoEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
@@ -122,6 +123,7 @@ const VimeoEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
|
122
123
|
muted: zod_1.z.boolean(),
|
|
123
124
|
pictureInPicture: zod_1.z.boolean(),
|
|
124
125
|
url: zod_1.z.string().min(1),
|
|
126
|
+
coverUrl: zod_1.z.string().nullable(),
|
|
125
127
|
ratioLock: zod_1.z.boolean()
|
|
126
128
|
}),
|
|
127
129
|
sticky: zod_1.z.record(zod_1.z.object({
|
|
@@ -134,7 +136,7 @@ const VimeoEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
|
134
136
|
opacity: zod_1.z.number().nonnegative()
|
|
135
137
|
})),
|
|
136
138
|
state: zod_1.z.object({
|
|
137
|
-
hover: zod_1.z.record(ItemState_schema_1.
|
|
139
|
+
hover: zod_1.z.record(ItemState_schema_1.EmbedStateParamsSchema)
|
|
138
140
|
})
|
|
139
141
|
});
|
|
140
142
|
const YoutubeEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
@@ -143,7 +145,8 @@ const YoutubeEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
|
143
145
|
play: zod_1.z.enum(['on-hover', 'on-click', 'auto']),
|
|
144
146
|
controls: zod_1.z.boolean(),
|
|
145
147
|
loop: zod_1.z.boolean(),
|
|
146
|
-
url: zod_1.z.string().min(1)
|
|
148
|
+
url: zod_1.z.string().min(1),
|
|
149
|
+
coverUrl: zod_1.z.string().nullable()
|
|
147
150
|
}),
|
|
148
151
|
sticky: zod_1.z.record(zod_1.z.object({
|
|
149
152
|
from: zod_1.z.number(),
|
|
@@ -155,7 +158,7 @@ const YoutubeEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
|
155
158
|
opacity: zod_1.z.number().nonnegative()
|
|
156
159
|
})),
|
|
157
160
|
state: zod_1.z.object({
|
|
158
|
-
hover: zod_1.z.record(ItemState_schema_1.
|
|
161
|
+
hover: zod_1.z.record(ItemState_schema_1.EmbedStateParamsSchema)
|
|
159
162
|
})
|
|
160
163
|
});
|
|
161
164
|
const CodeEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
@@ -175,7 +178,7 @@ const CodeEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
|
175
178
|
blur: zod_1.z.number()
|
|
176
179
|
})),
|
|
177
180
|
state: zod_1.z.object({
|
|
178
|
-
hover: zod_1.z.record(ItemState_schema_1.
|
|
181
|
+
hover: zod_1.z.record(ItemState_schema_1.CodeEmbedStateParamsSchema)
|
|
179
182
|
})
|
|
180
183
|
});
|
|
181
184
|
exports.ItemSchema = zod_1.z.lazy(() => zod_1.z.discriminatedUnion('type', [
|
|
@@ -199,7 +202,7 @@ exports.ItemSchema = zod_1.z.lazy(() => zod_1.z.discriminatedUnion('type', [
|
|
|
199
202
|
opacity: zod_1.z.number().nonnegative()
|
|
200
203
|
})),
|
|
201
204
|
state: zod_1.z.object({
|
|
202
|
-
hover: zod_1.z.record(ItemState_schema_1.
|
|
205
|
+
hover: zod_1.z.record(ItemState_schema_1.GroupStateParamsSchema)
|
|
203
206
|
})
|
|
204
207
|
})
|
|
205
208
|
]));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ItemStateParamsSchema = exports.CodeEmbedStateParamsSchema = exports.GroupStateParamsSchema = exports.RichTextStateParamsSchema = exports.EmbedStateParamsSchema = exports.CustomItemStateParamsSchema = exports.RectangleStateParamsSchema = exports.MediaStateParamsSchema = exports.ItemStateBaseSchema = exports.getStateParamsSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const
|
|
5
|
+
const getStateParamsSchema = (schema) => {
|
|
6
6
|
return zod_1.z.object({
|
|
7
7
|
timing: zod_1.z.string(),
|
|
8
8
|
duration: zod_1.z.number(),
|
|
@@ -10,52 +10,52 @@ const getHoverParamsSchema = (schema) => {
|
|
|
10
10
|
value: schema
|
|
11
11
|
}).optional();
|
|
12
12
|
};
|
|
13
|
-
exports.
|
|
14
|
-
exports.
|
|
15
|
-
width: (0, exports.
|
|
16
|
-
height: (0, exports.
|
|
17
|
-
angle: (0, exports.
|
|
18
|
-
top: (0, exports.
|
|
19
|
-
left: (0, exports.
|
|
20
|
-
scale: (0, exports.
|
|
21
|
-
blur: (0, exports.
|
|
13
|
+
exports.getStateParamsSchema = getStateParamsSchema;
|
|
14
|
+
exports.ItemStateBaseSchema = zod_1.z.object({
|
|
15
|
+
width: (0, exports.getStateParamsSchema)(zod_1.z.number()),
|
|
16
|
+
height: (0, exports.getStateParamsSchema)(zod_1.z.number()),
|
|
17
|
+
angle: (0, exports.getStateParamsSchema)(zod_1.z.number()),
|
|
18
|
+
top: (0, exports.getStateParamsSchema)(zod_1.z.number()),
|
|
19
|
+
left: (0, exports.getStateParamsSchema)(zod_1.z.number()),
|
|
20
|
+
scale: (0, exports.getStateParamsSchema)(zod_1.z.number()),
|
|
21
|
+
blur: (0, exports.getStateParamsSchema)(zod_1.z.number())
|
|
22
22
|
});
|
|
23
|
-
exports.
|
|
24
|
-
opacity: (0, exports.
|
|
25
|
-
radius: (0, exports.
|
|
26
|
-
strokeWidth: (0, exports.
|
|
27
|
-
strokeColor: (0, exports.
|
|
23
|
+
exports.MediaStateParamsSchema = zod_1.z.object({
|
|
24
|
+
opacity: (0, exports.getStateParamsSchema)(zod_1.z.number()),
|
|
25
|
+
radius: (0, exports.getStateParamsSchema)(zod_1.z.number()),
|
|
26
|
+
strokeWidth: (0, exports.getStateParamsSchema)(zod_1.z.number()),
|
|
27
|
+
strokeColor: (0, exports.getStateParamsSchema)(zod_1.z.string())
|
|
28
28
|
})
|
|
29
|
-
.merge(exports.
|
|
30
|
-
exports.
|
|
31
|
-
strokeWidth: (0, exports.
|
|
32
|
-
radius: (0, exports.
|
|
33
|
-
fillColor: (0, exports.
|
|
34
|
-
strokeColor: (0, exports.
|
|
35
|
-
backdropBlur: (0, exports.
|
|
36
|
-
}).merge(exports.
|
|
37
|
-
exports.
|
|
38
|
-
exports.
|
|
39
|
-
radius: (0, exports.
|
|
40
|
-
opacity: (0, exports.
|
|
41
|
-
}).merge(exports.
|
|
42
|
-
exports.
|
|
43
|
-
color: (0, exports.
|
|
44
|
-
letterSpacing: (0, exports.
|
|
45
|
-
wordSpacing: (0, exports.
|
|
46
|
-
}).merge(exports.
|
|
47
|
-
exports.
|
|
48
|
-
opacity: (0, exports.
|
|
49
|
-
}).merge(exports.
|
|
50
|
-
exports.
|
|
51
|
-
opacity: (0, exports.
|
|
52
|
-
}).merge(exports.
|
|
53
|
-
exports.
|
|
54
|
-
exports.
|
|
55
|
-
exports.
|
|
56
|
-
exports.
|
|
57
|
-
exports.
|
|
58
|
-
exports.
|
|
59
|
-
exports.
|
|
60
|
-
exports.
|
|
29
|
+
.merge(exports.ItemStateBaseSchema);
|
|
30
|
+
exports.RectangleStateParamsSchema = zod_1.z.object({
|
|
31
|
+
strokeWidth: (0, exports.getStateParamsSchema)(zod_1.z.number()),
|
|
32
|
+
radius: (0, exports.getStateParamsSchema)(zod_1.z.number()),
|
|
33
|
+
fillColor: (0, exports.getStateParamsSchema)(zod_1.z.string()),
|
|
34
|
+
strokeColor: (0, exports.getStateParamsSchema)(zod_1.z.string()),
|
|
35
|
+
backdropBlur: (0, exports.getStateParamsSchema)(zod_1.z.number())
|
|
36
|
+
}).merge(exports.ItemStateBaseSchema);
|
|
37
|
+
exports.CustomItemStateParamsSchema = exports.ItemStateBaseSchema;
|
|
38
|
+
exports.EmbedStateParamsSchema = zod_1.z.object({
|
|
39
|
+
radius: (0, exports.getStateParamsSchema)(zod_1.z.number()),
|
|
40
|
+
opacity: (0, exports.getStateParamsSchema)(zod_1.z.number().nonnegative())
|
|
41
|
+
}).merge(exports.ItemStateBaseSchema);
|
|
42
|
+
exports.RichTextStateParamsSchema = zod_1.z.object({
|
|
43
|
+
color: (0, exports.getStateParamsSchema)(zod_1.z.string()),
|
|
44
|
+
letterSpacing: (0, exports.getStateParamsSchema)(zod_1.z.number()),
|
|
45
|
+
wordSpacing: (0, exports.getStateParamsSchema)(zod_1.z.number())
|
|
46
|
+
}).merge(exports.ItemStateBaseSchema);
|
|
47
|
+
exports.GroupStateParamsSchema = zod_1.z.object({
|
|
48
|
+
opacity: (0, exports.getStateParamsSchema)(zod_1.z.number().nonnegative())
|
|
49
|
+
}).merge(exports.ItemStateBaseSchema);
|
|
50
|
+
exports.CodeEmbedStateParamsSchema = zod_1.z.object({
|
|
51
|
+
opacity: (0, exports.getStateParamsSchema)(zod_1.z.number().nonnegative())
|
|
52
|
+
}).merge(exports.ItemStateBaseSchema);
|
|
53
|
+
exports.ItemStateParamsSchema = zod_1.z.union([
|
|
54
|
+
exports.EmbedStateParamsSchema,
|
|
55
|
+
exports.MediaStateParamsSchema,
|
|
56
|
+
exports.RectangleStateParamsSchema,
|
|
57
|
+
exports.RichTextStateParamsSchema,
|
|
58
|
+
exports.CustomItemStateParamsSchema,
|
|
59
|
+
exports.GroupStateParamsSchema,
|
|
60
|
+
exports.CodeEmbedStateParamsSchema
|
|
61
61
|
]);
|
|
@@ -54,6 +54,6 @@ exports.RichTextItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
|
54
54
|
fontVariant: zod_1.z.string()
|
|
55
55
|
})),
|
|
56
56
|
state: zod_1.z.object({
|
|
57
|
-
hover: zod_1.z.record(ItemState_schema_1.
|
|
57
|
+
hover: zod_1.z.record(ItemState_schema_1.RichTextStateParamsSchema)
|
|
58
58
|
})
|
|
59
59
|
});
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export { Client as CntrlClient } from './Client/Client';
|
|
3
3
|
export { FontFaceGenerator } from './FontFaceGenerator/FontFaceGenerator';
|
|
4
4
|
export { getLayoutStyles, getLayoutMediaQuery } from './utils';
|
|
5
|
-
export {ScrollPlaybackVideoManager} from './ScrollPlaybackVideoManager/ScrollPlaybackVideoManager';
|
|
5
|
+
export { ScrollPlaybackVideoManager } from './ScrollPlaybackVideoManager/ScrollPlaybackVideoManager';
|
|
6
6
|
|
|
7
7
|
// enums
|
|
8
8
|
export { SectionHeightMode } from './types/article/Section';
|
|
@@ -21,7 +21,7 @@ export type {
|
|
|
21
21
|
} from './types/article/Item';
|
|
22
22
|
export type { RichTextBlock, RichTextEntity, RichTextStyle } from './types/article/RichText';
|
|
23
23
|
export type { ItemArea } from './types/article/ItemArea';
|
|
24
|
-
export type { ItemState,
|
|
24
|
+
export type { ItemState, ItemStateParams, StateParams, ItemStatesMap } from './types/article/ItemState';
|
|
25
25
|
export type { Layout } from './types/project/Layout';
|
|
26
26
|
export type { Project } from './types/project/Project';
|
|
27
27
|
export type { Meta } from './types/project/Meta';
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { SectionSchema } from './Section.schema';
|
|
3
|
+
import { InteractionSchema } from './Interaction.schema';
|
|
3
4
|
|
|
4
5
|
export const ArticleSchema = z.object({
|
|
5
6
|
id: z.string().min(1),
|
|
6
|
-
sections: z.array(SectionSchema)
|
|
7
|
+
sections: z.array(SectionSchema),
|
|
8
|
+
interactions: z.array(InteractionSchema)
|
|
7
9
|
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z, ZodType } from 'zod';
|
|
2
|
+
import { Interaction, InteractionTrigger } from '../../types/article/Interaction';
|
|
3
|
+
|
|
4
|
+
const TriggerSchema = z.object({
|
|
5
|
+
itemId: z.string(),
|
|
6
|
+
type: z.enum(['hover-on', 'hover-on-off', 'click']),
|
|
7
|
+
to: z.string()
|
|
8
|
+
}) satisfies ZodType<InteractionTrigger>;
|
|
9
|
+
|
|
10
|
+
const StateSchema = z.object({
|
|
11
|
+
id: z.string()
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const InteractionSchema = z.object({
|
|
15
|
+
id: z.string(),
|
|
16
|
+
triggers: z.array(TriggerSchema),
|
|
17
|
+
states: z.array(StateSchema)
|
|
18
|
+
}) satisfies ZodType<Interaction>;
|
|
@@ -10,10 +10,11 @@ import {
|
|
|
10
10
|
YoutubeEmbedItem
|
|
11
11
|
} from '../../types/article/Item';
|
|
12
12
|
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
CodeEmbedStateParamsSchema,
|
|
14
|
+
CustomItemStateParamsSchema,
|
|
15
|
+
EmbedStateParamsSchema, GroupStateParamsSchema,
|
|
16
|
+
MediaStateParamsSchema,
|
|
17
|
+
RectangleStateParamsSchema
|
|
17
18
|
} from './ItemState.schema';
|
|
18
19
|
import { RichTextItemSchema } from './RichTextItem.schema';
|
|
19
20
|
import { ItemBaseSchema } from './ItemBase.schema';
|
|
@@ -68,14 +69,15 @@ const ImageItemSchema = ItemBaseSchema.extend({
|
|
|
68
69
|
})
|
|
69
70
|
),
|
|
70
71
|
state: z.object({
|
|
71
|
-
hover: z.record(
|
|
72
|
+
hover: z.record(MediaStateParamsSchema)
|
|
72
73
|
})
|
|
73
74
|
}) satisfies ZodType<ImageItem>;
|
|
74
75
|
|
|
75
76
|
const VideoItemSchema = ItemBaseSchema.extend({
|
|
76
77
|
type: z.literal(ArticleItemType.Video),
|
|
77
78
|
commonParams: z.object({
|
|
78
|
-
url: z.string().min(1)
|
|
79
|
+
url: z.string().min(1),
|
|
80
|
+
coverUrl: z.string().nullable()
|
|
79
81
|
}),
|
|
80
82
|
sticky: z.record(
|
|
81
83
|
z.object({
|
|
@@ -98,7 +100,7 @@ const VideoItemSchema = ItemBaseSchema.extend({
|
|
|
98
100
|
})
|
|
99
101
|
),
|
|
100
102
|
state: z.object({
|
|
101
|
-
hover: z.record(
|
|
103
|
+
hover: z.record(MediaStateParamsSchema)
|
|
102
104
|
})
|
|
103
105
|
}) satisfies ZodType<VideoItem>;
|
|
104
106
|
|
|
@@ -125,7 +127,7 @@ const RectangleItemSchema = ItemBaseSchema.extend({
|
|
|
125
127
|
})
|
|
126
128
|
),
|
|
127
129
|
state: z.object({
|
|
128
|
-
hover: z.record(
|
|
130
|
+
hover: z.record(RectangleStateParamsSchema)
|
|
129
131
|
})
|
|
130
132
|
}) satisfies ZodType<RectangleItem>;
|
|
131
133
|
|
|
@@ -142,7 +144,7 @@ const CustomItemSchema = ItemBaseSchema.extend({
|
|
|
142
144
|
),
|
|
143
145
|
layoutParams: z.record(z.object({})),
|
|
144
146
|
state: z.object({
|
|
145
|
-
hover: z.record(
|
|
147
|
+
hover: z.record(CustomItemStateParamsSchema)
|
|
146
148
|
})
|
|
147
149
|
}) satisfies ZodType<CustomItem>;
|
|
148
150
|
|
|
@@ -155,6 +157,7 @@ const VimeoEmbedItemSchema = ItemBaseSchema.extend({
|
|
|
155
157
|
muted: z.boolean(),
|
|
156
158
|
pictureInPicture: z.boolean(),
|
|
157
159
|
url: z.string().min(1),
|
|
160
|
+
coverUrl: z.string().nullable(),
|
|
158
161
|
ratioLock: z.boolean()
|
|
159
162
|
}),
|
|
160
163
|
sticky: z.record(
|
|
@@ -171,7 +174,7 @@ const VimeoEmbedItemSchema = ItemBaseSchema.extend({
|
|
|
171
174
|
})
|
|
172
175
|
),
|
|
173
176
|
state: z.object({
|
|
174
|
-
hover: z.record(
|
|
177
|
+
hover: z.record(EmbedStateParamsSchema)
|
|
175
178
|
})
|
|
176
179
|
}) satisfies ZodType<VimeoEmbedItem>;
|
|
177
180
|
|
|
@@ -181,7 +184,8 @@ const YoutubeEmbedItemSchema = ItemBaseSchema.extend({
|
|
|
181
184
|
play: z.enum(['on-hover', 'on-click', 'auto']),
|
|
182
185
|
controls: z.boolean(),
|
|
183
186
|
loop: z.boolean(),
|
|
184
|
-
url: z.string().min(1)
|
|
187
|
+
url: z.string().min(1),
|
|
188
|
+
coverUrl: z.string().nullable()
|
|
185
189
|
}),
|
|
186
190
|
sticky: z.record(
|
|
187
191
|
z.object({
|
|
@@ -197,7 +201,7 @@ const YoutubeEmbedItemSchema = ItemBaseSchema.extend({
|
|
|
197
201
|
})
|
|
198
202
|
),
|
|
199
203
|
state: z.object({
|
|
200
|
-
hover: z.record(
|
|
204
|
+
hover: z.record(EmbedStateParamsSchema)
|
|
201
205
|
})
|
|
202
206
|
}) satisfies ZodType<YoutubeEmbedItem>;
|
|
203
207
|
|
|
@@ -222,7 +226,7 @@ const CodeEmbedItemSchema = ItemBaseSchema.extend({
|
|
|
222
226
|
})
|
|
223
227
|
),
|
|
224
228
|
state: z.object({
|
|
225
|
-
hover: z.record(
|
|
229
|
+
hover: z.record(CodeEmbedStateParamsSchema)
|
|
226
230
|
})
|
|
227
231
|
}) satisfies ZodType<CodeEmbedItem>;
|
|
228
232
|
|
|
@@ -251,7 +255,7 @@ export const ItemSchema: ZodType<ItemAny> = z.lazy(() => z.discriminatedUnion('t
|
|
|
251
255
|
})
|
|
252
256
|
),
|
|
253
257
|
state: z.object({
|
|
254
|
-
hover: z.record(
|
|
258
|
+
hover: z.record(GroupStateParamsSchema)
|
|
255
259
|
})
|
|
256
260
|
})
|
|
257
261
|
]));
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { z, ZodType } from 'zod';
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
CodeEmbedStateParams,
|
|
4
|
+
CustomItemStateParams,
|
|
5
|
+
VideoEmbedStateParams,
|
|
6
|
+
GroupStateParams,
|
|
7
|
+
MediaStateParams,
|
|
8
|
+
RectangleStateParams,
|
|
9
|
+
RichTextStateParams
|
|
7
10
|
} from '../../types/article/ItemState';
|
|
8
11
|
|
|
9
|
-
export const
|
|
12
|
+
export const getStateParamsSchema = <T extends z.ZodTypeAny>(schema: T) => {
|
|
10
13
|
return z.object({
|
|
11
14
|
timing: z.string(),
|
|
12
15
|
duration: z.number(),
|
|
@@ -15,60 +18,60 @@ export const getHoverParamsSchema = <T extends z.ZodTypeAny>(schema: T) => {
|
|
|
15
18
|
}).optional();
|
|
16
19
|
};
|
|
17
20
|
|
|
18
|
-
export const
|
|
19
|
-
width:
|
|
20
|
-
height:
|
|
21
|
-
angle:
|
|
22
|
-
top:
|
|
23
|
-
left:
|
|
24
|
-
scale:
|
|
25
|
-
blur:
|
|
21
|
+
export const ItemStateBaseSchema = z.object({
|
|
22
|
+
width: getStateParamsSchema(z.number()),
|
|
23
|
+
height: getStateParamsSchema(z.number()),
|
|
24
|
+
angle: getStateParamsSchema(z.number()),
|
|
25
|
+
top: getStateParamsSchema(z.number()),
|
|
26
|
+
left: getStateParamsSchema(z.number()),
|
|
27
|
+
scale: getStateParamsSchema(z.number()),
|
|
28
|
+
blur: getStateParamsSchema(z.number())
|
|
26
29
|
});
|
|
27
30
|
|
|
28
|
-
export const
|
|
31
|
+
export const MediaStateParamsSchema =
|
|
29
32
|
z.object({
|
|
30
|
-
opacity:
|
|
31
|
-
radius:
|
|
32
|
-
strokeWidth:
|
|
33
|
-
strokeColor:
|
|
33
|
+
opacity: getStateParamsSchema(z.number()),
|
|
34
|
+
radius: getStateParamsSchema(z.number()),
|
|
35
|
+
strokeWidth: getStateParamsSchema(z.number()),
|
|
36
|
+
strokeColor: getStateParamsSchema(z.string())
|
|
34
37
|
})
|
|
35
|
-
.merge(
|
|
38
|
+
.merge(ItemStateBaseSchema) satisfies ZodType<MediaStateParams>;
|
|
36
39
|
|
|
37
|
-
export const
|
|
38
|
-
strokeWidth:
|
|
39
|
-
radius:
|
|
40
|
-
fillColor:
|
|
41
|
-
strokeColor:
|
|
42
|
-
backdropBlur:
|
|
43
|
-
}).merge(
|
|
40
|
+
export const RectangleStateParamsSchema = z.object({
|
|
41
|
+
strokeWidth: getStateParamsSchema(z.number()),
|
|
42
|
+
radius: getStateParamsSchema(z.number()),
|
|
43
|
+
fillColor: getStateParamsSchema(z.string()),
|
|
44
|
+
strokeColor: getStateParamsSchema(z.string()),
|
|
45
|
+
backdropBlur: getStateParamsSchema(z.number())
|
|
46
|
+
}).merge(ItemStateBaseSchema) satisfies ZodType<RectangleStateParams>;
|
|
44
47
|
|
|
45
|
-
export const
|
|
48
|
+
export const CustomItemStateParamsSchema = ItemStateBaseSchema satisfies ZodType<CustomItemStateParams>;
|
|
46
49
|
|
|
47
|
-
export const
|
|
48
|
-
radius:
|
|
49
|
-
opacity:
|
|
50
|
-
}).merge(
|
|
50
|
+
export const EmbedStateParamsSchema = z.object({
|
|
51
|
+
radius: getStateParamsSchema(z.number()),
|
|
52
|
+
opacity: getStateParamsSchema(z.number().nonnegative())
|
|
53
|
+
}).merge(ItemStateBaseSchema) satisfies ZodType<VideoEmbedStateParams>;
|
|
51
54
|
|
|
52
|
-
export const
|
|
53
|
-
color:
|
|
54
|
-
letterSpacing:
|
|
55
|
-
wordSpacing:
|
|
56
|
-
}).merge(
|
|
55
|
+
export const RichTextStateParamsSchema = z.object({
|
|
56
|
+
color: getStateParamsSchema(z.string()),
|
|
57
|
+
letterSpacing: getStateParamsSchema(z.number()),
|
|
58
|
+
wordSpacing: getStateParamsSchema(z.number())
|
|
59
|
+
}).merge(ItemStateBaseSchema) satisfies ZodType<RichTextStateParams>;
|
|
57
60
|
|
|
58
|
-
export const
|
|
59
|
-
opacity:
|
|
60
|
-
}).merge(
|
|
61
|
+
export const GroupStateParamsSchema = z.object({
|
|
62
|
+
opacity: getStateParamsSchema(z.number().nonnegative())
|
|
63
|
+
}).merge(ItemStateBaseSchema) satisfies ZodType<GroupStateParams>;
|
|
61
64
|
|
|
62
|
-
export const
|
|
63
|
-
opacity:
|
|
64
|
-
}).merge(
|
|
65
|
+
export const CodeEmbedStateParamsSchema = z.object({
|
|
66
|
+
opacity: getStateParamsSchema(z.number().nonnegative())
|
|
67
|
+
}).merge(ItemStateBaseSchema) satisfies ZodType<CodeEmbedStateParams>;
|
|
65
68
|
|
|
66
|
-
export const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
export const ItemStateParamsSchema = z.union([
|
|
70
|
+
EmbedStateParamsSchema,
|
|
71
|
+
MediaStateParamsSchema,
|
|
72
|
+
RectangleStateParamsSchema,
|
|
73
|
+
RichTextStateParamsSchema,
|
|
74
|
+
CustomItemStateParamsSchema,
|
|
75
|
+
GroupStateParamsSchema,
|
|
76
|
+
CodeEmbedStateParamsSchema
|
|
74
77
|
]);
|
|
@@ -2,7 +2,7 @@ import { z, ZodType } from 'zod';
|
|
|
2
2
|
import { RichTextBlock, TextAlign, TextTransform, VerticalAlign } from '../../types/article/RichText';
|
|
3
3
|
import { ItemBaseSchema } from './ItemBase.schema';
|
|
4
4
|
import { ArticleItemType } from '../../types/article/ArticleItemType';
|
|
5
|
-
import {
|
|
5
|
+
import { RichTextStateParamsSchema } from './ItemState.schema';
|
|
6
6
|
import { RichTextItem } from '../../types/article/Item';
|
|
7
7
|
|
|
8
8
|
export const RichTextEntitySchema = z.object({
|
|
@@ -62,6 +62,6 @@ export const RichTextItemSchema = ItemBaseSchema.extend({
|
|
|
62
62
|
})
|
|
63
63
|
),
|
|
64
64
|
state: z.object({
|
|
65
|
-
hover: z.record(
|
|
65
|
+
hover: z.record(RichTextStateParamsSchema)
|
|
66
66
|
})
|
|
67
67
|
}) satisfies ZodType<RichTextItem>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface Interaction {
|
|
2
|
+
id: string;
|
|
3
|
+
triggers: InteractionTrigger[];
|
|
4
|
+
states: InteractionState[];
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface InteractionTrigger {
|
|
8
|
+
itemId: string;
|
|
9
|
+
type: 'hover-on' | 'hover-on-off' | 'click';
|
|
10
|
+
to: StateId;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface InteractionState {
|
|
14
|
+
id: StateId;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type StateId = string;
|
|
@@ -3,6 +3,7 @@ import { ArticleItemType } from './ArticleItemType';
|
|
|
3
3
|
import { AreaAnchor, ItemArea } from './ItemArea';
|
|
4
4
|
import { ItemState } from './ItemState';
|
|
5
5
|
import { FXControlAny, FXCursor } from './FX';
|
|
6
|
+
import { z } from 'zod';
|
|
6
7
|
|
|
7
8
|
export type ItemAny = Item<ArticleItemType>;
|
|
8
9
|
|
|
@@ -47,7 +48,9 @@ interface MediaCommonParams {
|
|
|
47
48
|
url: string;
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
interface VideoCommonParams extends MediaCommonParams {
|
|
51
|
+
interface VideoCommonParams extends MediaCommonParams {
|
|
52
|
+
coverUrl: string | null;
|
|
53
|
+
}
|
|
51
54
|
|
|
52
55
|
interface ImageCommonParams extends MediaCommonParams {
|
|
53
56
|
hasGLEffect?: boolean;
|
|
@@ -84,6 +87,7 @@ interface VimeoEmbedCommonParams {
|
|
|
84
87
|
muted: boolean;
|
|
85
88
|
pictureInPicture: boolean;
|
|
86
89
|
url: string;
|
|
90
|
+
coverUrl: string | null;
|
|
87
91
|
}
|
|
88
92
|
|
|
89
93
|
interface YoutubeEmbedCommonParams {
|
|
@@ -91,6 +95,7 @@ interface YoutubeEmbedCommonParams {
|
|
|
91
95
|
controls: boolean;
|
|
92
96
|
loop: boolean;
|
|
93
97
|
url: string;
|
|
98
|
+
coverUrl: string | null;
|
|
94
99
|
}
|
|
95
100
|
|
|
96
101
|
interface MediaLayoutParams {
|
|
@@ -1,75 +1,73 @@
|
|
|
1
1
|
import { ArticleItemType } from './ArticleItemType';
|
|
2
2
|
|
|
3
|
-
type
|
|
3
|
+
type LayoutId = string;
|
|
4
|
+
type StateId = string;
|
|
4
5
|
|
|
5
|
-
export
|
|
6
|
-
hover: Record<LayoutIdentifier, ItemHoverStatesMap[T]>;
|
|
7
|
-
}
|
|
6
|
+
export type ItemState<T extends ArticleItemType> = Record<StateId, Record<LayoutId, ItemStatesMap[T]>>;
|
|
8
7
|
|
|
9
|
-
export type
|
|
8
|
+
export type ItemStateParams = ItemStatesMap[ArticleItemType];
|
|
10
9
|
|
|
11
|
-
export interface
|
|
12
|
-
[ArticleItemType.Image]:
|
|
13
|
-
[ArticleItemType.Video]:
|
|
14
|
-
[ArticleItemType.RichText]:
|
|
15
|
-
[ArticleItemType.Rectangle]:
|
|
16
|
-
[ArticleItemType.VimeoEmbed]:
|
|
17
|
-
[ArticleItemType.YoutubeEmbed]:
|
|
18
|
-
[ArticleItemType.Custom]:
|
|
19
|
-
[ArticleItemType.Group]:
|
|
20
|
-
[ArticleItemType.CodeEmbed]:
|
|
10
|
+
export interface ItemStatesMap {
|
|
11
|
+
[ArticleItemType.Image]: MediaStateParams;
|
|
12
|
+
[ArticleItemType.Video]: MediaStateParams;
|
|
13
|
+
[ArticleItemType.RichText]: RichTextStateParams;
|
|
14
|
+
[ArticleItemType.Rectangle]: RectangleStateParams;
|
|
15
|
+
[ArticleItemType.VimeoEmbed]: VideoEmbedStateParams;
|
|
16
|
+
[ArticleItemType.YoutubeEmbed]: VideoEmbedStateParams;
|
|
17
|
+
[ArticleItemType.Custom]: CustomItemStateParams;
|
|
18
|
+
[ArticleItemType.Group]: GroupStateParams;
|
|
19
|
+
[ArticleItemType.CodeEmbed]: CodeEmbedStateParams;
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
export interface
|
|
22
|
+
export interface StateParams<T> {
|
|
24
23
|
timing: string;
|
|
25
24
|
duration: number;
|
|
26
25
|
delay: number;
|
|
27
26
|
value: T;
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
interface
|
|
31
|
-
width?:
|
|
32
|
-
height?:
|
|
33
|
-
angle?:
|
|
34
|
-
top?:
|
|
35
|
-
left?:
|
|
36
|
-
scale?:
|
|
37
|
-
blur?:
|
|
29
|
+
interface ItemStatesBaseMap {
|
|
30
|
+
width?: StateParams<number>;
|
|
31
|
+
height?: StateParams<number>;
|
|
32
|
+
angle?: StateParams<number>;
|
|
33
|
+
top?: StateParams<number>;
|
|
34
|
+
left?: StateParams<number>;
|
|
35
|
+
scale?: StateParams<number>;
|
|
36
|
+
blur?: StateParams<number>;
|
|
38
37
|
}
|
|
39
38
|
|
|
40
|
-
export interface
|
|
41
|
-
opacity?:
|
|
42
|
-
radius?:
|
|
43
|
-
strokeWidth?:
|
|
44
|
-
strokeColor?:
|
|
39
|
+
export interface MediaStateParams extends ItemStatesBaseMap {
|
|
40
|
+
opacity?: StateParams<number>;
|
|
41
|
+
radius?: StateParams<number>;
|
|
42
|
+
strokeWidth?: StateParams<number>;
|
|
43
|
+
strokeColor?: StateParams<string>;
|
|
45
44
|
}
|
|
46
45
|
|
|
47
|
-
export interface
|
|
48
|
-
color?:
|
|
49
|
-
letterSpacing?:
|
|
50
|
-
wordSpacing?:
|
|
46
|
+
export interface RichTextStateParams extends ItemStatesBaseMap {
|
|
47
|
+
color?: StateParams<string>;
|
|
48
|
+
letterSpacing?: StateParams<number>;
|
|
49
|
+
wordSpacing?: StateParams<number>;
|
|
51
50
|
}
|
|
52
51
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
backdropBlur?: HoverParams<number>;
|
|
52
|
+
export interface RectangleStateParams extends ItemStatesBaseMap {
|
|
53
|
+
radius?: StateParams<number>;
|
|
54
|
+
strokeWidth?: StateParams<number>;
|
|
55
|
+
fillColor?: StateParams<string>;
|
|
56
|
+
strokeColor?: StateParams<string>;
|
|
57
|
+
backdropBlur?: StateParams<number>;
|
|
60
58
|
}
|
|
61
59
|
|
|
62
|
-
export interface
|
|
63
|
-
radius?:
|
|
64
|
-
opacity?:
|
|
60
|
+
export interface VideoEmbedStateParams extends ItemStatesBaseMap {
|
|
61
|
+
radius?: StateParams<number>;
|
|
62
|
+
opacity?: StateParams<number>;
|
|
65
63
|
}
|
|
66
64
|
|
|
67
|
-
export interface
|
|
65
|
+
export interface CustomItemStateParams extends ItemStatesBaseMap {}
|
|
68
66
|
|
|
69
|
-
export interface
|
|
70
|
-
opacity?:
|
|
67
|
+
export interface GroupStateParams extends ItemStatesBaseMap {
|
|
68
|
+
opacity?: StateParams<number>;
|
|
71
69
|
}
|
|
72
70
|
|
|
73
|
-
export interface
|
|
74
|
-
opacity?:
|
|
71
|
+
export interface CodeEmbedStateParams extends ItemStatesBaseMap {
|
|
72
|
+
opacity?: StateParams<number>;
|
|
75
73
|
}
|
|
Binary file
|