@webstudio-is/sdk 0.210.0 → 0.212.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.
@@ -13,7 +13,8 @@ import {
13
13
  ListViewIcon,
14
14
  PaintBrushIcon,
15
15
  SettingsIcon,
16
- AddTemplateInstanceIcon
16
+ AddTemplateInstanceIcon,
17
+ HtmlElementIcon
17
18
  } from "@webstudio-is/icons/svg";
18
19
 
19
20
  // src/__generated__/normalize.css.ts
@@ -48,6 +49,15 @@ var rootMeta = {
48
49
  var rootPropsMeta = {
49
50
  props: {}
50
51
  };
52
+ var elementComponent = "ws:element";
53
+ var elementMeta = {
54
+ type: "container",
55
+ label: "Element",
56
+ icon: HtmlElementIcon
57
+ };
58
+ var elementPropsMeta = {
59
+ props: {}
60
+ };
51
61
  var collectionComponent = "ws:collection";
52
62
  var collectionMeta = {
53
63
  type: "container",
@@ -137,6 +147,7 @@ var blockPropsMeta = {
137
147
  };
138
148
  var coreMetas = {
139
149
  [rootComponent]: rootMeta,
150
+ [elementComponent]: elementMeta,
140
151
  [collectionComponent]: collectionMeta,
141
152
  [descendantComponent]: descendantMeta,
142
153
  [blockComponent]: blockMeta,
@@ -144,6 +155,7 @@ var coreMetas = {
144
155
  };
145
156
  var corePropsMetas = {
146
157
  [rootComponent]: rootPropsMeta,
158
+ [elementComponent]: elementPropsMeta,
147
159
  [collectionComponent]: collectionPropsMeta,
148
160
  [descendantComponent]: descendantPropsMeta,
149
161
  [blockComponent]: blockPropsMeta,
@@ -175,12 +187,12 @@ var blockMeta2 = {
175
187
  template: /* @__PURE__ */ jsxs(ws.block, { children: [
176
188
  /* @__PURE__ */ jsxs(BlockTemplate, { "ws:label": "Templates", children: [
177
189
  /* @__PURE__ */ jsx($.Paragraph, {}),
178
- /* @__PURE__ */ jsx($.Heading, { "ws:label": "Heading 1", tag: "h1" }),
179
- /* @__PURE__ */ jsx($.Heading, { "ws:label": "Heading 2", tag: "h2" }),
180
- /* @__PURE__ */ jsx($.Heading, { "ws:label": "Heading 3", tag: "h3" }),
181
- /* @__PURE__ */ jsx($.Heading, { "ws:label": "Heading 4", tag: "h4" }),
182
- /* @__PURE__ */ jsx($.Heading, { "ws:label": "Heading 5", tag: "h5" }),
183
- /* @__PURE__ */ jsx($.Heading, { "ws:label": "Heading 6", tag: "h6" }),
190
+ /* @__PURE__ */ jsx($.Heading, { "ws:label": "Heading 1", "ws:tag": "h1" }),
191
+ /* @__PURE__ */ jsx($.Heading, { "ws:label": "Heading 2", "ws:tag": "h2" }),
192
+ /* @__PURE__ */ jsx($.Heading, { "ws:label": "Heading 3", "ws:tag": "h3" }),
193
+ /* @__PURE__ */ jsx($.Heading, { "ws:label": "Heading 4", "ws:tag": "h4" }),
194
+ /* @__PURE__ */ jsx($.Heading, { "ws:label": "Heading 5", "ws:tag": "h5" }),
195
+ /* @__PURE__ */ jsx($.Heading, { "ws:label": "Heading 6", "ws:tag": "h6" }),
184
196
  /* @__PURE__ */ jsx($.List, { "ws:label": "List (Unordered)", children: /* @__PURE__ */ jsx($.ListItem, {}) }),
185
197
  /* @__PURE__ */ jsx($.List, { "ws:label": "List (Ordered)", ordered: true, children: /* @__PURE__ */ jsx($.ListItem, {}) }),
186
198
  /* @__PURE__ */ jsx($.Link, {}),
package/lib/index.js CHANGED
@@ -88,10 +88,7 @@ var HomePage = z2.object({
88
88
  ...commonPageFields,
89
89
  path: HomePagePath
90
90
  });
91
- var PagePath = z2.string().refine((path) => path !== "", "Can't be empty").refine((path) => path !== "/", "Can't be just a /").refine(
92
- (path) => path === "" || path.startsWith("/"),
93
- "Must start with a / or a full URL e.g. https://website.org"
94
- ).refine((path) => path.endsWith("/") === false, "Can't end with a /").refine((path) => path.includes("//") === false, "Can't contain repeating /").refine(
91
+ var DefaultPagePage = z2.string().refine((path) => path !== "", "Can't be empty").refine((path) => path !== "/", "Can't be just a /").refine((path) => path.endsWith("/") === false, "Can't end with a /").refine((path) => path.includes("//") === false, "Can't contain repeating /").refine(
95
92
  (path) => /^[-_a-z0-9*:?\\/.]*$/.test(path),
96
93
  "Only a-z, 0-9, -, _, /, :, ?, . and * are allowed"
97
94
  ).refine(
@@ -104,6 +101,14 @@ var PagePath = z2.string().refine((path) => path !== "", "Can't be empty").refin
104
101
  (path) => path !== "/build" && path.startsWith("/build/") === false,
105
102
  "/build prefix is reserved for the system"
106
103
  );
104
+ var PagePath = DefaultPagePage.refine(
105
+ (path) => path === "" || path.startsWith("/"),
106
+ "Must start with a / or a full URL e.g. https://website.org"
107
+ );
108
+ var OldPagePath = DefaultPagePage.refine(
109
+ (path) => path === "" || path.startsWith("/"),
110
+ "Must start with a / and it must be full path e.g. /project/id"
111
+ );
107
112
  var Page = z2.object({
108
113
  ...commonPageFields,
109
114
  path: PagePath
@@ -167,6 +172,7 @@ var Instance = z3.object({
167
172
  type: z3.literal("instance"),
168
173
  id: InstanceId,
169
174
  component: z3.string(),
175
+ tag: z3.string().optional(),
170
176
  label: z3.string().optional(),
171
177
  children: z3.array(InstanceChild)
172
178
  });
@@ -350,6 +356,23 @@ var rangeUnitValueSchema = z6.union([
350
356
  z6.object({
351
357
  type: z6.literal("unparsed"),
352
358
  value: z6.string()
359
+ }),
360
+ z6.object({
361
+ type: z6.literal("var"),
362
+ value: z6.string()
363
+ })
364
+ ]);
365
+ var TIME_UNITS = ["ms", "s"];
366
+ var timeUnitSchema = literalUnion(TIME_UNITS);
367
+ var durationUnitValueSchema = z6.union([
368
+ z6.object({
369
+ type: z6.literal("unit"),
370
+ value: z6.number(),
371
+ unit: timeUnitSchema
372
+ }),
373
+ z6.object({
374
+ type: z6.literal("var"),
375
+ value: z6.string()
353
376
  })
354
377
  ]);
355
378
  var insetUnitValueSchema = z6.union([
@@ -371,8 +394,9 @@ var keyframeEffectOptionsSchema = z6.object({
371
394
  z6.literal("forwards"),
372
395
  z6.literal("backwards"),
373
396
  z6.literal("both")
374
- ]).optional()
397
+ ]).optional(),
375
398
  // FillMode
399
+ duration: durationUnitValueSchema.optional()
376
400
  });
377
401
  var scrollNamedRangeSchema = z6.union([
378
402
  z6.literal("start"),
@@ -654,6 +678,13 @@ var common = {
654
678
  description: z14.string().optional(),
655
679
  required: z14.boolean()
656
680
  };
681
+ var Tag = z14.object({
682
+ ...common,
683
+ control: z14.literal("tag"),
684
+ type: z14.literal("string"),
685
+ defaultValue: z14.undefined().optional(),
686
+ options: z14.array(z14.string())
687
+ });
657
688
  var Number = z14.object({
658
689
  ...common,
659
690
  control: z14.literal("number"),
@@ -797,6 +828,7 @@ var AnimationAction = z14.object({
797
828
  defaultValue: z14.undefined().optional()
798
829
  });
799
830
  var PropMeta = z14.union([
831
+ Tag,
800
832
  Number,
801
833
  Range,
802
834
  Text,
@@ -981,7 +1013,8 @@ import {
981
1013
  ListViewIcon,
982
1014
  PaintBrushIcon,
983
1015
  SettingsIcon,
984
- AddTemplateInstanceIcon
1016
+ AddTemplateInstanceIcon,
1017
+ HtmlElementIcon
985
1018
  } from "@webstudio-is/icons/svg";
986
1019
 
987
1020
  // src/__generated__/normalize.css.ts
@@ -1016,6 +1049,15 @@ var rootMeta = {
1016
1049
  var rootPropsMeta = {
1017
1050
  props: {}
1018
1051
  };
1052
+ var elementComponent = "ws:element";
1053
+ var elementMeta = {
1054
+ type: "container",
1055
+ label: "Element",
1056
+ icon: HtmlElementIcon
1057
+ };
1058
+ var elementPropsMeta = {
1059
+ props: {}
1060
+ };
1019
1061
  var portalComponent = "Slot";
1020
1062
  var collectionComponent = "ws:collection";
1021
1063
  var collectionMeta = {
@@ -1106,6 +1148,7 @@ var blockPropsMeta = {
1106
1148
  };
1107
1149
  var coreMetas = {
1108
1150
  [rootComponent]: rootMeta,
1151
+ [elementComponent]: elementMeta,
1109
1152
  [collectionComponent]: collectionMeta,
1110
1153
  [descendantComponent]: descendantMeta,
1111
1154
  [blockComponent]: blockMeta,
@@ -1113,12 +1156,13 @@ var coreMetas = {
1113
1156
  };
1114
1157
  var corePropsMetas = {
1115
1158
  [rootComponent]: rootPropsMeta,
1159
+ [elementComponent]: elementPropsMeta,
1116
1160
  [collectionComponent]: collectionPropsMeta,
1117
1161
  [descendantComponent]: descendantPropsMeta,
1118
1162
  [blockComponent]: blockPropsMeta,
1119
1163
  [blockTemplateComponent]: blockTemplatePropsMeta
1120
1164
  };
1121
- var isCoreComponent = (component) => component === rootComponent || component === collectionComponent || component === descendantComponent || component === blockComponent || component === blockTemplateComponent;
1165
+ var isCoreComponent = (component) => component === rootComponent || component === elementComponent || component === collectionComponent || component === descendantComponent || component === blockComponent || component === blockTemplateComponent;
1122
1166
 
1123
1167
  // src/instances-utils.ts
1124
1168
  var ROOT_INSTANCE_ID = ":root";
@@ -2154,6 +2198,7 @@ export {
2154
2198
  MatcherOperation,
2155
2199
  MatcherRelation,
2156
2200
  Matchers,
2201
+ OldPagePath,
2157
2202
  PageName,
2158
2203
  PagePath,
2159
2204
  PageRedirect,
@@ -2199,6 +2244,8 @@ export {
2199
2244
  defaultStates,
2200
2245
  descendantComponent,
2201
2246
  documentTypes,
2247
+ durationUnitValueSchema,
2248
+ elementComponent,
2202
2249
  encodeDataVariableId as encodeDataSourceVariable,
2203
2250
  encodeDataVariableId,
2204
2251
  executeExpression,
package/lib/runtime.js CHANGED
@@ -89,13 +89,27 @@ var isPlainObject = (value) => {
89
89
  // src/form-fields.ts
90
90
  var formIdFieldName = `ws--form-id`;
91
91
  var formBotFieldName = `ws--form-bot`;
92
+
93
+ // src/runtime.ts
94
+ var tagProperty = "data-ws-tag";
95
+ var getTagFromProps = (props) => {
96
+ return props[tagProperty];
97
+ };
98
+ var indexProperty = "data-ws-index";
99
+ var getIndexWithinAncestorFromProps = (props) => {
100
+ return props[indexProperty];
101
+ };
92
102
  export {
93
103
  createJsonStringifyProxy,
94
104
  formBotFieldName,
95
105
  formIdFieldName,
106
+ getIndexWithinAncestorFromProps,
107
+ getTagFromProps,
108
+ indexProperty,
96
109
  isLocalResource,
97
110
  isPlainObject,
98
111
  loadResource,
99
112
  loadResources,
100
- sitemapResourceUrl
113
+ sitemapResourceUrl,
114
+ tagProperty
101
115
  };
@@ -1,5 +1,6 @@
1
1
  import type { WsComponentMeta } from "./schema/component-meta";
2
2
  export declare const rootComponent = "ws:root";
3
+ export declare const elementComponent = "ws:element";
3
4
  export declare const portalComponent = "Slot";
4
5
  export declare const collectionComponent = "ws:collection";
5
6
  export declare const descendantComponent = "ws:descendant";
@@ -8,6 +9,7 @@ export declare const blockTemplateComponent = "ws:block-template";
8
9
  export declare const blockTemplateMeta: WsComponentMeta;
9
10
  export declare const coreMetas: {
10
11
  "ws:root": WsComponentMeta;
12
+ "ws:element": WsComponentMeta;
11
13
  "ws:collection": WsComponentMeta;
12
14
  "ws:descendant": WsComponentMeta;
13
15
  "ws:block": WsComponentMeta;
@@ -16,6 +18,182 @@ export declare const coreMetas: {
16
18
  export declare const corePropsMetas: {
17
19
  "ws:root": {
18
20
  props: Record<string, {
21
+ options: string[];
22
+ type: "string";
23
+ required: boolean;
24
+ control: "tag";
25
+ label?: string | undefined;
26
+ defaultValue?: undefined;
27
+ description?: string | undefined;
28
+ } | {
29
+ type: "number";
30
+ required: boolean;
31
+ control: "number";
32
+ label?: string | undefined;
33
+ defaultValue?: number | undefined;
34
+ description?: string | undefined;
35
+ } | {
36
+ type: "number";
37
+ required: boolean;
38
+ control: "range";
39
+ label?: string | undefined;
40
+ defaultValue?: number | undefined;
41
+ description?: string | undefined;
42
+ } | {
43
+ type: "string";
44
+ required: boolean;
45
+ control: "text";
46
+ label?: string | undefined;
47
+ defaultValue?: string | undefined;
48
+ description?: string | undefined;
49
+ rows?: number | undefined;
50
+ } | {
51
+ type: "resource";
52
+ required: boolean;
53
+ control: "resource";
54
+ label?: string | undefined;
55
+ defaultValue?: string | undefined;
56
+ description?: string | undefined;
57
+ } | {
58
+ type: "string";
59
+ required: boolean;
60
+ control: "code";
61
+ language: "html" | "markdown";
62
+ label?: string | undefined;
63
+ defaultValue?: string | undefined;
64
+ description?: string | undefined;
65
+ } | {
66
+ type: "string";
67
+ required: boolean;
68
+ control: "codetext";
69
+ label?: string | undefined;
70
+ defaultValue?: string | undefined;
71
+ description?: string | undefined;
72
+ } | {
73
+ type: "string";
74
+ required: boolean;
75
+ control: "color";
76
+ label?: string | undefined;
77
+ defaultValue?: string | undefined;
78
+ description?: string | undefined;
79
+ } | {
80
+ type: "boolean";
81
+ required: boolean;
82
+ control: "boolean";
83
+ label?: string | undefined;
84
+ defaultValue?: boolean | undefined;
85
+ description?: string | undefined;
86
+ } | {
87
+ options: string[];
88
+ type: "string";
89
+ required: boolean;
90
+ control: "radio";
91
+ label?: string | undefined;
92
+ defaultValue?: string | undefined;
93
+ description?: string | undefined;
94
+ } | {
95
+ options: string[];
96
+ type: "string";
97
+ required: boolean;
98
+ control: "inline-radio";
99
+ label?: string | undefined;
100
+ defaultValue?: string | undefined;
101
+ description?: string | undefined;
102
+ } | {
103
+ options: string[];
104
+ type: "string";
105
+ required: boolean;
106
+ control: "select";
107
+ label?: string | undefined;
108
+ defaultValue?: string | undefined;
109
+ description?: string | undefined;
110
+ } | {
111
+ options: string[];
112
+ type: "string[]";
113
+ required: boolean;
114
+ control: "check";
115
+ label?: string | undefined;
116
+ defaultValue?: string[] | undefined;
117
+ description?: string | undefined;
118
+ } | {
119
+ options: string[];
120
+ type: "string[]";
121
+ required: boolean;
122
+ control: "inline-check";
123
+ label?: string | undefined;
124
+ defaultValue?: string[] | undefined;
125
+ description?: string | undefined;
126
+ } | {
127
+ options: string[];
128
+ type: "string[]";
129
+ required: boolean;
130
+ control: "multi-select";
131
+ label?: string | undefined;
132
+ defaultValue?: string[] | undefined;
133
+ description?: string | undefined;
134
+ } | {
135
+ type: "string";
136
+ required: boolean;
137
+ control: "file";
138
+ label?: string | undefined;
139
+ defaultValue?: string | undefined;
140
+ description?: string | undefined;
141
+ accept?: string | undefined;
142
+ } | {
143
+ type: "string";
144
+ required: boolean;
145
+ control: "url";
146
+ label?: string | undefined;
147
+ defaultValue?: string | undefined;
148
+ description?: string | undefined;
149
+ } | {
150
+ type: "json";
151
+ required: boolean;
152
+ control: "json";
153
+ label?: string | undefined;
154
+ defaultValue?: unknown;
155
+ description?: string | undefined;
156
+ } | {
157
+ type: "string";
158
+ required: boolean;
159
+ control: "date";
160
+ label?: string | undefined;
161
+ defaultValue?: string | undefined;
162
+ description?: string | undefined;
163
+ } | {
164
+ type: "action";
165
+ required: boolean;
166
+ control: "action";
167
+ label?: string | undefined;
168
+ defaultValue?: undefined;
169
+ description?: string | undefined;
170
+ } | {
171
+ type: "string";
172
+ required: boolean;
173
+ control: "textContent";
174
+ label?: string | undefined;
175
+ defaultValue?: string | undefined;
176
+ description?: string | undefined;
177
+ } | {
178
+ type: "animationAction";
179
+ required: boolean;
180
+ control: "animationAction";
181
+ label?: string | undefined;
182
+ defaultValue?: undefined;
183
+ description?: string | undefined;
184
+ }>;
185
+ initialProps?: string[] | undefined;
186
+ };
187
+ "ws:element": {
188
+ props: Record<string, {
189
+ options: string[];
190
+ type: "string";
191
+ required: boolean;
192
+ control: "tag";
193
+ label?: string | undefined;
194
+ defaultValue?: undefined;
195
+ description?: string | undefined;
196
+ } | {
19
197
  type: "number";
20
198
  required: boolean;
21
199
  control: "number";
@@ -176,6 +354,14 @@ export declare const corePropsMetas: {
176
354
  };
177
355
  "ws:collection": {
178
356
  props: Record<string, {
357
+ options: string[];
358
+ type: "string";
359
+ required: boolean;
360
+ control: "tag";
361
+ label?: string | undefined;
362
+ defaultValue?: undefined;
363
+ description?: string | undefined;
364
+ } | {
179
365
  type: "number";
180
366
  required: boolean;
181
367
  control: "number";
@@ -336,6 +522,14 @@ export declare const corePropsMetas: {
336
522
  };
337
523
  "ws:descendant": {
338
524
  props: Record<string, {
525
+ options: string[];
526
+ type: "string";
527
+ required: boolean;
528
+ control: "tag";
529
+ label?: string | undefined;
530
+ defaultValue?: undefined;
531
+ description?: string | undefined;
532
+ } | {
339
533
  type: "number";
340
534
  required: boolean;
341
535
  control: "number";
@@ -496,6 +690,14 @@ export declare const corePropsMetas: {
496
690
  };
497
691
  "ws:block": {
498
692
  props: Record<string, {
693
+ options: string[];
694
+ type: "string";
695
+ required: boolean;
696
+ control: "tag";
697
+ label?: string | undefined;
698
+ defaultValue?: undefined;
699
+ description?: string | undefined;
700
+ } | {
499
701
  type: "number";
500
702
  required: boolean;
501
703
  control: "number";
@@ -656,6 +858,14 @@ export declare const corePropsMetas: {
656
858
  };
657
859
  "ws:block-template": {
658
860
  props: Record<string, {
861
+ options: string[];
862
+ type: "string";
863
+ required: boolean;
864
+ control: "tag";
865
+ label?: string | undefined;
866
+ defaultValue?: undefined;
867
+ description?: string | undefined;
868
+ } | {
659
869
  type: "number";
660
870
  required: boolean;
661
871
  control: "number";
@@ -815,4 +1025,4 @@ export declare const corePropsMetas: {
815
1025
  initialProps?: string[] | undefined;
816
1026
  };
817
1027
  };
818
- export declare const isCoreComponent: (component: string) => component is "ws:root" | "ws:collection" | "ws:descendant" | "ws:block" | "ws:block-template";
1028
+ export declare const isCoreComponent: (component: string) => component is "ws:root" | "ws:element" | "ws:collection" | "ws:descendant" | "ws:block" | "ws:block-template";
@@ -22,5 +22,5 @@ export * from "./resources-generator";
22
22
  export * from "./page-meta-generator";
23
23
  export * from "./url-pattern";
24
24
  export * from "./css";
25
- export type { AnimationAction, AnimationActionScroll, AnimationActionView, AnimationKeyframe, KeyframeStyles, RangeUnit, RangeUnitValue, ScrollNamedRange, ScrollRangeValue, ViewNamedRange, ViewRangeValue, ScrollAnimation, ViewAnimation, InsetUnitValue, } from "./schema/animation-schema";
26
- export { animationActionSchema, scrollAnimationSchema, viewAnimationSchema, rangeUnitValueSchema, animationKeyframeSchema, insetUnitValueSchema, RANGE_UNITS, } from "./schema/animation-schema";
25
+ export type { AnimationAction, AnimationActionScroll, AnimationActionView, AnimationKeyframe, KeyframeStyles, RangeUnit, RangeUnitValue, ScrollNamedRange, ScrollRangeValue, ViewNamedRange, ViewRangeValue, ScrollAnimation, ViewAnimation, InsetUnitValue, DurationUnitValue, TimeUnit, } from "./schema/animation-schema";
26
+ export { animationActionSchema, scrollAnimationSchema, viewAnimationSchema, rangeUnitValueSchema, animationKeyframeSchema, insetUnitValueSchema, durationUnitValueSchema, RANGE_UNITS, } from "./schema/animation-schema";
@@ -1,3 +1,7 @@
1
1
  export * from "./resource-loader";
2
2
  export * from "./to-string";
3
3
  export * from "./form-fields";
4
+ export declare const tagProperty = "data-ws-tag";
5
+ export declare const getTagFromProps: (props: Record<string, unknown>) => string | undefined;
6
+ export declare const indexProperty: "data-ws-index";
7
+ export declare const getIndexWithinAncestorFromProps: (props: Record<string, unknown>) => string | undefined;