@webstudio-is/sdk 0.198.0 → 0.199.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.
- package/lib/core-templates.js +224 -0
- package/lib/index.js +156 -0
- package/lib/types/core-metas.d.ts +748 -0
- package/lib/types/core-templates.d.ts +6 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/schema/assets.d.ts +50 -50
- package/lib/types/schema/breakpoints.d.ts +8 -8
- package/lib/types/schema/component-meta.d.ts +46 -46
- package/lib/types/schema/data-sources.d.ts +12 -12
- package/lib/types/schema/embed-template.d.ts +56 -56
- package/lib/types/schema/instances.d.ts +4 -4
- package/lib/types/schema/pages.d.ts +48 -48
- package/lib/types/schema/prop-meta.d.ts +2 -2
- package/lib/types/schema/props.d.ts +44 -44
- package/lib/types/schema/resources.d.ts +12 -12
- package/lib/types/schema/style-sources.d.ts +6 -6
- package/lib/types/schema/styles.d.ts +74 -74
- package/lib/types/schema/webstudio.d.ts +336 -336
- package/package.json +15 -9
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
// src/core-templates.tsx
|
|
2
|
+
import {
|
|
3
|
+
$,
|
|
4
|
+
css,
|
|
5
|
+
expression,
|
|
6
|
+
Parameter,
|
|
7
|
+
ws
|
|
8
|
+
} from "@webstudio-is/template";
|
|
9
|
+
|
|
10
|
+
// src/core-metas.ts
|
|
11
|
+
import {
|
|
12
|
+
ContentBlockIcon,
|
|
13
|
+
ListViewIcon,
|
|
14
|
+
PaintBrushIcon,
|
|
15
|
+
SettingsIcon,
|
|
16
|
+
AddTemplateInstanceIcon
|
|
17
|
+
} from "@webstudio-is/icons/svg";
|
|
18
|
+
|
|
19
|
+
// src/__generated__/normalize.css.ts
|
|
20
|
+
var html = [
|
|
21
|
+
{ property: "display", value: { type: "keyword", value: "grid" } },
|
|
22
|
+
{ property: "minHeight", value: { type: "unit", unit: "%", value: 100 } },
|
|
23
|
+
{
|
|
24
|
+
property: "fontFamily",
|
|
25
|
+
value: { type: "fontFamily", value: ["Arial", "Roboto", "sans-serif"] }
|
|
26
|
+
},
|
|
27
|
+
{ property: "fontSize", value: { type: "unit", unit: "px", value: 16 } },
|
|
28
|
+
{
|
|
29
|
+
property: "lineHeight",
|
|
30
|
+
value: { type: "unit", unit: "number", value: 1.2 }
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
property: "whiteSpaceCollapse",
|
|
34
|
+
value: { type: "keyword", value: "preserve" }
|
|
35
|
+
}
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
// src/core-metas.ts
|
|
39
|
+
var rootComponent = "ws:root";
|
|
40
|
+
var rootMeta = {
|
|
41
|
+
type: "container",
|
|
42
|
+
label: "Global Root",
|
|
43
|
+
icon: SettingsIcon,
|
|
44
|
+
presetStyle: {
|
|
45
|
+
html
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var rootPropsMeta = {
|
|
49
|
+
props: {}
|
|
50
|
+
};
|
|
51
|
+
var collectionComponent = "ws:collection";
|
|
52
|
+
var collectionMeta = {
|
|
53
|
+
type: "container",
|
|
54
|
+
label: "Collection",
|
|
55
|
+
icon: ListViewIcon,
|
|
56
|
+
stylable: false
|
|
57
|
+
};
|
|
58
|
+
var collectionPropsMeta = {
|
|
59
|
+
props: {
|
|
60
|
+
data: {
|
|
61
|
+
required: true,
|
|
62
|
+
control: "json",
|
|
63
|
+
type: "json"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
initialProps: ["data"]
|
|
67
|
+
};
|
|
68
|
+
var descendantComponent = "ws:descendant";
|
|
69
|
+
var descendantMeta = {
|
|
70
|
+
type: "control",
|
|
71
|
+
label: "Descendant",
|
|
72
|
+
icon: PaintBrushIcon,
|
|
73
|
+
constraints: {
|
|
74
|
+
relation: "parent",
|
|
75
|
+
component: { $in: ["HtmlEmbed", "MarkdownEmbed"] }
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
var descendantPropsMeta = {
|
|
79
|
+
props: {
|
|
80
|
+
selector: {
|
|
81
|
+
required: true,
|
|
82
|
+
type: "string",
|
|
83
|
+
control: "select",
|
|
84
|
+
options: [
|
|
85
|
+
" p",
|
|
86
|
+
" h1",
|
|
87
|
+
" h2",
|
|
88
|
+
" h3",
|
|
89
|
+
" h4",
|
|
90
|
+
" h5",
|
|
91
|
+
" h6",
|
|
92
|
+
" :where(strong, b)",
|
|
93
|
+
" :where(em, i)",
|
|
94
|
+
" a",
|
|
95
|
+
" img",
|
|
96
|
+
" blockquote",
|
|
97
|
+
" code",
|
|
98
|
+
" :where(ul, ol)",
|
|
99
|
+
" li",
|
|
100
|
+
" hr"
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
initialProps: ["selector"]
|
|
105
|
+
};
|
|
106
|
+
var blockComponent = "ws:block";
|
|
107
|
+
var blockTemplateComponent = "ws:block-template";
|
|
108
|
+
var blockTemplateMeta = {
|
|
109
|
+
type: "container",
|
|
110
|
+
icon: AddTemplateInstanceIcon,
|
|
111
|
+
stylable: false,
|
|
112
|
+
constraints: {
|
|
113
|
+
relation: "parent",
|
|
114
|
+
component: { $eq: blockComponent }
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
var blockTemplatePropsMeta = {
|
|
118
|
+
props: {}
|
|
119
|
+
};
|
|
120
|
+
var blockMeta = {
|
|
121
|
+
type: "container",
|
|
122
|
+
label: "Content Block",
|
|
123
|
+
icon: ContentBlockIcon,
|
|
124
|
+
constraints: [
|
|
125
|
+
{
|
|
126
|
+
relation: "ancestor",
|
|
127
|
+
component: { $nin: [collectionComponent, blockComponent] }
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
relation: "child",
|
|
131
|
+
component: { $eq: blockTemplateComponent }
|
|
132
|
+
}
|
|
133
|
+
],
|
|
134
|
+
stylable: false
|
|
135
|
+
};
|
|
136
|
+
var blockPropsMeta = {
|
|
137
|
+
props: {}
|
|
138
|
+
};
|
|
139
|
+
var coreMetas = {
|
|
140
|
+
[rootComponent]: rootMeta,
|
|
141
|
+
[collectionComponent]: collectionMeta,
|
|
142
|
+
[descendantComponent]: descendantMeta,
|
|
143
|
+
[blockComponent]: blockMeta,
|
|
144
|
+
[blockTemplateComponent]: blockTemplateMeta
|
|
145
|
+
};
|
|
146
|
+
var corePropsMetas = {
|
|
147
|
+
[rootComponent]: rootPropsMeta,
|
|
148
|
+
[collectionComponent]: collectionPropsMeta,
|
|
149
|
+
[descendantComponent]: descendantPropsMeta,
|
|
150
|
+
[blockComponent]: blockPropsMeta,
|
|
151
|
+
[blockTemplateComponent]: blockTemplatePropsMeta
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// src/core-templates.tsx
|
|
155
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
156
|
+
var collectionItem = new Parameter("collectionItem");
|
|
157
|
+
var collectionMeta2 = {
|
|
158
|
+
category: "data",
|
|
159
|
+
order: 2,
|
|
160
|
+
template: /* @__PURE__ */ jsx(
|
|
161
|
+
ws.collection,
|
|
162
|
+
{
|
|
163
|
+
data: ["Collection Item 1", "Collection Item 2", "Collection Item 3"],
|
|
164
|
+
item: collectionItem,
|
|
165
|
+
children: /* @__PURE__ */ jsx($.Box, { children: /* @__PURE__ */ jsx($.Text, { children: expression`${collectionItem}` }) })
|
|
166
|
+
}
|
|
167
|
+
)
|
|
168
|
+
};
|
|
169
|
+
var descendantMeta2 = {
|
|
170
|
+
category: "internal",
|
|
171
|
+
template: /* @__PURE__ */ jsx(ws.descendant, { selector: " p" })
|
|
172
|
+
};
|
|
173
|
+
var BlockTemplate = ws["block-template"];
|
|
174
|
+
var blockMeta2 = {
|
|
175
|
+
category: "typography",
|
|
176
|
+
template: /* @__PURE__ */ jsxs(ws.block, { children: [
|
|
177
|
+
/* @__PURE__ */ jsxs(BlockTemplate, { "ws:label": "Templates", children: [
|
|
178
|
+
/* @__PURE__ */ jsx($.Paragraph, {}),
|
|
179
|
+
/* @__PURE__ */ jsx($.Heading, { "ws:label": "Heading 1", tag: "h1" }),
|
|
180
|
+
/* @__PURE__ */ jsx($.Heading, { "ws:label": "Heading 2", tag: "h2" }),
|
|
181
|
+
/* @__PURE__ */ jsx($.Heading, { "ws:label": "Heading 3", tag: "h3" }),
|
|
182
|
+
/* @__PURE__ */ jsx($.Heading, { "ws:label": "Heading 4", tag: "h4" }),
|
|
183
|
+
/* @__PURE__ */ jsx($.Heading, { "ws:label": "Heading 5", tag: "h5" }),
|
|
184
|
+
/* @__PURE__ */ jsx($.Heading, { "ws:label": "Heading 6", tag: "h6" }),
|
|
185
|
+
/* @__PURE__ */ jsx($.List, { "ws:label": "List (Unordered)", children: /* @__PURE__ */ jsx($.ListItem, {}) }),
|
|
186
|
+
/* @__PURE__ */ jsx($.List, { "ws:label": "List (Ordered)", ordered: true, children: /* @__PURE__ */ jsx($.ListItem, {}) }),
|
|
187
|
+
/* @__PURE__ */ jsx($.Link, {}),
|
|
188
|
+
/* @__PURE__ */ jsx(
|
|
189
|
+
$.Image,
|
|
190
|
+
{
|
|
191
|
+
"ws:style": css`
|
|
192
|
+
margin-right: auto;
|
|
193
|
+
margin-left: auto;
|
|
194
|
+
width: 100%;
|
|
195
|
+
height: auto;
|
|
196
|
+
`
|
|
197
|
+
}
|
|
198
|
+
),
|
|
199
|
+
/* @__PURE__ */ jsx($.Separator, {}),
|
|
200
|
+
/* @__PURE__ */ jsx($.Blockquote, {}),
|
|
201
|
+
/* @__PURE__ */ jsx($.HtmlEmbed, {}),
|
|
202
|
+
/* @__PURE__ */ jsx($.CodeText, {})
|
|
203
|
+
] }),
|
|
204
|
+
/* @__PURE__ */ jsxs($.Paragraph, { children: [
|
|
205
|
+
"The Content Block component designates regions on the page where pre-styled instances can be inserted in",
|
|
206
|
+
" ",
|
|
207
|
+
/* @__PURE__ */ jsx($.RichTextLink, { href: "https://wstd.us/content-block", children: "Content mode" }),
|
|
208
|
+
"."
|
|
209
|
+
] }),
|
|
210
|
+
/* @__PURE__ */ jsxs($.List, { children: [
|
|
211
|
+
/* @__PURE__ */ jsx($.ListItem, { children: "In Content mode, you can edit any direct child instances that were pre-added to the Content Block, as well as add new instances predefined in Templates." }),
|
|
212
|
+
/* @__PURE__ */ jsx($.ListItem, { children: "To predefine instances for insertion in Content mode, switch to Design mode and add them to the Templates container." }),
|
|
213
|
+
/* @__PURE__ */ jsx($.ListItem, { children: "To insert predefined instances in Content mode, click the + button while hovering over the Content Block on the canvas and choose an instance from the list." })
|
|
214
|
+
] })
|
|
215
|
+
] })
|
|
216
|
+
};
|
|
217
|
+
var coreTemplates = {
|
|
218
|
+
[collectionComponent]: collectionMeta2,
|
|
219
|
+
[descendantComponent]: descendantMeta2,
|
|
220
|
+
[blockComponent]: blockMeta2
|
|
221
|
+
};
|
|
222
|
+
export {
|
|
223
|
+
coreTemplates
|
|
224
|
+
};
|
package/lib/index.js
CHANGED
|
@@ -775,6 +775,152 @@ var WsComponentMeta = z15.object({
|
|
|
775
775
|
order: z15.number().optional()
|
|
776
776
|
});
|
|
777
777
|
|
|
778
|
+
// src/core-metas.ts
|
|
779
|
+
import {
|
|
780
|
+
ContentBlockIcon,
|
|
781
|
+
ListViewIcon,
|
|
782
|
+
PaintBrushIcon,
|
|
783
|
+
SettingsIcon,
|
|
784
|
+
AddTemplateInstanceIcon
|
|
785
|
+
} from "@webstudio-is/icons/svg";
|
|
786
|
+
|
|
787
|
+
// src/__generated__/normalize.css.ts
|
|
788
|
+
var html = [
|
|
789
|
+
{ property: "display", value: { type: "keyword", value: "grid" } },
|
|
790
|
+
{ property: "minHeight", value: { type: "unit", unit: "%", value: 100 } },
|
|
791
|
+
{
|
|
792
|
+
property: "fontFamily",
|
|
793
|
+
value: { type: "fontFamily", value: ["Arial", "Roboto", "sans-serif"] }
|
|
794
|
+
},
|
|
795
|
+
{ property: "fontSize", value: { type: "unit", unit: "px", value: 16 } },
|
|
796
|
+
{
|
|
797
|
+
property: "lineHeight",
|
|
798
|
+
value: { type: "unit", unit: "number", value: 1.2 }
|
|
799
|
+
},
|
|
800
|
+
{
|
|
801
|
+
property: "whiteSpaceCollapse",
|
|
802
|
+
value: { type: "keyword", value: "preserve" }
|
|
803
|
+
}
|
|
804
|
+
];
|
|
805
|
+
|
|
806
|
+
// src/core-metas.ts
|
|
807
|
+
var rootComponent = "ws:root";
|
|
808
|
+
var rootMeta = {
|
|
809
|
+
type: "container",
|
|
810
|
+
label: "Global Root",
|
|
811
|
+
icon: SettingsIcon,
|
|
812
|
+
presetStyle: {
|
|
813
|
+
html
|
|
814
|
+
}
|
|
815
|
+
};
|
|
816
|
+
var rootPropsMeta = {
|
|
817
|
+
props: {}
|
|
818
|
+
};
|
|
819
|
+
var portalComponent = "Slot";
|
|
820
|
+
var collectionComponent = "ws:collection";
|
|
821
|
+
var collectionMeta = {
|
|
822
|
+
type: "container",
|
|
823
|
+
label: "Collection",
|
|
824
|
+
icon: ListViewIcon,
|
|
825
|
+
stylable: false
|
|
826
|
+
};
|
|
827
|
+
var collectionPropsMeta = {
|
|
828
|
+
props: {
|
|
829
|
+
data: {
|
|
830
|
+
required: true,
|
|
831
|
+
control: "json",
|
|
832
|
+
type: "json"
|
|
833
|
+
}
|
|
834
|
+
},
|
|
835
|
+
initialProps: ["data"]
|
|
836
|
+
};
|
|
837
|
+
var descendantComponent = "ws:descendant";
|
|
838
|
+
var descendantMeta = {
|
|
839
|
+
type: "control",
|
|
840
|
+
label: "Descendant",
|
|
841
|
+
icon: PaintBrushIcon,
|
|
842
|
+
constraints: {
|
|
843
|
+
relation: "parent",
|
|
844
|
+
component: { $in: ["HtmlEmbed", "MarkdownEmbed"] }
|
|
845
|
+
}
|
|
846
|
+
};
|
|
847
|
+
var descendantPropsMeta = {
|
|
848
|
+
props: {
|
|
849
|
+
selector: {
|
|
850
|
+
required: true,
|
|
851
|
+
type: "string",
|
|
852
|
+
control: "select",
|
|
853
|
+
options: [
|
|
854
|
+
" p",
|
|
855
|
+
" h1",
|
|
856
|
+
" h2",
|
|
857
|
+
" h3",
|
|
858
|
+
" h4",
|
|
859
|
+
" h5",
|
|
860
|
+
" h6",
|
|
861
|
+
" :where(strong, b)",
|
|
862
|
+
" :where(em, i)",
|
|
863
|
+
" a",
|
|
864
|
+
" img",
|
|
865
|
+
" blockquote",
|
|
866
|
+
" code",
|
|
867
|
+
" :where(ul, ol)",
|
|
868
|
+
" li",
|
|
869
|
+
" hr"
|
|
870
|
+
]
|
|
871
|
+
}
|
|
872
|
+
},
|
|
873
|
+
initialProps: ["selector"]
|
|
874
|
+
};
|
|
875
|
+
var blockComponent = "ws:block";
|
|
876
|
+
var blockTemplateComponent = "ws:block-template";
|
|
877
|
+
var blockTemplateMeta = {
|
|
878
|
+
type: "container",
|
|
879
|
+
icon: AddTemplateInstanceIcon,
|
|
880
|
+
stylable: false,
|
|
881
|
+
constraints: {
|
|
882
|
+
relation: "parent",
|
|
883
|
+
component: { $eq: blockComponent }
|
|
884
|
+
}
|
|
885
|
+
};
|
|
886
|
+
var blockTemplatePropsMeta = {
|
|
887
|
+
props: {}
|
|
888
|
+
};
|
|
889
|
+
var blockMeta = {
|
|
890
|
+
type: "container",
|
|
891
|
+
label: "Content Block",
|
|
892
|
+
icon: ContentBlockIcon,
|
|
893
|
+
constraints: [
|
|
894
|
+
{
|
|
895
|
+
relation: "ancestor",
|
|
896
|
+
component: { $nin: [collectionComponent, blockComponent] }
|
|
897
|
+
},
|
|
898
|
+
{
|
|
899
|
+
relation: "child",
|
|
900
|
+
component: { $eq: blockTemplateComponent }
|
|
901
|
+
}
|
|
902
|
+
],
|
|
903
|
+
stylable: false
|
|
904
|
+
};
|
|
905
|
+
var blockPropsMeta = {
|
|
906
|
+
props: {}
|
|
907
|
+
};
|
|
908
|
+
var coreMetas = {
|
|
909
|
+
[rootComponent]: rootMeta,
|
|
910
|
+
[collectionComponent]: collectionMeta,
|
|
911
|
+
[descendantComponent]: descendantMeta,
|
|
912
|
+
[blockComponent]: blockMeta,
|
|
913
|
+
[blockTemplateComponent]: blockTemplateMeta
|
|
914
|
+
};
|
|
915
|
+
var corePropsMetas = {
|
|
916
|
+
[rootComponent]: rootPropsMeta,
|
|
917
|
+
[collectionComponent]: collectionPropsMeta,
|
|
918
|
+
[descendantComponent]: descendantPropsMeta,
|
|
919
|
+
[blockComponent]: blockPropsMeta,
|
|
920
|
+
[blockTemplateComponent]: blockTemplatePropsMeta
|
|
921
|
+
};
|
|
922
|
+
var isCoreComponent = (component) => component === rootComponent || component === collectionComponent || component === descendantComponent || component === blockComponent || component === blockTemplateComponent;
|
|
923
|
+
|
|
778
924
|
// src/instances-utils.ts
|
|
779
925
|
var ROOT_INSTANCE_ID = ":root";
|
|
780
926
|
var traverseInstances = (instances, instanceId, callback) => {
|
|
@@ -1583,10 +1729,17 @@ export {
|
|
|
1583
1729
|
WebstudioFragment,
|
|
1584
1730
|
WsComponentMeta,
|
|
1585
1731
|
WsEmbedTemplate,
|
|
1732
|
+
blockComponent,
|
|
1733
|
+
blockTemplateComponent,
|
|
1734
|
+
blockTemplateMeta,
|
|
1735
|
+
collectionComponent,
|
|
1586
1736
|
componentCategories,
|
|
1737
|
+
coreMetas,
|
|
1738
|
+
corePropsMetas,
|
|
1587
1739
|
createScope,
|
|
1588
1740
|
decodeDataSourceVariable,
|
|
1589
1741
|
defaultStates,
|
|
1742
|
+
descendantComponent,
|
|
1590
1743
|
documentTypes,
|
|
1591
1744
|
encodeDataSourceVariable,
|
|
1592
1745
|
executeExpression,
|
|
@@ -1603,6 +1756,7 @@ export {
|
|
|
1603
1756
|
getStaticSiteMapXml,
|
|
1604
1757
|
getStyleDeclKey,
|
|
1605
1758
|
initialBreakpoints,
|
|
1759
|
+
isCoreComponent,
|
|
1606
1760
|
isLiteralExpression,
|
|
1607
1761
|
isPathnamePattern,
|
|
1608
1762
|
isRootFolder,
|
|
@@ -1610,7 +1764,9 @@ export {
|
|
|
1610
1764
|
matchPathnameParams,
|
|
1611
1765
|
parseComponentName,
|
|
1612
1766
|
parseObjectExpression,
|
|
1767
|
+
portalComponent,
|
|
1613
1768
|
replaceFormActionsWithResources,
|
|
1769
|
+
rootComponent,
|
|
1614
1770
|
stateCategories,
|
|
1615
1771
|
transpileExpression
|
|
1616
1772
|
};
|