@webiny/website-builder-react 0.0.0-unstable.7be00a75a9 → 0.0.0-unstable.7c2def32a7
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.
- package/components/ConnectToEditor.js +3 -2
- package/components/ConnectToEditor.js.map +1 -1
- package/components/ContentClientContext.d.ts +3 -0
- package/components/ContentClientContext.js +6 -0
- package/components/ContentClientContext.js.map +1 -0
- package/components/ContentClientProvider.d.ts +12 -0
- package/components/ContentClientProvider.js +9 -0
- package/components/ContentClientProvider.js.map +1 -0
- package/components/ContentClientProvider.test.d.ts +1 -0
- package/components/ContentClientProvider.test.js +143 -0
- package/components/ContentClientProvider.test.js.map +1 -0
- package/components/DocumentRenderer.js +4 -3
- package/components/DocumentRenderer.js.map +1 -1
- package/components/DocumentStoreProvider.js +5 -2
- package/components/DocumentStoreProvider.js.map +1 -1
- package/components/EditingElementRenderer/EditingElementRenderer.d.ts +2 -2
- package/components/EditingElementRenderer/EditingElementRenderer.js +13 -3
- package/components/EditingElementRenderer/EditingElementRenderer.js.map +1 -1
- package/components/EditingElementRenderer/EditingElementRenderer.presenter.d.ts +2 -2
- package/components/EditingElementRenderer/EditingElementRenderer.presenter.js +3 -3
- package/components/EditingElementRenderer/EditingElementRenderer.presenter.js.map +1 -1
- package/components/ElementRenderer.d.ts +2 -2
- package/components/FragmentsProvider.js +4 -3
- package/components/FragmentsProvider.js.map +1 -1
- package/components/LiveElementRenderer.d.ts +2 -2
- package/components/LiveElementRenderer.js +7 -2
- package/components/LiveElementRenderer.js.map +1 -1
- package/components/index.d.ts +2 -0
- package/components/index.js +2 -0
- package/components/useContentClient.d.ts +6 -0
- package/components/useContentClient.js +11 -0
- package/components/useContentClient.js.map +1 -0
- package/contentEntry/useContentEntryList.d.ts +22 -0
- package/contentEntry/useContentEntryList.js +51 -0
- package/contentEntry/useContentEntryList.js.map +1 -0
- package/createComponent.d.ts +1 -3
- package/createComponent.js +1 -32
- package/createComponent.test.js +3 -3
- package/createComponent.test.js.map +1 -1
- package/editorComponents/Box.manifest.js +1 -1
- package/editorComponents/Box.manifest.js.map +1 -1
- package/editorComponents/Fragment.manifest.js +1 -1
- package/editorComponents/Fragment.manifest.js.map +1 -1
- package/editorComponents/Grid.manifest.js +1 -1
- package/editorComponents/Grid.manifest.js.map +1 -1
- package/editorComponents/Image.manifest.js +1 -1
- package/editorComponents/Image.manifest.js.map +1 -1
- package/editorComponents/Lexical.manifest.js +1 -1
- package/editorComponents/Lexical.manifest.js.map +1 -1
- package/image/BackgroundImage.d.ts +33 -0
- package/image/BackgroundImage.js +61 -0
- package/image/BackgroundImage.js.map +1 -0
- package/image/Image.d.ts +29 -0
- package/image/Image.js +43 -0
- package/image/Image.js.map +1 -0
- package/image/getImageProps.d.ts +42 -0
- package/image/getImageProps.js +18 -0
- package/image/getImageProps.js.map +1 -0
- package/image/getImageProps.test.d.ts +1 -0
- package/image/getImageProps.test.js +70 -0
- package/image/getImageProps.test.js.map +1 -0
- package/image/index.d.ts +3 -0
- package/image/index.js +3 -0
- package/index.d.ts +3 -2
- package/index.js +2 -2
- package/package.json +9 -8
- package/types.d.ts +2 -4
- package/createComponent.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components/useContentClient.js","sources":["../../src/components/useContentClient.ts"],"sourcesContent":["\"use client\";\nimport { useContext } from \"react\";\nimport type { ContentClient } from \"@webiny/website-builder-sdk\";\nimport { contentSdk } from \"@webiny/website-builder-sdk\";\nimport { ContentClientContext } from \"./ContentClientContext.js\";\n\n/**\n * Returns the client from the nearest `ContentClientProvider`, or the `contentSdk` singleton\n * when there is none.\n */\nexport const useContentClient = (): ContentClient => {\n const client = useContext(ContentClientContext);\n return client ?? contentSdk;\n};\n"],"names":["useContentClient","client","useContext","ContentClientContext","contentSdk"],"mappings":";;;;AAUO,MAAMA,mBAAmB;IAC5B,MAAMC,SAASC,WAAWC;IAC1B,OAAOF,UAAUG;AACrB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ResolvedContentEntryQuery } from "@webiny/website-builder-sdk";
|
|
2
|
+
export type { ResolvedContentEntryQuery, ContentEntryQuerySpec } from "@webiny/website-builder-sdk";
|
|
3
|
+
export interface ContentEntryList<T = unknown> {
|
|
4
|
+
/** The loaded entries (first page + any loaded via loadMore). */
|
|
5
|
+
items: T[];
|
|
6
|
+
/** Whether more pages are available (and pagination is enabled). */
|
|
7
|
+
hasMore: boolean;
|
|
8
|
+
/** True while a loadMore fetch is in flight. */
|
|
9
|
+
loading: boolean;
|
|
10
|
+
/** Fetch and append the next page. No-op when nothing more to load. */
|
|
11
|
+
loadMore: () => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Client hook for a query-mode `contentEntry` input. Seeds from the server-resolved
|
|
15
|
+
* first page (SSR-safe — no fetch on mount) and loads further pages on demand from
|
|
16
|
+
* the embedded query + cursor. Re-seeds when the underlying query changes (e.g. the
|
|
17
|
+
* editor tweaks sort/limit/search in preview).
|
|
18
|
+
*
|
|
19
|
+
* Pagination is active only when the input enables it (the resolved value then
|
|
20
|
+
* carries a `query`); otherwise `hasMore` is always false and `loadMore` is a no-op.
|
|
21
|
+
*/
|
|
22
|
+
export declare function useContentEntryList<T = unknown>(value: ResolvedContentEntryQuery<T> | null | undefined): ContentEntryList<T>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useState } from "react";
|
|
3
|
+
import { contentSdk } from "@webiny/cms-sdk";
|
|
4
|
+
function useContentEntryList(value) {
|
|
5
|
+
const query = value?.query;
|
|
6
|
+
const signature = JSON.stringify({
|
|
7
|
+
query,
|
|
8
|
+
cursor: value?.pageInfo?.cursor ?? null
|
|
9
|
+
});
|
|
10
|
+
const seed = ()=>({
|
|
11
|
+
signature,
|
|
12
|
+
items: value?.items ?? [],
|
|
13
|
+
cursor: value?.pageInfo?.cursor ?? null,
|
|
14
|
+
apiHasMore: value?.pageInfo?.hasMore ?? false
|
|
15
|
+
});
|
|
16
|
+
const [state, setState] = useState(seed);
|
|
17
|
+
const [loading, setLoading] = useState(false);
|
|
18
|
+
if (state.signature !== signature) setState(seed());
|
|
19
|
+
const loadMore = useCallback(()=>{
|
|
20
|
+
if (!query || loading || !state.apiHasMore || !state.cursor) return;
|
|
21
|
+
setLoading(true);
|
|
22
|
+
contentSdk.listEntries({
|
|
23
|
+
...query,
|
|
24
|
+
after: state.cursor
|
|
25
|
+
}).then((result)=>{
|
|
26
|
+
setState((prev)=>({
|
|
27
|
+
...prev,
|
|
28
|
+
items: [
|
|
29
|
+
...prev.items,
|
|
30
|
+
...result.data
|
|
31
|
+
],
|
|
32
|
+
cursor: result.meta.cursor,
|
|
33
|
+
apiHasMore: result.meta.hasMoreItems
|
|
34
|
+
}));
|
|
35
|
+
}).finally(()=>setLoading(false));
|
|
36
|
+
}, [
|
|
37
|
+
query,
|
|
38
|
+
loading,
|
|
39
|
+
state.apiHasMore,
|
|
40
|
+
state.cursor
|
|
41
|
+
]);
|
|
42
|
+
return {
|
|
43
|
+
items: state.items,
|
|
44
|
+
hasMore: Boolean(query) && state.apiHasMore,
|
|
45
|
+
loading,
|
|
46
|
+
loadMore
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export { useContentEntryList };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=useContentEntryList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contentEntry/useContentEntryList.js","sources":["../../src/contentEntry/useContentEntryList.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useState } from \"react\";\nimport { contentSdk } from \"@webiny/cms-sdk\";\nimport type { ResolvedContentEntryQuery } from \"@webiny/website-builder-sdk\";\n\nexport type { ResolvedContentEntryQuery, ContentEntryQuerySpec } from \"@webiny/website-builder-sdk\";\n\nexport interface ContentEntryList<T = unknown> {\n /** The loaded entries (first page + any loaded via loadMore). */\n items: T[];\n /** Whether more pages are available (and pagination is enabled). */\n hasMore: boolean;\n /** True while a loadMore fetch is in flight. */\n loading: boolean;\n /** Fetch and append the next page. No-op when nothing more to load. */\n loadMore: () => void;\n}\n\ninterface PageState<T> {\n signature: string;\n items: T[];\n cursor: string | null;\n apiHasMore: boolean;\n}\n\n/**\n * Client hook for a query-mode `contentEntry` input. Seeds from the server-resolved\n * first page (SSR-safe — no fetch on mount) and loads further pages on demand from\n * the embedded query + cursor. Re-seeds when the underlying query changes (e.g. the\n * editor tweaks sort/limit/search in preview).\n *\n * Pagination is active only when the input enables it (the resolved value then\n * carries a `query`); otherwise `hasMore` is always false and `loadMore` is a no-op.\n */\nexport function useContentEntryList<T = unknown>(\n value: ResolvedContentEntryQuery<T> | null | undefined\n): ContentEntryList<T> {\n const query = value?.query;\n const signature = JSON.stringify({ query, cursor: value?.pageInfo?.cursor ?? null });\n\n const seed = (): PageState<T> => ({\n signature,\n items: value?.items ?? [],\n cursor: value?.pageInfo?.cursor ?? null,\n apiHasMore: value?.pageInfo?.hasMore ?? false\n });\n\n const [state, setState] = useState<PageState<T>>(seed);\n const [loading, setLoading] = useState(false);\n\n // Re-seed (on the client) when the resolved page changes — e.g. the editor edits\n // the query. The first/SSR render already has the right data via useState.\n if (state.signature !== signature) {\n setState(seed());\n }\n\n const loadMore = useCallback(() => {\n if (!query || loading || !state.apiHasMore || !state.cursor) {\n return;\n }\n setLoading(true);\n contentSdk\n .listEntries({ ...query, after: state.cursor })\n .then(result => {\n setState(prev => ({\n ...prev,\n items: [...prev.items, ...(result.data as T[])],\n cursor: result.meta.cursor,\n apiHasMore: result.meta.hasMoreItems\n }));\n })\n .finally(() => setLoading(false));\n }, [query, loading, state.apiHasMore, state.cursor]);\n\n return {\n items: state.items,\n hasMore: Boolean(query) && state.apiHasMore,\n loading,\n loadMore\n };\n}\n"],"names":["useContentEntryList","value","query","signature","JSON","seed","state","setState","useState","loading","setLoading","loadMore","useCallback","contentSdk","result","prev","Boolean"],"mappings":";;;AAkCO,SAASA,oBACZC,KAAsD;IAEtD,MAAMC,QAAQD,OAAO;IACrB,MAAME,YAAYC,KAAK,SAAS,CAAC;QAAEF;QAAO,QAAQD,OAAO,UAAU,UAAU;IAAK;IAElF,MAAMI,OAAO,IAAqB;YAC9BF;YACA,OAAOF,OAAO,SAAS,EAAE;YACzB,QAAQA,OAAO,UAAU,UAAU;YACnC,YAAYA,OAAO,UAAU,WAAW;QAC5C;IAEA,MAAM,CAACK,OAAOC,SAAS,GAAGC,SAAuBH;IACjD,MAAM,CAACI,SAASC,WAAW,GAAGF,SAAS;IAIvC,IAAIF,MAAM,SAAS,KAAKH,WACpBI,SAASF;IAGb,MAAMM,WAAWC,YAAY;QACzB,IAAI,CAACV,SAASO,WAAW,CAACH,MAAM,UAAU,IAAI,CAACA,MAAM,MAAM,EACvD;QAEJI,WAAW;QACXG,WAAAA,WACgB,CAAC;YAAE,GAAGX,KAAK;YAAE,OAAOI,MAAM,MAAM;QAAC,GAC5C,IAAI,CAACQ,CAAAA;YACFP,SAASQ,CAAAA,OAAS;oBACd,GAAGA,IAAI;oBACP,OAAO;2BAAIA,KAAK,KAAK;2BAAMD,OAAO,IAAI;qBAAS;oBAC/C,QAAQA,OAAO,IAAI,CAAC,MAAM;oBAC1B,YAAYA,OAAO,IAAI,CAAC,YAAY;gBACxC;QACJ,GACC,OAAO,CAAC,IAAMJ,WAAW;IAClC,GAAG;QAACR;QAAOO;QAASH,MAAM,UAAU;QAAEA,MAAM,MAAM;KAAC;IAEnD,OAAO;QACH,OAAOA,MAAM,KAAK;QAClB,SAASU,QAAQd,UAAUI,MAAM,UAAU;QAC3CG;QACAE;IACJ;AACJ"}
|
package/createComponent.d.ts
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { ExtractInputs } from "./types.js";
|
|
3
|
-
export declare function createComponent<TComponent extends (props: any) => any, TInputs extends ExtractInputs<Parameters<TComponent>[0]>>(component: TComponent, manifest: ComponentManifestInput<TInputs>): Component;
|
|
1
|
+
export { createComponent } from "@webiny/website-builder-sdk";
|
package/createComponent.js
CHANGED
|
@@ -1,32 +1 @@
|
|
|
1
|
-
|
|
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
|
-
});
|
|
13
|
-
}
|
|
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
|
-
}));
|
|
20
|
-
}
|
|
21
|
-
return {
|
|
22
|
-
component,
|
|
23
|
-
manifest: {
|
|
24
|
-
...manifest,
|
|
25
|
-
tags: manifest.tags ?? [],
|
|
26
|
-
inputs
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
export { createComponent };
|
|
31
|
-
|
|
32
|
-
//# sourceMappingURL=createComponent.js.map
|
|
1
|
+
export { createComponent } from "@webiny/website-builder-sdk";
|
package/createComponent.test.js
CHANGED
|
@@ -4,7 +4,7 @@ import { createTextInput } from "./index.js";
|
|
|
4
4
|
import { createSlotInput } from "@webiny/website-builder-sdk";
|
|
5
5
|
describe("Component Manifest", ()=>{
|
|
6
6
|
it("should support input arrays and strict input objects", ()=>{
|
|
7
|
-
const Button = (
|
|
7
|
+
const Button = ({})=>null;
|
|
8
8
|
const button1 = createComponent(Button, {
|
|
9
9
|
name: "Button",
|
|
10
10
|
inputs: [
|
|
@@ -49,7 +49,7 @@ describe("Component Manifest", ()=>{
|
|
|
49
49
|
expect(button2.manifest).toEqual(snapshot);
|
|
50
50
|
});
|
|
51
51
|
it("acceptsChildren should satisfy the `children` input requirement", ()=>{
|
|
52
|
-
const Button = (
|
|
52
|
+
const Button = ({})=>null;
|
|
53
53
|
const { manifest } = createComponent(Button, {
|
|
54
54
|
name: "Button",
|
|
55
55
|
acceptsChildren: true
|
|
@@ -70,7 +70,7 @@ describe("Component Manifest", ()=>{
|
|
|
70
70
|
});
|
|
71
71
|
});
|
|
72
72
|
it("`acceptsChildren` should work alongside other inputs", ()=>{
|
|
73
|
-
const Button = (
|
|
73
|
+
const Button = ({})=>null;
|
|
74
74
|
const button1 = createComponent(Button, {
|
|
75
75
|
name: "Button",
|
|
76
76
|
acceptsChildren: true,
|
|
@@ -1 +1 @@
|
|
|
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 = (
|
|
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"}
|
|
@@ -6,7 +6,7 @@ const Box = createComponent(BoxComponent, {
|
|
|
6
6
|
label: "Box",
|
|
7
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
8
|
group: "basic",
|
|
9
|
-
image: '<svg xmlns="http://www.w3.org/2000/svg" height="
|
|
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
10
|
acceptsChildren: true,
|
|
11
11
|
defaults: {
|
|
12
12
|
styles: {
|
|
@@ -1 +1 @@
|
|
|
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=\"
|
|
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"}
|
|
@@ -7,7 +7,7 @@ const Fragment = createComponent(FragmentComponent, {
|
|
|
7
7
|
label: "Fragment",
|
|
8
8
|
useInAiContentGeneration: false,
|
|
9
9
|
group: "basic",
|
|
10
|
-
image: '<svg xmlns="http://www.w3.org/2000/svg" height="
|
|
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
11
|
inputs: [
|
|
12
12
|
createTextInput({
|
|
13
13
|
name: "name",
|
|
@@ -1 +1 @@
|
|
|
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\" height=\"
|
|
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"}
|
|
@@ -6,7 +6,7 @@ const Grid = createComponent(GridComponent, {
|
|
|
6
6
|
name: "Webiny/Grid",
|
|
7
7
|
label: "Grid",
|
|
8
8
|
aiContext: "Multi-column layout container. Set gridLayout to a dash-separated pattern (e.g. '6-6' for two equal columns, '8-4' for wide-narrow, '4-4-4' for three equal). Each segment becomes a GridColumn. Columns stack vertically on smaller screens when stackAtBreakpoint is set.",
|
|
9
|
-
image: '<svg xmlns="http://www.w3.org/2000/svg" height="
|
|
9
|
+
image: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M20 2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM8 20H4v-4h4v4zm0-6H4v-4h4v4zm0-6H4V4h4v4zm6 12h-4v-4h4v4zm0-6h-4v-4h4v4zm0-6h-4V4h4v4zm6 12h-4v-4h4v4zm0-6h-4v-4h4v4zm0-6h-4V4h4v4z"/></svg>',
|
|
10
10
|
group: "basic",
|
|
11
11
|
autoApplyStyles: false,
|
|
12
12
|
inputs: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editorComponents/Grid.manifest.js","sources":["../../src/editorComponents/Grid.manifest.ts"],"sourcesContent":["\"use client\";\nimport {\n createBooleanInput,\n createElement,\n createNumberInput,\n createObjectInput,\n createSelectInput,\n createSlotInput,\n createTextInput\n} from \"@webiny/website-builder-sdk\";\nimport { createComponent } from \"~/createComponent.js\";\nimport { GridComponent } from \"./Grid.js\";\n\nexport interface Column {\n children: React.ReactNode;\n}\nexport const Grid = createComponent(GridComponent, {\n name: \"Webiny/Grid\",\n label: \"Grid\",\n aiContext:\n \"Multi-column layout container. Set gridLayout to a dash-separated pattern (e.g. '6-6' for two equal columns, '8-4' for wide-narrow, '4-4-4' for three equal). Each segment becomes a GridColumn. Columns stack vertically on smaller screens when stackAtBreakpoint is set.\",\n image: `<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#e8eaed\"><path d=\"M120-520v-320h320v320H120Zm0 400v-320h320v320H120Zm400-400v-320h320v320H520Zm0 400v-320h320v320H520ZM200-600h160v-160H200v160Zm400 0h160v-160H600v160Zm0 400h160v-160H600v160Zm-400 0h160v-160H200v160Zm400-400Zm0 240Zm-240 0Zm0-240Z\"/></svg>`,\n group: \"basic\",\n autoApplyStyles: false,\n inputs: [\n createTextInput({\n name: \"gridLayout\",\n label: \"Grid Layout\",\n renderer: \"Webiny/GridLayout\",\n onChange: ({ inputs, createElement }) => {\n const rowColumnCount = inputs.gridLayout.split(\"-\").length;\n const columns = inputs.columns.length;\n\n const remainder = columns % rowColumnCount;\n\n if (remainder !== 0) {\n const fullColumnCount = rowColumnCount * inputs.rowCount;\n const toCreate =\n columns > fullColumnCount ? remainder : rowColumnCount - remainder;\n\n Array.from({ length: toCreate }).forEach(() => {\n inputs.columns.push({\n children: createElement({\n component: \"Webiny/GridColumn\"\n })\n });\n });\n }\n\n inputs.rowCount = inputs.columns.length / rowColumnCount;\n }\n }),\n createNumberInput({\n name: \"rowCount\",\n label: \"Row Count\",\n defaultValue: 1,\n minValue: 1,\n onChange: ({ inputs, createElement }) => {\n const gridLayout = inputs.gridLayout;\n const columnCount = gridLayout.split(\"-\").length;\n const rowCount = Math.max(1, inputs.rowCount);\n const columns = inputs.columns;\n const rows: Column[][] = [];\n\n // Chunk columns into rows\n for (let i = 0; i < columns.length; i += columnCount) {\n rows.push(columns.slice(i, i + columnCount));\n }\n\n if (rows.length > rowCount) {\n inputs.columns = columns.slice(0, columnCount * rowCount);\n return;\n }\n\n const createRows = Math.max(0, rowCount - rows.length);\n\n if (createRows <= 0) {\n return;\n }\n\n const newRows = Array.from({ length: createRows * columnCount }).map(() => {\n return {\n children: createElement({\n component: \"Webiny/GridColumn\"\n })\n };\n });\n\n inputs.columns.push(...newRows);\n }\n }),\n createNumberInput({\n name: \"rowGap\",\n label: \"Row Gap\",\n defaultValue: 0,\n responsive: true,\n onChange: ({ inputs, styles }) => {\n const rowGap = parseInt(inputs.rowGap);\n if (isNaN(rowGap)) {\n delete styles.rowGap;\n } else {\n styles.rowGap = `${inputs.rowGap}px`;\n }\n }\n }),\n createNumberInput({\n name: \"columnGap\",\n label: \"Column Gap\",\n defaultValue: 0,\n responsive: true,\n onChange: ({ inputs, styles }) => {\n const columnGap = parseInt(inputs.columnGap);\n if (isNaN(columnGap)) {\n delete styles.columnGap;\n } else {\n styles.columnGap = `${inputs.columnGap}px`;\n }\n }\n }),\n createSelectInput({\n name: \"stackAtBreakpoint\",\n label: \"Stack at breakpoint\",\n options: [\n { label: \"Tablet\", value: \"tablet\" },\n { label: \"Mobile\", value: \"mobile\" }\n ]\n }),\n createBooleanInput({\n name: \"reverseWhenStacked\",\n label: \"Reverse columns when stacked\"\n }),\n createObjectInput({\n name: \"columns\",\n list: true,\n hideFromUi: true,\n fields: [\n createSlotInput({\n name: \"children\",\n list: false,\n components: [\"Webiny/GridColumn\"]\n })\n ]\n })\n ],\n defaults: {\n inputs: {\n gridLayout: \"6-6\",\n columns: [\n {\n children: createElement({\n component: \"Webiny/GridColumn\",\n inputs: {\n children: [\n createElement({\n component: \"Webiny/Lexical\"\n })\n ]\n }\n })\n },\n {\n children: createElement({\n component: \"Webiny/GridColumn\",\n inputs: {\n children: [\n createElement({\n component: \"Webiny/Lexical\"\n })\n ]\n }\n })\n }\n ]\n },\n styles: {\n boxSizing: \"border-box\",\n display: \"flex\",\n flexDirection: \"row\",\n flexWrap: \"wrap\",\n justifyContent: \"flex-start\",\n alignItems: \"stretch\",\n width: \"100%\",\n marginTop: \"0px\",\n marginBottom: \"0px\",\n marginLeft: \"0px\",\n marginRight: \"0px\",\n paddingTop: \"5px\",\n paddingRight: \"5px\",\n paddingBottom: \"5px\",\n paddingLeft: \"5px\"\n }\n }\n});\n"],"names":["Grid","createComponent","GridComponent","createTextInput","inputs","createElement","rowColumnCount","columns","remainder","fullColumnCount","toCreate","Array","createNumberInput","gridLayout","columnCount","rowCount","Math","rows","i","createRows","newRows","styles","rowGap","parseInt","isNaN","columnGap","createSelectInput","create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N,YAAY;wBAAC;qBAAoB;gBACrC;aACH;QACL;KACH;IACD,UAAU;QACN,QAAQ;YACJ,YAAY;YACZ,SAAS;gBACL;oBACI,UAAUxB,kCAAc;wBACpB,WAAW;wBACX,QAAQ;4BACJ,UAAU;gCACNA,kCAAc;oCACV,WAAW;gCACf;6BACH;wBACL;oBACJ;gBACJ;gBACA;oBACI,UAAUA,kCAAc;wBACpB,WAAW;wBACX,QAAQ;4BACJ,UAAU;gCACNA,kCAAc;oCACV,WAAW;gCACf;6BACH;wBACL;oBACJ;gBACJ;aACH;QACL;QACA,QAAQ;YACJ,WAAW;YACX,SAAS;YACT,eAAe;YACf,UAAU;YACV,gBAAgB;YAChB,YAAY;YACZ,OAAO;YACP,WAAW;YACX,cAAc;YACd,YAAY;YACZ,aAAa;YACb,YAAY;YACZ,cAAc;YACd,eAAe;YACf,aAAa;QACjB;IACJ;AACJ"}
|
|
1
|
+
{"version":3,"file":"editorComponents/Grid.manifest.js","sources":["../../src/editorComponents/Grid.manifest.ts"],"sourcesContent":["\"use client\";\nimport {\n createBooleanInput,\n createElement,\n createNumberInput,\n createObjectInput,\n createSelectInput,\n createSlotInput,\n createTextInput\n} from \"@webiny/website-builder-sdk\";\nimport { createComponent } from \"~/createComponent.js\";\nimport { GridComponent } from \"./Grid.js\";\n\nexport interface Column {\n children: React.ReactNode;\n}\nexport const Grid = createComponent(GridComponent, {\n name: \"Webiny/Grid\",\n label: \"Grid\",\n aiContext:\n \"Multi-column layout container. Set gridLayout to a dash-separated pattern (e.g. '6-6' for two equal columns, '8-4' for wide-narrow, '4-4-4' for three equal). Each segment becomes a GridColumn. Columns stack vertically on smaller screens when stackAtBreakpoint is set.\",\n image: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M20 2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM8 20H4v-4h4v4zm0-6H4v-4h4v4zm0-6H4V4h4v4zm6 12h-4v-4h4v4zm0-6h-4v-4h4v4zm0-6h-4V4h4v4zm6 12h-4v-4h4v4zm0-6h-4v-4h4v4zm0-6h-4V4h4v4z\"/></svg>`,\n group: \"basic\",\n autoApplyStyles: false,\n inputs: [\n createTextInput({\n name: \"gridLayout\",\n label: \"Grid Layout\",\n renderer: \"Webiny/GridLayout\",\n onChange: ({ inputs, createElement }) => {\n const rowColumnCount = inputs.gridLayout.split(\"-\").length;\n const columns = inputs.columns.length;\n\n const remainder = columns % rowColumnCount;\n\n if (remainder !== 0) {\n const fullColumnCount = rowColumnCount * inputs.rowCount;\n const toCreate =\n columns > fullColumnCount ? remainder : rowColumnCount - remainder;\n\n Array.from({ length: toCreate }).forEach(() => {\n inputs.columns.push({\n children: createElement({\n component: \"Webiny/GridColumn\"\n })\n });\n });\n }\n\n inputs.rowCount = inputs.columns.length / rowColumnCount;\n }\n }),\n createNumberInput({\n name: \"rowCount\",\n label: \"Row Count\",\n defaultValue: 1,\n minValue: 1,\n onChange: ({ inputs, createElement }) => {\n const gridLayout = inputs.gridLayout;\n const columnCount = gridLayout.split(\"-\").length;\n const rowCount = Math.max(1, inputs.rowCount);\n const columns = inputs.columns;\n const rows: Column[][] = [];\n\n // Chunk columns into rows\n for (let i = 0; i < columns.length; i += columnCount) {\n rows.push(columns.slice(i, i + columnCount));\n }\n\n if (rows.length > rowCount) {\n inputs.columns = columns.slice(0, columnCount * rowCount);\n return;\n }\n\n const createRows = Math.max(0, rowCount - rows.length);\n\n if (createRows <= 0) {\n return;\n }\n\n const newRows = Array.from({ length: createRows * columnCount }).map(() => {\n return {\n children: createElement({\n component: \"Webiny/GridColumn\"\n })\n };\n });\n\n inputs.columns.push(...newRows);\n }\n }),\n createNumberInput({\n name: \"rowGap\",\n label: \"Row Gap\",\n defaultValue: 0,\n responsive: true,\n onChange: ({ inputs, styles }) => {\n const rowGap = parseInt(inputs.rowGap);\n if (isNaN(rowGap)) {\n delete styles.rowGap;\n } else {\n styles.rowGap = `${inputs.rowGap}px`;\n }\n }\n }),\n createNumberInput({\n name: \"columnGap\",\n label: \"Column Gap\",\n defaultValue: 0,\n responsive: true,\n onChange: ({ inputs, styles }) => {\n const columnGap = parseInt(inputs.columnGap);\n if (isNaN(columnGap)) {\n delete styles.columnGap;\n } else {\n styles.columnGap = `${inputs.columnGap}px`;\n }\n }\n }),\n createSelectInput({\n name: \"stackAtBreakpoint\",\n label: \"Stack at breakpoint\",\n options: [\n { label: \"Tablet\", value: \"tablet\" },\n { label: \"Mobile\", value: \"mobile\" }\n ]\n }),\n createBooleanInput({\n name: \"reverseWhenStacked\",\n label: \"Reverse columns when stacked\"\n }),\n createObjectInput({\n name: \"columns\",\n list: true,\n hideFromUi: true,\n fields: [\n createSlotInput({\n name: \"children\",\n list: false,\n components: [\"Webiny/GridColumn\"]\n })\n ]\n })\n ],\n defaults: {\n inputs: {\n gridLayout: \"6-6\",\n columns: [\n {\n children: createElement({\n component: \"Webiny/GridColumn\",\n inputs: {\n children: [\n createElement({\n component: \"Webiny/Lexical\"\n })\n ]\n }\n })\n },\n {\n children: createElement({\n component: \"Webiny/GridColumn\",\n inputs: {\n children: [\n createElement({\n component: \"Webiny/Lexical\"\n })\n ]\n }\n })\n }\n ]\n },\n styles: {\n boxSizing: \"border-box\",\n display: \"flex\",\n flexDirection: \"row\",\n flexWrap: \"wrap\",\n justifyContent: \"flex-start\",\n alignItems: \"stretch\",\n width: \"100%\",\n marginTop: \"0px\",\n marginBottom: \"0px\",\n marginLeft: \"0px\",\n marginRight: \"0px\",\n paddingTop: \"5px\",\n paddingRight: \"5px\",\n paddingBottom: \"5px\",\n paddingLeft: \"5px\"\n }\n }\n});\n"],"names":["Grid","createComponent","GridComponent","createTextInput","inputs","createElement","rowColumnCount","columns","remainder","fullColumnCount","toCreate","Array","createNumberInput","gridLayout","columnCount","rowCount","Math","rows","i","createRows","newRows","styles","rowGap","parseInt","isNaN","columnGap","createSelectInput","createBooleanInput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;wBAAC;qBAAoB;gBACrC;aACH;QACL;KACH;IACD,UAAU;QACN,QAAQ;YACJ,YAAY;YACZ,SAAS;gBACL;oBACI,UAAUxB,kCAAc;wBACpB,WAAW;wBACX,QAAQ;4BACJ,UAAU;gCACNA,kCAAc;oCACV,WAAW;gCACf;6BACH;wBACL;oBACJ;gBACJ;gBACA;oBACI,UAAUA,kCAAc;wBACpB,WAAW;wBACX,QAAQ;4BACJ,UAAU;gCACNA,kCAAc;oCACV,WAAW;gCACf;6BACH;wBACL;oBACJ;gBACJ;aACH;QACL;QACA,QAAQ;YACJ,WAAW;YACX,SAAS;YACT,eAAe;YACf,UAAU;YACV,gBAAgB;YAChB,YAAY;YACZ,OAAO;YACP,WAAW;YACX,cAAc;YACd,YAAY;YACZ,aAAa;YACb,YAAY;YACZ,cAAc;YACd,eAAe;YACf,aAAa;QACjB;IACJ;AACJ"}
|
|
@@ -7,7 +7,7 @@ const Image = createComponent(ImageComponent, {
|
|
|
7
7
|
label: "Image",
|
|
8
8
|
aiContext: "Displays an image from the file manager with configurable title and alt text.",
|
|
9
9
|
group: "basic",
|
|
10
|
-
image: '<svg xmlns="http://www.w3.org/2000/svg" height="
|
|
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-2zm-4.86 8.86-3 3.87L9 13.14 6 17h12l-3.86-5.14z"/></svg>',
|
|
11
11
|
autoApplyStyles: false,
|
|
12
12
|
inputs: {
|
|
13
13
|
image: createFileInput({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editorComponents/Image.manifest.js","sources":["../../src/editorComponents/Image.manifest.ts"],"sourcesContent":["\"use client\";\nimport { createFileInput, createTextInput } from \"@webiny/website-builder-sdk\";\nimport { createComponent } from \"~/createComponent.js\";\nimport { ImageComponent } from \"./Image.js\";\n\nexport const Image = createComponent(ImageComponent, {\n name: \"Webiny/Image\",\n label: \"Image\",\n aiContext: \"Displays an image from the file manager with configurable title and alt text.\",\n group: \"basic\",\n image: `<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"
|
|
1
|
+
{"version":3,"file":"editorComponents/Image.manifest.js","sources":["../../src/editorComponents/Image.manifest.ts"],"sourcesContent":["\"use client\";\nimport { createFileInput, createTextInput } from \"@webiny/website-builder-sdk\";\nimport { createComponent } from \"~/createComponent.js\";\nimport { ImageComponent } from \"./Image.js\";\n\nexport const Image = createComponent(ImageComponent, {\n name: \"Webiny/Image\",\n label: \"Image\",\n aiContext: \"Displays an image from the file manager with configurable title and alt text.\",\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-2zm-4.86 8.86-3 3.87L9 13.14 6 17h12l-3.86-5.14z\"/></svg>`,\n autoApplyStyles: false,\n inputs: {\n image: createFileInput({\n label: \"Image\",\n allowedFileTypes: [\"image/*\"],\n onChange: ({ inputs }) => {\n if (inputs.image) {\n inputs.title = inputs.image.name;\n inputs.altText = inputs.image.name;\n }\n }\n }),\n title: createTextInput({\n label: \"Title\",\n description: \"Title of the image\"\n }),\n altText: createTextInput({\n label: \"Alternate Text\",\n description: \"Shown when the user has disabled images\"\n })\n },\n defaults: {\n styles: {\n width: \"100%\"\n }\n }\n});\n"],"names":["Image","createComponent","ImageComponent","createFileInput","inputs","createTextInput"],"mappings":";;;;AAKO,MAAMA,QAAQC,gBAAgBC,gBAAgB;IACjD,MAAM;IACN,OAAO;IACP,WAAW;IACX,OAAO;IACP,OAAO;IACP,iBAAiB;IACjB,QAAQ;QACJ,OAAOC,gBAAgB;YACnB,OAAO;YACP,kBAAkB;gBAAC;aAAU;YAC7B,UAAU,CAAC,EAAEC,MAAM,EAAE;gBACjB,IAAIA,OAAO,KAAK,EAAE;oBACdA,OAAO,KAAK,GAAGA,OAAO,KAAK,CAAC,IAAI;oBAChCA,OAAO,OAAO,GAAGA,OAAO,KAAK,CAAC,IAAI;gBACtC;YACJ;QACJ;QACA,OAAOC,gBAAgB;YACnB,OAAO;YACP,aAAa;QACjB;QACA,SAASA,gBAAgB;YACrB,OAAO;YACP,aAAa;QACjB;IACJ;IACA,UAAU;QACN,QAAQ;YACJ,OAAO;QACX;IACJ;AACJ"}
|
|
@@ -7,7 +7,7 @@ const Lexical = createComponent(LexicalComponent, {
|
|
|
7
7
|
label: "Rich Text",
|
|
8
8
|
aiContext: "Rich text content. Generate semantic HTML tags. Do NOT generate markdown.",
|
|
9
9
|
group: "basic",
|
|
10
|
-
image: '<svg xmlns="http://www.w3.org/2000/svg" height="
|
|
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
11
|
inputs: [
|
|
12
12
|
createLexicalInput({
|
|
13
13
|
name: "content",
|
|
@@ -1 +1 @@
|
|
|
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\" height=\"
|
|
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"}
|
|
@@ -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"}
|
package/image/Image.d.ts
ADDED
|
@@ -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
|