@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.
@@ -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.MediaHoverStateParamsSchema)
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.MediaHoverStateParamsSchema)
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.RectangleHoverStateParamsSchema)
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.CustomItemHoverStateParamsSchema)
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.EmbedHoverStateParamsSchema)
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.EmbedHoverStateParamsSchema)
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.CodeEmbedHoverStateParamsSchema)
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.GroupHoverStateParamsSchema)
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.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.3",
3
+ "version": "1.12.4-alpha.1",
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,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, ItemHoverState, HoverParams } from './types/article/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
- 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,7 +69,7 @@ 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
 
@@ -99,7 +100,7 @@ const VideoItemSchema = ItemBaseSchema.extend({
99
100
  })
100
101
  ),
101
102
  state: z.object({
102
- hover: z.record(MediaHoverStateParamsSchema)
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(RectangleHoverStateParamsSchema)
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(CustomItemHoverStateParamsSchema)
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(EmbedHoverStateParamsSchema)
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(EmbedHoverStateParamsSchema)
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(CodeEmbedHoverStateParamsSchema)
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(GroupHoverStateParamsSchema)
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
- 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,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 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
  }