@webiny/website-builder-sdk 6.0.0-rc.7 → 6.1.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/BindingsResolver.js +1 -4
- package/BindingsResolver.js.map +1 -1
- package/ComponentRegistry.js +30 -0
- package/ComponentRegistry.js.map +1 -1
- package/ConstraintEvaluator.d.ts +36 -0
- package/ConstraintEvaluator.js +395 -0
- package/ConstraintEvaluator.js.map +1 -0
- package/ConstraintEvaluator.test.d.ts +1 -0
- package/ConstraintEvaluator.test.js +1456 -0
- package/ConstraintEvaluator.test.js.map +1 -0
- package/ElementFactory.d.ts +2 -3
- package/ElementFactory.js +21 -12
- package/ElementFactory.js.map +1 -1
- package/ElementFactory.test.d.ts +1 -0
- package/ElementFactory.test.js +280 -0
- package/ElementFactory.test.js.map +1 -0
- package/InputBindingsProcessor.js +24 -6
- package/InputBindingsProcessor.js.map +1 -1
- package/InputsBindingsProcessor.test.js +1 -0
- package/InputsBindingsProcessor.test.js.map +1 -1
- package/documentOperations/$addElementReferenceToParent.d.ts +1 -1
- package/documentOperations/$addElementReferenceToParent.js +9 -2
- package/documentOperations/$addElementReferenceToParent.js.map +1 -1
- package/documentOperations/AddToParent.d.ts +2 -2
- package/documentOperations/AddToParent.js.map +1 -1
- package/documentOperations/RemoveElement.js +9 -0
- package/documentOperations/RemoveElement.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/messenger/Messenger.js +1 -3
- package/messenger/Messenger.js.map +1 -1
- package/package.json +8 -8
- package/types.d.ts +120 -7
- package/types.js.map +1 -1
|
@@ -6,7 +6,7 @@ export function $addElementReferenceToParent(document, {
|
|
|
6
6
|
}) {
|
|
7
7
|
const bindings = document.bindings[parentId] ?? {};
|
|
8
8
|
const inputs = bindings.inputs ?? {};
|
|
9
|
-
if (index < 0) {
|
|
9
|
+
if (index !== undefined && index < 0) {
|
|
10
10
|
// Single value slot
|
|
11
11
|
inputs[slot] = {
|
|
12
12
|
...inputs[slot],
|
|
@@ -15,11 +15,18 @@ export function $addElementReferenceToParent(document, {
|
|
|
15
15
|
};
|
|
16
16
|
} else {
|
|
17
17
|
const slotElements = inputs[slot];
|
|
18
|
+
const existing = slotElements?.static ?? [];
|
|
19
|
+
let staticValue;
|
|
20
|
+
if (index === undefined) {
|
|
21
|
+
staticValue = [...existing, elementId];
|
|
22
|
+
} else {
|
|
23
|
+
staticValue = [...existing.slice(0, index), elementId, ...existing.slice(index)];
|
|
24
|
+
}
|
|
18
25
|
inputs[slot] = {
|
|
19
26
|
...inputs[slot],
|
|
20
27
|
type: "slot",
|
|
21
28
|
list: true,
|
|
22
|
-
static:
|
|
29
|
+
static: staticValue
|
|
23
30
|
};
|
|
24
31
|
}
|
|
25
32
|
document.bindings[parentId] = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["$addElementReferenceToParent","document","elementId","parentId","slot","index","bindings","inputs","type","static","slotElements","
|
|
1
|
+
{"version":3,"names":["$addElementReferenceToParent","document","elementId","parentId","slot","index","bindings","inputs","undefined","type","static","slotElements","existing","staticValue","slice","list"],"sources":["$addElementReferenceToParent.ts"],"sourcesContent":["import type { Document } from \"~/types.js\";\nimport type { InputValueBinding } from \"~/types.js\";\n\ninterface Params {\n elementId: string;\n parentId: string;\n slot: string;\n index?: number;\n}\n\nexport function $addElementReferenceToParent(\n document: Document,\n { elementId, parentId, slot, index }: Params\n) {\n const bindings = document.bindings[parentId] ?? {};\n const inputs = bindings.inputs ?? {};\n\n if (index !== undefined && index < 0) {\n // Single value slot\n inputs[slot] = {\n ...inputs[slot],\n type: \"slot\",\n static: elementId\n };\n } else {\n const slotElements = inputs[slot] as InputValueBinding;\n const existing = slotElements?.static ?? [];\n\n let staticValue;\n if (index === undefined) {\n staticValue = [...existing, elementId];\n } else {\n staticValue = [...existing.slice(0, index), elementId, ...existing.slice(index)];\n }\n\n inputs[slot] = {\n ...inputs[slot],\n type: \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
|
|
@@ -2,7 +2,7 @@ import type { Document, DocumentElement } from "../types.js";
|
|
|
2
2
|
import type { IDocumentOperation } from "./IDocumentOperation.js";
|
|
3
3
|
export declare class AddToParent implements IDocumentOperation {
|
|
4
4
|
private element;
|
|
5
|
-
private readonly index
|
|
6
|
-
constructor(element: DocumentElement, index
|
|
5
|
+
private readonly index?;
|
|
6
|
+
constructor(element: DocumentElement, index?: number);
|
|
7
7
|
apply(document: Document): void;
|
|
8
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["$addElementReferenceToParent","AddToParent","constructor","element","index","apply","document","elementId","id","parentId","parent","slot"],"sources":["AddToParent.ts"],"sourcesContent":["import type { Document, DocumentElement } from \"~/types.js\";\nimport type { IDocumentOperation } from \"./IDocumentOperation.js\";\nimport { $addElementReferenceToParent } from \"./$addElementReferenceToParent.js\";\n\nexport class AddToParent implements IDocumentOperation {\n private element: DocumentElement;\n private readonly index
|
|
1
|
+
{"version":3,"names":["$addElementReferenceToParent","AddToParent","constructor","element","index","apply","document","elementId","id","parentId","parent","slot"],"sources":["AddToParent.ts"],"sourcesContent":["import type { Document, DocumentElement } from \"~/types.js\";\nimport type { IDocumentOperation } from \"./IDocumentOperation.js\";\nimport { $addElementReferenceToParent } from \"./$addElementReferenceToParent.js\";\n\nexport class AddToParent implements IDocumentOperation {\n private element: DocumentElement;\n private readonly index?: number;\n\n constructor(element: DocumentElement, index?: number) {\n this.element = element;\n this.index = index;\n }\n\n apply(document: Document) {\n $addElementReferenceToParent(document, {\n elementId: this.element.id,\n parentId: this.element.parent!.id,\n slot: this.element.parent!.slot,\n index: this.index\n });\n }\n}\n"],"mappings":"AAEA,SAASA,4BAA4B;AAErC,OAAO,MAAMC,WAAW,CAA+B;EAInDC,WAAWA,CAACC,OAAwB,EAAEC,KAAc,EAAE;IAClD,IAAI,CAACD,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,KAAK,GAAGA,KAAK;EACtB;EAEAC,KAAKA,CAACC,QAAkB,EAAE;IACtBN,4BAA4B,CAACM,QAAQ,EAAE;MACnCC,SAAS,EAAE,IAAI,CAACJ,OAAO,CAACK,EAAE;MAC1BC,QAAQ,EAAE,IAAI,CAACN,OAAO,CAACO,MAAM,CAAEF,EAAE;MACjCG,IAAI,EAAE,IAAI,CAACR,OAAO,CAACO,MAAM,CAAEC,IAAI;MAC/BP,KAAK,EAAE,IAAI,CAACA;IAChB,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
|
|
@@ -3,6 +3,15 @@ export class RemoveElement {
|
|
|
3
3
|
this.elementId = elementId;
|
|
4
4
|
}
|
|
5
5
|
apply(document) {
|
|
6
|
+
// Recursively remove all descendants first.
|
|
7
|
+
for (const id in document.elements) {
|
|
8
|
+
if (document.elements[id].parent?.id === this.elementId) {
|
|
9
|
+
new RemoveElement(id).apply(document);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Remove bindings and the element itself.
|
|
14
|
+
delete document.bindings[this.elementId];
|
|
6
15
|
delete document.elements[this.elementId];
|
|
7
16
|
}
|
|
8
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["RemoveElement","constructor","elementId","apply","document","elements"],"sources":["RemoveElement.ts"],"sourcesContent":["import type { Document } from \"~/types.js\";\nimport type { IDocumentOperation } from \"./IDocumentOperation.js\";\n\nexport class RemoveElement implements IDocumentOperation {\n private readonly elementId: string;\n\n constructor(elementId: string) {\n this.elementId = elementId;\n }\n\n apply(document: Document) {\n delete document.elements[this.elementId];\n }\n}\n"],"mappings":"AAGA,OAAO,MAAMA,aAAa,CAA+B;EAGrDC,WAAWA,CAACC,SAAiB,EAAE;IAC3B,IAAI,CAACA,SAAS,GAAGA,SAAS;EAC9B;EAEAC,KAAKA,CAACC,QAAkB,EAAE;IACtB,
|
|
1
|
+
{"version":3,"names":["RemoveElement","constructor","elementId","apply","document","id","elements","parent","bindings"],"sources":["RemoveElement.ts"],"sourcesContent":["import type { Document } from \"~/types.js\";\nimport type { IDocumentOperation } from \"./IDocumentOperation.js\";\n\nexport class RemoveElement implements IDocumentOperation {\n private readonly elementId: string;\n\n constructor(elementId: string) {\n this.elementId = elementId;\n }\n\n apply(document: Document) {\n // Recursively remove all descendants first.\n for (const id in document.elements) {\n if (document.elements[id].parent?.id === this.elementId) {\n new RemoveElement(id).apply(document);\n }\n }\n\n // Remove bindings and the element itself.\n delete document.bindings[this.elementId];\n delete document.elements[this.elementId];\n }\n}\n"],"mappings":"AAGA,OAAO,MAAMA,aAAa,CAA+B;EAGrDC,WAAWA,CAACC,SAAiB,EAAE;IAC3B,IAAI,CAACA,SAAS,GAAGA,SAAS;EAC9B;EAEAC,KAAKA,CAACC,QAAkB,EAAE;IACtB;IACA,KAAK,MAAMC,EAAE,IAAID,QAAQ,CAACE,QAAQ,EAAE;MAChC,IAAIF,QAAQ,CAACE,QAAQ,CAACD,EAAE,CAAC,CAACE,MAAM,EAAEF,EAAE,KAAK,IAAI,CAACH,SAAS,EAAE;QACrD,IAAIF,aAAa,CAACK,EAAE,CAAC,CAACF,KAAK,CAACC,QAAQ,CAAC;MACzC;IACJ;;IAEA;IACA,OAAOA,QAAQ,CAACI,QAAQ,CAAC,IAAI,CAACN,SAAS,CAAC;IACxC,OAAOE,QAAQ,CAACE,QAAQ,CAAC,IAAI,CAACJ,SAAS,CAAC;EAC5C;AACJ","ignoreList":[]}
|
package/index.d.ts
CHANGED
|
@@ -27,4 +27,5 @@ export * from "./InheritanceProcessor.js";
|
|
|
27
27
|
export * from "./InputBindingsProcessor.js";
|
|
28
28
|
export * from "./StylesBindingsProcessor.js";
|
|
29
29
|
export * from "./ElementFactory.js";
|
|
30
|
+
export * from "./ConstraintEvaluator.js";
|
|
30
31
|
export { StyleSettings } from "./constants.js";
|
package/index.js
CHANGED
|
@@ -26,6 +26,7 @@ export * from "./InheritanceProcessor.js";
|
|
|
26
26
|
export * from "./InputBindingsProcessor.js";
|
|
27
27
|
export * from "./StylesBindingsProcessor.js";
|
|
28
28
|
export * from "./ElementFactory.js";
|
|
29
|
+
export * from "./ConstraintEvaluator.js";
|
|
29
30
|
export { StyleSettings } from "./constants.js";
|
|
30
31
|
|
|
31
32
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["StyleSettings"],"sources":["index.ts"],"sourcesContent":["export * from \"./createTheme.js\";\nexport * from \"./EditingSdk.js\";\nexport * from \"./LiveSdk.js\";\nexport * from \"./NullSdk.js\";\nexport * from \"./ContentSdk.js\";\nexport * from \"./Environment.js\";\nexport * from \"./DocumentStore.js\";\nexport * from \"./Logger.js\";\nexport * from \"./FunctionConverter.js\";\nexport * from \"./createInput.js\";\nexport * from \"./MouseTracker.js\";\nexport * from \"./ViewportManager.js\";\nexport * from \"./messenger/Messenger.js\";\nexport * from \"./messenger/MessageOrigin.js\";\nexport type * from \"./types.js\";\nexport * from \"./DocumentStoreManager.js\";\nexport * from \"./BindingsProcessor.js\";\nexport * from \"./ResizeObserver.js\";\nexport * from \"./BindingsResolver.js\";\nexport * from \"./createElement.js\";\nexport * from \"./registerComponentGroup.js\";\nexport * from \"./jsonPatch.js\";\nexport * from \"./headersProvider.js\";\nexport * from \"./ComponentManifestToAstConverter.js\";\nexport * from \"./findMatchingAstNode.js\";\nexport * from \"./InheritanceProcessor.js\";\nexport * from \"./InputBindingsProcessor.js\";\nexport * from \"./StylesBindingsProcessor.js\";\nexport * from \"./ElementFactory.js\";\nexport { StyleSettings } from \"./constants.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,aAAa","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["StyleSettings"],"sources":["index.ts"],"sourcesContent":["export * from \"./createTheme.js\";\nexport * from \"./EditingSdk.js\";\nexport * from \"./LiveSdk.js\";\nexport * from \"./NullSdk.js\";\nexport * from \"./ContentSdk.js\";\nexport * from \"./Environment.js\";\nexport * from \"./DocumentStore.js\";\nexport * from \"./Logger.js\";\nexport * from \"./FunctionConverter.js\";\nexport * from \"./createInput.js\";\nexport * from \"./MouseTracker.js\";\nexport * from \"./ViewportManager.js\";\nexport * from \"./messenger/Messenger.js\";\nexport * from \"./messenger/MessageOrigin.js\";\nexport type * from \"./types.js\";\nexport * from \"./DocumentStoreManager.js\";\nexport * from \"./BindingsProcessor.js\";\nexport * from \"./ResizeObserver.js\";\nexport * from \"./BindingsResolver.js\";\nexport * from \"./createElement.js\";\nexport * from \"./registerComponentGroup.js\";\nexport * from \"./jsonPatch.js\";\nexport * from \"./headersProvider.js\";\nexport * from \"./ComponentManifestToAstConverter.js\";\nexport * from \"./findMatchingAstNode.js\";\nexport * from \"./InheritanceProcessor.js\";\nexport * from \"./InputBindingsProcessor.js\";\nexport * from \"./StylesBindingsProcessor.js\";\nexport * from \"./ElementFactory.js\";\nexport * from \"./ConstraintEvaluator.js\";\nexport { StyleSettings } from \"./constants.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,aAAa","ignoreList":[]}
|
package/messenger/Messenger.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { isMatch } from "matcher";
|
|
2
2
|
import { logger } from "../Logger.js";
|
|
3
|
-
const ignored = ["preview.mouse.move", "preview.component.register", "preview.scroll",
|
|
4
|
-
// "preview.viewport",
|
|
5
|
-
"preview.viewport.change.start", "preview.viewport.change.end"];
|
|
3
|
+
const ignored = ["preview.mouse.move", "preview.component.register", "preview.scroll", "preview.viewport", "preview.viewport.change.start", "preview.viewport.change.end"];
|
|
6
4
|
export class Messenger {
|
|
7
5
|
listeners = new Map();
|
|
8
6
|
constructor(source, target,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isMatch","logger","ignored","Messenger","listeners","Map","constructor","source","target","pattern","prefixGlob","replace","handleMessage","bind","window","addEventListener","event","type","payload","data","matches","logicalType","stripPrefix","isIgnored","debug","getTime","origin","handlers","get","forEach","fn","fullType","startsWith","slice","length","includes","on","handler","has","set","Set","add","delete","send","postMessage","dispose","removeEventListener","clear","date","Date","getHours","getMinutes","getSeconds","getMilliseconds"],"sources":["Messenger.ts"],"sourcesContent":["import { isMatch } from \"matcher\";\nimport type { MessageOrigin } from \"./MessageOrigin.js\";\nimport { logger } from \"../Logger.js\";\n\nexport type Message<T = any> = {\n type: string;\n payload: T;\n};\n\ntype Handler<T = any> = (payload: T, logicalType: string, wildcardMatch?: string) => void;\n\nconst ignored = [\n \"preview.mouse.move\",\n \"preview.component.register\",\n \"preview.scroll\",\n
|
|
1
|
+
{"version":3,"names":["isMatch","logger","ignored","Messenger","listeners","Map","constructor","source","target","pattern","prefixGlob","replace","handleMessage","bind","window","addEventListener","event","type","payload","data","matches","logicalType","stripPrefix","isIgnored","debug","getTime","origin","handlers","get","forEach","fn","fullType","startsWith","slice","length","includes","on","handler","has","set","Set","add","delete","send","postMessage","dispose","removeEventListener","clear","date","Date","getHours","getMinutes","getSeconds","getMilliseconds"],"sources":["Messenger.ts"],"sourcesContent":["import { isMatch } from \"matcher\";\nimport type { MessageOrigin } from \"./MessageOrigin.js\";\nimport { logger } from \"../Logger.js\";\n\nexport type Message<T = any> = {\n type: string;\n payload: T;\n};\n\ntype Handler<T = any> = (payload: T, logicalType: string, wildcardMatch?: string) => void;\n\nconst ignored = [\n \"preview.mouse.move\",\n \"preview.component.register\",\n \"preview.scroll\",\n \"preview.viewport\",\n \"preview.viewport.change.start\",\n \"preview.viewport.change.end\"\n];\n\nexport class Messenger {\n private listeners = new Map<string, Set<Handler>>();\n private readonly pattern: string;\n private readonly prefixGlob: string;\n\n constructor(\n private source: MessageOrigin,\n private target: MessageOrigin,\n // Pattern to filter events this Messenger handles.\n pattern: string\n ) {\n this.pattern = pattern;\n this.prefixGlob = pattern.replace(/\\*+$/, \"\");\n this.handleMessage = this.handleMessage.bind(this);\n this.source.window.addEventListener(\"message\", this.handleMessage);\n }\n\n private handleMessage(event: MessageEvent) {\n const { type, payload } = event.data || {};\n if (!this.target.matches(event)) {\n return;\n }\n\n if (!type || !isMatch(type, this.pattern)) {\n return;\n }\n\n const logicalType = this.stripPrefix(type);\n\n if (!this.isIgnored(logicalType)) {\n logger.debug(\n {\n type,\n payload\n },\n `${this.getTime()} --> [${this.source.origin}][${logicalType}]`\n );\n }\n\n const handlers = this.listeners.get(logicalType);\n if (handlers) {\n handlers.forEach(fn => fn(payload, logicalType));\n }\n }\n\n private stripPrefix(fullType: string): string {\n return fullType.startsWith(this.prefixGlob)\n ? fullType.slice(this.prefixGlob.length)\n : fullType;\n }\n\n private isIgnored(logicalType: string): boolean {\n return ignored.includes(logicalType);\n }\n\n on<T = any>(logicalType: string, handler: Handler<T>) {\n if (!this.listeners.has(logicalType)) {\n this.listeners.set(logicalType, new Set());\n }\n this.listeners.get(logicalType)!.add(handler);\n return () => {\n const listeners = this.listeners.get(logicalType);\n if (listeners) {\n listeners.delete(handler);\n }\n };\n }\n\n send<T = any>(logicalType: string, payload?: T) {\n const fullType = this.prefixGlob + logicalType;\n\n if (!this.isIgnored(logicalType)) {\n logger.debug(\n {\n type: fullType,\n payload\n },\n `${this.getTime()} <-- [${this.source.origin}][${logicalType}]`\n );\n }\n\n this.target.window.postMessage({ type: fullType, payload }, this.target.origin);\n }\n\n dispose() {\n this.source.window.removeEventListener(\"message\", this.handleMessage);\n this.listeners.clear();\n }\n\n getTime() {\n const date = new Date();\n return `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}.${date.getMilliseconds()}`;\n }\n}\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,SAAS;AAEjC,SAASC,MAAM;AASf,MAAMC,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ACD,GAAG,IAAI,CAACO,OAAO,CAAC,CAAC,SAAS,IAAI,CAAClB,MAAM,CAACmB,MAAM,KAAKL,WAAW,GAChE,CAAC;IACL;IAEA,IAAI,CAACb,MAAM,CAACM,MAAM,CAAC8B,WAAW,CAAC;MAAE3B,IAAI,EAAEc,QAAQ;MAAEb;IAAQ,CAAC,EAAE,IAAI,CAACV,MAAM,CAACkB,MAAM,CAAC;EACnF;EAEAmB,OAAOA,CAAA,EAAG;IACN,IAAI,CAACtC,MAAM,CAACO,MAAM,CAACgC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAClC,aAAa,CAAC;IACrE,IAAI,CAACR,SAAS,CAAC2C,KAAK,CAAC,CAAC;EAC1B;EAEAtB,OAAOA,CAAA,EAAG;IACN,MAAMuB,IAAI,GAAG,IAAIC,IAAI,CAAC,CAAC;IACvB,OAAO,GAAGD,IAAI,CAACE,QAAQ,CAAC,CAAC,IAAIF,IAAI,CAACG,UAAU,CAAC,CAAC,IAAIH,IAAI,CAACI,UAAU,CAAC,CAAC,IAAIJ,IAAI,CAACK,eAAe,CAAC,CAAC,EAAE;EACnG;AACJ","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/website-builder-sdk",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.0-beta.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -20,19 +20,19 @@
|
|
|
20
20
|
"fast-json-stable-stringify": "2.1.0",
|
|
21
21
|
"is-hotkey": "0.2.0",
|
|
22
22
|
"lodash": "4.17.23",
|
|
23
|
-
"matcher": "
|
|
23
|
+
"matcher": "6.0.0",
|
|
24
24
|
"mobx": "6.15.0",
|
|
25
|
-
"nanoid": "5.1.
|
|
25
|
+
"nanoid": "5.1.7",
|
|
26
26
|
"nanoid-dictionary": "5.0.0",
|
|
27
|
-
"pino": "
|
|
28
|
-
"pino-pretty": "
|
|
27
|
+
"pino": "10.3.1",
|
|
28
|
+
"pino-pretty": "13.1.3"
|
|
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.
|
|
33
|
+
"@webiny/build-tools": "6.1.0-beta.0",
|
|
34
34
|
"typescript": "5.9.3",
|
|
35
|
-
"vitest": "4.
|
|
35
|
+
"vitest": "4.1.2"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
]
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "a3bd3695c66c79238e380d7360d9731b5fcf9c87"
|
|
49
49
|
}
|
package/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type * as CSS from "csstype";
|
|
|
2
2
|
import type { BindingsApi } from "./BindingsApi.js";
|
|
3
3
|
import type { ShorthandCssProperties } from "./types/ShorthandCssProperties.js";
|
|
4
4
|
import type { InputFactory } from "./createInput.js";
|
|
5
|
+
import type { Breakpoint } from "./types/WebsiteBuilderTheme.js";
|
|
5
6
|
export type { WebsiteBuilderTheme, Breakpoint } from "./types/WebsiteBuilderTheme.js";
|
|
6
7
|
type CSSProperties = CSS.Properties<string | number>;
|
|
7
8
|
export type ElementMap = Record<string, DocumentElement>;
|
|
@@ -81,6 +82,107 @@ export type ComponentGroup = {
|
|
|
81
82
|
export type ResponsiveStyles = {
|
|
82
83
|
[key: string]: SerializableCSSStyleDeclaration;
|
|
83
84
|
};
|
|
85
|
+
export type ConstraintElementContext = {
|
|
86
|
+
/** Component name (e.g., "FunnelBuilder/Step") */
|
|
87
|
+
name: string;
|
|
88
|
+
/** Component tags */
|
|
89
|
+
tags: string[];
|
|
90
|
+
/** Get the parent element context. undefined for root. */
|
|
91
|
+
getParent(): ConstraintElementContext | undefined;
|
|
92
|
+
/** Index of this element among siblings in the same parent slot. -1 if not in a list slot. */
|
|
93
|
+
childIndex(): number;
|
|
94
|
+
/** Total siblings in the same parent slot. -1 if not in a list slot. */
|
|
95
|
+
childCount(): number;
|
|
96
|
+
/** True if this element is the last among siblings in its parent slot. */
|
|
97
|
+
isLastChild(): boolean;
|
|
98
|
+
/** True if this element is the first among siblings in its parent slot. */
|
|
99
|
+
isFirstChild(): boolean;
|
|
100
|
+
};
|
|
101
|
+
export type ConstraintContext = {
|
|
102
|
+
/** The component/element this constraint is about */
|
|
103
|
+
component: ConstraintElementContext;
|
|
104
|
+
/** The direct parent element at the drop target */
|
|
105
|
+
parent: ConstraintElementContext;
|
|
106
|
+
/** The target slot name (e.g., "children", "leftColumn", "rightColumn") */
|
|
107
|
+
slot: string;
|
|
108
|
+
/** True if the direct parent is the given component */
|
|
109
|
+
isChildOf: (componentName: string) => boolean;
|
|
110
|
+
/** True if any ancestor (including parent) is the given component */
|
|
111
|
+
isDescendantOf: (componentName: string) => boolean;
|
|
112
|
+
/** Find the nearest ancestor matching a component name */
|
|
113
|
+
getAncestor: (componentName: string) => ConstraintElementContext | undefined;
|
|
114
|
+
/** True if the component being placed has the given tag */
|
|
115
|
+
hasTag: (tag: string) => boolean;
|
|
116
|
+
/** Number of items currently in the target slot */
|
|
117
|
+
slotChildCount: () => number;
|
|
118
|
+
/** Count instances of a component type in the entire document */
|
|
119
|
+
countInstances: (componentName: string) => number;
|
|
120
|
+
/** True if the component has any descendant element carrying the given tag */
|
|
121
|
+
hasDescendantWithTag: (tag: string) => boolean;
|
|
122
|
+
/** Returns the resolved inputs of the nearest ancestor matching componentName, or undefined */
|
|
123
|
+
getAncestorInputs: (componentName: string) => Record<string, any> | undefined;
|
|
124
|
+
/** Returns the resolved inputs of the element this constraint is evaluating */
|
|
125
|
+
getElementInputs: () => Record<string, any>;
|
|
126
|
+
/** Debug logger — safe to call inside serialized constraints */
|
|
127
|
+
log: (...args: any[]) => void;
|
|
128
|
+
/** Block placement with an error message shown to the user */
|
|
129
|
+
block: (message: string) => never;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* A constraint function. Call `ctx.block("message")` to block placement.
|
|
133
|
+
* Returning without blocking means the constraint passes.
|
|
134
|
+
*/
|
|
135
|
+
export type ComponentConstraint = (ctx: ConstraintContext) => void;
|
|
136
|
+
export type Stop = symbol;
|
|
137
|
+
export type Continue = symbol;
|
|
138
|
+
export type HandlerResult = void | Stop | Continue;
|
|
139
|
+
export type OnChangeAction = "create" | "update" | "delete";
|
|
140
|
+
export type OnChangeElementContext = {
|
|
141
|
+
id: string;
|
|
142
|
+
component: ComponentManifest;
|
|
143
|
+
inputs: Record<string, any>;
|
|
144
|
+
};
|
|
145
|
+
export type ManifestAncestorContext = {
|
|
146
|
+
id: string;
|
|
147
|
+
component: ComponentManifest;
|
|
148
|
+
inputs: Record<string, any>;
|
|
149
|
+
updateInputs: (cb: (inputs: Record<string, any>) => void) => void;
|
|
150
|
+
getElement: (id: string) => OnChangeElementContext | undefined;
|
|
151
|
+
};
|
|
152
|
+
export type ComponentChangeContext<TInputs = Record<string, any>> = {
|
|
153
|
+
action: OnChangeAction;
|
|
154
|
+
id: string;
|
|
155
|
+
component: ComponentManifest;
|
|
156
|
+
inputs: TInputs;
|
|
157
|
+
styles: Record<string, any>;
|
|
158
|
+
getAncestor: (componentName: string) => ManifestAncestorContext | undefined;
|
|
159
|
+
getElement: (id: string) => OnChangeElementContext | undefined;
|
|
160
|
+
createElement: (params: any) => any;
|
|
161
|
+
executeCommand: <T = unknown>(command: string, payload?: T) => void;
|
|
162
|
+
breakpoint: string;
|
|
163
|
+
log: (...args: any[]) => void;
|
|
164
|
+
stop: () => Stop;
|
|
165
|
+
continue: () => Continue;
|
|
166
|
+
};
|
|
167
|
+
export type DescendantChangeContext<TInputs = Record<string, any>, TDescendantInputs = Record<string, any>> = {
|
|
168
|
+
action: OnChangeAction;
|
|
169
|
+
descendant: {
|
|
170
|
+
component: ComponentManifest;
|
|
171
|
+
id: string;
|
|
172
|
+
inputs: TDescendantInputs;
|
|
173
|
+
updateInputs: (cb: (inputs: TDescendantInputs) => void) => void;
|
|
174
|
+
};
|
|
175
|
+
inputs: TInputs;
|
|
176
|
+
updateInputs: (cb: (inputs: TInputs) => void) => void;
|
|
177
|
+
getElement: (id: string) => OnChangeElementContext | undefined;
|
|
178
|
+
executeCommand: <T = unknown>(command: string, payload?: T) => void;
|
|
179
|
+
breakpoint: string;
|
|
180
|
+
log: (...args: any[]) => void;
|
|
181
|
+
stop: () => Stop;
|
|
182
|
+
continue: () => Continue;
|
|
183
|
+
};
|
|
184
|
+
export type ComponentChangeHandler<TInputs = Record<string, any>> = (ctx: ComponentChangeContext<TInputs>) => HandlerResult;
|
|
185
|
+
export type DescendantChangeHandler<TInputs = Record<string, any>, TDescendantInputs = Record<string, any>> = (ctx: DescendantChangeContext<TInputs, TDescendantInputs>) => HandlerResult;
|
|
84
186
|
export type ComponentManifest = {
|
|
85
187
|
name: string;
|
|
86
188
|
group?: string;
|
|
@@ -88,12 +190,16 @@ export type ComponentManifest = {
|
|
|
88
190
|
image?: string;
|
|
89
191
|
inputs: ComponentInput[];
|
|
90
192
|
canDrag?: boolean;
|
|
91
|
-
canDelete?: boolean;
|
|
193
|
+
canDelete?: boolean | ComponentConstraint;
|
|
92
194
|
acceptsChildren?: boolean;
|
|
93
195
|
hideFromToolbar?: boolean;
|
|
94
196
|
hideStyleSettings?: string[];
|
|
95
197
|
autoApplyStyles?: boolean;
|
|
96
|
-
tags
|
|
198
|
+
tags: string[];
|
|
199
|
+
constraints?: ComponentConstraint[];
|
|
200
|
+
descendantConstraints?: ComponentConstraint[];
|
|
201
|
+
onChange?: ComponentChangeHandler | ComponentChangeHandler[];
|
|
202
|
+
onDescendantChange?: DescendantChangeHandler | DescendantChangeHandler[];
|
|
97
203
|
defaults?: {
|
|
98
204
|
inputs?: Record<string, any>;
|
|
99
205
|
styles?: SerializableCSSStyleDeclaration;
|
|
@@ -127,6 +233,7 @@ export type Document = {
|
|
|
127
233
|
state: DocumentState;
|
|
128
234
|
version: number;
|
|
129
235
|
properties: Record<string, any>;
|
|
236
|
+
extensions: Record<string, any>;
|
|
130
237
|
metadata: DocumentMetadata;
|
|
131
238
|
bindings: DocumentBindings;
|
|
132
239
|
elements: ElementMap;
|
|
@@ -139,9 +246,7 @@ export type PublicRedirect = {
|
|
|
139
246
|
permanent: boolean;
|
|
140
247
|
};
|
|
141
248
|
export type EditorPage = EditorDocument & Pick<Page, "properties" | "status" | "location">;
|
|
142
|
-
export type EditorDocument = Document
|
|
143
|
-
metadata: Record<string, any>;
|
|
144
|
-
};
|
|
249
|
+
export type EditorDocument = Document;
|
|
145
250
|
export type Page = Document & {
|
|
146
251
|
id: string;
|
|
147
252
|
status: string;
|
|
@@ -194,6 +299,8 @@ export type BoxData = ElementBoxData | ElementSlotBoxData;
|
|
|
194
299
|
export type EditorViewportInfo = PreviewViewportInfo & {
|
|
195
300
|
top: number;
|
|
196
301
|
left: number;
|
|
302
|
+
breakpoint: string;
|
|
303
|
+
breakpoints: Breakpoint[];
|
|
197
304
|
};
|
|
198
305
|
export type PreviewViewportInfo = {
|
|
199
306
|
width: number;
|
|
@@ -328,10 +435,16 @@ export type ManifestInputsObject<TInputs, TAllowChildren extends boolean> = TAll
|
|
|
328
435
|
} : {
|
|
329
436
|
[K in keyof TInputs]: InputFactory<K & string>;
|
|
330
437
|
};
|
|
331
|
-
export type ComponentManifestInput<TInputs> = (Omit<ComponentManifest, "inputs" | "acceptsChildren"> & {
|
|
438
|
+
export type ComponentManifestInput<TInputs> = (Omit<ComponentManifest, "inputs" | "acceptsChildren" | "tags" | "onChange" | "onDescendantChange"> & {
|
|
332
439
|
acceptsChildren: true;
|
|
440
|
+
tags?: string[];
|
|
333
441
|
inputs?: ManifestInputsArray<TInputs, true> | ManifestInputsObject<TInputs, true>;
|
|
334
|
-
|
|
442
|
+
onChange?: ComponentChangeHandler<TInputs> | ComponentChangeHandler<TInputs>[];
|
|
443
|
+
onDescendantChange?: DescendantChangeHandler<TInputs> | DescendantChangeHandler<TInputs>[];
|
|
444
|
+
}) | (Omit<ComponentManifest, "inputs" | "acceptsChildren" | "tags" | "onChange" | "onDescendantChange"> & {
|
|
335
445
|
acceptsChildren?: false;
|
|
446
|
+
tags?: string[];
|
|
336
447
|
inputs: ManifestInputsArray<TInputs, false> | ManifestInputsObject<TInputs, false>;
|
|
448
|
+
onChange?: ComponentChangeHandler<TInputs> | ComponentChangeHandler<TInputs>[];
|
|
449
|
+
onDescendantChange?: DescendantChangeHandler<TInputs> | DescendantChangeHandler<TInputs>[];
|
|
337
450
|
});
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type * as CSS from \"csstype\";\nimport type { BindingsApi } from \"~/BindingsApi.js\";\nimport type { ShorthandCssProperties } from \"./types/ShorthandCssProperties.js\";\nimport type { InputFactory } from \"~/createInput.js\";\nexport type { WebsiteBuilderTheme, Breakpoint } from \"./types/WebsiteBuilderTheme.js\";\n\ntype CSSProperties = CSS.Properties<string | number>;\n\nexport type ElementMap = Record<string, DocumentElement>;\n\nexport type DocumentState = Record<string, any>;\n\nexport type DocumentMetadata = Record<string, any>;\n\nexport type InputValueBinding<T = any> = ValueBinding<T> & {\n id: string;\n type: string;\n translatable?: boolean;\n list?: boolean;\n};\n\nexport type StyleValueBinding<T = any> = ValueBinding<T>;\n\nexport type ValueBinding<T = any> = {\n static?: T;\n expression?: string;\n};\n\nexport type RepeatValueBinding = {\n expression: string;\n};\n\nexport type CssProperties = Omit<CSSProperties, ShorthandCssProperties>;\n\nexport type DocumentElementStyleBindings = Partial<{\n [K in keyof CssProperties]: StyleValueBinding<CssProperties[K]>;\n}>;\n\nexport type DocumentElementInputBindings = {\n [inputName: string]: InputValueBinding;\n};\n\nexport type DocumentElementBindings = {\n $repeat?: RepeatValueBinding;\n inputs?: DocumentElementInputBindings;\n styles?: DocumentElementStyleBindings;\n metadata?: Record<string, any>;\n overrides?: {\n [key: string]: {\n inputs?: DocumentElementInputBindings;\n styles?: DocumentElementStyleBindings;\n };\n };\n};\n\nexport type DocumentBindings = {\n [elementId: string]: DocumentElementBindings;\n};\n\nexport type ResolvedComponent<TComponent = any> = {\n component: TComponent;\n inputs: Record<string, any>;\n manifest: ComponentManifest;\n styles: SerializableCSSStyleDeclaration;\n};\n\nexport type ResolvedElement = {\n id: string;\n inputs: Record<string, any>;\n styles: SerializableCSSStyleDeclaration;\n};\n\nexport type Component = {\n component: any;\n manifest: ComponentManifest;\n};\n\nexport type ComponentBlueprint<TComponent = any, TManifest = any> = {\n component: TComponent;\n manifest: TManifest;\n};\n\nexport type ComponentGroupItem = {\n // Name of the component.\n name: string;\n // Optionally, define an exact element to insert.\n item?: DocumentElementTemplate;\n};\n\nexport type SerializedComponentGroup = ComponentGroup & {\n filter?: string;\n};\n\nexport type ComponentGroupFilterContext = {\n document: EditorDocument;\n};\n\nexport type ComponentGroup = {\n name: string;\n label: string;\n description?: string;\n filter?: (component: ComponentManifest, context: ComponentGroupFilterContext) => boolean;\n};\n\nexport type ResponsiveStyles = {\n [key: string]: SerializableCSSStyleDeclaration;\n};\n\nexport type ComponentManifest = {\n name: string;\n group?: string;\n label?: string;\n image?: string;\n inputs: ComponentInput[];\n canDrag?: boolean;\n canDelete?: boolean;\n acceptsChildren?: boolean;\n hideFromToolbar?: boolean;\n hideStyleSettings?: string[];\n autoApplyStyles?: boolean;\n tags?: string[];\n defaults?: {\n inputs?: Record<string, any>;\n styles?: SerializableCSSStyleDeclaration;\n overrides?: {\n [breakpoint: string]: {\n inputs?: Record<string, any>;\n styles?: SerializableCSSStyleDeclaration;\n };\n };\n };\n};\n\nexport type DocumentElementTemplate = Omit<DocumentElement, \"id\">;\n\nexport type ElementComponent = {\n name: string;\n};\n\nexport type DocumentElement = {\n type: \"Webiny/Element\";\n id: string;\n component: ElementComponent;\n parent?: {\n id: string;\n slot: string;\n };\n styles?: ResponsiveStyles;\n};\n\nexport type SerializableCSSStyleDeclaration = {\n [K in keyof CssProperties]?: CssProperties[K];\n};\n\nexport type Document = {\n id: string;\n state: DocumentState;\n version: number;\n properties: Record<string, any>;\n metadata: DocumentMetadata;\n bindings: DocumentBindings;\n elements: ElementMap;\n};\n\nexport type PublicPage = Pick<\n Page,\n \"id\" | \"version\" | \"properties\" | \"bindings\" | \"elements\" | \"extensions\" | \"metadata\" | \"state\"\n>;\n\nexport type PublicRedirect = {\n id: string;\n from: string;\n to: string;\n permanent: boolean;\n};\n\nexport type EditorPage = EditorDocument & Pick<Page, \"properties\" | \"status\" | \"location\">;\n\nexport type EditorDocument = Document & {\n metadata: Record<string, any>;\n};\n\nexport type Page = Document & {\n id: string;\n status: string;\n version: number;\n location: {\n folderId: string;\n };\n properties: {\n title: string;\n snippet: string;\n /*image: {\n id: string;\n name: string;\n size: number;\n mimeType: string;\n src: string;\n };*/\n path: string;\n tags: string[];\n seo: {\n title: string;\n description: string;\n metaTags: Array<{ name: string; content: string }>;\n };\n social: {\n title: string;\n description: string;\n /*image: {\n id: string;\n name: string;\n size: number;\n mimeType: string;\n src: string;\n };*/\n metaTags: Array<{ property: string; content: string }>;\n };\n };\n extensions: Record<string, any>;\n metadata: DocumentMetadata;\n};\n\nexport type Box = {\n depth: number;\n parentId: string;\n parentSlot: string;\n parentIndex: number;\n width: number;\n height: number;\n top: number;\n left: number;\n};\n\nexport type ElementBoxData = Box & {\n type: \"element\";\n};\n\nexport type ElementSlotBoxData = Box & {\n type: \"element-slot\";\n};\n\nexport type BoxData = ElementBoxData | ElementSlotBoxData;\n\nexport type EditorViewportInfo = PreviewViewportInfo & {\n top: number;\n left: number;\n};\n\nexport type PreviewViewportInfo = {\n // Viewport width (only the visible part)\n width: number;\n // Viewport height (only the visible part)\n height: number;\n // Full iframe width\n scrollWidth: number;\n // Full iframe height\n scrollHeight: number;\n // Iframe horizontal scroll offset\n scrollX: number;\n // Iframe vertical scroll offest\n scrollY: number;\n};\n\nexport type BoxesData = Record<string, BoxData>;\n\nexport type EditorViewportData = {\n boxes: BoxesData;\n viewport: EditorViewportInfo;\n};\n\nexport type PreviewViewportData = {\n boxes: BoxesData;\n viewport: PreviewViewportInfo;\n};\n\nexport type ApiOptions = Record<string, any>;\n\nexport type GetPageOptions = ApiOptions;\n\nexport interface ListPagesOptions {\n where?: Record<string, any>;\n limit?: number;\n after?: string;\n sort?: string[];\n search?: string;\n}\n\nexport interface ListPagesMeta {\n hasMoreItems: boolean;\n totalCount: number;\n cursor: string | null;\n}\n\nexport interface ListPagesResult {\n data: Array<Omit<PublicPage, \"elements\" | \"bindings\">>;\n meta: ListPagesMeta;\n}\n\nexport interface IDataProvider {\n getPageByPath(path: string, options?: GetPageOptions): Promise<PublicPage | null>;\n getPageById(id: string, options?: GetPageOptions): Promise<PublicPage | null>;\n listPages(options?: ListPagesOptions): Promise<ListPagesResult>;\n}\n\nexport interface IEnvironment {\n isClient(): boolean;\n isServer(): boolean;\n isPreview(): boolean;\n}\n\nexport interface IContentSdk {\n getPage(path: string): Promise<PublicPage | null>;\n listPages(options?: ListPagesOptions): Promise<ListPagesResult>;\n}\n\n// Input types\n\n// inputTypes.ts\nexport type BaseInput<T = any> = {\n name: string;\n type: string;\n onChange?: (\n bindings: ReturnType<BindingsApi[\"getPublicApi\"]>,\n context: { breakpoint: string }\n ) => void;\n label?: string;\n description?: string;\n helperText?: string;\n defaultValue?: T;\n responsive?: boolean;\n required?: boolean;\n hideFromUi?: boolean;\n renderer?: string;\n list?: boolean;\n translatable?: boolean;\n};\n\n// Discriminated union per input type\nexport type TextInput = BaseInput<string> & {\n type: \"text\";\n};\n\nexport type SlotInput = BaseInput<any> & {\n type: \"slot\";\n components?: string[];\n};\n\nexport type TagsInput = BaseInput<string[]> & {\n type: \"text\";\n};\n\nexport type LongTextInput = BaseInput<string> & {\n type: \"longText\";\n};\n\nexport type NumberInput = BaseInput<number> & {\n type: \"number\";\n minValue?: number;\n};\n\nexport type BooleanInput = BaseInput<boolean> & {\n type: \"boolean\";\n};\n\nexport type ColorInput = BaseInput<string> & {\n type: \"color\";\n};\n\nexport type FileInput = BaseInput<string> & {\n type: \"file\";\n allowedFileTypes: string[];\n};\n\nexport type DateTimeInput = BaseInput<string> & {\n type: \"datetime\";\n};\n\nexport type LexicalInput = BaseInput<string> & {\n type: \"lexical\";\n};\n\nexport type SelectInput = BaseInput<string> & {\n type: \"select\";\n options: { label: string; value: string }[];\n showResetAction?: boolean;\n};\n\nexport type RadioInput = BaseInput<string> & {\n type: \"radio\";\n options: { label: string; value: string }[];\n};\n\nexport type ObjectInput = BaseInput<Record<string, any>> & {\n type: \"object\";\n fields: ComponentInput[];\n};\n\nexport type CustomInput = BaseInput<any> & {\n type: string;\n fields: ComponentInput[];\n};\n\n// Union of all input types\nexport type ComponentInput =\n | TextInput\n | LongTextInput\n | NumberInput\n | BooleanInput\n | ColorInput\n | FileInput\n | DateTimeInput\n | LexicalInput\n | SelectInput\n | RadioInput\n | TagsInput\n | ObjectInput\n | SlotInput\n | CustomInput;\n\nexport type ManifestInputsArray<\n TInputs,\n TAllowChildren extends boolean\n> = TAllowChildren extends true\n ? {\n [K in Exclude<keyof TInputs, \"children\">]: InputFactory<K & string>;\n }[Exclude<keyof TInputs, \"children\">][]\n : {\n [K in keyof TInputs]: InputFactory<K & string>;\n }[keyof TInputs][];\n\nexport type ManifestInputsObject<\n TInputs,\n TAllowChildren extends boolean\n> = TAllowChildren extends true\n ? { [K in Exclude<keyof TInputs, \"children\">]: InputFactory<K & string> }\n : { [K in keyof TInputs]: InputFactory<K & string> };\n\nexport type ComponentManifestInput<TInputs> =\n | (Omit<ComponentManifest, \"inputs\" | \"acceptsChildren\"> & {\n acceptsChildren: true;\n inputs?: ManifestInputsArray<TInputs, true> | ManifestInputsObject<TInputs, true>;\n })\n | (Omit<ComponentManifest, \"inputs\" | \"acceptsChildren\"> & {\n acceptsChildren?: false;\n inputs: ManifestInputsArray<TInputs, false> | ManifestInputsObject<TInputs, false>;\n });\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type * as CSS from \"csstype\";\nimport type { BindingsApi } from \"~/BindingsApi.js\";\nimport type { ShorthandCssProperties } from \"./types/ShorthandCssProperties.js\";\nimport type { InputFactory } from \"~/createInput.js\";\nimport type { Breakpoint } from \"~/types/WebsiteBuilderTheme.js\";\nexport type { WebsiteBuilderTheme, Breakpoint } from \"./types/WebsiteBuilderTheme.js\";\n\ntype CSSProperties = CSS.Properties<string | number>;\n\nexport type ElementMap = Record<string, DocumentElement>;\n\nexport type DocumentState = Record<string, any>;\n\nexport type DocumentMetadata = Record<string, any>;\n\nexport type InputValueBinding<T = any> = ValueBinding<T> & {\n id: string;\n type: string;\n translatable?: boolean;\n list?: boolean;\n};\n\nexport type StyleValueBinding<T = any> = ValueBinding<T>;\n\nexport type ValueBinding<T = any> = {\n static?: T;\n expression?: string;\n};\n\nexport type RepeatValueBinding = {\n expression: string;\n};\n\nexport type CssProperties = Omit<CSSProperties, ShorthandCssProperties>;\n\nexport type DocumentElementStyleBindings = Partial<{\n [K in keyof CssProperties]: StyleValueBinding<CssProperties[K]>;\n}>;\n\nexport type DocumentElementInputBindings = {\n [inputName: string]: InputValueBinding;\n};\n\nexport type DocumentElementBindings = {\n $repeat?: RepeatValueBinding;\n inputs?: DocumentElementInputBindings;\n styles?: DocumentElementStyleBindings;\n metadata?: Record<string, any>;\n overrides?: {\n [key: string]: {\n inputs?: DocumentElementInputBindings;\n styles?: DocumentElementStyleBindings;\n };\n };\n};\n\nexport type DocumentBindings = {\n [elementId: string]: DocumentElementBindings;\n};\n\nexport type ResolvedComponent<TComponent = any> = {\n component: TComponent;\n inputs: Record<string, any>;\n manifest: ComponentManifest;\n styles: SerializableCSSStyleDeclaration;\n};\n\nexport type ResolvedElement = {\n id: string;\n inputs: Record<string, any>;\n styles: SerializableCSSStyleDeclaration;\n};\n\nexport type Component = {\n component: any;\n manifest: ComponentManifest;\n};\n\nexport type ComponentBlueprint<TComponent = any, TManifest = any> = {\n component: TComponent;\n manifest: TManifest;\n};\n\nexport type ComponentGroupItem = {\n // Name of the component.\n name: string;\n // Optionally, define an exact element to insert.\n item?: DocumentElementTemplate;\n};\n\nexport type SerializedComponentGroup = ComponentGroup & {\n filter?: string;\n};\n\nexport type ComponentGroupFilterContext = {\n document: EditorDocument;\n};\n\nexport type ComponentGroup = {\n name: string;\n label: string;\n description?: string;\n filter?: (component: ComponentManifest, context: ComponentGroupFilterContext) => boolean;\n};\n\nexport type ResponsiveStyles = {\n [key: string]: SerializableCSSStyleDeclaration;\n};\n\nexport type ConstraintElementContext = {\n /** Component name (e.g., \"FunnelBuilder/Step\") */\n name: string;\n /** Component tags */\n tags: string[];\n\n /** Get the parent element context. undefined for root. */\n getParent(): ConstraintElementContext | undefined;\n\n /** Index of this element among siblings in the same parent slot. -1 if not in a list slot. */\n childIndex(): number;\n /** Total siblings in the same parent slot. -1 if not in a list slot. */\n childCount(): number;\n /** True if this element is the last among siblings in its parent slot. */\n isLastChild(): boolean;\n /** True if this element is the first among siblings in its parent slot. */\n isFirstChild(): boolean;\n};\n\nexport type ConstraintContext = {\n /** The component/element this constraint is about */\n component: ConstraintElementContext;\n /** The direct parent element at the drop target */\n parent: ConstraintElementContext;\n /** The target slot name (e.g., \"children\", \"leftColumn\", \"rightColumn\") */\n slot: string;\n /** True if the direct parent is the given component */\n isChildOf: (componentName: string) => boolean;\n /** True if any ancestor (including parent) is the given component */\n isDescendantOf: (componentName: string) => boolean;\n /** Find the nearest ancestor matching a component name */\n getAncestor: (componentName: string) => ConstraintElementContext | undefined;\n /** True if the component being placed has the given tag */\n hasTag: (tag: string) => boolean;\n /** Number of items currently in the target slot */\n slotChildCount: () => number;\n /** Count instances of a component type in the entire document */\n countInstances: (componentName: string) => number;\n /** True if the component has any descendant element carrying the given tag */\n hasDescendantWithTag: (tag: string) => boolean;\n /** Returns the resolved inputs of the nearest ancestor matching componentName, or undefined */\n getAncestorInputs: (componentName: string) => Record<string, any> | undefined;\n /** Returns the resolved inputs of the element this constraint is evaluating */\n getElementInputs: () => Record<string, any>;\n /** Debug logger — safe to call inside serialized constraints */\n log: (...args: any[]) => void;\n /** Block placement with an error message shown to the user */\n block: (message: string) => never;\n};\n\n/**\n * A constraint function. Call `ctx.block(\"message\")` to block placement.\n * Returning without blocking means the constraint passes.\n */\nexport type ComponentConstraint = (ctx: ConstraintContext) => void;\n\n// Flow-control symbols\nexport type Stop = symbol;\nexport type Continue = symbol;\nexport type HandlerResult = void | Stop | Continue;\n\nexport type OnChangeAction = \"create\" | \"update\" | \"delete\";\n\nexport type OnChangeElementContext = {\n id: string;\n component: ComponentManifest;\n inputs: Record<string, any>;\n};\n\nexport type ManifestAncestorContext = {\n id: string;\n component: ComponentManifest;\n inputs: Record<string, any>;\n updateInputs: (cb: (inputs: Record<string, any>) => void) => void;\n getElement: (id: string) => OnChangeElementContext | undefined;\n};\n\nexport type ComponentChangeContext<TInputs = Record<string, any>> = {\n action: OnChangeAction;\n id: string;\n component: ComponentManifest;\n inputs: TInputs;\n styles: Record<string, any>;\n getAncestor: (componentName: string) => ManifestAncestorContext | undefined;\n getElement: (id: string) => OnChangeElementContext | undefined;\n createElement: (params: any) => any;\n executeCommand: <T = unknown>(command: string, payload?: T) => void;\n breakpoint: string;\n log: (...args: any[]) => void;\n stop: () => Stop;\n continue: () => Continue;\n};\n\nexport type DescendantChangeContext<\n TInputs = Record<string, any>,\n TDescendantInputs = Record<string, any>\n> = {\n action: OnChangeAction;\n descendant: {\n component: ComponentManifest;\n id: string;\n inputs: TDescendantInputs;\n updateInputs: (cb: (inputs: TDescendantInputs) => void) => void;\n };\n inputs: TInputs;\n updateInputs: (cb: (inputs: TInputs) => void) => void;\n getElement: (id: string) => OnChangeElementContext | undefined;\n executeCommand: <T = unknown>(command: string, payload?: T) => void;\n breakpoint: string;\n log: (...args: any[]) => void;\n stop: () => Stop;\n continue: () => Continue;\n};\n\nexport type ComponentChangeHandler<TInputs = Record<string, any>> = (\n ctx: ComponentChangeContext<TInputs>\n) => HandlerResult;\n\nexport type DescendantChangeHandler<\n TInputs = Record<string, any>,\n TDescendantInputs = Record<string, any>\n> = (ctx: DescendantChangeContext<TInputs, TDescendantInputs>) => HandlerResult;\n\nexport type ComponentManifest = {\n name: string;\n group?: string;\n label?: string;\n image?: string;\n inputs: ComponentInput[];\n canDrag?: boolean;\n canDelete?: boolean | ComponentConstraint;\n acceptsChildren?: boolean;\n hideFromToolbar?: boolean;\n hideStyleSettings?: string[];\n autoApplyStyles?: boolean;\n tags: string[];\n constraints?: ComponentConstraint[];\n descendantConstraints?: ComponentConstraint[];\n onChange?: ComponentChangeHandler | ComponentChangeHandler[];\n onDescendantChange?: DescendantChangeHandler | DescendantChangeHandler[];\n defaults?: {\n inputs?: Record<string, any>;\n styles?: SerializableCSSStyleDeclaration;\n overrides?: {\n [breakpoint: string]: {\n inputs?: Record<string, any>;\n styles?: SerializableCSSStyleDeclaration;\n };\n };\n };\n};\n\nexport type DocumentElementTemplate = Omit<DocumentElement, \"id\">;\n\nexport type ElementComponent = {\n name: string;\n};\n\nexport type DocumentElement = {\n type: \"Webiny/Element\";\n id: string;\n component: ElementComponent;\n parent?: {\n id: string;\n slot: string;\n };\n styles?: ResponsiveStyles;\n};\n\nexport type SerializableCSSStyleDeclaration = {\n [K in keyof CssProperties]?: CssProperties[K];\n};\n\nexport type Document = {\n id: string;\n state: DocumentState;\n version: number;\n properties: Record<string, any>;\n extensions: Record<string, any>;\n metadata: DocumentMetadata;\n bindings: DocumentBindings;\n elements: ElementMap;\n};\n\nexport type PublicPage = Pick<\n Page,\n \"id\" | \"version\" | \"properties\" | \"bindings\" | \"elements\" | \"extensions\" | \"metadata\" | \"state\"\n>;\n\nexport type PublicRedirect = {\n id: string;\n from: string;\n to: string;\n permanent: boolean;\n};\n\nexport type EditorPage = EditorDocument & Pick<Page, \"properties\" | \"status\" | \"location\">;\n\nexport type EditorDocument = Document;\n\nexport type Page = Document & {\n id: string;\n status: string;\n version: number;\n location: {\n folderId: string;\n };\n properties: {\n title: string;\n snippet: string;\n /*image: {\n id: string;\n name: string;\n size: number;\n mimeType: string;\n src: string;\n };*/\n path: string;\n tags: string[];\n seo: {\n title: string;\n description: string;\n metaTags: Array<{ name: string; content: string }>;\n };\n social: {\n title: string;\n description: string;\n /*image: {\n id: string;\n name: string;\n size: number;\n mimeType: string;\n src: string;\n };*/\n metaTags: Array<{ property: string; content: string }>;\n };\n };\n extensions: Record<string, any>;\n metadata: DocumentMetadata;\n};\n\nexport type Box = {\n depth: number;\n parentId: string;\n parentSlot: string;\n parentIndex: number;\n width: number;\n height: number;\n top: number;\n left: number;\n};\n\nexport type ElementBoxData = Box & {\n type: \"element\";\n};\n\nexport type ElementSlotBoxData = Box & {\n type: \"element-slot\";\n};\n\nexport type BoxData = ElementBoxData | ElementSlotBoxData;\n\nexport type EditorViewportInfo = PreviewViewportInfo & {\n top: number;\n left: number;\n // Current breakpoint name\n breakpoint: string;\n breakpoints: Breakpoint[];\n};\n\nexport type PreviewViewportInfo = {\n // Viewport width (only the visible part)\n width: number;\n // Viewport height (only the visible part)\n height: number;\n // Full iframe width\n scrollWidth: number;\n // Full iframe height\n scrollHeight: number;\n // Iframe horizontal scroll offset\n scrollX: number;\n // Iframe vertical scroll offest\n scrollY: number;\n};\n\nexport type BoxesData = Record<string, BoxData>;\n\nexport type EditorViewportData = {\n boxes: BoxesData;\n viewport: EditorViewportInfo;\n};\n\nexport type PreviewViewportData = {\n boxes: BoxesData;\n viewport: PreviewViewportInfo;\n};\n\nexport type ApiOptions = Record<string, any>;\n\nexport type GetPageOptions = ApiOptions;\n\nexport interface ListPagesOptions {\n where?: Record<string, any>;\n limit?: number;\n after?: string;\n sort?: string[];\n search?: string;\n}\n\nexport interface ListPagesMeta {\n hasMoreItems: boolean;\n totalCount: number;\n cursor: string | null;\n}\n\nexport interface ListPagesResult {\n data: Array<Omit<PublicPage, \"elements\" | \"bindings\">>;\n meta: ListPagesMeta;\n}\n\nexport interface IDataProvider {\n getPageByPath(path: string, options?: GetPageOptions): Promise<PublicPage | null>;\n getPageById(id: string, options?: GetPageOptions): Promise<PublicPage | null>;\n listPages(options?: ListPagesOptions): Promise<ListPagesResult>;\n}\n\nexport interface IEnvironment {\n isClient(): boolean;\n isServer(): boolean;\n isPreview(): boolean;\n}\n\nexport interface IContentSdk {\n getPage(path: string): Promise<PublicPage | null>;\n listPages(options?: ListPagesOptions): Promise<ListPagesResult>;\n}\n\n// Input types\n\n// inputTypes.ts\nexport type BaseInput<T = any> = {\n name: string;\n type: string;\n onChange?: (\n bindings: ReturnType<BindingsApi[\"getPublicApi\"]>,\n context: { breakpoint: string }\n ) => void;\n label?: string;\n description?: string;\n helperText?: string;\n defaultValue?: T;\n responsive?: boolean;\n required?: boolean;\n hideFromUi?: boolean;\n renderer?: string;\n list?: boolean;\n translatable?: boolean;\n};\n\n// Discriminated union per input type\nexport type TextInput = BaseInput<string> & {\n type: \"text\";\n};\n\nexport type SlotInput = BaseInput<any> & {\n type: \"slot\";\n components?: string[];\n};\n\nexport type TagsInput = BaseInput<string[]> & {\n type: \"text\";\n};\n\nexport type LongTextInput = BaseInput<string> & {\n type: \"longText\";\n};\n\nexport type NumberInput = BaseInput<number> & {\n type: \"number\";\n minValue?: number;\n};\n\nexport type BooleanInput = BaseInput<boolean> & {\n type: \"boolean\";\n};\n\nexport type ColorInput = BaseInput<string> & {\n type: \"color\";\n};\n\nexport type FileInput = BaseInput<string> & {\n type: \"file\";\n allowedFileTypes: string[];\n};\n\nexport type DateTimeInput = BaseInput<string> & {\n type: \"datetime\";\n};\n\nexport type LexicalInput = BaseInput<string> & {\n type: \"lexical\";\n};\n\nexport type SelectInput = BaseInput<string> & {\n type: \"select\";\n options: { label: string; value: string }[];\n showResetAction?: boolean;\n};\n\nexport type RadioInput = BaseInput<string> & {\n type: \"radio\";\n options: { label: string; value: string }[];\n};\n\nexport type ObjectInput = BaseInput<Record<string, any>> & {\n type: \"object\";\n fields: ComponentInput[];\n};\n\nexport type CustomInput = BaseInput<any> & {\n type: string;\n fields: ComponentInput[];\n};\n\n// Union of all input types\nexport type ComponentInput =\n | TextInput\n | LongTextInput\n | NumberInput\n | BooleanInput\n | ColorInput\n | FileInput\n | DateTimeInput\n | LexicalInput\n | SelectInput\n | RadioInput\n | TagsInput\n | ObjectInput\n | SlotInput\n | CustomInput;\n\nexport type ManifestInputsArray<\n TInputs,\n TAllowChildren extends boolean\n> = TAllowChildren extends true\n ? {\n [K in Exclude<keyof TInputs, \"children\">]: InputFactory<K & string>;\n }[Exclude<keyof TInputs, \"children\">][]\n : {\n [K in keyof TInputs]: InputFactory<K & string>;\n }[keyof TInputs][];\n\nexport type ManifestInputsObject<\n TInputs,\n TAllowChildren extends boolean\n> = TAllowChildren extends true\n ? { [K in Exclude<keyof TInputs, \"children\">]: InputFactory<K & string> }\n : { [K in keyof TInputs]: InputFactory<K & string> };\n\nexport type ComponentManifestInput<TInputs> =\n | (Omit<\n ComponentManifest,\n \"inputs\" | \"acceptsChildren\" | \"tags\" | \"onChange\" | \"onDescendantChange\"\n > & {\n acceptsChildren: true;\n tags?: string[];\n inputs?: ManifestInputsArray<TInputs, true> | ManifestInputsObject<TInputs, true>;\n onChange?: ComponentChangeHandler<TInputs> | ComponentChangeHandler<TInputs>[];\n onDescendantChange?:\n | DescendantChangeHandler<TInputs>\n | DescendantChangeHandler<TInputs>[];\n })\n | (Omit<\n ComponentManifest,\n \"inputs\" | \"acceptsChildren\" | \"tags\" | \"onChange\" | \"onDescendantChange\"\n > & {\n acceptsChildren?: false;\n tags?: string[];\n inputs: ManifestInputsArray<TInputs, false> | ManifestInputsObject<TInputs, false>;\n onChange?: ComponentChangeHandler<TInputs> | ComponentChangeHandler<TInputs>[];\n onDescendantChange?:\n | DescendantChangeHandler<TInputs>\n | DescendantChangeHandler<TInputs>[];\n });\n"],"mappings":"","ignoreList":[]}
|