@cntrl-site/sdk 1.12.3 → 1.12.4-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/schemas/article/Article.schema.js +3 -1
- package/lib/schemas/article/Interaction.schema.js +18 -0
- package/lib/schemas/article/Item.schema.js +8 -8
- 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 +3 -2
- package/src/schemas/article/Article.schema.ts +3 -1
- package/src/schemas/article/Interaction.schema.ts +19 -0
- package/src/schemas/article/Item.schema.ts +13 -12
- package/src/schemas/article/ItemState.schema.ts +53 -50
- package/src/schemas/article/RichTextItem.schema.ts +2 -2
- package/src/types/article/Interaction.ts +18 -0
- package/src/types/article/ItemState.ts +46 -48
|
@@ -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,18 @@
|
|
|
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
|
+
from: zod_1.z.string(),
|
|
9
|
+
to: zod_1.z.string()
|
|
10
|
+
});
|
|
11
|
+
const StateSchema = zod_1.z.object({
|
|
12
|
+
id: zod_1.z.string()
|
|
13
|
+
});
|
|
14
|
+
exports.InteractionSchema = zod_1.z.object({
|
|
15
|
+
id: zod_1.z.string(),
|
|
16
|
+
triggers: zod_1.z.array(TriggerSchema),
|
|
17
|
+
states: zod_1.z.array(StateSchema)
|
|
18
|
+
});
|
|
@@ -49,7 +49,7 @@ 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({
|
|
@@ -75,7 +75,7 @@ const VideoItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
|
75
75
|
blur: zod_1.z.number()
|
|
76
76
|
})),
|
|
77
77
|
state: zod_1.z.object({
|
|
78
|
-
hover: zod_1.z.record(ItemState_schema_1.
|
|
78
|
+
hover: zod_1.z.record(ItemState_schema_1.MediaStateParamsSchema)
|
|
79
79
|
})
|
|
80
80
|
});
|
|
81
81
|
const RectangleItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
@@ -97,7 +97,7 @@ const RectangleItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
|
97
97
|
blurMode: zod_1.z.enum(['default', 'backdrop'])
|
|
98
98
|
})),
|
|
99
99
|
state: zod_1.z.object({
|
|
100
|
-
hover: zod_1.z.record(ItemState_schema_1.
|
|
100
|
+
hover: zod_1.z.record(ItemState_schema_1.RectangleStateParamsSchema)
|
|
101
101
|
})
|
|
102
102
|
});
|
|
103
103
|
const CustomItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
@@ -111,7 +111,7 @@ const CustomItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
|
111
111
|
}).nullable()),
|
|
112
112
|
layoutParams: zod_1.z.record(zod_1.z.object({})),
|
|
113
113
|
state: zod_1.z.object({
|
|
114
|
-
hover: zod_1.z.record(ItemState_schema_1.
|
|
114
|
+
hover: zod_1.z.record(ItemState_schema_1.CustomItemStateParamsSchema)
|
|
115
115
|
})
|
|
116
116
|
});
|
|
117
117
|
const VimeoEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
@@ -136,7 +136,7 @@ const VimeoEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
|
136
136
|
opacity: zod_1.z.number().nonnegative()
|
|
137
137
|
})),
|
|
138
138
|
state: zod_1.z.object({
|
|
139
|
-
hover: zod_1.z.record(ItemState_schema_1.
|
|
139
|
+
hover: zod_1.z.record(ItemState_schema_1.EmbedStateParamsSchema)
|
|
140
140
|
})
|
|
141
141
|
});
|
|
142
142
|
const YoutubeEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
@@ -158,7 +158,7 @@ const YoutubeEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
|
158
158
|
opacity: zod_1.z.number().nonnegative()
|
|
159
159
|
})),
|
|
160
160
|
state: zod_1.z.object({
|
|
161
|
-
hover: zod_1.z.record(ItemState_schema_1.
|
|
161
|
+
hover: zod_1.z.record(ItemState_schema_1.EmbedStateParamsSchema)
|
|
162
162
|
})
|
|
163
163
|
});
|
|
164
164
|
const CodeEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
@@ -178,7 +178,7 @@ const CodeEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
|
178
178
|
blur: zod_1.z.number()
|
|
179
179
|
})),
|
|
180
180
|
state: zod_1.z.object({
|
|
181
|
-
hover: zod_1.z.record(ItemState_schema_1.
|
|
181
|
+
hover: zod_1.z.record(ItemState_schema_1.CodeEmbedStateParamsSchema)
|
|
182
182
|
})
|
|
183
183
|
});
|
|
184
184
|
exports.ItemSchema = zod_1.z.lazy(() => zod_1.z.discriminatedUnion('type', [
|
|
@@ -202,7 +202,7 @@ exports.ItemSchema = zod_1.z.lazy(() => zod_1.z.discriminatedUnion('type', [
|
|
|
202
202
|
opacity: zod_1.z.number().nonnegative()
|
|
203
203
|
})),
|
|
204
204
|
state: zod_1.z.object({
|
|
205
|
-
hover: zod_1.z.record(ItemState_schema_1.
|
|
205
|
+
hover: zod_1.z.record(ItemState_schema_1.GroupStateParamsSchema)
|
|
206
206
|
})
|
|
207
207
|
})
|
|
208
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,8 @@ 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
|
+
export type { Interaction, InteractionTrigger, InteractionState } from './types/article/Interaction';
|
|
25
26
|
export type { Layout } from './types/project/Layout';
|
|
26
27
|
export type { Project } from './types/project/Project';
|
|
27
28
|
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,19 @@
|
|
|
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
|
+
from: z.string(),
|
|
8
|
+
to: z.string()
|
|
9
|
+
}) satisfies ZodType<InteractionTrigger>;
|
|
10
|
+
|
|
11
|
+
const StateSchema = z.object({
|
|
12
|
+
id: z.string()
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const InteractionSchema = z.object({
|
|
16
|
+
id: z.string(),
|
|
17
|
+
triggers: z.array(TriggerSchema),
|
|
18
|
+
states: z.array(StateSchema)
|
|
19
|
+
}) 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,7 +69,7 @@ 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
|
|
|
@@ -99,7 +100,7 @@ const VideoItemSchema = ItemBaseSchema.extend({
|
|
|
99
100
|
})
|
|
100
101
|
),
|
|
101
102
|
state: z.object({
|
|
102
|
-
hover: z.record(
|
|
103
|
+
hover: z.record(MediaStateParamsSchema)
|
|
103
104
|
})
|
|
104
105
|
}) satisfies ZodType<VideoItem>;
|
|
105
106
|
|
|
@@ -126,7 +127,7 @@ const RectangleItemSchema = ItemBaseSchema.extend({
|
|
|
126
127
|
})
|
|
127
128
|
),
|
|
128
129
|
state: z.object({
|
|
129
|
-
hover: z.record(
|
|
130
|
+
hover: z.record(RectangleStateParamsSchema)
|
|
130
131
|
})
|
|
131
132
|
}) satisfies ZodType<RectangleItem>;
|
|
132
133
|
|
|
@@ -143,7 +144,7 @@ const CustomItemSchema = ItemBaseSchema.extend({
|
|
|
143
144
|
),
|
|
144
145
|
layoutParams: z.record(z.object({})),
|
|
145
146
|
state: z.object({
|
|
146
|
-
hover: z.record(
|
|
147
|
+
hover: z.record(CustomItemStateParamsSchema)
|
|
147
148
|
})
|
|
148
149
|
}) satisfies ZodType<CustomItem>;
|
|
149
150
|
|
|
@@ -173,7 +174,7 @@ const VimeoEmbedItemSchema = ItemBaseSchema.extend({
|
|
|
173
174
|
})
|
|
174
175
|
),
|
|
175
176
|
state: z.object({
|
|
176
|
-
hover: z.record(
|
|
177
|
+
hover: z.record(EmbedStateParamsSchema)
|
|
177
178
|
})
|
|
178
179
|
}) satisfies ZodType<VimeoEmbedItem>;
|
|
179
180
|
|
|
@@ -200,7 +201,7 @@ const YoutubeEmbedItemSchema = ItemBaseSchema.extend({
|
|
|
200
201
|
})
|
|
201
202
|
),
|
|
202
203
|
state: z.object({
|
|
203
|
-
hover: z.record(
|
|
204
|
+
hover: z.record(EmbedStateParamsSchema)
|
|
204
205
|
})
|
|
205
206
|
}) satisfies ZodType<YoutubeEmbedItem>;
|
|
206
207
|
|
|
@@ -225,7 +226,7 @@ const CodeEmbedItemSchema = ItemBaseSchema.extend({
|
|
|
225
226
|
})
|
|
226
227
|
),
|
|
227
228
|
state: z.object({
|
|
228
|
-
hover: z.record(
|
|
229
|
+
hover: z.record(CodeEmbedStateParamsSchema)
|
|
229
230
|
})
|
|
230
231
|
}) satisfies ZodType<CodeEmbedItem>;
|
|
231
232
|
|
|
@@ -254,7 +255,7 @@ export const ItemSchema: ZodType<ItemAny> = z.lazy(() => z.discriminatedUnion('t
|
|
|
254
255
|
})
|
|
255
256
|
),
|
|
256
257
|
state: z.object({
|
|
257
|
-
hover: z.record(
|
|
258
|
+
hover: z.record(GroupStateParamsSchema)
|
|
258
259
|
})
|
|
259
260
|
})
|
|
260
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,18 @@
|
|
|
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
|
+
from: StateId;
|
|
11
|
+
to: StateId;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface InteractionState {
|
|
15
|
+
id: StateId;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type StateId = string;
|
|
@@ -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
|
}
|