@cntrl-site/sdk 1.13.0 → 1.14.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.
Binary file
@@ -188,5 +188,20 @@ exports.ItemSchema = zod_1.z.lazy(() => zod_1.z.discriminatedUnion('type', [
188
188
  opacity: zod_1.z.number().nonnegative()
189
189
  })),
190
190
  state: zod_1.z.record(zod_1.z.record(ItemState_schema_1.GroupStateParamsSchema))
191
+ }),
192
+ ItemBase_schema_1.ItemBaseSchema.extend({
193
+ type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.Compound),
194
+ commonParams: zod_1.z.object({
195
+ overflow: zod_1.z.enum(['hidden', 'visible']),
196
+ }),
197
+ items: zod_1.z.array(exports.ItemSchema),
198
+ sticky: zod_1.z.record(zod_1.z.object({
199
+ from: zod_1.z.number(),
200
+ to: zod_1.z.number().optional()
201
+ }).nullable()),
202
+ layoutParams: zod_1.z.record(zod_1.z.object({
203
+ opacity: zod_1.z.number().nonnegative()
204
+ })),
205
+ state: zod_1.z.record(zod_1.z.record(ItemState_schema_1.CompoundStateParamsSchema))
191
206
  })
192
207
  ]));
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ItemBaseSchema = exports.Link = void 0;
3
+ exports.ItemBaseSchema = exports.CompoundSettingsSchema = exports.Link = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const ItemArea_schema_1 = require("./ItemArea.schema");
6
+ const ItemArea_1 = require("../../types/article/ItemArea");
6
7
  exports.Link = zod_1.z.object({
7
8
  url: zod_1.z.string().min(1),
8
9
  target: zod_1.z.string().min(1)
@@ -10,11 +11,17 @@ exports.Link = zod_1.z.object({
10
11
  const CommonParamsBase = zod_1.z.object({
11
12
  sizing: zod_1.z.string().min(1)
12
13
  });
14
+ exports.CompoundSettingsSchema = zod_1.z.object({
15
+ positionAnchor: zod_1.z.nativeEnum(ItemArea_1.AreaAnchor),
16
+ widthMode: zod_1.z.nativeEnum(ItemArea_1.DimensionMode),
17
+ heightMode: zod_1.z.nativeEnum(ItemArea_1.DimensionMode),
18
+ });
13
19
  exports.ItemBaseSchema = zod_1.z.object({
14
20
  id: zod_1.z.string().min(1),
15
21
  area: zod_1.z.record(ItemArea_schema_1.ItemAreaSchema),
16
22
  hidden: zod_1.z.record(zod_1.z.boolean()),
17
23
  link: exports.Link.optional(),
18
24
  commonParams: CommonParamsBase,
25
+ compoundSettings: zod_1.z.record(exports.CompoundSettingsSchema).optional(),
19
26
  layoutParams: zod_1.z.record(zod_1.z.any()).optional()
20
27
  });
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ItemStateParamsSchema = exports.CodeEmbedStateParamsSchema = exports.GroupStateParamsSchema = exports.RichTextStateParamsSchema = exports.EmbedStateParamsSchema = exports.CustomItemStateParamsSchema = exports.RectangleStateParamsSchema = exports.MediaStateParamsSchema = exports.ItemStateBaseSchema = exports.getStateParamsSchema = void 0;
3
+ exports.ItemStateParamsSchema = exports.CodeEmbedStateParamsSchema = exports.CompoundStateParamsSchema = 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
5
  const TransitionSchema = zod_1.z.object({
6
6
  timing: zod_1.z.string(),
@@ -51,6 +51,9 @@ exports.RichTextStateParamsSchema = zod_1.z.object({
51
51
  exports.GroupStateParamsSchema = zod_1.z.object({
52
52
  opacity: (0, exports.getStateParamsSchema)(zod_1.z.number().nonnegative())
53
53
  }).merge(exports.ItemStateBaseSchema);
54
+ exports.CompoundStateParamsSchema = zod_1.z.object({
55
+ opacity: (0, exports.getStateParamsSchema)(zod_1.z.number().nonnegative())
56
+ }).merge(exports.ItemStateBaseSchema);
54
57
  exports.CodeEmbedStateParamsSchema = zod_1.z.object({
55
58
  opacity: (0, exports.getStateParamsSchema)(zod_1.z.number().nonnegative())
56
59
  }).merge(exports.ItemStateBaseSchema);
@@ -61,5 +64,6 @@ exports.ItemStateParamsSchema = zod_1.z.union([
61
64
  exports.RichTextStateParamsSchema,
62
65
  exports.CustomItemStateParamsSchema,
63
66
  exports.GroupStateParamsSchema,
67
+ exports.CompoundStateParamsSchema,
64
68
  exports.CodeEmbedStateParamsSchema
65
69
  ]);
@@ -12,4 +12,5 @@ var ArticleItemType;
12
12
  ArticleItemType["Custom"] = "custom";
13
13
  ArticleItemType["Group"] = "group";
14
14
  ArticleItemType["CodeEmbed"] = "code-embed";
15
+ ArticleItemType["Compound"] = "compound";
15
16
  })(ArticleItemType || (exports.ArticleItemType = ArticleItemType = {}));
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AreaAnchor = exports.PositionType = exports.AnchorSide = void 0;
3
+ exports.DimensionMode = exports.AreaAnchor = exports.PositionType = exports.AnchorSide = void 0;
4
4
  var AnchorSide;
5
5
  (function (AnchorSide) {
6
6
  AnchorSide["Top"] = "top";
@@ -24,3 +24,8 @@ var AreaAnchor;
24
24
  AreaAnchor["BottomCenter"] = "bottom-center";
25
25
  AreaAnchor["BottomRight"] = "bottom-right";
26
26
  })(AreaAnchor || (exports.AreaAnchor = AreaAnchor = {}));
27
+ var DimensionMode;
28
+ (function (DimensionMode) {
29
+ DimensionMode["ControlUnits"] = "control-units";
30
+ DimensionMode["Relative"] = "relative";
31
+ })(DimensionMode || (exports.DimensionMode = DimensionMode = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk",
3
- "version": "1.13.0",
3
+ "version": "1.14.0",
4
4
  "description": "Generic SDK for use in public websites.",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/index.ts",
@@ -11,5 +11,6 @@ export const articleMock: Article = {
11
11
  hidden: {},
12
12
  color: {}
13
13
  }
14
- ]
14
+ ],
15
+ interactions: []
15
16
  };
package/src/index.ts CHANGED
@@ -17,7 +17,7 @@ export type { Section, SectionHeight } from './types/article/Section';
17
17
  export type {
18
18
  Item, ImageItem, ItemAny, CustomItem, ItemCommonParamsMap,
19
19
  ItemLayoutParamsMap, RectangleItem, StickyParams, VideoItem, RichTextItem,
20
- Link, VimeoEmbedItem, YoutubeEmbedItem, GroupItem, CodeEmbedItem
20
+ Link, VimeoEmbedItem, YoutubeEmbedItem, GroupItem, CodeEmbedItem, CompoundItem
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';
@@ -27,3 +27,4 @@ export type { Layout } from './types/project/Layout';
27
27
  export type { Project } from './types/project/Project';
28
28
  export type { Meta } from './types/project/Meta';
29
29
  export type { KeyframeValueMap, KeyframeAny } from './types/keyframe/Keyframe';
30
+ export type { CompoundSettings } from './types/article/CompoundSettings';
@@ -10,7 +10,7 @@ import {
10
10
  YoutubeEmbedItem
11
11
  } from '../../types/article/Item';
12
12
  import {
13
- CodeEmbedStateParamsSchema,
13
+ CodeEmbedStateParamsSchema, CompoundStateParamsSchema,
14
14
  CustomItemStateParamsSchema,
15
15
  EmbedStateParamsSchema, GroupStateParamsSchema,
16
16
  MediaStateParamsSchema,
@@ -241,5 +241,24 @@ export const ItemSchema: ZodType<ItemAny> = z.lazy(() => z.discriminatedUnion('t
241
241
  })
242
242
  ),
243
243
  state: z.record(z.record(GroupStateParamsSchema))
244
+ }),
245
+ ItemBaseSchema.extend({
246
+ type: z.literal(ArticleItemType.Compound),
247
+ commonParams: z.object({
248
+ overflow: z.enum(['hidden', 'visible']),
249
+ }),
250
+ items: z.array(ItemSchema),
251
+ sticky: z.record(
252
+ z.object({
253
+ from: z.number(),
254
+ to: z.number().optional()
255
+ }).nullable(),
256
+ ),
257
+ layoutParams: z.record(
258
+ z.object({
259
+ opacity: z.number().nonnegative()
260
+ })
261
+ ),
262
+ state: z.record(z.record(CompoundStateParamsSchema))
244
263
  })
245
264
  ]));
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { ItemAreaSchema } from './ItemArea.schema';
3
+ import { AreaAnchor, DimensionMode } from '../../types/article/ItemArea';
3
4
 
4
5
  export const Link = z.object({
5
6
  url: z.string().min(1),
@@ -10,11 +11,18 @@ const CommonParamsBase = z.object({
10
11
  sizing: z.string().min(1)
11
12
  });
12
13
 
14
+ export const CompoundSettingsSchema = z.object({
15
+ positionAnchor: z.nativeEnum(AreaAnchor),
16
+ widthMode: z.nativeEnum(DimensionMode),
17
+ heightMode: z.nativeEnum(DimensionMode),
18
+ });
19
+
13
20
  export const ItemBaseSchema = z.object({
14
21
  id: z.string().min(1),
15
22
  area: z.record(ItemAreaSchema),
16
23
  hidden: z.record(z.boolean()),
17
24
  link: Link.optional(),
18
25
  commonParams: CommonParamsBase,
26
+ compoundSettings: z.record(CompoundSettingsSchema).optional(),
19
27
  layoutParams: z.record(z.any()).optional()
20
28
  });
@@ -6,7 +6,7 @@ import {
6
6
  GroupStateParams,
7
7
  MediaStateParams,
8
8
  RectangleStateParams,
9
- RichTextStateParams
9
+ RichTextStateParams, CompoundStateParams
10
10
  } from '../../types/article/ItemState';
11
11
 
12
12
  const TransitionSchema = z.object({
@@ -67,6 +67,10 @@ export const GroupStateParamsSchema = z.object({
67
67
  opacity: getStateParamsSchema(z.number().nonnegative())
68
68
  }).merge(ItemStateBaseSchema) satisfies ZodType<GroupStateParams>;
69
69
 
70
+ export const CompoundStateParamsSchema = z.object({
71
+ opacity: getStateParamsSchema(z.number().nonnegative())
72
+ }).merge(ItemStateBaseSchema) satisfies ZodType<CompoundStateParams>;
73
+
70
74
  export const CodeEmbedStateParamsSchema = z.object({
71
75
  opacity: getStateParamsSchema(z.number().nonnegative())
72
76
  }).merge(ItemStateBaseSchema) satisfies ZodType<CodeEmbedStateParams>;
@@ -78,5 +82,6 @@ export const ItemStateParamsSchema = z.union([
78
82
  RichTextStateParamsSchema,
79
83
  CustomItemStateParamsSchema,
80
84
  GroupStateParamsSchema,
85
+ CompoundStateParamsSchema,
81
86
  CodeEmbedStateParamsSchema
82
87
  ]);
@@ -7,5 +7,6 @@ export enum ArticleItemType {
7
7
  YoutubeEmbed = 'youtube-embed',
8
8
  Custom = 'custom',
9
9
  Group = 'group',
10
- CodeEmbed = 'code-embed'
10
+ CodeEmbed = 'code-embed',
11
+ Compound = 'compound'
11
12
  }
@@ -0,0 +1,7 @@
1
+ import { AreaAnchor, DimensionMode } from './ItemArea';
2
+
3
+ export interface CompoundSettings {
4
+ positionAnchor: AreaAnchor;
5
+ widthMode: DimensionMode;
6
+ heightMode: DimensionMode;
7
+ }
@@ -3,7 +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
+ import { CompoundSettings } from './CompoundSettings';
7
7
 
8
8
  export type ItemAny = Item<ArticleItemType>;
9
9
 
@@ -13,8 +13,9 @@ export interface Item<T extends ArticleItemType> {
13
13
  area: Record<LayoutIdentifier, ItemArea>;
14
14
  hidden: Record<LayoutIdentifier, boolean>;
15
15
  link?: Link;
16
- items?: T extends ArticleItemType.Group ? ItemAny[] : never;
16
+ items?: T extends (ArticleItemType.Group | ArticleItemType.Compound) ? ItemAny[] : never;
17
17
  sticky: Record<LayoutIdentifier, StickyParams | null>;
18
+ compoundSettings?: Record<LayoutIdentifier, CompoundSettings>;
18
19
  commonParams: ItemCommonParamsMap[T];
19
20
  state: ItemState<T>;
20
21
  layoutParams: Record<LayoutIdentifier, ItemLayoutParamsMap[T]>;
@@ -29,6 +30,7 @@ export interface ItemCommonParamsMap {
29
30
  [ArticleItemType.YoutubeEmbed]: YoutubeEmbedCommonParams;
30
31
  [ArticleItemType.Custom]: CustomCommonParams;
31
32
  [ArticleItemType.Group]: GroupCommonParams;
33
+ [ArticleItemType.Compound]: CompoundCommonParams;
32
34
  [ArticleItemType.CodeEmbed]: CodeEmbedCommonParams
33
35
  }
34
36
 
@@ -41,6 +43,7 @@ export interface ItemLayoutParamsMap {
41
43
  [ArticleItemType.YoutubeEmbed]: YoutubeEmbedLayoutParams;
42
44
  [ArticleItemType.Custom]: CustomLayoutParams;
43
45
  [ArticleItemType.Group]: GroupLayoutParams;
46
+ [ArticleItemType.Compound]: CompoundLayoutParams;
44
47
  [ArticleItemType.CodeEmbed]: CodeEmbedLayoutParams;
45
48
  }
46
49
 
@@ -74,6 +77,10 @@ interface CustomCommonParams {
74
77
 
75
78
  interface GroupCommonParams {}
76
79
 
80
+ interface CompoundCommonParams {
81
+ overflow: 'hidden' | 'visible';
82
+ }
83
+
77
84
  interface CodeEmbedCommonParams {
78
85
  html: string;
79
86
  scale: boolean;
@@ -112,6 +119,10 @@ interface GroupLayoutParams {
112
119
  opacity: number;
113
120
  }
114
121
 
122
+ interface CompoundLayoutParams {
123
+ opacity: number;
124
+ }
125
+
115
126
  interface CodeEmbedLayoutParams {
116
127
  areaAnchor: AreaAnchor;
117
128
  opacity: number;
@@ -191,3 +202,4 @@ export type YoutubeEmbedItem = Item<ArticleItemType.YoutubeEmbed>;
191
202
  export type CustomItem = Item<ArticleItemType.Custom>;
192
203
  export type GroupItem = Item<ArticleItemType.Group>;
193
204
  export type CodeEmbedItem = Item<ArticleItemType.CodeEmbed>;
205
+ export type CompoundItem = Item<ArticleItemType.Compound>;
@@ -21,6 +21,11 @@ export enum AreaAnchor {
21
21
  BottomRight = 'bottom-right'
22
22
  }
23
23
 
24
+ export enum DimensionMode {
25
+ ControlUnits = 'control-units',
26
+ Relative = 'relative',
27
+ }
28
+
24
29
  export interface ItemArea {
25
30
  top: number;
26
31
  left: number;
@@ -17,6 +17,7 @@ export interface ItemStatesMap {
17
17
  [ArticleItemType.Custom]: CustomItemStateParams;
18
18
  [ArticleItemType.Group]: GroupStateParams;
19
19
  [ArticleItemType.CodeEmbed]: CodeEmbedStateParams;
20
+ [ArticleItemType.Compound]: CompoundStateParams;
20
21
  }
21
22
 
22
23
  export interface StateParams<T> {
@@ -75,6 +76,10 @@ export interface GroupStateParams extends ItemStatesBaseMap {
75
76
  opacity?: StateParams<number>;
76
77
  }
77
78
 
79
+ export interface CompoundStateParams extends ItemStatesBaseMap {
80
+ opacity?: StateParams<number>;
81
+ }
82
+
78
83
  export interface CodeEmbedStateParams extends ItemStatesBaseMap {
79
84
  opacity?: StateParams<number>;
80
85
  }