@webiny/website-builder-sdk 6.3.0 → 6.4.0-beta.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/BindingsApi.js +29 -36
- package/BindingsApi.js.map +1 -1
- package/BindingsProcessor.js +34 -43
- package/BindingsProcessor.js.map +1 -1
- package/BindingsProcessor.test.js +82 -78
- package/BindingsProcessor.test.js.map +1 -1
- package/BindingsResolver.js +92 -119
- package/BindingsResolver.js.map +1 -1
- package/BindingsResolver.test.js +399 -363
- package/BindingsResolver.test.js.map +1 -1
- package/ComponentInputTraverser.js +28 -49
- package/ComponentInputTraverser.js.map +1 -1
- package/ComponentManifestToAstConverter.js +20 -21
- package/ComponentManifestToAstConverter.js.map +1 -1
- package/ComponentRegistry.js +26 -45
- package/ComponentRegistry.js.map +1 -1
- package/ComponentResolver.js +25 -29
- package/ComponentResolver.js.map +1 -1
- package/ConstraintEvaluator.js +246 -353
- package/ConstraintEvaluator.js.map +1 -1
- package/ConstraintEvaluator.test.js +1616 -1438
- package/ConstraintEvaluator.test.js.map +1 -1
- package/ContentSdk.js +83 -90
- package/ContentSdk.js.map +1 -1
- package/DocumentStore.js +47 -59
- package/DocumentStore.js.map +1 -1
- package/DocumentStoreManager.js +17 -16
- package/DocumentStoreManager.js.map +1 -1
- package/EditingSdk.js +87 -121
- package/EditingSdk.js.map +1 -1
- package/ElementFactory.js +126 -174
- package/ElementFactory.js.map +1 -1
- package/ElementFactory.test.js +234 -263
- package/ElementFactory.test.js.map +1 -1
- package/Environment.js +18 -19
- package/Environment.js.map +1 -1
- package/FunctionConverter.js +8 -7
- package/FunctionConverter.js.map +1 -1
- package/HashObject.js +11 -26
- package/HashObject.js.map +1 -1
- package/HotkeyManager.js +40 -47
- package/HotkeyManager.js.map +1 -1
- package/IBindingsUpdater.js +0 -3
- package/IRedirects.js +0 -3
- package/InheritanceProcessor.js +99 -139
- package/InheritanceProcessor.js.map +1 -1
- package/InheritanceProcessor.test.js +178 -179
- package/InheritanceProcessor.test.js.map +1 -1
- package/InheritedValueResolver.js +15 -20
- package/InheritedValueResolver.js.map +1 -1
- package/InputBindingsProcessor.js +187 -307
- package/InputBindingsProcessor.js.map +1 -1
- package/InputsBindingsProcessor.test.js +334 -315
- package/InputsBindingsProcessor.test.js.map +1 -1
- package/InputsUpdater.js +23 -26
- package/InputsUpdater.js.map +1 -1
- package/LiveSdk.js +12 -13
- package/LiveSdk.js.map +1 -1
- package/Logger.js +9 -8
- package/Logger.js.map +1 -1
- package/MouseTracker.js +77 -83
- package/MouseTracker.js.map +1 -1
- package/NullSdk.js +22 -21
- package/NullSdk.js.map +1 -1
- package/PreviewDocument.js +27 -30
- package/PreviewDocument.js.map +1 -1
- package/PreviewSdk.js +16 -17
- package/PreviewSdk.js.map +1 -1
- package/PreviewViewport.js +51 -63
- package/PreviewViewport.js.map +1 -1
- package/ResizeObserver.js +24 -31
- package/ResizeObserver.js.map +1 -1
- package/StylesBindingsProcessor.js +40 -79
- package/StylesBindingsProcessor.js.map +1 -1
- package/StylesUpdater.js +20 -25
- package/StylesUpdater.js.map +1 -1
- package/Theme.js +28 -25
- package/Theme.js.map +1 -1
- package/ViewportManager.js +89 -101
- package/ViewportManager.js.map +1 -1
- package/constants.js +7 -6
- package/constants.js.map +1 -1
- package/createElement.js +5 -6
- package/createElement.js.map +1 -1
- package/createInput.js +85 -143
- package/createInput.js.map +1 -1
- package/createTheme.js +2 -3
- package/createTheme.js.map +1 -1
- package/dataProviders/ApiClient.js +40 -49
- package/dataProviders/ApiClient.js.map +1 -1
- package/dataProviders/DefaultDataProvider.js +56 -58
- package/dataProviders/DefaultDataProvider.js.map +1 -1
- package/dataProviders/GET_PAGE_BY_ID.js +2 -1
- package/dataProviders/GET_PAGE_BY_ID.js.map +1 -1
- package/dataProviders/GET_PAGE_BY_PATH.js +2 -1
- package/dataProviders/GET_PAGE_BY_PATH.js.map +1 -1
- package/dataProviders/LIST_PUBLISHED_PAGES.js +2 -1
- package/dataProviders/LIST_PUBLISHED_PAGES.js.map +1 -1
- package/dataProviders/NullDataProvider.js +21 -20
- package/dataProviders/NullDataProvider.js.map +1 -1
- package/dataProviders/RedirectsProvider.js +24 -27
- package/dataProviders/RedirectsProvider.js.map +1 -1
- package/defaultBreakpoints.js +23 -22
- package/defaultBreakpoints.js.map +1 -1
- package/documentOperations/$addElementReferenceToParent.js +29 -32
- package/documentOperations/$addElementReferenceToParent.js.map +1 -1
- package/documentOperations/AddElement.js +8 -7
- package/documentOperations/AddElement.js.map +1 -1
- package/documentOperations/AddToParent.js +14 -13
- package/documentOperations/AddToParent.js.map +1 -1
- package/documentOperations/IDocumentOperation.js +0 -3
- package/documentOperations/RemoveElement.js +9 -15
- package/documentOperations/RemoveElement.js.map +1 -1
- package/documentOperations/SetGlobalInputBinding.js +23 -22
- package/documentOperations/SetGlobalInputBinding.js.map +1 -1
- package/documentOperations/SetGlobalStyleBinding.js +23 -23
- package/documentOperations/SetGlobalStyleBinding.js.map +1 -1
- package/documentOperations/SetInputBindingOverride.js +30 -29
- package/documentOperations/SetInputBindingOverride.js.map +1 -1
- package/documentOperations/SetStyleBindingOverride.js +30 -31
- package/documentOperations/SetStyleBindingOverride.js.map +1 -1
- package/documentOperations/index.js +9 -8
- package/documentOperations/index.js.map +1 -1
- package/findMatchingAstNode.js +11 -13
- package/findMatchingAstNode.js.map +1 -1
- package/generateElementId.js +2 -1
- package/generateElementId.js.map +1 -1
- package/headersProvider.js +4 -3
- package/headersProvider.js.map +1 -1
- package/index.js +0 -2
- package/jsonPatch.js +5 -9
- package/jsonPatch.js.map +1 -1
- package/messages.js +12 -11
- package/messages.js.map +1 -1
- package/messenger/MessageOrigin.js +12 -11
- package/messenger/MessageOrigin.js.map +1 -1
- package/messenger/Messenger.js +58 -69
- package/messenger/Messenger.js.map +1 -1
- package/messenger/index.js +0 -2
- package/package.json +5 -5
- package/registerComponentGroup.js +5 -6
- package/registerComponentGroup.js.map +1 -1
- package/types/ShorthandCssProperties.js +0 -3
- package/types/WebsiteBuilderTheme.js +0 -3
- package/types.d.ts +3 -0
- package/types.js +0 -3
- package/IBindingsUpdater.js.map +0 -1
- package/IRedirects.js.map +0 -1
- package/documentOperations/IDocumentOperation.js.map +0 -1
- package/index.js.map +0 -1
- package/messenger/index.js.map +0 -1
- package/types/ShorthandCssProperties.js.map +0 -1
- package/types/WebsiteBuilderTheme.js.map +0 -1
- package/types.js.map +0 -1
package/PreviewSdk.js
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import { PreviewDocument } from "./PreviewDocument.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
class PreviewSdk {
|
|
3
|
+
constructor(dataProvider, liveSdk){
|
|
4
|
+
this.liveSdk = liveSdk;
|
|
5
|
+
this.dataProvider = dataProvider;
|
|
6
|
+
}
|
|
7
|
+
async getPage(path) {
|
|
8
|
+
const previewDocument = await PreviewDocument.createFromHeaders();
|
|
9
|
+
if (!previewDocument.matches({
|
|
10
|
+
type: "page",
|
|
11
|
+
path
|
|
12
|
+
})) return this.liveSdk.getPage(path);
|
|
13
|
+
return this.dataProvider.getPageById(previewDocument.getId());
|
|
14
|
+
}
|
|
15
|
+
async listPages(options) {
|
|
16
|
+
return this.liveSdk.listPages(options);
|
|
14
17
|
}
|
|
15
|
-
return this.dataProvider.getPageById(previewDocument.getId());
|
|
16
|
-
}
|
|
17
|
-
async listPages(options) {
|
|
18
|
-
return this.liveSdk.listPages(options);
|
|
19
|
-
}
|
|
20
18
|
}
|
|
19
|
+
export { PreviewSdk };
|
|
21
20
|
|
|
22
21
|
//# sourceMappingURL=PreviewSdk.js.map
|
package/PreviewSdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"PreviewSdk.js","sources":["../src/PreviewSdk.ts"],"sourcesContent":["import type {\n IContentSdk,\n IDataProvider,\n ListPagesOptions,\n ListPagesResult,\n PublicPage\n} from \"~/types.js\";\nimport { PreviewDocument } from \"~/PreviewDocument.js\";\n\nexport class PreviewSdk implements IContentSdk {\n private liveSdk: IContentSdk;\n private dataProvider: IDataProvider;\n\n constructor(dataProvider: IDataProvider, liveSdk: IContentSdk) {\n this.liveSdk = liveSdk;\n this.dataProvider = dataProvider;\n }\n\n async getPage(path: string): Promise<PublicPage | null> {\n const previewDocument = await PreviewDocument.createFromHeaders();\n if (!previewDocument.matches({ type: \"page\", path })) {\n return this.liveSdk.getPage(path);\n }\n return this.dataProvider.getPageById(previewDocument.getId());\n }\n\n async listPages(options?: ListPagesOptions): Promise<ListPagesResult> {\n return this.liveSdk.listPages(options);\n }\n}\n"],"names":["PreviewSdk","dataProvider","liveSdk","path","previewDocument","PreviewDocument","options"],"mappings":";AASO,MAAMA;IAIT,YAAYC,YAA2B,EAAEC,OAAoB,CAAE;QAC3D,IAAI,CAAC,OAAO,GAAGA;QACf,IAAI,CAAC,YAAY,GAAGD;IACxB;IAEA,MAAM,QAAQE,IAAY,EAA8B;QACpD,MAAMC,kBAAkB,MAAMC,gBAAgB,iBAAiB;QAC/D,IAAI,CAACD,gBAAgB,OAAO,CAAC;YAAE,MAAM;YAAQD;QAAK,IAC9C,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAACA;QAEhC,OAAO,IAAI,CAAC,YAAY,CAAC,WAAW,CAACC,gBAAgB,KAAK;IAC9D;IAEA,MAAM,UAAUE,OAA0B,EAA4B;QAClE,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAACA;IAClC;AACJ"}
|
package/PreviewViewport.js
CHANGED
|
@@ -1,68 +1,56 @@
|
|
|
1
1
|
import { viewportManager } from "./ViewportManager.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
2
|
+
class PreviewViewport {
|
|
3
|
+
getBoxes() {
|
|
4
|
+
const elementBoxes = {};
|
|
5
|
+
const elements = document.querySelectorAll("[data-element-id]");
|
|
6
|
+
elements.forEach((element)=>{
|
|
7
|
+
const id = element.getAttribute("data-element-id");
|
|
8
|
+
const depth = element.getAttribute("data-depth");
|
|
9
|
+
if (id) {
|
|
10
|
+
const rect = element.firstElementChild?.getBoundingClientRect();
|
|
11
|
+
if (!rect) return;
|
|
12
|
+
elementBoxes[id] = {
|
|
13
|
+
type: "element",
|
|
14
|
+
depth: parseInt(depth ?? "0"),
|
|
15
|
+
parentId: element.getAttribute("data-parent-id"),
|
|
16
|
+
parentSlot: element.getAttribute("data-parent-slot"),
|
|
17
|
+
parentIndex: parseInt(element.getAttribute("data-parent-index") ?? "0"),
|
|
18
|
+
top: rect.top,
|
|
19
|
+
left: rect.left,
|
|
20
|
+
width: rect.width,
|
|
21
|
+
height: rect.height
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const slotBoxes = {};
|
|
26
|
+
const elementSlots = document.querySelectorAll("[data-role='element-slot']");
|
|
27
|
+
elementSlots.forEach((element)=>{
|
|
28
|
+
const parentId = element.getAttribute("data-parent-id");
|
|
29
|
+
const slot = element.getAttribute("data-parent-slot");
|
|
30
|
+
const depth = element.getAttribute("data-depth");
|
|
31
|
+
const rect = element.getBoundingClientRect();
|
|
32
|
+
slotBoxes[`${parentId}:${slot}`] = {
|
|
33
|
+
type: "element-slot",
|
|
34
|
+
depth: parseInt(depth ?? "0"),
|
|
35
|
+
parentId: element.getAttribute("data-parent-id"),
|
|
36
|
+
parentSlot: element.getAttribute("data-parent-slot"),
|
|
37
|
+
parentIndex: parseInt(element.getAttribute("data-parent-index") ?? "0"),
|
|
38
|
+
top: rect.top,
|
|
39
|
+
left: rect.left,
|
|
40
|
+
width: rect.width,
|
|
41
|
+
height: rect.height
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
...elementBoxes,
|
|
46
|
+
...slotBoxes
|
|
29
47
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const elementSlots = document.querySelectorAll("[data-role='element-slot']");
|
|
36
|
-
elementSlots.forEach(element => {
|
|
37
|
-
const parentId = element.getAttribute("data-parent-id");
|
|
38
|
-
const slot = element.getAttribute("data-parent-slot");
|
|
39
|
-
const depth = element.getAttribute("data-depth");
|
|
40
|
-
|
|
41
|
-
// Get the bounding box relative to the viewport
|
|
42
|
-
const rect = element.getBoundingClientRect();
|
|
43
|
-
|
|
44
|
-
// Convert DOMRect to a plain object to ensure it can be serialized
|
|
45
|
-
slotBoxes[`${parentId}:${slot}`] = {
|
|
46
|
-
type: "element-slot",
|
|
47
|
-
depth: parseInt(depth ?? "0"),
|
|
48
|
-
parentId: element.getAttribute("data-parent-id"),
|
|
49
|
-
parentSlot: element.getAttribute("data-parent-slot"),
|
|
50
|
-
parentIndex: parseInt(element.getAttribute("data-parent-index") ?? "0"),
|
|
51
|
-
top: rect.top,
|
|
52
|
-
left: rect.left,
|
|
53
|
-
width: rect.width,
|
|
54
|
-
height: rect.height
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
return {
|
|
58
|
-
...elementBoxes,
|
|
59
|
-
...slotBoxes
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
getViewport() {
|
|
63
|
-
return viewportManager.getViewport();
|
|
64
|
-
}
|
|
65
|
-
destroy() {}
|
|
48
|
+
}
|
|
49
|
+
getViewport() {
|
|
50
|
+
return viewportManager.getViewport();
|
|
51
|
+
}
|
|
52
|
+
destroy() {}
|
|
66
53
|
}
|
|
54
|
+
export { PreviewViewport };
|
|
67
55
|
|
|
68
56
|
//# sourceMappingURL=PreviewViewport.js.map
|
package/PreviewViewport.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"PreviewViewport.js","sources":["../src/PreviewViewport.ts"],"sourcesContent":["import type { ElementBoxData, ElementSlotBoxData } from \"~/types.js\";\nimport { viewportManager } from \"./ViewportManager.js\";\n\nexport class PreviewViewport {\n getBoxes() {\n const elementBoxes: Record<string, ElementBoxData> = {};\n\n // Collect positions for all elements\n const elements = document.querySelectorAll(\"[data-element-id]\");\n\n elements.forEach(element => {\n const id = element.getAttribute(\"data-element-id\");\n const depth = element.getAttribute(\"data-depth\");\n if (id) {\n // Get the bounding box relative to the viewport\n const rect = element.firstElementChild?.getBoundingClientRect();\n\n if (!rect) {\n return;\n }\n\n // Convert DOMRect to a plain object to ensure it can be serialized\n elementBoxes[id] = {\n type: \"element\",\n depth: parseInt(depth ?? \"0\"),\n parentId: element.getAttribute(\"data-parent-id\")!,\n parentSlot: element.getAttribute(\"data-parent-slot\")!,\n parentIndex: parseInt(element.getAttribute(\"data-parent-index\") ?? \"0\"),\n top: rect.top,\n left: rect.left,\n width: rect.width,\n height: rect.height\n };\n }\n });\n\n // Collect positions for all element slots\n const slotBoxes: Record<string, ElementSlotBoxData> = {};\n\n const elementSlots = document.querySelectorAll(\"[data-role='element-slot']\");\n\n elementSlots.forEach(element => {\n const parentId = element.getAttribute(\"data-parent-id\");\n const slot = element.getAttribute(\"data-parent-slot\");\n const depth = element.getAttribute(\"data-depth\");\n\n // Get the bounding box relative to the viewport\n const rect = element.getBoundingClientRect();\n\n // Convert DOMRect to a plain object to ensure it can be serialized\n slotBoxes[`${parentId}:${slot}`] = {\n type: \"element-slot\",\n depth: parseInt(depth ?? \"0\"),\n parentId: element.getAttribute(\"data-parent-id\")!,\n parentSlot: element.getAttribute(\"data-parent-slot\")!,\n parentIndex: parseInt(element.getAttribute(\"data-parent-index\") ?? \"0\"),\n top: rect.top,\n left: rect.left,\n width: rect.width,\n height: rect.height\n };\n });\n\n return { ...elementBoxes, ...slotBoxes };\n }\n\n getViewport() {\n return viewportManager.getViewport();\n }\n\n destroy(): void {}\n}\n"],"names":["PreviewViewport","elementBoxes","elements","document","element","id","depth","rect","parseInt","slotBoxes","elementSlots","parentId","slot","viewportManager"],"mappings":";AAGO,MAAMA;IACT,WAAW;QACP,MAAMC,eAA+C,CAAC;QAGtD,MAAMC,WAAWC,SAAS,gBAAgB,CAAC;QAE3CD,SAAS,OAAO,CAACE,CAAAA;YACb,MAAMC,KAAKD,QAAQ,YAAY,CAAC;YAChC,MAAME,QAAQF,QAAQ,YAAY,CAAC;YACnC,IAAIC,IAAI;gBAEJ,MAAME,OAAOH,QAAQ,iBAAiB,EAAE;gBAExC,IAAI,CAACG,MACD;gBAIJN,YAAY,CAACI,GAAG,GAAG;oBACf,MAAM;oBACN,OAAOG,SAASF,SAAS;oBACzB,UAAUF,QAAQ,YAAY,CAAC;oBAC/B,YAAYA,QAAQ,YAAY,CAAC;oBACjC,aAAaI,SAASJ,QAAQ,YAAY,CAAC,wBAAwB;oBACnE,KAAKG,KAAK,GAAG;oBACb,MAAMA,KAAK,IAAI;oBACf,OAAOA,KAAK,KAAK;oBACjB,QAAQA,KAAK,MAAM;gBACvB;YACJ;QACJ;QAGA,MAAME,YAAgD,CAAC;QAEvD,MAAMC,eAAeP,SAAS,gBAAgB,CAAC;QAE/CO,aAAa,OAAO,CAACN,CAAAA;YACjB,MAAMO,WAAWP,QAAQ,YAAY,CAAC;YACtC,MAAMQ,OAAOR,QAAQ,YAAY,CAAC;YAClC,MAAME,QAAQF,QAAQ,YAAY,CAAC;YAGnC,MAAMG,OAAOH,QAAQ,qBAAqB;YAG1CK,SAAS,CAAC,GAAGE,SAAS,CAAC,EAAEC,MAAM,CAAC,GAAG;gBAC/B,MAAM;gBACN,OAAOJ,SAASF,SAAS;gBACzB,UAAUF,QAAQ,YAAY,CAAC;gBAC/B,YAAYA,QAAQ,YAAY,CAAC;gBACjC,aAAaI,SAASJ,QAAQ,YAAY,CAAC,wBAAwB;gBACnE,KAAKG,KAAK,GAAG;gBACb,MAAMA,KAAK,IAAI;gBACf,OAAOA,KAAK,KAAK;gBACjB,QAAQA,KAAK,MAAM;YACvB;QACJ;QAEA,OAAO;YAAE,GAAGN,YAAY;YAAE,GAAGQ,SAAS;QAAC;IAC3C;IAEA,cAAc;QACV,OAAOI,gBAAgB,WAAW;IACtC;IAEA,UAAgB,CAAC;AACrB"}
|
package/ResizeObserver.js
CHANGED
|
@@ -1,41 +1,34 @@
|
|
|
1
1
|
let resizeQueue = {};
|
|
2
2
|
const onChangeListeners = [];
|
|
3
|
-
const flushResizeQueue = ()
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
entry();
|
|
3
|
+
const flushResizeQueue = ()=>{
|
|
4
|
+
if (Object.entries(resizeQueue).length > 0) onChangeListeners.forEach((entry)=>{
|
|
5
|
+
entry();
|
|
7
6
|
});
|
|
8
|
-
|
|
9
|
-
resizeQueue = {};
|
|
7
|
+
resizeQueue = {};
|
|
10
8
|
};
|
|
11
9
|
let observer;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const el = entry.target;
|
|
21
|
-
const id = el.getAttribute("data-element-id");
|
|
22
|
-
if (id) {
|
|
23
|
-
resizeQueue[id] = el.getBoundingClientRect();
|
|
24
|
-
}
|
|
10
|
+
observer = "u" < typeof window ? {
|
|
11
|
+
observe: ()=>{},
|
|
12
|
+
unobserve: ()=>{}
|
|
13
|
+
} : new ResizeObserver((entries)=>{
|
|
14
|
+
for (const entry of entries){
|
|
15
|
+
const el = entry.target;
|
|
16
|
+
const id = el.getAttribute("data-element-id");
|
|
17
|
+
if (id) resizeQueue[id] = el.getBoundingClientRect();
|
|
25
18
|
}
|
|
26
19
|
requestAnimationFrame(flushResizeQueue);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
20
|
+
});
|
|
21
|
+
const resizeObserver = {
|
|
22
|
+
observe: (element)=>{
|
|
23
|
+
observer.observe(element);
|
|
24
|
+
},
|
|
25
|
+
unobserve: (element)=>{
|
|
26
|
+
observer.unobserve(element);
|
|
27
|
+
},
|
|
28
|
+
onChange: (cb)=>{
|
|
29
|
+
onChangeListeners.push(cb);
|
|
30
|
+
}
|
|
39
31
|
};
|
|
32
|
+
export { resizeObserver };
|
|
40
33
|
|
|
41
34
|
//# sourceMappingURL=ResizeObserver.js.map
|
package/ResizeObserver.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"ResizeObserver.js","sources":["../src/ResizeObserver.ts"],"sourcesContent":["let resizeQueue: Record<string, DOMRect> = {};\nconst onChangeListeners: Array<() => void> = [];\n\nconst flushResizeQueue = () => {\n if (Object.entries(resizeQueue).length > 0) {\n onChangeListeners.forEach(entry => {\n entry();\n });\n }\n resizeQueue = {};\n};\n\nlet observer: any;\n\nif (typeof window === \"undefined\") {\n observer = {\n observe: () => {},\n unobserve: () => {}\n };\n} else {\n observer = new ResizeObserver(entries => {\n for (const entry of entries) {\n const el = entry.target as HTMLElement;\n const id = el.getAttribute(\"data-element-id\");\n if (id) {\n resizeQueue[id] = el.getBoundingClientRect();\n }\n }\n requestAnimationFrame(flushResizeQueue);\n });\n}\n\nexport const resizeObserver = {\n observe: (element: HTMLElement) => {\n observer.observe(element);\n },\n unobserve: (element: HTMLElement) => {\n observer.unobserve(element);\n },\n onChange: (cb: () => void) => {\n onChangeListeners.push(cb);\n }\n};\n"],"names":["resizeQueue","onChangeListeners","flushResizeQueue","Object","entry","observer","window","ResizeObserver","entries","el","id","requestAnimationFrame","resizeObserver","element","cb"],"mappings":"AAAA,IAAIA,cAAuC,CAAC;AAC5C,MAAMC,oBAAuC,EAAE;AAE/C,MAAMC,mBAAmB;IACrB,IAAIC,OAAO,OAAO,CAACH,aAAa,MAAM,GAAG,GACrCC,kBAAkB,OAAO,CAACG,CAAAA;QACtBA;IACJ;IAEJJ,cAAc,CAAC;AACnB;AAEA,IAAIK;AAGAA,WADA,AAAkB,MAAlB,OAAOC,SACI;IACP,SAAS,KAAO;IAChB,WAAW,KAAO;AACtB,IAEW,IAAIC,eAAeC,CAAAA;IAC1B,KAAK,MAAMJ,SAASI,QAAS;QACzB,MAAMC,KAAKL,MAAM,MAAM;QACvB,MAAMM,KAAKD,GAAG,YAAY,CAAC;QAC3B,IAAIC,IACAV,WAAW,CAACU,GAAG,GAAGD,GAAG,qBAAqB;IAElD;IACAE,sBAAsBT;AAC1B;AAGG,MAAMU,iBAAiB;IAC1B,SAAS,CAACC;QACNR,SAAS,OAAO,CAACQ;IACrB;IACA,WAAW,CAACA;QACRR,SAAS,SAAS,CAACQ;IACvB;IACA,UAAU,CAACC;QACPb,kBAAkB,IAAI,CAACa;IAC3B;AACJ"}
|
|
@@ -2,90 +2,51 @@ import set from "lodash/set.js";
|
|
|
2
2
|
import unset from "lodash/unset.js";
|
|
3
3
|
import { InheritedValueResolver } from "./InheritedValueResolver.js";
|
|
4
4
|
import { StylesUpdater } from "./StylesUpdater.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* Converts flat style bindings into deep styles object (removes `.static`).
|
|
18
|
-
*/
|
|
19
|
-
toDeepStyles(styles = {}) {
|
|
20
|
-
const result = {};
|
|
21
|
-
Object.keys(styles).forEach(key => {
|
|
22
|
-
// @ts-expect-error Style keys cannot be indexed with a string.
|
|
23
|
-
result[key] = styles[key].static;
|
|
24
|
-
});
|
|
25
|
-
return result;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Flattens deep styles object into flat bindings with `.static` wrappers.
|
|
30
|
-
* Skips overrides where the value matches inherited parent breakpoint.
|
|
31
|
-
*/
|
|
32
|
-
createUpdate(styles, currentBreakpoint) {
|
|
33
|
-
const rebuilt = this.getBaseStyles();
|
|
34
|
-
const valueResolver = new InheritedValueResolver(this.breakpoints, breakpoint => {
|
|
35
|
-
if (this.isBaseBreakpoint(breakpoint)) {
|
|
36
|
-
return this.rawBindings.styles;
|
|
37
|
-
}
|
|
38
|
-
return this.rawBindings?.overrides?.[breakpoint]?.styles;
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// Collect original keys for the breakpoint
|
|
42
|
-
const originalStyles = this.isBaseBreakpoint(currentBreakpoint) ? this.rawBindings.styles || {} : this.rawBindings?.overrides?.[currentBreakpoint]?.styles || {};
|
|
43
|
-
const newKeys = new Set(Object.keys(styles));
|
|
44
|
-
const originalKeys = Object.keys(originalStyles);
|
|
45
|
-
|
|
46
|
-
// Remove keys that no longer exist
|
|
47
|
-
for (const key of originalKeys) {
|
|
48
|
-
if (!newKeys.has(key)) {
|
|
49
|
-
if (this.isBaseBreakpoint(currentBreakpoint)) {
|
|
50
|
-
unset(rebuilt, `styles.${key}`);
|
|
51
|
-
} else {
|
|
52
|
-
unset(rebuilt, `overrides.${currentBreakpoint}.styles.${key}`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
5
|
+
class StylesBindingsProcessor {
|
|
6
|
+
constructor(elementId, breakpoints, rawBindings){
|
|
7
|
+
this.elementId = elementId;
|
|
8
|
+
this.breakpoints = breakpoints;
|
|
9
|
+
this.rawBindings = rawBindings;
|
|
10
|
+
}
|
|
11
|
+
toDeepStyles(styles = {}) {
|
|
12
|
+
const result = {};
|
|
13
|
+
Object.keys(styles).forEach((key)=>{
|
|
14
|
+
result[key] = styles[key].static;
|
|
15
|
+
});
|
|
16
|
+
return result;
|
|
55
17
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
18
|
+
createUpdate(styles, currentBreakpoint) {
|
|
19
|
+
const rebuilt = this.getBaseStyles();
|
|
20
|
+
const valueResolver = new InheritedValueResolver(this.breakpoints, (breakpoint)=>{
|
|
21
|
+
if (this.isBaseBreakpoint(breakpoint)) return this.rawBindings.styles;
|
|
22
|
+
return this.rawBindings?.overrides?.[breakpoint]?.styles;
|
|
23
|
+
});
|
|
24
|
+
const originalStyles = this.isBaseBreakpoint(currentBreakpoint) ? this.rawBindings.styles || {} : this.rawBindings?.overrides?.[currentBreakpoint]?.styles || {};
|
|
25
|
+
const newKeys = new Set(Object.keys(styles));
|
|
26
|
+
const originalKeys = Object.keys(originalStyles);
|
|
27
|
+
for (const key of originalKeys)if (!newKeys.has(key)) this.isBaseBreakpoint(currentBreakpoint) ? unset(rebuilt, `styles.${key}`) : unset(rebuilt, `overrides.${currentBreakpoint}.styles.${key}`);
|
|
28
|
+
for (const [key, value] of Object.entries(styles))if (this.isBaseBreakpoint(currentBreakpoint)) set(rebuilt, `styles.${key}.static`, value);
|
|
29
|
+
else {
|
|
30
|
+
const inheritedValue = valueResolver.getInheritedValue(key, currentBreakpoint);
|
|
31
|
+
if (value !== inheritedValue) set(rebuilt, `overrides.${currentBreakpoint}.styles.${key}.static`, value);
|
|
32
|
+
else unset(rebuilt, `overrides.${currentBreakpoint}.styles.${key}`);
|
|
65
33
|
}
|
|
66
|
-
|
|
34
|
+
return new StylesUpdater(this.elementId, rebuilt);
|
|
67
35
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
// Clone existing overrides if present, to avoid losing breakpoint overrides
|
|
77
|
-
if (this.rawBindings.overrides) {
|
|
78
|
-
for (const [bp, overrides] of Object.entries(this.rawBindings.overrides)) {
|
|
79
|
-
if (overrides.styles) {
|
|
80
|
-
set(baseStyles, `overrides.${bp}.styles`, structuredClone(this.rawBindings.overrides[bp].styles));
|
|
36
|
+
getBaseStyles() {
|
|
37
|
+
const baseStyles = {
|
|
38
|
+
styles: structuredClone(this.rawBindings.styles) ?? {},
|
|
39
|
+
overrides: {}
|
|
40
|
+
};
|
|
41
|
+
if (this.rawBindings.overrides) {
|
|
42
|
+
for (const [bp, overrides] of Object.entries(this.rawBindings.overrides))if (overrides.styles) set(baseStyles, `overrides.${bp}.styles`, structuredClone(this.rawBindings.overrides[bp].styles));
|
|
81
43
|
}
|
|
82
|
-
|
|
44
|
+
return baseStyles;
|
|
45
|
+
}
|
|
46
|
+
isBaseBreakpoint(name) {
|
|
47
|
+
return 0 === this.breakpoints.indexOf(name);
|
|
83
48
|
}
|
|
84
|
-
return baseStyles;
|
|
85
|
-
}
|
|
86
|
-
isBaseBreakpoint(name) {
|
|
87
|
-
return this.breakpoints.indexOf(name) === 0;
|
|
88
|
-
}
|
|
89
49
|
}
|
|
50
|
+
export { StylesBindingsProcessor };
|
|
90
51
|
|
|
91
52
|
//# sourceMappingURL=StylesBindingsProcessor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"StylesBindingsProcessor.js","sources":["../src/StylesBindingsProcessor.ts"],"sourcesContent":["import set from \"lodash/set.js\";\nimport unset from \"lodash/unset.js\";\nimport type { DocumentElementBindings, DocumentElementStyleBindings } from \"~/types.js\";\nimport { InheritedValueResolver } from \"~/InheritedValueResolver.js\";\nimport { StylesUpdater } from \"./StylesUpdater.js\";\n\ntype DeepBindings = Record<string, any>;\n\nexport type ElementStylesBindings = {\n styles: DocumentElementStyleBindings;\n overrides: {\n [breakpoint: string]: {\n styles: DocumentElementStyleBindings;\n };\n };\n};\n\n/**\n * Handles deep-to-flat and flat-to-deep conversion of style bindings,\n * with breakpoint inheritance awareness.\n */\nexport class StylesBindingsProcessor {\n private breakpoints: string[];\n private rawBindings: DocumentElementBindings;\n private elementId: string;\n\n constructor(elementId: string, breakpoints: string[], rawBindings: DocumentElementBindings) {\n this.elementId = elementId;\n this.breakpoints = breakpoints;\n this.rawBindings = rawBindings;\n }\n\n /**\n * Converts flat style bindings into deep styles object (removes `.static`).\n */\n public toDeepStyles(styles: DocumentElementBindings[\"styles\"] = {}): DeepBindings {\n const result: DeepBindings = {};\n Object.keys(styles).forEach(key => {\n // @ts-expect-error Style keys cannot be indexed with a string.\n result[key] = styles[key].static;\n });\n return result;\n }\n\n /**\n * Flattens deep styles object into flat bindings with `.static` wrappers.\n * Skips overrides where the value matches inherited parent breakpoint.\n */\n public createUpdate(styles: DeepBindings, currentBreakpoint: string) {\n const rebuilt = this.getBaseStyles();\n const valueResolver = new InheritedValueResolver(this.breakpoints, breakpoint => {\n if (this.isBaseBreakpoint(breakpoint)) {\n return this.rawBindings.styles;\n }\n return this.rawBindings?.overrides?.[breakpoint]?.styles;\n });\n\n // Collect original keys for the breakpoint\n const originalStyles = this.isBaseBreakpoint(currentBreakpoint)\n ? this.rawBindings.styles || {}\n : this.rawBindings?.overrides?.[currentBreakpoint]?.styles || {};\n\n const newKeys = new Set(Object.keys(styles));\n const originalKeys = Object.keys(originalStyles);\n\n // Remove keys that no longer exist\n for (const key of originalKeys) {\n if (!newKeys.has(key)) {\n if (this.isBaseBreakpoint(currentBreakpoint)) {\n unset(rebuilt, `styles.${key}`);\n } else {\n unset(rebuilt, `overrides.${currentBreakpoint}.styles.${key}`);\n }\n }\n }\n\n for (const [key, value] of Object.entries(styles)) {\n if (this.isBaseBreakpoint(currentBreakpoint)) {\n set(rebuilt, `styles.${key}.static`, value);\n } else {\n const inheritedValue = valueResolver.getInheritedValue(key, currentBreakpoint);\n\n if (value !== inheritedValue) {\n set(rebuilt, `overrides.${currentBreakpoint}.styles.${key}.static`, value);\n } else {\n unset(rebuilt, `overrides.${currentBreakpoint}.styles.${key}`);\n }\n }\n }\n\n return new StylesUpdater(this.elementId, rebuilt);\n }\n\n private getBaseStyles(): ElementStylesBindings {\n const baseStyles: ElementStylesBindings = {\n styles: structuredClone(this.rawBindings.styles) ?? {},\n overrides: {}\n };\n\n // Clone existing overrides if present, to avoid losing breakpoint overrides\n if (this.rawBindings.overrides) {\n for (const [bp, overrides] of Object.entries(this.rawBindings.overrides)) {\n if (overrides.styles) {\n set(\n baseStyles,\n `overrides.${bp}.styles`,\n structuredClone(this.rawBindings.overrides[bp].styles)\n );\n }\n }\n }\n\n return baseStyles;\n }\n\n private isBaseBreakpoint(name: string): boolean {\n return this.breakpoints.indexOf(name) === 0;\n }\n}\n"],"names":["StylesBindingsProcessor","elementId","breakpoints","rawBindings","styles","result","Object","key","currentBreakpoint","rebuilt","valueResolver","InheritedValueResolver","breakpoint","originalStyles","newKeys","Set","originalKeys","unset","value","set","inheritedValue","StylesUpdater","baseStyles","structuredClone","bp","overrides","name"],"mappings":";;;;AAqBO,MAAMA;IAKT,YAAYC,SAAiB,EAAEC,WAAqB,EAAEC,WAAoC,CAAE;QACxF,IAAI,CAAC,SAAS,GAAGF;QACjB,IAAI,CAAC,WAAW,GAAGC;QACnB,IAAI,CAAC,WAAW,GAAGC;IACvB;IAKO,aAAaC,SAA4C,CAAC,CAAC,EAAgB;QAC9E,MAAMC,SAAuB,CAAC;QAC9BC,OAAO,IAAI,CAACF,QAAQ,OAAO,CAACG,CAAAA;YAExBF,MAAM,CAACE,IAAI,GAAGH,MAAM,CAACG,IAAI,CAAC,MAAM;QACpC;QACA,OAAOF;IACX;IAMO,aAAaD,MAAoB,EAAEI,iBAAyB,EAAE;QACjE,MAAMC,UAAU,IAAI,CAAC,aAAa;QAClC,MAAMC,gBAAgB,IAAIC,uBAAuB,IAAI,CAAC,WAAW,EAAEC,CAAAA;YAC/D,IAAI,IAAI,CAAC,gBAAgB,CAACA,aACtB,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM;YAElC,OAAO,IAAI,CAAC,WAAW,EAAE,WAAW,CAACA,WAAW,EAAE;QACtD;QAGA,MAAMC,iBAAiB,IAAI,CAAC,gBAAgB,CAACL,qBACvC,IAAI,CAAC,WAAW,CAAC,MAAM,IAAI,CAAC,IAC5B,IAAI,CAAC,WAAW,EAAE,WAAW,CAACA,kBAAkB,EAAE,UAAU,CAAC;QAEnE,MAAMM,UAAU,IAAIC,IAAIT,OAAO,IAAI,CAACF;QACpC,MAAMY,eAAeV,OAAO,IAAI,CAACO;QAGjC,KAAK,MAAMN,OAAOS,aACd,IAAI,CAACF,QAAQ,GAAG,CAACP,MACT,IAAI,CAAC,gBAAgB,CAACC,qBACtBS,MAAMR,SAAS,CAAC,OAAO,EAAEF,KAAK,IAE9BU,MAAMR,SAAS,CAAC,UAAU,EAAED,kBAAkB,QAAQ,EAAED,KAAK;QAKzE,KAAK,MAAM,CAACA,KAAKW,MAAM,IAAIZ,OAAO,OAAO,CAACF,QACtC,IAAI,IAAI,CAAC,gBAAgB,CAACI,oBACtBW,IAAIV,SAAS,CAAC,OAAO,EAAEF,IAAI,OAAO,CAAC,EAAEW;aAClC;YACH,MAAME,iBAAiBV,cAAc,iBAAiB,CAACH,KAAKC;YAE5D,IAAIU,UAAUE,gBACVD,IAAIV,SAAS,CAAC,UAAU,EAAED,kBAAkB,QAAQ,EAAED,IAAI,OAAO,CAAC,EAAEW;iBAEpED,MAAMR,SAAS,CAAC,UAAU,EAAED,kBAAkB,QAAQ,EAAED,KAAK;QAErE;QAGJ,OAAO,IAAIc,cAAc,IAAI,CAAC,SAAS,EAAEZ;IAC7C;IAEQ,gBAAuC;QAC3C,MAAMa,aAAoC;YACtC,QAAQC,gBAAgB,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC;YACrD,WAAW,CAAC;QAChB;QAGA,IAAI,IAAI,CAAC,WAAW,CAAC,SAAS,EAC1B;YAAA,KAAK,MAAM,CAACC,IAAIC,UAAU,IAAInB,OAAO,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,EACnE,IAAImB,UAAU,MAAM,EAChBN,IACIG,YACA,CAAC,UAAU,EAAEE,GAAG,OAAO,CAAC,EACxBD,gBAAgB,IAAI,CAAC,WAAW,CAAC,SAAS,CAACC,GAAG,CAAC,MAAM;QAGjE;QAGJ,OAAOF;IACX;IAEQ,iBAAiBI,IAAY,EAAW;QAC5C,OAAO,AAAmC,MAAnC,IAAI,CAAC,WAAW,CAAC,OAAO,CAACA;IACpC;AACJ"}
|
package/StylesUpdater.js
CHANGED
|
@@ -1,34 +1,29 @@
|
|
|
1
1
|
import { jsonPatch } from "./jsonPatch.js";
|
|
2
2
|
import set from "lodash/set.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
applyToDocument(document) {
|
|
9
|
-
if (this.bindings.styles) {
|
|
10
|
-
document.bindings[this.elementId].styles = this.bindings.styles;
|
|
3
|
+
class StylesUpdater {
|
|
4
|
+
constructor(elementId, bindings){
|
|
5
|
+
this.elementId = elementId;
|
|
6
|
+
this.bindings = bindings;
|
|
11
7
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (overrides
|
|
15
|
-
|
|
8
|
+
applyToDocument(document) {
|
|
9
|
+
if (this.bindings.styles) document.bindings[this.elementId].styles = this.bindings.styles;
|
|
10
|
+
if (this.bindings.overrides) {
|
|
11
|
+
for (const [bp, overrides] of Object.entries(this.bindings.overrides))if (overrides.styles) set(document.bindings, `${this.elementId}.overrides.${bp}.styles`, structuredClone(this.bindings.overrides[bp].styles));
|
|
16
12
|
}
|
|
17
|
-
}
|
|
18
13
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
createJsonPatch(bindings) {
|
|
15
|
+
const toCompare = {
|
|
16
|
+
...this.bindings
|
|
17
|
+
};
|
|
18
|
+
if (0 === Object.keys(toCompare.overrides ?? {}).length) delete toCompare.overrides;
|
|
19
|
+
const ignore = [
|
|
20
|
+
"/inputs",
|
|
21
|
+
"/overrides/inputs",
|
|
22
|
+
"/metadata"
|
|
23
|
+
];
|
|
24
|
+
return jsonPatch.compare(bindings, toCompare).filter((op)=>!ignore.some((prefix)=>op.path.startsWith(prefix)));
|
|
26
25
|
}
|
|
27
|
-
const ignore = ["/inputs", "/overrides/inputs", "/metadata"];
|
|
28
|
-
return jsonPatch.compare(bindings, toCompare).filter(op => {
|
|
29
|
-
return !ignore.some(prefix => op.path.startsWith(prefix));
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
26
|
}
|
|
27
|
+
export { StylesUpdater };
|
|
33
28
|
|
|
34
29
|
//# sourceMappingURL=StylesUpdater.js.map
|
package/StylesUpdater.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"StylesUpdater.js","sources":["../src/StylesUpdater.ts"],"sourcesContent":["import { jsonPatch } from \"~/jsonPatch.js\";\nimport set from \"lodash/set.js\";\nimport type { Document, DocumentElementBindings } from \"./types.js\";\nimport type { IBindingsUpdater } from \"./IBindingsUpdater.js\";\nimport type { ElementStylesBindings } from \"./StylesBindingsProcessor.js\";\n\nexport class StylesUpdater implements IBindingsUpdater {\n private readonly bindings: ElementStylesBindings;\n private elementId: string;\n\n constructor(elementId: string, bindings: ElementStylesBindings) {\n this.elementId = elementId;\n this.bindings = bindings;\n }\n\n applyToDocument(document: Document) {\n if (this.bindings.styles) {\n document.bindings[this.elementId].styles = this.bindings.styles;\n }\n\n if (this.bindings.overrides) {\n for (const [bp, overrides] of Object.entries(this.bindings.overrides)) {\n if (overrides.styles) {\n set(\n document.bindings,\n `${this.elementId}.overrides.${bp}.styles`,\n structuredClone(this.bindings.overrides[bp].styles)\n );\n }\n }\n }\n }\n\n createJsonPatch(bindings: DocumentElementBindings) {\n const toCompare: Partial<DocumentElementBindings> = { ...this.bindings };\n if (Object.keys(toCompare.overrides ?? {}).length === 0) {\n delete toCompare.overrides;\n }\n\n const ignore = [\"/inputs\", \"/overrides/inputs\", \"/metadata\"];\n\n return jsonPatch.compare(bindings, toCompare).filter(op => {\n return !ignore.some(prefix => op.path.startsWith(prefix));\n });\n }\n}\n"],"names":["StylesUpdater","elementId","bindings","document","bp","overrides","Object","set","structuredClone","toCompare","ignore","jsonPatch","op","prefix"],"mappings":";;AAMO,MAAMA;IAIT,YAAYC,SAAiB,EAAEC,QAA+B,CAAE;QAC5D,IAAI,CAAC,SAAS,GAAGD;QACjB,IAAI,CAAC,QAAQ,GAAGC;IACpB;IAEA,gBAAgBC,QAAkB,EAAE;QAChC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EACpBA,SAAS,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM;QAGnE,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,EACvB;YAAA,KAAK,MAAM,CAACC,IAAIC,UAAU,IAAIC,OAAO,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,EAChE,IAAID,UAAU,MAAM,EAChBE,IACIJ,SAAS,QAAQ,EACjB,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,EAAEC,GAAG,OAAO,CAAC,EAC1CI,gBAAgB,IAAI,CAAC,QAAQ,CAAC,SAAS,CAACJ,GAAG,CAAC,MAAM;QAG9D;IAER;IAEA,gBAAgBF,QAAiC,EAAE;QAC/C,MAAMO,YAA8C;YAAE,GAAG,IAAI,CAAC,QAAQ;QAAC;QACvE,IAAIH,AAAkD,MAAlDA,OAAO,IAAI,CAACG,UAAU,SAAS,IAAI,CAAC,GAAG,MAAM,EAC7C,OAAOA,UAAU,SAAS;QAG9B,MAAMC,SAAS;YAAC;YAAW;YAAqB;SAAY;QAE5D,OAAOC,UAAU,OAAO,CAACT,UAAUO,WAAW,MAAM,CAACG,CAAAA,KAC1C,CAACF,OAAO,IAAI,CAACG,CAAAA,SAAUD,GAAG,IAAI,CAAC,UAAU,CAACC;IAEzD;AACJ"}
|
package/Theme.js
CHANGED
|
@@ -1,29 +1,32 @@
|
|
|
1
|
-
import
|
|
1
|
+
import deepmerge from "deepmerge";
|
|
2
2
|
import { defaultBreakpoints } from "./defaultBreakpoints.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
name,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
3
|
+
class Theme {
|
|
4
|
+
static from(input) {
|
|
5
|
+
const { custom = {}, ...builtInOverrides } = input?.breakpoints ?? {};
|
|
6
|
+
const mergedBreakpoints = deepmerge.all([
|
|
7
|
+
{},
|
|
8
|
+
defaultBreakpoints,
|
|
9
|
+
builtInOverrides,
|
|
10
|
+
custom
|
|
11
|
+
]);
|
|
12
|
+
const breakpoints = [];
|
|
13
|
+
Object.entries(mergedBreakpoints ?? {}).forEach(([name, breakpoint])=>{
|
|
14
|
+
breakpoints.push({
|
|
15
|
+
name,
|
|
16
|
+
...breakpoint
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
css: input.css,
|
|
21
|
+
fonts: input.fonts,
|
|
22
|
+
breakpoints: breakpoints.sort((a, b)=>b.maxWidth - a.maxWidth),
|
|
23
|
+
colors: input?.colors ?? [],
|
|
24
|
+
typography: {
|
|
25
|
+
...input?.typography
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
27
29
|
}
|
|
30
|
+
export { Theme };
|
|
28
31
|
|
|
29
32
|
//# sourceMappingURL=Theme.js.map
|