@cntrl-site/sdk 1.4.1 → 1.5.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.
@@ -128,6 +128,21 @@ const YoutubeEmbedItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
128
128
  hover: zod_1.z.record(ItemState_schema_1.EmbedHoverStateParamsSchema)
129
129
  })
130
130
  });
131
+ const GroupItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
132
+ type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.Group),
133
+ commonParams: zod_1.z.object({}),
134
+ itemsIds: zod_1.z.array(zod_1.z.string()),
135
+ sticky: zod_1.z.record(zod_1.z.object({
136
+ from: zod_1.z.number(),
137
+ to: zod_1.z.number().optional()
138
+ }).nullable()),
139
+ layoutParams: zod_1.z.record(zod_1.z.object({
140
+ opacity: zod_1.z.number().nonnegative()
141
+ })),
142
+ state: zod_1.z.object({
143
+ hover: zod_1.z.record(ItemState_schema_1.GroupHoverStateParamsSchema)
144
+ })
145
+ });
131
146
  exports.ItemSchema = zod_1.z.discriminatedUnion('type', [
132
147
  ImageItemSchema,
133
148
  VideoItemSchema,
@@ -135,5 +150,6 @@ exports.ItemSchema = zod_1.z.discriminatedUnion('type', [
135
150
  CustomItemSchema,
136
151
  RichTextItem_schema_1.RichTextItemSchema,
137
152
  VimeoEmbedItemSchema,
138
- YoutubeEmbedItemSchema
153
+ YoutubeEmbedItemSchema,
154
+ GroupItemSchema
139
155
  ]);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ItemHoverStateParamsSchema = exports.RichTextHoverStateParamsSchema = exports.EmbedHoverStateParamsSchema = exports.CustomItemHoverStateParamsSchema = exports.RectangleHoverStateParamsSchema = exports.MediaHoverStateParamsSchema = exports.ItemHoverStateBaseSchema = exports.getHoverParamsSchema = void 0;
3
+ exports.ItemHoverStateParamsSchema = exports.GroupHoverStateParamsSchema = exports.RichTextHoverStateParamsSchema = exports.EmbedHoverStateParamsSchema = exports.CustomItemHoverStateParamsSchema = exports.RectangleHoverStateParamsSchema = exports.MediaHoverStateParamsSchema = exports.ItemHoverStateBaseSchema = exports.getHoverParamsSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const getHoverParamsSchema = (schema) => {
6
6
  return zod_1.z.object({
@@ -43,10 +43,14 @@ exports.RichTextHoverStateParamsSchema = zod_1.z.object({
43
43
  letterSpacing: (0, exports.getHoverParamsSchema)(zod_1.z.number()),
44
44
  wordSpacing: (0, exports.getHoverParamsSchema)(zod_1.z.number())
45
45
  }).merge(exports.ItemHoverStateBaseSchema);
46
+ exports.GroupHoverStateParamsSchema = zod_1.z.object({
47
+ opacity: (0, exports.getHoverParamsSchema)(zod_1.z.number().nonnegative())
48
+ }).merge(exports.ItemHoverStateBaseSchema);
46
49
  exports.ItemHoverStateParamsSchema = zod_1.z.union([
47
50
  exports.EmbedHoverStateParamsSchema,
48
51
  exports.MediaHoverStateParamsSchema,
49
52
  exports.RectangleHoverStateParamsSchema,
50
53
  exports.RichTextHoverStateParamsSchema,
51
- exports.CustomItemHoverStateParamsSchema
54
+ exports.CustomItemHoverStateParamsSchema,
55
+ exports.GroupHoverStateParamsSchema
52
56
  ]);
@@ -10,4 +10,5 @@ var ArticleItemType;
10
10
  ArticleItemType["VimeoEmbed"] = "vimeo-embed";
11
11
  ArticleItemType["YoutubeEmbed"] = "youtube-embed";
12
12
  ArticleItemType["Custom"] = "custom";
13
+ ArticleItemType["Group"] = "group";
13
14
  })(ArticleItemType = exports.ArticleItemType || (exports.ArticleItemType = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk",
3
- "version": "1.4.1",
3
+ "version": "1.5.1",
4
4
  "description": "Generic SDK for use in public websites.",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/index.ts",
@@ -1,6 +1,6 @@
1
1
  import { z, ZodType } from 'zod';
2
2
  import {
3
- CustomItem,
3
+ CustomItem, GroupItem,
4
4
  ImageItem,
5
5
  RectangleItem,
6
6
  VideoItem,
@@ -9,7 +9,7 @@ import {
9
9
  } from '../../types/article/Item';
10
10
  import {
11
11
  CustomItemHoverStateParamsSchema,
12
- EmbedHoverStateParamsSchema, MediaHoverStateParamsSchema,
12
+ EmbedHoverStateParamsSchema, GroupHoverStateParamsSchema, MediaHoverStateParamsSchema,
13
13
  RectangleHoverStateParamsSchema
14
14
  } from './ItemState.schema';
15
15
  import { RichTextItemSchema } from './RichTextItem.schema';
@@ -166,6 +166,26 @@ const YoutubeEmbedItemSchema = ItemBaseSchema.extend({
166
166
  })
167
167
  }) satisfies ZodType<YoutubeEmbedItem>;
168
168
 
169
+ const GroupItemSchema = ItemBaseSchema.extend({
170
+ type: z.literal(ArticleItemType.Group),
171
+ commonParams: z.object({}),
172
+ itemsIds: z.array(z.string()),
173
+ sticky: z.record(
174
+ z.object({
175
+ from: z.number(),
176
+ to: z.number().optional()
177
+ }).nullable(),
178
+ ),
179
+ layoutParams: z.record(
180
+ z.object({
181
+ opacity: z.number().nonnegative()
182
+ })
183
+ ),
184
+ state: z.object({
185
+ hover: z.record(GroupHoverStateParamsSchema)
186
+ })
187
+ }) satisfies ZodType<GroupItem>;
188
+
169
189
  export const ItemSchema = z.discriminatedUnion('type', [
170
190
  ImageItemSchema,
171
191
  VideoItemSchema,
@@ -173,5 +193,6 @@ export const ItemSchema = z.discriminatedUnion('type', [
173
193
  CustomItemSchema,
174
194
  RichTextItemSchema,
175
195
  VimeoEmbedItemSchema,
176
- YoutubeEmbedItemSchema
196
+ YoutubeEmbedItemSchema,
197
+ GroupItemSchema
177
198
  ]);
@@ -1,6 +1,6 @@
1
1
  import { z, ZodType } from 'zod';
2
2
  import {
3
- CustomHoverStateParams, EmbedHoverStateParams,
3
+ CustomHoverStateParams, EmbedHoverStateParams, GroupHoverStateParams,
4
4
  MediaHoverStateParams,
5
5
  RectangleHoverStateParams, RichTextHoverStateParams
6
6
  } from '../../types/article/ItemState';
@@ -53,10 +53,15 @@ export const RichTextHoverStateParamsSchema = z.object({
53
53
  wordSpacing: getHoverParamsSchema(z.number())
54
54
  }).merge(ItemHoverStateBaseSchema) satisfies ZodType<RichTextHoverStateParams>;
55
55
 
56
+ export const GroupHoverStateParamsSchema = z.object({
57
+ opacity: getHoverParamsSchema(z.number().nonnegative())
58
+ }).merge(ItemHoverStateBaseSchema) satisfies ZodType<GroupHoverStateParams>;
59
+
56
60
  export const ItemHoverStateParamsSchema = z.union([
57
61
  EmbedHoverStateParamsSchema,
58
62
  MediaHoverStateParamsSchema,
59
63
  RectangleHoverStateParamsSchema,
60
64
  RichTextHoverStateParamsSchema,
61
- CustomItemHoverStateParamsSchema
65
+ CustomItemHoverStateParamsSchema,
66
+ GroupHoverStateParamsSchema
62
67
  ]);
@@ -5,5 +5,6 @@ export enum ArticleItemType {
5
5
  Rectangle = 'rectangle',
6
6
  VimeoEmbed = 'vimeo-embed',
7
7
  YoutubeEmbed = 'youtube-embed',
8
- Custom = 'custom'
8
+ Custom = 'custom',
9
+ Group = 'group'
9
10
  }
@@ -11,6 +11,7 @@ export interface Item<T extends ArticleItemType> {
11
11
  area: Record<LayoutIdentifier, ItemArea>;
12
12
  hidden: Record<LayoutIdentifier, boolean>;
13
13
  link?: Link;
14
+ items?: T extends ArticleItemType.Group ? ItemAny[] : never;
14
15
  sticky: Record<LayoutIdentifier, StickyParams | null>;
15
16
  commonParams: ItemCommonParamsMap[T];
16
17
  state: ItemState<T>;
@@ -25,6 +26,7 @@ export interface ItemCommonParamsMap {
25
26
  [ArticleItemType.VimeoEmbed]: VimeoEmbedCommonParams;
26
27
  [ArticleItemType.YoutubeEmbed]: YoutubeEmbedCommonParams;
27
28
  [ArticleItemType.Custom]: CustomCommonParams;
29
+ [ArticleItemType.Group]: GroupCommonParams;
28
30
  }
29
31
 
30
32
  export interface ItemLayoutParamsMap {
@@ -35,6 +37,7 @@ export interface ItemLayoutParamsMap {
35
37
  [ArticleItemType.VimeoEmbed]: VimeoEmbedLayoutParams;
36
38
  [ArticleItemType.YoutubeEmbed]: YoutubeEmbedLayoutParams;
37
39
  [ArticleItemType.Custom]: CustomLayoutParams;
40
+ [ArticleItemType.Group]: GroupLayoutParams;
38
41
  }
39
42
 
40
43
  interface MediaCommonParams {
@@ -61,6 +64,8 @@ interface CustomCommonParams {
61
64
  name: string;
62
65
  }
63
66
 
67
+ interface GroupCommonParams {}
68
+
64
69
  interface VimeoEmbedCommonParams {
65
70
  play: 'on-hover' | 'on-click' | 'auto';
66
71
  controls: boolean;
@@ -87,6 +92,10 @@ interface MediaLayoutParams {
87
92
 
88
93
  interface CustomLayoutParams {}
89
94
 
95
+ interface GroupLayoutParams {
96
+ opacity: number;
97
+ }
98
+
90
99
  interface VimeoEmbedLayoutParams {
91
100
  radius: number;
92
101
  blur: number;
@@ -151,3 +160,4 @@ export type RichTextItem = Item<ArticleItemType.RichText>;
151
160
  export type VimeoEmbedItem = Item<ArticleItemType.VimeoEmbed>;
152
161
  export type YoutubeEmbedItem = Item<ArticleItemType.YoutubeEmbed>;
153
162
  export type CustomItem = Item<ArticleItemType.Custom>;
163
+ export type GroupItem = Item<ArticleItemType.Group>;
@@ -16,6 +16,7 @@ export interface ItemHoverStatesMap {
16
16
  [ArticleItemType.VimeoEmbed]: EmbedHoverStateParams;
17
17
  [ArticleItemType.YoutubeEmbed]: EmbedHoverStateParams;
18
18
  [ArticleItemType.Custom]: CustomHoverStateParams;
19
+ [ArticleItemType.Group]: GroupHoverStateParams;
19
20
  }
20
21
 
21
22
  export interface HoverParams<T> {
@@ -62,3 +63,7 @@ export interface EmbedHoverStateParams extends ItemHoversBaseMap {
62
63
  }
63
64
 
64
65
  export interface CustomHoverStateParams extends ItemHoversBaseMap {}
66
+
67
+ export interface GroupHoverStateParams extends ItemHoversBaseMap {
68
+ opacity?: HoverParams<number>;
69
+ }