@webiny/website-builder-sdk 6.6.0-alpha.1 → 6.6.0-alpha.11
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/BindingsResolver.d.ts +4 -1
- package/BindingsResolver.js.map +1 -1
- package/ComponentInputTraverser.js +1 -0
- package/ComponentInputTraverser.js.map +1 -1
- package/ComponentManifestToAstConverter.d.ts +23 -1
- package/ComponentManifestToAstConverter.js +122 -2
- package/ComponentManifestToAstConverter.js.map +1 -1
- package/ComponentRegistry.d.ts +2 -1
- package/ComponentRegistry.js +7 -0
- package/ComponentRegistry.js.map +1 -1
- package/ComponentResolver.d.ts +6 -3
- package/ComponentResolver.js +9 -4
- package/ComponentResolver.js.map +1 -1
- package/ConstraintEvaluator.d.ts +5 -0
- package/ConstraintEvaluator.js +20 -4
- package/ConstraintEvaluator.js.map +1 -1
- package/ConstraintEvaluator.test.js +137 -0
- package/ConstraintEvaluator.test.js.map +1 -1
- package/ContentSdk.d.ts +64 -2
- package/ContentSdk.js +90 -12
- package/ContentSdk.js.map +1 -1
- package/DocumentStoreManager.d.ts +9 -2
- package/DocumentStoreManager.js +24 -5
- package/DocumentStoreManager.js.map +1 -1
- package/EditingSdk.d.ts +18 -2
- package/EditingSdk.js +30 -5
- package/EditingSdk.js.map +1 -1
- package/ElementBindings.d.ts +28 -0
- package/ElementBindings.js +88 -0
- package/ElementBindings.js.map +1 -0
- package/ElementBindings.test.d.ts +1 -0
- package/ElementBindings.test.js +127 -0
- package/ElementBindings.test.js.map +1 -0
- package/ElementFactory.d.ts +10 -1
- package/ElementFactory.js +38 -7
- package/ElementFactory.js.map +1 -1
- package/ElementFactory.test.js +260 -0
- package/ElementFactory.test.js.map +1 -1
- package/ElementSelection.d.ts +20 -0
- package/ElementSelection.js +32 -0
- package/ElementSelection.js.map +1 -0
- package/ElementSelection.test.d.ts +1 -0
- package/ElementSelection.test.js +73 -0
- package/ElementSelection.test.js.map +1 -0
- package/Environment.d.ts +7 -0
- package/Environment.js +2 -1
- package/Environment.js.map +1 -1
- package/Environment.test.d.ts +1 -0
- package/Environment.test.js +39 -0
- package/Environment.test.js.map +1 -0
- package/GlobalComponentLanguage.d.ts +31 -0
- package/GlobalComponentLanguage.js +37 -0
- package/GlobalComponentLanguage.js.map +1 -0
- package/InheritanceProcessor.test.js +8 -0
- package/InheritanceProcessor.test.js.map +1 -1
- package/InheritedValueResolver.d.ts +6 -0
- package/InheritedValueResolver.js +7 -0
- package/InheritedValueResolver.js.map +1 -1
- package/InputBindingsProcessor.js +6 -2
- package/InputBindingsProcessor.js.map +1 -1
- package/InputRenderer.test.d.ts +1 -0
- package/InputRenderer.test.js +186 -0
- package/InputRenderer.test.js.map +1 -0
- package/InputsBindingsProcessor.test.js +130 -0
- package/InputsBindingsProcessor.test.js.map +1 -1
- package/InputsUpdater.js +1 -0
- package/InputsUpdater.js.map +1 -1
- package/LayoutContentArea.d.ts +68 -0
- package/LayoutContentArea.js +78 -0
- package/LayoutContentArea.js.map +1 -0
- package/LayoutContentArea.test.d.ts +1 -0
- package/LayoutContentArea.test.js +111 -0
- package/LayoutContentArea.test.js.map +1 -0
- package/LiveSdk.d.ts +5 -2
- package/LiveSdk.js +6 -2
- package/LiveSdk.js.map +1 -1
- package/NullSdk.d.ts +2 -1
- package/NullSdk.js +3 -0
- package/NullSdk.js.map +1 -1
- package/PreviewDocument.d.ts +2 -1
- package/PreviewDocument.js +2 -2
- package/PreviewDocument.js.map +1 -1
- package/PreviewSdk.d.ts +5 -2
- package/PreviewSdk.js +6 -2
- package/PreviewSdk.js.map +1 -1
- package/PreviewViewport.d.ts +5 -0
- package/PreviewViewport.js +9 -0
- package/PreviewViewport.js.map +1 -1
- package/PreviewViewport.test.d.ts +1 -0
- package/PreviewViewport.test.js +27 -0
- package/PreviewViewport.test.js.map +1 -0
- package/RadioOptionInputs.test.d.ts +1 -0
- package/RadioOptionInputs.test.js +521 -0
- package/RadioOptionInputs.test.js.map +1 -0
- package/ResizeObserver.js +1 -1
- package/ResizeObserver.js.map +1 -1
- package/StylesUpdater.js +4 -1
- package/StylesUpdater.js.map +1 -1
- package/asset/deliveryUrl.test.js +1 -1
- package/asset/deliveryUrl.test.js.map +1 -1
- package/asset/imageSrcSet.test.js +1 -1
- package/asset/imageSrcSet.test.js.map +1 -1
- package/asset/normalize.d.ts +1 -1
- package/asset/normalize.js +18 -14
- package/asset/normalize.js.map +1 -1
- package/asset/normalize.test.js +15 -8
- package/asset/normalize.test.js.map +1 -1
- package/componentLoader/ComponentLoader.d.ts +16 -0
- package/componentLoader/ComponentLoader.js +0 -0
- package/componentLoader/RegistryOnlyComponentLoader.d.ts +9 -0
- package/componentLoader/RegistryOnlyComponentLoader.js +8 -0
- package/componentLoader/RegistryOnlyComponentLoader.js.map +1 -0
- package/componentLoader/createComponentLoader.d.ts +7 -0
- package/componentLoader/createComponentLoader.js +10 -0
- package/componentLoader/createComponentLoader.js.map +1 -0
- package/componentLoader/defaultComponentLoader.d.ts +7 -0
- package/componentLoader/defaultComponentLoader.js +8 -0
- package/componentLoader/defaultComponentLoader.js.map +1 -0
- package/componentLoader/index.d.ts +3 -0
- package/componentLoader/index.js +3 -0
- package/contentClientState.test.d.ts +1 -0
- package/contentClientState.test.js +404 -0
- package/contentClientState.test.js.map +1 -0
- package/contentEntry/ContentEntryBindingsResolver.d.ts +33 -0
- package/contentEntry/ContentEntryBindingsResolver.js +52 -0
- package/contentEntry/ContentEntryBindingsResolver.js.map +1 -0
- package/contentEntry/ContentEntryCache.d.ts +49 -0
- package/contentEntry/ContentEntryCache.js +51 -0
- package/contentEntry/ContentEntryCache.js.map +1 -0
- package/contentEntry/resolveContentEntry.d.ts +74 -0
- package/contentEntry/resolveContentEntry.js +53 -0
- package/contentEntry/resolveContentEntry.js.map +1 -0
- package/contentEntry/resolveContentEntry.test.d.ts +1 -0
- package/contentEntry/resolveContentEntry.test.js +213 -0
- package/contentEntry/resolveContentEntry.test.js.map +1 -0
- package/createContentClient.d.ts +17 -0
- package/createContentClient.js +16 -0
- package/createContentClient.js.map +1 -0
- package/createContentClient.test.d.ts +1 -0
- package/createContentClient.test.js +165 -0
- package/createContentClient.test.js.map +1 -0
- package/createGlobalElementDocument.d.ts +6 -0
- package/createGlobalElementDocument.js +23 -0
- package/createGlobalElementDocument.js.map +1 -0
- package/createInput.d.ts +10 -2
- package/createInput.js +8 -1
- package/createInput.js.map +1 -1
- package/dataProviders/ApiClient.d.ts +3 -0
- package/dataProviders/ApiClient.js +23 -5
- package/dataProviders/ApiClient.js.map +1 -1
- package/dataProviders/ApiClient.test.d.ts +1 -0
- package/dataProviders/ApiClient.test.js +116 -0
- package/dataProviders/ApiClient.test.js.map +1 -0
- package/dataProviders/DefaultDataProvider.d.ts +2 -1
- package/dataProviders/DefaultDataProvider.js +12 -0
- package/dataProviders/DefaultDataProvider.js.map +1 -1
- package/dataProviders/DefaultDataProvider.test.d.ts +1 -0
- package/dataProviders/DefaultDataProvider.test.js +81 -0
- package/dataProviders/DefaultDataProvider.test.js.map +1 -0
- package/dataProviders/GET_LAYOUT_BY_SLUG.d.ts +1 -0
- package/dataProviders/GET_LAYOUT_BY_SLUG.js +27 -0
- package/dataProviders/GET_LAYOUT_BY_SLUG.js.map +1 -0
- package/dataProviders/GET_PAGE_BY_ID.d.ts +1 -1
- package/dataProviders/GET_PAGE_BY_ID.js +7 -0
- package/dataProviders/GET_PAGE_BY_ID.js.map +1 -1
- package/dataProviders/GET_PAGE_BY_PATH.d.ts +1 -1
- package/dataProviders/GET_PAGE_BY_PATH.js +7 -0
- package/dataProviders/GET_PAGE_BY_PATH.js.map +1 -1
- package/dataProviders/NullDataProvider.d.ts +2 -1
- package/dataProviders/NullDataProvider.js +3 -0
- package/dataProviders/NullDataProvider.js.map +1 -1
- package/dataProviders/queries.test.d.ts +1 -0
- package/dataProviders/queries.test.js +53 -0
- package/dataProviders/queries.test.js.map +1 -0
- package/experiments/render.d.ts +3 -0
- package/experiments/render.js +1 -1
- package/experiments/render.js.map +1 -1
- package/globalElements.d.ts +43 -0
- package/globalElements.js +79 -0
- package/globalElements.js.map +1 -0
- package/globalElements.test.d.ts +1 -0
- package/globalElements.test.js +343 -0
- package/globalElements.test.js.map +1 -0
- package/headersProvider.d.ts +1 -2
- package/headersProvider.js.map +1 -1
- package/index.d.ts +14 -0
- package/index.js +14 -0
- package/messages.d.ts +3 -0
- package/messages.js +4 -1
- package/messages.js.map +1 -1
- package/package.json +10 -10
- package/radioOptionInputs.d.ts +24 -0
- package/radioOptionInputs.js +26 -0
- package/radioOptionInputs.js.map +1 -0
- package/types.d.ts +159 -7
- package/withGlobalElementDefaults.d.ts +8 -0
- package/withGlobalElementDefaults.js +60 -0
- package/withGlobalElementDefaults.js.map +1 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { GlobalElementId } from "./globalElements.js";
|
|
3
|
+
import { withGlobalElementDefaults } from "./withGlobalElementDefaults.js";
|
|
4
|
+
import { createComponent } from "./createComponent.js";
|
|
5
|
+
import { createTextInput } from "./createInput.js";
|
|
6
|
+
import { createElement } from "./createElement.js";
|
|
7
|
+
const header = {
|
|
8
|
+
name: "Demo/Header",
|
|
9
|
+
global: true,
|
|
10
|
+
tags: [],
|
|
11
|
+
inputs: [
|
|
12
|
+
{
|
|
13
|
+
type: "text",
|
|
14
|
+
renderer: "Webiny/Input",
|
|
15
|
+
name: "title",
|
|
16
|
+
defaultValue: "Welcome"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
};
|
|
20
|
+
const banner = {
|
|
21
|
+
name: "Demo/Banner",
|
|
22
|
+
tags: [],
|
|
23
|
+
inputs: [
|
|
24
|
+
{
|
|
25
|
+
type: "text",
|
|
26
|
+
renderer: "Webiny/Input",
|
|
27
|
+
name: "headline"
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
};
|
|
31
|
+
const components = {
|
|
32
|
+
[header.name]: header,
|
|
33
|
+
[banner.name]: banner
|
|
34
|
+
};
|
|
35
|
+
const globalElements_test_element = (id, parentId)=>({
|
|
36
|
+
type: "Webiny/Element",
|
|
37
|
+
id,
|
|
38
|
+
component: {
|
|
39
|
+
name: "Any"
|
|
40
|
+
},
|
|
41
|
+
parent: parentId ? {
|
|
42
|
+
id: parentId,
|
|
43
|
+
slot: "children"
|
|
44
|
+
} : void 0
|
|
45
|
+
});
|
|
46
|
+
describe("global elements", ()=>{
|
|
47
|
+
it("uses a fixed id per global component", ()=>{
|
|
48
|
+
expect(GlobalElementId.fromName("Demo/Header").toString()).toBe("$global:Demo/Header");
|
|
49
|
+
expect(GlobalElementId.fromId("$global:Demo/Header")?.name).toBe("Demo/Header");
|
|
50
|
+
expect(GlobalElementId.fromId("Demo/Header")).toBeNull();
|
|
51
|
+
});
|
|
52
|
+
it("treats elements nested inside a global as global", ()=>{
|
|
53
|
+
const elements = {
|
|
54
|
+
root: globalElements_test_element("root"),
|
|
55
|
+
"$global:Demo/Header": globalElements_test_element("$global:Demo/Header"),
|
|
56
|
+
child: globalElements_test_element("child", "$global:Demo/Header"),
|
|
57
|
+
grandChild: globalElements_test_element("grandChild", "child"),
|
|
58
|
+
pageElement: globalElements_test_element("pageElement", "root")
|
|
59
|
+
};
|
|
60
|
+
expect(GlobalElementId.isInGlobal(elements, "$global:Demo/Header")).toBe(true);
|
|
61
|
+
expect(GlobalElementId.isInGlobal(elements, "child")).toBe(true);
|
|
62
|
+
expect(GlobalElementId.isInGlobal(elements, "grandChild")).toBe(true);
|
|
63
|
+
expect(GlobalElementId.isInGlobal(elements, "pageElement")).toBe(false);
|
|
64
|
+
expect(GlobalElementId.isInGlobal(elements, "root")).toBe(false);
|
|
65
|
+
});
|
|
66
|
+
it("tells placements of a global apart from its instance", ()=>{
|
|
67
|
+
const placement = {
|
|
68
|
+
id: "abc",
|
|
69
|
+
component: {
|
|
70
|
+
name: "Demo/Header"
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const instance = {
|
|
74
|
+
id: "$global:Demo/Header",
|
|
75
|
+
component: {
|
|
76
|
+
name: "Demo/Header"
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const other = {
|
|
80
|
+
id: "def",
|
|
81
|
+
component: {
|
|
82
|
+
name: "Demo/Banner"
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
expect(GlobalElementId.isPlacement(placement, components)).toBe(true);
|
|
86
|
+
expect(GlobalElementId.isPlacement(instance, components)).toBe(false);
|
|
87
|
+
expect(GlobalElementId.isPlacement(other, components)).toBe(false);
|
|
88
|
+
expect(GlobalElementId.bindingsIdOf(placement, components)).toBe("$global:Demo/Header");
|
|
89
|
+
expect(GlobalElementId.bindingsIdOf(other, components)).toBe("def");
|
|
90
|
+
});
|
|
91
|
+
it("splits a merged document into page and globals parts", ()=>{
|
|
92
|
+
const document = {
|
|
93
|
+
elements: {
|
|
94
|
+
root: globalElements_test_element("root"),
|
|
95
|
+
"$global:Demo/Header": globalElements_test_element("$global:Demo/Header"),
|
|
96
|
+
child: globalElements_test_element("child", "$global:Demo/Header")
|
|
97
|
+
},
|
|
98
|
+
bindings: {
|
|
99
|
+
root: {
|
|
100
|
+
inputs: {}
|
|
101
|
+
},
|
|
102
|
+
"$global:Demo/Header": {
|
|
103
|
+
inputs: {}
|
|
104
|
+
},
|
|
105
|
+
child: {
|
|
106
|
+
inputs: {}
|
|
107
|
+
},
|
|
108
|
+
"$global:Demo/Footer": {
|
|
109
|
+
inputs: {}
|
|
110
|
+
},
|
|
111
|
+
layoutElement: {
|
|
112
|
+
inputs: {}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
const { page, globals } = GlobalElementId.splitDocument(document);
|
|
117
|
+
expect(Object.keys(page.elements)).toEqual([
|
|
118
|
+
"root"
|
|
119
|
+
]);
|
|
120
|
+
expect(Object.keys(page.bindings)).toEqual([
|
|
121
|
+
"root",
|
|
122
|
+
"layoutElement"
|
|
123
|
+
]);
|
|
124
|
+
expect(Object.keys(globals.elements)).toEqual([
|
|
125
|
+
"$global:Demo/Header",
|
|
126
|
+
"child"
|
|
127
|
+
]);
|
|
128
|
+
expect(Object.keys(globals.bindings)).toEqual([
|
|
129
|
+
"$global:Demo/Header",
|
|
130
|
+
"child",
|
|
131
|
+
"$global:Demo/Footer"
|
|
132
|
+
]);
|
|
133
|
+
});
|
|
134
|
+
it("finds the global an element belongs to", ()=>{
|
|
135
|
+
const elements = {
|
|
136
|
+
root: globalElements_test_element("root"),
|
|
137
|
+
"$global:Demo/Header": globalElements_test_element("$global:Demo/Header"),
|
|
138
|
+
child: globalElements_test_element("child", "$global:Demo/Header"),
|
|
139
|
+
"$global:Demo/Footer": globalElements_test_element("$global:Demo/Footer")
|
|
140
|
+
};
|
|
141
|
+
const headerId = GlobalElementId.fromName("Demo/Header");
|
|
142
|
+
expect(GlobalElementId.rootOf(elements, "child")?.toString()).toBe("$global:Demo/Header");
|
|
143
|
+
expect(GlobalElementId.rootOf(elements, "root")).toBeNull();
|
|
144
|
+
expect(GlobalElementId.rootOf(elements, "$global:Demo/Banner")?.name).toBe("Demo/Banner");
|
|
145
|
+
expect(GlobalElementId.rootOf(elements, "missing")).toBeNull();
|
|
146
|
+
expect(headerId.owns(elements, "$global:Demo/Header")).toBe(true);
|
|
147
|
+
expect(headerId.owns(elements, "child")).toBe(true);
|
|
148
|
+
expect(headerId.owns(elements, "$global:Demo/Footer")).toBe(false);
|
|
149
|
+
expect(headerId.owns(elements, "root")).toBe(false);
|
|
150
|
+
});
|
|
151
|
+
it("adds default instances only for globals without a stored instance", ()=>{
|
|
152
|
+
const empty = withGlobalElementDefaults({
|
|
153
|
+
elements: {},
|
|
154
|
+
bindings: {}
|
|
155
|
+
}, components);
|
|
156
|
+
expect(Object.keys(empty.elements)).toEqual([
|
|
157
|
+
"$global:Demo/Header"
|
|
158
|
+
]);
|
|
159
|
+
expect(empty.elements["$global:Demo/Header"]).toEqual({
|
|
160
|
+
type: "Webiny/Element",
|
|
161
|
+
id: "$global:Demo/Header",
|
|
162
|
+
component: {
|
|
163
|
+
name: "Demo/Header"
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
expect(empty.bindings["$global:Demo/Header"].inputs?.title?.static).toBe("Welcome");
|
|
167
|
+
const stored = {
|
|
168
|
+
elements: {
|
|
169
|
+
"$global:Demo/Header": globalElements_test_element("$global:Demo/Header")
|
|
170
|
+
},
|
|
171
|
+
bindings: {
|
|
172
|
+
"$global:Demo/Header": {
|
|
173
|
+
inputs: {}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
expect(withGlobalElementDefaults(stored, components)).toBe(stored);
|
|
178
|
+
});
|
|
179
|
+
it("builds the same ids every time for a default instance with slot children", ()=>{
|
|
180
|
+
const footer = {
|
|
181
|
+
name: "Demo/Footer",
|
|
182
|
+
global: true,
|
|
183
|
+
tags: [],
|
|
184
|
+
inputs: [
|
|
185
|
+
{
|
|
186
|
+
type: "slot",
|
|
187
|
+
list: true,
|
|
188
|
+
renderer: "Webiny/Slot",
|
|
189
|
+
name: "links"
|
|
190
|
+
}
|
|
191
|
+
],
|
|
192
|
+
defaults: {
|
|
193
|
+
inputs: {
|
|
194
|
+
links: [
|
|
195
|
+
createElement({
|
|
196
|
+
component: banner.name
|
|
197
|
+
})
|
|
198
|
+
]
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
const withFooter = {
|
|
203
|
+
...components,
|
|
204
|
+
[footer.name]: footer
|
|
205
|
+
};
|
|
206
|
+
const first = withGlobalElementDefaults({
|
|
207
|
+
elements: {},
|
|
208
|
+
bindings: {}
|
|
209
|
+
}, withFooter);
|
|
210
|
+
const second = withGlobalElementDefaults({
|
|
211
|
+
elements: {},
|
|
212
|
+
bindings: {}
|
|
213
|
+
}, withFooter);
|
|
214
|
+
const childIds = Object.keys(first.elements).filter((id)=>!GlobalElementId.isGlobal(id));
|
|
215
|
+
expect(childIds).toHaveLength(1);
|
|
216
|
+
expect(first.elements[childIds[0]].parent?.id).toBe("$global:Demo/Footer");
|
|
217
|
+
expect(second).toEqual(first);
|
|
218
|
+
});
|
|
219
|
+
it("keeps default ids apart for globals whose names differ only in punctuation", ()=>{
|
|
220
|
+
const slotGlobal = (name)=>({
|
|
221
|
+
name,
|
|
222
|
+
global: true,
|
|
223
|
+
tags: [],
|
|
224
|
+
inputs: [
|
|
225
|
+
{
|
|
226
|
+
type: "slot",
|
|
227
|
+
list: true,
|
|
228
|
+
renderer: "Webiny/Slot",
|
|
229
|
+
name: "links"
|
|
230
|
+
}
|
|
231
|
+
],
|
|
232
|
+
defaults: {
|
|
233
|
+
inputs: {
|
|
234
|
+
links: [
|
|
235
|
+
createElement({
|
|
236
|
+
component: banner.name
|
|
237
|
+
})
|
|
238
|
+
]
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
const names = [
|
|
243
|
+
"Demo/Header",
|
|
244
|
+
"Demo-Header",
|
|
245
|
+
"Demo Header",
|
|
246
|
+
"Demo_Header"
|
|
247
|
+
];
|
|
248
|
+
const manifests = Object.fromEntries(names.map((name)=>[
|
|
249
|
+
name,
|
|
250
|
+
slotGlobal(name)
|
|
251
|
+
]));
|
|
252
|
+
const document = withGlobalElementDefaults({
|
|
253
|
+
elements: {},
|
|
254
|
+
bindings: {}
|
|
255
|
+
}, {
|
|
256
|
+
...manifests,
|
|
257
|
+
[banner.name]: banner
|
|
258
|
+
});
|
|
259
|
+
const childIds = Object.keys(document.elements).filter((id)=>!GlobalElementId.isGlobal(id));
|
|
260
|
+
expect(childIds).toHaveLength(names.length);
|
|
261
|
+
expect(childIds.map((id)=>document.elements[id].parent?.id).sort()).toEqual(names.map((name)=>`$global:${name}`).sort());
|
|
262
|
+
});
|
|
263
|
+
it("keeps overrides of a global without a stored instance on top of its defaults", ()=>{
|
|
264
|
+
const document = withGlobalElementDefaults({
|
|
265
|
+
elements: {},
|
|
266
|
+
bindings: {
|
|
267
|
+
"$global:Demo/Header": {
|
|
268
|
+
inputs: {
|
|
269
|
+
title: {
|
|
270
|
+
id: "x",
|
|
271
|
+
type: "text",
|
|
272
|
+
static: "Overridden"
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}, components);
|
|
278
|
+
expect(document.elements["$global:Demo/Header"]).toBeDefined();
|
|
279
|
+
expect(document.bindings["$global:Demo/Header"].inputs?.title?.static).toBe("Overridden");
|
|
280
|
+
});
|
|
281
|
+
it("keeps the default styles of a global without a stored instance when one of its inputs is overridden", ()=>{
|
|
282
|
+
const id = "$global:Demo/Header";
|
|
283
|
+
const styled = {
|
|
284
|
+
...components,
|
|
285
|
+
[header.name]: {
|
|
286
|
+
...header,
|
|
287
|
+
defaults: {
|
|
288
|
+
styles: {
|
|
289
|
+
color: "red"
|
|
290
|
+
},
|
|
291
|
+
overrides: {
|
|
292
|
+
mobile: {
|
|
293
|
+
styles: {
|
|
294
|
+
color: "blue"
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
const defaults = withGlobalElementDefaults({
|
|
302
|
+
elements: {},
|
|
303
|
+
bindings: {}
|
|
304
|
+
}, styled);
|
|
305
|
+
const document = withGlobalElementDefaults({
|
|
306
|
+
elements: {},
|
|
307
|
+
bindings: {
|
|
308
|
+
[id]: {
|
|
309
|
+
inputs: {
|
|
310
|
+
title: {
|
|
311
|
+
id: "x",
|
|
312
|
+
type: "text",
|
|
313
|
+
static: "Overridden"
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
styles: {},
|
|
317
|
+
overrides: {}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}, styled);
|
|
321
|
+
expect(defaults.bindings[id].styles?.color).toEqual({
|
|
322
|
+
static: "red"
|
|
323
|
+
});
|
|
324
|
+
expect(document.bindings[id].inputs?.title?.static).toBe("Overridden");
|
|
325
|
+
expect(document.bindings[id].styles).toEqual(defaults.bindings[id].styles);
|
|
326
|
+
expect(document.bindings[id].overrides).toEqual(defaults.bindings[id].overrides);
|
|
327
|
+
});
|
|
328
|
+
it("keeps the global flag on the manifest", ()=>{
|
|
329
|
+
const Header = (_props)=>null;
|
|
330
|
+
const { manifest } = createComponent(Header, {
|
|
331
|
+
name: "Demo/Header",
|
|
332
|
+
global: true,
|
|
333
|
+
inputs: [
|
|
334
|
+
createTextInput({
|
|
335
|
+
name: "title"
|
|
336
|
+
})
|
|
337
|
+
]
|
|
338
|
+
});
|
|
339
|
+
expect(manifest.global).toBe(true);
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
//# sourceMappingURL=globalElements.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"globalElements.test.js","sources":["../src/globalElements.test.ts"],"sourcesContent":["import { describe, it, expect } from \"vitest\";\nimport type { ComponentManifest, GlobalDocument } from \"~/types.js\";\nimport { GlobalElementId } from \"./globalElements.js\";\nimport { withGlobalElementDefaults } from \"./withGlobalElementDefaults.js\";\nimport { createComponent } from \"./createComponent.js\";\nimport { createTextInput } from \"./createInput.js\";\nimport { createElement } from \"./createElement.js\";\n\nconst header: ComponentManifest = {\n name: \"Demo/Header\",\n global: true,\n tags: [],\n inputs: [{ type: \"text\", renderer: \"Webiny/Input\", name: \"title\", defaultValue: \"Welcome\" }]\n};\n\nconst banner: ComponentManifest = {\n name: \"Demo/Banner\",\n tags: [],\n inputs: [{ type: \"text\", renderer: \"Webiny/Input\", name: \"headline\" }]\n};\n\nconst components = { [header.name]: header, [banner.name]: banner };\n\nconst element = (id: string, parentId?: string) => ({\n type: \"Webiny/Element\" as const,\n id,\n component: { name: \"Any\" },\n parent: parentId ? { id: parentId, slot: \"children\" } : undefined\n});\n\ndescribe(\"global elements\", () => {\n it(\"uses a fixed id per global component\", () => {\n expect(GlobalElementId.fromName(\"Demo/Header\").toString()).toBe(\"$global:Demo/Header\");\n expect(GlobalElementId.fromId(\"$global:Demo/Header\")?.name).toBe(\"Demo/Header\");\n expect(GlobalElementId.fromId(\"Demo/Header\")).toBeNull();\n });\n\n it(\"treats elements nested inside a global as global\", () => {\n const elements = {\n root: element(\"root\"),\n \"$global:Demo/Header\": element(\"$global:Demo/Header\"),\n child: element(\"child\", \"$global:Demo/Header\"),\n grandChild: element(\"grandChild\", \"child\"),\n pageElement: element(\"pageElement\", \"root\")\n };\n\n expect(GlobalElementId.isInGlobal(elements, \"$global:Demo/Header\")).toBe(true);\n expect(GlobalElementId.isInGlobal(elements, \"child\")).toBe(true);\n expect(GlobalElementId.isInGlobal(elements, \"grandChild\")).toBe(true);\n expect(GlobalElementId.isInGlobal(elements, \"pageElement\")).toBe(false);\n expect(GlobalElementId.isInGlobal(elements, \"root\")).toBe(false);\n });\n\n it(\"tells placements of a global apart from its instance\", () => {\n const placement = { id: \"abc\", component: { name: \"Demo/Header\" } };\n const instance = { id: \"$global:Demo/Header\", component: { name: \"Demo/Header\" } };\n const other = { id: \"def\", component: { name: \"Demo/Banner\" } };\n\n expect(GlobalElementId.isPlacement(placement, components)).toBe(true);\n expect(GlobalElementId.isPlacement(instance, components)).toBe(false);\n expect(GlobalElementId.isPlacement(other, components)).toBe(false);\n\n expect(GlobalElementId.bindingsIdOf(placement, components)).toBe(\"$global:Demo/Header\");\n expect(GlobalElementId.bindingsIdOf(other, components)).toBe(\"def\");\n });\n\n it(\"splits a merged document into page and globals parts\", () => {\n const document: GlobalDocument = {\n elements: {\n root: element(\"root\"),\n \"$global:Demo/Header\": element(\"$global:Demo/Header\"),\n child: element(\"child\", \"$global:Demo/Header\")\n },\n bindings: {\n root: { inputs: {} },\n \"$global:Demo/Header\": { inputs: {} },\n child: { inputs: {} },\n // Bindings without an element: an override of a global, and of a layout's element.\n \"$global:Demo/Footer\": { inputs: {} },\n layoutElement: { inputs: {} }\n }\n };\n\n const { page, globals } = GlobalElementId.splitDocument(document);\n\n expect(Object.keys(page.elements)).toEqual([\"root\"]);\n expect(Object.keys(page.bindings)).toEqual([\"root\", \"layoutElement\"]);\n expect(Object.keys(globals.elements)).toEqual([\"$global:Demo/Header\", \"child\"]);\n expect(Object.keys(globals.bindings)).toEqual([\n \"$global:Demo/Header\",\n \"child\",\n \"$global:Demo/Footer\"\n ]);\n });\n\n it(\"finds the global an element belongs to\", () => {\n const elements = {\n root: element(\"root\"),\n \"$global:Demo/Header\": element(\"$global:Demo/Header\"),\n child: element(\"child\", \"$global:Demo/Header\"),\n \"$global:Demo/Footer\": element(\"$global:Demo/Footer\")\n };\n const headerId = GlobalElementId.fromName(\"Demo/Header\");\n\n expect(GlobalElementId.rootOf(elements, \"child\")?.toString()).toBe(\"$global:Demo/Header\");\n expect(GlobalElementId.rootOf(elements, \"root\")).toBeNull();\n expect(GlobalElementId.rootOf(elements, \"$global:Demo/Banner\")?.name).toBe(\"Demo/Banner\");\n expect(GlobalElementId.rootOf(elements, \"missing\")).toBeNull();\n\n expect(headerId.owns(elements, \"$global:Demo/Header\")).toBe(true);\n expect(headerId.owns(elements, \"child\")).toBe(true);\n expect(headerId.owns(elements, \"$global:Demo/Footer\")).toBe(false);\n expect(headerId.owns(elements, \"root\")).toBe(false);\n });\n\n it(\"adds default instances only for globals without a stored instance\", () => {\n const empty = withGlobalElementDefaults({ elements: {}, bindings: {} }, components);\n\n expect(Object.keys(empty.elements)).toEqual([\"$global:Demo/Header\"]);\n expect(empty.elements[\"$global:Demo/Header\"]).toEqual({\n type: \"Webiny/Element\",\n id: \"$global:Demo/Header\",\n component: { name: \"Demo/Header\" }\n });\n expect(empty.bindings[\"$global:Demo/Header\"].inputs?.title?.static).toBe(\"Welcome\");\n\n const stored = {\n elements: { \"$global:Demo/Header\": element(\"$global:Demo/Header\") },\n bindings: { \"$global:Demo/Header\": { inputs: {} } }\n };\n expect(withGlobalElementDefaults(stored, components)).toBe(stored);\n });\n\n it(\"builds the same ids every time for a default instance with slot children\", () => {\n const footer: ComponentManifest = {\n name: \"Demo/Footer\",\n global: true,\n tags: [],\n inputs: [{ type: \"slot\", list: true, renderer: \"Webiny/Slot\", name: \"links\" }],\n defaults: {\n inputs: { links: [createElement({ component: banner.name })] }\n }\n };\n const withFooter = { ...components, [footer.name]: footer };\n\n const first = withGlobalElementDefaults({ elements: {}, bindings: {} }, withFooter);\n const second = withGlobalElementDefaults({ elements: {}, bindings: {} }, withFooter);\n\n const childIds = Object.keys(first.elements).filter(id => !GlobalElementId.isGlobal(id));\n expect(childIds).toHaveLength(1);\n expect(first.elements[childIds[0]].parent?.id).toBe(\"$global:Demo/Footer\");\n expect(second).toEqual(first);\n });\n\n it(\"keeps default ids apart for globals whose names differ only in punctuation\", () => {\n const slotGlobal = (name: string): ComponentManifest => ({\n name,\n global: true,\n tags: [],\n inputs: [{ type: \"slot\", list: true, renderer: \"Webiny/Slot\", name: \"links\" }],\n defaults: {\n inputs: { links: [createElement({ component: banner.name })] }\n }\n });\n const names = [\"Demo/Header\", \"Demo-Header\", \"Demo Header\", \"Demo_Header\"];\n const manifests = Object.fromEntries(names.map(name => [name, slotGlobal(name)]));\n\n const document = withGlobalElementDefaults(\n { elements: {}, bindings: {} },\n { ...manifests, [banner.name]: banner }\n );\n\n const childIds = Object.keys(document.elements).filter(id => !GlobalElementId.isGlobal(id));\n expect(childIds).toHaveLength(names.length);\n expect(childIds.map(id => document.elements[id].parent?.id).sort()).toEqual(\n names.map(name => `$global:${name}`).sort()\n );\n });\n\n it(\"keeps overrides of a global without a stored instance on top of its defaults\", () => {\n const document = withGlobalElementDefaults(\n {\n elements: {},\n bindings: {\n \"$global:Demo/Header\": {\n inputs: { title: { id: \"x\", type: \"text\", static: \"Overridden\" } }\n }\n }\n },\n components\n );\n\n expect(document.elements[\"$global:Demo/Header\"]).toBeDefined();\n expect(document.bindings[\"$global:Demo/Header\"].inputs?.title?.static).toBe(\"Overridden\");\n });\n\n it(\"keeps the default styles of a global without a stored instance when one of its inputs is overridden\", () => {\n const id = \"$global:Demo/Header\";\n const styled = {\n ...components,\n [header.name]: {\n ...header,\n defaults: {\n styles: { color: \"red\" },\n overrides: { mobile: { styles: { color: \"blue\" } } }\n }\n }\n };\n const defaults = withGlobalElementDefaults({ elements: {}, bindings: {} }, styled);\n const document = withGlobalElementDefaults(\n {\n elements: {},\n bindings: {\n [id]: {\n inputs: { title: { id: \"x\", type: \"text\", static: \"Overridden\" } },\n styles: {},\n overrides: {}\n }\n }\n },\n styled\n );\n\n expect(defaults.bindings[id].styles?.color).toEqual({ static: \"red\" });\n expect(document.bindings[id].inputs?.title?.static).toBe(\"Overridden\");\n expect(document.bindings[id].styles).toEqual(defaults.bindings[id].styles);\n expect(document.bindings[id].overrides).toEqual(defaults.bindings[id].overrides);\n });\n\n it(\"keeps the global flag on the manifest\", () => {\n const Header = (_props: { inputs: { title: string } }) => null;\n const { manifest } = createComponent(Header, {\n name: \"Demo/Header\",\n global: true,\n inputs: [createTextInput({ name: \"title\" })]\n });\n\n expect(manifest.global).toBe(true);\n });\n});\n"],"names":["header","banner","components","element","id","parentId","undefined","describe","it","expect","GlobalElementId","elements","placement","instance","other","document","page","globals","Object","headerId","empty","withGlobalElementDefaults","stored","footer","createElement","withFooter","first","second","childIds","slotGlobal","name","names","manifests","styled","defaults","Header","_props","manifest","createComponent","createTextInput"],"mappings":";;;;;;AAQA,MAAMA,SAA4B;IAC9B,MAAM;IACN,QAAQ;IACR,MAAM,EAAE;IACR,QAAQ;QAAC;YAAE,MAAM;YAAQ,UAAU;YAAgB,MAAM;YAAS,cAAc;QAAU;KAAE;AAChG;AAEA,MAAMC,SAA4B;IAC9B,MAAM;IACN,MAAM,EAAE;IACR,QAAQ;QAAC;YAAE,MAAM;YAAQ,UAAU;YAAgB,MAAM;QAAW;KAAE;AAC1E;AAEA,MAAMC,aAAa;IAAE,CAACF,OAAO,IAAI,CAAC,EAAEA;IAAQ,CAACC,OAAO,IAAI,CAAC,EAAEA;AAAO;AAElE,MAAME,8BAAU,CAACC,IAAYC,WAAuB;QAChD,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AO,OAAO,CAAC;YAAE,QAAQ;QAAM;QACpEK,OAAOM,SAAS,QAAQ,CAACX,GAAG,CAAC,MAAM,EAAE,OAAO,QAAQ,IAAI,CAAC;QACzDK,OAAOM,SAAS,QAAQ,CAACX,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC8B,SAAS,QAAQ,CAAC9B,GAAG,CAAC,MAAM;QACzEK,OAAOM,SAAS,QAAQ,CAACX,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC8B,SAAS,QAAQ,CAAC9B,GAAG,CAAC,SAAS;IACnF;IAEAI,GAAG,yCAAyC;QACxC,MAAM2B,SAAS,CAACC,SAA0C;QAC1D,MAAM,EAAEC,QAAQ,EAAE,GAAGC,gBAAgBH,QAAQ;YACzC,MAAM;YACN,QAAQ;YACR,QAAQ;gBAACI,gBAAgB;oBAAE,MAAM;gBAAQ;aAAG;QAChD;QAEA9B,OAAO4B,SAAS,MAAM,EAAE,IAAI,CAAC;IACjC;AACJ"}
|
package/headersProvider.d.ts
CHANGED
package/headersProvider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headersProvider.js","sources":["../src/headersProvider.ts"],"sourcesContent":["type HeadersProvider = () => Promise<Headers>;\n\nlet headersProvider: HeadersProvider;\n\nexport const setHeadersProvider = (provider: HeadersProvider) => {\n headersProvider = provider;\n};\n\nexport const getHeadersProvider = () => headersProvider;\n"],"names":["headersProvider","setHeadersProvider","provider","getHeadersProvider"],"mappings":"AAEA,IAAIA;AAEG,MAAMC,qBAAqB,CAACC;IAC/BF,kBAAkBE;AACtB;AAEO,MAAMC,qBAAqB,IAAMH"}
|
|
1
|
+
{"version":3,"file":"headersProvider.js","sources":["../src/headersProvider.ts"],"sourcesContent":["export type HeadersProvider = () => Promise<Headers>;\n\nlet headersProvider: HeadersProvider;\n\nexport const setHeadersProvider = (provider: HeadersProvider) => {\n headersProvider = provider;\n};\n\nexport const getHeadersProvider = () => headersProvider;\n"],"names":["headersProvider","setHeadersProvider","provider","getHeadersProvider"],"mappings":"AAEA,IAAIA;AAEG,MAAMC,qBAAqB,CAACC;IAC/BF,kBAAkBE;AACtB;AAEO,MAAMC,qBAAqB,IAAMH"}
|
package/index.d.ts
CHANGED
|
@@ -3,11 +3,15 @@ export * from "./EditingSdk.js";
|
|
|
3
3
|
export * from "./LiveSdk.js";
|
|
4
4
|
export * from "./NullSdk.js";
|
|
5
5
|
export * from "./ContentSdk.js";
|
|
6
|
+
export * from "./createContentClient.js";
|
|
6
7
|
export * from "./Environment.js";
|
|
7
8
|
export * from "./DocumentStore.js";
|
|
8
9
|
export * from "./Logger.js";
|
|
9
10
|
export * from "./FunctionConverter.js";
|
|
10
11
|
export * from "./createInput.js";
|
|
12
|
+
export * from "./contentEntry/resolveContentEntry.js";
|
|
13
|
+
export * from "./contentEntry/ContentEntryCache.js";
|
|
14
|
+
export * from "./contentEntry/ContentEntryBindingsResolver.js";
|
|
11
15
|
export * from "./createComponent.js";
|
|
12
16
|
export * from "./image/index.js";
|
|
13
17
|
export * from "./asset/index.js";
|
|
@@ -17,6 +21,9 @@ export * from "./messenger/Messenger.js";
|
|
|
17
21
|
export * from "./messenger/MessageOrigin.js";
|
|
18
22
|
export type * from "./types.js";
|
|
19
23
|
export * from "./DocumentStoreManager.js";
|
|
24
|
+
export * from "./ComponentRegistry.js";
|
|
25
|
+
export * from "./componentLoader/index.js";
|
|
26
|
+
export * from "./dataProviders/ApiClient.js";
|
|
20
27
|
export * from "./BindingsProcessor.js";
|
|
21
28
|
export * from "./ResizeObserver.js";
|
|
22
29
|
export * from "./BindingsResolver.js";
|
|
@@ -26,6 +33,7 @@ export * from "./jsonPatch.js";
|
|
|
26
33
|
export * from "./headersProvider.js";
|
|
27
34
|
export * from "./experiments/index.js";
|
|
28
35
|
export * from "./ComponentManifestToAstConverter.js";
|
|
36
|
+
export * from "./radioOptionInputs.js";
|
|
29
37
|
export * from "./findMatchingAstNode.js";
|
|
30
38
|
export * from "./InheritanceProcessor.js";
|
|
31
39
|
export * from "./InputBindingsProcessor.js";
|
|
@@ -33,4 +41,10 @@ export * from "./StylesBindingsProcessor.js";
|
|
|
33
41
|
export * from "./ElementFactory.js";
|
|
34
42
|
export * from "./ConstraintEvaluator.js";
|
|
35
43
|
export * from "./generateElementId.js";
|
|
44
|
+
export * from "./globalElements.js";
|
|
45
|
+
export * from "./ElementBindings.js";
|
|
46
|
+
export * from "./GlobalComponentLanguage.js";
|
|
47
|
+
export * from "./LayoutContentArea.js";
|
|
48
|
+
export * from "./createGlobalElementDocument.js";
|
|
49
|
+
export * from "./withGlobalElementDefaults.js";
|
|
36
50
|
export { StyleSettings } from "./constants.js";
|
package/index.js
CHANGED
|
@@ -3,11 +3,15 @@ export * from "./EditingSdk.js";
|
|
|
3
3
|
export * from "./LiveSdk.js";
|
|
4
4
|
export * from "./NullSdk.js";
|
|
5
5
|
export * from "./ContentSdk.js";
|
|
6
|
+
export * from "./createContentClient.js";
|
|
6
7
|
export * from "./Environment.js";
|
|
7
8
|
export * from "./DocumentStore.js";
|
|
8
9
|
export * from "./Logger.js";
|
|
9
10
|
export * from "./FunctionConverter.js";
|
|
10
11
|
export * from "./createInput.js";
|
|
12
|
+
export * from "./contentEntry/resolveContentEntry.js";
|
|
13
|
+
export * from "./contentEntry/ContentEntryCache.js";
|
|
14
|
+
export * from "./contentEntry/ContentEntryBindingsResolver.js";
|
|
11
15
|
export * from "./createComponent.js";
|
|
12
16
|
export * from "./image/index.js";
|
|
13
17
|
export * from "./asset/index.js";
|
|
@@ -16,6 +20,9 @@ export * from "./ViewportManager.js";
|
|
|
16
20
|
export * from "./messenger/Messenger.js";
|
|
17
21
|
export * from "./messenger/MessageOrigin.js";
|
|
18
22
|
export * from "./DocumentStoreManager.js";
|
|
23
|
+
export * from "./ComponentRegistry.js";
|
|
24
|
+
export * from "./componentLoader/index.js";
|
|
25
|
+
export * from "./dataProviders/ApiClient.js";
|
|
19
26
|
export * from "./BindingsProcessor.js";
|
|
20
27
|
export * from "./ResizeObserver.js";
|
|
21
28
|
export * from "./BindingsResolver.js";
|
|
@@ -25,6 +32,7 @@ export * from "./jsonPatch.js";
|
|
|
25
32
|
export * from "./headersProvider.js";
|
|
26
33
|
export * from "./experiments/index.js";
|
|
27
34
|
export * from "./ComponentManifestToAstConverter.js";
|
|
35
|
+
export * from "./radioOptionInputs.js";
|
|
28
36
|
export * from "./findMatchingAstNode.js";
|
|
29
37
|
export * from "./InheritanceProcessor.js";
|
|
30
38
|
export * from "./InputBindingsProcessor.js";
|
|
@@ -32,4 +40,10 @@ export * from "./StylesBindingsProcessor.js";
|
|
|
32
40
|
export * from "./ElementFactory.js";
|
|
33
41
|
export * from "./ConstraintEvaluator.js";
|
|
34
42
|
export * from "./generateElementId.js";
|
|
43
|
+
export * from "./globalElements.js";
|
|
44
|
+
export * from "./ElementBindings.js";
|
|
45
|
+
export * from "./GlobalComponentLanguage.js";
|
|
46
|
+
export * from "./LayoutContentArea.js";
|
|
47
|
+
export * from "./createGlobalElementDocument.js";
|
|
48
|
+
export * from "./withGlobalElementDefaults.js";
|
|
35
49
|
export { StyleSettings } from "./constants.js";
|
package/messages.d.ts
CHANGED
|
@@ -9,3 +9,6 @@ export declare const PREVIEW_ELEMENT_POSITIONS = "preview.element.positions";
|
|
|
9
9
|
export declare const PREVIEW_ELEMENT_CLICK = "preview.element.click";
|
|
10
10
|
export declare const PREVIEW_ELEMENT_ENTER = "preview.element.enter";
|
|
11
11
|
export declare const PREVIEW_ELEMENT_LEAVE = "preview.element.leave";
|
|
12
|
+
export declare const ELEMENT_SELECTED = "element.selected";
|
|
13
|
+
export declare const ELEMENT_DESELECTED = "element.deselected";
|
|
14
|
+
export declare const PREVIEW_DATA = "preview.data";
|
package/messages.js
CHANGED
|
@@ -9,6 +9,9 @@ const PREVIEW_ELEMENT_POSITIONS = "preview.element.positions";
|
|
|
9
9
|
const PREVIEW_ELEMENT_CLICK = "preview.element.click";
|
|
10
10
|
const PREVIEW_ELEMENT_ENTER = "preview.element.enter";
|
|
11
11
|
const PREVIEW_ELEMENT_LEAVE = "preview.element.leave";
|
|
12
|
-
|
|
12
|
+
const ELEMENT_SELECTED = "element.selected";
|
|
13
|
+
const ELEMENT_DESELECTED = "element.deselected";
|
|
14
|
+
const PREVIEW_DATA = "preview.data";
|
|
15
|
+
export { DOCUMENT_PATCH, DOCUMENT_SET, ELEMENT_DESELECTED, ELEMENT_SELECTED, PREVIEW_COMPONENTGROUP_REGISTER, PREVIEW_COMPONENT_REGISTER, PREVIEW_DATA, PREVIEW_ELEMENT_CLICK, PREVIEW_ELEMENT_ENTER, PREVIEW_ELEMENT_LEAVE, PREVIEW_ELEMENT_POSITIONS, PREVIEW_READY, PREVIEW_VIEWPORT_CHANGE_END, PREVIEW_VIEWPORT_CHANGE_START };
|
|
13
16
|
|
|
14
17
|
//# sourceMappingURL=messages.js.map
|
package/messages.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","sources":["../src/messages.ts"],"sourcesContent":["export const DOCUMENT_SET = \"document.set\";\nexport const DOCUMENT_PATCH = \"document.patch\";\nexport const PREVIEW_COMPONENT_REGISTER = \"preview.component.register\";\nexport const PREVIEW_READY = \"preview.ready\";\nexport const PREVIEW_COMPONENTGROUP_REGISTER = \"preview.componentGroup.register\";\nexport const PREVIEW_VIEWPORT_CHANGE_START = \"preview.viewport.change.start\";\nexport const PREVIEW_VIEWPORT_CHANGE_END = \"preview.viewport.change.end\";\nexport const PREVIEW_ELEMENT_POSITIONS = \"preview.element.positions\";\nexport const PREVIEW_ELEMENT_CLICK = \"preview.element.click\";\nexport const PREVIEW_ELEMENT_ENTER = \"preview.element.enter\";\nexport const PREVIEW_ELEMENT_LEAVE = \"preview.element.leave\";\n"],"names":["DOCUMENT_SET","DOCUMENT_PATCH","PREVIEW_COMPONENT_REGISTER","PREVIEW_READY","PREVIEW_COMPONENTGROUP_REGISTER","PREVIEW_VIEWPORT_CHANGE_START","PREVIEW_VIEWPORT_CHANGE_END","PREVIEW_ELEMENT_POSITIONS","PREVIEW_ELEMENT_CLICK","PREVIEW_ELEMENT_ENTER","PREVIEW_ELEMENT_LEAVE"],"mappings":"AAAO,MAAMA,eAAe;AACrB,MAAMC,iBAAiB;AACvB,MAAMC,6BAA6B;AACnC,MAAMC,gBAAgB;AACtB,MAAMC,kCAAkC;AACxC,MAAMC,gCAAgC;AACtC,MAAMC,8BAA8B;AACpC,MAAMC,4BAA4B;AAClC,MAAMC,wBAAwB;AAC9B,MAAMC,wBAAwB;AAC9B,MAAMC,wBAAwB"}
|
|
1
|
+
{"version":3,"file":"messages.js","sources":["../src/messages.ts"],"sourcesContent":["export const DOCUMENT_SET = \"document.set\";\nexport const DOCUMENT_PATCH = \"document.patch\";\nexport const PREVIEW_COMPONENT_REGISTER = \"preview.component.register\";\nexport const PREVIEW_READY = \"preview.ready\";\nexport const PREVIEW_COMPONENTGROUP_REGISTER = \"preview.componentGroup.register\";\nexport const PREVIEW_VIEWPORT_CHANGE_START = \"preview.viewport.change.start\";\nexport const PREVIEW_VIEWPORT_CHANGE_END = \"preview.viewport.change.end\";\nexport const PREVIEW_ELEMENT_POSITIONS = \"preview.element.positions\";\nexport const PREVIEW_ELEMENT_CLICK = \"preview.element.click\";\nexport const PREVIEW_ELEMENT_ENTER = \"preview.element.enter\";\nexport const PREVIEW_ELEMENT_LEAVE = \"preview.element.leave\";\nexport const ELEMENT_SELECTED = \"element.selected\";\nexport const ELEMENT_DESELECTED = \"element.deselected\";\nexport const PREVIEW_DATA = \"preview.data\";\n"],"names":["DOCUMENT_SET","DOCUMENT_PATCH","PREVIEW_COMPONENT_REGISTER","PREVIEW_READY","PREVIEW_COMPONENTGROUP_REGISTER","PREVIEW_VIEWPORT_CHANGE_START","PREVIEW_VIEWPORT_CHANGE_END","PREVIEW_ELEMENT_POSITIONS","PREVIEW_ELEMENT_CLICK","PREVIEW_ELEMENT_ENTER","PREVIEW_ELEMENT_LEAVE","ELEMENT_SELECTED","ELEMENT_DESELECTED","PREVIEW_DATA"],"mappings":"AAAO,MAAMA,eAAe;AACrB,MAAMC,iBAAiB;AACvB,MAAMC,6BAA6B;AACnC,MAAMC,gBAAgB;AACtB,MAAMC,kCAAkC;AACxC,MAAMC,gCAAgC;AACtC,MAAMC,8BAA8B;AACpC,MAAMC,4BAA4B;AAClC,MAAMC,wBAAwB;AAC9B,MAAMC,wBAAwB;AAC9B,MAAMC,wBAAwB;AAC9B,MAAMC,mBAAmB;AACzB,MAAMC,qBAAqB;AAC3B,MAAMC,eAAe"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/website-builder-sdk",
|
|
3
|
-
"version": "6.6.0-alpha.
|
|
3
|
+
"version": "6.6.0-alpha.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,27 +12,27 @@
|
|
|
12
12
|
"author": "Pavel Denisjuk",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@webiny/sdk": "6.6.0-alpha.
|
|
15
|
+
"@webiny/sdk": "6.6.0-alpha.11",
|
|
16
16
|
"csstype": "3.2.3",
|
|
17
17
|
"deep-equal": "2.2.3",
|
|
18
18
|
"deepmerge": "4.3.1",
|
|
19
19
|
"fast-json-patch": "3.1.1",
|
|
20
20
|
"fast-json-stable-stringify": "2.1.0",
|
|
21
|
-
"is-hotkey": "0.2.
|
|
21
|
+
"is-hotkey": "0.2.1",
|
|
22
22
|
"lodash": "4.18.1",
|
|
23
|
-
"matcher": "
|
|
24
|
-
"mobx": "7.
|
|
25
|
-
"nanoid": "6.0.
|
|
23
|
+
"matcher": "7.0.0",
|
|
24
|
+
"mobx": "7.1.4",
|
|
25
|
+
"nanoid": "6.0.2",
|
|
26
26
|
"nanoid-dictionary": "5.0.0",
|
|
27
|
-
"pino": "10.
|
|
28
|
-
"pino-pretty": "13.
|
|
27
|
+
"pino": "10.4.0",
|
|
28
|
+
"pino-pretty": "13.2.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/deep-equal": "1.0.4",
|
|
32
32
|
"@types/is-hotkey": "0.1.10",
|
|
33
|
-
"@webiny/build-tools": "6.6.0-alpha.
|
|
33
|
+
"@webiny/build-tools": "6.6.0-alpha.11",
|
|
34
34
|
"typescript": "7.0.2",
|
|
35
|
-
"vitest": "
|
|
35
|
+
"vitest": "5.0.5"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type InputAstNode } from "./ComponentManifestToAstConverter.js";
|
|
2
|
+
/**
|
|
3
|
+
* Whether the node is a radio whose options carry inputs, i.e. an object node with a `value` child
|
|
4
|
+
* (see `ComponentManifestToAstConverter`).
|
|
5
|
+
*/
|
|
6
|
+
export declare function hasRadioOptionInputs(node: InputAstNode): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The child node that stores the selected option of a radio with option inputs.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getRadioValueNode(node: InputAstNode): InputAstNode | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* The selected option of a radio with option inputs: the stored `value` of the radio object, or its default.
|
|
13
|
+
* Pass the radio's value resolved for the active breakpoint (the renderer's `value`), so a breakpoint
|
|
14
|
+
* override of the selection is shown.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getSelectedRadioValue(node: InputAstNode, radioValue: Record<string, unknown> | undefined): string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* The nodes of one option's inputs, with that option's definitions, at the radio's shared paths.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getRadioOptionNodes(node: InputAstNode, optionValue: string | undefined): InputAstNode[];
|
|
21
|
+
/**
|
|
22
|
+
* The radio object's next value with another option selected; the option inputs keep their values.
|
|
23
|
+
*/
|
|
24
|
+
export declare function withRadioValue(current: Record<string, unknown> | undefined, optionValue: string): Record<string, unknown>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ComponentManifestToAstConverter, RADIO_VALUE_INPUT } from "./ComponentManifestToAstConverter.js";
|
|
2
|
+
function hasRadioOptionInputs(node) {
|
|
3
|
+
return "radio" === node.input.type && "object" === node.type;
|
|
4
|
+
}
|
|
5
|
+
function getRadioValueNode(node) {
|
|
6
|
+
return node.children.find((child)=>child.name === RADIO_VALUE_INPUT);
|
|
7
|
+
}
|
|
8
|
+
function getSelectedRadioValue(node, radioValue) {
|
|
9
|
+
const valueNode = getRadioValueNode(node);
|
|
10
|
+
if (!valueNode) return;
|
|
11
|
+
const stored = radioValue?.[RADIO_VALUE_INPUT];
|
|
12
|
+
return stored ?? valueNode.input.defaultValue;
|
|
13
|
+
}
|
|
14
|
+
function getRadioOptionNodes(node, optionValue) {
|
|
15
|
+
if (void 0 === optionValue) return [];
|
|
16
|
+
return ComponentManifestToAstConverter.convertRadioOptionInputs(node, optionValue);
|
|
17
|
+
}
|
|
18
|
+
function withRadioValue(current, optionValue) {
|
|
19
|
+
return {
|
|
20
|
+
...current,
|
|
21
|
+
[RADIO_VALUE_INPUT]: optionValue
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export { getRadioOptionNodes, getRadioValueNode, getSelectedRadioValue, hasRadioOptionInputs, withRadioValue };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=radioOptionInputs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radioOptionInputs.js","sources":["../src/radioOptionInputs.ts"],"sourcesContent":["import {\n ComponentManifestToAstConverter,\n RADIO_VALUE_INPUT,\n type InputAstNode\n} from \"./ComponentManifestToAstConverter.js\";\n\n/**\n * Whether the node is a radio whose options carry inputs, i.e. an object node with a `value` child\n * (see `ComponentManifestToAstConverter`).\n */\nexport function hasRadioOptionInputs(node: InputAstNode): boolean {\n return node.input.type === \"radio\" && node.type === \"object\";\n}\n\n/**\n * The child node that stores the selected option of a radio with option inputs.\n */\nexport function getRadioValueNode(node: InputAstNode): InputAstNode | undefined {\n return node.children.find(child => child.name === RADIO_VALUE_INPUT);\n}\n\n/**\n * The selected option of a radio with option inputs: the stored `value` of the radio object, or its default.\n * Pass the radio's value resolved for the active breakpoint (the renderer's `value`), so a breakpoint\n * override of the selection is shown.\n */\nexport function getSelectedRadioValue(\n node: InputAstNode,\n radioValue: Record<string, unknown> | undefined\n): string | undefined {\n const valueNode = getRadioValueNode(node);\n if (!valueNode) {\n return undefined;\n }\n const stored = radioValue?.[RADIO_VALUE_INPUT];\n return (stored ?? valueNode.input.defaultValue) as string | undefined;\n}\n\n/**\n * The nodes of one option's inputs, with that option's definitions, at the radio's shared paths.\n */\nexport function getRadioOptionNodes(node: InputAstNode, optionValue: string | undefined) {\n if (optionValue === undefined) {\n return [];\n }\n return ComponentManifestToAstConverter.convertRadioOptionInputs(node, optionValue);\n}\n\n/**\n * The radio object's next value with another option selected; the option inputs keep their values.\n */\nexport function withRadioValue(\n current: Record<string, unknown> | undefined,\n optionValue: string\n): Record<string, unknown> {\n return { ...current, [RADIO_VALUE_INPUT]: optionValue };\n}\n"],"names":["hasRadioOptionInputs","node","getRadioValueNode","child","RADIO_VALUE_INPUT","getSelectedRadioValue","radioValue","valueNode","stored","getRadioOptionNodes","optionValue","undefined","ComponentManifestToAstConverter","withRadioValue","current"],"mappings":";AAUO,SAASA,qBAAqBC,IAAkB;IACnD,OAAOA,AAAoB,YAApBA,KAAK,KAAK,CAAC,IAAI,IAAgBA,AAAc,aAAdA,KAAK,IAAI;AACnD;AAKO,SAASC,kBAAkBD,IAAkB;IAChD,OAAOA,KAAK,QAAQ,CAAC,IAAI,CAACE,CAAAA,QAASA,MAAM,IAAI,KAAKC;AACtD;AAOO,SAASC,sBACZJ,IAAkB,EAClBK,UAA+C;IAE/C,MAAMC,YAAYL,kBAAkBD;IACpC,IAAI,CAACM,WACD;IAEJ,MAAMC,SAASF,YAAY,CAACF,kBAAkB;IAC9C,OAAQI,UAAUD,UAAU,KAAK,CAAC,YAAY;AAClD;AAKO,SAASE,oBAAoBR,IAAkB,EAAES,WAA+B;IACnF,IAAIA,AAAgBC,WAAhBD,aACA,OAAO,EAAE;IAEb,OAAOE,gCAAgC,wBAAwB,CAACX,MAAMS;AAC1E;AAKO,SAASG,eACZC,OAA4C,EAC5CJ,WAAmB;IAEnB,OAAO;QAAE,GAAGI,OAAO;QAAE,CAACV,kBAAkB,EAAEM;IAAY;AAC1D"}
|