@webiny/website-builder-react 0.0.0-unstable.6f45466a1d → 0.0.0-unstable.7be00a75a9

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 (82) hide show
  1. package/components/ConnectToEditor.js +16 -18
  2. package/components/ConnectToEditor.js.map +1 -1
  3. package/components/DocumentFragment.js +5 -7
  4. package/components/DocumentFragment.js.map +1 -1
  5. package/components/DocumentRenderer.js +37 -46
  6. package/components/DocumentRenderer.js.map +1 -1
  7. package/components/DocumentStoreProvider.js +15 -21
  8. package/components/DocumentStoreProvider.js.map +1 -1
  9. package/components/EditingElementRenderer/EditingElementRenderer.js +31 -35
  10. package/components/EditingElementRenderer/EditingElementRenderer.js.map +1 -1
  11. package/components/EditingElementRenderer/EditingElementRenderer.presenter.js +29 -35
  12. package/components/EditingElementRenderer/EditingElementRenderer.presenter.js.map +1 -1
  13. package/components/EditingElementRenderer/index.js +0 -2
  14. package/components/ElementIndexProvider.js +9 -14
  15. package/components/ElementIndexProvider.js.map +1 -1
  16. package/components/ElementRenderer.js +11 -16
  17. package/components/ElementRenderer.js.map +1 -1
  18. package/components/ElementSlot.js +6 -9
  19. package/components/ElementSlot.js.map +1 -1
  20. package/components/ElementSlotDepthProvider.js +9 -14
  21. package/components/ElementSlotDepthProvider.js.map +1 -1
  22. package/components/FragmentsProvider.js +30 -36
  23. package/components/FragmentsProvider.js.map +1 -1
  24. package/components/LiveElementRenderer.js +53 -68
  25. package/components/LiveElementRenderer.js.map +1 -1
  26. package/components/LiveElementSlot.js +12 -14
  27. package/components/LiveElementSlot.js.map +1 -1
  28. package/components/PreviewElementSlot.js +17 -23
  29. package/components/PreviewElementSlot.js.map +1 -1
  30. package/components/index.js +0 -2
  31. package/components/useBindingsForElement.d.ts +80 -48
  32. package/components/useBindingsForElement.js +13 -11
  33. package/components/useBindingsForElement.js.map +1 -1
  34. package/components/useDocumentState.js +4 -3
  35. package/components/useDocumentState.js.map +1 -1
  36. package/components/useSelectFromState.js +29 -35
  37. package/components/useSelectFromState.js.map +1 -1
  38. package/components/useViewportInfo.js +5 -6
  39. package/components/useViewportInfo.js.map +1 -1
  40. package/createComponent.js +26 -30
  41. package/createComponent.js.map +1 -1
  42. package/createComponent.test.js +108 -119
  43. package/createComponent.test.js.map +1 -1
  44. package/editorComponents/Box.js +3 -6
  45. package/editorComponents/Box.js.map +1 -1
  46. package/editorComponents/Box.manifest.js +15 -14
  47. package/editorComponents/Box.manifest.js.map +1 -1
  48. package/editorComponents/Fragment.js +23 -32
  49. package/editorComponents/Fragment.js.map +1 -1
  50. package/editorComponents/Fragment.manifest.js +14 -11
  51. package/editorComponents/Fragment.manifest.js.map +1 -1
  52. package/editorComponents/Grid.js +33 -61
  53. package/editorComponents/Grid.js.map +1 -1
  54. package/editorComponents/Grid.manifest.js +163 -166
  55. package/editorComponents/Grid.manifest.js.map +1 -1
  56. package/editorComponents/GridColumn.js +3 -6
  57. package/editorComponents/GridColumn.js.map +1 -1
  58. package/editorComponents/GridColumn.manifest.js +20 -17
  59. package/editorComponents/GridColumn.manifest.js.map +1 -1
  60. package/editorComponents/Image.js +99 -119
  61. package/editorComponents/Image.js.map +1 -1
  62. package/editorComponents/Image.manifest.js +33 -32
  63. package/editorComponents/Image.manifest.js.map +1 -1
  64. package/editorComponents/Lexical.js +13 -21
  65. package/editorComponents/Lexical.js.map +1 -1
  66. package/editorComponents/Lexical.manifest.js +17 -14
  67. package/editorComponents/Lexical.manifest.js.map +1 -1
  68. package/editorComponents/Root.js +3 -6
  69. package/editorComponents/Root.js.map +1 -1
  70. package/editorComponents/Root.manifest.js +7 -6
  71. package/editorComponents/Root.manifest.js.map +1 -1
  72. package/editorComponents/index.js +10 -1
  73. package/editorComponents/index.js.map +1 -1
  74. package/index.d.ts +2 -2
  75. package/index.js +1 -3
  76. package/package.json +14 -14
  77. package/types.d.ts +36 -1
  78. package/types.js +0 -3
  79. package/components/EditingElementRenderer/index.js.map +0 -1
  80. package/components/index.js.map +0 -1
  81. package/index.js.map +0 -1
  82. package/types.js.map +0 -1
@@ -1,39 +1,33 @@
1
- import deepEqual from "deep-equal";
2
- import { useState, useEffect, useMemo } from "react";
1
+ import deep_equal from "deep-equal";
2
+ import { useEffect, useMemo, useState } from "react";
3
3
  import { reaction } from "mobx";
4
- /**
5
- * Subscribe to part of the document state.
6
- * @param selector Pick the slice of state you care about.
7
- * @param equals (optional) comparator, defaults to Object.is
8
- */
9
- export function useSelectFromState(getState, selector, deps = [], equals = deepEqual) {
10
- // Pull the initial slice synchronously
11
- const initialValue = useMemo(() => selector(getState()), deps);
12
- const [value, setValue] = useState(initialValue);
13
- useEffect(() => {
14
- setValue(selector(getState())); // reset state on dep change
15
- }, deps);
16
- useEffect(() => {
17
- // reaction tracks selector(doc) and only fires when newVal !== oldVal
18
- const disposer = reaction(() => {
19
- const state = getState();
20
- return selector(state);
21
- }, (newValue, oldValue) => {
22
- if (!equals(oldValue, newValue)) {
23
- setValue(newValue);
24
- }
25
- }, {
26
- // use your comparator to decide if newValue “really” changed
27
- equals,
28
- // we already set initial via useState
29
- fireImmediately: false
30
- });
31
- return () => {
32
- // clean up when the component unmounts
33
- disposer();
34
- };
35
- }, [getState, selector, equals, ...deps]);
36
- return value;
4
+ function useSelectFromState(getState, selector, deps = [], equals = deep_equal) {
5
+ const initialValue = useMemo(()=>selector(getState()), deps);
6
+ const [value, setValue] = useState(initialValue);
7
+ useEffect(()=>{
8
+ setValue(selector(getState()));
9
+ }, deps);
10
+ useEffect(()=>{
11
+ const disposer = reaction(()=>{
12
+ const state = getState();
13
+ return selector(state);
14
+ }, (newValue, oldValue)=>{
15
+ if (!equals(oldValue, newValue)) setValue(newValue);
16
+ }, {
17
+ equals,
18
+ fireImmediately: false
19
+ });
20
+ return ()=>{
21
+ disposer();
22
+ };
23
+ }, [
24
+ getState,
25
+ selector,
26
+ equals,
27
+ ...deps
28
+ ]);
29
+ return value;
37
30
  }
31
+ export { useSelectFromState };
38
32
 
39
33
  //# sourceMappingURL=useSelectFromState.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["deepEqual","useState","useEffect","useMemo","reaction","useSelectFromState","getState","selector","deps","equals","initialValue","value","setValue","disposer","state","newValue","oldValue","fireImmediately"],"sources":["useSelectFromState.ts"],"sourcesContent":["import deepEqual from \"deep-equal\";\nimport { useState, useEffect, useMemo } from \"react\";\nimport type { IReactionDisposer } from \"mobx\";\nimport { reaction } from \"mobx\";\n\ntype Equals<T> = (a: T, b: T) => boolean;\n\n/**\n * Subscribe to part of the document state.\n * @param selector Pick the slice of state you care about.\n * @param equals (optional) comparator, defaults to Object.is\n */\nexport function useSelectFromState<TState, T>(\n getState: () => TState,\n selector: (doc: TState) => T,\n deps: React.DependencyList = [],\n equals: Equals<T> = deepEqual\n): T {\n // Pull the initial slice synchronously\n const initialValue = useMemo(() => selector(getState()), deps);\n const [value, setValue] = useState<T>(initialValue);\n\n useEffect(() => {\n setValue(selector(getState())); // reset state on dep change\n }, deps);\n\n useEffect(() => {\n // reaction tracks selector(doc) and only fires when newVal !== oldVal\n const disposer: IReactionDisposer = reaction(\n () => {\n const state = getState();\n\n return selector(state);\n },\n (newValue, oldValue) => {\n if (!equals(oldValue, newValue)) {\n setValue(newValue);\n }\n },\n {\n // use your comparator to decide if newValue “really” changed\n equals,\n // we already set initial via useState\n fireImmediately: false\n }\n );\n\n return () => {\n // clean up when the component unmounts\n disposer();\n };\n }, [getState, selector, equals, ...deps]);\n\n return value;\n}\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,YAAY;AAClC,SAASC,QAAQ,EAAEC,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAEpD,SAASC,QAAQ,QAAQ,MAAM;AAI/B;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAC9BC,QAAsB,EACtBC,QAA4B,EAC5BC,IAA0B,GAAG,EAAE,EAC/BC,MAAiB,GAAGT,SAAS,EAC5B;EACD;EACA,MAAMU,YAAY,GAAGP,OAAO,CAAC,MAAMI,QAAQ,CAACD,QAAQ,CAAC,CAAC,CAAC,EAAEE,IAAI,CAAC;EAC9D,MAAM,CAACG,KAAK,EAAEC,QAAQ,CAAC,GAAGX,QAAQ,CAAIS,YAAY,CAAC;EAEnDR,SAAS,CAAC,MAAM;IACZU,QAAQ,CAACL,QAAQ,CAACD,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;EACpC,CAAC,EAAEE,IAAI,CAAC;EAERN,SAAS,CAAC,MAAM;IACZ;IACA,MAAMW,QAA2B,GAAGT,QAAQ,CACxC,MAAM;MACF,MAAMU,KAAK,GAAGR,QAAQ,CAAC,CAAC;MAExB,OAAOC,QAAQ,CAACO,KAAK,CAAC;IAC1B,CAAC,EACD,CAACC,QAAQ,EAAEC,QAAQ,KAAK;MACpB,IAAI,CAACP,MAAM,CAACO,QAAQ,EAAED,QAAQ,CAAC,EAAE;QAC7BH,QAAQ,CAACG,QAAQ,CAAC;MACtB;IACJ,CAAC,EACD;MACI;MACAN,MAAM;MACN;MACAQ,eAAe,EAAE;IACrB,CACJ,CAAC;IAED,OAAO,MAAM;MACT;MACAJ,QAAQ,CAAC,CAAC;IACd,CAAC;EACL,CAAC,EAAE,CAACP,QAAQ,EAAEC,QAAQ,EAAEE,MAAM,EAAE,GAAGD,IAAI,CAAC,CAAC;EAEzC,OAAOG,KAAK;AAChB","ignoreList":[]}
1
+ {"version":3,"file":"components/useSelectFromState.js","sources":["../../src/components/useSelectFromState.ts"],"sourcesContent":["import deepEqual from \"deep-equal\";\nimport { useState, useEffect, useMemo } from \"react\";\nimport type { IReactionDisposer } from \"mobx\";\nimport { reaction } from \"mobx\";\n\ntype Equals<T> = (a: T, b: T) => boolean;\n\n/**\n * Subscribe to part of the document state.\n * @param selector Pick the slice of state you care about.\n * @param equals (optional) comparator, defaults to Object.is\n */\nexport function useSelectFromState<TState, T>(\n getState: () => TState,\n selector: (doc: TState) => T,\n deps: React.DependencyList = [],\n equals: Equals<T> = deepEqual\n): T {\n // Pull the initial slice synchronously\n const initialValue = useMemo(() => selector(getState()), deps);\n const [value, setValue] = useState<T>(initialValue);\n\n useEffect(() => {\n setValue(selector(getState())); // reset state on dep change\n }, deps);\n\n useEffect(() => {\n // reaction tracks selector(doc) and only fires when newVal !== oldVal\n const disposer: IReactionDisposer = reaction(\n () => {\n const state = getState();\n\n return selector(state);\n },\n (newValue, oldValue) => {\n if (!equals(oldValue, newValue)) {\n setValue(newValue);\n }\n },\n {\n // use your comparator to decide if newValue “really” changed\n equals,\n // we already set initial via useState\n fireImmediately: false\n }\n );\n\n return () => {\n // clean up when the component unmounts\n disposer();\n };\n }, [getState, selector, equals, ...deps]);\n\n return value;\n}\n"],"names":["useSelectFromState","getState","selector","deps","equals","deepEqual","initialValue","useMemo","value","setValue","useState","useEffect","disposer","reaction","state","newValue","oldValue"],"mappings":";;;AAYO,SAASA,mBACZC,QAAsB,EACtBC,QAA4B,EAC5BC,OAA6B,EAAE,EAC/BC,SAAoBC,UAAS;IAG7B,MAAMC,eAAeC,QAAQ,IAAML,SAASD,aAAaE;IACzD,MAAM,CAACK,OAAOC,SAAS,GAAGC,SAAYJ;IAEtCK,UAAU;QACNF,SAASP,SAASD;IACtB,GAAGE;IAEHQ,UAAU;QAEN,MAAMC,WAA8BC,SAChC;YACI,MAAMC,QAAQb;YAEd,OAAOC,SAASY;QACpB,GACA,CAACC,UAAUC;YACP,IAAI,CAACZ,OAAOY,UAAUD,WAClBN,SAASM;QAEjB,GACA;YAEIX;YAEA,iBAAiB;QACrB;QAGJ,OAAO;YAEHQ;QACJ;IACJ,GAAG;QAACX;QAAUC;QAAUE;WAAWD;KAAK;IAExC,OAAOK;AACX"}
@@ -1,11 +1,10 @@
1
1
  import { useEffect, useState } from "react";
2
2
  import { viewportManager } from "@webiny/website-builder-sdk";
3
- export const useViewport = () => {
4
- const [viewport, setViewport] = useState(viewportManager.getViewport());
5
- useEffect(() => {
6
- return viewportManager.onViewportChangeEnd(setViewport);
7
- }, []);
8
- return viewport;
3
+ const useViewport = ()=>{
4
+ const [viewport, setViewport] = useState(viewportManager.getViewport());
5
+ useEffect(()=>viewportManager.onViewportChangeEnd(setViewport), []);
6
+ return viewport;
9
7
  };
8
+ export { useViewport };
10
9
 
11
10
  //# sourceMappingURL=useViewportInfo.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useState","viewportManager","useViewport","viewport","setViewport","getViewport","onViewportChangeEnd"],"sources":["useViewportInfo.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport { viewportManager } from \"@webiny/website-builder-sdk\";\n\nexport const useViewport = () => {\n const [viewport, setViewport] = useState(viewportManager.getViewport());\n\n useEffect(() => {\n return viewportManager.onViewportChangeEnd(setViewport);\n }, []);\n\n return viewport;\n};\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,eAAe,QAAQ,6BAA6B;AAE7D,OAAO,MAAMC,WAAW,GAAGA,CAAA,KAAM;EAC7B,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGJ,QAAQ,CAACC,eAAe,CAACI,WAAW,CAAC,CAAC,CAAC;EAEvEN,SAAS,CAAC,MAAM;IACZ,OAAOE,eAAe,CAACK,mBAAmB,CAACF,WAAW,CAAC;EAC3D,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOD,QAAQ;AACnB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"components/useViewportInfo.js","sources":["../../src/components/useViewportInfo.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport { viewportManager } from \"@webiny/website-builder-sdk\";\n\nexport const useViewport = () => {\n const [viewport, setViewport] = useState(viewportManager.getViewport());\n\n useEffect(() => {\n return viewportManager.onViewportChangeEnd(setViewport);\n }, []);\n\n return viewport;\n};\n"],"names":["useViewport","viewport","setViewport","useState","viewportManager","useEffect"],"mappings":";;AAGO,MAAMA,cAAc;IACvB,MAAM,CAACC,UAAUC,YAAY,GAAGC,SAASC,gBAAgB,WAAW;IAEpEC,UAAU,IACCD,gBAAgB,mBAAmB,CAACF,cAC5C,EAAE;IAEL,OAAOD;AACX"}
@@ -1,36 +1,32 @@
1
1
  import { createSlotInput } from "@webiny/website-builder-sdk";
2
- export function createComponent(component, manifest) {
3
- const inputs = [];
4
-
5
- // Normalize inputs to always be an array of objects.
6
-
7
- if (Array.isArray(manifest.inputs)) {
8
- inputs.push(...manifest.inputs);
9
- } else {
10
- const inputsObject = manifest.inputs ?? {};
11
- Object.keys(inputsObject).forEach(name => {
12
- inputs.push({
13
- ...inputsObject[name],
14
- name
15
- });
16
- });
17
- }
18
- const acceptsChildren = manifest.acceptsChildren;
19
- if (acceptsChildren) {
20
- const hasChildren = inputs.some(input => input.name === "children");
21
- if (!hasChildren) {
22
- inputs.push(createSlotInput({
23
- name: "children"
24
- }));
2
+ function createComponent(component, manifest) {
3
+ const inputs = [];
4
+ if (Array.isArray(manifest.inputs)) inputs.push(...manifest.inputs);
5
+ else {
6
+ const inputsObject = manifest.inputs ?? {};
7
+ Object.keys(inputsObject).forEach((name)=>{
8
+ inputs.push({
9
+ ...inputsObject[name],
10
+ name
11
+ });
12
+ });
25
13
  }
26
- }
27
- return {
28
- component,
29
- manifest: {
30
- ...manifest,
31
- inputs
14
+ const acceptsChildren = manifest.acceptsChildren;
15
+ if (acceptsChildren) {
16
+ const hasChildren = inputs.some((input)=>"children" === input.name);
17
+ if (!hasChildren) inputs.push(createSlotInput({
18
+ name: "children"
19
+ }));
32
20
  }
33
- };
21
+ return {
22
+ component,
23
+ manifest: {
24
+ ...manifest,
25
+ tags: manifest.tags ?? [],
26
+ inputs
27
+ }
28
+ };
34
29
  }
30
+ export { createComponent };
35
31
 
36
32
  //# sourceMappingURL=createComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createSlotInput","createComponent","component","manifest","inputs","Array","isArray","push","inputsObject","Object","keys","forEach","name","acceptsChildren","hasChildren","some","input"],"sources":["createComponent.ts"],"sourcesContent":["import type {\n Component,\n ComponentInput,\n ComponentManifestInput,\n InputFactory\n} from \"@webiny/website-builder-sdk\";\nimport { createSlotInput } from \"@webiny/website-builder-sdk\";\nimport type { ExtractInputs } from \"~/types.js\";\n\nexport function createComponent<\n TComponent extends (props: any) => any,\n TInputs extends ExtractInputs<Parameters<TComponent>[0]>\n>(component: TComponent, manifest: ComponentManifestInput<TInputs>): Component {\n const inputs: ComponentInput[] = [];\n\n // Normalize inputs to always be an array of objects.\n\n if (Array.isArray(manifest.inputs)) {\n inputs.push(...manifest.inputs);\n } else {\n const inputsObject: Record<string, InputFactory<any>> = manifest.inputs ?? {};\n Object.keys(inputsObject).forEach((name: string) => {\n inputs.push({ ...inputsObject[name], name });\n });\n }\n\n const acceptsChildren = manifest.acceptsChildren;\n\n if (acceptsChildren) {\n const hasChildren = inputs.some(input => input.name === \"children\");\n if (!hasChildren) {\n inputs.push(createSlotInput({ name: \"children\" }));\n }\n }\n\n return { component, manifest: { ...manifest, inputs } };\n}\n"],"mappings":"AAMA,SAASA,eAAe,QAAQ,6BAA6B;AAG7D,OAAO,SAASC,eAAeA,CAG7BC,SAAqB,EAAEC,QAAyC,EAAa;EAC3E,MAAMC,MAAwB,GAAG,EAAE;;EAEnC;;EAEA,IAAIC,KAAK,CAACC,OAAO,CAACH,QAAQ,CAACC,MAAM,CAAC,EAAE;IAChCA,MAAM,CAACG,IAAI,CAAC,GAAGJ,QAAQ,CAACC,MAAM,CAAC;EACnC,CAAC,MAAM;IACH,MAAMI,YAA+C,GAAGL,QAAQ,CAACC,MAAM,IAAI,CAAC,CAAC;IAC7EK,MAAM,CAACC,IAAI,CAACF,YAAY,CAAC,CAACG,OAAO,CAAEC,IAAY,IAAK;MAChDR,MAAM,CAACG,IAAI,CAAC;QAAE,GAAGC,YAAY,CAACI,IAAI,CAAC;QAAEA;MAAK,CAAC,CAAC;IAChD,CAAC,CAAC;EACN;EAEA,MAAMC,eAAe,GAAGV,QAAQ,CAACU,eAAe;EAEhD,IAAIA,eAAe,EAAE;IACjB,MAAMC,WAAW,GAAGV,MAAM,CAACW,IAAI,CAACC,KAAK,IAAIA,KAAK,CAACJ,IAAI,KAAK,UAAU,CAAC;IACnE,IAAI,CAACE,WAAW,EAAE;MACdV,MAAM,CAACG,IAAI,CAACP,eAAe,CAAC;QAAEY,IAAI,EAAE;MAAW,CAAC,CAAC,CAAC;IACtD;EACJ;EAEA,OAAO;IAAEV,SAAS;IAAEC,QAAQ,EAAE;MAAE,GAAGA,QAAQ;MAAEC;IAAO;EAAE,CAAC;AAC3D","ignoreList":[]}
1
+ {"version":3,"file":"createComponent.js","sources":["../src/createComponent.ts"],"sourcesContent":["import type {\n Component,\n ComponentInput,\n ComponentManifest,\n ComponentManifestInput,\n InputFactory\n} from \"@webiny/website-builder-sdk\";\nimport { createSlotInput } from \"@webiny/website-builder-sdk\";\nimport type { ExtractInputs } from \"~/types.js\";\n\nexport function createComponent<\n TComponent extends (props: any) => any,\n TInputs extends ExtractInputs<Parameters<TComponent>[0]>\n>(component: TComponent, manifest: ComponentManifestInput<TInputs>): Component {\n const inputs: ComponentInput[] = [];\n\n // Normalize inputs to always be an array of objects.\n\n if (Array.isArray(manifest.inputs)) {\n inputs.push(...manifest.inputs);\n } else {\n const inputsObject: Record<string, InputFactory<any>> = manifest.inputs ?? {};\n Object.keys(inputsObject).forEach((name: string) => {\n inputs.push({ ...inputsObject[name], name });\n });\n }\n\n const acceptsChildren = manifest.acceptsChildren;\n\n if (acceptsChildren) {\n const hasChildren = inputs.some(input => input.name === \"children\");\n if (!hasChildren) {\n inputs.push(createSlotInput({ name: \"children\" }));\n }\n }\n\n return {\n component,\n manifest: { ...manifest, tags: manifest.tags ?? [], inputs } as ComponentManifest\n };\n}\n"],"names":["createComponent","component","manifest","inputs","Array","inputsObject","Object","name","acceptsChildren","hasChildren","input","createSlotInput"],"mappings":";AAUO,SAASA,gBAGdC,SAAqB,EAAEC,QAAyC;IAC9D,MAAMC,SAA2B,EAAE;IAInC,IAAIC,MAAM,OAAO,CAACF,SAAS,MAAM,GAC7BC,OAAO,IAAI,IAAID,SAAS,MAAM;SAC3B;QACH,MAAMG,eAAkDH,SAAS,MAAM,IAAI,CAAC;QAC5EI,OAAO,IAAI,CAACD,cAAc,OAAO,CAAC,CAACE;YAC/BJ,OAAO,IAAI,CAAC;gBAAE,GAAGE,YAAY,CAACE,KAAK;gBAAEA;YAAK;QAC9C;IACJ;IAEA,MAAMC,kBAAkBN,SAAS,eAAe;IAEhD,IAAIM,iBAAiB;QACjB,MAAMC,cAAcN,OAAO,IAAI,CAACO,CAAAA,QAASA,AAAe,eAAfA,MAAM,IAAI;QACnD,IAAI,CAACD,aACDN,OAAO,IAAI,CAACQ,gBAAgB;YAAE,MAAM;QAAW;IAEvD;IAEA,OAAO;QACHV;QACA,UAAU;YAAE,GAAGC,QAAQ;YAAE,MAAMA,SAAS,IAAI,IAAI,EAAE;YAAEC;QAAO;IAC/D;AACJ"}
@@ -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":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAE7C,SAASC,eAAe;AACxB,SAASC,eAAe;AACxB,SAASC,eAAe,QAAQ,6BAA6B;;AAE7D;AACA;AACA;AACA;;AAEAL,QAAQ,CAAC,oBAAoB,EAAE,MAAM;EACjCE,EAAE,CAAC,sDAAsD,EAAE,MAAM;IAC7D;IACA,MAAMI,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CAAC;IAEDlB,MAAM,CAACO,OAAO,CAACY,QAAQ,CAAC,CAACC,OAAO,CAACN,QAAQ,CAAC;IAC1Cd,MAAM,CAACW,OAAO,CAACQ,QAAQ,CAAC,CAACC,OAAO,CAACN,QAAQ,CAAC;EAC9C,CAAC,CAAC;AACN,CAAC,CAAC","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,CAACC,IACL;QAKX,MAAMC,UAAUC,gBAAgBH,QAAQ;YACpC,MAAM;YACN,QAAQ;gBAEJI,gBAAwB;oBACpB,MAAM;oBACN,OAAO;gBACX;gBAEAC,gBAAgB;oBACZ,MAAM;gBACV;aACH;QACL;QAEA,MAAMC,UAAUH,gBAAgBH,QAAQ;YACpC,MAAM;YACN,QAAQ;gBACJ,OAAOI,gBAAgB;oBACnB,OAAO;gBACX;gBACA,UAAUC,gBAAgB,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K;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" 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"
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\" 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"],"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