@webiny/website-builder-sdk 0.0.0-unstable.e0bfc55d5a → 0.0.0-unstable.e2758ee1cf

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.
Files changed (164) hide show
  1. package/BindingsApi.d.ts +4 -4
  2. package/BindingsApi.js +3 -3
  3. package/BindingsApi.js.map +1 -1
  4. package/BindingsProcessor.d.ts +1 -1
  5. package/BindingsProcessor.js.map +1 -1
  6. package/BindingsProcessor.test.js +2 -1
  7. package/BindingsProcessor.test.js.map +1 -1
  8. package/BindingsResolver.d.ts +2 -2
  9. package/BindingsResolver.js +2 -2
  10. package/BindingsResolver.js.map +1 -1
  11. package/BindingsResolver.test.js +4 -3
  12. package/BindingsResolver.test.js.map +1 -1
  13. package/ComponentInputTraverser.d.ts +1 -1
  14. package/ComponentInputTraverser.js.map +1 -1
  15. package/ComponentManifestToAstConverter.d.ts +1 -1
  16. package/ComponentManifestToAstConverter.js.map +1 -1
  17. package/ComponentResolver.d.ts +2 -2
  18. package/ComponentResolver.js +3 -3
  19. package/ComponentResolver.js.map +1 -1
  20. package/ContentSdk.d.ts +5 -5
  21. package/ContentSdk.js +9 -9
  22. package/ContentSdk.js.map +1 -1
  23. package/DocumentStore.d.ts +3 -3
  24. package/DocumentStore.js +1 -1
  25. package/DocumentStore.js.map +1 -1
  26. package/DocumentStoreManager.d.ts +2 -2
  27. package/DocumentStoreManager.js +1 -1
  28. package/DocumentStoreManager.js.map +1 -1
  29. package/EditingSdk.d.ts +4 -4
  30. package/EditingSdk.js +12 -15
  31. package/EditingSdk.js.map +1 -1
  32. package/ElementFactory.d.ts +3 -3
  33. package/ElementFactory.js +4 -4
  34. package/ElementFactory.js.map +1 -1
  35. package/HotkeyManager.js +1 -1
  36. package/HotkeyManager.js.map +1 -1
  37. package/IBindingsUpdater.d.ts +2 -2
  38. package/IBindingsUpdater.js.map +1 -1
  39. package/IRedirects.d.ts +1 -1
  40. package/IRedirects.js.map +1 -1
  41. package/InheritanceProcessor.d.ts +4 -4
  42. package/InheritanceProcessor.js.map +1 -1
  43. package/InheritanceProcessor.test.js +2 -1
  44. package/InheritanceProcessor.test.js.map +1 -1
  45. package/InheritedValueResolver.d.ts +1 -1
  46. package/InheritedValueResolver.js.map +1 -1
  47. package/InputBindingsProcessor.d.ts +4 -4
  48. package/InputBindingsProcessor.js +5 -5
  49. package/InputBindingsProcessor.js.map +1 -1
  50. package/InputsBindingsProcessor.test.js +3 -2
  51. package/InputsBindingsProcessor.test.js.map +1 -1
  52. package/InputsUpdater.d.ts +5 -5
  53. package/InputsUpdater.js +2 -2
  54. package/InputsUpdater.js.map +1 -1
  55. package/LiveSdk.d.ts +2 -2
  56. package/LiveSdk.js +1 -1
  57. package/LiveSdk.js.map +1 -1
  58. package/Logger.d.ts +2 -1
  59. package/NullSdk.d.ts +2 -2
  60. package/NullSdk.js +8 -1
  61. package/NullSdk.js.map +1 -1
  62. package/PreviewDocument.js +1 -1
  63. package/PreviewDocument.js.map +1 -1
  64. package/PreviewSdk.d.ts +2 -2
  65. package/PreviewSdk.js +3 -3
  66. package/PreviewSdk.js.map +1 -1
  67. package/PreviewViewport.d.ts +1 -2
  68. package/PreviewViewport.js +1 -21
  69. package/PreviewViewport.js.map +1 -1
  70. package/README.md +10 -2
  71. package/StylesBindingsProcessor.d.ts +2 -2
  72. package/StylesBindingsProcessor.js +4 -4
  73. package/StylesBindingsProcessor.js.map +1 -1
  74. package/StylesUpdater.d.ts +4 -4
  75. package/StylesUpdater.js +2 -2
  76. package/StylesUpdater.js.map +1 -1
  77. package/Theme.d.ts +1 -1
  78. package/Theme.js +4 -11
  79. package/Theme.js.map +1 -1
  80. package/ViewportManager.d.ts +3 -1
  81. package/ViewportManager.js +5 -1
  82. package/ViewportManager.js.map +1 -1
  83. package/createElement.d.ts +1 -1
  84. package/createElement.js.map +1 -1
  85. package/createInput.d.ts +124 -16
  86. package/createInput.js +33 -1
  87. package/createInput.js.map +1 -1
  88. package/createTheme.d.ts +1 -1
  89. package/createTheme.js.map +1 -1
  90. package/dataProviders/ApiClient.d.ts +6 -1
  91. package/dataProviders/ApiClient.js +19 -8
  92. package/dataProviders/ApiClient.js.map +1 -1
  93. package/dataProviders/DefaultDataProvider.d.ts +3 -3
  94. package/dataProviders/DefaultDataProvider.js +24 -6
  95. package/dataProviders/DefaultDataProvider.js.map +1 -1
  96. package/dataProviders/GET_PAGE_BY_ID.d.ts +1 -1
  97. package/dataProviders/GET_PAGE_BY_ID.js +1 -0
  98. package/dataProviders/GET_PAGE_BY_ID.js.map +1 -1
  99. package/dataProviders/GET_PAGE_BY_PATH.d.ts +1 -1
  100. package/dataProviders/GET_PAGE_BY_PATH.js +1 -0
  101. package/dataProviders/GET_PAGE_BY_PATH.js.map +1 -1
  102. package/dataProviders/LIST_PUBLISHED_PAGES.d.ts +1 -1
  103. package/dataProviders/LIST_PUBLISHED_PAGES.js +14 -2
  104. package/dataProviders/LIST_PUBLISHED_PAGES.js.map +1 -1
  105. package/dataProviders/NullDataProvider.d.ts +8 -1
  106. package/dataProviders/NullDataProvider.js +8 -1
  107. package/dataProviders/NullDataProvider.js.map +1 -1
  108. package/dataProviders/RedirectsProvider.d.ts +3 -3
  109. package/dataProviders/RedirectsProvider.js +6 -7
  110. package/dataProviders/RedirectsProvider.js.map +1 -1
  111. package/defaultBreakpoints.d.ts +1 -1
  112. package/defaultBreakpoints.js.map +1 -1
  113. package/documentOperations/$addElementReferenceToParent.js.map +1 -1
  114. package/documentOperations/AddElement.d.ts +1 -1
  115. package/documentOperations/AddElement.js.map +1 -1
  116. package/documentOperations/AddToParent.d.ts +1 -1
  117. package/documentOperations/AddToParent.js.map +1 -1
  118. package/documentOperations/RemoveElement.d.ts +1 -1
  119. package/documentOperations/RemoveElement.js.map +1 -1
  120. package/documentOperations/SetGlobalInputBinding.d.ts +1 -1
  121. package/documentOperations/SetGlobalInputBinding.js.map +1 -1
  122. package/documentOperations/SetGlobalStyleBinding.d.ts +1 -1
  123. package/documentOperations/SetGlobalStyleBinding.js.map +1 -1
  124. package/documentOperations/SetInputBindingOverride.d.ts +1 -1
  125. package/documentOperations/SetInputBindingOverride.js.map +1 -1
  126. package/documentOperations/SetStyleBindingOverride.d.ts +1 -1
  127. package/documentOperations/SetStyleBindingOverride.js.map +1 -1
  128. package/documentOperations/index.d.ts +8 -8
  129. package/documentOperations/index.js +7 -7
  130. package/documentOperations/index.js.map +1 -1
  131. package/findMatchingAstNode.d.ts +1 -1
  132. package/findMatchingAstNode.js.map +1 -1
  133. package/generateElementId.d.ts +1 -1
  134. package/generateElementId.js +0 -1
  135. package/generateElementId.js.map +1 -1
  136. package/index.d.ts +2 -3
  137. package/index.js +1 -3
  138. package/index.js.map +1 -1
  139. package/jsonPatch.d.ts +1 -1
  140. package/messenger/Messenger.js +9 -7
  141. package/messenger/Messenger.js.map +1 -1
  142. package/package.json +14 -19
  143. package/registerComponentGroup.d.ts +1 -1
  144. package/registerComponentGroup.js +1 -1
  145. package/registerComponentGroup.js.map +1 -1
  146. package/types/WebsiteBuilderTheme.d.ts +42 -45
  147. package/types/WebsiteBuilderTheme.js.map +1 -1
  148. package/types.d.ts +49 -10
  149. package/types.js.map +1 -1
  150. package/dataProviders/GET_ACTIVE_REDIRECTS.d.ts +0 -1
  151. package/dataProviders/GET_ACTIVE_REDIRECTS.js +0 -21
  152. package/dataProviders/GET_ACTIVE_REDIRECTS.js.map +0 -1
  153. package/lexical/createDefaultLexicalTheme.d.ts +0 -2
  154. package/lexical/createDefaultLexicalTheme.js +0 -84
  155. package/lexical/createDefaultLexicalTheme.js.map +0 -1
  156. package/lexical/createLexicalTheme.d.ts +0 -2
  157. package/lexical/createLexicalTheme.js +0 -7
  158. package/lexical/createLexicalTheme.js.map +0 -1
  159. package/lexical/deepMerge.d.ts +0 -1
  160. package/lexical/deepMerge.js +0 -23
  161. package/lexical/deepMerge.js.map +0 -1
  162. package/types/LexicalEditorTheme.d.ts +0 -2
  163. package/types/LexicalEditorTheme.js +0 -3
  164. package/types/LexicalEditorTheme.js.map +0 -1
@@ -1,10 +1,10 @@
1
- import type { Document, DocumentElementBindings } from "./types";
2
- import type { IBindingsUpdater } from "./IBindingsUpdater";
3
- import type { ElementStylesBindings } from "./StylesBindingsProcessor";
1
+ import type { Document, DocumentElementBindings } from "./types.js";
2
+ import type { IBindingsUpdater } from "./IBindingsUpdater.js";
3
+ import type { ElementStylesBindings } from "./StylesBindingsProcessor.js";
4
4
  export declare class StylesUpdater implements IBindingsUpdater {
5
5
  private readonly bindings;
6
6
  private elementId;
7
7
  constructor(elementId: string, bindings: ElementStylesBindings);
8
8
  applyToDocument(document: Document): void;
9
- createJsonPatch(bindings: DocumentElementBindings): import("./jsonPatch").JsonPatchOperation[];
9
+ createJsonPatch(bindings: DocumentElementBindings): import("~/jsonPatch.js").JsonPatchOperation[];
10
10
  }
package/StylesUpdater.js CHANGED
@@ -1,5 +1,5 @@
1
- import { jsonPatch } from "./jsonPatch";
2
- import set from "lodash/set";
1
+ import { jsonPatch } from "./jsonPatch.js";
2
+ import set from "lodash/set.js";
3
3
  export class StylesUpdater {
4
4
  constructor(elementId, bindings) {
5
5
  this.elementId = elementId;
@@ -1 +1 @@
1
- {"version":3,"names":["jsonPatch","set","StylesUpdater","constructor","elementId","bindings","applyToDocument","document","styles","overrides","bp","Object","entries","structuredClone","createJsonPatch","toCompare","keys","length","ignore","compare","filter","op","some","prefix","path","startsWith"],"sources":["StylesUpdater.ts"],"sourcesContent":["import { jsonPatch } from \"~/jsonPatch\";\nimport set from \"lodash/set\";\nimport type { Document, DocumentElementBindings } from \"./types\";\nimport type { IBindingsUpdater } from \"./IBindingsUpdater\";\nimport type { ElementStylesBindings } from \"./StylesBindingsProcessor\";\n\nexport class StylesUpdater implements IBindingsUpdater {\n private readonly bindings: ElementStylesBindings;\n private elementId: string;\n\n constructor(elementId: string, bindings: ElementStylesBindings) {\n this.elementId = elementId;\n this.bindings = bindings;\n }\n\n applyToDocument(document: Document) {\n if (this.bindings.styles) {\n document.bindings[this.elementId].styles = this.bindings.styles;\n }\n\n if (this.bindings.overrides) {\n for (const [bp, overrides] of Object.entries(this.bindings.overrides)) {\n if (overrides.styles) {\n set(\n document.bindings,\n `${this.elementId}.overrides.${bp}.styles`,\n structuredClone(this.bindings.overrides[bp].styles)\n );\n }\n }\n }\n }\n\n createJsonPatch(bindings: DocumentElementBindings) {\n const toCompare: Partial<DocumentElementBindings> = { ...this.bindings };\n if (Object.keys(toCompare.overrides ?? {}).length === 0) {\n delete toCompare.overrides;\n }\n\n const ignore = [\"/inputs\", \"/overrides/inputs\", \"/metadata\"];\n\n return jsonPatch.compare(bindings, toCompare).filter(op => {\n return !ignore.some(prefix => op.path.startsWith(prefix));\n });\n }\n}\n"],"mappings":"AAAA,SAASA,SAAS;AAClB,OAAOC,GAAG,MAAM,YAAY;AAK5B,OAAO,MAAMC,aAAa,CAA6B;EAInDC,WAAWA,CAACC,SAAiB,EAAEC,QAA+B,EAAE;IAC5D,IAAI,CAACD,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAACC,QAAQ,GAAGA,QAAQ;EAC5B;EAEAC,eAAeA,CAACC,QAAkB,EAAE;IAChC,IAAI,IAAI,CAACF,QAAQ,CAACG,MAAM,EAAE;MACtBD,QAAQ,CAACF,QAAQ,CAAC,IAAI,CAACD,SAAS,CAAC,CAACI,MAAM,GAAG,IAAI,CAACH,QAAQ,CAACG,MAAM;IACnE;IAEA,IAAI,IAAI,CAACH,QAAQ,CAACI,SAAS,EAAE;MACzB,KAAK,MAAM,CAACC,EAAE,EAAED,SAAS,CAAC,IAAIE,MAAM,CAACC,OAAO,CAAC,IAAI,CAACP,QAAQ,CAACI,SAAS,CAAC,EAAE;QACnE,IAAIA,SAAS,CAACD,MAAM,EAAE;UAClBP,GAAG,CACCM,QAAQ,CAACF,QAAQ,EACjB,GAAG,IAAI,CAACD,SAAS,cAAcM,EAAE,SAAS,EAC1CG,eAAe,CAAC,IAAI,CAACR,QAAQ,CAACI,SAAS,CAACC,EAAE,CAAC,CAACF,MAAM,CACtD,CAAC;QACL;MACJ;IACJ;EACJ;EAEAM,eAAeA,CAACT,QAAiC,EAAE;IAC/C,MAAMU,SAA2C,GAAG;MAAE,GAAG,IAAI,CAACV;IAAS,CAAC;IACxE,IAAIM,MAAM,CAACK,IAAI,CAACD,SAAS,CAACN,SAAS,IAAI,CAAC,CAAC,CAAC,CAACQ,MAAM,KAAK,CAAC,EAAE;MACrD,OAAOF,SAAS,CAACN,SAAS;IAC9B;IAEA,MAAMS,MAAM,GAAG,CAAC,SAAS,EAAE,mBAAmB,EAAE,WAAW,CAAC;IAE5D,OAAOlB,SAAS,CAACmB,OAAO,CAACd,QAAQ,EAAEU,SAAS,CAAC,CAACK,MAAM,CAACC,EAAE,IAAI;MACvD,OAAO,CAACH,MAAM,CAACI,IAAI,CAACC,MAAM,IAAIF,EAAE,CAACG,IAAI,CAACC,UAAU,CAACF,MAAM,CAAC,CAAC;IAC7D,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["jsonPatch","set","StylesUpdater","constructor","elementId","bindings","applyToDocument","document","styles","overrides","bp","Object","entries","structuredClone","createJsonPatch","toCompare","keys","length","ignore","compare","filter","op","some","prefix","path","startsWith"],"sources":["StylesUpdater.ts"],"sourcesContent":["import { jsonPatch } from \"~/jsonPatch.js\";\nimport set from \"lodash/set.js\";\nimport type { Document, DocumentElementBindings } from \"./types.js\";\nimport type { IBindingsUpdater } from \"./IBindingsUpdater.js\";\nimport type { ElementStylesBindings } from \"./StylesBindingsProcessor.js\";\n\nexport class StylesUpdater implements IBindingsUpdater {\n private readonly bindings: ElementStylesBindings;\n private elementId: string;\n\n constructor(elementId: string, bindings: ElementStylesBindings) {\n this.elementId = elementId;\n this.bindings = bindings;\n }\n\n applyToDocument(document: Document) {\n if (this.bindings.styles) {\n document.bindings[this.elementId].styles = this.bindings.styles;\n }\n\n if (this.bindings.overrides) {\n for (const [bp, overrides] of Object.entries(this.bindings.overrides)) {\n if (overrides.styles) {\n set(\n document.bindings,\n `${this.elementId}.overrides.${bp}.styles`,\n structuredClone(this.bindings.overrides[bp].styles)\n );\n }\n }\n }\n }\n\n createJsonPatch(bindings: DocumentElementBindings) {\n const toCompare: Partial<DocumentElementBindings> = { ...this.bindings };\n if (Object.keys(toCompare.overrides ?? {}).length === 0) {\n delete toCompare.overrides;\n }\n\n const ignore = [\"/inputs\", \"/overrides/inputs\", \"/metadata\"];\n\n return jsonPatch.compare(bindings, toCompare).filter(op => {\n return !ignore.some(prefix => op.path.startsWith(prefix));\n });\n }\n}\n"],"mappings":"AAAA,SAASA,SAAS;AAClB,OAAOC,GAAG,MAAM,eAAe;AAK/B,OAAO,MAAMC,aAAa,CAA6B;EAInDC,WAAWA,CAACC,SAAiB,EAAEC,QAA+B,EAAE;IAC5D,IAAI,CAACD,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAACC,QAAQ,GAAGA,QAAQ;EAC5B;EAEAC,eAAeA,CAACC,QAAkB,EAAE;IAChC,IAAI,IAAI,CAACF,QAAQ,CAACG,MAAM,EAAE;MACtBD,QAAQ,CAACF,QAAQ,CAAC,IAAI,CAACD,SAAS,CAAC,CAACI,MAAM,GAAG,IAAI,CAACH,QAAQ,CAACG,MAAM;IACnE;IAEA,IAAI,IAAI,CAACH,QAAQ,CAACI,SAAS,EAAE;MACzB,KAAK,MAAM,CAACC,EAAE,EAAED,SAAS,CAAC,IAAIE,MAAM,CAACC,OAAO,CAAC,IAAI,CAACP,QAAQ,CAACI,SAAS,CAAC,EAAE;QACnE,IAAIA,SAAS,CAACD,MAAM,EAAE;UAClBP,GAAG,CACCM,QAAQ,CAACF,QAAQ,EACjB,GAAG,IAAI,CAACD,SAAS,cAAcM,EAAE,SAAS,EAC1CG,eAAe,CAAC,IAAI,CAACR,QAAQ,CAACI,SAAS,CAACC,EAAE,CAAC,CAACF,MAAM,CACtD,CAAC;QACL;MACJ;IACJ;EACJ;EAEAM,eAAeA,CAACT,QAAiC,EAAE;IAC/C,MAAMU,SAA2C,GAAG;MAAE,GAAG,IAAI,CAACV;IAAS,CAAC;IACxE,IAAIM,MAAM,CAACK,IAAI,CAACD,SAAS,CAACN,SAAS,IAAI,CAAC,CAAC,CAAC,CAACQ,MAAM,KAAK,CAAC,EAAE;MACrD,OAAOF,SAAS,CAACN,SAAS;IAC9B;IAEA,MAAMS,MAAM,GAAG,CAAC,SAAS,EAAE,mBAAmB,EAAE,WAAW,CAAC;IAE5D,OAAOlB,SAAS,CAACmB,OAAO,CAACd,QAAQ,EAAEU,SAAS,CAAC,CAACK,MAAM,CAACC,EAAE,IAAI;MACvD,OAAO,CAACH,MAAM,CAACI,IAAI,CAACC,MAAM,IAAIF,EAAE,CAACG,IAAI,CAACC,UAAU,CAACF,MAAM,CAAC,CAAC;IAC7D,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
package/Theme.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { WebsiteBuilderTheme, WebsiteBuilderThemeInput } from "./types/WebsiteBuilderTheme";
1
+ import type { WebsiteBuilderTheme, WebsiteBuilderThemeInput } from "./types/WebsiteBuilderTheme.js";
2
2
  export declare class Theme {
3
3
  static from(input: WebsiteBuilderThemeInput): WebsiteBuilderTheme;
4
4
  }
package/Theme.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import deepMerge from "deepmerge";
2
- import { defaultBreakpoints } from "./defaultBreakpoints";
3
- import { createLexicalTheme } from "./lexical/createLexicalTheme";
2
+ import { defaultBreakpoints } from "./defaultBreakpoints.js";
4
3
  export class Theme {
5
4
  static from(input) {
6
5
  const {
@@ -17,17 +16,11 @@ export class Theme {
17
16
  });
18
17
  return {
19
18
  css: input.css,
20
- cssVariables: input.cssVariables,
21
19
  fonts: input.fonts,
22
20
  breakpoints: breakpoints.sort((a, b) => b.maxWidth - a.maxWidth),
23
- lexical: createLexicalTheme(input?.lexical),
24
- styles: {
25
- colors: {
26
- ...input?.styles?.colors
27
- },
28
- typography: {
29
- ...input?.styles?.typography
30
- }
21
+ colors: input?.colors ?? [],
22
+ typography: {
23
+ ...input?.typography
31
24
  }
32
25
  };
33
26
  }
package/Theme.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["deepMerge","defaultBreakpoints","createLexicalTheme","Theme","from","input","custom","builtInOverrides","breakpoints","mergedBreakpoints","all","Object","entries","forEach","name","breakpoint","push","css","cssVariables","fonts","sort","a","b","maxWidth","lexical","styles","colors","typography"],"sources":["Theme.ts"],"sourcesContent":["import deepMerge from \"deepmerge\";\nimport type {\n Breakpoint,\n WebsiteBuilderTheme,\n WebsiteBuilderThemeInput\n} from \"~/types/WebsiteBuilderTheme\";\nimport { defaultBreakpoints } from \"~/defaultBreakpoints\";\nimport { createLexicalTheme } from \"~/lexical/createLexicalTheme\";\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 cssVariables: input.cssVariables,\n fonts: input.fonts,\n breakpoints: breakpoints.sort((a, b) => b.maxWidth - a.maxWidth),\n lexical: createLexicalTheme(input?.lexical),\n styles: {\n colors: {\n ...input?.styles?.colors\n },\n typography: {\n ...input?.styles?.typography\n }\n }\n };\n }\n}\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,WAAW;AAMjC,SAASC,kBAAkB;AAC3B,SAASC,kBAAkB;AAE3B,OAAO,MAAMC,KAAK,CAAC;EACf,OAAOC,IAAIA,CAACC,KAA+B,EAAuB;IAC9D,MAAM;MAAEC,MAAM,GAAG,CAAC,CAAC;MAAE,GAAGC;IAAiB,CAAC,GAAGF,KAAK,EAAEG,WAAW,IAAI,CAAC,CAAC;IAErE,MAAMC,iBAAiB,GAAGT,SAAS,CAACU,GAAG,CAAC,CACpC,CAAC,CAAC,EACFT,kBAAkB,EAClBM,gBAAgB,EAChBD,MAAM,CACT,CAA4C;IAE7C,MAAME,WAAyB,GAAG,EAAE;IACpCG,MAAM,CAACC,OAAO,CAACH,iBAAiB,IAAI,CAAC,CAAC,CAAC,CAACI,OAAO,CAAC,CAAC,CAACC,IAAI,EAAEC,UAAU,CAAC,KAAK;MACpEP,WAAW,CAACQ,IAAI,CAAC;QACbF,IAAI;QACJ,GAAIC;MACR,CAAC,CAAC;IACN,CAAC,CAAC;IAEF,OAAO;MACHE,GAAG,EAAEZ,KAAK,CAACY,GAAG;MACdC,YAAY,EAAEb,KAAK,CAACa,YAAY;MAChCC,KAAK,EAAEd,KAAK,CAACc,KAAK;MAClBX,WAAW,EAAEA,WAAW,CAACY,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKA,CAAC,CAACC,QAAQ,GAAGF,CAAC,CAACE,QAAQ,CAAC;MAChEC,OAAO,EAAEtB,kBAAkB,CAACG,KAAK,EAAEmB,OAAO,CAAC;MAC3CC,MAAM,EAAE;QACJC,MAAM,EAAE;UACJ,GAAGrB,KAAK,EAAEoB,MAAM,EAAEC;QACtB,CAAC;QACDC,UAAU,EAAE;UACR,GAAGtB,KAAK,EAAEoB,MAAM,EAAEE;QACtB;MACJ;IACJ,CAAC;EACL;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["deepMerge","defaultBreakpoints","Theme","from","input","custom","builtInOverrides","breakpoints","mergedBreakpoints","all","Object","entries","forEach","name","breakpoint","push","css","fonts","sort","a","b","maxWidth","colors","typography"],"sources":["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"],"mappings":"AAAA,OAAOA,SAAS,MAAM,WAAW;AAMjC,SAASC,kBAAkB;AAE3B,OAAO,MAAMC,KAAK,CAAC;EACf,OAAOC,IAAIA,CAACC,KAA+B,EAAuB;IAC9D,MAAM;MAAEC,MAAM,GAAG,CAAC,CAAC;MAAE,GAAGC;IAAiB,CAAC,GAAGF,KAAK,EAAEG,WAAW,IAAI,CAAC,CAAC;IAErE,MAAMC,iBAAiB,GAAGR,SAAS,CAACS,GAAG,CAAC,CACpC,CAAC,CAAC,EACFR,kBAAkB,EAClBK,gBAAgB,EAChBD,MAAM,CACT,CAA4C;IAE7C,MAAME,WAAyB,GAAG,EAAE;IACpCG,MAAM,CAACC,OAAO,CAACH,iBAAiB,IAAI,CAAC,CAAC,CAAC,CAACI,OAAO,CAAC,CAAC,CAACC,IAAI,EAAEC,UAAU,CAAC,KAAK;MACpEP,WAAW,CAACQ,IAAI,CAAC;QACbF,IAAI;QACJ,GAAIC;MACR,CAAC,CAAC;IACN,CAAC,CAAC;IAEF,OAAO;MACHE,GAAG,EAAEZ,KAAK,CAACY,GAAG;MACdC,KAAK,EAAEb,KAAK,CAACa,KAAK;MAClBV,WAAW,EAAEA,WAAW,CAACW,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKA,CAAC,CAACC,QAAQ,GAAGF,CAAC,CAACE,QAAQ,CAAC;MAChEC,MAAM,EAAElB,KAAK,EAAEkB,MAAM,IAAI,EAAE;MAC3BC,UAAU,EAAE;QACR,GAAGnB,KAAK,EAAEmB;MACd;IACJ,CAAC;EACL;AACJ","ignoreList":[]}
@@ -1,7 +1,9 @@
1
- import type { Breakpoint } from "./types";
1
+ import type { Breakpoint } from "./types.js";
2
2
  export interface ViewportInfo {
3
3
  width: number;
4
4
  height: number;
5
+ scrollWidth: number;
6
+ scrollHeight: number;
5
7
  scrollX: number;
6
8
  scrollY: number;
7
9
  breakpoint: string;
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
 
3
- import { environment } from "./Environment";
3
+ import { environment } from "./Environment.js";
4
4
  export class ViewportManager {
5
5
  /**
6
6
  * We need this fallback breakpoint for server environments.
@@ -77,12 +77,16 @@ export class ViewportManager {
77
77
  const viewport = environment.isClient() ? {
78
78
  width: window.innerWidth,
79
79
  height: window.innerHeight,
80
+ scrollWidth: window.document.body.scrollWidth,
81
+ scrollHeight: window.document.body.scrollHeight,
80
82
  scrollX: window.scrollX,
81
83
  scrollY: window.scrollY
82
84
  } : {
83
85
  // During SSR or Next.js build, viewport is not available.
84
86
  height: 0,
85
87
  width: 2000,
88
+ scrollHeight: 0,
89
+ scrollWidth: 2000,
86
90
  scrollX: 0,
87
91
  scrollY: 0
88
92
  };
@@ -1 +1 @@
1
- {"version":3,"names":["environment","ViewportManager","breakpoints","name","title","description","icon","minWidth","maxWidth","constructor","timeout","changeTimeout","changeStartSubscribers","Set","changeEndSubscribers","isChanging","changeTimer","handleViewportChange","bind","handleResize","isClient","window","addEventListener","passive","setBreakpoints","onViewportChangeStart","callback","add","delete","onViewportChangeEnd","getViewport","getViewportInfo","destroy","removeEventListener","clearTimeout","clear","viewportInfo","notifySubscribers","setTimeout","modes","reverse","viewport","width","innerWidth","height","innerHeight","scrollX","scrollY","breakpoint","filter","mode","subscribers","forEach","viewportManager"],"sources":["ViewportManager.ts"],"sourcesContent":["\"use client\";\nimport type { Breakpoint } from \"~/types\";\nimport { environment } from \"~/Environment\";\n\nexport interface ViewportInfo {\n width: number;\n height: 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 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 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"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,WAAW;AAWpB,OAAO,MAAMC,eAAe,CAAC;EAOzB;AACJ;AACA;EACYC,WAAW,GAAiB,CAChC;IACIC,IAAI,EAAE,SAAS;IACfC,KAAK,EAAE,EAAE;IACTC,WAAW,EAAE,EAAE;IACfC,IAAI,EAAE,EAAE;IACRC,QAAQ,EAAE,CAAC;IACXC,QAAQ,EAAE;EACd,CAAC,CACJ;EAEDC,WAAWA,CAACC,OAAe,GAAG,GAAG,EAAE;IAC/B,IAAI,CAACC,aAAa,GAAGD,OAAO;IAC5B,IAAI,CAACE,sBAAsB,GAAG,IAAIC,GAAG,CAAC,CAAC;IACvC,IAAI,CAACC,oBAAoB,GAAG,IAAID,GAAG,CAAC,CAAC;IACrC,IAAI,CAACE,UAAU,GAAG,KAAK;IACv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1C,QAAQ,IAAIiC,QAAQ,CAACC,KAAK,CAAC;IAE1E,OAAO;MAAE,GAAGD,QAAQ;MAAEO,UAAU,EAAEA,UAAU,CAAC7C,IAAI;MAAED,WAAW,EAAE,IAAI,CAACA;IAAY,CAAC;EACtF;EAEQmC,iBAAiBA,CACrBc,WAA8C,EAC9Cf,YAA0B,EACtB;IACJe,WAAW,CAACC,OAAO,CAAC1B,QAAQ,IAAI;MAC5B,IAAI,OAAOA,QAAQ,KAAK,UAAU,EAAE;QAChCA,QAAQ,CAACU,YAAY,CAAC;MAC1B;IACJ,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMiB,eAAe,GAAG,IAAIpD,eAAe,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["environment","ViewportManager","breakpoints","name","title","description","icon","minWidth","maxWidth","constructor","timeout","changeTimeout","changeStartSubscribers","Set","changeEndSubscribers","isChanging","changeTimer","handleViewportChange","bind","handleResize","isClient","window","addEventListener","passive","setBreakpoints","onViewportChangeStart","callback","add","delete","onViewportChangeEnd","getViewport","getViewportInfo","destroy","removeEventListener","clearTimeout","clear","viewportInfo","notifySubscribers","setTimeout","modes","reverse","viewport","width","innerWidth","height","innerHeight","scrollWidth","document","body","scrollHeight","scrollX","scrollY","breakpoint","filter","mode","subscribers","forEach","viewportManager"],"sources":["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"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,WAAW;AAapB,OAAO,MAAMC,eAAe,CAAC;EAOzB;AACJ;AACA;EACYC,WAAW,GAAiB,CAChC;IACIC,IAAI,EAAE,SAAS;IACfC,KAAK,EAAE,EAAE;IACTC,WAAW,EAAE,EAAE;IACfC,IAAI,EAAE,EAAE;IACRC,QAAQ,EAAE,CAAC;IACXC,QAAQ,EAAE;EACd,CAAC,CACJ;EAEDC,WAAWA,CAACC,OAAe,GAAG,GAAG,EAAE;IAC/B,IAAI,CAACC,aAAa,GAAGD,OAAO;IAC5B,IAAI,CAACE,sBAAsB,GAAG,IAAIC,GAAG,CAAC,CAAC;IACvC,IAAI,CAACC,oBAAoB,GAAG,IAAID,GAAG,CAAC,CAAC;IACrC,IAAI,CAACE,UAAU,GAAG,KAAK;IACvB,IAAI,CAACC,WAAW,GAAG,IAAI;IAEvB,IAAI,CAACC,oBAAoB,GAAG,IAAI,CAACA,oBAAoB,CAACC,IAAI,CAAC,IAAI,CAAC;IAChE,IAAI,CAACC,YAAY,GAAG,IAAI,CAACA,YAAY,CAACD,IAAI,CAAC,IAAI,CAAC;IAEhD,IAAIlB,WAAW,CAACoB,QAAQ,CAAC,CAAC,EAAE;MACxBC,MAAM,CAACC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAACH,YAAY,EAAE;QA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,IAAI,CAACA;IAAY,CAAC;EACtF;EAEQmC,iBAAiBA,CACrBkB,WAA8C,EAC9CnB,YAA0B,EACtB;IACJmB,WAAW,CAACC,OAAO,CAAC9B,QAAQ,IAAI;MAC5B,IAAI,OAAOA,QAAQ,KAAK,UAAU,EAAE;QAChCA,QAAQ,CAACU,YAAY,CAAC;MAC1B;IACJ,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMqB,eAAe,GAAG,IAAIxD,eAAe,CAAC,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import type { ResponsiveStyles } from "./types";
1
+ import type { ResponsiveStyles } from "./types.js";
2
2
  export interface CreateElementParams {
3
3
  component: string;
4
4
  inputs?: Record<string, any>;
@@ -1 +1 @@
1
- {"version":3,"names":["createElement","params","action"],"sources":["createElement.ts"],"sourcesContent":["import type { ResponsiveStyles } from \"~/types\";\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"],"mappings":"AAQA,OAAO,MAAMA,aAAa,GAAIC,MAA2B,IAAK;EAC1D,OAAO;IACHC,MAAM,EAAE,eAAe;IACvBD;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["createElement","params","action"],"sources":["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"],"mappings":"AAQA,OAAO,MAAMA,aAAa,GAAIC,MAA2B,IAAK;EAC1D,OAAO;IACHC,MAAM,EAAE,eAAe;IACvBD;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
package/createInput.d.ts CHANGED
@@ -1,17 +1,125 @@
1
- import type { TextInput, LongTextInput, NumberInput, BooleanInput, ColorInput, FileInput, LexicalInput, SelectInput, RadioInput, ObjectInput, DateTimeInput, ComponentInput, TagsInput, SlotInput } from "./types";
2
- type OmitType<T> = Omit<T, "type">;
3
- export declare function createTextInput(input: OmitType<TextInput>): TextInput;
4
- export declare function createLongTextInput(input: OmitType<LongTextInput>): ComponentInput;
5
- export declare function createNumberInput(input: OmitType<NumberInput>): NumberInput;
6
- export declare function createBooleanInput(input: OmitType<BooleanInput>): BooleanInput;
7
- export declare function createColorInput(input: OmitType<ColorInput>): ColorInput;
8
- export declare function createFileInput(input: OmitType<FileInput>): FileInput;
9
- export declare function createDateInput(input: OmitType<DateTimeInput>): DateTimeInput;
10
- export declare function createLexicalInput(input: OmitType<LexicalInput>): LexicalInput;
11
- export declare function createSelectInput(input: OmitType<SelectInput>): SelectInput;
12
- export declare function createRadioInput(input: OmitType<RadioInput>): RadioInput;
13
- export declare function createObjectInput(input: OmitType<ObjectInput>): ObjectInput;
14
- export declare function createTagsInput(input: OmitType<TagsInput>): TagsInput;
15
- export declare function createSlotInput(input: OmitType<SlotInput>): SlotInput;
1
+ import type { TextInput, LongTextInput, NumberInput, BooleanInput, ColorInput, FileInput, LexicalInput, SelectInput, RadioInput, ObjectInput, DateTimeInput, ComponentInput, TagsInput, SlotInput } from "./types.js";
2
+ export type InputFactory<Name extends string> = ReturnType<typeof createTextInput<Name>> | ReturnType<typeof createLongTextInput<Name>> | ReturnType<typeof createNumberInput<Name>> | ReturnType<typeof createBooleanInput<Name>> | ReturnType<typeof createColorInput<Name>> | ReturnType<typeof createFileInput<Name>> | ReturnType<typeof createDateInput<Name>> | ReturnType<typeof createLexicalInput<Name>> | ReturnType<typeof createSelectInput<Name>> | ReturnType<typeof createRadioInput<Name>> | ReturnType<typeof createObjectInput<Name>> | ReturnType<typeof createTagsInput<Name>> | ReturnType<typeof createSlotInput<Name>>;
3
+ /**
4
+ * TypeScript Overload Resolution and Input Factory Design
5
+ *
6
+ * Each input factory (e.g., createTextInput) is defined with two TypeScript overload signatures:
7
+ * 1. One overload requires a `name` property in the input (used for array-based APIs, where inference is needed).
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
+ export declare function createTextInput<TName extends string>(input: {
22
+ name: TName;
23
+ } & Omit<TextInput, "type" | "name">): TextInput & {
24
+ name: TName;
25
+ };
26
+ export declare function createTextInput<TName extends string>(input: Omit<TextInput, "type" | "name">): TextInput & {
27
+ name: TName;
28
+ };
29
+ export declare function createLongTextInput<TName extends string>(input: {
30
+ name: TName;
31
+ } & Omit<LongTextInput, "type" | "name">): LongTextInput & {
32
+ name: TName;
33
+ };
34
+ export declare function createLongTextInput<TName extends string>(input: Omit<LongTextInput, "type" | "name">): LongTextInput & {
35
+ name: TName;
36
+ };
37
+ export declare function createNumberInput<TName extends string>(input: {
38
+ name: TName;
39
+ } & Omit<NumberInput, "type" | "name">): NumberInput & {
40
+ name: TName;
41
+ };
42
+ export declare function createNumberInput<TName extends string>(input: Omit<NumberInput, "type" | "name">): NumberInput & {
43
+ name: TName;
44
+ };
45
+ export declare function createBooleanInput<TName extends string>(input: {
46
+ name: TName;
47
+ } & Omit<BooleanInput, "type" | "name">): BooleanInput & {
48
+ name: TName;
49
+ };
50
+ export declare function createBooleanInput<TName extends string>(input: Omit<BooleanInput, "type" | "name">): BooleanInput & {
51
+ name: TName;
52
+ };
53
+ export declare function createColorInput<TName extends string>(input: {
54
+ name: TName;
55
+ } & Omit<ColorInput, "type" | "name">): ColorInput & {
56
+ name: TName;
57
+ };
58
+ export declare function createColorInput<TName extends string>(input: Omit<ColorInput, "type" | "name">): ColorInput & {
59
+ name: TName;
60
+ };
61
+ export declare function createFileInput<TName extends string>(input: {
62
+ name: TName;
63
+ } & Omit<FileInput, "type" | "name">): FileInput & {
64
+ name: TName;
65
+ };
66
+ export declare function createFileInput<TName extends string>(input: Omit<FileInput, "type" | "name">): FileInput & {
67
+ name: TName;
68
+ };
69
+ export declare function createDateInput<TName extends string>(input: {
70
+ name: TName;
71
+ } & Omit<DateTimeInput, "type" | "name">): DateTimeInput & {
72
+ name: TName;
73
+ };
74
+ export declare function createDateInput<TName extends string>(input: Omit<DateTimeInput, "type" | "name">): DateTimeInput & {
75
+ name: TName;
76
+ };
77
+ export declare function createLexicalInput<TName extends string>(input: {
78
+ name: TName;
79
+ } & Omit<LexicalInput, "type" | "name">): LexicalInput & {
80
+ name: TName;
81
+ };
82
+ export declare function createLexicalInput<TName extends string>(input: Omit<LexicalInput, "type" | "name">): LexicalInput & {
83
+ name: TName;
84
+ };
85
+ export declare function createSelectInput<TName extends string>(input: {
86
+ name: TName;
87
+ } & Omit<SelectInput, "type" | "name">): SelectInput & {
88
+ name: TName;
89
+ };
90
+ export declare function createSelectInput<TName extends string>(input: Omit<SelectInput, "type" | "name">): SelectInput & {
91
+ name: TName;
92
+ };
93
+ export declare function createRadioInput<TName extends string>(input: {
94
+ name: TName;
95
+ } & Omit<RadioInput, "type" | "name">): RadioInput & {
96
+ name: TName;
97
+ };
98
+ export declare function createRadioInput<TName extends string>(input: Omit<RadioInput, "type" | "name">): RadioInput & {
99
+ name: TName;
100
+ };
101
+ export declare function createObjectInput<TName extends string>(input: {
102
+ name: TName;
103
+ } & Omit<ObjectInput, "type" | "name">): ObjectInput & {
104
+ name: TName;
105
+ };
106
+ export declare function createObjectInput<TName extends string>(input: Omit<ObjectInput, "type" | "name">): ObjectInput & {
107
+ name: TName;
108
+ };
109
+ export declare function createTagsInput<TName extends string>(input: {
110
+ name: TName;
111
+ } & Omit<TagsInput, "type" | "name">): TagsInput & {
112
+ name: TName;
113
+ };
114
+ export declare function createTagsInput<TName extends string>(input: Omit<TagsInput, "type" | "name">): TagsInput & {
115
+ name: TName;
116
+ };
117
+ export declare function createSlotInput<TName extends string>(input: {
118
+ name: TName;
119
+ } & Omit<SlotInput, "type" | "name">): SlotInput & {
120
+ name: TName;
121
+ };
122
+ export declare function createSlotInput<TName extends string>(input: Omit<SlotInput, "type" | "name">): SlotInput & {
123
+ name: TName;
124
+ };
16
125
  export declare function createInput(input: ComponentInput): ComponentInput;
17
- export {};
package/createInput.js CHANGED
@@ -1,5 +1,25 @@
1
- import { functionConverter } from "./FunctionConverter";
1
+ import { functionConverter } from "./FunctionConverter.js";
2
+
3
+ /**
4
+ * TypeScript Overload Resolution and Input Factory Design
5
+ *
6
+ * Each input factory (e.g., createTextInput) is defined with two TypeScript overload signatures:
7
+ * 1. One overload requires a `name` property in the input (used for array-based APIs, where inference is needed).
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
+ */
2
21
  // Text
22
+
3
23
  export function createTextInput(input) {
4
24
  return createInput({
5
25
  type: "text",
@@ -9,6 +29,7 @@ export function createTextInput(input) {
9
29
  }
10
30
 
11
31
  // Long Text
32
+
12
33
  export function createLongTextInput(input) {
13
34
  return createInput({
14
35
  type: "longText",
@@ -18,6 +39,7 @@ export function createLongTextInput(input) {
18
39
  }
19
40
 
20
41
  // Number
42
+
21
43
  export function createNumberInput(input) {
22
44
  return createInput({
23
45
  type: "number",
@@ -27,6 +49,7 @@ export function createNumberInput(input) {
27
49
  }
28
50
 
29
51
  // Boolean
52
+
30
53
  export function createBooleanInput(input) {
31
54
  return createInput({
32
55
  type: "boolean",
@@ -36,6 +59,7 @@ export function createBooleanInput(input) {
36
59
  }
37
60
 
38
61
  // Color
62
+
39
63
  export function createColorInput(input) {
40
64
  return createInput({
41
65
  type: "color",
@@ -45,6 +69,7 @@ export function createColorInput(input) {
45
69
  }
46
70
 
47
71
  // File
72
+
48
73
  export function createFileInput(input) {
49
74
  return createInput({
50
75
  type: "file",
@@ -54,6 +79,7 @@ export function createFileInput(input) {
54
79
  }
55
80
 
56
81
  // Date
82
+
57
83
  export function createDateInput(input) {
58
84
  return createInput({
59
85
  type: "datetime",
@@ -63,6 +89,7 @@ export function createDateInput(input) {
63
89
  }
64
90
 
65
91
  // Rich Text
92
+
66
93
  export function createLexicalInput(input) {
67
94
  return createInput({
68
95
  type: "lexical",
@@ -72,6 +99,7 @@ export function createLexicalInput(input) {
72
99
  }
73
100
 
74
101
  // Select
102
+
75
103
  export function createSelectInput(input) {
76
104
  return createInput({
77
105
  type: "select",
@@ -81,6 +109,7 @@ export function createSelectInput(input) {
81
109
  }
82
110
 
83
111
  // Radio
112
+
84
113
  export function createRadioInput(input) {
85
114
  return createInput({
86
115
  type: "radio",
@@ -90,6 +119,7 @@ export function createRadioInput(input) {
90
119
  }
91
120
 
92
121
  // Object
122
+
93
123
  export function createObjectInput(input) {
94
124
  return createInput({
95
125
  type: "object",
@@ -99,6 +129,7 @@ export function createObjectInput(input) {
99
129
  }
100
130
 
101
131
  // Tags
132
+
102
133
  export function createTagsInput(input) {
103
134
  return createInput({
104
135
  type: "text",
@@ -112,6 +143,7 @@ export function createSlotInput(input) {
112
143
  type: "slot",
113
144
  list: true,
114
145
  renderer: "Webiny/Slot",
146
+ defaultValue: [],
115
147
  ...input
116
148
  });
117
149
  }
@@ -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","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\";\nimport { functionConverter } from \"~/FunctionConverter\";\n\ntype OmitType<T> = Omit<T, \"type\">;\n\n// Text\nexport function createTextInput(input: OmitType<TextInput>) {\n return createInput({\n type: \"text\",\n renderer: \"Webiny/Input\",\n ...input\n }) as TextInput;\n}\n\n// Long Text\nexport function createLongTextInput(input: OmitType<LongTextInput>) {\n return createInput({\n type: \"longText\",\n renderer: \"Webiny/Textarea\",\n ...input\n });\n}\n\n// Number\nexport function createNumberInput(input: OmitType<NumberInput>) {\n return createInput({\n type: \"number\",\n renderer: \"Webiny/Number\",\n ...input\n }) as NumberInput;\n}\n\n// Boolean\nexport function createBooleanInput(input: OmitType<BooleanInput>) {\n return createInput({\n type: \"boolean\",\n renderer: \"Webiny/Switch\",\n ...input\n }) as BooleanInput;\n}\n\n// Color\nexport function createColorInput(input: OmitType<ColorInput>) {\n return createInput({\n type: \"color\",\n renderer: \"Webiny/ColorPicker\",\n ...input\n }) as ColorInput;\n}\n\n// File\nexport function createFileInput(input: OmitType<FileInput>) {\n return createInput({\n type: \"file\",\n renderer: \"Webiny/FileManager\",\n ...input\n }) as FileInput;\n}\n\n// Date\nexport function createDateInput(input: OmitType<DateTimeInput>) {\n return createInput({\n type: \"datetime\",\n renderer: \"Webiny/DateTime\",\n ...input\n }) as DateTimeInput;\n}\n\n// Rich Text\nexport function createLexicalInput(input: OmitType<LexicalInput>) {\n return createInput({\n type: \"lexical\",\n renderer: \"Webiny/Lexical\",\n ...input\n }) as LexicalInput;\n}\n\n// Select\nexport function createSelectInput(input: OmitType<SelectInput>) {\n return createInput({\n type: \"select\",\n renderer: \"Webiny/Select\",\n ...input\n }) as SelectInput;\n}\n\n// Radio\nexport function createRadioInput(input: OmitType<RadioInput>) {\n return createInput({\n type: \"radio\",\n renderer: \"Webiny/RadioGroup\",\n ...input\n }) as RadioInput;\n}\n\n// Object\nexport function createObjectInput(input: OmitType<ObjectInput>) {\n return createInput({\n type: \"object\",\n renderer: \"Webiny/Object\",\n ...input\n }) as ObjectInput;\n}\n\n// Tags\nexport function createTagsInput(input: OmitType<TagsInput>) {\n return createInput({\n type: \"text\",\n list: true,\n renderer: \"Webiny/Tags\",\n ...input\n }) as TagsInput;\n}\n\nexport function createSlotInput(input: OmitType<SlotInput>) {\n return createInput({\n type: \"slot\",\n list: true,\n renderer: \"Webiny/Slot\",\n ...input\n }) as SlotInput;\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;AAI1B;AACA,OAAO,SAASC,eAAeA,CAACC,KAA0B,EAAE;EACxD,OAAOC,WAAW,CAAC;IACfC,IAAI,EAAE,MAAM;IACZC,QAAQ,EAAE,cAAc;IACxB,GAAGH;EACP,CAAC,CAAC;AACN;;AAEA;AACA,OAAO,SAASI,mBAAmBA,CAACJ,KAA8B,EAAE;EAChE,OAAOC,WAAW,CAAC;IACfC,IAAI,EAAE,UAAU;IAChBC,QAAQ,EAAE,iBAAiB;IAC3B,GAAGH;EACP,CAAC,CAAC;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WAAW,CAAC;IACfC,IAAI,EAAE,OAAO;IACbC,QAAQ,EAAE,mBAAmB;IAC7B,GAAGH;EACP,CAAC,CAAC;AACN;;AAEA;AACA,OAAO,SAASa,iBAAiBA,CAACb,KAA4B,EAAE;EAC5D,OAAOC,WAAW,CAAC;IACfC,IAAI,EAAE,QAAQ;IACdC,QAAQ,EAAE,eAAe;IACzB,GAAGH;EACP,CAAC,CAAC;AACN;;AAEA;AACA,OAAO,SAASc,eAAeA,CAACd,KAA0B,EAAE;EACxD,OAAOC,WAAW,CAAC;IACfC,IAAI,EAAE,MAAM;IACZa,IAAI,EAAE,IAAI;IACVZ,QAAQ,EAAE,aAAa;IACvB,GAAGH;EACP,CAAC,CAAC;AACN;AAEA,OAAO,SAASgB,eAAeA,CAAChB,KAA0B,EAAE;EACxD,OAAOC,WAAW,CAAC;IACfC,IAAI,EAAE,MAAM;IACZa,IAAI,EAAE,IAAI;IACVZ,QAAQ,EAAE,aAAa;IACvB,GAAGH;EACP,CAAC,CAAC;AACN;;AAEA;AACA,OAAO,SAASC,WAAWA,CAACD,KAAqB,EAAkB;EAC/D,IAAIA,KAAK,CAACiB,QAAQ,EAAE;IAChB;IACAjB,KAAK,CAACiB,QAAQ,GAAGnB,iBAAiB,CAACoB,SAAS,CAAClB,KAAK,CAACiB,QAAS,CAAC;EACjE;EACA,OAAOjB,KAAK;AAChB","ignoreList":[]}
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,EA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teBuilderThemeInput } from "./types/WebsiteBuilderTheme";
1
+ import type { WebsiteBuilderThemeInput } from "./types/WebsiteBuilderTheme.js";
2
2
  export type { WebsiteBuilderThemeInput };
3
3
  export declare const createTheme: (theme: WebsiteBuilderThemeInput) => WebsiteBuilderThemeInput;
@@ -1 +1 @@
1
- {"version":3,"names":["createTheme","theme"],"sources":["createTheme.ts"],"sourcesContent":["import type { WebsiteBuilderThemeInput } from \"~/types/WebsiteBuilderTheme\";\n\nexport type { WebsiteBuilderThemeInput };\n\nexport const createTheme = (theme: WebsiteBuilderThemeInput) => {\n return theme;\n};\n"],"mappings":"AAIA,OAAO,MAAMA,WAAW,GAAIC,KAA+B,IAAK;EAC5D,OAAOA,KAAK;AAChB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["createTheme","theme"],"sources":["createTheme.ts"],"sourcesContent":["import type { WebsiteBuilderThemeInput } from \"~/types/WebsiteBuilderTheme.js\";\n\nexport type { WebsiteBuilderThemeInput };\n\nexport const createTheme = (theme: WebsiteBuilderThemeInput) => {\n return theme;\n};\n"],"mappings":"AAIA,OAAO,MAAMA,WAAW,GAAIC,KAA+B,IAAK;EAC5D,OAAOA,KAAK;AAChB,CAAC","ignoreList":[]}
@@ -3,11 +3,16 @@ interface QueryParams {
3
3
  variables: Record<string, any>;
4
4
  preview?: boolean;
5
5
  }
6
+ type WithPath<T> = T & {
7
+ path?: string;
8
+ next?: Record<string, any>;
9
+ };
6
10
  export declare class ApiClient {
7
- private readonly apiEndpoint;
11
+ private readonly apiHost;
8
12
  private readonly apiKey;
9
13
  private readonly apiTenant;
10
14
  constructor(apiHost: string, apiKey: string, apiTenant: string);
15
+ fetch({ headers, path, ...params }: WithPath<RequestInit>): Promise<any>;
11
16
  query({ query, variables, preview }: QueryParams): Promise<any>;
12
17
  }
13
18
  export {};
@@ -1,9 +1,25 @@
1
1
  export class ApiClient {
2
2
  constructor(apiHost, apiKey, apiTenant) {
3
3
  this.apiTenant = apiTenant;
4
- this.apiEndpoint = apiHost + "/graphql";
4
+ this.apiHost = apiHost;
5
5
  this.apiKey = apiKey;
6
6
  }
7
+ async fetch({
8
+ headers,
9
+ path,
10
+ ...params
11
+ }) {
12
+ return fetch(`${this.apiHost}${path}`, {
13
+ method: "GET",
14
+ headers: {
15
+ "Content-Type": "application/json",
16
+ "X-Tenant": this.apiTenant,
17
+ Authorization: "Bearer " + this.apiKey,
18
+ ...headers
19
+ },
20
+ ...params
21
+ }).then(res => res.json());
22
+ }
7
23
  async query({
8
24
  query,
9
25
  variables,
@@ -16,19 +32,14 @@ export class ApiClient {
16
32
  };
17
33
  const request = {
18
34
  ...fetchOptions,
35
+ path: "/graphql",
19
36
  method: "POST",
20
- headers: {
21
- "Content-Type": "application/json",
22
- "X-Tenant": this.apiTenant,
23
- Authorization: "Bearer " + this.apiKey
24
- },
25
37
  body: JSON.stringify({
26
38
  query,
27
39
  variables
28
40
  })
29
41
  };
30
- const res = await fetch(this.apiEndpoint, request);
31
- const json = await res.json();
42
+ const json = await this.fetch(request);
32
43
  if (json.message) {
33
44
  throw new Error(json.message);
34
45
  }
@@ -1 +1 @@
1
- {"version":3,"names":["ApiClient","constructor","apiHost","apiKey","apiTenant","apiEndpoint","query","variables","preview","fetchOptions","next","revalidate","request","method","headers","Authorization","body","JSON","stringify","res","fetch","json","message","Error","errors","console","error","data"],"sources":["ApiClient.ts"],"sourcesContent":["interface QueryParams {\n query: string;\n variables: Record<string, any>;\n preview?: boolean;\n}\n\nexport class ApiClient {\n private readonly apiEndpoint: string;\n private readonly apiKey: string;\n private readonly apiTenant: string;\n\n constructor(apiHost: string, apiKey: string, apiTenant: string) {\n this.apiTenant = apiTenant;\n this.apiEndpoint = apiHost + \"/graphql\";\n this.apiKey = apiKey;\n }\n\n async query({ query, variables, preview }: QueryParams) {\n const fetchOptions = {\n next: {\n revalidate: preview ? 0 : 60\n }\n };\n\n const request = {\n ...fetchOptions,\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"X-Tenant\": this.apiTenant,\n Authorization: \"Bearer \" + this.apiKey\n },\n body: JSON.stringify({\n query,\n variables\n })\n };\n\n const res = await fetch(this.apiEndpoint, request);\n const json = await res.json();\n\n if (json.message) {\n throw new Error(json.message);\n }\n\n if (json.errors) {\n console.error(json.errors);\n throw new Error(\"Failed to fetch API\");\n }\n\n return json.data;\n }\n}\n"],"mappings":"AAMA,OAAO,MAAMA,SAAS,CAAC;EAKnBC,WAAWA,CAACC,OAAe,EAAEC,MAAc,EAAEC,SAAiB,EAAE;IAC5D,IAAI,CAACA,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAACC,WAAW,GAAGH,OAAO,GAAG,UAAU;IACvC,IAAI,CAACC,MAAM,GAAGA,MAAM;EACxB;EAEA,MAAMG,KAAKA,CAAC;IAAEA,KAAK;IAAEC,SAAS;IAAEC;EAAqB,CAAC,EAAE;IACpD,MAAMC,YAAY,GAAG;MACjBC,IAAI,EAAE;QACFC,UAAU,EAAEH,OAAO,GAAG,CAAC,GAAG;MAC9B;IACJ,CAAC;IAED,MAAMI,OAAO,GAAG;MACZ,GAAGH,YAAY;MACfI,MAAM,EAAE,MAAM;MACdC,OAAO,EAAE;QACL,cAAc,EAAE,kBAAkB;QAClC,UAAU,EAAE,IAAI,CAACV,SAAS;QAC1BW,aAAa,EAAE,SAAS,GAAG,IAAI,CAACZ;MACpC,CAAC;MACDa,IAAI,EAAEC,IAAI,CAACC,SAAS,CAAC;QACjBZ,KAAK;QACLC;MACJ,CAAC;IACL,CAAC;IAED,MAAMY,GAAG,GAAG,MAAMC,KAAK,CAAC,IAAI,CAACf,WAAW,EAAEO,OAAO,CAAC;IAClD,MAAMS,IAAI,GAAG,MAAMF,GAAG,CAACE,IAAI,CAAC,CAAC;IAE7B,IAAIA,IAAI,CAACC,OAAO,EAAE;MACd,MAAM,IAAIC,KAAK,CAACF,IAAI,CAACC,OAAO,CAAC;IACjC;IAEA,IAAID,IAAI,CAACG,MAAM,EAAE;MACbC,OAAO,CAACC,KAAK,CAACL,IAAI,CAACG,MAAM,CAAC;MAC1B,MAAM,IAAID,KAAK,CAAC,qBAAqB,CAAC;IAC1C;IAEA,OAAOF,IAAI,CAACM,IAAI;EACpB;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["ApiClient","constructor","apiHost","apiKey","apiTenant","fetch","headers","path","params","method","Authorization","then","res","json","query","variables","preview","fetchOptions","next","revalidate","request","body","JSON","stringify","message","Error","errors","console","error","data"],"sources":["ApiClient.ts"],"sourcesContent":["interface QueryParams {\n query: string;\n variables: Record<string, any>;\n preview?: boolean;\n}\n\ntype WithPath<T> = T & {\n path?: string;\n next?: Record<string, any>;\n};\n\nexport class ApiClient {\n private readonly apiHost: string;\n private readonly apiKey: string;\n private readonly apiTenant: string;\n\n constructor(apiHost: string, apiKey: string, apiTenant: string) {\n this.apiTenant = apiTenant;\n this.apiHost = apiHost;\n this.apiKey = apiKey;\n }\n\n async fetch({ headers, path, ...params }: WithPath<RequestInit>): Promise<any> {\n return fetch(`${this.apiHost}${path}`, {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"X-Tenant\": this.apiTenant,\n Authorization: \"Bearer \" + this.apiKey,\n ...headers\n },\n ...params\n }).then(res => res.json());\n }\n\n async query({ query, variables, preview }: QueryParams) {\n const fetchOptions = {\n next: {\n revalidate: preview ? 0 : 60\n }\n };\n\n const request: WithPath<RequestInit> = {\n ...fetchOptions,\n path: \"/graphql\",\n method: \"POST\",\n body: JSON.stringify({\n query,\n variables\n })\n };\n\n const json = await this.fetch(request);\n\n if (json.message) {\n throw new Error(json.message);\n }\n\n if (json.errors) {\n console.error(json.errors);\n throw new Error(\"Failed to fetch API\");\n }\n\n return json.data;\n }\n}\n"],"mappings":"AAWA,OAAO,MAAMA,SAAS,CAAC;EAKnBC,WAAWA,CAACC,OAAe,EAAEC,MAAc,EAAEC,SAAiB,EAAE;IAC5D,IAAI,CAACA,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAACF,OAAO,GAAGA,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1,5 +1,5 @@
1
- import type { IDataProvider, PublicPage } from "../types.js";
2
- import type { ApiClient } from "./ApiClient";
1
+ import type { IDataProvider, ListPagesOptions, ListPagesResult, PublicPage } from "../types.js";
2
+ import type { ApiClient } from "../dataProviders/ApiClient.js";
3
3
  interface DefaultDataProviderConfig {
4
4
  apiClient: ApiClient;
5
5
  }
@@ -8,7 +8,7 @@ export declare class DefaultDataProvider implements IDataProvider {
8
8
  constructor(config: DefaultDataProviderConfig);
9
9
  getPageByPath(path: string): Promise<PublicPage | null>;
10
10
  getPageById(id: string): Promise<PublicPage | null>;
11
- listPages(): Promise<any>;
11
+ listPages(options?: ListPagesOptions): Promise<ListPagesResult>;
12
12
  private checkForErrors;
13
13
  }
14
14
  export {};