@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.
@@ -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.MediaHoverStateParamsSchema)
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.MediaHoverStateParamsSchema)
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.RectangleHoverStateParamsSchema)
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.CustomItemHoverStateParamsSchema)
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.EmbedHoverStateParamsSchema)
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.EmbedHoverStateParamsSchema)
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.CodeEmbedHoverStateParamsSchema)
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.GroupHoverStateParamsSchema)
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.ItemHoverStateParamsSchema = exports.CodeEmbedHoverStateParamsSchema = exports.GroupHoverStateParamsSchema = exports.RichTextHoverStateParamsSchema = exports.EmbedHoverStateParamsSchema = exports.CustomItemHoverStateParamsSchema = exports.RectangleHoverStateParamsSchema = exports.MediaHoverStateParamsSchema = exports.ItemHoverStateBaseSchema = exports.getHoverParamsSchema = void 0;
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 getHoverParamsSchema = (schema) => {
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.getHoverParamsSchema = getHoverParamsSchema;
14
- exports.ItemHoverStateBaseSchema = zod_1.z.object({
15
- width: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
16
- height: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
17
- angle: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
18
- top: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
19
- left: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
20
- scale: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
21
- blur: (0, exports.getHoverParamsSchema)(zod_1.z.number())
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.MediaHoverStateParamsSchema = zod_1.z.object({
24
- opacity: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
25
- radius: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
26
- strokeWidth: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
27
- strokeColor: (0, exports.getHoverParamsSchema)(zod_1.z.string())
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.ItemHoverStateBaseSchema);
30
- exports.RectangleHoverStateParamsSchema = zod_1.z.object({
31
- strokeWidth: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
32
- radius: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
33
- fillColor: (0, exports.getHoverParamsSchema)(zod_1.z.string()),
34
- strokeColor: (0, exports.getHoverParamsSchema)(zod_1.z.string()),
35
- backdropBlur: (0, exports.getHoverParamsSchema)(zod_1.z.number())
36
- }).merge(exports.ItemHoverStateBaseSchema);
37
- exports.CustomItemHoverStateParamsSchema = exports.ItemHoverStateBaseSchema;
38
- exports.EmbedHoverStateParamsSchema = zod_1.z.object({
39
- radius: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
40
- opacity: (0, exports.getHoverParamsSchema)(zod_1.z.number().nonnegative())
41
- }).merge(exports.ItemHoverStateBaseSchema);
42
- exports.RichTextHoverStateParamsSchema = zod_1.z.object({
43
- color: (0, exports.getHoverParamsSchema)(zod_1.z.string()),
44
- letterSpacing: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
45
- wordSpacing: (0, exports.getHoverParamsSchema)(zod_1.z.number())
46
- }).merge(exports.ItemHoverStateBaseSchema);
47
- exports.GroupHoverStateParamsSchema = zod_1.z.object({
48
- opacity: (0, exports.getHoverParamsSchema)(zod_1.z.number().nonnegative())
49
- }).merge(exports.ItemHoverStateBaseSchema);
50
- exports.CodeEmbedHoverStateParamsSchema = zod_1.z.object({
51
- opacity: (0, exports.getHoverParamsSchema)(zod_1.z.number().nonnegative())
52
- }).merge(exports.ItemHoverStateBaseSchema);
53
- exports.ItemHoverStateParamsSchema = zod_1.z.union([
54
- exports.EmbedHoverStateParamsSchema,
55
- exports.MediaHoverStateParamsSchema,
56
- exports.RectangleHoverStateParamsSchema,
57
- exports.RichTextHoverStateParamsSchema,
58
- exports.CustomItemHoverStateParamsSchema,
59
- exports.GroupHoverStateParamsSchema,
60
- exports.CodeEmbedHoverStateParamsSchema
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.RichTextHoverStateParamsSchema)
57
+ hover: zod_1.z.record(ItemState_schema_1.RichTextStateParamsSchema)
58
58
  })
59
59
  });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk",
3
- "version": "1.12.2",
3
+ "version": "1.12.4-alpha.0",
4
4
  "description": "Generic SDK for use in public websites.",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/index.ts",
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, ItemHoverState, HoverParams } from './types/article/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
- CodeEmbedHoverStateParamsSchema,
14
- CustomItemHoverStateParamsSchema,
15
- EmbedHoverStateParamsSchema, GroupHoverStateParamsSchema, MediaHoverStateParamsSchema,
16
- RectangleHoverStateParamsSchema
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(MediaHoverStateParamsSchema)
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(MediaHoverStateParamsSchema)
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(RectangleHoverStateParamsSchema)
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(CustomItemHoverStateParamsSchema)
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(EmbedHoverStateParamsSchema)
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(EmbedHoverStateParamsSchema)
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(CodeEmbedHoverStateParamsSchema)
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(GroupHoverStateParamsSchema)
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
- CodeEmbedHoverStateParams,
4
- CustomHoverStateParams, EmbedHoverStateParams, GroupHoverStateParams,
5
- MediaHoverStateParams,
6
- RectangleHoverStateParams, RichTextHoverStateParams
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 getHoverParamsSchema = <T extends z.ZodTypeAny>(schema: T) => {
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 ItemHoverStateBaseSchema = z.object({
19
- width: getHoverParamsSchema(z.number()),
20
- height: getHoverParamsSchema(z.number()),
21
- angle: getHoverParamsSchema(z.number()),
22
- top: getHoverParamsSchema(z.number()),
23
- left: getHoverParamsSchema(z.number()),
24
- scale: getHoverParamsSchema(z.number()),
25
- blur: getHoverParamsSchema(z.number())
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 MediaHoverStateParamsSchema =
31
+ export const MediaStateParamsSchema =
29
32
  z.object({
30
- opacity: getHoverParamsSchema(z.number()),
31
- radius: getHoverParamsSchema(z.number()),
32
- strokeWidth: getHoverParamsSchema(z.number()),
33
- strokeColor: getHoverParamsSchema(z.string())
33
+ opacity: getStateParamsSchema(z.number()),
34
+ radius: getStateParamsSchema(z.number()),
35
+ strokeWidth: getStateParamsSchema(z.number()),
36
+ strokeColor: getStateParamsSchema(z.string())
34
37
  })
35
- .merge(ItemHoverStateBaseSchema) satisfies ZodType<MediaHoverStateParams>;
38
+ .merge(ItemStateBaseSchema) satisfies ZodType<MediaStateParams>;
36
39
 
37
- export const RectangleHoverStateParamsSchema = z.object({
38
- strokeWidth: getHoverParamsSchema(z.number()),
39
- radius: getHoverParamsSchema(z.number()),
40
- fillColor: getHoverParamsSchema(z.string()),
41
- strokeColor: getHoverParamsSchema(z.string()),
42
- backdropBlur: getHoverParamsSchema(z.number())
43
- }).merge(ItemHoverStateBaseSchema) satisfies ZodType<RectangleHoverStateParams>;
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 CustomItemHoverStateParamsSchema = ItemHoverStateBaseSchema satisfies ZodType<CustomHoverStateParams>;
48
+ export const CustomItemStateParamsSchema = ItemStateBaseSchema satisfies ZodType<CustomItemStateParams>;
46
49
 
47
- export const EmbedHoverStateParamsSchema = z.object({
48
- radius: getHoverParamsSchema(z.number()),
49
- opacity: getHoverParamsSchema(z.number().nonnegative())
50
- }).merge(ItemHoverStateBaseSchema) satisfies ZodType<EmbedHoverStateParams>;
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 RichTextHoverStateParamsSchema = z.object({
53
- color: getHoverParamsSchema(z.string()),
54
- letterSpacing: getHoverParamsSchema(z.number()),
55
- wordSpacing: getHoverParamsSchema(z.number())
56
- }).merge(ItemHoverStateBaseSchema) satisfies ZodType<RichTextHoverStateParams>;
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 GroupHoverStateParamsSchema = z.object({
59
- opacity: getHoverParamsSchema(z.number().nonnegative())
60
- }).merge(ItemHoverStateBaseSchema) satisfies ZodType<GroupHoverStateParams>;
61
+ export const GroupStateParamsSchema = z.object({
62
+ opacity: getStateParamsSchema(z.number().nonnegative())
63
+ }).merge(ItemStateBaseSchema) satisfies ZodType<GroupStateParams>;
61
64
 
62
- export const CodeEmbedHoverStateParamsSchema = z.object({
63
- opacity: getHoverParamsSchema(z.number().nonnegative())
64
- }).merge(ItemHoverStateBaseSchema) satisfies ZodType<CodeEmbedHoverStateParams>;
65
+ export const CodeEmbedStateParamsSchema = z.object({
66
+ opacity: getStateParamsSchema(z.number().nonnegative())
67
+ }).merge(ItemStateBaseSchema) satisfies ZodType<CodeEmbedStateParams>;
65
68
 
66
- export const ItemHoverStateParamsSchema = z.union([
67
- EmbedHoverStateParamsSchema,
68
- MediaHoverStateParamsSchema,
69
- RectangleHoverStateParamsSchema,
70
- RichTextHoverStateParamsSchema,
71
- CustomItemHoverStateParamsSchema,
72
- GroupHoverStateParamsSchema,
73
- CodeEmbedHoverStateParamsSchema
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 { RichTextHoverStateParamsSchema } from './ItemState.schema';
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(RichTextHoverStateParamsSchema)
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 LayoutIdentifier = string;
3
+ type LayoutId = string;
4
+ type StateId = string;
4
5
 
5
- export interface ItemState<T extends ArticleItemType> {
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 ItemHoverState = ItemHoverStatesMap[ArticleItemType];
8
+ export type ItemStateParams = ItemStatesMap[ArticleItemType];
10
9
 
11
- export interface ItemHoverStatesMap {
12
- [ArticleItemType.Image]: MediaHoverStateParams;
13
- [ArticleItemType.Video]: MediaHoverStateParams;
14
- [ArticleItemType.RichText]: RichTextHoverStateParams;
15
- [ArticleItemType.Rectangle]: RectangleHoverStateParams;
16
- [ArticleItemType.VimeoEmbed]: EmbedHoverStateParams;
17
- [ArticleItemType.YoutubeEmbed]: EmbedHoverStateParams;
18
- [ArticleItemType.Custom]: CustomHoverStateParams;
19
- [ArticleItemType.Group]: GroupHoverStateParams;
20
- [ArticleItemType.CodeEmbed]: CodeEmbedHoverStateParams;
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 HoverParams<T> {
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 ItemHoversBaseMap {
31
- width?: HoverParams<number>;
32
- height?: HoverParams<number>;
33
- angle?: HoverParams<number>;
34
- top?: HoverParams<number>;
35
- left?: HoverParams<number>;
36
- scale?: HoverParams<number>;
37
- blur?: HoverParams<number>;
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 MediaHoverStateParams extends ItemHoversBaseMap {
41
- opacity?: HoverParams<number>;
42
- radius?: HoverParams<number>;
43
- strokeWidth?: HoverParams<number>;
44
- strokeColor?: HoverParams<string>;
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 RichTextHoverStateParams extends ItemHoversBaseMap {
48
- color?: HoverParams<string>;
49
- letterSpacing?: HoverParams<number>;
50
- wordSpacing?: HoverParams<number>;
46
+ export interface RichTextStateParams extends ItemStatesBaseMap {
47
+ color?: StateParams<string>;
48
+ letterSpacing?: StateParams<number>;
49
+ wordSpacing?: StateParams<number>;
51
50
  }
52
51
 
53
-
54
- export interface RectangleHoverStateParams extends ItemHoversBaseMap {
55
- radius?: HoverParams<number>;
56
- strokeWidth?: HoverParams<number>;
57
- fillColor?: HoverParams<string>;
58
- strokeColor?: HoverParams<string>;
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 EmbedHoverStateParams extends ItemHoversBaseMap {
63
- radius?: HoverParams<number>;
64
- opacity?: HoverParams<number>;
60
+ export interface VideoEmbedStateParams extends ItemStatesBaseMap {
61
+ radius?: StateParams<number>;
62
+ opacity?: StateParams<number>;
65
63
  }
66
64
 
67
- export interface CustomHoverStateParams extends ItemHoversBaseMap {}
65
+ export interface CustomItemStateParams extends ItemStatesBaseMap {}
68
66
 
69
- export interface GroupHoverStateParams extends ItemHoversBaseMap {
70
- opacity?: HoverParams<number>;
67
+ export interface GroupStateParams extends ItemStatesBaseMap {
68
+ opacity?: StateParams<number>;
71
69
  }
72
70
 
73
- export interface CodeEmbedHoverStateParams extends ItemHoversBaseMap {
74
- opacity?: HoverParams<number>;
71
+ export interface CodeEmbedStateParams extends ItemStatesBaseMap {
72
+ opacity?: StateParams<number>;
75
73
  }
Binary file