@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/Theme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"Theme.js","sources":["../src/Theme.ts"],"sourcesContent":["import deepMerge from \"deepmerge\";\nimport type {\n Breakpoint,\n WebsiteBuilderTheme,\n WebsiteBuilderThemeInput\n} from \"~/types/WebsiteBuilderTheme.js\";\nimport { defaultBreakpoints } from \"~/defaultBreakpoints.js\";\n\nexport class Theme {\n static from(input: WebsiteBuilderThemeInput): WebsiteBuilderTheme {\n const { custom = {}, ...builtInOverrides } = input?.breakpoints ?? {};\n\n const mergedBreakpoints = deepMerge.all([\n {},\n defaultBreakpoints,\n builtInOverrides,\n custom\n ]) as WebsiteBuilderThemeInput[\"breakpoints\"];\n\n const breakpoints: Breakpoint[] = [];\n Object.entries(mergedBreakpoints ?? {}).forEach(([name, breakpoint]) => {\n breakpoints.push({\n name,\n ...(breakpoint as Omit<Breakpoint, \"name\">)\n });\n });\n\n return {\n css: input.css,\n fonts: input.fonts,\n breakpoints: breakpoints.sort((a, b) => b.maxWidth - a.maxWidth),\n colors: input?.colors ?? [],\n typography: {\n ...input?.typography\n }\n };\n }\n}\n"],"names":["Theme","input","custom","builtInOverrides","mergedBreakpoints","deepMerge","defaultBreakpoints","breakpoints","Object","name","breakpoint","a","b"],"mappings":";;AAQO,MAAMA;IACT,OAAO,KAAKC,KAA+B,EAAuB;QAC9D,MAAM,EAAEC,SAAS,CAAC,CAAC,EAAE,GAAGC,kBAAkB,GAAGF,OAAO,eAAe,CAAC;QAEpE,MAAMG,oBAAoBC,UAAAA,GAAa,CAAC;YACpC,CAAC;YACDC;YACAH;YACAD;SACH;QAED,MAAMK,cAA4B,EAAE;QACpCC,OAAO,OAAO,CAACJ,qBAAqB,CAAC,GAAG,OAAO,CAAC,CAAC,CAACK,MAAMC,WAAW;YAC/DH,YAAY,IAAI,CAAC;gBACbE;gBACA,GAAIC,UAAU;YAClB;QACJ;QAEA,OAAO;YACH,KAAKT,MAAM,GAAG;YACd,OAAOA,MAAM,KAAK;YAClB,aAAaM,YAAY,IAAI,CAAC,CAACI,GAAGC,IAAMA,EAAE,QAAQ,GAAGD,EAAE,QAAQ;YAC/D,QAAQV,OAAO,UAAU,EAAE;YAC3B,YAAY;gBACR,GAAGA,OAAO,UAAU;YACxB;QACJ;IACJ;AACJ"}
|
package/ViewportManager.js
CHANGED
|
@@ -1,110 +1,98 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
2
|
import { environment } from "./Environment.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
passive: true
|
|
27
|
-
});
|
|
3
|
+
class ViewportManager {
|
|
4
|
+
constructor(timeout = 150){
|
|
5
|
+
this.breakpoints = [
|
|
6
|
+
{
|
|
7
|
+
name: "desktop",
|
|
8
|
+
title: "",
|
|
9
|
+
description: "",
|
|
10
|
+
icon: "",
|
|
11
|
+
minWidth: 0,
|
|
12
|
+
maxWidth: 4000
|
|
13
|
+
}
|
|
14
|
+
];
|
|
15
|
+
this.changeTimeout = timeout;
|
|
16
|
+
this.changeStartSubscribers = new Set();
|
|
17
|
+
this.changeEndSubscribers = new Set();
|
|
18
|
+
this.isChanging = false;
|
|
19
|
+
this.changeTimer = null;
|
|
20
|
+
this.handleViewportChange = this.handleViewportChange.bind(this);
|
|
21
|
+
this.handleResize = this.handleResize.bind(this);
|
|
22
|
+
if (environment.isClient()) window.addEventListener("resize", this.handleResize, {
|
|
23
|
+
passive: true
|
|
24
|
+
});
|
|
28
25
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
26
|
+
setBreakpoints(breakpoints) {
|
|
27
|
+
this.breakpoints = breakpoints;
|
|
28
|
+
}
|
|
29
|
+
onViewportChangeStart(callback) {
|
|
30
|
+
this.changeStartSubscribers.add(callback);
|
|
31
|
+
return ()=>this.changeStartSubscribers.delete(callback);
|
|
32
|
+
}
|
|
33
|
+
onViewportChangeEnd(callback) {
|
|
34
|
+
this.changeEndSubscribers.add(callback);
|
|
35
|
+
return ()=>this.changeEndSubscribers.delete(callback);
|
|
36
|
+
}
|
|
37
|
+
getViewport() {
|
|
38
|
+
return this.getViewportInfo();
|
|
39
|
+
}
|
|
40
|
+
destroy() {
|
|
41
|
+
if (environment.isClient()) {
|
|
42
|
+
window.removeEventListener("resize", this.handleResize);
|
|
43
|
+
if (null !== this.changeTimer) clearTimeout(this.changeTimer);
|
|
44
|
+
this.changeStartSubscribers.clear();
|
|
45
|
+
this.changeEndSubscribers.clear();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
handleResize() {
|
|
49
|
+
this.handleViewportChange();
|
|
50
|
+
}
|
|
51
|
+
handleViewportChange() {
|
|
52
|
+
const viewportInfo = this.getViewportInfo();
|
|
53
|
+
if (!this.isChanging) {
|
|
54
|
+
this.isChanging = true;
|
|
55
|
+
this.notifySubscribers(this.changeStartSubscribers, viewportInfo);
|
|
56
|
+
}
|
|
57
|
+
if (null !== this.changeTimer) clearTimeout(this.changeTimer);
|
|
58
|
+
this.changeTimer = window.setTimeout(()=>{
|
|
59
|
+
this.isChanging = false;
|
|
60
|
+
this.notifySubscribers(this.changeEndSubscribers, viewportInfo);
|
|
61
|
+
}, this.changeTimeout);
|
|
56
62
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
getViewportInfo() {
|
|
64
|
+
const modes = [
|
|
65
|
+
...this.breakpoints
|
|
66
|
+
].reverse();
|
|
67
|
+
const viewport = environment.isClient() ? {
|
|
68
|
+
width: window.innerWidth,
|
|
69
|
+
height: window.innerHeight,
|
|
70
|
+
scrollWidth: window.document.body.scrollWidth,
|
|
71
|
+
scrollHeight: window.document.body.scrollHeight,
|
|
72
|
+
scrollX: window.scrollX,
|
|
73
|
+
scrollY: window.scrollY
|
|
74
|
+
} : {
|
|
75
|
+
height: 0,
|
|
76
|
+
width: 2000,
|
|
77
|
+
scrollHeight: 0,
|
|
78
|
+
scrollWidth: 2000,
|
|
79
|
+
scrollX: 0,
|
|
80
|
+
scrollY: 0
|
|
81
|
+
};
|
|
82
|
+
const [breakpoint] = modes.filter((mode)=>mode.maxWidth >= viewport.width);
|
|
83
|
+
return {
|
|
84
|
+
...viewport,
|
|
85
|
+
breakpoint: breakpoint.name,
|
|
86
|
+
breakpoints: this.breakpoints
|
|
87
|
+
};
|
|
66
88
|
}
|
|
67
|
-
|
|
68
|
-
|
|
89
|
+
notifySubscribers(subscribers, viewportInfo) {
|
|
90
|
+
subscribers.forEach((callback)=>{
|
|
91
|
+
if ("function" == typeof callback) callback(viewportInfo);
|
|
92
|
+
});
|
|
69
93
|
}
|
|
70
|
-
this.changeTimer = window.setTimeout(() => {
|
|
71
|
-
this.isChanging = false;
|
|
72
|
-
this.notifySubscribers(this.changeEndSubscribers, viewportInfo);
|
|
73
|
-
}, this.changeTimeout);
|
|
74
|
-
}
|
|
75
|
-
getViewportInfo() {
|
|
76
|
-
const modes = [...this.breakpoints].reverse();
|
|
77
|
-
const viewport = environment.isClient() ? {
|
|
78
|
-
width: window.innerWidth,
|
|
79
|
-
height: window.innerHeight,
|
|
80
|
-
scrollWidth: window.document.body.scrollWidth,
|
|
81
|
-
scrollHeight: window.document.body.scrollHeight,
|
|
82
|
-
scrollX: window.scrollX,
|
|
83
|
-
scrollY: window.scrollY
|
|
84
|
-
} : {
|
|
85
|
-
// During SSR or Next.js build, viewport is not available.
|
|
86
|
-
height: 0,
|
|
87
|
-
width: 2000,
|
|
88
|
-
scrollHeight: 0,
|
|
89
|
-
scrollWidth: 2000,
|
|
90
|
-
scrollX: 0,
|
|
91
|
-
scrollY: 0
|
|
92
|
-
};
|
|
93
|
-
const [breakpoint] = modes.filter(mode => mode.maxWidth >= viewport.width);
|
|
94
|
-
return {
|
|
95
|
-
...viewport,
|
|
96
|
-
breakpoint: breakpoint.name,
|
|
97
|
-
breakpoints: this.breakpoints
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
notifySubscribers(subscribers, viewportInfo) {
|
|
101
|
-
subscribers.forEach(callback => {
|
|
102
|
-
if (typeof callback === "function") {
|
|
103
|
-
callback(viewportInfo);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
94
|
}
|
|
108
|
-
|
|
95
|
+
const viewportManager = new ViewportManager();
|
|
96
|
+
export { ViewportManager, viewportManager };
|
|
109
97
|
|
|
110
98
|
//# sourceMappingURL=ViewportManager.js.map
|
package/ViewportManager.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"ViewportManager.js","sources":["../src/ViewportManager.ts"],"sourcesContent":["\"use client\";\nimport type { Breakpoint } from \"~/types.js\";\nimport { environment } from \"~/Environment.js\";\n\nexport interface ViewportInfo {\n width: number;\n height: number;\n scrollWidth: number;\n scrollHeight: number;\n scrollX: number;\n scrollY: number;\n breakpoint: string;\n breakpoints: Breakpoint[];\n}\n\nexport class ViewportManager {\n private readonly changeTimeout: number;\n private readonly changeStartSubscribers: Set<(info: ViewportInfo) => void>;\n private readonly changeEndSubscribers: Set<(info: ViewportInfo) => void>;\n private isChanging: boolean;\n private changeTimer: number | null;\n\n /**\n * We need this fallback breakpoint for server environments.\n */\n private breakpoints: Breakpoint[] = [\n {\n name: \"desktop\",\n title: \"\",\n description: \"\",\n icon: \"\",\n minWidth: 0,\n maxWidth: 4000\n }\n ];\n\n constructor(timeout: number = 150) {\n this.changeTimeout = timeout;\n this.changeStartSubscribers = new Set();\n this.changeEndSubscribers = new Set();\n this.isChanging = false;\n this.changeTimer = null;\n\n this.handleViewportChange = this.handleViewportChange.bind(this);\n this.handleResize = this.handleResize.bind(this);\n\n if (environment.isClient()) {\n window.addEventListener(\"resize\", this.handleResize, { passive: true });\n }\n }\n\n public setBreakpoints(breakpoints: Breakpoint[]) {\n this.breakpoints = breakpoints;\n }\n\n public onViewportChangeStart(callback: (info: ViewportInfo) => void): () => void {\n this.changeStartSubscribers.add(callback);\n return () => this.changeStartSubscribers.delete(callback);\n }\n\n public onViewportChangeEnd(callback: (info: ViewportInfo) => void): () => void {\n this.changeEndSubscribers.add(callback);\n return () => this.changeEndSubscribers.delete(callback);\n }\n\n /**\n * Get the current viewport information\n */\n public getViewport(): ViewportInfo {\n return this.getViewportInfo();\n }\n\n public destroy(): void {\n if (environment.isClient()) {\n window.removeEventListener(\"resize\", this.handleResize);\n if (this.changeTimer !== null) {\n clearTimeout(this.changeTimer);\n }\n this.changeStartSubscribers.clear();\n this.changeEndSubscribers.clear();\n }\n }\n\n private handleResize(): void {\n this.handleViewportChange();\n }\n\n private handleViewportChange(): void {\n const viewportInfo = this.getViewportInfo();\n\n if (!this.isChanging) {\n this.isChanging = true;\n this.notifySubscribers(this.changeStartSubscribers, viewportInfo);\n }\n\n if (this.changeTimer !== null) {\n clearTimeout(this.changeTimer);\n }\n\n this.changeTimer = window.setTimeout(() => {\n this.isChanging = false;\n this.notifySubscribers(this.changeEndSubscribers, viewportInfo);\n }, this.changeTimeout);\n }\n\n private getViewportInfo(): ViewportInfo {\n const modes = [...this.breakpoints].reverse();\n const viewport = environment.isClient()\n ? {\n width: window.innerWidth,\n height: window.innerHeight,\n scrollWidth: window.document.body.scrollWidth,\n scrollHeight: window.document.body.scrollHeight,\n scrollX: window.scrollX,\n scrollY: window.scrollY\n }\n : {\n // During SSR or Next.js build, viewport is not available.\n height: 0,\n width: 2000,\n scrollHeight: 0,\n scrollWidth: 2000,\n scrollX: 0,\n scrollY: 0\n };\n\n const [breakpoint] = modes.filter(mode => mode.maxWidth >= viewport.width);\n\n return { ...viewport, breakpoint: breakpoint.name, breakpoints: this.breakpoints };\n }\n\n private notifySubscribers(\n subscribers: Set<(info: ViewportInfo) => void>,\n viewportInfo: ViewportInfo\n ): void {\n subscribers.forEach(callback => {\n if (typeof callback === \"function\") {\n callback(viewportInfo);\n }\n });\n }\n}\n\nexport const viewportManager = new ViewportManager();\n"],"names":["ViewportManager","timeout","Set","environment","window","breakpoints","callback","clearTimeout","viewportInfo","modes","viewport","breakpoint","mode","subscribers","viewportManager"],"mappings":";;AAeO,MAAMA;IAqBT,YAAYC,UAAkB,GAAG,CAAE;QAZlC,KACO,WAAW,GAAiB;YAChC;gBACI,MAAM;gBACN,OAAO;gBACP,aAAa;gBACb,MAAM;gBACN,UAAU;gBACV,UAAU;YACd;SACH;QAGG,IAAI,CAAC,aAAa,GAAGA;QACrB,IAAI,CAAC,sBAAsB,GAAG,IAAIC;QAClC,IAAI,CAAC,oBAAoB,GAAG,IAAIA;QAChC,IAAI,CAAC,UAAU,GAAG;QAClB,IAAI,CAAC,WAAW,GAAG;QAEn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C,IAAI,CAAC,WAAW,GAAGH,OAAO,UAAU,CAAC;YACjC,IAAI,CAAC,UAAU,GAAG;YAClB,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,oBAAoB,EAAEI;QACtD,GAAG,IAAI,CAAC,aAAa;IACzB;IAEQ,kBAAgC;QACpC,MAAMC,QAAQ;eAAI,IAAI,CAAC,WAAW;SAAC,CAAC,OAAO;QAC3C,MAAMC,WAAWP,YAAY,QAAQ,KAC/B;YACI,OAAOC,OAAO,UAAU;YACxB,QAAQA,OAAO,WAAW;YAC1B,aAAaA,OAAO,QAAQ,CAAC,IAAI,CAAC,WAAW;YAC7C,cAAcA,OAAO,QAAQ,CAAC,IAAI,CAAC,YAAY;YAC/C,SAASA,OAAO,OAAO;YACvB,SAASA,OAAO,OAAO;QAC3B,IACA;YAEI,QAAQ;YACR,OAAO;YACP,cAAc;YACd,aAAa;YACb,SAAS;YACT,SAAS;QACb;QAEN,MAAM,CAACO,WAAW,GAAGF,MAAM,MAAM,CAACG,CAAAA,OAAQA,KAAK,QAAQ,IAAIF,SAAS,KAAK;QAEzE,OAAO;YAAE,GAAGA,QAAQ;YAAE,YAAYC,WAAW,IAAI;YAAE,aAAa,IAAI,CAAC,WAAW;QAAC;IACrF;IAEQ,kBACJE,WAA8C,EAC9CL,YAA0B,EACtB;QACJK,YAAY,OAAO,CAACP,CAAAA;YAChB,IAAI,AAAoB,cAApB,OAAOA,UACPA,SAASE;QAEjB;IACJ;AACJ;AAEO,MAAMM,kBAAkB,IAAId"}
|
package/constants.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
const StyleSettings = {
|
|
2
|
+
Layout: "layout",
|
|
3
|
+
Visibility: "visibility",
|
|
4
|
+
Background: "background",
|
|
5
|
+
MarginPadding: "marginPadding",
|
|
6
|
+
Border: "border"
|
|
7
7
|
};
|
|
8
|
+
export { StyleSettings };
|
|
8
9
|
|
|
9
10
|
//# sourceMappingURL=constants.js.map
|
package/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../src/constants.ts"],"sourcesContent":["export const StyleSettings = {\n Layout: \"layout\",\n Visibility: \"visibility\",\n Background: \"background\",\n MarginPadding: \"marginPadding\",\n Border: \"border\"\n};\n"],"names":["StyleSettings"],"mappings":"AAAO,MAAMA,gBAAgB;IACzB,QAAQ;IACR,YAAY;IACZ,YAAY;IACZ,eAAe;IACf,QAAQ;AACZ"}
|
package/createElement.js
CHANGED
package/createElement.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"createElement.js","sources":["../src/createElement.ts"],"sourcesContent":["import type { ResponsiveStyles } from \"~/types.js\";\n\nexport interface CreateElementParams {\n component: string;\n inputs?: Record<string, any>;\n styles?: ResponsiveStyles;\n}\n\nexport const createElement = (params: CreateElementParams) => {\n return {\n action: \"CreateElement\",\n params\n };\n};\n"],"names":["createElement","params"],"mappings":"AAQO,MAAMA,gBAAgB,CAACC,SACnB;QACH,QAAQ;QACRA;IACJ"}
|
package/createInput.js
CHANGED
|
@@ -1,160 +1,102 @@
|
|
|
1
1
|
import { functionConverter } from "./FunctionConverter.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* 2. The other overload omits the `name` property (used for object-based APIs, where the key provides the name).
|
|
9
|
-
*
|
|
10
|
-
* TypeScript resolves overloads by scanning from top to bottom and picking the first matching signature.
|
|
11
|
-
* The implementation signature uses `any` for the argument, and the return type is unified to match all overloads.
|
|
12
|
-
*
|
|
13
|
-
* In array mode, the `name` must be explicitly provided in the input object, so inference for `TName` works.
|
|
14
|
-
* In object mode, the input does not require a `name` property; instead, the key in the object (e.g., `{ foo: createTextInput({ ... }) }`)
|
|
15
|
-
* provides the name via contextual typing from the consuming function (such as `createComponent`). TypeScript uses this context
|
|
16
|
-
* to resolve the correct type for `TName` even when `name` is omitted from the input.
|
|
17
|
-
*
|
|
18
|
-
* This pattern ensures that all returned input objects are typed as `{ name: TName }`, whether `name` is provided explicitly or inferred,
|
|
19
|
-
* so consumers of these factories do not need to worry about the presence of the `name` property in the result.
|
|
20
|
-
*/
|
|
21
|
-
// Text
|
|
22
|
-
|
|
23
|
-
export function createTextInput(input) {
|
|
24
|
-
return createInput({
|
|
25
|
-
type: "text",
|
|
26
|
-
renderer: "Webiny/Input",
|
|
27
|
-
...input
|
|
28
|
-
});
|
|
2
|
+
function createTextInput(input) {
|
|
3
|
+
return createInput({
|
|
4
|
+
type: "text",
|
|
5
|
+
renderer: "Webiny/Input",
|
|
6
|
+
...input
|
|
7
|
+
});
|
|
29
8
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
renderer: "Webiny/Textarea",
|
|
37
|
-
...input
|
|
38
|
-
});
|
|
9
|
+
function createLongTextInput(input) {
|
|
10
|
+
return createInput({
|
|
11
|
+
type: "longText",
|
|
12
|
+
renderer: "Webiny/Textarea",
|
|
13
|
+
...input
|
|
14
|
+
});
|
|
39
15
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
renderer: "Webiny/Number",
|
|
47
|
-
...input
|
|
48
|
-
});
|
|
16
|
+
function createNumberInput(input) {
|
|
17
|
+
return createInput({
|
|
18
|
+
type: "number",
|
|
19
|
+
renderer: "Webiny/Number",
|
|
20
|
+
...input
|
|
21
|
+
});
|
|
49
22
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
renderer: "Webiny/Switch",
|
|
57
|
-
...input
|
|
58
|
-
});
|
|
23
|
+
function createBooleanInput(input) {
|
|
24
|
+
return createInput({
|
|
25
|
+
type: "boolean",
|
|
26
|
+
renderer: "Webiny/Switch",
|
|
27
|
+
...input
|
|
28
|
+
});
|
|
59
29
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
renderer: "Webiny/ColorPicker",
|
|
67
|
-
...input
|
|
68
|
-
});
|
|
30
|
+
function createColorInput(input) {
|
|
31
|
+
return createInput({
|
|
32
|
+
type: "color",
|
|
33
|
+
renderer: "Webiny/ColorPicker",
|
|
34
|
+
...input
|
|
35
|
+
});
|
|
69
36
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
renderer: "Webiny/FileManager",
|
|
77
|
-
...input
|
|
78
|
-
});
|
|
37
|
+
function createFileInput(input) {
|
|
38
|
+
return createInput({
|
|
39
|
+
type: "file",
|
|
40
|
+
renderer: "Webiny/FileManager",
|
|
41
|
+
...input
|
|
42
|
+
});
|
|
79
43
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
renderer: "Webiny/DateTime",
|
|
87
|
-
...input
|
|
88
|
-
});
|
|
44
|
+
function createDateInput(input) {
|
|
45
|
+
return createInput({
|
|
46
|
+
type: "datetime",
|
|
47
|
+
renderer: "Webiny/DateTime",
|
|
48
|
+
...input
|
|
49
|
+
});
|
|
89
50
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
renderer: "Webiny/Lexical",
|
|
97
|
-
...input
|
|
98
|
-
});
|
|
51
|
+
function createLexicalInput(input) {
|
|
52
|
+
return createInput({
|
|
53
|
+
type: "lexical",
|
|
54
|
+
renderer: "Webiny/Lexical",
|
|
55
|
+
...input
|
|
56
|
+
});
|
|
99
57
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
renderer: "Webiny/Select",
|
|
107
|
-
...input
|
|
108
|
-
});
|
|
58
|
+
function createSelectInput(input) {
|
|
59
|
+
return createInput({
|
|
60
|
+
type: "select",
|
|
61
|
+
renderer: "Webiny/Select",
|
|
62
|
+
...input
|
|
63
|
+
});
|
|
109
64
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
renderer: "Webiny/RadioGroup",
|
|
117
|
-
...input
|
|
118
|
-
});
|
|
65
|
+
function createRadioInput(input) {
|
|
66
|
+
return createInput({
|
|
67
|
+
type: "radio",
|
|
68
|
+
renderer: "Webiny/RadioGroup",
|
|
69
|
+
...input
|
|
70
|
+
});
|
|
119
71
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
renderer: "Webiny/Object",
|
|
127
|
-
...input
|
|
128
|
-
});
|
|
72
|
+
function createObjectInput(input) {
|
|
73
|
+
return createInput({
|
|
74
|
+
type: "object",
|
|
75
|
+
renderer: "Webiny/Object",
|
|
76
|
+
...input
|
|
77
|
+
});
|
|
129
78
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
renderer: "Webiny/Tags",
|
|
138
|
-
...input
|
|
139
|
-
});
|
|
79
|
+
function createTagsInput(input) {
|
|
80
|
+
return createInput({
|
|
81
|
+
type: "text",
|
|
82
|
+
list: true,
|
|
83
|
+
renderer: "Webiny/Tags",
|
|
84
|
+
...input
|
|
85
|
+
});
|
|
140
86
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
87
|
+
function createSlotInput(input) {
|
|
88
|
+
return createInput({
|
|
89
|
+
type: "slot",
|
|
90
|
+
list: true,
|
|
91
|
+
renderer: "Webiny/Slot",
|
|
92
|
+
defaultValue: [],
|
|
93
|
+
...input
|
|
94
|
+
});
|
|
149
95
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
if (input.onChange) {
|
|
154
|
-
// @ts-expect-error We don't use this function on the frontend, so this is ok.
|
|
155
|
-
input.onChange = functionConverter.serialize(input.onChange);
|
|
156
|
-
}
|
|
157
|
-
return input;
|
|
96
|
+
function createInput(input) {
|
|
97
|
+
if (input.onChange) input.onChange = functionConverter.serialize(input.onChange);
|
|
98
|
+
return input;
|
|
158
99
|
}
|
|
100
|
+
export { createBooleanInput, createColorInput, createDateInput, createFileInput, createInput, createLexicalInput, createLongTextInput, createNumberInput, createObjectInput, createRadioInput, createSelectInput, createSlotInput, createTagsInput, createTextInput };
|
|
159
101
|
|
|
160
102
|
//# sourceMappingURL=createInput.js.map
|
package/createInput.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["functionConverter","createTextInput","input","createInput","type","renderer","createLongTextInput","createNumberInput","createBooleanInput","createColorInput","createFileInput","createDateInput","createLexicalInput","createSelectInput","createRadioInput","createObjectInput","createTagsInput","list","createSlotInput","defaultValue","onChange","serialize"],"sources":["createInput.ts"],"sourcesContent":["import type {\n TextInput,\n LongTextInput,\n NumberInput,\n BooleanInput,\n ColorInput,\n FileInput,\n LexicalInput,\n SelectInput,\n RadioInput,\n ObjectInput,\n DateTimeInput,\n ComponentInput,\n TagsInput,\n SlotInput\n} from \"./types.js\";\nimport { functionConverter } from \"~/FunctionConverter.js\";\n\nexport type InputFactory<Name extends string> =\n | ReturnType<typeof createTextInput<Name>>\n | ReturnType<typeof createLongTextInput<Name>>\n | ReturnType<typeof createNumberInput<Name>>\n | ReturnType<typeof createBooleanInput<Name>>\n | ReturnType<typeof createColorInput<Name>>\n | ReturnType<typeof createFileInput<Name>>\n | ReturnType<typeof createDateInput<Name>>\n | ReturnType<typeof createLexicalInput<Name>>\n | ReturnType<typeof createSelectInput<Name>>\n | ReturnType<typeof createRadioInput<Name>>\n | ReturnType<typeof createObjectInput<Name>>\n | ReturnType<typeof createTagsInput<Name>>\n | ReturnType<typeof createSlotInput<Name>>;\n\n/**\n * TypeScript Overload Resolution and Input Factory Design\n *\n * Each input factory (e.g., createTextInput) is defined with two TypeScript overload signatures:\n * 1. One overload requires a `name` property in the input (used for array-based APIs, where inference is needed).\n * 2. The other overload omits the `name` property (used for object-based APIs, where the key provides the name).\n *\n * TypeScript resolves overloads by scanning from top to bottom and picking the first matching signature.\n * The implementation signature uses `any` for the argument, and the return type is unified to match all overloads.\n *\n * In array mode, the `name` must be explicitly provided in the input object, so inference for `TName` works.\n * In object mode, the input does not require a `name` property; instead, the key in the object (e.g., `{ foo: createTextInput({ ... }) }`)\n * provides the name via contextual typing from the consuming function (such as `createComponent`). TypeScript uses this context\n * to resolve the correct type for `TName` even when `name` is omitted from the input.\n *\n * This pattern ensures that all returned input objects are typed as `{ name: TName }`, whether `name` is provided explicitly or inferred,\n * so consumers of these factories do not need to worry about the presence of the `name` property in the result.\n */\n// Text\nexport function createTextInput<TName extends string>(\n input: { name: TName } & Omit<TextInput, \"type\" | \"name\">\n): TextInput & { name: TName };\nexport function createTextInput<TName extends string>(\n input: Omit<TextInput, \"type\" | \"name\">\n): TextInput & { name: TName };\nexport function createTextInput<TName extends string>(input: any): TextInput & { name: TName } {\n return createInput({\n type: \"text\",\n renderer: \"Webiny/Input\",\n ...input\n }) as TextInput & { name: TName };\n}\n\n// Long Text\nexport function createLongTextInput<TName extends string>(\n input: { name: TName } & Omit<LongTextInput, \"type\" | \"name\">\n): LongTextInput & { name: TName };\nexport function createLongTextInput<TName extends string>(\n input: Omit<LongTextInput, \"type\" | \"name\">\n): LongTextInput & { name: TName };\nexport function createLongTextInput<TName extends string>(\n input: any\n): LongTextInput & { name: TName } {\n return createInput({\n type: \"longText\",\n renderer: \"Webiny/Textarea\",\n ...input\n }) as LongTextInput & { name: TName };\n}\n\n// Number\nexport function createNumberInput<TName extends string>(\n input: { name: TName } & Omit<NumberInput, \"type\" | \"name\">\n): NumberInput & { name: TName };\nexport function createNumberInput<TName extends string>(\n input: Omit<NumberInput, \"type\" | \"name\">\n): NumberInput & { name: TName };\nexport function createNumberInput<TName extends string>(input: any): NumberInput & { name: TName } {\n return createInput({\n type: \"number\",\n renderer: \"Webiny/Number\",\n ...input\n }) as NumberInput & { name: TName };\n}\n\n// Boolean\nexport function createBooleanInput<TName extends string>(\n input: { name: TName } & Omit<BooleanInput, \"type\" | \"name\">\n): BooleanInput & { name: TName };\nexport function createBooleanInput<TName extends string>(\n input: Omit<BooleanInput, \"type\" | \"name\">\n): BooleanInput & { name: TName };\nexport function createBooleanInput<TName extends string>(\n input: any\n): BooleanInput & { name: TName } {\n return createInput({\n type: \"boolean\",\n renderer: \"Webiny/Switch\",\n ...input\n }) as BooleanInput & { name: TName };\n}\n\n// Color\nexport function createColorInput<TName extends string>(\n input: { name: TName } & Omit<ColorInput, \"type\" | \"name\">\n): ColorInput & { name: TName };\nexport function createColorInput<TName extends string>(\n input: Omit<ColorInput, \"type\" | \"name\">\n): ColorInput & { name: TName };\nexport function createColorInput<TName extends string>(input: any): ColorInput & { name: TName } {\n return createInput({\n type: \"color\",\n renderer: \"Webiny/ColorPicker\",\n ...input\n }) as ColorInput & { name: TName };\n}\n\n// File\nexport function createFileInput<TName extends string>(\n input: { name: TName } & Omit<FileInput, \"type\" | \"name\">\n): FileInput & { name: TName };\nexport function createFileInput<TName extends string>(\n input: Omit<FileInput, \"type\" | \"name\">\n): FileInput & { name: TName };\nexport function createFileInput<TName extends string>(input: any): FileInput & { name: TName } {\n return createInput({\n type: \"file\",\n renderer: \"Webiny/FileManager\",\n ...input\n }) as FileInput & { name: TName };\n}\n\n// Date\nexport function createDateInput<TName extends string>(\n input: { name: TName } & Omit<DateTimeInput, \"type\" | \"name\">\n): DateTimeInput & { name: TName };\nexport function createDateInput<TName extends string>(\n input: Omit<DateTimeInput, \"type\" | \"name\">\n): DateTimeInput & { name: TName };\nexport function createDateInput<TName extends string>(input: any): DateTimeInput & { name: TName } {\n return createInput({\n type: \"datetime\",\n renderer: \"Webiny/DateTime\",\n ...input\n }) as DateTimeInput & { name: TName };\n}\n\n// Rich Text\nexport function createLexicalInput<TName extends string>(\n input: { name: TName } & Omit<LexicalInput, \"type\" | \"name\">\n): LexicalInput & { name: TName };\nexport function createLexicalInput<TName extends string>(\n input: Omit<LexicalInput, \"type\" | \"name\">\n): LexicalInput & { name: TName };\nexport function createLexicalInput<TName extends string>(\n input: any\n): LexicalInput & { name: TName } {\n return createInput({\n type: \"lexical\",\n renderer: \"Webiny/Lexical\",\n ...input\n }) as LexicalInput & { name: TName };\n}\n\n// Select\nexport function createSelectInput<TName extends string>(\n input: { name: TName } & Omit<SelectInput, \"type\" | \"name\">\n): SelectInput & { name: TName };\nexport function createSelectInput<TName extends string>(\n input: Omit<SelectInput, \"type\" | \"name\">\n): SelectInput & { name: TName };\nexport function createSelectInput<TName extends string>(input: any): SelectInput & { name: TName } {\n return createInput({\n type: \"select\",\n renderer: \"Webiny/Select\",\n ...input\n }) as SelectInput & { name: TName };\n}\n\n// Radio\nexport function createRadioInput<TName extends string>(\n input: { name: TName } & Omit<RadioInput, \"type\" | \"name\">\n): RadioInput & { name: TName };\nexport function createRadioInput<TName extends string>(\n input: Omit<RadioInput, \"type\" | \"name\">\n): RadioInput & { name: TName };\nexport function createRadioInput<TName extends string>(input: any): RadioInput & { name: TName } {\n return createInput({\n type: \"radio\",\n renderer: \"Webiny/RadioGroup\",\n ...input\n }) as RadioInput & { name: TName };\n}\n\n// Object\nexport function createObjectInput<TName extends string>(\n input: { name: TName } & Omit<ObjectInput, \"type\" | \"name\">\n): ObjectInput & { name: TName };\nexport function createObjectInput<TName extends string>(\n input: Omit<ObjectInput, \"type\" | \"name\">\n): ObjectInput & { name: TName };\nexport function createObjectInput<TName extends string>(input: any): ObjectInput & { name: TName } {\n return createInput({\n type: \"object\",\n renderer: \"Webiny/Object\",\n ...input\n }) as ObjectInput & { name: TName };\n}\n\n// Tags\nexport function createTagsInput<TName extends string>(\n input: { name: TName } & Omit<TagsInput, \"type\" | \"name\">\n): TagsInput & { name: TName };\nexport function createTagsInput<TName extends string>(\n input: Omit<TagsInput, \"type\" | \"name\">\n): TagsInput & { name: TName };\nexport function createTagsInput<TName extends string>(input: any): TagsInput & { name: TName } {\n return createInput({\n type: \"text\",\n list: true,\n renderer: \"Webiny/Tags\",\n ...input\n }) as TagsInput & { name: TName };\n}\n\nexport function createSlotInput<TName extends string>(\n input: { name: TName } & Omit<SlotInput, \"type\" | \"name\">\n): SlotInput & { name: TName };\nexport function createSlotInput<TName extends string>(\n input: Omit<SlotInput, \"type\" | \"name\">\n): SlotInput & { name: TName };\nexport function createSlotInput<TName extends string>(input: any): SlotInput & { name: TName } {\n return createInput({\n type: \"slot\",\n list: true,\n renderer: \"Webiny/Slot\",\n defaultValue: [],\n ...input\n }) as SlotInput & { name: TName };\n}\n\n// Implementation\nexport function createInput(input: ComponentInput): ComponentInput {\n if (input.onChange) {\n // @ts-expect-error We don't use this function on the frontend, so this is ok.\n input.onChange = functionConverter.serialize(input.onChange!);\n }\n return input;\n}\n"],"mappings":"AAgBA,SAASA,iBAAiB;;AAiB1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA,OAAO,SAASC,eAAeA,CAAuBC,KAAU,EAA+B;EAC3F,OAAOC,WAAW,CAAC;IACfC,IAAI,EAAE,MAAM;IACZC,QAAQ,EAAE,cAAc;IACxB,GAAGH;EACP,CAAC,CAAC;AACN;;AAEA;;AAOA,OAAO,SAASI,mBAAmBA,CAC/BJ,KAAU,EACqB;EAC/B,OAAOC,WAAW,CAAC;IACfC,IAAI,EAAE,UAAU;IAChBC,QAAQ,EAA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;AACN;;AAEA;;AAOA,OAAO,SAASY,gBAAgBA,CAAuBZ,KAAU,EAAgC;EAC7F,OAAOC,WAAW,CAAC;IACfC,IAAI,EAAE,OAAO;IACbC,QAAQ,EAAE,mBAAmB;IAC7B,GAAGH;EACP,CAAC,CAAC;AACN;;AAEA;;AAOA,OAAO,SAASa,iBAAiBA,CAAuBb,KAAU,EAAiC;EAC/F,OAAOC,WAAW,CAAC;IACfC,IAAI,EAAE,QAAQ;IACdC,QAAQ,EAAE,eAAe;IACzB,GAAGH;EACP,CAAC,CAAC;AACN;;AAEA;;AAOA,OAAO,SAASc,eAAeA,CAAuBd,KAAU,EAA+B;EAC3F,OAAOC,WAAW,CAAC;IACfC,IAAI,EAAE,MAAM;IACZa,IAAI,EAAE,IAAI;IACVZ,QAAQ,EAAE,aAAa;IACvB,GAAGH;EACP,CAAC,CAAC;AACN;AAQA,OAAO,SAASgB,eAAeA,CAAuBhB,KAAU,EAA+B;EAC3F,OAAOC,WAAW,CAAC;IACfC,IAAI,EAAE,MAAM;IACZa,IAAI,EAAE,IAAI;IACVZ,QAAQ,EAAE,aAAa;IACvBc,YAAY,EAAE,EAAE;IAChB,GAAGjB;EACP,CAAC,CAAC;AACN;;AAEA;AACA,OAAO,SAASC,WAAWA,CAACD,KAAqB,EAAkB;EAC/D,IAAIA,KAAK,CAACkB,QAAQ,EAAE;IAChB;IACAlB,KAAK,CAACkB,QAAQ,GAAGpB,iBAAiB,CAACqB,SAAS,CAACnB,KAAK,CAACkB,QAAS,CAAC;EACjE;EACA,OAAOlB,KAAK;AAChB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"createInput.js","sources":["../src/createInput.ts"],"sourcesContent":["import type {\n TextInput,\n LongTextInput,\n NumberInput,\n BooleanInput,\n ColorInput,\n FileInput,\n LexicalInput,\n SelectInput,\n RadioInput,\n ObjectInput,\n DateTimeInput,\n ComponentInput,\n TagsInput,\n SlotInput\n} from \"./types.js\";\nimport { functionConverter } from \"~/FunctionConverter.js\";\n\nexport type InputFactory<Name extends string> =\n | ReturnType<typeof createTextInput<Name>>\n | ReturnType<typeof createLongTextInput<Name>>\n | ReturnType<typeof createNumberInput<Name>>\n | ReturnType<typeof createBooleanInput<Name>>\n | ReturnType<typeof createColorInput<Name>>\n | ReturnType<typeof createFileInput<Name>>\n | ReturnType<typeof createDateInput<Name>>\n | ReturnType<typeof createLexicalInput<Name>>\n | ReturnType<typeof createSelectInput<Name>>\n | ReturnType<typeof createRadioInput<Name>>\n | ReturnType<typeof createObjectInput<Name>>\n | ReturnType<typeof createTagsInput<Name>>\n | ReturnType<typeof createSlotInput<Name>>;\n\n/**\n * TypeScript Overload Resolution and Input Factory Design\n *\n * Each input factory (e.g., createTextInput) is defined with two TypeScript overload signatures:\n * 1. One overload requires a `name` property in the input (used for array-based APIs, where inference is needed).\n * 2. The other overload omits the `name` property (used for object-based APIs, where the key provides the name).\n *\n * TypeScript resolves overloads by scanning from top to bottom and picking the first matching signature.\n * The implementation signature uses `any` for the argument, and the return type is unified to match all overloads.\n *\n * In array mode, the `name` must be explicitly provided in the input object, so inference for `TName` works.\n * In object mode, the input does not require a `name` property; instead, the key in the object (e.g., `{ foo: createTextInput({ ... }) }`)\n * provides the name via contextual typing from the consuming function (such as `createComponent`). TypeScript uses this context\n * to resolve the correct type for `TName` even when `name` is omitted from the input.\n *\n * This pattern ensures that all returned input objects are typed as `{ name: TName }`, whether `name` is provided explicitly or inferred,\n * so consumers of these factories do not need to worry about the presence of the `name` property in the result.\n */\n// Text\nexport function createTextInput<TName extends string>(\n input: { name: TName } & Omit<TextInput, \"type\" | \"name\">\n): TextInput & { name: TName };\nexport function createTextInput<TName extends string>(\n input: Omit<TextInput, \"type\" | \"name\">\n): TextInput & { name: TName };\nexport function createTextInput<TName extends string>(input: any): TextInput & { name: TName } {\n return createInput({\n type: \"text\",\n renderer: \"Webiny/Input\",\n ...input\n }) as TextInput & { name: TName };\n}\n\n// Long Text\nexport function createLongTextInput<TName extends string>(\n input: { name: TName } & Omit<LongTextInput, \"type\" | \"name\">\n): LongTextInput & { name: TName };\nexport function createLongTextInput<TName extends string>(\n input: Omit<LongTextInput, \"type\" | \"name\">\n): LongTextInput & { name: TName };\nexport function createLongTextInput<TName extends string>(\n input: any\n): LongTextInput & { name: TName } {\n return createInput({\n type: \"longText\",\n renderer: \"Webiny/Textarea\",\n ...input\n }) as LongTextInput & { name: TName };\n}\n\n// Number\nexport function createNumberInput<TName extends string>(\n input: { name: TName } & Omit<NumberInput, \"type\" | \"name\">\n): NumberInput & { name: TName };\nexport function createNumberInput<TName extends string>(\n input: Omit<NumberInput, \"type\" | \"name\">\n): NumberInput & { name: TName };\nexport function createNumberInput<TName extends string>(input: any): NumberInput & { name: TName } {\n return createInput({\n type: \"number\",\n renderer: \"Webiny/Number\",\n ...input\n }) as NumberInput & { name: TName };\n}\n\n// Boolean\nexport function createBooleanInput<TName extends string>(\n input: { name: TName } & Omit<BooleanInput, \"type\" | \"name\">\n): BooleanInput & { name: TName };\nexport function createBooleanInput<TName extends string>(\n input: Omit<BooleanInput, \"type\" | \"name\">\n): BooleanInput & { name: TName };\nexport function createBooleanInput<TName extends string>(\n input: any\n): BooleanInput & { name: TName } {\n return createInput({\n type: \"boolean\",\n renderer: \"Webiny/Switch\",\n ...input\n }) as BooleanInput & { name: TName };\n}\n\n// Color\nexport function createColorInput<TName extends string>(\n input: { name: TName } & Omit<ColorInput, \"type\" | \"name\">\n): ColorInput & { name: TName };\nexport function createColorInput<TName extends string>(\n input: Omit<ColorInput, \"type\" | \"name\">\n): ColorInput & { name: TName };\nexport function createColorInput<TName extends string>(input: any): ColorInput & { name: TName } {\n return createInput({\n type: \"color\",\n renderer: \"Webiny/ColorPicker\",\n ...input\n }) as ColorInput & { name: TName };\n}\n\n// File\nexport function createFileInput<TName extends string>(\n input: { name: TName } & Omit<FileInput, \"type\" | \"name\">\n): FileInput & { name: TName };\nexport function createFileInput<TName extends string>(\n input: Omit<FileInput, \"type\" | \"name\">\n): FileInput & { name: TName };\nexport function createFileInput<TName extends string>(input: any): FileInput & { name: TName } {\n return createInput({\n type: \"file\",\n renderer: \"Webiny/FileManager\",\n ...input\n }) as FileInput & { name: TName };\n}\n\n// Date\nexport function createDateInput<TName extends string>(\n input: { name: TName } & Omit<DateTimeInput, \"type\" | \"name\">\n): DateTimeInput & { name: TName };\nexport function createDateInput<TName extends string>(\n input: Omit<DateTimeInput, \"type\" | \"name\">\n): DateTimeInput & { name: TName };\nexport function createDateInput<TName extends string>(input: any): DateTimeInput & { name: TName } {\n return createInput({\n type: \"datetime\",\n renderer: \"Webiny/DateTime\",\n ...input\n }) as DateTimeInput & { name: TName };\n}\n\n// Rich Text\nexport function createLexicalInput<TName extends string>(\n input: { name: TName } & Omit<LexicalInput, \"type\" | \"name\">\n): LexicalInput & { name: TName };\nexport function createLexicalInput<TName extends string>(\n input: Omit<LexicalInput, \"type\" | \"name\">\n): LexicalInput & { name: TName };\nexport function createLexicalInput<TName extends string>(\n input: any\n): LexicalInput & { name: TName } {\n return createInput({\n type: \"lexical\",\n renderer: \"Webiny/Lexical\",\n ...input\n }) as LexicalInput & { name: TName };\n}\n\n// Select\nexport function createSelectInput<TName extends string>(\n input: { name: TName } & Omit<SelectInput, \"type\" | \"name\">\n): SelectInput & { name: TName };\nexport function createSelectInput<TName extends string>(\n input: Omit<SelectInput, \"type\" | \"name\">\n): SelectInput & { name: TName };\nexport function createSelectInput<TName extends string>(input: any): SelectInput & { name: TName } {\n return createInput({\n type: \"select\",\n renderer: \"Webiny/Select\",\n ...input\n }) as SelectInput & { name: TName };\n}\n\n// Radio\nexport function createRadioInput<TName extends string>(\n input: { name: TName } & Omit<RadioInput, \"type\" | \"name\">\n): RadioInput & { name: TName };\nexport function createRadioInput<TName extends string>(\n input: Omit<RadioInput, \"type\" | \"name\">\n): RadioInput & { name: TName };\nexport function createRadioInput<TName extends string>(input: any): RadioInput & { name: TName } {\n return createInput({\n type: \"radio\",\n renderer: \"Webiny/RadioGroup\",\n ...input\n }) as RadioInput & { name: TName };\n}\n\n// Object\nexport function createObjectInput<TName extends string>(\n input: { name: TName } & Omit<ObjectInput, \"type\" | \"name\">\n): ObjectInput & { name: TName };\nexport function createObjectInput<TName extends string>(\n input: Omit<ObjectInput, \"type\" | \"name\">\n): ObjectInput & { name: TName };\nexport function createObjectInput<TName extends string>(input: any): ObjectInput & { name: TName } {\n return createInput({\n type: \"object\",\n renderer: \"Webiny/Object\",\n ...input\n }) as ObjectInput & { name: TName };\n}\n\n// Tags\nexport function createTagsInput<TName extends string>(\n input: { name: TName } & Omit<TagsInput, \"type\" | \"name\">\n): TagsInput & { name: TName };\nexport function createTagsInput<TName extends string>(\n input: Omit<TagsInput, \"type\" | \"name\">\n): TagsInput & { name: TName };\nexport function createTagsInput<TName extends string>(input: any): TagsInput & { name: TName } {\n return createInput({\n type: \"text\",\n list: true,\n renderer: \"Webiny/Tags\",\n ...input\n }) as TagsInput & { name: TName };\n}\n\nexport function createSlotInput<TName extends string>(\n input: { name: TName } & Omit<SlotInput, \"type\" | \"name\">\n): SlotInput & { name: TName };\nexport function createSlotInput<TName extends string>(\n input: Omit<SlotInput, \"type\" | \"name\">\n): SlotInput & { name: TName };\nexport function createSlotInput<TName extends string>(input: any): SlotInput & { name: TName } {\n return createInput({\n type: \"slot\",\n list: true,\n renderer: \"Webiny/Slot\",\n defaultValue: [],\n ...input\n }) as SlotInput & { name: TName };\n}\n\n// Implementation\nexport function createInput(input: ComponentInput): ComponentInput {\n if (input.onChange) {\n // @ts-expect-error We don't use this function on the frontend, so this is ok.\n input.onChange = functionConverter.serialize(input.onChange!);\n }\n return input;\n}\n"],"names":["createTextInput","input","createInput","createLongTextInput","createNumberInput","createBooleanInput","createColorInput","createFileInput","createDateInput","createLexicalInput","createSelectInput","createRadioInput","createObjectInput","createTagsInput","createSlotInput","functionConverter"],"mappings":";AA0DO,SAASA,gBAAsCC,KAAU;IAC5D,OAAOC,YAAY;QACf,MAAM;QACN,UAAU;QACV,GAAGD,KAAK;IAC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