@webiny/website-builder-sdk 6.6.0-alpha.0 → 6.6.0-alpha.10

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 (259) hide show
  1. package/BindingsResolver.d.ts +4 -1
  2. package/BindingsResolver.js.map +1 -1
  3. package/ComponentInputTraverser.js +1 -0
  4. package/ComponentInputTraverser.js.map +1 -1
  5. package/ComponentManifestToAstConverter.d.ts +23 -1
  6. package/ComponentManifestToAstConverter.js +122 -2
  7. package/ComponentManifestToAstConverter.js.map +1 -1
  8. package/ComponentRegistry.d.ts +2 -1
  9. package/ComponentRegistry.js +7 -0
  10. package/ComponentRegistry.js.map +1 -1
  11. package/ComponentResolver.d.ts +6 -3
  12. package/ComponentResolver.js +9 -4
  13. package/ComponentResolver.js.map +1 -1
  14. package/ConstraintEvaluator.d.ts +5 -0
  15. package/ConstraintEvaluator.js +20 -4
  16. package/ConstraintEvaluator.js.map +1 -1
  17. package/ConstraintEvaluator.test.js +137 -0
  18. package/ConstraintEvaluator.test.js.map +1 -1
  19. package/ContentSdk.d.ts +77 -2
  20. package/ContentSdk.js +113 -10
  21. package/ContentSdk.js.map +1 -1
  22. package/DocumentStoreManager.d.ts +9 -2
  23. package/DocumentStoreManager.js +24 -5
  24. package/DocumentStoreManager.js.map +1 -1
  25. package/EditingSdk.d.ts +18 -2
  26. package/EditingSdk.js +30 -5
  27. package/EditingSdk.js.map +1 -1
  28. package/ElementBindings.d.ts +28 -0
  29. package/ElementBindings.js +88 -0
  30. package/ElementBindings.js.map +1 -0
  31. package/ElementBindings.test.d.ts +1 -0
  32. package/ElementBindings.test.js +127 -0
  33. package/ElementBindings.test.js.map +1 -0
  34. package/ElementFactory.d.ts +10 -1
  35. package/ElementFactory.js +41 -8
  36. package/ElementFactory.js.map +1 -1
  37. package/ElementFactory.test.js +260 -0
  38. package/ElementFactory.test.js.map +1 -1
  39. package/ElementSelection.d.ts +20 -0
  40. package/ElementSelection.js +32 -0
  41. package/ElementSelection.js.map +1 -0
  42. package/ElementSelection.test.d.ts +1 -0
  43. package/ElementSelection.test.js +73 -0
  44. package/ElementSelection.test.js.map +1 -0
  45. package/Environment.d.ts +7 -0
  46. package/Environment.js +2 -1
  47. package/Environment.js.map +1 -1
  48. package/Environment.test.d.ts +1 -0
  49. package/Environment.test.js +39 -0
  50. package/Environment.test.js.map +1 -0
  51. package/GlobalComponentLanguage.d.ts +31 -0
  52. package/GlobalComponentLanguage.js +37 -0
  53. package/GlobalComponentLanguage.js.map +1 -0
  54. package/InheritanceProcessor.test.js +8 -0
  55. package/InheritanceProcessor.test.js.map +1 -1
  56. package/InheritedValueResolver.d.ts +6 -0
  57. package/InheritedValueResolver.js +7 -0
  58. package/InheritedValueResolver.js.map +1 -1
  59. package/InputBindingsProcessor.js +6 -2
  60. package/InputBindingsProcessor.js.map +1 -1
  61. package/InputRenderer.test.d.ts +1 -0
  62. package/InputRenderer.test.js +186 -0
  63. package/InputRenderer.test.js.map +1 -0
  64. package/InputsBindingsProcessor.test.js +130 -0
  65. package/InputsBindingsProcessor.test.js.map +1 -1
  66. package/InputsUpdater.js +1 -0
  67. package/InputsUpdater.js.map +1 -1
  68. package/LayoutContentArea.d.ts +68 -0
  69. package/LayoutContentArea.js +78 -0
  70. package/LayoutContentArea.js.map +1 -0
  71. package/LayoutContentArea.test.d.ts +1 -0
  72. package/LayoutContentArea.test.js +111 -0
  73. package/LayoutContentArea.test.js.map +1 -0
  74. package/LiveSdk.d.ts +5 -2
  75. package/LiveSdk.js +6 -2
  76. package/LiveSdk.js.map +1 -1
  77. package/NullSdk.d.ts +2 -1
  78. package/NullSdk.js +3 -0
  79. package/NullSdk.js.map +1 -1
  80. package/PreviewDocument.d.ts +2 -1
  81. package/PreviewDocument.js +2 -2
  82. package/PreviewDocument.js.map +1 -1
  83. package/PreviewSdk.d.ts +5 -2
  84. package/PreviewSdk.js +6 -2
  85. package/PreviewSdk.js.map +1 -1
  86. package/PreviewViewport.d.ts +5 -0
  87. package/PreviewViewport.js +9 -0
  88. package/PreviewViewport.js.map +1 -1
  89. package/PreviewViewport.test.d.ts +1 -0
  90. package/PreviewViewport.test.js +27 -0
  91. package/PreviewViewport.test.js.map +1 -0
  92. package/RadioOptionInputs.test.d.ts +1 -0
  93. package/RadioOptionInputs.test.js +521 -0
  94. package/RadioOptionInputs.test.js.map +1 -0
  95. package/ResizeObserver.js +1 -1
  96. package/ResizeObserver.js.map +1 -1
  97. package/StylesUpdater.js +4 -1
  98. package/StylesUpdater.js.map +1 -1
  99. package/Theme.js +2 -1
  100. package/Theme.js.map +1 -1
  101. package/asset/deliveryUrl.d.ts +41 -0
  102. package/asset/deliveryUrl.js +34 -0
  103. package/asset/deliveryUrl.js.map +1 -0
  104. package/asset/deliveryUrl.test.d.ts +1 -0
  105. package/asset/deliveryUrl.test.js +127 -0
  106. package/asset/deliveryUrl.test.js.map +1 -0
  107. package/asset/geometry.d.ts +7 -0
  108. package/asset/geometry.js +10 -0
  109. package/asset/geometry.js.map +1 -0
  110. package/asset/imageSrcSet.d.ts +63 -0
  111. package/asset/imageSrcSet.js +98 -0
  112. package/asset/imageSrcSet.js.map +1 -0
  113. package/asset/imageSrcSet.test.d.ts +1 -0
  114. package/asset/imageSrcSet.test.js +103 -0
  115. package/asset/imageSrcSet.test.js.map +1 -0
  116. package/asset/index.d.ts +5 -0
  117. package/asset/index.js +5 -0
  118. package/asset/normalize.d.ts +24 -0
  119. package/asset/normalize.js +106 -0
  120. package/asset/normalize.js.map +1 -0
  121. package/asset/normalize.test.d.ts +1 -0
  122. package/asset/normalize.test.js +263 -0
  123. package/asset/normalize.test.js.map +1 -0
  124. package/asset/types.d.ts +2 -0
  125. package/asset/types.js +0 -0
  126. package/componentLoader/ComponentLoader.d.ts +16 -0
  127. package/componentLoader/ComponentLoader.js +0 -0
  128. package/componentLoader/RegistryOnlyComponentLoader.d.ts +9 -0
  129. package/componentLoader/RegistryOnlyComponentLoader.js +8 -0
  130. package/componentLoader/RegistryOnlyComponentLoader.js.map +1 -0
  131. package/componentLoader/createComponentLoader.d.ts +7 -0
  132. package/componentLoader/createComponentLoader.js +10 -0
  133. package/componentLoader/createComponentLoader.js.map +1 -0
  134. package/componentLoader/defaultComponentLoader.d.ts +7 -0
  135. package/componentLoader/defaultComponentLoader.js +8 -0
  136. package/componentLoader/defaultComponentLoader.js.map +1 -0
  137. package/componentLoader/index.d.ts +3 -0
  138. package/componentLoader/index.js +3 -0
  139. package/contentClientState.test.d.ts +1 -0
  140. package/contentClientState.test.js +404 -0
  141. package/contentClientState.test.js.map +1 -0
  142. package/contentEntry/ContentEntryBindingsResolver.d.ts +33 -0
  143. package/contentEntry/ContentEntryBindingsResolver.js +52 -0
  144. package/contentEntry/ContentEntryBindingsResolver.js.map +1 -0
  145. package/contentEntry/ContentEntryCache.d.ts +49 -0
  146. package/contentEntry/ContentEntryCache.js +51 -0
  147. package/contentEntry/ContentEntryCache.js.map +1 -0
  148. package/contentEntry/resolveContentEntry.d.ts +74 -0
  149. package/contentEntry/resolveContentEntry.js +53 -0
  150. package/contentEntry/resolveContentEntry.js.map +1 -0
  151. package/contentEntry/resolveContentEntry.test.d.ts +1 -0
  152. package/contentEntry/resolveContentEntry.test.js +213 -0
  153. package/contentEntry/resolveContentEntry.test.js.map +1 -0
  154. package/createComponent.d.ts +5 -0
  155. package/createComponent.js +32 -0
  156. package/createComponent.js.map +1 -0
  157. package/createContentClient.d.ts +17 -0
  158. package/createContentClient.js +16 -0
  159. package/createContentClient.js.map +1 -0
  160. package/createContentClient.test.d.ts +1 -0
  161. package/createContentClient.test.js +165 -0
  162. package/createContentClient.test.js.map +1 -0
  163. package/createGlobalElementDocument.d.ts +6 -0
  164. package/createGlobalElementDocument.js +23 -0
  165. package/createGlobalElementDocument.js.map +1 -0
  166. package/createInput.d.ts +10 -2
  167. package/createInput.js +8 -1
  168. package/createInput.js.map +1 -1
  169. package/dataProviders/ApiClient.d.ts +6 -1
  170. package/dataProviders/ApiClient.js +27 -7
  171. package/dataProviders/ApiClient.js.map +1 -1
  172. package/dataProviders/ApiClient.test.d.ts +1 -0
  173. package/dataProviders/ApiClient.test.js +116 -0
  174. package/dataProviders/ApiClient.test.js.map +1 -0
  175. package/dataProviders/DefaultDataProvider.d.ts +6 -1
  176. package/dataProviders/DefaultDataProvider.js +47 -0
  177. package/dataProviders/DefaultDataProvider.js.map +1 -1
  178. package/dataProviders/DefaultDataProvider.test.d.ts +1 -0
  179. package/dataProviders/DefaultDataProvider.test.js +81 -0
  180. package/dataProviders/DefaultDataProvider.test.js.map +1 -0
  181. package/dataProviders/GET_EXPERIMENT_PAUSED.d.ts +1 -0
  182. package/dataProviders/GET_EXPERIMENT_PAUSED.js +17 -0
  183. package/dataProviders/GET_EXPERIMENT_PAUSED.js.map +1 -0
  184. package/dataProviders/GET_LAYOUT_BY_SLUG.d.ts +1 -0
  185. package/dataProviders/GET_LAYOUT_BY_SLUG.js +27 -0
  186. package/dataProviders/GET_LAYOUT_BY_SLUG.js.map +1 -0
  187. package/dataProviders/GET_PAGE_BY_ID.d.ts +1 -1
  188. package/dataProviders/GET_PAGE_BY_ID.js +7 -0
  189. package/dataProviders/GET_PAGE_BY_ID.js.map +1 -1
  190. package/dataProviders/GET_PAGE_BY_PATH.d.ts +1 -1
  191. package/dataProviders/GET_PAGE_BY_PATH.js +7 -0
  192. package/dataProviders/GET_PAGE_BY_PATH.js.map +1 -1
  193. package/dataProviders/GET_PAGE_EXPERIMENT.d.ts +1 -0
  194. package/dataProviders/GET_PAGE_EXPERIMENT.js +32 -0
  195. package/dataProviders/GET_PAGE_EXPERIMENT.js.map +1 -0
  196. package/dataProviders/GET_VARIANT_CONTENT.d.ts +1 -0
  197. package/dataProviders/GET_VARIANT_CONTENT.js +24 -0
  198. package/dataProviders/GET_VARIANT_CONTENT.js.map +1 -0
  199. package/dataProviders/NullDataProvider.d.ts +6 -1
  200. package/dataProviders/NullDataProvider.js +12 -0
  201. package/dataProviders/NullDataProvider.js.map +1 -1
  202. package/dataProviders/queries.test.d.ts +1 -0
  203. package/dataProviders/queries.test.js +53 -0
  204. package/dataProviders/queries.test.js.map +1 -0
  205. package/experiments/PostHogAnalyticsProvider.d.ts +31 -0
  206. package/experiments/PostHogAnalyticsProvider.js +28 -0
  207. package/experiments/PostHogAnalyticsProvider.js.map +1 -0
  208. package/experiments/analyticsProvider.d.ts +4 -0
  209. package/experiments/analyticsProvider.js +11 -0
  210. package/experiments/analyticsProvider.js.map +1 -0
  211. package/experiments/bucketing.d.ts +27 -0
  212. package/experiments/bucketing.js +91 -0
  213. package/experiments/bucketing.js.map +1 -0
  214. package/experiments/bucketing.test.d.ts +1 -0
  215. package/experiments/bucketing.test.js +183 -0
  216. package/experiments/bucketing.test.js.map +1 -0
  217. package/experiments/index.d.ts +5 -0
  218. package/experiments/index.js +5 -0
  219. package/experiments/render.d.ts +82 -0
  220. package/experiments/render.js +149 -0
  221. package/experiments/render.js.map +1 -0
  222. package/experiments/types.d.ts +108 -0
  223. package/experiments/types.js +4 -0
  224. package/experiments/types.js.map +1 -0
  225. package/globalElements.d.ts +43 -0
  226. package/globalElements.js +79 -0
  227. package/globalElements.js.map +1 -0
  228. package/globalElements.test.d.ts +1 -0
  229. package/globalElements.test.js +343 -0
  230. package/globalElements.test.js.map +1 -0
  231. package/headersProvider.d.ts +1 -2
  232. package/headersProvider.js.map +1 -1
  233. package/image/geometry.d.ts +54 -0
  234. package/image/geometry.js +112 -0
  235. package/image/geometry.js.map +1 -0
  236. package/image/geometry.test.d.ts +1 -0
  237. package/image/geometry.test.js +190 -0
  238. package/image/geometry.test.js.map +1 -0
  239. package/image/index.d.ts +3 -0
  240. package/image/index.js +3 -0
  241. package/image/presets.d.ts +6 -0
  242. package/image/presets.js +20 -0
  243. package/image/presets.js.map +1 -0
  244. package/image/types.d.ts +10 -0
  245. package/image/types.js +0 -0
  246. package/index.d.ts +19 -0
  247. package/index.js +19 -0
  248. package/messages.d.ts +3 -0
  249. package/messages.js +4 -1
  250. package/messages.js.map +1 -1
  251. package/package.json +10 -9
  252. package/radioOptionInputs.d.ts +24 -0
  253. package/radioOptionInputs.js +26 -0
  254. package/radioOptionInputs.js.map +1 -0
  255. package/types/WebsiteBuilderTheme.d.ts +5 -0
  256. package/types.d.ts +164 -7
  257. package/withGlobalElementDefaults.d.ts +8 -0
  258. package/withGlobalElementDefaults.js +60 -0
  259. package/withGlobalElementDefaults.js.map +1 -0
@@ -0,0 +1,24 @@
1
+ import { type InputAstNode } from "./ComponentManifestToAstConverter.js";
2
+ /**
3
+ * Whether the node is a radio whose options carry inputs, i.e. an object node with a `value` child
4
+ * (see `ComponentManifestToAstConverter`).
5
+ */
6
+ export declare function hasRadioOptionInputs(node: InputAstNode): boolean;
7
+ /**
8
+ * The child node that stores the selected option of a radio with option inputs.
9
+ */
10
+ export declare function getRadioValueNode(node: InputAstNode): InputAstNode | undefined;
11
+ /**
12
+ * The selected option of a radio with option inputs: the stored `value` of the radio object, or its default.
13
+ * Pass the radio's value resolved for the active breakpoint (the renderer's `value`), so a breakpoint
14
+ * override of the selection is shown.
15
+ */
16
+ export declare function getSelectedRadioValue(node: InputAstNode, radioValue: Record<string, unknown> | undefined): string | undefined;
17
+ /**
18
+ * The nodes of one option's inputs, with that option's definitions, at the radio's shared paths.
19
+ */
20
+ export declare function getRadioOptionNodes(node: InputAstNode, optionValue: string | undefined): InputAstNode[];
21
+ /**
22
+ * The radio object's next value with another option selected; the option inputs keep their values.
23
+ */
24
+ export declare function withRadioValue(current: Record<string, unknown> | undefined, optionValue: string): Record<string, unknown>;
@@ -0,0 +1,26 @@
1
+ import { ComponentManifestToAstConverter, RADIO_VALUE_INPUT } from "./ComponentManifestToAstConverter.js";
2
+ function hasRadioOptionInputs(node) {
3
+ return "radio" === node.input.type && "object" === node.type;
4
+ }
5
+ function getRadioValueNode(node) {
6
+ return node.children.find((child)=>child.name === RADIO_VALUE_INPUT);
7
+ }
8
+ function getSelectedRadioValue(node, radioValue) {
9
+ const valueNode = getRadioValueNode(node);
10
+ if (!valueNode) return;
11
+ const stored = radioValue?.[RADIO_VALUE_INPUT];
12
+ return stored ?? valueNode.input.defaultValue;
13
+ }
14
+ function getRadioOptionNodes(node, optionValue) {
15
+ if (void 0 === optionValue) return [];
16
+ return ComponentManifestToAstConverter.convertRadioOptionInputs(node, optionValue);
17
+ }
18
+ function withRadioValue(current, optionValue) {
19
+ return {
20
+ ...current,
21
+ [RADIO_VALUE_INPUT]: optionValue
22
+ };
23
+ }
24
+ export { getRadioOptionNodes, getRadioValueNode, getSelectedRadioValue, hasRadioOptionInputs, withRadioValue };
25
+
26
+ //# sourceMappingURL=radioOptionInputs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"radioOptionInputs.js","sources":["../src/radioOptionInputs.ts"],"sourcesContent":["import {\n ComponentManifestToAstConverter,\n RADIO_VALUE_INPUT,\n type InputAstNode\n} from \"./ComponentManifestToAstConverter.js\";\n\n/**\n * Whether the node is a radio whose options carry inputs, i.e. an object node with a `value` child\n * (see `ComponentManifestToAstConverter`).\n */\nexport function hasRadioOptionInputs(node: InputAstNode): boolean {\n return node.input.type === \"radio\" && node.type === \"object\";\n}\n\n/**\n * The child node that stores the selected option of a radio with option inputs.\n */\nexport function getRadioValueNode(node: InputAstNode): InputAstNode | undefined {\n return node.children.find(child => child.name === RADIO_VALUE_INPUT);\n}\n\n/**\n * The selected option of a radio with option inputs: the stored `value` of the radio object, or its default.\n * Pass the radio's value resolved for the active breakpoint (the renderer's `value`), so a breakpoint\n * override of the selection is shown.\n */\nexport function getSelectedRadioValue(\n node: InputAstNode,\n radioValue: Record<string, unknown> | undefined\n): string | undefined {\n const valueNode = getRadioValueNode(node);\n if (!valueNode) {\n return undefined;\n }\n const stored = radioValue?.[RADIO_VALUE_INPUT];\n return (stored ?? valueNode.input.defaultValue) as string | undefined;\n}\n\n/**\n * The nodes of one option's inputs, with that option's definitions, at the radio's shared paths.\n */\nexport function getRadioOptionNodes(node: InputAstNode, optionValue: string | undefined) {\n if (optionValue === undefined) {\n return [];\n }\n return ComponentManifestToAstConverter.convertRadioOptionInputs(node, optionValue);\n}\n\n/**\n * The radio object's next value with another option selected; the option inputs keep their values.\n */\nexport function withRadioValue(\n current: Record<string, unknown> | undefined,\n optionValue: string\n): Record<string, unknown> {\n return { ...current, [RADIO_VALUE_INPUT]: optionValue };\n}\n"],"names":["hasRadioOptionInputs","node","getRadioValueNode","child","RADIO_VALUE_INPUT","getSelectedRadioValue","radioValue","valueNode","stored","getRadioOptionNodes","optionValue","undefined","ComponentManifestToAstConverter","withRadioValue","current"],"mappings":";AAUO,SAASA,qBAAqBC,IAAkB;IACnD,OAAOA,AAAoB,YAApBA,KAAK,KAAK,CAAC,IAAI,IAAgBA,AAAc,aAAdA,KAAK,IAAI;AACnD;AAKO,SAASC,kBAAkBD,IAAkB;IAChD,OAAOA,KAAK,QAAQ,CAAC,IAAI,CAACE,CAAAA,QAASA,MAAM,IAAI,KAAKC;AACtD;AAOO,SAASC,sBACZJ,IAAkB,EAClBK,UAA+C;IAE/C,MAAMC,YAAYL,kBAAkBD;IACpC,IAAI,CAACM,WACD;IAEJ,MAAMC,SAASF,YAAY,CAACF,kBAAkB;IAC9C,OAAQI,UAAUD,UAAU,KAAK,CAAC,YAAY;AAClD;AAKO,SAASE,oBAAoBR,IAAkB,EAAES,WAA+B;IACnF,IAAIA,AAAgBC,WAAhBD,aACA,OAAO,EAAE;IAEb,OAAOE,gCAAgC,wBAAwB,CAACX,MAAMS;AAC1E;AAKO,SAASG,eACZC,OAA4C,EAC5CJ,WAAmB;IAEnB,OAAO;QAAE,GAAGI,OAAO;QAAE,CAACV,kBAAkB,EAAEM;IAAY;AAC1D"}
@@ -13,6 +13,7 @@ export type WebsiteBuilderTheme = {
13
13
  colors: ColorStyle[];
14
14
  fontSizes?: FontSizes;
15
15
  typography: Typography;
16
+ allowCustomColors?: boolean;
16
17
  };
17
18
  type KnownKeys = "desktop" | "tablet" | "mobile";
18
19
  type BreakpointBase = Omit<Breakpoint, "name">;
@@ -92,5 +93,9 @@ export type WebsiteBuilderThemeInput = {
92
93
  * ]
93
94
  */
94
95
  typography?: Typography;
96
+ /**
97
+ * Allow custom color selection (ChromePicker) in the Lexical editor's font color toolbar action.
98
+ */
99
+ allowCustomColors?: boolean;
95
100
  };
96
101
  export {};
package/types.d.ts CHANGED
@@ -3,6 +3,7 @@ import type { BindingsApi } from "./BindingsApi.js";
3
3
  import type { ShorthandCssProperties } from "./types/ShorthandCssProperties.js";
4
4
  import type { InputFactory } from "./createInput.js";
5
5
  import type { Breakpoint } from "./types/WebsiteBuilderTheme.js";
6
+ import type { ActiveExperiment, VariantContent } from "./experiments/types.js";
6
7
  export type { WebsiteBuilderTheme, Breakpoint } from "./types/WebsiteBuilderTheme.js";
7
8
  type CSSProperties = CSS.Properties<string | number>;
8
9
  export type ElementMap = Record<string, DocumentElement>;
@@ -196,8 +197,14 @@ export type ComponentManifest = {
196
197
  canDelete?: boolean | ComponentConstraint;
197
198
  acceptsChildren?: boolean;
198
199
  hideFromToolbar?: boolean;
200
+ /**
201
+ * A global component has exactly one instance per site, stored outside of pages.
202
+ * The frontend layout decides where it renders, via `<GlobalComponent>`.
203
+ */
204
+ global?: boolean;
199
205
  hideStyleSettings?: string[];
200
206
  autoApplyStyles?: boolean;
207
+ applyDefaultStyles?: boolean;
201
208
  tags: string[];
202
209
  constraints?: ComponentConstraint[];
203
210
  descendantConstraints?: ComponentConstraint[];
@@ -231,6 +238,7 @@ export type DocumentElement = {
231
238
  export type SerializableCSSStyleDeclaration = {
232
239
  [K in keyof CssProperties]?: CssProperties[K];
233
240
  };
241
+ export type DocumentCache = Record<string, unknown>;
234
242
  export type Document = {
235
243
  id: string;
236
244
  state: DocumentState;
@@ -240,10 +248,54 @@ export type Document = {
240
248
  metadata: DocumentMetadata;
241
249
  bindings: DocumentBindings;
242
250
  elements: ElementMap;
251
+ layout?: PageLayout | null;
252
+ previewPage?: PreviewPage | null;
253
+ __cache?: DocumentCache;
243
254
  };
244
- export type PublicPage = Pick<Page, "id" | "version" | "properties" | "bindings" | "elements" | "extensions" | "metadata" | "state"> & {
255
+ /**
256
+ * A page shown inside a layout in the layout editor, in place of its page content placeholder.
257
+ * It's only shown: it's never saved with the layout.
258
+ */
259
+ export type PreviewPage = Pick<Document, "id" | "properties" | "elements" | "bindings">;
260
+ /**
261
+ * A page layout built in the layout editor: elements placed around one `Webiny/LayoutContent` element
262
+ * (main content), where the page renders its own content, and any `Webiny/NamedContent` areas. Global components are placed in it like on a page, by placement
263
+ * elements: their instances (`$global:{name}`) come with the page. Its bindings may also hold overrides of
264
+ * global components, under their element ids.
265
+ */
266
+ export type PageLayout = Pick<Document, "elements" | "bindings"> & {
267
+ id: string;
268
+ entryId?: string;
269
+ properties?: Record<string, any>;
270
+ };
271
+ /**
272
+ * Elements and bindings of global components, keyed `$global:{componentName}` (plus anything nested inside).
273
+ * Pages are delivered with the stored global components merged into their own elements and bindings.
274
+ */
275
+ export type GlobalDocument = Pick<Document, "elements" | "bindings">;
276
+ /**
277
+ * The stored instance of one global component in one language. Each global component is stored as its
278
+ * own record per language.
279
+ */
280
+ export type GlobalComponentRecord = GlobalDocument & {
281
+ name: string;
282
+ language: string;
283
+ };
284
+ export type PublicPage = Pick<Page, "id" | "version" | "properties" | "bindings" | "elements" | "extensions" | "metadata" | "state" | "layout"> & {
245
285
  languagePaths: Record<string, string>;
246
286
  };
287
+ /**
288
+ * A layout delivered by slug, for content code renders in it (e.g. a CMS entry): composed like a page with no
289
+ * content of its own. `elements` and `bindings` hold the instances of the global components, in the requested
290
+ * language, and `layout` is the layout itself, whose Main content is where the content goes.
291
+ */
292
+ export type PublicLayout = Pick<Document, "elements" | "bindings"> & {
293
+ layout: PageLayout;
294
+ };
295
+ export interface GetLayoutParams {
296
+ slug: string;
297
+ language?: string | null;
298
+ }
247
299
  export type PublicRedirect = {
248
300
  id: string;
249
301
  from: string;
@@ -277,6 +329,7 @@ export type Page = Document & {
277
329
  path: string;
278
330
  language?: string;
279
331
  sourcePage?: string;
332
+ layout?: string | null;
280
333
  tags: string[];
281
334
  seo: {
282
335
  title: string;
@@ -350,6 +403,7 @@ export type EditorViewportData = {
350
403
  export type PreviewViewportData = {
351
404
  boxes: BoxesData;
352
405
  viewport: PreviewViewportInfo;
406
+ layout: string[];
353
407
  };
354
408
  export type ApiOptions = Record<string, any>;
355
409
  export type GetPageOptions = ApiOptions;
@@ -372,7 +426,11 @@ export interface ListPagesResult {
372
426
  export interface IDataProvider {
373
427
  getPageByPath(path: string, options?: GetPageOptions): Promise<PublicPage | null>;
374
428
  getPageById(id: string, options?: GetPageOptions): Promise<PublicPage | null>;
429
+ getLayoutBySlug(params: GetLayoutParams): Promise<PublicLayout | null>;
375
430
  listPages(options?: ListPagesOptions): Promise<ListPagesResult>;
431
+ getPageExperiment(path: string): Promise<ActiveExperiment | null>;
432
+ getVariantContent(variantId: string): Promise<VariantContent | null>;
433
+ getExperimentPaused(experimentId: string): Promise<boolean>;
376
434
  }
377
435
  export interface IEnvironment {
378
436
  isClient(): boolean;
@@ -381,8 +439,27 @@ export interface IEnvironment {
381
439
  }
382
440
  export interface IContentSdk {
383
441
  getPage(path: string): Promise<PublicPage | null>;
442
+ getLayout(params: GetLayoutParams): Promise<PublicLayout | null>;
384
443
  listPages(options?: ListPagesOptions): Promise<ListPagesResult>;
385
444
  }
445
+ /**
446
+ * An input's renderer with settings for it. The settings belong to the named renderer: Webiny passes
447
+ * them to it untouched (`ElementInputRendererProps.settings`) and never reads them itself. `name` is
448
+ * required, so an input factory that spreads the author's input over its default renderer can't end
449
+ * up with settings and no renderer.
450
+ */
451
+ export type InputRendererConfig = {
452
+ name: string;
453
+ settings?: Record<string, any>;
454
+ };
455
+ /**
456
+ * The renderer as the editor resolves it (`InputAstNode.renderer`): always an object, `name` is `""`
457
+ * when the input names no renderer, `settings` is `{}` when it has none.
458
+ */
459
+ export type ResolvedInputRenderer = {
460
+ name: string;
461
+ settings: Record<string, any>;
462
+ };
386
463
  export type BaseInput<T = any> = {
387
464
  name: string;
388
465
  type: string;
@@ -396,7 +473,11 @@ export type BaseInput<T = any> = {
396
473
  responsive?: boolean;
397
474
  required?: boolean;
398
475
  hideFromUi?: boolean;
399
- renderer?: string;
476
+ /**
477
+ * The editor's renderer for this input: its name, or `{ name, settings }` to give the renderer
478
+ * settings (e.g. `{ name: "Webiny/Textarea", settings: { maxLength: 54 } }`).
479
+ */
480
+ renderer?: string | InputRendererConfig;
400
481
  list?: boolean;
401
482
  translatable?: boolean;
402
483
  };
@@ -441,12 +522,88 @@ export type SelectInput = BaseInput<string> & {
441
522
  }[];
442
523
  showResetAction?: boolean;
443
524
  };
525
+ /**
526
+ * A radio option. `image` is a URL or a data URI, for renderers that draw options as pictures.
527
+ * `inputs` are shown while the option is selected. When any option has `inputs`, the radio is
528
+ * stored as an object: `<radio>/value` holds the selected option, and the options' inputs are its
529
+ * other children, merged by name (see `ComponentManifestToAstConverter`).
530
+ */
531
+ export type RadioOption = {
532
+ value: string;
533
+ label?: string;
534
+ description?: string;
535
+ image?: string;
536
+ inputs?: ComponentInput[];
537
+ };
444
538
  export type RadioInput = BaseInput<string> & {
445
539
  type: "radio";
446
- options: {
447
- label: string;
448
- value: string;
449
- }[];
540
+ options: RadioOption[];
541
+ };
542
+ export interface ContentEntryReference {
543
+ id: string;
544
+ modelId: string;
545
+ }
546
+ /**
547
+ * Query-mode configuration, declared by the component author. The editor then
548
+ * builds a query within these bounds (see `ContentEntryQueryValue`).
549
+ */
550
+ /**
551
+ * A field the editor may sort by: a bare read-API sort key, or a key paired with
552
+ * a display label shown in the editor.
553
+ */
554
+ export type ContentEntrySortField = string | {
555
+ field: string;
556
+ label?: string;
557
+ };
558
+ export interface ContentEntryQueryConfig {
559
+ /**
560
+ * Fields the editor may sort by (one at a time). Each `field` is a CMS read-API
561
+ * sort key — value fields as `values_<fieldId>` (e.g. `values_title`), meta
562
+ * fields bare (e.g. `createdOn`). Provide a `label` for a friendlier UI; a bare
563
+ * string uses the key as its label.
564
+ */
565
+ sort?: {
566
+ fields: ContentEntrySortField[];
567
+ };
568
+ /** Editor-configurable result limit, with an optional default and hard cap. */
569
+ limit?: {
570
+ default?: number;
571
+ max?: number;
572
+ };
573
+ /** Show a free-text search box (matches fullTextSearch-enabled fields). */
574
+ search?: boolean;
575
+ /** Enable "load more" pagination in the rendered component. */
576
+ pagination?: boolean;
577
+ }
578
+ /**
579
+ * The value stored for a query-mode input: the editor's chosen query.
580
+ * `modelId` identifies the CMS model so the frontend SDK can resolve the
581
+ * query without component manifests.
582
+ */
583
+ export interface ContentEntryQueryValue {
584
+ modelId: string;
585
+ sort?: {
586
+ field: string;
587
+ order: "asc" | "desc";
588
+ };
589
+ limit?: number;
590
+ search?: string;
591
+ }
592
+ export type ContentEntryInput = BaseInput<ContentEntryReference | ContentEntryReference[] | ContentEntryQueryValue> & {
593
+ type: "contentEntry";
594
+ /**
595
+ * The content model(s) the editor may pick entries from. Author-fixed.
596
+ */
597
+ models: string[];
598
+ /**
599
+ * "manual" (default): the editor hand-picks entries (stored as references).
600
+ * "query": the editor configures a dynamic query on the fixed model.
601
+ */
602
+ mode?: "manual" | "query";
603
+ /**
604
+ * Query-mode configuration. Only used when `mode` is "query".
605
+ */
606
+ query?: ContentEntryQueryConfig;
450
607
  };
451
608
  export type ObjectInput = BaseInput<Record<string, any>> & {
452
609
  type: "object";
@@ -456,7 +613,7 @@ export type CustomInput = BaseInput<any> & {
456
613
  type: string;
457
614
  fields: ComponentInput[];
458
615
  };
459
- export type ComponentInput = TextInput | LongTextInput | NumberInput | BooleanInput | ColorInput | FileInput | DateTimeInput | LexicalInput | SelectInput | RadioInput | TagsInput | ObjectInput | SlotInput | CustomInput;
616
+ export type ComponentInput = TextInput | LongTextInput | NumberInput | BooleanInput | ColorInput | FileInput | DateTimeInput | LexicalInput | SelectInput | RadioInput | TagsInput | ObjectInput | SlotInput | ContentEntryInput | CustomInput;
460
617
  export type ManifestInputsArray<TInputs, TAllowChildren extends boolean> = TAllowChildren extends true ? {
461
618
  [K in Exclude<keyof TInputs, "children">]: InputFactory<K & string>;
462
619
  }[Exclude<keyof TInputs, "children">][] : {
@@ -0,0 +1,8 @@
1
+ import type { ComponentManifest, GlobalDocument } from "./types.js";
2
+ /**
3
+ * Add a default instance for every registered global component that has no stored instance,
4
+ * so a global defined in code appears immediately, without a data backfill.
5
+ * The page may still come with bindings for such a global: the layout's and the page's overrides, merged by
6
+ * the backend. They're kept over the defaults.
7
+ */
8
+ export declare const withGlobalElementDefaults: (globals: GlobalDocument, components: Record<string, ComponentManifest>) => GlobalDocument;
@@ -0,0 +1,60 @@
1
+ import { GlobalElementId } from "./globalElements.js";
2
+ import { createGlobalElementDocument } from "./createGlobalElementDocument.js";
3
+ const withGlobalElementDefaults = (globals, components)=>{
4
+ const missing = Object.values(components).filter((manifest)=>manifest.global && !globals.elements[GlobalElementId.fromName(manifest.name).toString()]);
5
+ if (!missing.length) return globals;
6
+ const result = {
7
+ elements: {
8
+ ...globals.elements
9
+ },
10
+ bindings: {
11
+ ...globals.bindings
12
+ }
13
+ };
14
+ for (const manifest of missing){
15
+ const defaults = createGlobalElementDocument(manifest.name, components);
16
+ Object.assign(result.elements, defaults.elements);
17
+ for(const id in defaults.bindings){
18
+ const delivered = globals.bindings[id];
19
+ result.bindings[id] = delivered ? withDefaultBindings(defaults.bindings[id], delivered) : defaults.bindings[id];
20
+ }
21
+ }
22
+ return result;
23
+ };
24
+ const withDefaultBindings = (defaults, delivered)=>{
25
+ const overrides = {
26
+ ...defaults.overrides
27
+ };
28
+ for(const breakpoint in delivered.overrides){
29
+ const base = defaults.overrides?.[breakpoint];
30
+ const value = delivered.overrides[breakpoint];
31
+ overrides[breakpoint] = {
32
+ ...base,
33
+ ...value,
34
+ inputs: {
35
+ ...base?.inputs,
36
+ ...value?.inputs
37
+ },
38
+ styles: {
39
+ ...base?.styles,
40
+ ...value?.styles
41
+ }
42
+ };
43
+ }
44
+ return {
45
+ ...defaults,
46
+ ...delivered,
47
+ inputs: {
48
+ ...defaults.inputs,
49
+ ...delivered.inputs
50
+ },
51
+ styles: {
52
+ ...defaults.styles,
53
+ ...delivered.styles
54
+ },
55
+ overrides
56
+ };
57
+ };
58
+ export { withGlobalElementDefaults };
59
+
60
+ //# sourceMappingURL=withGlobalElementDefaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withGlobalElementDefaults.js","sources":["../src/withGlobalElementDefaults.ts"],"sourcesContent":["import type { ComponentManifest, DocumentElementBindings, GlobalDocument } from \"./types.js\";\nimport { GlobalElementId } from \"./globalElements.js\";\nimport { createGlobalElementDocument } from \"./createGlobalElementDocument.js\";\n\n/**\n * Add a default instance for every registered global component that has no stored instance,\n * so a global defined in code appears immediately, without a data backfill.\n * The page may still come with bindings for such a global: the layout's and the page's overrides, merged by\n * the backend. They're kept over the defaults.\n */\nexport const withGlobalElementDefaults = (\n globals: GlobalDocument,\n components: Record<string, ComponentManifest>\n): GlobalDocument => {\n const missing = Object.values(components).filter(manifest => {\n return (\n manifest.global && !globals.elements[GlobalElementId.fromName(manifest.name).toString()]\n );\n });\n\n if (!missing.length) {\n return globals;\n }\n\n const result: GlobalDocument = {\n elements: { ...globals.elements },\n bindings: { ...globals.bindings }\n };\n\n for (const manifest of missing) {\n const defaults = createGlobalElementDocument(manifest.name, components);\n Object.assign(result.elements, defaults.elements);\n for (const id in defaults.bindings) {\n const delivered = globals.bindings[id];\n result.bindings[id] = delivered\n ? withDefaultBindings(defaults.bindings[id], delivered)\n : defaults.bindings[id];\n }\n }\n\n return result;\n};\n\n/**\n * The defaults are only the bottom layer: what's delivered wins per input and per style, also per\n * breakpoint override, so overriding one input of a global keeps the rest of its defaults.\n */\nconst withDefaultBindings = (\n defaults: DocumentElementBindings,\n delivered: DocumentElementBindings\n): DocumentElementBindings => {\n const overrides: NonNullable<DocumentElementBindings[\"overrides\"]> = {\n ...defaults.overrides\n };\n for (const breakpoint in delivered.overrides) {\n const base = defaults.overrides?.[breakpoint];\n const value = delivered.overrides[breakpoint];\n overrides[breakpoint] = {\n ...base,\n ...value,\n inputs: { ...base?.inputs, ...value?.inputs },\n styles: { ...base?.styles, ...value?.styles }\n };\n }\n\n return {\n ...defaults,\n ...delivered,\n inputs: { ...defaults.inputs, ...delivered.inputs },\n styles: { ...defaults.styles, ...delivered.styles },\n overrides\n };\n};\n"],"names":["withGlobalElementDefaults","globals","components","missing","Object","manifest","GlobalElementId","result","defaults","createGlobalElementDocument","id","delivered","withDefaultBindings","overrides","breakpoint","base","value"],"mappings":";;AAUO,MAAMA,4BAA4B,CACrCC,SACAC;IAEA,MAAMC,UAAUC,OAAO,MAAM,CAACF,YAAY,MAAM,CAACG,CAAAA,WAEzCA,SAAS,MAAM,IAAI,CAACJ,QAAQ,QAAQ,CAACK,gBAAgB,QAAQ,CAACD,SAAS,IAAI,EAAE,QAAQ,GAAG;IAIhG,IAAI,CAACF,QAAQ,MAAM,EACf,OAAOF;IAGX,MAAMM,SAAyB;QAC3B,UAAU;YAAE,GAAGN,QAAQ,QAAQ;QAAC;QAChC,UAAU;YAAE,GAAGA,QAAQ,QAAQ;QAAC;IACpC;IAEA,KAAK,MAAMI,YAAYF,QAAS;QAC5B,MAAMK,WAAWC,4BAA4BJ,SAAS,IAAI,EAAEH;QAC5DE,OAAO,MAAM,CAACG,OAAO,QAAQ,EAAEC,SAAS,QAAQ;QAChD,IAAK,MAAME,MAAMF,SAAS,QAAQ,CAAE;YAChC,MAAMG,YAAYV,QAAQ,QAAQ,CAACS,GAAG;YACtCH,OAAO,QAAQ,CAACG,GAAG,GAAGC,YAChBC,oBAAoBJ,SAAS,QAAQ,CAACE,GAAG,EAAEC,aAC3CH,SAAS,QAAQ,CAACE,GAAG;QAC/B;IACJ;IAEA,OAAOH;AACX;AAMA,MAAMK,sBAAsB,CACxBJ,UACAG;IAEA,MAAME,YAA+D;QACjE,GAAGL,SAAS,SAAS;IACzB;IACA,IAAK,MAAMM,cAAcH,UAAU,SAAS,CAAE;QAC1C,MAAMI,OAAOP,SAAS,SAAS,EAAE,CAACM,WAAW;QAC7C,MAAME,QAAQL,UAAU,SAAS,CAACG,WAAW;QAC7CD,SAAS,CAACC,WAAW,GAAG;YACpB,GAAGC,IAAI;YACP,GAAGC,KAAK;YACR,QAAQ;gBAAE,GAAGD,MAAM,MAAM;gBAAE,GAAGC,OAAO,MAAM;YAAC;YAC5C,QAAQ;gBAAE,GAAGD,MAAM,MAAM;gBAAE,GAAGC,OAAO,MAAM;YAAC;QAChD;IACJ;IAEA,OAAO;QACH,GAAGR,QAAQ;QACX,GAAGG,SAAS;QACZ,QAAQ;YAAE,GAAGH,SAAS,MAAM;YAAE,GAAGG,UAAU,MAAM;QAAC;QAClD,QAAQ;YAAE,GAAGH,SAAS,MAAM;YAAE,GAAGG,UAAU,MAAM;QAAC;QAClDE;IACJ;AACJ"}