@webiny/website-builder-react 0.0.0-unstable.e0bfc55d5a → 0.0.0-unstable.e1999482d0

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 (186) hide show
  1. package/README.md +10 -2
  2. package/components/ConnectToEditor.d.ts +3 -1
  3. package/components/ConnectToEditor.js +21 -21
  4. package/components/ConnectToEditor.js.map +1 -1
  5. package/components/ContentClientContext.d.ts +3 -0
  6. package/components/ContentClientContext.js +6 -0
  7. package/components/ContentClientContext.js.map +1 -0
  8. package/components/ContentClientProvider.d.ts +12 -0
  9. package/components/ContentClientProvider.js +9 -0
  10. package/components/ContentClientProvider.js.map +1 -0
  11. package/components/ContentClientProvider.test.d.ts +1 -0
  12. package/components/ContentClientProvider.test.js +143 -0
  13. package/components/ContentClientProvider.test.js.map +1 -0
  14. package/components/DocumentFragment.d.ts +10 -3
  15. package/components/DocumentFragment.js +5 -6
  16. package/components/DocumentFragment.js.map +1 -1
  17. package/components/DocumentRenderer.d.ts +8 -3
  18. package/components/DocumentRenderer.js +55 -43
  19. package/components/DocumentRenderer.js.map +1 -1
  20. package/components/DocumentStoreProvider.d.ts +8 -1
  21. package/components/DocumentStoreProvider.js +35 -22
  22. package/components/DocumentStoreProvider.js.map +1 -1
  23. package/components/DocumentStoreProvider.test.d.ts +1 -0
  24. package/components/DocumentStoreProvider.test.js +66 -0
  25. package/components/DocumentStoreProvider.test.js.map +1 -0
  26. package/components/EditingElementRenderer/EditingElementRenderer.d.ts +7 -2
  27. package/components/EditingElementRenderer/EditingElementRenderer.js +48 -40
  28. package/components/EditingElementRenderer/EditingElementRenderer.js.map +1 -1
  29. package/components/EditingElementRenderer/EditingElementRenderer.presenter.d.ts +2 -2
  30. package/components/EditingElementRenderer/EditingElementRenderer.presenter.js +31 -36
  31. package/components/EditingElementRenderer/EditingElementRenderer.presenter.js.map +1 -1
  32. package/components/EditingElementRenderer/index.js +0 -2
  33. package/components/ElementIndexProvider.js +9 -14
  34. package/components/ElementIndexProvider.js.map +1 -1
  35. package/components/ElementRenderer.d.ts +2 -2
  36. package/components/ElementRenderer.js +25 -17
  37. package/components/ElementRenderer.js.map +1 -1
  38. package/components/ElementSlot.js +11 -11
  39. package/components/ElementSlot.js.map +1 -1
  40. package/components/ElementSlotDepthProvider.js +9 -14
  41. package/components/ElementSlotDepthProvider.js.map +1 -1
  42. package/components/FragmentsProvider.d.ts +10 -1
  43. package/components/FragmentsProvider.js +33 -25
  44. package/components/FragmentsProvider.js.map +1 -1
  45. package/components/GlobalComponent.d.ts +10 -0
  46. package/components/GlobalComponent.js +17 -0
  47. package/components/GlobalComponent.js.map +1 -0
  48. package/components/GlobalPlacement.d.ts +11 -0
  49. package/components/GlobalPlacement.js +27 -0
  50. package/components/GlobalPlacement.js.map +1 -0
  51. package/components/LayoutAreas.d.ts +19 -0
  52. package/components/LayoutAreas.js +15 -0
  53. package/components/LayoutAreas.js.map +1 -0
  54. package/components/LayoutRenderer.d.ts +14 -0
  55. package/components/LayoutRenderer.js +60 -0
  56. package/components/LayoutRenderer.js.map +1 -0
  57. package/components/LayoutRenderer.test.d.ts +1 -0
  58. package/components/LayoutRenderer.test.js +138 -0
  59. package/components/LayoutRenderer.test.js.map +1 -0
  60. package/components/LiveElementRenderer.d.ts +2 -2
  61. package/components/LiveElementRenderer.js +64 -73
  62. package/components/LiveElementRenderer.js.map +1 -1
  63. package/components/LiveElementSlot.d.ts +1 -1
  64. package/components/LiveElementSlot.js +15 -17
  65. package/components/LiveElementSlot.js.map +1 -1
  66. package/components/PageLayout.d.ts +40 -0
  67. package/components/PageLayout.js +71 -0
  68. package/components/PageLayout.js.map +1 -0
  69. package/components/PreviewElementSlot.js +29 -25
  70. package/components/PreviewElementSlot.js.map +1 -1
  71. package/components/SlotLabel.d.ts +15 -0
  72. package/components/SlotLabel.js +13 -0
  73. package/components/SlotLabel.js.map +1 -0
  74. package/components/index.d.ts +7 -0
  75. package/components/index.js +6 -2
  76. package/components/renderWithLayout.d.ts +5 -0
  77. package/components/renderWithLayout.js +7 -0
  78. package/components/renderWithLayout.js.map +1 -0
  79. package/components/useBindingsForElement.d.ts +203 -69
  80. package/components/useBindingsForElement.js +16 -14
  81. package/components/useBindingsForElement.js.map +1 -1
  82. package/components/useContentClient.d.ts +6 -0
  83. package/components/useContentClient.js +11 -0
  84. package/components/useContentClient.js.map +1 -0
  85. package/components/useDocumentState.d.ts +1 -1
  86. package/components/useDocumentState.js +7 -5
  87. package/components/useDocumentState.js.map +1 -1
  88. package/components/useIsElementSelected.d.ts +8 -0
  89. package/components/useIsElementSelected.js +22 -0
  90. package/components/useIsElementSelected.js.map +1 -0
  91. package/components/useSeededDocumentStore.d.ts +10 -0
  92. package/components/useSeededDocumentStore.js +22 -0
  93. package/components/useSeededDocumentStore.js.map +1 -0
  94. package/components/useSelectFromState.d.ts +2 -2
  95. package/components/useSelectFromState.js +29 -35
  96. package/components/useSelectFromState.js.map +1 -1
  97. package/components/useSelectFromState.test.d.ts +1 -0
  98. package/components/useSelectFromState.test.js +67 -0
  99. package/components/useSelectFromState.test.js.map +1 -0
  100. package/components/useViewportInfo.js +5 -6
  101. package/components/useViewportInfo.js.map +1 -1
  102. package/contentEntry/useContentEntryList.d.ts +22 -0
  103. package/contentEntry/useContentEntryList.js +51 -0
  104. package/contentEntry/useContentEntryList.js.map +1 -0
  105. package/createComponent.d.ts +1 -2
  106. package/createComponent.js +1 -16
  107. package/createComponent.test.d.ts +1 -0
  108. package/createComponent.test.js +118 -0
  109. package/createComponent.test.js.map +1 -0
  110. package/editorComponents/Box.d.ts +1 -1
  111. package/editorComponents/Box.js +3 -6
  112. package/editorComponents/Box.js.map +1 -1
  113. package/editorComponents/Box.manifest.d.ts +1 -1
  114. package/editorComponents/Box.manifest.js +17 -16
  115. package/editorComponents/Box.manifest.js.map +1 -1
  116. package/editorComponents/Fragment.d.ts +2 -2
  117. package/editorComponents/Fragment.js +24 -27
  118. package/editorComponents/Fragment.js.map +1 -1
  119. package/editorComponents/Fragment.manifest.js +16 -13
  120. package/editorComponents/Fragment.manifest.js.map +1 -1
  121. package/editorComponents/Grid.d.ts +3 -2
  122. package/editorComponents/Grid.js +34 -61
  123. package/editorComponents/Grid.js.map +1 -1
  124. package/editorComponents/Grid.manifest.d.ts +0 -1
  125. package/editorComponents/Grid.manifest.js +165 -168
  126. package/editorComponents/Grid.manifest.js.map +1 -1
  127. package/editorComponents/GridColumn.d.ts +1 -1
  128. package/editorComponents/GridColumn.js +3 -6
  129. package/editorComponents/GridColumn.js.map +1 -1
  130. package/editorComponents/GridColumn.manifest.js +22 -19
  131. package/editorComponents/GridColumn.manifest.js.map +1 -1
  132. package/editorComponents/Image.d.ts +2 -2
  133. package/editorComponents/Image.js +99 -119
  134. package/editorComponents/Image.js.map +1 -1
  135. package/editorComponents/Image.manifest.js +35 -33
  136. package/editorComponents/Image.manifest.js.map +1 -1
  137. package/editorComponents/LayoutContent.d.ts +6 -0
  138. package/editorComponents/LayoutContent.js +121 -0
  139. package/editorComponents/LayoutContent.js.map +1 -0
  140. package/editorComponents/LayoutContent.manifest.d.ts +10 -0
  141. package/editorComponents/LayoutContent.manifest.js +32 -0
  142. package/editorComponents/LayoutContent.manifest.js.map +1 -0
  143. package/editorComponents/LayoutContentLabel.d.ts +2 -0
  144. package/editorComponents/LayoutContentLabel.js +7 -0
  145. package/editorComponents/LayoutContentLabel.js.map +1 -0
  146. package/editorComponents/LayoutContentLabel.test.d.ts +1 -0
  147. package/editorComponents/LayoutContentLabel.test.js +23 -0
  148. package/editorComponents/LayoutContentLabel.test.js.map +1 -0
  149. package/editorComponents/Lexical.d.ts +3 -3
  150. package/editorComponents/Lexical.js +13 -25
  151. package/editorComponents/Lexical.js.map +1 -1
  152. package/editorComponents/Lexical.manifest.js +19 -16
  153. package/editorComponents/Lexical.manifest.js.map +1 -1
  154. package/editorComponents/Root.d.ts +1 -1
  155. package/editorComponents/Root.js +3 -6
  156. package/editorComponents/Root.js.map +1 -1
  157. package/editorComponents/Root.manifest.d.ts +1 -1
  158. package/editorComponents/Root.manifest.js +9 -8
  159. package/editorComponents/Root.manifest.js.map +1 -1
  160. package/editorComponents/index.d.ts +1 -1
  161. package/editorComponents/index.js +15 -3
  162. package/editorComponents/index.js.map +1 -1
  163. package/image/BackgroundImage.d.ts +33 -0
  164. package/image/BackgroundImage.js +61 -0
  165. package/image/BackgroundImage.js.map +1 -0
  166. package/image/Image.d.ts +29 -0
  167. package/image/Image.js +43 -0
  168. package/image/Image.js.map +1 -0
  169. package/image/getImageProps.d.ts +42 -0
  170. package/image/getImageProps.js +18 -0
  171. package/image/getImageProps.js.map +1 -0
  172. package/image/getImageProps.test.d.ts +1 -0
  173. package/image/getImageProps.test.js +70 -0
  174. package/image/getImageProps.test.js.map +1 -0
  175. package/image/index.d.ts +3 -0
  176. package/image/index.js +3 -0
  177. package/index.d.ts +4 -3
  178. package/index.js +2 -4
  179. package/package.json +19 -19
  180. package/types.d.ts +40 -2
  181. package/types.js +0 -3
  182. package/components/EditingElementRenderer/index.js.map +0 -1
  183. package/components/index.js.map +0 -1
  184. package/createComponent.js.map +0 -1
  185. package/index.js.map +0 -1
  186. package/types.js.map +0 -1
@@ -0,0 +1,23 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { LayoutContentArea } from "@webiny/website-builder-sdk";
3
+ import { getContentAreaLabel } from "./LayoutContentLabel.js";
4
+ const LayoutContentLabel_test_element = (id, name)=>({
5
+ id,
6
+ component: {
7
+ name
8
+ }
9
+ });
10
+ describe("getContentAreaLabel", ()=>{
11
+ it('labels the main content area "Main content", and a named one by its own name, with no "Named content ·" prefix', ()=>{
12
+ const main = LayoutContentArea.fromElement(LayoutContentLabel_test_element("content", "Webiny/LayoutContent"));
13
+ const named = LayoutContentArea.fromElement(LayoutContentLabel_test_element("sidebar", "Webiny/NamedContent"), "sidebar");
14
+ expect(getContentAreaLabel(main)).toBe("Main content");
15
+ expect(getContentAreaLabel(named)).toBe("sidebar");
16
+ });
17
+ it('labels a named content area without a name "Named content"', ()=>{
18
+ const area = LayoutContentArea.fromElement(LayoutContentLabel_test_element("area", "Webiny/NamedContent"), " ");
19
+ expect(getContentAreaLabel(area)).toBe("Named content");
20
+ });
21
+ });
22
+
23
+ //# sourceMappingURL=LayoutContentLabel.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editorComponents/LayoutContentLabel.test.js","sources":["../../src/editorComponents/LayoutContentLabel.test.ts"],"sourcesContent":["import { describe, it, expect } from \"vitest\";\nimport { LayoutContentArea } from \"@webiny/website-builder-sdk\";\nimport { getContentAreaLabel } from \"./LayoutContentLabel.js\";\n\nconst element = (id: string, name: string) => ({ id, component: { name } });\n\ndescribe(\"getContentAreaLabel\", () => {\n it('labels the main content area \"Main content\", and a named one by its own name, with no \"Named content ·\" prefix', () => {\n const main = LayoutContentArea.fromElement(element(\"content\", \"Webiny/LayoutContent\"));\n const named = LayoutContentArea.fromElement(\n element(\"sidebar\", \"Webiny/NamedContent\"),\n \"sidebar\"\n );\n\n expect(getContentAreaLabel(main)).toBe(\"Main content\");\n expect(getContentAreaLabel(named)).toBe(\"sidebar\");\n });\n\n it('labels a named content area without a name \"Named content\"', () => {\n const area = LayoutContentArea.fromElement(element(\"area\", \"Webiny/NamedContent\"), \" \");\n\n expect(getContentAreaLabel(area)).toBe(\"Named content\");\n });\n});\n"],"names":["element","id","name","describe","it","main","LayoutContentArea","named","expect","getContentAreaLabel","area"],"mappings":";;;AAIA,MAAMA,kCAAU,CAACC,IAAYC,OAAkB;QAAED;QAAI,WAAW;YAAEC;QAAK;IAAE;AAEzEC,SAAS,uBAAuB;IAC5BC,GAAG,kHAAkH;QACjH,MAAMC,OAAOC,kBAAkB,WAAW,CAACN,gCAAQ,WAAW;QAC9D,MAAMO,QAAQD,kBAAkB,WAAW,CACvCN,gCAAQ,WAAW,wBACnB;QAGJQ,OAAOC,oBAAoBJ,OAAO,IAAI,CAAC;QACvCG,OAAOC,oBAAoBF,QAAQ,IAAI,CAAC;IAC5C;IAEAH,GAAG,8DAA8D;QAC7D,MAAMM,OAAOJ,kBAAkB,WAAW,CAACN,gCAAQ,QAAQ,wBAAwB;QAEnFQ,OAAOC,oBAAoBC,OAAO,IAAI,CAAC;IAC3C;AACJ"}
@@ -1,13 +1,13 @@
1
1
  import React from "react";
2
- import type { ComponentProps } from "../types";
2
+ import type { ComponentProps } from "../types.js";
3
3
  export declare const createLexicalValue: (value: string) => {
4
4
  state: string;
5
+ html: string;
5
6
  };
6
7
  type LexicalProps = ComponentProps<{
7
8
  content: {
8
- state: string;
9
9
  html?: string;
10
10
  };
11
11
  }>;
12
- export declare const LexicalComponent: ({ inputs }: LexicalProps) => React.JSX.Element;
12
+ export declare const LexicalComponent: ({ inputs }: LexicalProps) => React.JSX.Element | null;
13
13
  export {};
@@ -1,30 +1,18 @@
1
1
  "use client";
2
-
3
- import React from "react";
4
- import { LexicalHtmlRenderer } from "@webiny/lexical-editor";
5
- export const createLexicalValue = value => {
6
- return {
7
- state: `{"root":{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"${value}","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph-element","version":1,"textFormat":0,"textStyle":""}],"direction":"ltr","format":"","indent":0,"type":"root","version":1}}`
8
- };
9
- };
10
- export const LexicalComponent = ({
11
- inputs
12
- }) => {
13
- const {
14
- state,
15
- html
16
- } = inputs.content;
17
- if (html) {
18
- return /*#__PURE__*/React.createElement("div", {
19
- dangerouslySetInnerHTML: {
20
- __html: html
21
- }
2
+ import react from "react";
3
+ const createLexicalValue = (value)=>({
4
+ state: `{"root":{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"${value}","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"wby-paragraph","version":1,"textFormat":0,"textStyle":""}],"direction":"ltr","format":"","indent":0,"type":"root","version":1}}`,
5
+ html: `<p class="wb-paragraph-1">${value}</p>`
6
+ });
7
+ const LexicalComponent = ({ inputs })=>{
8
+ const { html } = inputs.content;
9
+ if (html) return /*#__PURE__*/ react.createElement("div", {
10
+ dangerouslySetInnerHTML: {
11
+ __html: html
12
+ }
22
13
  });
23
- }
24
- return /*#__PURE__*/React.createElement(LexicalHtmlRenderer, {
25
- value: state,
26
- theme: {}
27
- });
14
+ return null;
28
15
  };
16
+ export { LexicalComponent, createLexicalValue };
29
17
 
30
18
  //# sourceMappingURL=Lexical.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","LexicalHtmlRenderer","createLexicalValue","value","state","LexicalComponent","inputs","html","content","createElement","dangerouslySetInnerHTML","__html","theme"],"sources":["Lexical.tsx"],"sourcesContent":["\"use client\";\nimport React from \"react\";\nimport { LexicalHtmlRenderer } from \"@webiny/lexical-editor\";\nimport type { ComponentProps } from \"~/types\";\n\nexport const createLexicalValue = (value: string) => {\n return {\n state: `{\"root\":{\"children\":[{\"children\":[{\"detail\":0,\"format\":0,\"mode\":\"normal\",\"style\":\"\",\"text\":\"${value}\",\"type\":\"text\",\"version\":1}],\"direction\":\"ltr\",\"format\":\"\",\"indent\":0,\"type\":\"paragraph-element\",\"version\":1,\"textFormat\":0,\"textStyle\":\"\"}],\"direction\":\"ltr\",\"format\":\"\",\"indent\":0,\"type\":\"root\",\"version\":1}}`\n };\n};\n\ntype LexicalProps = ComponentProps<{\n content: {\n state: string;\n html?: string;\n };\n}>;\n\nexport const LexicalComponent = ({ inputs }: LexicalProps) => {\n const { state, html } = inputs.content;\n\n if (html) {\n return <div dangerouslySetInnerHTML={{ __html: html }}></div>;\n }\n\n return <LexicalHtmlRenderer value={state} theme={{}} />;\n};\n"],"mappings":"AAAA,YAAY;;AACZ,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,mBAAmB,QAAQ,wBAAwB;AAG5D,OAAO,MAAMC,kBAAkB,GAAIC,KAAa,IAAK;EACjD,OAAO;IACHC,KAAK,EAAE,+FAA+FD,KAAK;EAC/G,CAAC;AACL,CAAC;AASD,OAAO,MAAME,gBAAgB,GAAGA,CAAC;EAAEC;AAAqB,CAAC,KAAK;EAC1D,MAAM;IAAEF,KAAK;IAAEG;EAAK,CAAC,GAAGD,MAAM,CAACE,OAAO;EAEtC,IAAID,IAAI,EAAE;IACN,oBAAOP,KAAA,CAAAS,aAAA;MAAKC,uBAAuB,EAAE;QAAEC,MAAM,EAAEJ;MAAK;IAAE,CAAM,CAAC;EACjE;EAEA,oBAAOP,KAAA,CAAAS,aAAA,CAACR,mBAAmB;IAACE,KAAK,EAAEC,KAAM;IAACQ,KAAK,EAAE,CAAC;EAAE,CAAE,CAAC;AAC3D,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"editorComponents/Lexical.js","sources":["../../src/editorComponents/Lexical.tsx"],"sourcesContent":["\"use client\";\nimport React from \"react\";\nimport type { ComponentProps } from \"~/types.js\";\n\nexport const createLexicalValue = (value: string) => {\n return {\n state: `{\"root\":{\"children\":[{\"children\":[{\"detail\":0,\"format\":0,\"mode\":\"normal\",\"style\":\"\",\"text\":\"${value}\",\"type\":\"text\",\"version\":1}],\"direction\":\"ltr\",\"format\":\"\",\"indent\":0,\"type\":\"wby-paragraph\",\"version\":1,\"textFormat\":0,\"textStyle\":\"\"}],\"direction\":\"ltr\",\"format\":\"\",\"indent\":0,\"type\":\"root\",\"version\":1}}`,\n html: `<p class=\"wb-paragraph-1\">${value}</p>`\n };\n};\n\ntype LexicalProps = ComponentProps<{\n content: {\n html?: string;\n };\n}>;\n\nexport const LexicalComponent = ({ inputs }: LexicalProps) => {\n const { html } = inputs.content;\n\n if (html) {\n return <div dangerouslySetInnerHTML={{ __html: html }}></div>;\n }\n\n return null;\n};\n"],"names":["createLexicalValue","value","LexicalComponent","inputs","html"],"mappings":";;AAIO,MAAMA,qBAAqB,CAACC,QACxB;QACH,OAAO,CAAC,4FAA4F,EAAEA,MAAM,8MAA8M,CAAC;QAC3T,MAAM,CAAC,0BAA0B,EAAEA,MAAM,IAAI,CAAC;IAClD;AASG,MAAMC,mBAAmB,CAAC,EAAEC,MAAM,EAAgB;IACrD,MAAM,EAAEC,IAAI,EAAE,GAAGD,OAAO,OAAO;IAE/B,IAAIC,MACA,OAAO,WAAP,GAAO,oBAAC;QAAI,yBAAyB;YAAE,QAAQA;QAAK;;IAGxD,OAAO;AACX"}
@@ -1,22 +1,25 @@
1
1
  "use client";
2
-
3
2
  import { createLexicalInput } from "@webiny/website-builder-sdk";
4
- import { createComponent } from "../createComponent";
5
- import { LexicalComponent, createLexicalValue } from "./Lexical";
6
- export const Lexical = createComponent(LexicalComponent, {
7
- name: "Webiny/Lexical",
8
- label: "Rich Text",
9
- group: "basic",
10
- image: `<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px"><path d="M280-160v-520H80v-120h520v120H400v520H280Zm360 0v-320H520v-120h360v120H760v320H640Z"/></svg>`,
11
- inputs: [createLexicalInput({
12
- name: "content",
13
- label: "Content"
14
- })],
15
- defaults: {
16
- inputs: {
17
- content: createLexicalValue("Examine she brother prudent add day ham. Far stairs now coming bed oppose hunted become his. You zealously departure had procuring suspicion. Books whose front would purse if be do decay. Quitting you way formerly disposed perceive ladyship are. Common turned boy direct and yet.")
3
+ import { createComponent } from "../createComponent.js";
4
+ import { LexicalComponent, createLexicalValue } from "./Lexical.js";
5
+ const Lexical = createComponent(LexicalComponent, {
6
+ name: "Webiny/Lexical",
7
+ label: "Rich Text",
8
+ aiContext: "Rich text content. Generate semantic HTML tags. Do NOT generate markdown.",
9
+ group: "basic",
10
+ image: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"/><path d="M14 17H7v-2h7v2zm3-4H7v-2h10v2zm0-4H7V7h10v2z"/></svg>',
11
+ inputs: [
12
+ createLexicalInput({
13
+ name: "content",
14
+ label: "Content"
15
+ })
16
+ ],
17
+ defaults: {
18
+ inputs: {
19
+ content: createLexicalValue("Examine she brother prudent add day ham. Far stairs now coming bed oppose hunted become his. You zealously departure had procuring suspicion. Books whose front would purse if be do decay. Quitting you way formerly disposed perceive ladyship are. Common turned boy direct and yet.")
20
+ }
18
21
  }
19
- }
20
22
  });
23
+ export { Lexical };
21
24
 
22
25
  //# sourceMappingURL=Lexical.manifest.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createLexicalInput","createComponent","LexicalComponent","createLexicalValue","Lexical","name","label","group","image","inputs","defaults","content"],"sources":["Lexical.manifest.ts"],"sourcesContent":["\"use client\";\nimport { createLexicalInput } from \"@webiny/website-builder-sdk\";\nimport { createComponent } from \"~/createComponent\";\nimport { LexicalComponent, createLexicalValue } from \"./Lexical\";\n\nexport const Lexical = createComponent(LexicalComponent, {\n name: \"Webiny/Lexical\",\n label: \"Rich Text\",\n group: \"basic\",\n image: `<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\"><path d=\"M280-160v-520H80v-120h520v120H400v520H280Zm360 0v-320H520v-120h360v120H760v320H640Z\"/></svg>`,\n inputs: [\n createLexicalInput({\n name: \"content\",\n label: \"Content\"\n })\n ],\n defaults: {\n inputs: {\n content: createLexicalValue(\n \"Examine she brother prudent add day ham. Far stairs now coming bed oppose hunted become his. You zealously departure had procuring suspicion. Books whose front would purse if be do decay. Quitting you way formerly disposed perceive ladyship are. Common turned boy direct and yet.\"\n )\n }\n }\n});\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,kBAAkB,QAAQ,6BAA6B;AAChE,SAASC,eAAe;AACxB,SAASC,gBAAgB,EAAEC,kBAAkB;AAE7C,OAAO,MAAMC,OAAO,GAAGH,eAAe,CAACC,gBAAgB,EAAE;EACrDG,IAAI,EAAE,gBAAgB;EACtBC,KAAK,EAAE,WAAW;EAClBC,KAAK,EAAE,OAAO;EACdC,KAAK,EAAE,mMAAmM;EAC1MC,MAAM,EAAE,CACJT,kBAAkB,CAAC;IACfK,IAAI,EAAE,SAAS;IACfC,KAAK,EAAE;EACX,CAAC,CAAC,CACL;EACDI,QAAQ,EAAE;IACND,MAAM,EAAE;MACJE,OAAO,EAAER,kBAAkB,CACvB,yRACJ;IACJ;EACJ;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"editorComponents/Lexical.manifest.js","sources":["../../src/editorComponents/Lexical.manifest.ts"],"sourcesContent":["\"use client\";\nimport { createLexicalInput } from \"@webiny/website-builder-sdk\";\nimport { createComponent } from \"~/createComponent.js\";\nimport { LexicalComponent, createLexicalValue } from \"./Lexical.js\";\n\nexport const Lexical = createComponent(LexicalComponent, {\n name: \"Webiny/Lexical\",\n label: \"Rich Text\",\n aiContext: \"Rich text content. Generate semantic HTML tags. Do NOT generate markdown.\",\n group: \"basic\",\n image: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z\"/><path d=\"M14 17H7v-2h7v2zm3-4H7v-2h10v2zm0-4H7V7h10v2z\"/></svg>`,\n inputs: [\n createLexicalInput({\n name: \"content\",\n label: \"Content\"\n })\n ],\n defaults: {\n inputs: {\n content: createLexicalValue(\n \"Examine she brother prudent add day ham. Far stairs now coming bed oppose hunted become his. You zealously departure had procuring suspicion. Books whose front would purse if be do decay. Quitting you way formerly disposed perceive ladyship are. Common turned boy direct and yet.\"\n )\n }\n }\n});\n"],"names":["Lexical","createComponent","LexicalComponent","createLexicalInput","createLexicalValue"],"mappings":";;;;AAKO,MAAMA,UAAUC,gBAAgBC,kBAAkB;IACrD,MAAM;IACN,OAAO;IACP,WAAW;IACX,OAAO;IACP,OAAO;IACP,QAAQ;QACJC,mBAAmB;YACf,MAAM;YACN,OAAO;QACX;KACH;IACD,UAAU;QACN,QAAQ;YACJ,SAASC,mBACL;QAER;IACJ;AACJ"}
@@ -1,3 +1,3 @@
1
1
  import React from "react";
2
- import type { ComponentPropsWithChildren } from "../types";
2
+ import type { ComponentPropsWithChildren } from "../types.js";
3
3
  export declare const RootComponent: ({ inputs }: ComponentPropsWithChildren) => React.JSX.Element;
@@ -1,8 +1,5 @@
1
- import React from "react";
2
- export const RootComponent = ({
3
- inputs
4
- }) => {
5
- return /*#__PURE__*/React.createElement(React.Fragment, null, inputs.children);
6
- };
1
+ import react from "react";
2
+ const RootComponent = ({ inputs })=>/*#__PURE__*/ react.createElement(react.Fragment, null, inputs.children);
3
+ export { RootComponent };
7
4
 
8
5
  //# sourceMappingURL=Root.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","RootComponent","inputs","createElement","Fragment","children"],"sources":["Root.tsx"],"sourcesContent":["import React from \"react\";\nimport type { ComponentPropsWithChildren } from \"~/types\";\n\nexport const RootComponent = ({ inputs }: ComponentPropsWithChildren) => {\n return <>{inputs.children}</>;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAGzB,OAAO,MAAMC,aAAa,GAAGA,CAAC;EAAEC;AAAmC,CAAC,KAAK;EACrE,oBAAOF,KAAA,CAAAG,aAAA,CAAAH,KAAA,CAAAI,QAAA,QAAGF,MAAM,CAACG,QAAW,CAAC;AACjC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"editorComponents/Root.js","sources":["../../src/editorComponents/Root.tsx"],"sourcesContent":["import React from \"react\";\nimport type { ComponentPropsWithChildren } from \"~/types.js\";\n\nexport const RootComponent = ({ inputs }: ComponentPropsWithChildren) => {\n return <>{inputs.children}</>;\n};\n"],"names":["RootComponent","inputs"],"mappings":";AAGO,MAAMA,gBAAgB,CAAC,EAAEC,MAAM,EAA8B,GACzD,WAAP,GAAO,0CAAGA,OAAO,QAAQ"}
@@ -1 +1 @@
1
- export declare const Root: import("@webiny/website-builder-sdk").Component;
1
+ export declare const Root: import("@webiny/website-builder-sdk/types.js").Component;
@@ -1,12 +1,13 @@
1
1
  "use client";
2
-
3
- import { createComponent } from "../createComponent";
4
- import { RootComponent } from "./Root";
5
- export const Root = createComponent(RootComponent, {
6
- name: "Webiny/Root",
7
- label: "Main Content",
8
- acceptsChildren: true,
9
- hideFromToolbar: true
2
+ import { createComponent } from "../createComponent.js";
3
+ import { RootComponent } from "./Root.js";
4
+ const Root = createComponent(RootComponent, {
5
+ name: "Webiny/Root",
6
+ label: "Main Content",
7
+ acceptsChildren: true,
8
+ hideFromToolbar: true,
9
+ useInAiContentGeneration: false
10
10
  });
11
+ export { Root };
11
12
 
12
13
  //# sourceMappingURL=Root.manifest.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createComponent","RootComponent","Root","name","label","acceptsChildren","hideFromToolbar"],"sources":["Root.manifest.ts"],"sourcesContent":["\"use client\";\nimport { createComponent } from \"~/createComponent\";\nimport { RootComponent } from \"./Root\";\n\nexport const Root = createComponent(RootComponent, {\n name: \"Webiny/Root\",\n label: \"Main Content\",\n acceptsChildren: true,\n hideFromToolbar: true\n});\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe;AACxB,SAASC,aAAa;AAEtB,OAAO,MAAMC,IAAI,GAAGF,eAAe,CAACC,aAAa,EAAE;EAC/CE,IAAI,EAAE,aAAa;EACnBC,KAAK,EAAE,cAAc;EACrBC,eAAe,EAAE,IAAI;EACrBC,eAAe,EAAE;AACrB,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"editorComponents/Root.manifest.js","sources":["../../src/editorComponents/Root.manifest.ts"],"sourcesContent":["\"use client\";\nimport { createComponent } from \"~/createComponent.js\";\nimport { RootComponent } from \"./Root.js\";\n\nexport const Root = createComponent(RootComponent, {\n name: \"Webiny/Root\",\n label: \"Main Content\",\n acceptsChildren: true,\n hideFromToolbar: true,\n useInAiContentGeneration: false\n});\n"],"names":["Root","createComponent","RootComponent"],"mappings":";;;AAIO,MAAMA,OAAOC,gBAAgBC,eAAe;IAC/C,MAAM;IACN,OAAO;IACP,iBAAiB;IACjB,iBAAiB;IACjB,0BAA0B;AAC9B"}
@@ -1 +1 @@
1
- export declare const editorComponents: import("@webiny/website-builder-sdk").Component[];
1
+ export declare const editorComponents: import("@webiny/website-builder-sdk/types.js").Component[];
@@ -3,8 +3,20 @@ import { Grid } from "./Grid.manifest.js";
3
3
  import { Image } from "./Image.manifest.js";
4
4
  import { Lexical } from "./Lexical.manifest.js";
5
5
  import { Root } from "./Root.manifest.js";
6
- import { GridColumn } from "./GridColumn.manifest";
7
- import { Fragment } from "./Fragment.manifest";
8
- export const editorComponents = [Root, Box, Grid, GridColumn, Image, Lexical, Fragment];
6
+ import { GridColumn } from "./GridColumn.manifest.js";
7
+ import { Fragment } from "./Fragment.manifest.js";
8
+ import { LayoutContent, NamedContent } from "./LayoutContent.manifest.js";
9
+ const editorComponents = [
10
+ Root,
11
+ Box,
12
+ Grid,
13
+ GridColumn,
14
+ Image,
15
+ Lexical,
16
+ Fragment,
17
+ LayoutContent,
18
+ NamedContent
19
+ ];
20
+ export { editorComponents };
9
21
 
10
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Box","Grid","Image","Lexical","Root","GridColumn","Fragment","editorComponents"],"sources":["index.ts"],"sourcesContent":["import { Box } from \"./Box.manifest.js\";\nimport { Grid } from \"./Grid.manifest.js\";\nimport { Image } from \"./Image.manifest.js\";\nimport { Lexical } from \"./Lexical.manifest.js\";\nimport { Root } from \"./Root.manifest.js\";\nimport { GridColumn } from \"./GridColumn.manifest\";\nimport { Fragment } from \"./Fragment.manifest\";\n\nexport const editorComponents = [Root, Box, Grid, GridColumn, Image, Lexical, Fragment];\n"],"mappings":"AAAA,SAASA,GAAG;AACZ,SAASC,IAAI;AACb,SAASC,KAAK;AACd,SAASC,OAAO;AAChB,SAASC,IAAI;AACb,SAASC,UAAU;AACnB,SAASC,QAAQ;AAEjB,OAAO,MAAMC,gBAAgB,GAAG,CAACH,IAAI,EAAEJ,GAAG,EAAEC,IAAI,EAAEI,UAAU,EAAEH,KAAK,EAAEC,OAAO,EAAEG,QAAQ,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"editorComponents/index.js","sources":["../../src/editorComponents/index.ts"],"sourcesContent":["import { Box } from \"./Box.manifest.js\";\nimport { Grid } from \"./Grid.manifest.js\";\nimport { Image } from \"./Image.manifest.js\";\nimport { Lexical } from \"./Lexical.manifest.js\";\nimport { Root } from \"./Root.manifest.js\";\nimport { GridColumn } from \"./GridColumn.manifest.js\";\nimport { Fragment } from \"./Fragment.manifest.js\";\nimport { LayoutContent, NamedContent } from \"./LayoutContent.manifest.js\";\n\nexport const editorComponents = [\n Root,\n Box,\n Grid,\n GridColumn,\n Image,\n Lexical,\n Fragment,\n LayoutContent,\n NamedContent\n];\n"],"names":["editorComponents","Root","Box","Grid","GridColumn","Image","Lexical","Fragment","LayoutContent","NamedContent"],"mappings":";;;;;;;;AASO,MAAMA,mBAAmB;IAC5BC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;CACH"}
@@ -0,0 +1,33 @@
1
+ import React from "react";
2
+ import { type Asset } from "@webiny/website-builder-sdk";
3
+ export interface BackgroundImageProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "style"> {
4
+ /** The image value (unified `Asset` or a legacy value — both accepted). */
5
+ image: Asset;
6
+ /** Content rendered on top of the background (auto-stacked above the image). */
7
+ children?: React.ReactNode;
8
+ /** Class applied to the wrapper element. */
9
+ className?: string;
10
+ /** Styles merged into the wrapper. Give it a height (e.g. `minHeight`). */
11
+ style?: React.CSSProperties;
12
+ /** Class applied to the background `<img>`. */
13
+ imgClassName?: string;
14
+ /** Explicit alt text; falls back to the image's stored alt. Empty = decorative. */
15
+ alt?: string;
16
+ /** Delivery width requested for the background image. Defaults to 1920. */
17
+ width?: number;
18
+ /**
19
+ * Responsive URL builder — e.g. `({ src, width }) => \`${src}?width=${width}&format=auto\``.
20
+ * When provided, a `srcSet` is generated from `widths`.
21
+ */
22
+ loader?: (params: {
23
+ src: string;
24
+ width: number;
25
+ }) => string;
26
+ /** Candidate widths for the generated `srcSet`. */
27
+ widths?: number[];
28
+ /** The `sizes` attribute (defaults to `100vw`, since backgrounds are usually full-bleed). */
29
+ sizes?: string;
30
+ /** Native loading strategy for the background image. */
31
+ loading?: "eager" | "lazy";
32
+ }
33
+ export declare function BackgroundImage({ image, children, className, style, imgClassName, alt, width, loader, widths, sizes, loading, ...rest }: BackgroundImageProps): React.JSX.Element;
@@ -0,0 +1,61 @@
1
+ import react from "react";
2
+ import { normalizeToAsset } from "@webiny/website-builder-sdk";
3
+ const DEFAULT_WIDTHS = [
4
+ 640,
5
+ 750,
6
+ 828,
7
+ 1080,
8
+ 1200,
9
+ 1920,
10
+ 2048
11
+ ];
12
+ function BackgroundImage({ image, children, className, style, imgClassName, alt, width = 1920, loader, widths = DEFAULT_WIDTHS, sizes = "100vw", loading, ...rest }) {
13
+ const asset = normalizeToAsset(image);
14
+ const src = asset?.src ?? "";
15
+ const focalPoint = asset?.image?.focalPoint ?? {
16
+ x: 0.5,
17
+ y: 0.5
18
+ };
19
+ const resolvedAlt = alt ?? asset?.image?.alt ?? "";
20
+ const resolvedSrc = loader ? loader({
21
+ src,
22
+ width
23
+ }) : src;
24
+ const srcSet = loader ? widths.map((w)=>`${loader({
25
+ src,
26
+ width: w
27
+ })} ${w}w`).join(", ") || void 0 : void 0;
28
+ return /*#__PURE__*/ react.createElement("div", {
29
+ ...rest,
30
+ className: className,
31
+ style: {
32
+ position: "relative",
33
+ overflow: "hidden",
34
+ ...style
35
+ }
36
+ }, /*#__PURE__*/ react.createElement("img", {
37
+ className: imgClassName,
38
+ src: resolvedSrc,
39
+ srcSet: srcSet,
40
+ sizes: srcSet ? sizes : void 0,
41
+ alt: resolvedAlt,
42
+ "aria-hidden": "" === resolvedAlt ? true : void 0,
43
+ loading: loading,
44
+ style: {
45
+ position: "absolute",
46
+ inset: 0,
47
+ width: "100%",
48
+ height: "100%",
49
+ objectFit: "cover",
50
+ objectPosition: `${100 * focalPoint.x}% ${100 * focalPoint.y}%`
51
+ }
52
+ }), null != children ? /*#__PURE__*/ react.createElement("div", {
53
+ style: {
54
+ position: "relative",
55
+ zIndex: 1
56
+ }
57
+ }, children) : null);
58
+ }
59
+ export { BackgroundImage };
60
+
61
+ //# sourceMappingURL=BackgroundImage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image/BackgroundImage.js","sources":["../../src/image/BackgroundImage.tsx"],"sourcesContent":["import React from \"react\";\nimport { normalizeToAsset, type Asset } from \"@webiny/website-builder-sdk\";\n\nexport interface BackgroundImageProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"style\"> {\n /** The image value (unified `Asset` or a legacy value — both accepted). */\n image: Asset;\n /** Content rendered on top of the background (auto-stacked above the image). */\n children?: React.ReactNode;\n /** Class applied to the wrapper element. */\n className?: string;\n /** Styles merged into the wrapper. Give it a height (e.g. `minHeight`). */\n style?: React.CSSProperties;\n /** Class applied to the background `<img>`. */\n imgClassName?: string;\n /** Explicit alt text; falls back to the image's stored alt. Empty = decorative. */\n alt?: string;\n /** Delivery width requested for the background image. Defaults to 1920. */\n width?: number;\n /**\n * Responsive URL builder — e.g. `({ src, width }) => \\`${src}?width=${width}&format=auto\\``.\n * When provided, a `srcSet` is generated from `widths`.\n */\n loader?: (params: { src: string; width: number }) => string;\n /** Candidate widths for the generated `srcSet`. */\n widths?: number[];\n /** The `sizes` attribute (defaults to `100vw`, since backgrounds are usually full-bleed). */\n sizes?: string;\n /** Native loading strategy for the background image. */\n loading?: \"eager\" | \"lazy\";\n}\n\nconst DEFAULT_WIDTHS = [640, 750, 828, 1080, 1200, 1920, 2048];\n\nexport function BackgroundImage({\n image,\n children,\n className,\n style,\n imgClassName,\n alt,\n width = 1920,\n loader,\n widths = DEFAULT_WIDTHS,\n sizes = \"100vw\",\n loading,\n ...rest\n}: BackgroundImageProps) {\n const asset = normalizeToAsset(image);\n const src = asset?.src ?? \"\";\n const focalPoint = asset?.image?.focalPoint ?? { x: 0.5, y: 0.5 };\n const resolvedAlt = alt ?? asset?.image?.alt ?? \"\";\n\n const resolvedSrc = loader ? loader({ src, width }) : src;\n const srcSet = loader\n ? widths.map(w => `${loader({ src, width: w })} ${w}w`).join(\", \") || undefined\n : undefined;\n\n return (\n <div\n {...rest}\n className={className}\n style={{ position: \"relative\", overflow: \"hidden\", ...style }}\n >\n <img\n className={imgClassName}\n src={resolvedSrc}\n srcSet={srcSet}\n sizes={srcSet ? sizes : undefined}\n alt={resolvedAlt}\n aria-hidden={resolvedAlt === \"\" ? true : undefined}\n loading={loading}\n style={{\n position: \"absolute\",\n inset: 0,\n width: \"100%\",\n height: \"100%\",\n objectFit: \"cover\",\n objectPosition: `${focalPoint.x * 100}% ${focalPoint.y * 100}%`\n }}\n />\n {children != null ? (\n <div style={{ position: \"relative\", zIndex: 1 }}>{children}</div>\n ) : null}\n </div>\n );\n}\n"],"names":["DEFAULT_WIDTHS","BackgroundImage","image","children","className","style","imgClassName","alt","width","loader","widths","sizes","loading","rest","asset","normalizeToAsset","src","focalPoint","resolvedAlt","resolvedSrc","srcSet","w","undefined"],"mappings":";;AA+BA,MAAMA,iBAAiB;IAAC;IAAK;IAAK;IAAK;IAAM;IAAM;IAAM;CAAK;AAEvD,SAASC,gBAAgB,EAC5BC,KAAK,EACLC,QAAQ,EACRC,SAAS,EACTC,KAAK,EACLC,YAAY,EACZC,GAAG,EACHC,QAAQ,IAAI,EACZC,MAAM,EACNC,SAASV,cAAc,EACvBW,QAAQ,OAAO,EACfC,OAAO,EACP,GAAGC,MACgB;IACnB,MAAMC,QAAQC,iBAAiBb;IAC/B,MAAMc,MAAMF,OAAO,OAAO;IAC1B,MAAMG,aAAaH,OAAO,OAAO,cAAc;QAAE,GAAG;QAAK,GAAG;IAAI;IAChE,MAAMI,cAAcX,OAAOO,OAAO,OAAO,OAAO;IAEhD,MAAMK,cAAcV,SAASA,OAAO;QAAEO;QAAKR;IAAM,KAAKQ;IACtD,MAAMI,SAASX,SACTC,OAAO,GAAG,CAACW,CAAAA,IAAK,GAAGZ,OAAO;YAAEO;YAAK,OAAOK;QAAE,GAAG,CAAC,EAAEA,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,SAASC,SACpEA;IAEN,OAAO,WAAP,GACI,oBAAC;QACI,GAAGT,IAAI;QACR,WAAWT;QACX,OAAO;YAAE,UAAU;YAAY,UAAU;YAAU,GAAGC,KAAK;QAAC;qBAE5D,oBAAC;QACG,WAAWC;QACX,KAAKa;QACL,QAAQC;QACR,OAAOA,SAAST,QAAQW;QACxB,KAAKJ;QACL,eAAaA,AAAgB,OAAhBA,cAAqB,OAAOI;QACzC,SAASV;QACT,OAAO;YACH,UAAU;YACV,OAAO;YACP,OAAO;YACP,QAAQ;YACR,WAAW;YACX,gBAAgB,GAAGK,AAAe,MAAfA,WAAW,CAAC,CAAO,EAAE,EAAEA,AAAe,MAAfA,WAAW,CAAC,CAAO,CAAC,CAAC;QACnE;QAEHd,AAAY,QAAZA,WAAmB,WAAP,GACT,oBAAC;QAAI,OAAO;YAAE,UAAU;YAAY,QAAQ;QAAE;OAAIA,YAClD;AAGhB"}
@@ -0,0 +1,29 @@
1
+ import React from "react";
2
+ import type { AspectRatioInput, Asset } from "@webiny/website-builder-sdk";
3
+ export interface ImageComponentProps extends Omit<React.ImgHTMLAttributes<HTMLImageElement>, "src" | "width" | "height" | "style" | "alt"> {
4
+ image: Asset;
5
+ /** Target aspect ratio (e.g. `16 / 9` or `{ width, height }`). Omit for the crop's own ratio. */
6
+ aspectRatio?: AspectRatioInput;
7
+ /** Explicit alt text; falls back to the image's stored alt. */
8
+ alt?: string;
9
+ /** Class applied to the wrapper element. */
10
+ className?: string;
11
+ /** Class applied to the `<img>` element. */
12
+ imgClassName?: string;
13
+ /** Extra styles merged into the wrapper (e.g. `maxWidth`). */
14
+ style?: React.CSSProperties;
15
+ /**
16
+ * Optional responsive URL builder — e.g. `({ src, width }) => \`${src}?width=${width}\``.
17
+ * When provided, a `srcSet` is generated from `widths`. This is also the seam for a
18
+ * future server/CDN transform (crop params can be appended here).
19
+ */
20
+ loader?: (params: {
21
+ src: string;
22
+ width: number;
23
+ }) => string;
24
+ /** Candidate widths for the generated `srcSet` (defaults to a common set). */
25
+ widths?: number[];
26
+ /** The `sizes` attribute for responsive selection. */
27
+ sizes?: string;
28
+ }
29
+ export declare function Image({ image, aspectRatio, alt, className, imgClassName, style, loader, widths, sizes, ...imgProps }: ImageComponentProps): React.JSX.Element;
package/image/Image.js ADDED
@@ -0,0 +1,43 @@
1
+ import react from "react";
2
+ import { getImageProps } from "./getImageProps.js";
3
+ const DEFAULT_WIDTHS = [
4
+ 640,
5
+ 750,
6
+ 828,
7
+ 1080,
8
+ 1200,
9
+ 1920,
10
+ 2048
11
+ ];
12
+ function Image({ image, aspectRatio, alt, className, imgClassName, style, loader, widths = DEFAULT_WIDTHS, sizes, ...imgProps }) {
13
+ const { style: containerStyle, imgStyle, src, alt: resolvedAlt, width } = getImageProps(image, {
14
+ aspectRatio,
15
+ alt
16
+ });
17
+ const srcSet = loader ? widths.filter((w)=>!width || w <= width).map((w)=>`${loader({
18
+ src,
19
+ width: w
20
+ })} ${w}w`).join(", ") || void 0 : void 0;
21
+ const resolvedSrc = loader ? loader({
22
+ src,
23
+ width: width || widths[widths.length - 1]
24
+ }) : src;
25
+ return /*#__PURE__*/ react.createElement("div", {
26
+ className: className,
27
+ style: {
28
+ ...containerStyle,
29
+ ...style
30
+ }
31
+ }, /*#__PURE__*/ react.createElement("img", {
32
+ ...imgProps,
33
+ className: imgClassName,
34
+ src: resolvedSrc,
35
+ srcSet: srcSet,
36
+ sizes: sizes,
37
+ alt: resolvedAlt,
38
+ style: imgStyle
39
+ }));
40
+ }
41
+ export { Image };
42
+
43
+ //# sourceMappingURL=Image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image/Image.js","sources":["../../src/image/Image.tsx"],"sourcesContent":["import React from \"react\";\nimport type { AspectRatioInput, Asset } from \"@webiny/website-builder-sdk\";\nimport { getImageProps } from \"./getImageProps.js\";\n\nexport interface ImageComponentProps extends Omit<\n React.ImgHTMLAttributes<HTMLImageElement>,\n \"src\" | \"width\" | \"height\" | \"style\" | \"alt\"\n> {\n image: Asset;\n /** Target aspect ratio (e.g. `16 / 9` or `{ width, height }`). Omit for the crop's own ratio. */\n aspectRatio?: AspectRatioInput;\n /** Explicit alt text; falls back to the image's stored alt. */\n alt?: string;\n /** Class applied to the wrapper element. */\n className?: string;\n /** Class applied to the `<img>` element. */\n imgClassName?: string;\n /** Extra styles merged into the wrapper (e.g. `maxWidth`). */\n style?: React.CSSProperties;\n /**\n * Optional responsive URL builder — e.g. `({ src, width }) => \\`${src}?width=${width}\\``.\n * When provided, a `srcSet` is generated from `widths`. This is also the seam for a\n * future server/CDN transform (crop params can be appended here).\n */\n loader?: (params: { src: string; width: number }) => string;\n /** Candidate widths for the generated `srcSet` (defaults to a common set). */\n widths?: number[];\n /** The `sizes` attribute for responsive selection. */\n sizes?: string;\n}\n\nconst DEFAULT_WIDTHS = [640, 750, 828, 1080, 1200, 1920, 2048];\n\nexport function Image({\n image,\n aspectRatio,\n alt,\n className,\n imgClassName,\n style,\n loader,\n widths = DEFAULT_WIDTHS,\n sizes,\n ...imgProps\n}: ImageComponentProps) {\n const {\n style: containerStyle,\n imgStyle,\n src,\n alt: resolvedAlt,\n width\n } = getImageProps(image, { aspectRatio, alt });\n\n const srcSet = loader\n ? widths\n .filter(w => !width || w <= width)\n .map(w => `${loader({ src, width: w })} ${w}w`)\n .join(\", \") || undefined\n : undefined;\n\n const resolvedSrc = loader ? loader({ src, width: width || widths[widths.length - 1] }) : src;\n\n return (\n <div className={className} style={{ ...containerStyle, ...style }}>\n <img\n {...imgProps}\n className={imgClassName}\n src={resolvedSrc}\n srcSet={srcSet}\n sizes={sizes}\n alt={resolvedAlt}\n style={imgStyle}\n />\n </div>\n );\n}\n"],"names":["DEFAULT_WIDTHS","Image","image","aspectRatio","alt","className","imgClassName","style","loader","widths","sizes","imgProps","containerStyle","imgStyle","src","resolvedAlt","width","getImageProps","srcSet","w","undefined","resolvedSrc"],"mappings":";;AA+BA,MAAMA,iBAAiB;IAAC;IAAK;IAAK;IAAK;IAAM;IAAM;IAAM;CAAK;AAEvD,SAASC,MAAM,EAClBC,KAAK,EACLC,WAAW,EACXC,GAAG,EACHC,SAAS,EACTC,YAAY,EACZC,KAAK,EACLC,MAAM,EACNC,SAAST,cAAc,EACvBU,KAAK,EACL,GAAGC,UACe;IAClB,MAAM,EACF,OAAOC,cAAc,EACrBC,QAAQ,EACRC,GAAG,EACH,KAAKC,WAAW,EAChBC,KAAK,EACR,GAAGC,cAAcf,OAAO;QAAEC;QAAaC;IAAI;IAE5C,MAAMc,SAASV,SACTC,OACK,MAAM,CAACU,CAAAA,IAAK,CAACH,SAASG,KAAKH,OAC3B,GAAG,CAACG,CAAAA,IAAK,GAAGX,OAAO;YAAEM;YAAK,OAAOK;QAAE,GAAG,CAAC,EAAEA,EAAE,CAAC,CAAC,EAC7C,IAAI,CAAC,SAASC,SACnBA;IAEN,MAAMC,cAAcb,SAASA,OAAO;QAAEM;QAAK,OAAOE,SAASP,MAAM,CAACA,OAAO,MAAM,GAAG,EAAE;IAAC,KAAKK;IAE1F,OAAO,WAAP,GACI,oBAAC;QAAI,WAAWT;QAAW,OAAO;YAAE,GAAGO,cAAc;YAAE,GAAGL,KAAK;QAAC;qBAC5D,oBAAC;QACI,GAAGI,QAAQ;QACZ,WAAWL;QACX,KAAKe;QACL,QAAQH;QACR,OAAOR;QACP,KAAKK;QACL,OAAOF;;AAIvB"}
@@ -0,0 +1,42 @@
1
+ import type { CSSProperties } from "react";
2
+ import { type AspectRatioInput, type Asset } from "@webiny/website-builder-sdk";
3
+ export interface ImageProps {
4
+ /** Wrapper style: an aspect-ratio box that clips overflow. Spread onto a container. */
5
+ style: CSSProperties;
6
+ /** Image style: absolutely positioned to reveal exactly the cropped/focused region. */
7
+ imgStyle: CSSProperties;
8
+ /** The image URL. */
9
+ src: string;
10
+ /** Resolved alt text (explicit override, else the image's stored alt, else ""). */
11
+ alt: string;
12
+ /** Intrinsic (original) pixel dimensions of the asset. */
13
+ width: number;
14
+ height: number;
15
+ }
16
+ export interface ImageValue {
17
+ id: string;
18
+ name: string;
19
+ size: number;
20
+ mimeType: string;
21
+ src: string;
22
+ width: number;
23
+ height: number;
24
+ }
25
+ export interface GetImagePropsOptions {
26
+ /** Target aspect ratio. Omit to render at the crop's own aspect ratio. */
27
+ aspectRatio?: AspectRatioInput;
28
+ /** Explicit alt text; falls back to the image's stored `image.alt`. */
29
+ alt?: string;
30
+ }
31
+ /**
32
+ * Compute the props needed to render a Webiny image honoring its crop + focal point,
33
+ * using pure CSS (no image backend). Works with a plain `<img>`, SSR, and static
34
+ * export. Spread `style` onto a wrapper element and `imgStyle` onto the `<img>`.
35
+ *
36
+ * Accepts either the unified {@link Asset} shape or a legacy
37
+ * `ImageValue` (existing page snapshots) — both are normalized transparently.
38
+ *
39
+ * This is the escape hatch for custom rendering; most consumers can use the
40
+ * `<Image>` component instead.
41
+ */
42
+ export declare function getImageProps(input: Asset | ImageValue, options?: GetImagePropsOptions): ImageProps;
@@ -0,0 +1,18 @@
1
+ import { getAssetImageRenderData, normalizeToAsset } from "@webiny/website-builder-sdk";
2
+ function getImageProps(input, options = {}) {
3
+ const asset = normalizeToAsset(input);
4
+ const data = getAssetImageRenderData({
5
+ image: asset?.image
6
+ }, options.aspectRatio);
7
+ return {
8
+ style: data.container,
9
+ imgStyle: data.image,
10
+ src: asset?.src ?? "",
11
+ alt: options.alt ?? asset?.image?.alt ?? "",
12
+ width: data.intrinsicWidth,
13
+ height: data.intrinsicHeight
14
+ };
15
+ }
16
+ export { getImageProps };
17
+
18
+ //# sourceMappingURL=getImageProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image/getImageProps.js","sources":["../../src/image/getImageProps.ts"],"sourcesContent":["import type { CSSProperties } from \"react\";\nimport {\n getAssetImageRenderData,\n normalizeToAsset,\n type AspectRatioInput,\n type Asset\n} from \"@webiny/website-builder-sdk\";\n\nexport interface ImageProps {\n /** Wrapper style: an aspect-ratio box that clips overflow. Spread onto a container. */\n style: CSSProperties;\n /** Image style: absolutely positioned to reveal exactly the cropped/focused region. */\n imgStyle: CSSProperties;\n /** The image URL. */\n src: string;\n /** Resolved alt text (explicit override, else the image's stored alt, else \"\"). */\n alt: string;\n /** Intrinsic (original) pixel dimensions of the asset. */\n width: number;\n height: number;\n}\n\nexport interface ImageValue {\n id: string;\n name: string;\n size: number;\n mimeType: string; // not \"type\"\n src: string;\n width: number; // top-level, not nested in image\n height: number; // top-level\n}\n\nexport interface GetImagePropsOptions {\n /** Target aspect ratio. Omit to render at the crop's own aspect ratio. */\n aspectRatio?: AspectRatioInput;\n /** Explicit alt text; falls back to the image's stored `image.alt`. */\n alt?: string;\n}\n\n/**\n * Compute the props needed to render a Webiny image honoring its crop + focal point,\n * using pure CSS (no image backend). Works with a plain `<img>`, SSR, and static\n * export. Spread `style` onto a wrapper element and `imgStyle` onto the `<img>`.\n *\n * Accepts either the unified {@link Asset} shape or a legacy\n * `ImageValue` (existing page snapshots) — both are normalized transparently.\n *\n * This is the escape hatch for custom rendering; most consumers can use the\n * `<Image>` component instead.\n */\nexport function getImageProps(\n input: Asset | ImageValue,\n options: GetImagePropsOptions = {}\n): ImageProps {\n const asset = normalizeToAsset(input);\n const data = getAssetImageRenderData({ image: asset?.image }, options.aspectRatio);\n\n return {\n style: data.container,\n imgStyle: data.image,\n src: asset?.src ?? \"\",\n alt: options.alt ?? asset?.image?.alt ?? \"\",\n width: data.intrinsicWidth,\n height: data.intrinsicHeight\n };\n}\n"],"names":["getImageProps","input","options","asset","normalizeToAsset","data","getAssetImageRenderData"],"mappings":";AAkDO,SAASA,cACZC,KAAyB,EACzBC,UAAgC,CAAC,CAAC;IAElC,MAAMC,QAAQC,iBAAiBH;IAC/B,MAAMI,OAAOC,wBAAwB;QAAE,OAAOH,OAAO;IAAM,GAAGD,QAAQ,WAAW;IAEjF,OAAO;QACH,OAAOG,KAAK,SAAS;QACrB,UAAUA,KAAK,KAAK;QACpB,KAAKF,OAAO,OAAO;QACnB,KAAKD,QAAQ,GAAG,IAAIC,OAAO,OAAO,OAAO;QACzC,OAAOE,KAAK,cAAc;QAC1B,QAAQA,KAAK,eAAe;IAChC;AACJ"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,70 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { getImageProps } from "./getImageProps.js";
3
+ const asset = (overrides = {})=>({
4
+ id: "1",
5
+ name: "photo.jpg",
6
+ size: 1234,
7
+ mimeType: "image/jpeg",
8
+ src: "https://cdn.test/photo.jpg",
9
+ url: "https://cdn.test/photo.jpg",
10
+ image: {
11
+ width: 1600,
12
+ height: 900
13
+ },
14
+ ...overrides
15
+ });
16
+ describe("getImageProps", ()=>{
17
+ it("returns wrapper + image styles and passes through src and dimensions", ()=>{
18
+ const props = getImageProps(asset());
19
+ expect(props.src).toBe("https://cdn.test/photo.jpg");
20
+ expect(props.width).toBe(1600);
21
+ expect(props.height).toBe(900);
22
+ expect(props.style.overflow).toBe("hidden");
23
+ expect(props.style.position).toBe("relative");
24
+ expect(props.imgStyle.position).toBe("absolute");
25
+ });
26
+ it("resolves alt from the explicit option first", ()=>{
27
+ const props = getImageProps(asset({
28
+ image: {
29
+ alt: "stored alt"
30
+ }
31
+ }), {
32
+ alt: "explicit alt"
33
+ });
34
+ expect(props.alt).toBe("explicit alt");
35
+ });
36
+ it("falls back to the image's stored alt", ()=>{
37
+ const props = getImageProps(asset({
38
+ image: {
39
+ alt: "stored alt"
40
+ }
41
+ }));
42
+ expect(props.alt).toBe("stored alt");
43
+ });
44
+ it("defaults alt to an empty string", ()=>{
45
+ expect(getImageProps(asset()).alt).toBe("");
46
+ });
47
+ it("produces a wrapper with the requested aspect ratio", ()=>{
48
+ const props = getImageProps(asset(), {
49
+ aspectRatio: 1
50
+ });
51
+ expect(props.style.aspectRatio).toBe("1");
52
+ });
53
+ it("offsets the image to reveal a focal-point-shifted crop region", ()=>{
54
+ const props = getImageProps(asset({
55
+ image: {
56
+ width: 1600,
57
+ height: 900,
58
+ focalPoint: {
59
+ x: 0.9,
60
+ y: 0.5
61
+ }
62
+ }
63
+ }), {
64
+ aspectRatio: 1
65
+ });
66
+ expect(parseFloat(props.imgStyle.left)).toBeLessThan(0);
67
+ });
68
+ });
69
+
70
+ //# sourceMappingURL=getImageProps.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image/getImageProps.test.js","sources":["../../src/image/getImageProps.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport { getImageProps } from \"./getImageProps.js\";\nimport type { Asset } from \"@webiny/website-builder-sdk\";\n\nconst asset = (overrides: Partial<Asset> = {}): Asset => ({\n id: \"1\",\n name: \"photo.jpg\",\n size: 1234,\n mimeType: \"image/jpeg\",\n src: \"https://cdn.test/photo.jpg\",\n url: \"https://cdn.test/photo.jpg\",\n image: { width: 1600, height: 900 },\n ...overrides\n});\n\ndescribe(\"getImageProps\", () => {\n it(\"returns wrapper + image styles and passes through src and dimensions\", () => {\n const props = getImageProps(asset());\n expect(props.src).toBe(\"https://cdn.test/photo.jpg\");\n expect(props.width).toBe(1600);\n expect(props.height).toBe(900);\n expect(props.style.overflow).toBe(\"hidden\");\n expect(props.style.position).toBe(\"relative\");\n expect(props.imgStyle.position).toBe(\"absolute\");\n });\n\n it(\"resolves alt from the explicit option first\", () => {\n const props = getImageProps(asset({ image: { alt: \"stored alt\" } }), {\n alt: \"explicit alt\"\n });\n expect(props.alt).toBe(\"explicit alt\");\n });\n\n it(\"falls back to the image's stored alt\", () => {\n const props = getImageProps(asset({ image: { alt: \"stored alt\" } }));\n expect(props.alt).toBe(\"stored alt\");\n });\n\n it(\"defaults alt to an empty string\", () => {\n expect(getImageProps(asset()).alt).toBe(\"\");\n });\n\n it(\"produces a wrapper with the requested aspect ratio\", () => {\n const props = getImageProps(asset(), { aspectRatio: 1 });\n expect(props.style.aspectRatio).toBe(\"1\");\n });\n\n it(\"offsets the image to reveal a focal-point-shifted crop region\", () => {\n const props = getImageProps(\n asset({\n image: {\n width: 1600,\n height: 900,\n focalPoint: { x: 0.9, y: 0.5 }\n }\n }),\n { aspectRatio: 1 }\n );\n expect(parseFloat(props.imgStyle.left as string)).toBeLessThan(0);\n });\n});\n"],"names":["asset","overrides","describe","it","props","getImageProps","expect","parseFloat"],"mappings":";;AAIA,MAAMA,QAAQ,CAACC,YAA4B,CAAC,CAAC,GAAa;QACtD,IAAI;QACJ,MAAM;QACN,MAAM;QACN,UAAU;QACV,KAAK;QACL,KAAK;QACL,OAAO;YAAE,OAAO;YAAM,QAAQ;QAAI;QAClC,GAAGA,SAAS;IAChB;AAEAC,SAAS,iBAAiB;IACtBC,GAAG,wEAAwE;QACvE,MAAMC,QAAQC,cAAcL;QAC5BM,OAAOF,MAAM,GAAG,EAAE,IAAI,CAAC;QACvBE,OAAOF,MAAM,KAAK,EAAE,IAAI,CAAC;QACzBE,OAAOF,MAAM,MAAM,EAAE,IAAI,CAAC;QAC1BE,OAAOF,MAAM,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC;QAClCE,OAAOF,MAAM,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC;QAClCE,OAAOF,MAAM,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC;IACzC;IAEAD,GAAG,+CAA+C;QAC9C,MAAMC,QAAQC,cAAcL,MAAM;YAAE,OAAO;gBAAE,KAAK;YAAa;QAAE,IAAI;YACjE,KAAK;QACT;QACAM,OAAOF,MAAM,GAAG,EAAE,IAAI,CAAC;IAC3B;IAEAD,GAAG,wCAAwC;QACvC,MAAMC,QAAQC,cAAcL,MAAM;YAAE,OAAO;gBAAE,KAAK;YAAa;QAAE;QACjEM,OAAOF,MAAM,GAAG,EAAE,IAAI,CAAC;IAC3B;IAEAD,GAAG,mCAAmC;QAClCG,OAAOD,cAAcL,SAAS,GAAG,EAAE,IAAI,CAAC;IAC5C;IAEAG,GAAG,sDAAsD;QACrD,MAAMC,QAAQC,cAAcL,SAAS;YAAE,aAAa;QAAE;QACtDM,OAAOF,MAAM,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC;IACzC;IAEAD,GAAG,iEAAiE;QAChE,MAAMC,QAAQC,cACVL,MAAM;YACF,OAAO;gBACH,OAAO;gBACP,QAAQ;gBACR,YAAY;oBAAE,GAAG;oBAAK,GAAG;gBAAI;YACjC;QACJ,IACA;YAAE,aAAa;QAAE;QAErBM,OAAOC,WAAWH,MAAM,QAAQ,CAAC,IAAI,GAAa,YAAY,CAAC;IACnE;AACJ"}
@@ -0,0 +1,3 @@
1
+ export * from "./getImageProps.js";
2
+ export * from "./Image.js";
3
+ export * from "./BackgroundImage.js";