@webiny/website-builder-react 0.0.0-unstable.c27f4d8a31 → 0.0.0-unstable.d0f34a8194

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 (116) hide show
  1. package/components/ConnectToEditor.js +18 -19
  2. package/components/ConnectToEditor.js.map +1 -1
  3. package/components/ContentClientContext.d.ts +3 -0
  4. package/components/ContentClientContext.js +6 -0
  5. package/components/ContentClientContext.js.map +1 -0
  6. package/components/ContentClientProvider.d.ts +12 -0
  7. package/components/ContentClientProvider.js +9 -0
  8. package/components/ContentClientProvider.js.map +1 -0
  9. package/components/ContentClientProvider.test.d.ts +1 -0
  10. package/components/ContentClientProvider.test.js +143 -0
  11. package/components/ContentClientProvider.test.js.map +1 -0
  12. package/components/DocumentFragment.js +5 -7
  13. package/components/DocumentFragment.js.map +1 -1
  14. package/components/DocumentRenderer.js +39 -47
  15. package/components/DocumentRenderer.js.map +1 -1
  16. package/components/DocumentStoreProvider.js +19 -22
  17. package/components/DocumentStoreProvider.js.map +1 -1
  18. package/components/EditingElementRenderer/EditingElementRenderer.d.ts +2 -2
  19. package/components/EditingElementRenderer/EditingElementRenderer.js +41 -35
  20. package/components/EditingElementRenderer/EditingElementRenderer.js.map +1 -1
  21. package/components/EditingElementRenderer/EditingElementRenderer.presenter.d.ts +2 -2
  22. package/components/EditingElementRenderer/EditingElementRenderer.presenter.js +30 -36
  23. package/components/EditingElementRenderer/EditingElementRenderer.presenter.js.map +1 -1
  24. package/components/EditingElementRenderer/index.js +0 -2
  25. package/components/ElementIndexProvider.js +9 -14
  26. package/components/ElementIndexProvider.js.map +1 -1
  27. package/components/ElementRenderer.d.ts +2 -2
  28. package/components/ElementRenderer.js +11 -16
  29. package/components/ElementRenderer.js.map +1 -1
  30. package/components/ElementSlot.js +6 -9
  31. package/components/ElementSlot.js.map +1 -1
  32. package/components/ElementSlotDepthProvider.js +9 -14
  33. package/components/ElementSlotDepthProvider.js.map +1 -1
  34. package/components/FragmentsProvider.js +32 -37
  35. package/components/FragmentsProvider.js.map +1 -1
  36. package/components/LiveElementRenderer.d.ts +2 -2
  37. package/components/LiveElementRenderer.js +59 -69
  38. package/components/LiveElementRenderer.js.map +1 -1
  39. package/components/LiveElementSlot.js +12 -14
  40. package/components/LiveElementSlot.js.map +1 -1
  41. package/components/PreviewElementSlot.js +17 -23
  42. package/components/PreviewElementSlot.js.map +1 -1
  43. package/components/index.d.ts +2 -0
  44. package/components/index.js +2 -2
  45. package/components/useBindingsForElement.js +13 -11
  46. package/components/useBindingsForElement.js.map +1 -1
  47. package/components/useContentClient.d.ts +6 -0
  48. package/components/useContentClient.js +11 -0
  49. package/components/useContentClient.js.map +1 -0
  50. package/components/useDocumentState.js +4 -3
  51. package/components/useDocumentState.js.map +1 -1
  52. package/components/useSelectFromState.js +29 -35
  53. package/components/useSelectFromState.js.map +1 -1
  54. package/components/useViewportInfo.js +5 -6
  55. package/components/useViewportInfo.js.map +1 -1
  56. package/contentEntry/useContentEntryList.d.ts +22 -0
  57. package/contentEntry/useContentEntryList.js +51 -0
  58. package/contentEntry/useContentEntryList.js.map +1 -0
  59. package/createComponent.d.ts +1 -3
  60. package/createComponent.js +1 -36
  61. package/createComponent.test.js +108 -119
  62. package/createComponent.test.js.map +1 -1
  63. package/editorComponents/Box.js +3 -6
  64. package/editorComponents/Box.js.map +1 -1
  65. package/editorComponents/Box.manifest.js +15 -14
  66. package/editorComponents/Box.manifest.js.map +1 -1
  67. package/editorComponents/Fragment.js +23 -32
  68. package/editorComponents/Fragment.js.map +1 -1
  69. package/editorComponents/Fragment.manifest.js +14 -11
  70. package/editorComponents/Fragment.manifest.js.map +1 -1
  71. package/editorComponents/Grid.js +33 -61
  72. package/editorComponents/Grid.js.map +1 -1
  73. package/editorComponents/Grid.manifest.js +163 -166
  74. package/editorComponents/Grid.manifest.js.map +1 -1
  75. package/editorComponents/GridColumn.js +3 -6
  76. package/editorComponents/GridColumn.js.map +1 -1
  77. package/editorComponents/GridColumn.manifest.js +20 -17
  78. package/editorComponents/GridColumn.manifest.js.map +1 -1
  79. package/editorComponents/Image.js +99 -119
  80. package/editorComponents/Image.js.map +1 -1
  81. package/editorComponents/Image.manifest.js +33 -32
  82. package/editorComponents/Image.manifest.js.map +1 -1
  83. package/editorComponents/Lexical.js +13 -21
  84. package/editorComponents/Lexical.js.map +1 -1
  85. package/editorComponents/Lexical.manifest.js +17 -14
  86. package/editorComponents/Lexical.manifest.js.map +1 -1
  87. package/editorComponents/Root.js +3 -6
  88. package/editorComponents/Root.js.map +1 -1
  89. package/editorComponents/Root.manifest.js +7 -6
  90. package/editorComponents/Root.manifest.js.map +1 -1
  91. package/editorComponents/index.js +10 -1
  92. package/editorComponents/index.js.map +1 -1
  93. package/image/BackgroundImage.d.ts +33 -0
  94. package/image/BackgroundImage.js +61 -0
  95. package/image/BackgroundImage.js.map +1 -0
  96. package/image/Image.d.ts +29 -0
  97. package/image/Image.js +43 -0
  98. package/image/Image.js.map +1 -0
  99. package/image/getImageProps.d.ts +42 -0
  100. package/image/getImageProps.js +18 -0
  101. package/image/getImageProps.js.map +1 -0
  102. package/image/getImageProps.test.d.ts +1 -0
  103. package/image/getImageProps.test.js +70 -0
  104. package/image/getImageProps.test.js.map +1 -0
  105. package/image/index.d.ts +3 -0
  106. package/image/index.js +3 -0
  107. package/index.d.ts +4 -3
  108. package/index.js +2 -4
  109. package/package.json +13 -12
  110. package/types.d.ts +37 -4
  111. package/types.js +0 -3
  112. package/components/EditingElementRenderer/index.js.map +0 -1
  113. package/components/index.js.map +0 -1
  114. package/createComponent.js.map +0 -1
  115. package/index.js.map +0 -1
  116. package/types.js.map +0 -1
@@ -2,128 +2,117 @@ import { describe, expect, it } from "vitest";
2
2
  import { createComponent } from "./createComponent.js";
3
3
  import { createTextInput } from "./index.js";
4
4
  import { createSlotInput } from "@webiny/website-builder-sdk";
5
-
6
- /**
7
- * These tests are aimed at testing TS types rather than functionality itself.
8
- * // TODO: figure out how to enable typechecking for a single test. Currently it only typechecks at build time.
9
- */
10
-
11
- describe("Component Manifest", () => {
12
- it("should support input arrays and strict input objects", () => {
13
- // eslint-disable-next-line
14
- const Button = _ => {
15
- return null;
16
- };
17
- const button1 = createComponent(Button, {
18
- name: "Button",
19
- inputs: [
20
- // Passing a generic narrows down the `name` property and provides autocomplete.
21
- createTextInput({
22
- name: "title",
23
- label: "Title"
24
- }),
25
- // Skipping the generic still performs typechecks, but doesn't provide autocomplete.
26
- createSlotInput({
27
- name: "children"
28
- })]
29
- });
30
- const button2 = createComponent(Button, {
31
- name: "Button",
32
- inputs: {
33
- title: createTextInput({
34
- label: "Title"
35
- }),
36
- children: createSlotInput({})
37
- }
38
- });
39
- const snapshot = {
40
- name: "Button",
41
- inputs: [{
42
- type: "text",
43
- label: "Title",
44
- renderer: "Webiny/Input",
45
- name: "title"
46
- }, {
47
- type: "slot",
48
- renderer: "Webiny/Slot",
49
- name: "children",
50
- list: true,
51
- defaultValue: []
52
- }]
53
- };
54
- expect(button1.manifest).toEqual(snapshot);
55
- expect(button2.manifest).toEqual(snapshot);
56
- });
57
- it("acceptsChildren should satisfy the `children` input requirement", () => {
58
- // eslint-disable-next-line
59
- const Button = _ => {
60
- return null;
61
- };
62
- const {
63
- manifest
64
- } = createComponent(Button, {
65
- name: "Button",
66
- acceptsChildren: true
5
+ describe("Component Manifest", ()=>{
6
+ it("should support input arrays and strict input objects", ()=>{
7
+ const Button = ({})=>null;
8
+ const button1 = createComponent(Button, {
9
+ name: "Button",
10
+ inputs: [
11
+ createTextInput({
12
+ name: "title",
13
+ label: "Title"
14
+ }),
15
+ createSlotInput({
16
+ name: "children"
17
+ })
18
+ ]
19
+ });
20
+ const button2 = createComponent(Button, {
21
+ name: "Button",
22
+ inputs: {
23
+ title: createTextInput({
24
+ label: "Title"
25
+ }),
26
+ children: createSlotInput({})
27
+ }
28
+ });
29
+ const snapshot = {
30
+ name: "Button",
31
+ tags: [],
32
+ inputs: [
33
+ {
34
+ type: "text",
35
+ label: "Title",
36
+ renderer: "Webiny/Input",
37
+ name: "title"
38
+ },
39
+ {
40
+ type: "slot",
41
+ renderer: "Webiny/Slot",
42
+ name: "children",
43
+ list: true,
44
+ defaultValue: []
45
+ }
46
+ ]
47
+ };
48
+ expect(button1.manifest).toEqual(snapshot);
49
+ expect(button2.manifest).toEqual(snapshot);
67
50
  });
68
- expect(manifest).toEqual({
69
- name: "Button",
70
- acceptsChildren: true,
71
- inputs: [{
72
- type: "slot",
73
- list: true,
74
- renderer: "Webiny/Slot",
75
- name: "children",
76
- defaultValue: []
77
- }]
51
+ it("acceptsChildren should satisfy the `children` input requirement", ()=>{
52
+ const Button = ({})=>null;
53
+ const { manifest } = createComponent(Button, {
54
+ name: "Button",
55
+ acceptsChildren: true
56
+ });
57
+ expect(manifest).toEqual({
58
+ name: "Button",
59
+ acceptsChildren: true,
60
+ tags: [],
61
+ inputs: [
62
+ {
63
+ type: "slot",
64
+ list: true,
65
+ renderer: "Webiny/Slot",
66
+ name: "children",
67
+ defaultValue: []
68
+ }
69
+ ]
70
+ });
78
71
  });
79
- });
80
- it("`acceptsChildren` should work alongside other inputs", () => {
81
- // eslint-disable-next-line
82
- const Button = _ => {
83
- return null;
84
- };
85
-
86
- // Inputs as array
87
- const button1 = createComponent(Button, {
88
- name: "Button",
89
- acceptsChildren: true,
90
- inputs: [createTextInput({
91
- name: "title",
92
- label: "Title"
93
- })]
94
- });
95
-
96
- // Inputs as object
97
- const button2 = createComponent(Button, {
98
- name: "Button",
99
- acceptsChildren: true,
100
- inputs: {
101
- title: createTextInput({
102
- label: "Title"
103
- })
104
- }
72
+ it("`acceptsChildren` should work alongside other inputs", ()=>{
73
+ const Button = ({})=>null;
74
+ const button1 = createComponent(Button, {
75
+ name: "Button",
76
+ acceptsChildren: true,
77
+ inputs: [
78
+ createTextInput({
79
+ name: "title",
80
+ label: "Title"
81
+ })
82
+ ]
83
+ });
84
+ const button2 = createComponent(Button, {
85
+ name: "Button",
86
+ acceptsChildren: true,
87
+ inputs: {
88
+ title: createTextInput({
89
+ label: "Title"
90
+ })
91
+ }
92
+ });
93
+ const snapshot = {
94
+ name: "Button",
95
+ acceptsChildren: true,
96
+ tags: [],
97
+ inputs: [
98
+ {
99
+ type: "text",
100
+ renderer: "Webiny/Input",
101
+ name: "title",
102
+ label: "Title"
103
+ },
104
+ {
105
+ type: "slot",
106
+ renderer: "Webiny/Slot",
107
+ name: "children",
108
+ list: true,
109
+ defaultValue: []
110
+ }
111
+ ]
112
+ };
113
+ expect(button1.manifest).toEqual(snapshot);
114
+ expect(button2.manifest).toEqual(snapshot);
105
115
  });
106
-
107
- // Both must produce the same component manifest
108
- const snapshot = {
109
- name: "Button",
110
- acceptsChildren: true,
111
- inputs: [{
112
- type: "text",
113
- renderer: "Webiny/Input",
114
- name: "title",
115
- label: "Title"
116
- }, {
117
- type: "slot",
118
- renderer: "Webiny/Slot",
119
- name: "children",
120
- list: true,
121
- defaultValue: []
122
- }]
123
- };
124
- expect(button1.manifest).toEqual(snapshot);
125
- expect(button2.manifest).toEqual(snapshot);
126
- });
127
116
  });
128
117
 
129
118
  //# sourceMappingURL=createComponent.test.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["describe","expect","it","createComponent","createTextInput","createSlotInput","Button","_","button1","name","inputs","label","button2","title","children","snapshot","type","renderer","list","defaultValue","manifest","toEqual","acceptsChildren"],"sources":["createComponent.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport type { ComponentProps, ExtractInputNames } from \"~/types.js\";\nimport { createComponent } from \"~/createComponent.js\";\nimport { createTextInput } from \"~/index.js\";\nimport { createSlotInput } from \"@webiny/website-builder-sdk\";\n\n/**\n * These tests are aimed at testing TS types rather than functionality itself.\n * // TODO: figure out how to enable typechecking for a single test. Currently it only typechecks at build time.\n */\n\ndescribe(\"Component Manifest\", () => {\n it(\"should support input arrays and strict input objects\", () => {\n // eslint-disable-next-line\n const Button = (_: ComponentProps<{ title: string; children: React.ReactNode }>) => {\n return null;\n };\n\n type Inputs = ExtractInputNames<typeof Button>;\n\n const button1 = createComponent(Button, {\n name: \"Button\",\n inputs: [\n // Passing a generic narrows down the `name` property and provides autocomplete.\n createTextInput<Inputs>({\n name: \"title\",\n label: \"Title\"\n }),\n // Skipping the generic still performs typechecks, but doesn't provide autocomplete.\n createSlotInput({\n name: \"children\"\n })\n ]\n });\n\n const button2 = createComponent(Button, {\n name: \"Button\",\n inputs: {\n title: createTextInput({\n label: \"Title\"\n }),\n children: createSlotInput({})\n }\n });\n\n const snapshot = {\n name: \"Button\",\n inputs: [\n {\n type: \"text\",\n label: \"Title\",\n renderer: \"Webiny/Input\",\n name: \"title\"\n },\n {\n type: \"slot\",\n renderer: \"Webiny/Slot\",\n name: \"children\",\n list: true,\n defaultValue: []\n }\n ]\n };\n\n expect(button1.manifest).toEqual(snapshot);\n expect(button2.manifest).toEqual(snapshot);\n });\n\n it(\"acceptsChildren should satisfy the `children` input requirement\", () => {\n // eslint-disable-next-line\n const Button = (_: ComponentProps<{ children: React.ReactNode }>) => {\n return null;\n };\n\n const { manifest } = createComponent(Button, {\n name: \"Button\",\n acceptsChildren: true\n });\n\n expect(manifest).toEqual({\n name: \"Button\",\n acceptsChildren: true,\n inputs: [\n {\n type: \"slot\",\n list: true,\n renderer: \"Webiny/Slot\",\n name: \"children\",\n defaultValue: []\n }\n ]\n });\n });\n\n it(\"`acceptsChildren` should work alongside other inputs\", () => {\n // eslint-disable-next-line\n const Button = (_: ComponentProps<{ title: string; children: React.ReactNode }>) => {\n return null;\n };\n\n // Inputs as array\n const button1 = createComponent(Button, {\n name: \"Button\",\n acceptsChildren: true,\n inputs: [\n createTextInput({\n name: \"title\",\n label: \"Title\"\n })\n ]\n });\n\n // Inputs as object\n const button2 = createComponent(Button, {\n name: \"Button\",\n acceptsChildren: true,\n inputs: {\n title: createTextInput({\n label: \"Title\"\n })\n }\n });\n\n // Both must produce the same component manifest\n const snapshot = {\n name: \"Button\",\n acceptsChildren: true,\n inputs: [\n {\n type: \"text\",\n renderer: \"Webiny/Input\",\n name: \"title\",\n label: \"Title\"\n },\n {\n type: \"slot\",\n renderer: \"Webiny/Slot\",\n name: \"children\",\n list: true,\n defaultValue: []\n }\n ]\n };\n\n expect(button1.manifest).toEqual(snapshot);\n expect(button2.manifest).toEqual(snapshot);\n });\n});\n"],"mappings":"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","ignoreList":[]}
1
+ {"version":3,"file":"createComponent.test.js","sources":["../src/createComponent.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport type { ComponentProps, ExtractInputNames } from \"~/types.js\";\nimport { createComponent } from \"~/createComponent.js\";\nimport { createTextInput } from \"~/index.js\";\nimport { createSlotInput } from \"@webiny/website-builder-sdk\";\n\n/**\n * These tests are aimed at testing TS types rather than functionality itself.\n * // TODO: figure out how to enable typechecking for a single test. Currently it only typechecks at build time.\n */\n\ndescribe(\"Component Manifest\", () => {\n it(\"should support input arrays and strict input objects\", () => {\n const Button = ({}: ComponentProps<{ title: string; children: React.ReactNode }>) => {\n return null;\n };\n\n type Inputs = ExtractInputNames<typeof Button>;\n\n const button1 = createComponent(Button, {\n name: \"Button\",\n inputs: [\n // Passing a generic narrows down the `name` property and provides autocomplete.\n createTextInput<Inputs>({\n name: \"title\",\n label: \"Title\"\n }),\n // Skipping the generic still performs typechecks, but doesn't provide autocomplete.\n createSlotInput({\n name: \"children\"\n })\n ]\n });\n\n const button2 = createComponent(Button, {\n name: \"Button\",\n inputs: {\n title: createTextInput({\n label: \"Title\"\n }),\n children: createSlotInput({})\n }\n });\n\n const snapshot = {\n name: \"Button\",\n tags: [],\n inputs: [\n {\n type: \"text\",\n label: \"Title\",\n renderer: \"Webiny/Input\",\n name: \"title\"\n },\n {\n type: \"slot\",\n renderer: \"Webiny/Slot\",\n name: \"children\",\n list: true,\n defaultValue: []\n }\n ]\n };\n\n expect(button1.manifest).toEqual(snapshot);\n expect(button2.manifest).toEqual(snapshot);\n });\n\n it(\"acceptsChildren should satisfy the `children` input requirement\", () => {\n const Button = ({}: ComponentProps<{ children: React.ReactNode }>) => {\n return null;\n };\n\n const { manifest } = createComponent(Button, {\n name: \"Button\",\n acceptsChildren: true\n });\n\n expect(manifest).toEqual({\n name: \"Button\",\n acceptsChildren: true,\n tags: [],\n inputs: [\n {\n type: \"slot\",\n list: true,\n renderer: \"Webiny/Slot\",\n name: \"children\",\n defaultValue: []\n }\n ]\n });\n });\n\n it(\"`acceptsChildren` should work alongside other inputs\", () => {\n const Button = ({}: ComponentProps<{ title: string; children: React.ReactNode }>) => {\n return null;\n };\n\n // Inputs as array\n const button1 = createComponent(Button, {\n name: \"Button\",\n acceptsChildren: true,\n inputs: [\n createTextInput({\n name: \"title\",\n label: \"Title\"\n })\n ]\n });\n\n // Inputs as object\n const button2 = createComponent(Button, {\n name: \"Button\",\n acceptsChildren: true,\n inputs: {\n title: createTextInput({\n label: \"Title\"\n })\n }\n });\n\n // Both must produce the same component manifest\n const snapshot = {\n name: \"Button\",\n acceptsChildren: true,\n tags: [],\n inputs: [\n {\n type: \"text\",\n renderer: \"Webiny/Input\",\n name: \"title\",\n label: \"Title\"\n },\n {\n type: \"slot\",\n renderer: \"Webiny/Slot\",\n name: \"children\",\n list: true,\n defaultValue: []\n }\n ]\n };\n\n expect(button1.manifest).toEqual(snapshot);\n expect(button2.manifest).toEqual(snapshot);\n });\n});\n"],"names":["describe","it","Button","button1","createComponent","createTextInput","createSlotInput","button2","snapshot","expect","manifest"],"mappings":";;;;AAWAA,SAAS,sBAAsB;IAC3BC,GAAG,wDAAwD;QACvD,MAAMC,SAAS,CAAC,EAAgE,GACrE;QAKX,MAAMC,UAAUC,gBAAgBF,QAAQ;YACpC,MAAM;YACN,QAAQ;gBAEJG,gBAAwB;oBACpB,MAAM;oBACN,OAAO;gBACX;gBAEAC,gBAAgB;oBACZ,MAAM;gBACV;aACH;QACL;QAEA,MAAMC,UAAUH,gBAAgBF,QAAQ;YACpC,MAAM;YACN,QAAQ;gBACJ,OAAOG,gBAAgB;oBACnB,OAAO;gBACX;gBACA,UAAUC,gBAAgB,CAAC;YAC/B;QACJ;QAEA,MAAME,WAAW;YACb,MAAM;YACN,MAAM,EAAE;YACR,QAAQ;gBACJ;oBACI,MAAM;oBACN,OAAO;oBACP,UAAU;oBACV,MAAM;gBACV;gBACA;oBACI,MAAM;oBACN,UAAU;oBACV,MAAM;oBACN,MAAM;oBACN,cAAc,EAAE;gBACpB;aACH;QACL;QAEAC,OAAON,QAAQ,QAAQ,EAAE,OAAO,CAACK;QACjCC,OAAOF,QAAQ,QAAQ,EAAE,OAAO,CAACC;IACrC;IAEAP,GAAG,mEAAmE;QAClE,MAAMC,SAAS,CAAC,EAAiD,GACtD;QAGX,MAAM,EAAEQ,QAAQ,EAAE,GAAGN,gBAAgBF,QAAQ;YACzC,MAAM;YACN,iBAAiB;QACrB;QAEAO,OAAOC,UAAU,OAAO,CAAC;YACrB,MAAM;YACN,iBAAiB;YACjB,MAAM,EAAE;YACR,QAAQ;gBACJ;oBACI,MAAM;oBACN,MAAM;oBACN,UAAU;oBACV,MAAM;oBACN,cAAc,EAAE;gBACpB;aACH;QACL;IACJ;IAEAT,GAAG,wDAAwD;QACvD,MAAMC,SAAS,CAAC,EAAgE,GACrE;QAIX,MAAMC,UAAUC,gBAAgBF,QAAQ;YACpC,MAAM;YACN,iBAAiB;YACjB,QAAQ;gBACJG,gBAAgB;oBACZ,MAAM;oBACN,OAAO;gBACX;aACH;QACL;QAGA,MAAME,UAAUH,gBAAgBF,QAAQ;YACpC,MAAM;YACN,iBAAiB;YACjB,QAAQ;gBACJ,OAAOG,gBAAgB;oBACnB,OAAO;gBACX;YACJ;QACJ;QAGA,MAAMG,WAAW;YACb,MAAM;YACN,iBAAiB;YACjB,MAAM,EAAE;YACR,QAAQ;gBACJ;oBACI,MAAM;oBACN,UAAU;oBACV,MAAM;oBACN,OAAO;gBACX;gBACA;oBACI,MAAM;oBACN,UAAU;oBACV,MAAM;oBACN,MAAM;oBACN,cAAc,EAAE;gBACpB;aACH;QACL;QAEAC,OAAON,QAAQ,QAAQ,EAAE,OAAO,CAACK;QACjCC,OAAOF,QAAQ,QAAQ,EAAE,OAAO,CAACC;IACrC;AACJ"}
@@ -1,8 +1,5 @@
1
- import React from "react";
2
- export const BoxComponent = ({
3
- inputs
4
- }) => {
5
- return /*#__PURE__*/React.createElement(React.Fragment, null, inputs.children);
6
- };
1
+ import react from "react";
2
+ const BoxComponent = ({ inputs })=>/*#__PURE__*/ react.createElement(react.Fragment, null, inputs.children);
3
+ export { BoxComponent };
7
4
 
8
5
  //# sourceMappingURL=Box.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","BoxComponent","inputs","createElement","Fragment","children"],"sources":["Box.tsx"],"sourcesContent":["import React from \"react\";\nimport type { ComponentPropsWithChildren } from \"~/types.js\";\n\nexport const BoxComponent = ({ inputs }: ComponentPropsWithChildren) => {\n return <>{inputs.children}</>;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAGzB,OAAO,MAAMC,YAAY,GAAGA,CAAC;EAAEC;AAAmC,CAAC,KAAK;EACpE,oBAAOF,KAAA,CAAAG,aAAA,CAAAH,KAAA,CAAAI,QAAA,QAAGF,MAAM,CAACG,QAAW,CAAC;AACjC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"editorComponents/Box.js","sources":["../../src/editorComponents/Box.tsx"],"sourcesContent":["import React from \"react\";\nimport type { ComponentPropsWithChildren } from \"~/types.js\";\n\nexport const BoxComponent = ({ inputs }: ComponentPropsWithChildren) => {\n return <>{inputs.children}</>;\n};\n"],"names":["BoxComponent","inputs"],"mappings":";AAGO,MAAMA,eAAe,CAAC,EAAEC,MAAM,EAA8B,GACxD,WAAP,GAAO,0CAAGA,OAAO,QAAQ"}
@@ -1,21 +1,22 @@
1
1
  "use client";
2
-
3
2
  import { createComponent } from "../createComponent.js";
4
3
  import { BoxComponent } from "./Box.js";
5
- export const Box = createComponent(BoxComponent, {
6
- name: "Webiny/Box",
7
- label: "Box",
8
- group: "basic",
9
- image: `<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e8eaed"><path d="M120-120v-720h720v720H120Zm80-80h560v-560H200v560Zm0 0v-560 560Z"/></svg>`,
10
- acceptsChildren: true,
11
- defaults: {
12
- styles: {
13
- paddingTop: "5px",
14
- paddingRight: "5px",
15
- paddingBottom: "5px",
16
- paddingLeft: "5px"
4
+ const Box = createComponent(BoxComponent, {
5
+ name: "Webiny/Box",
6
+ label: "Box",
7
+ aiContext: "Generic container with no visual output of its own. Use it to group child elements and apply shared padding, margin, background, or other styles.",
8
+ group: "basic",
9
+ image: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M3 3v18h18V3H3zm16 16H5V5h14v14z"/></svg>',
10
+ acceptsChildren: true,
11
+ defaults: {
12
+ styles: {
13
+ paddingTop: "5px",
14
+ paddingRight: "5px",
15
+ paddingBottom: "5px",
16
+ paddingLeft: "5px"
17
+ }
17
18
  }
18
- }
19
19
  });
20
+ export { Box };
20
21
 
21
22
  //# sourceMappingURL=Box.manifest.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createComponent","BoxComponent","Box","name","label","group","image","acceptsChildren","defaults","styles","paddingTop","paddingRight","paddingBottom","paddingLeft"],"sources":["Box.manifest.ts"],"sourcesContent":["\"use client\";\nimport { createComponent } from \"~/createComponent.js\";\nimport { BoxComponent } from \"./Box.js\";\n\nexport const Box = createComponent(BoxComponent, {\n name: \"Webiny/Box\",\n label: \"Box\",\n group: \"basic\",\n image: `<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#e8eaed\"><path d=\"M120-120v-720h720v720H120Zm80-80h560v-560H200v560Zm0 0v-560 560Z\"/></svg>`,\n acceptsChildren: true,\n defaults: {\n styles: {\n paddingTop: \"5px\",\n paddingRight: \"5px\",\n paddingBottom: \"5px\",\n paddingLeft: \"5px\"\n }\n }\n});\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe;AACxB,SAASC,YAAY;AAErB,OAAO,MAAMC,GAAG,GAAGF,eAAe,CAACC,YAAY,EAAE;EAC7CE,IAAI,EAAE,YAAY;EAClBC,KAAK,EAAE,KAAK;EACZC,KAAK,EAAE,OAAO;EACdC,KAAK,EAAE,+LAA+L;EACtMC,eAAe,EAAE,IAAI;EACrBC,QAAQ,EAAE;IACNC,MAAM,EAAE;MACJC,UAAU,EAAE,KAAK;MACjBC,YAAY,EAAE,KAAK;MACnBC,aAAa,EAAE,KAAK;MACpBC,WAAW,EAAE;IACjB;EACJ;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"editorComponents/Box.manifest.js","sources":["../../src/editorComponents/Box.manifest.ts"],"sourcesContent":["\"use client\";\nimport { createComponent } from \"~/createComponent.js\";\nimport { BoxComponent } from \"./Box.js\";\n\nexport const Box = createComponent(BoxComponent, {\n name: \"Webiny/Box\",\n label: \"Box\",\n aiContext:\n \"Generic container with no visual output of its own. Use it to group child elements and apply shared padding, margin, background, or other styles.\",\n group: \"basic\",\n image: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M3 3v18h18V3H3zm16 16H5V5h14v14z\"/></svg>`,\n acceptsChildren: true,\n defaults: {\n styles: {\n paddingTop: \"5px\",\n paddingRight: \"5px\",\n paddingBottom: \"5px\",\n paddingLeft: \"5px\"\n }\n }\n});\n"],"names":["Box","createComponent","BoxComponent"],"mappings":";;;AAIO,MAAMA,MAAMC,gBAAgBC,cAAc;IAC7C,MAAM;IACN,OAAO;IACP,WACI;IACJ,OAAO;IACP,OAAO;IACP,iBAAiB;IACjB,UAAU;QACN,QAAQ;YACJ,YAAY;YACZ,cAAc;YACd,eAAe;YACf,aAAa;QACjB;IACJ;AACJ"}
@@ -1,39 +1,30 @@
1
- import React from "react";
1
+ import react from "react";
2
2
  import { contentSdk } from "@webiny/website-builder-sdk";
3
3
  import { useDocumentFragments } from "../components/FragmentsProvider.js";
4
- const findFixedFragmentByName = (fragments, name) => {
5
- return fragments.filter(fragment => fragment.type === "fixed").find(fragment => fragment.name === name);
6
- };
7
- export const FragmentComponent = ({
8
- inputs
9
- }) => {
10
- const isEditing = contentSdk.isEditing();
11
- const fragments = useDocumentFragments();
12
- const fragment = findFixedFragmentByName(fragments, inputs.name);
13
- if (!fragment && isEditing) {
14
- return /*#__PURE__*/React.createElement(FragmentPlaceholder, {
15
- name: inputs.name
4
+ const findFixedFragmentByName = (fragments, name)=>fragments.filter((fragment)=>"fixed" === fragment.type).find((fragment)=>fragment.name === name);
5
+ const FragmentComponent = ({ inputs })=>{
6
+ const isEditing = contentSdk.isEditing();
7
+ const fragments = useDocumentFragments();
8
+ const fragment = findFixedFragmentByName(fragments, inputs.name);
9
+ if (!fragment && isEditing) return /*#__PURE__*/ react.createElement(FragmentPlaceholder, {
10
+ name: inputs.name
16
11
  });
17
- }
18
- if (fragment) {
19
- return /*#__PURE__*/React.createElement(React.Fragment, null, fragment.element);
20
- }
21
- return null;
12
+ if (fragment) return /*#__PURE__*/ react.createElement(react.Fragment, null, fragment.element);
13
+ return null;
22
14
  };
23
- const FragmentPlaceholder = ({
24
- name
25
- }) => {
26
- const fragmentName = name ? /*#__PURE__*/React.createElement(React.Fragment, null, "\xA0", /*#__PURE__*/React.createElement("strong", null, name), "\xA0") : /*#__PURE__*/React.createElement(React.Fragment, null, "\xA0");
27
- return /*#__PURE__*/React.createElement("div", {
28
- style: {
29
- display: "flex",
30
- height: "100px",
31
- backgroundColor: "#f4f4f4",
32
- justifyContent: "center",
33
- alignItems: "center",
34
- fill: "#ffffff"
35
- }
36
- }, "This is a placeholder for", fragmentName, "content coming from your frontend app.");
15
+ const FragmentPlaceholder = ({ name })=>{
16
+ const fragmentName = name ? /*#__PURE__*/ react.createElement(react.Fragment, null, "\xa0", /*#__PURE__*/ react.createElement("strong", null, name), "\xa0") : /*#__PURE__*/ react.createElement(react.Fragment, null, "\xa0");
17
+ return /*#__PURE__*/ react.createElement("div", {
18
+ style: {
19
+ display: "flex",
20
+ height: "100px",
21
+ backgroundColor: "#f4f4f4",
22
+ justifyContent: "center",
23
+ alignItems: "center",
24
+ fill: "#ffffff"
25
+ }
26
+ }, "This is a placeholder for", fragmentName, "content coming from your frontend app.");
37
27
  };
28
+ export { FragmentComponent };
38
29
 
39
30
  //# sourceMappingURL=Fragment.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","contentSdk","useDocumentFragments","findFixedFragmentByName","fragments","name","filter","fragment","type","find","FragmentComponent","inputs","isEditing","createElement","FragmentPlaceholder","Fragment","element","fragmentName","style","display","height","backgroundColor","justifyContent","alignItems","fill"],"sources":["Fragment.tsx"],"sourcesContent":["import React from \"react\";\nimport { contentSdk } from \"@webiny/website-builder-sdk\";\nimport { useDocumentFragments } from \"~/components/FragmentsProvider.js\";\nimport type { ComponentProps } from \"~/types.js\";\nimport type { DocumentFragments } from \"~/components/FragmentsProvider.js\";\n\ntype FragmentComponentProps = ComponentProps<{\n name: string;\n}>;\n\nconst findFixedFragmentByName = (fragments: DocumentFragments, name: string) => {\n return fragments\n .filter(fragment => fragment.type === \"fixed\")\n .find(fragment => fragment.name === name);\n};\n\nexport const FragmentComponent = ({ inputs }: FragmentComponentProps) => {\n const isEditing = contentSdk.isEditing();\n const fragments = useDocumentFragments();\n const fragment = findFixedFragmentByName(fragments, inputs.name);\n\n if (!fragment && isEditing) {\n return <FragmentPlaceholder name={inputs.name} />;\n }\n\n if (fragment) {\n return <>{fragment.element}</>;\n }\n\n return null;\n};\n\nconst FragmentPlaceholder = ({ name }: { name: string }) => {\n const fragmentName = name ? (\n <>\n &nbsp;<strong>{name}</strong>&nbsp;\n </>\n ) : (\n <>&nbsp;</>\n );\n return (\n <div\n style={{\n display: \"flex\",\n height: \"100px\",\n backgroundColor: \"#f4f4f4\",\n justifyContent: \"center\",\n alignItems: \"center\",\n fill: \"#ffffff\"\n }}\n >\n This is a placeholder for{fragmentName}content coming from your frontend app.\n </div>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,QAAQ,6BAA6B;AACxD,SAASC,oBAAoB;AAQ7B,MAAMC,uBAAuB,GAAGA,CAACC,SAA4B,EAAEC,IAAY,KAAK;EAC5E,OAAOD,SAAS,CACXE,MAAM,CAACC,QAAQ,IAAIA,QAAQ,CAACC,IAAI,KAAK,OAAO,CAAC,CAC7CC,IAAI,CAACF,QAAQ,IAAIA,QAAQ,CAACF,IAAI,KAAKA,IAAI,CAAC;AACjD,CAAC;AAED,OAAO,MAAMK,iBAAiB,GAAGA,CAAC;EAAEC;AAA+B,CAAC,KAAK;EACrE,MAAMC,SAAS,GAAGX,UAAU,CAACW,SAAS,CAAC,CAAC;EACxC,MAAMR,SAAS,GAAGF,oBAAoB,CAAC,CAAC;EACxC,MAAMK,QAAQ,GAAGJ,uBAAuB,CAACC,SAAS,EAAEO,MAAM,CAACN,IAAI,CAAC;EAEhE,IAAI,CAACE,QAAQ,IAAIK,SAAS,EAAE;IACxB,oBAAOZ,KAAA,CAAAa,aAAA,CAACC,mBAAmB;MAACT,IAAI,EAAEM,MAAM,CAACN;IAAK,CAAE,CAAC;EACrD;EAEA,IAAIE,QAAQ,EAAE;IACV,oBAAOP,KAAA,CAAAa,aAAA,CAAAb,KAAA,CAAAe,QAAA,QAAGR,QAAQ,CAACS,OAAU,CAAC;EAClC;EAEA,OAAO,IAAI;AACf,CAAC;AAED,MAAMF,mBAAmB,GAAGA,CAAC;EAAET;AAAuB,CAAC,KAAK;EACxD,MAAMY,YAAY,GAAGZ,IAAI,gBACrBL,KAAA,CAAAa,aAAA,CAAAb,KAAA,CAAAe,QAAA,QAAE,MACQ,eAAAf,KAAA,CAAAa,aAAA,iBAASR,IAAa,CAAC,QAC/B,CAAC,gBAEHL,KAAA,CAAAa,aAAA,CAAAb,KAAA,CAAAe,QAAA,QAAE,MAAQ,CACb;EACD,oBACIf,KAAA,CAAAa,aAAA;IACIK,KAAK,EAAE;MACHC,OAAO,EAAE,MAAM;MACfC,MAAM,EAAE,OAAO;MACfC,eAAe,EAAE,SAAS;MAC1BC,cAAc,EAAE,QAAQ;MACxBC,UAAU,EAAE,QAAQ;MACpBC,IAAI,EAAE;IACV;EAAE,GACL,2BAC4B,EAACP,YAAY,EAAC,wCACtC,CAAC;AAEd,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"editorComponents/Fragment.js","sources":["../../src/editorComponents/Fragment.tsx"],"sourcesContent":["import React from \"react\";\nimport { contentSdk } from \"@webiny/website-builder-sdk\";\nimport { useDocumentFragments } from \"~/components/FragmentsProvider.js\";\nimport type { ComponentProps } from \"~/types.js\";\nimport type { DocumentFragments } from \"~/components/FragmentsProvider.js\";\n\ntype FragmentComponentProps = ComponentProps<{\n name: string;\n}>;\n\nconst findFixedFragmentByName = (fragments: DocumentFragments, name: string) => {\n return fragments\n .filter(fragment => fragment.type === \"fixed\")\n .find(fragment => fragment.name === name);\n};\n\nexport const FragmentComponent = ({ inputs }: FragmentComponentProps) => {\n const isEditing = contentSdk.isEditing();\n const fragments = useDocumentFragments();\n const fragment = findFixedFragmentByName(fragments, inputs.name);\n\n if (!fragment && isEditing) {\n return <FragmentPlaceholder name={inputs.name} />;\n }\n\n if (fragment) {\n return <>{fragment.element}</>;\n }\n\n return null;\n};\n\nconst FragmentPlaceholder = ({ name }: { name: string }) => {\n const fragmentName = name ? (\n <>\n &nbsp;<strong>{name}</strong>&nbsp;\n </>\n ) : (\n <>&nbsp;</>\n );\n return (\n <div\n style={{\n display: \"flex\",\n height: \"100px\",\n backgroundColor: \"#f4f4f4\",\n justifyContent: \"center\",\n alignItems: \"center\",\n fill: \"#ffffff\"\n }}\n >\n This is a placeholder for{fragmentName}content coming from your frontend app.\n </div>\n );\n};\n"],"names":["findFixedFragmentByName","fragments","name","fragment","FragmentComponent","inputs","isEditing","contentSdk","useDocumentFragments","FragmentPlaceholder","fragmentName"],"mappings":";;;AAUA,MAAMA,0BAA0B,CAACC,WAA8BC,OACpDD,UACF,MAAM,CAACE,CAAAA,WAAYA,AAAkB,YAAlBA,SAAS,IAAI,EAChC,IAAI,CAACA,CAAAA,WAAYA,SAAS,IAAI,KAAKD;AAGrC,MAAME,oBAAoB,CAAC,EAAEC,MAAM,EAA0B;IAChE,MAAMC,YAAYC,WAAW,SAAS;IACtC,MAAMN,YAAYO;IAClB,MAAML,WAAWH,wBAAwBC,WAAWI,OAAO,IAAI;IAE/D,IAAI,CAACF,YAAYG,WACb,OAAO,WAAP,GAAO,oBAACG,qBAAmBA;QAAC,MAAMJ,OAAO,IAAI;;IAGjD,IAAIF,UACA,OAAO,WAAP,GAAO,0CAAGA,SAAS,OAAO;IAG9B,OAAO;AACX;AAEA,MAAMM,sBAAsB,CAAC,EAAEP,IAAI,EAAoB;IACnD,MAAMQ,eAAeR,OAAO,WAAPA,GACjB,0CAAE,sBACQ,oBAAC,gBAAQA,OAAc,wBAGjC,0CAAE;IAEN,OAAO,WAAP,GACI,oBAAC;QACG,OAAO;YACH,SAAS;YACT,QAAQ;YACR,iBAAiB;YACjB,gBAAgB;YAChB,YAAY;YACZ,MAAM;QACV;OACH,6BAC6BQ,cAAa;AAGnD"}
@@ -1,19 +1,22 @@
1
1
  "use client";
2
-
3
2
  import { createTextInput } from "@webiny/website-builder-sdk";
4
3
  import { createComponent } from "../createComponent.js";
5
4
  import { FragmentComponent } from "./Fragment.js";
6
- export const Fragment = createComponent(FragmentComponent, {
7
- name: "Webiny/Fragment",
8
- label: "Fragment",
9
- group: "basic",
10
- image: `<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e8eaed"><path d="M120-120v-720h720v720H120Zm80-80h560v-560H200v560Zm0 0v-560 560Z"/></svg>`,
11
- inputs: [createTextInput({
12
- name: "name",
5
+ const Fragment = createComponent(FragmentComponent, {
6
+ name: "Webiny/Fragment",
13
7
  label: "Fragment",
14
- description: "Select fragment to display.",
15
- renderer: "Webiny/FragmentSelector"
16
- })]
8
+ useInAiContentGeneration: false,
9
+ group: "basic",
10
+ image: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M3 3v18h18V3H3zm16 16H5V5h14v14z"/></svg>',
11
+ inputs: [
12
+ createTextInput({
13
+ name: "name",
14
+ label: "Fragment",
15
+ description: "Select fragment to display.",
16
+ renderer: "Webiny/FragmentSelector"
17
+ })
18
+ ]
17
19
  });
20
+ export { Fragment };
18
21
 
19
22
  //# sourceMappingURL=Fragment.manifest.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createTextInput","createComponent","FragmentComponent","Fragment","name","label","group","image","inputs","description","renderer"],"sources":["Fragment.manifest.ts"],"sourcesContent":["\"use client\";\nimport { createTextInput } from \"@webiny/website-builder-sdk\";\nimport { createComponent } from \"~/createComponent.js\";\nimport { FragmentComponent } from \"./Fragment.js\";\n\nexport const Fragment = createComponent(FragmentComponent, {\n name: \"Webiny/Fragment\",\n label: \"Fragment\",\n group: \"basic\",\n image: `<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#e8eaed\"><path d=\"M120-120v-720h720v720H120Zm80-80h560v-560H200v560Zm0 0v-560 560Z\"/></svg>`,\n inputs: [\n createTextInput({\n name: \"name\",\n label: \"Fragment\",\n description: \"Select fragment to display.\",\n renderer: \"Webiny/FragmentSelector\"\n })\n ]\n});\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe,QAAQ,6BAA6B;AAC7D,SAASC,eAAe;AACxB,SAASC,iBAAiB;AAE1B,OAAO,MAAMC,QAAQ,GAAGF,eAAe,CAACC,iBAAiB,EAAE;EACvDE,IAAI,EAAE,iBAAiB;EACvBC,KAAK,EAAE,UAAU;EACjBC,KAAK,EAAE,OAAO;EACdC,KAAK,EAAE,+LAA+L;EACtMC,MAAM,EAAE,CACJR,eAAe,CAAC;IACZI,IAAI,EAAE,MAAM;IACZC,KAAK,EAAE,UAAU;IACjBI,WAAW,EAAE,6BAA6B;IAC1CC,QAAQ,EAAE;EACd,CAAC,CAAC;AAEV,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"editorComponents/Fragment.manifest.js","sources":["../../src/editorComponents/Fragment.manifest.ts"],"sourcesContent":["\"use client\";\nimport { createTextInput } from \"@webiny/website-builder-sdk\";\nimport { createComponent } from \"~/createComponent.js\";\nimport { FragmentComponent } from \"./Fragment.js\";\n\nexport const Fragment = createComponent(FragmentComponent, {\n name: \"Webiny/Fragment\",\n label: \"Fragment\",\n useInAiContentGeneration: false,\n group: \"basic\",\n image: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M3 3v18h18V3H3zm16 16H5V5h14v14z\"/></svg>`,\n inputs: [\n createTextInput({\n name: \"name\",\n label: \"Fragment\",\n description: \"Select fragment to display.\",\n renderer: \"Webiny/FragmentSelector\"\n })\n ]\n});\n"],"names":["Fragment","createComponent","FragmentComponent","createTextInput"],"mappings":";;;;AAKO,MAAMA,WAAWC,gBAAgBC,mBAAmB;IACvD,MAAM;IACN,OAAO;IACP,0BAA0B;IAC1B,OAAO;IACP,OAAO;IACP,QAAQ;QACJC,gBAAgB;YACZ,MAAM;YACN,OAAO;YACP,aAAa;YACb,UAAU;QACd;KACH;AACL"}
@@ -1,65 +1,37 @@
1
- import React from "react";
2
- export const GridColumnComponent = ({
3
- inputs
4
- }) => {
5
- return /*#__PURE__*/React.createElement(React.Fragment, null, inputs.children);
1
+ import react from "react";
2
+ const GridColumnComponent = ({ inputs })=>/*#__PURE__*/ react.createElement(react.Fragment, null, inputs.children);
3
+ const GridComponent = ({ inputs, styles, breakpoint })=>{
4
+ const { gridLayout = "12", columns, columnGap, stackAtBreakpoint, reverseWhenStacked } = inputs;
5
+ const rowConfig = gridLayout.split("-").map((size)=>parseInt(size));
6
+ const rows = [];
7
+ for(let i = 0; i < columns.length; i += rowConfig.length)rows.push(columns.slice(i, i + rowConfig.length));
8
+ const cellWidthReduction = columnGap ? columnGap - columnGap / rowConfig.length : 0;
9
+ const stackColumns = breakpoint === stackAtBreakpoint;
10
+ if (stackColumns) styles.flexDirection = reverseWhenStacked ? "column-reverse" : "column";
11
+ return /*#__PURE__*/ react.createElement("div", {
12
+ style: styles
13
+ }, rows.map((columns)=>columns.map((column, i)=>/*#__PURE__*/ react.createElement(Span, {
14
+ key: i,
15
+ stackColumns: stackColumns,
16
+ size: rowConfig[i],
17
+ reductionInPx: cellWidthReduction
18
+ }, /*#__PURE__*/ react.createElement(GridColumnComponent, {
19
+ key: i,
20
+ inputs: {
21
+ children: column.children
22
+ }
23
+ })))));
6
24
  };
7
- export const GridComponent = ({
8
- inputs,
9
- styles,
10
- breakpoint
11
- }) => {
12
- const {
13
- gridLayout = "12",
14
- columns,
15
- columnGap,
16
- stackAtBreakpoint,
17
- reverseWhenStacked
18
- } = inputs;
19
- const rowConfig = gridLayout.split("-").map(size => parseInt(size));
20
- const rows = [];
21
-
22
- // Chunk columns into rows
23
- for (let i = 0; i < columns.length; i += rowConfig.length) {
24
- rows.push(columns.slice(i, i + rowConfig.length));
25
- }
26
-
27
- // Number of pixels we need to subtract from each cell to ensure they fit in the grid with column gap
28
- const cellWidthReduction = columnGap ? columnGap - columnGap / rowConfig.length : 0;
29
- const stackColumns = breakpoint === stackAtBreakpoint;
30
- if (stackColumns) {
31
- styles.flexDirection = reverseWhenStacked ? "column-reverse" : "column";
32
- }
33
- return /*#__PURE__*/React.createElement("div", {
34
- style: styles
35
- }, rows.map(columns => {
36
- return columns.map((column, i) => /*#__PURE__*/React.createElement(Span, {
37
- key: i,
38
- stackColumns: stackColumns,
39
- size: rowConfig[i],
40
- reductionInPx: cellWidthReduction
41
- }, /*#__PURE__*/React.createElement(GridColumnComponent, {
42
- key: i,
43
- inputs: {
44
- children: column.children
45
- }
46
- })));
47
- }));
48
- };
49
- const Span = ({
50
- size,
51
- children,
52
- reductionInPx,
53
- stackColumns
54
- }) => {
55
- const width = stackColumns ? "100%" : `calc(${size / 12 * 100}% - ${reductionInPx}px)`;
56
- return /*#__PURE__*/React.createElement("div", {
57
- style: {
58
- flex: `0 0 ${width}`,
59
- maxWidth: width,
60
- boxSizing: "border-box"
61
- }
62
- }, children);
25
+ const Span = ({ size, children, reductionInPx, stackColumns })=>{
26
+ const width = stackColumns ? "100%" : `calc(${size / 12 * 100}% - ${reductionInPx}px)`;
27
+ return /*#__PURE__*/ react.createElement("div", {
28
+ style: {
29
+ flex: `0 0 ${width}`,
30
+ maxWidth: width,
31
+ boxSizing: "border-box"
32
+ }
33
+ }, children);
63
34
  };
35
+ export { GridColumnComponent, GridComponent };
64
36
 
65
37
  //# sourceMappingURL=Grid.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","GridColumnComponent","inputs","createElement","Fragment","children","GridComponent","styles","breakpoint","gridLayout","columns","columnGap","stackAtBreakpoint","reverseWhenStacked","rowConfig","split","map","size","parseInt","rows","i","length","push","slice","cellWidthReduction","stackColumns","flexDirection","style","column","Span","key","reductionInPx","width","flex","maxWidth","boxSizing"],"sources":["Grid.tsx"],"sourcesContent":["import React from \"react\";\nimport type { ComponentProps, ComponentPropsWithChildren } from \"~/types.js\";\n\nexport const GridColumnComponent = ({\n inputs\n}: {\n inputs: ComponentPropsWithChildren[\"inputs\"];\n}) => {\n return <>{inputs.children}</>;\n};\n\nexport interface Column {\n children: React.ReactNode;\n}\n\ntype GridProps = ComponentProps<{\n gridLayout: string;\n rowCount: number;\n rowGap: number;\n columnGap: number;\n columns: Column[];\n stackAtBreakpoint?: string;\n reverseWhenStacked?: boolean;\n}>;\n\nexport const GridComponent = ({ inputs, styles, breakpoint }: GridProps) => {\n const { gridLayout = \"12\", columns, columnGap, stackAtBreakpoint, reverseWhenStacked } = inputs;\n const rowConfig = gridLayout.split(\"-\").map(size => parseInt(size));\n const rows: Column[][] = [];\n\n // Chunk columns into rows\n for (let i = 0; i < columns.length; i += rowConfig.length) {\n rows.push(columns.slice(i, i + rowConfig.length));\n }\n\n // Number of pixels we need to subtract from each cell to ensure they fit in the grid with column gap\n const cellWidthReduction = columnGap ? columnGap - columnGap / rowConfig.length : 0;\n\n const stackColumns = breakpoint === stackAtBreakpoint;\n\n if (stackColumns) {\n styles.flexDirection = reverseWhenStacked ? \"column-reverse\" : \"column\";\n }\n\n return (\n <div style={styles}>\n {rows.map(columns => {\n return columns.map((column, i) => (\n <Span\n key={i}\n stackColumns={stackColumns}\n size={rowConfig[i]}\n reductionInPx={cellWidthReduction}\n >\n <GridColumnComponent key={i} inputs={{ children: column.children }} />\n </Span>\n ));\n })}\n </div>\n );\n};\n\ninterface SpanProps {\n size: number;\n reductionInPx: number;\n stackColumns: boolean;\n children: React.ReactNode;\n}\n\nconst Span = ({ size, children, reductionInPx, stackColumns }: SpanProps) => {\n const width = stackColumns ? \"100%\" : `calc(${(size / 12) * 100}% - ${reductionInPx}px)`;\n\n return (\n <div\n style={{\n flex: `0 0 ${width}`,\n maxWidth: width,\n boxSizing: \"border-box\"\n }}\n >\n {children}\n </div>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAGzB,OAAO,MAAMC,mBAAmB,GAAGA,CAAC;EAChCC;AAGJ,CAAC,KAAK;EACF,oBAAOF,KAAA,CAAAG,aAAA,CAAAH,KAAA,CAAAI,QAAA,QAAGF,MAAM,CAACG,QAAW,CAAC;AACjC,CAAC;AAgBD,OAAO,MAAMC,aAAa,GAAGA,CAAC;EAAEJ,MAAM;EAAEK,MAAM;EAAEC;AAAsB,CAAC,KAAK;EACxE,MAAM;IAAEC,UAAU,GAAG,IAAI;IAAEC,OAAO;IAAEC,SAAS;IAAEC,iBAAiB;IAAEC;EAAmB,CAAC,GAAGX,MAAM;EAC/F,MAAMY,SAAS,GAAGL,UAAU,CAACM,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAACC,IAAI,IAAIC,QAAQ,CAACD,IAAI,CAAC,CAAC;EACnE,MAAME,IAAgB,GAAG,EAAE;;EAE3B;EACA,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGV,OAAO,CAACW,MAAM,EAAED,CAAC,IAAIN,SAAS,CAACO,MAAM,EAAE;IACvDF,IAAI,CAACG,IAAI,CAACZ,OAAO,CAACa,KAAK,CAACH,CAAC,EAAEA,CAAC,GAAGN,SAAS,CAACO,MAAM,CAAC,CAAC;EACrD;;EAEA;EACA,MAAMG,kBAAkB,GAAGb,SAAS,GAAGA,SAAS,GAAGA,SAAS,GAAGG,SAAS,CAACO,MAAM,GAAG,CAAC;EAEnF,MAAMI,YAAY,GAAGjB,UAAU,KAAKI,iBAAiB;EAErD,IAAIa,YAAY,EAAE;IACdlB,MAAM,CAACmB,aAAa,GAAGb,kBAAkB,GAAG,gBAAgB,GAAG,QAAQ;EAC3E;EAEA,oBACIb,KAAA,CAAAG,aAAA;IAAKwB,KAAK,EAAEpB;EAAO,GACdY,IAAI,CAACH,GAAG,CAACN,OAAO,IAAI;IACjB,OAAOA,OAAO,CAACM,GAAG,CAAC,CAACY,MAAM,EAAER,CAAC,kBACzBpB,KAAA,CAAAG,aAAA,CAAC0B,IAAI;MACDC,GAAG,EAAEV,CAAE;MACPK,YAAY,EAAEA,YAAa;MAC3BR,IAAI,EAAEH,SAAS,CAACM,CAAC,CAAE;MACnBW,aAAa,EAAEP;IAAmB,gBAElCxB,KAAA,CAAAG,aAAA,CAACF,mBAAmB;MAAC6B,GAAG,EAAEV,CAAE;MAAClB,MAAM,EAAE;QAAEG,QAAQ,EAAEuB,MAAM,CAACvB;MAAS;IAAE,CAAE,CACnE,CACT,CAAC;EACN,CAAC,CACA,CAAC;AAEd,CAAC;AASD,MAAMwB,IAAI,GAAGA,CAAC;EAAEZ,IAAI;EAAEZ,QAAQ;EAAE0B,aAAa;EAAEN;AAAwB,CAAC,KAAK;EACzE,MAAMO,KAAK,GAAGP,YAAY,GAAG,MAAM,GAAG,QAASR,IAAI,GAAG,EAAE,GAAI,GAAG,OAAOc,aAAa,KAAK;EAExF,oBACI/B,KAAA,CAAAG,aAAA;IACIwB,KAAK,EAAE;MACHM,IAAI,EAAE,OAAOD,KAAK,EAAE;MACpBE,QAAQ,EAAEF,KAAK;MACfG,SAAS,EAAE;IACf;EAAE,GAED9B,QACA,CAAC;AAEd,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"editorComponents/Grid.js","sources":["../../src/editorComponents/Grid.tsx"],"sourcesContent":["import React from \"react\";\nimport type { ComponentProps, ComponentPropsWithChildren } from \"~/types.js\";\n\nexport const GridColumnComponent = ({\n inputs\n}: {\n inputs: ComponentPropsWithChildren[\"inputs\"];\n}) => {\n return <>{inputs.children}</>;\n};\n\nexport interface Column {\n children: React.ReactNode;\n}\n\ntype GridProps = ComponentProps<{\n gridLayout: string;\n rowCount: number;\n rowGap: number;\n columnGap: number;\n columns: Column[];\n stackAtBreakpoint?: string;\n reverseWhenStacked?: boolean;\n}>;\n\nexport const GridComponent = ({ inputs, styles, breakpoint }: GridProps) => {\n const { gridLayout = \"12\", columns, columnGap, stackAtBreakpoint, reverseWhenStacked } = inputs;\n const rowConfig = gridLayout.split(\"-\").map(size => parseInt(size));\n const rows: Column[][] = [];\n\n // Chunk columns into rows\n for (let i = 0; i < columns.length; i += rowConfig.length) {\n rows.push(columns.slice(i, i + rowConfig.length));\n }\n\n // Number of pixels we need to subtract from each cell to ensure they fit in the grid with column gap\n const cellWidthReduction = columnGap ? columnGap - columnGap / rowConfig.length : 0;\n\n const stackColumns = breakpoint === stackAtBreakpoint;\n\n if (stackColumns) {\n styles.flexDirection = reverseWhenStacked ? \"column-reverse\" : \"column\";\n }\n\n return (\n <div style={styles}>\n {rows.map(columns => {\n return columns.map((column, i) => (\n <Span\n key={i}\n stackColumns={stackColumns}\n size={rowConfig[i]}\n reductionInPx={cellWidthReduction}\n >\n <GridColumnComponent key={i} inputs={{ children: column.children }} />\n </Span>\n ));\n })}\n </div>\n );\n};\n\ninterface SpanProps {\n size: number;\n reductionInPx: number;\n stackColumns: boolean;\n children: React.ReactNode;\n}\n\nconst Span = ({ size, children, reductionInPx, stackColumns }: SpanProps) => {\n const width = stackColumns ? \"100%\" : `calc(${(size / 12) * 100}% - ${reductionInPx}px)`;\n\n return (\n <div\n style={{\n flex: `0 0 ${width}`,\n maxWidth: width,\n boxSizing: \"border-box\"\n }}\n >\n {children}\n </div>\n );\n};\n"],"names":["GridColumnComponent","inputs","GridComponent","styles","breakpoint","gridLayout","columns","columnGap","stackAtBreakpoint","reverseWhenStacked","rowConfig","size","parseInt","rows","i","cellWidthReduction","stackColumns","column","Span","children","reductionInPx","width"],"mappings":";AAGO,MAAMA,sBAAsB,CAAC,EAChCC,MAAM,EAGT,GACU,WAAP,GAAO,0CAAGA,OAAO,QAAQ;AAiBtB,MAAMC,gBAAgB,CAAC,EAAED,MAAM,EAAEE,MAAM,EAAEC,UAAU,EAAa;IACnE,MAAM,EAAEC,aAAa,IAAI,EAAEC,OAAO,EAAEC,SAAS,EAAEC,iBAAiB,EAAEC,kBAAkB,EAAE,GAAGR;IACzF,MAAMS,YAAYL,WAAW,KAAK,CAAC,KAAK,GAAG,CAACM,CAAAA,OAAQC,SAASD;IAC7D,MAAME,OAAmB,EAAE;IAG3B,IAAK,IAAIC,IAAI,GAAGA,IAAIR,QAAQ,MAAM,EAAEQ,KAAKJ,UAAU,MAAM,CACrDG,KAAK,IAAI,CAACP,QAAQ,KAAK,CAACQ,GAAGA,IAAIJ,UAAU,MAAM;IAInD,MAAMK,qBAAqBR,YAAYA,YAAYA,YAAYG,UAAU,MAAM,GAAG;IAElF,MAAMM,eAAeZ,eAAeI;IAEpC,IAAIQ,cACAb,OAAO,aAAa,GAAGM,qBAAqB,mBAAmB;IAGnE,OAAO,WAAP,GACI,oBAAC;QAAI,OAAON;OACPU,KAAK,GAAG,CAACP,CAAAA,UACCA,QAAQ,GAAG,CAAC,CAACW,QAAQH,IAAAA,WAAAA,GACxB,oBAACI,MAAIA;gBACD,KAAKJ;gBACL,cAAcE;gBACd,MAAMN,SAAS,CAACI,EAAE;gBAClB,eAAeC;6BAEf,oBAACf,qBAAmBA;gBAAC,KAAKc;gBAAG,QAAQ;oBAAE,UAAUG,OAAO,QAAQ;gBAAC;;AAMzF;AASA,MAAMC,OAAO,CAAC,EAAEP,IAAI,EAAEQ,QAAQ,EAAEC,aAAa,EAAEJ,YAAY,EAAa;IACpE,MAAMK,QAAQL,eAAe,SAAS,CAAC,KAAK,EAAGL,OAAO,KAAM,IAAI,IAAI,EAAES,cAAc,GAAG,CAAC;IAExF,OAAO,WAAP,GACI,oBAAC;QACG,OAAO;YACH,MAAM,CAAC,IAAI,EAAEC,OAAO;YACpB,UAAUA;YACV,WAAW;QACf;OAECF;AAGb"}