@xwadex/fesd-next 0.3.4-7.21 → 0.3.4-7.23
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/dist/components/content-builders/article4/article4cora/article4cora-roots.d.ts +4 -0
- package/dist/components/content-builders/article4/article4cora/article4cora-roots.js +79 -0
- package/dist/components/content-builders/article4/article4cora/media-base/index.d.ts +2 -0
- package/dist/components/content-builders/article4/article4cora/media-base/index.js +2 -0
- package/dist/components/content-builders/article4/article4cora/media-base/media-base-root.d.ts +15 -0
- package/dist/components/content-builders/article4/article4cora/media-base/media-base-root.js +52 -0
- package/dist/components/content-builders/article4/article4cora/media-cover/index.d.ts +2 -0
- package/dist/components/content-builders/article4/article4cora/media-cover/index.js +2 -0
- package/dist/components/content-builders/article4/article4cora/media-cover/media-cover-root.d.ts +15 -0
- package/dist/components/content-builders/article4/article4cora/media-cover/media-cover-root.js +23 -0
- package/dist/components/content-builders/article4/article4cora/media-embla/index.d.ts +2 -0
- package/dist/components/content-builders/article4/article4cora/media-embla/index.js +2 -0
- package/dist/components/content-builders/article4/article4cora/media-embla/media-embla-root.d.ts +25 -0
- package/dist/components/content-builders/article4/article4cora/media-embla/media-embla-root.js +107 -0
- package/dist/components/content-builders/article4/baseBlock.d.ts +17 -0
- package/dist/components/content-builders/article4/baseBlock.js +115 -0
- package/dist/components/content-builders/article4/commonComponents.d.ts +53 -0
- package/dist/components/content-builders/article4/commonComponents.js +81 -0
- package/dist/components/content-builders/article4/config.d.ts +4 -0
- package/dist/components/content-builders/article4/config.js +6 -0
- package/dist/components/content-builders/article4/index.d.ts +12 -0
- package/dist/components/content-builders/article4/index.js +12 -0
- package/dist/components/content-builders/article4/type10Block.d.ts +14 -0
- package/dist/components/content-builders/article4/type10Block.js +24 -0
- package/dist/components/content-builders/article4/type1Block.d.ts +9 -0
- package/dist/components/content-builders/article4/type1Block.js +12 -0
- package/dist/components/content-builders/article4/type2Block.d.ts +9 -0
- package/dist/components/content-builders/article4/type2Block.js +17 -0
- package/dist/components/content-builders/article4/type3Block.d.ts +8 -0
- package/dist/components/content-builders/article4/type3Block.js +12 -0
- package/dist/components/content-builders/article4/type4Block.d.ts +27 -0
- package/dist/components/content-builders/article4/type4Block.js +53 -0
- package/dist/components/content-builders/article4/type5Block.d.ts +24 -0
- package/dist/components/content-builders/article4/type5Block.js +43 -0
- package/dist/components/content-builders/article4/type6Block.d.ts +24 -0
- package/dist/components/content-builders/article4/type6Block.js +43 -0
- package/dist/components/content-builders/article4/type7Block.d.ts +12 -0
- package/dist/components/content-builders/article4/type7Block.js +19 -0
- package/dist/components/content-builders/article4/type8Block.d.ts +11 -0
- package/dist/components/content-builders/article4/type8Block.js +14 -0
- package/dist/components/content-builders/article4/type9Block.d.ts +11 -0
- package/dist/components/content-builders/article4/type9Block.js +19 -0
- package/dist/components/content-builders/blocks/base-block.d.ts +12 -0
- package/dist/components/content-builders/blocks/base-block.js +91 -0
- package/dist/components/content-builders/blocks/headers-block.d.ts +20 -0
- package/dist/components/content-builders/blocks/headers-block.js +49 -0
- package/dist/components/content-builders/blocks/index.d.ts +4 -0
- package/dist/components/content-builders/blocks/index.js +4 -0
- package/dist/components/content-builders/blocks/media-content.d.ts +7 -0
- package/dist/components/content-builders/blocks/media-content.js +23 -0
- package/dist/components/content-builders/blocks/root-header.d.ts +11 -0
- package/dist/components/content-builders/blocks/root-header.js +14 -0
- package/dist/components/content-builders/blocks/roots.d.ts +8 -0
- package/dist/components/content-builders/blocks/roots.js +23 -0
- package/dist/components/content-builders/blocks/text-content.d.ts +20 -0
- package/dist/components/content-builders/blocks/text-content.js +190 -0
- package/dist/components/content-builders/content-builder-actionbar.d.ts +1 -0
- package/dist/components/content-builders/content-builder-actionbar.js +64 -0
- package/dist/components/content-builders/content-builder-blocks-dialogs.d.ts +4 -0
- package/dist/components/content-builders/content-builder-blocks-dialogs.js +45 -0
- package/dist/components/content-builders/content-builder-blocks.d.ts +15 -0
- package/dist/components/content-builders/content-builder-blocks.js +40 -0
- package/dist/components/content-builders/content-builder-builder.d.ts +13 -0
- package/dist/components/content-builders/content-builder-builder.js +17 -0
- package/dist/components/content-builders/content-builder-configs.d.ts +203 -0
- package/dist/components/content-builders/content-builder-configs.js +125 -0
- package/dist/components/content-builders/content-builder-context.d.ts +24 -0
- package/dist/components/content-builders/content-builder-context.js +47 -0
- package/dist/components/content-builders/content-builder-fields.d.ts +1 -0
- package/dist/components/content-builders/content-builder-fields.js +5 -0
- package/dist/components/content-builders/content-builder-functionbar.d.ts +1 -0
- package/dist/components/content-builders/content-builder-functionbar.js +37 -0
- package/dist/components/content-builders/content-builder-helpers.d.ts +9 -0
- package/dist/components/content-builders/content-builder-helpers.js +43 -0
- package/dist/components/content-builders/content-builder-hooks.d.ts +39 -0
- package/dist/components/content-builders/content-builder-hooks.js +129 -0
- package/dist/components/content-builders/content-builder-iframe.d.ts +5 -0
- package/dist/components/content-builders/content-builder-iframe.js +15 -0
- package/dist/components/content-builders/content-builder-overlay.d.ts +1 -0
- package/dist/components/content-builders/content-builder-overlay.js +22 -0
- package/dist/components/content-builders/content-builder-panels.d.ts +10 -0
- package/dist/components/content-builders/content-builder-panels.js +165 -0
- package/dist/components/content-builders/content-builder-preview.d.ts +4 -0
- package/dist/components/content-builders/content-builder-preview.js +22 -0
- package/dist/components/content-builders/content-builder-pucks-context.d.ts +13 -0
- package/dist/components/content-builders/content-builder-pucks-context.js +17 -0
- package/dist/components/content-builders/content-builder-pucks-hooks.d.ts +17 -0
- package/dist/components/content-builders/content-builder-pucks-hooks.js +119 -0
- package/dist/components/content-builders/content-builder-render.d.ts +6 -0
- package/dist/components/content-builders/content-builder-render.js +6 -0
- package/dist/components/content-builders/content-builder.d.ts +7 -0
- package/dist/components/content-builders/content-builder.js +24 -0
- package/dist/components/content-builders/fields/fields-tabs.d.ts +5 -0
- package/dist/components/content-builders/fields/fields-tabs.js +9 -0
- package/dist/components/content-builders/index.d.ts +5 -0
- package/dist/components/content-builders/index.js +5 -0
- package/dist/components/content-builders/initial-datas.d.ts +56 -0
- package/dist/components/content-builders/initial-datas.js +818 -0
- package/dist/components/emblas/embla-container.d.ts +8 -0
- package/dist/components/emblas/embla-container.js +13 -0
- package/dist/components/emblas/embla-context.d.ts +21 -0
- package/dist/components/emblas/embla-context.js +13 -0
- package/dist/components/emblas/embla.d.ts +20 -0
- package/dist/components/emblas/embla.js +125 -0
- package/dist/components/emblas/emblas-pagination.d.ts +11 -0
- package/dist/components/emblas/emblas-pagination.js +90 -0
- package/dist/components/emblas/index.d.ts +4 -0
- package/dist/components/emblas/index.js +4 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useCallback } from "react";
|
|
4
|
+
import { cn } from "../../../shadcns/index.js";
|
|
5
|
+
import { useGetPuck } from "@puckeditor/core";
|
|
6
|
+
import { usePuck } from "../content-builder-pucks-hooks";
|
|
7
|
+
export const HeaderBlock = (props) => {
|
|
8
|
+
const data = usePuck((api) => api.appState.data);
|
|
9
|
+
const getPuck = useGetPuck();
|
|
10
|
+
const sortBlockToTop = useCallback(() => {
|
|
11
|
+
const { appState, dispatch, getSelectorForId } = getPuck();
|
|
12
|
+
const headerBlock = data.content.reduce((init, block, index) => block.type == "HeaderBlock" ? { index, block } : init, {});
|
|
13
|
+
const { index, block } = headerBlock ?? {};
|
|
14
|
+
if (index === 0)
|
|
15
|
+
return;
|
|
16
|
+
dispatch({
|
|
17
|
+
type: "reorder",
|
|
18
|
+
sourceIndex: index,
|
|
19
|
+
destinationIndex: 0,
|
|
20
|
+
destinationZone: "root:default-zone",
|
|
21
|
+
});
|
|
22
|
+
requestAnimationFrame(() => {
|
|
23
|
+
dispatch({ type: "setUi", ui: { itemSelector: null } });
|
|
24
|
+
});
|
|
25
|
+
}, [data]);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
sortBlockToTop();
|
|
28
|
+
}, [data]);
|
|
29
|
+
return (_jsx("header", { className: "pt-10", children: _jsxs("div", { className: "px-10 py-2 flex justify-between border-b fixed left-0 top-0 w-full z-90 bg-white h-fit", children: [_jsx("div", { className: "text-xl font-semibold flex-1", children: "LOGO" }), _jsxs("div", { className: "flex-1 flex gap-10 justify-center items-center", children: [_jsx("div", { className: "text-md font-semibold", children: "ABOTU" }), _jsx("div", { className: "text-md font-semibold", children: "PRODUCTS" }), _jsx("div", { className: "text-md font-semibold", children: "SOLUTIONS" }), _jsx("div", { className: "text-md font-semibold", children: "SUPPORT" })] }), _jsx("div", { className: cn("text-2xl font-semibold flex-1 flex justify-end items-center", "[&_span]:w-8", "[&_span]:h-0.5", "[&_span]:bg-black"), children: _jsxs("div", { className: cn("flex flex-col gap-1"), children: [_jsx("span", {}), _jsx("span", {}), _jsx("span", {})] }) })] }) }));
|
|
30
|
+
};
|
|
31
|
+
export const HeaderBlockConfigs = {
|
|
32
|
+
label: "HeaderBlock",
|
|
33
|
+
permissions: {
|
|
34
|
+
drag: false,
|
|
35
|
+
duplicate: false,
|
|
36
|
+
delete: false,
|
|
37
|
+
// edit: false,
|
|
38
|
+
insert: false,
|
|
39
|
+
// editor: false,
|
|
40
|
+
},
|
|
41
|
+
fields: {
|
|
42
|
+
title: {
|
|
43
|
+
label: "Title",
|
|
44
|
+
type: "text",
|
|
45
|
+
contentEditable: true
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
render: HeaderBlock
|
|
49
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ComponentConfig, PuckComponent } from "@puckeditor/core";
|
|
2
|
+
export interface MediaContentProps {
|
|
3
|
+
imgs?: string;
|
|
4
|
+
alt?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const MediaContent: PuckComponent<MediaContentProps>;
|
|
7
|
+
export declare const MediaContentConfigs: ComponentConfig;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
export const MediaContent = ({ alt, imgs, }) => {
|
|
4
|
+
return (_jsx("div", { "data-component": "media-content", children: _jsx("figure", { className: "flex flex-col gap-3 items-center [&_img]:max-w-full w-full", children: _jsx("div", { className: "bg-gray-100 w-full", children: _jsx("img", { src: String(imgs), className: "w-full!" }) }) }) }));
|
|
5
|
+
};
|
|
6
|
+
export const MediaContentConfigs = {
|
|
7
|
+
label: "Media Content",
|
|
8
|
+
permissions: {
|
|
9
|
+
delete: false,
|
|
10
|
+
drag: false,
|
|
11
|
+
insert: false,
|
|
12
|
+
duplicate: false
|
|
13
|
+
},
|
|
14
|
+
fields: {
|
|
15
|
+
imgs: { type: "text" },
|
|
16
|
+
alt: { type: "text", contentEditable: true },
|
|
17
|
+
},
|
|
18
|
+
defaultProps: {
|
|
19
|
+
imgs: "/01.png",
|
|
20
|
+
alt: "alt"
|
|
21
|
+
},
|
|
22
|
+
render: MediaContent
|
|
23
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface Button {
|
|
2
|
+
label?: string;
|
|
3
|
+
link?: string;
|
|
4
|
+
linkBlank?: boolean;
|
|
5
|
+
labelColor?: string;
|
|
6
|
+
bgColor?: string;
|
|
7
|
+
borderColor?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface RootHeaderEditorProps extends React.ComponentProps<"div"> {
|
|
10
|
+
}
|
|
11
|
+
export declare const RootHeaderEditor: React.FC<RootHeaderEditorProps>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useBuilderPucksContext } from "../content-builder-pucks-context";
|
|
3
|
+
import { usePuckPreviewMode } from "../content-builder-pucks-hooks";
|
|
4
|
+
export const RootHeaderEditor = ({ children }) => {
|
|
5
|
+
const { insterBlock, selectBlock } = useBuilderPucksContext();
|
|
6
|
+
const previewMode = usePuckPreviewMode();
|
|
7
|
+
return (_jsx(_Fragment, { children: previewMode == "edit" && _jsx("div", { onClick: (e) => {
|
|
8
|
+
e.stopPropagation();
|
|
9
|
+
selectBlock(null);
|
|
10
|
+
requestAnimationFrame(() => {
|
|
11
|
+
insterBlock();
|
|
12
|
+
});
|
|
13
|
+
}, className: "inset-0 absolute border-2 border-indigo-600 left-0 top-0 opacity-0 bg-indigo-600/5 hover:opacity-100 duration-300 hover:cursor-pointer" }) }));
|
|
14
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../../shadcns/index.js";
|
|
3
|
+
import { RootHeaderEditor } from "./root-header";
|
|
4
|
+
const Roots = ({ puck, editMode, children, title, description, metadata, ...props }) => {
|
|
5
|
+
const { build } = metadata ?? {};
|
|
6
|
+
console.log("root", props);
|
|
7
|
+
return (_jsxs(_Fragment, { children: [_jsxs("header", { className: "px-10 py-2 flex justify-between border-b fixed left-0 w-full z-90 bg-white", children: [_jsx("div", { className: "text-xl font-semibold flex-1", children: "LOGO" }), _jsxs("div", { className: "flex-1 flex gap-10 justify-center items-center", children: [_jsx("div", { className: "text-md font-semibold", children: "ABOTU" }), _jsx("div", { className: "text-md font-semibold", children: "PRODUCTS" }), _jsx("div", { className: "text-md font-semibold", children: "SOLUTIONS" }), _jsx("div", { className: "text-md font-semibold", children: "SUPPORT" })] }), _jsx("div", { className: cn("text-2xl font-semibold flex-1 flex justify-end items-center", "[&_span]:w-8", "[&_span]:h-0.5", "[&_span]:bg-black"), children: _jsxs("div", { className: cn("flex flex-col gap-1"), children: [_jsx("span", {}), _jsx("span", {}), _jsx("span", {})] }) }), build && _jsx(RootHeaderEditor, {})] }), _jsx("main", { className: cn("pt-11.5", "flex", "flex-col", "z-1", "*:data-puck-dropzone:min-h-100!"), children: children }), _jsx("footer", { className: cn("px-10 py-2"), children: description })] }));
|
|
8
|
+
};
|
|
9
|
+
export const BuilderRootsConfigs = {
|
|
10
|
+
label: "Page Content",
|
|
11
|
+
fields: {
|
|
12
|
+
title: { type: "text" },
|
|
13
|
+
description: { type: "textarea" },
|
|
14
|
+
},
|
|
15
|
+
resolveData: async ({ props }, { metadata }) => {
|
|
16
|
+
return { props: { ...props, metadata } };
|
|
17
|
+
},
|
|
18
|
+
defaultProps: {
|
|
19
|
+
title: "Hello, world",
|
|
20
|
+
description: "Lorem ipsum",
|
|
21
|
+
},
|
|
22
|
+
render: Roots
|
|
23
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ComponentConfig, PuckComponent } from "@puckeditor/core";
|
|
2
|
+
export interface Button {
|
|
3
|
+
label?: string;
|
|
4
|
+
link?: string;
|
|
5
|
+
linkBlank?: boolean;
|
|
6
|
+
labelColor?: string;
|
|
7
|
+
bgColor?: string;
|
|
8
|
+
borderColor?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface TextContentProps {
|
|
11
|
+
title?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
subTitle?: string;
|
|
14
|
+
buttons?: Button[];
|
|
15
|
+
imgs?: string;
|
|
16
|
+
options?: any;
|
|
17
|
+
titleOptions?: any;
|
|
18
|
+
}
|
|
19
|
+
export declare const TextContent: PuckComponent<TextContentProps>;
|
|
20
|
+
export declare const TextContentConfigs: ComponentConfig;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../../../shadcns/index.js";
|
|
4
|
+
export const TextContent = ({ title, description, subTitle, buttons, titleOptions, ...props }) => {
|
|
5
|
+
const { tage2 } = titleOptions || {};
|
|
6
|
+
const TitleComponent = tage2 ?? "h3";
|
|
7
|
+
return (_jsx("div", { "data-component": "text-content", className: cn("flex", "justify-center", "p-5"), children: _jsxs("div", { className: cn("flex flex-col gap-10", "justify-start items-start"), children: [_jsxs("hgroup", { "data-component": "text-content-hgroup", className: "flex flex-col gap-3", children: [_jsx(TitleComponent, { "data-component": "text-content-title", className: "text-3xl font-semibold", children: title }), _jsx("p", { "data-component": "text-content-subTitle", className: "text-base font-medium", children: subTitle })] }), _jsx("p", { "data-component": "text-content-description", className: "", children: description }), buttons && buttons?.length > 0 && _jsx("div", { "data-component": "text-content-buttonGroup", className: "flex gap-0.5", children: buttons.map((bt, index) => (_jsx("button", { "data-component": "text-content-button", className: "p-3 border rounded", children: bt.label }, index))) })] }) }));
|
|
8
|
+
};
|
|
9
|
+
export const TextContentConfigs = {
|
|
10
|
+
label: "Text Content",
|
|
11
|
+
permissions: {
|
|
12
|
+
// delete: false,
|
|
13
|
+
// drag: true,
|
|
14
|
+
insert: true,
|
|
15
|
+
},
|
|
16
|
+
// resolvePermissions: async (data, { permissions }) => {
|
|
17
|
+
// console.log("resolvePermissions", data.props);
|
|
18
|
+
// if (data.props?.lockDelete) {
|
|
19
|
+
// return {
|
|
20
|
+
// ...permissions,
|
|
21
|
+
// delete: false,
|
|
22
|
+
// // 建議順便鎖,避免用拖拉/複製繞過「必須至少一個」
|
|
23
|
+
// drag: false,
|
|
24
|
+
// duplicate: false,
|
|
25
|
+
// };
|
|
26
|
+
// }
|
|
27
|
+
// return permissions;
|
|
28
|
+
// },
|
|
29
|
+
// resolveData: async ({ props }, { changed, parent }) => {
|
|
30
|
+
// console.log("resolvePermissions", props);
|
|
31
|
+
// // const isInRoot = !parent?.type || parent.type.startsWith("root");
|
|
32
|
+
// // if (isInRoot) {
|
|
33
|
+
// // console.log("isInRoot", isInRoot);
|
|
34
|
+
// // return {}
|
|
35
|
+
// // }
|
|
36
|
+
// if (changed.buttons && props?.buttons?.length) {
|
|
37
|
+
// const defaultButtons = props.buttons.map((
|
|
38
|
+
// button: Record<string, string>,
|
|
39
|
+
// index: number
|
|
40
|
+
// ) => {
|
|
41
|
+
// if (button?.label == "") button.label = `Unnamed ${Number(index) + 1}`
|
|
42
|
+
// if (!button?.linkTarget) button["linkTarget"] = "yes"
|
|
43
|
+
// return button
|
|
44
|
+
// })
|
|
45
|
+
// console.log("defaultButtons", defaultButtons);
|
|
46
|
+
// return { ...props, buttons: defaultButtons }
|
|
47
|
+
// }
|
|
48
|
+
// return { props }
|
|
49
|
+
// },
|
|
50
|
+
fields: {
|
|
51
|
+
// title2: {
|
|
52
|
+
// label: "Title2",
|
|
53
|
+
// type: "custom",
|
|
54
|
+
// render: ({ onChange, value }) => {
|
|
55
|
+
// const [tab, setTab] = useState("A")
|
|
56
|
+
// return (
|
|
57
|
+
// <FieldLabel label="Title2" readOnly>
|
|
58
|
+
// <div className="flex gap-2">
|
|
59
|
+
// <button
|
|
60
|
+
// onClick={() => setTab("A")}
|
|
61
|
+
// className="flex-1 p-2 border">A</button>
|
|
62
|
+
// <button
|
|
63
|
+
// onClick={() => setTab("B")}
|
|
64
|
+
// className="flex-1 p-2 border">B</button>
|
|
65
|
+
// </div>
|
|
66
|
+
// {tab == "A" && <div>
|
|
67
|
+
// <AutoField
|
|
68
|
+
// field={{ type: "text" }}
|
|
69
|
+
// onChange={onChange}
|
|
70
|
+
// value={value ?? "wade"}
|
|
71
|
+
// readOnly
|
|
72
|
+
// />
|
|
73
|
+
// </div>}
|
|
74
|
+
// {tab == "B" && <div>
|
|
75
|
+
// B
|
|
76
|
+
// </div>}
|
|
77
|
+
// </FieldLabel>
|
|
78
|
+
// )
|
|
79
|
+
// }
|
|
80
|
+
// },
|
|
81
|
+
title: {
|
|
82
|
+
label: "Title",
|
|
83
|
+
type: "text",
|
|
84
|
+
contentEditable: true
|
|
85
|
+
},
|
|
86
|
+
subTitle: {
|
|
87
|
+
label: "Sub Title",
|
|
88
|
+
type: "text",
|
|
89
|
+
contentEditable: true
|
|
90
|
+
},
|
|
91
|
+
description: {
|
|
92
|
+
label: "Description",
|
|
93
|
+
type: "textarea",
|
|
94
|
+
contentEditable: true
|
|
95
|
+
},
|
|
96
|
+
buttons: {
|
|
97
|
+
label: "Buttons",
|
|
98
|
+
type: "array",
|
|
99
|
+
arrayFields: {
|
|
100
|
+
label: {
|
|
101
|
+
label: "Label",
|
|
102
|
+
type: "text",
|
|
103
|
+
contentEditable: true,
|
|
104
|
+
placeholder: "ex: learn more"
|
|
105
|
+
},
|
|
106
|
+
link: {
|
|
107
|
+
label: "Link",
|
|
108
|
+
type: "text",
|
|
109
|
+
placeholder: "ex: http://www.abc.com"
|
|
110
|
+
},
|
|
111
|
+
linkTarget: {
|
|
112
|
+
label: "Link Blank",
|
|
113
|
+
type: "radio",
|
|
114
|
+
options: [
|
|
115
|
+
{ label: "Yes", value: "yes" },
|
|
116
|
+
{ label: "No", value: "no" },
|
|
117
|
+
],
|
|
118
|
+
},
|
|
119
|
+
labelColor: {
|
|
120
|
+
label: "Label Color",
|
|
121
|
+
type: "text",
|
|
122
|
+
placeholder: "ex: #000000"
|
|
123
|
+
},
|
|
124
|
+
backgroundColor: {
|
|
125
|
+
label: "Background Color",
|
|
126
|
+
type: "text",
|
|
127
|
+
placeholder: "ex: #000000"
|
|
128
|
+
},
|
|
129
|
+
borderColor: {
|
|
130
|
+
label: "Border Color",
|
|
131
|
+
type: "text",
|
|
132
|
+
placeholder: "ex: #000000"
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
defaultItemProps: (index) => ({
|
|
136
|
+
label: `Unnamed ${index + 1}`,
|
|
137
|
+
}),
|
|
138
|
+
getItemSummary: (item, index) => {
|
|
139
|
+
return item?.label || `Unnamed ${Number(index) + 1}`;
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
titleOptions: {
|
|
143
|
+
label: "Title",
|
|
144
|
+
type: "object",
|
|
145
|
+
objectFields: {
|
|
146
|
+
content2: {
|
|
147
|
+
label: "Content",
|
|
148
|
+
type: "text"
|
|
149
|
+
},
|
|
150
|
+
tage2: {
|
|
151
|
+
label: "Tag",
|
|
152
|
+
type: "radio",
|
|
153
|
+
options: [
|
|
154
|
+
{ label: "H1", value: "h1" },
|
|
155
|
+
{ label: "H2", value: "h2" },
|
|
156
|
+
{ label: "H3", value: "h3" },
|
|
157
|
+
{ label: "H4", value: "h4" },
|
|
158
|
+
{ label: "H5", value: "h5" },
|
|
159
|
+
{ label: "H6", value: "h6" }
|
|
160
|
+
]
|
|
161
|
+
},
|
|
162
|
+
color2: {
|
|
163
|
+
label: "Color",
|
|
164
|
+
type: "text"
|
|
165
|
+
},
|
|
166
|
+
align2: {
|
|
167
|
+
label: "Align",
|
|
168
|
+
type: "radio",
|
|
169
|
+
options: [
|
|
170
|
+
{ label: "Left", value: "left" },
|
|
171
|
+
{ label: "Center", value: "center" },
|
|
172
|
+
{ label: "Right", value: "right" }
|
|
173
|
+
],
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
defaultProps: {
|
|
179
|
+
title: "Content that adapts to your layout",
|
|
180
|
+
subTitle: "Designed for clarity and consistency",
|
|
181
|
+
description: "This section supports flexible content placement and alignment across different screen sizes.",
|
|
182
|
+
titleOptions: {
|
|
183
|
+
content2: "Content that adapts to your layout",
|
|
184
|
+
tage2: "h3",
|
|
185
|
+
color2: "",
|
|
186
|
+
align2: "left"
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
render: TextContent
|
|
190
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const BuilderActionBar: import("react").MemoExoticComponent<({ children, label }: any) => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { memo, useMemo } from "react";
|
|
4
|
+
import { ArrowDown, ArrowUp, CornerLeftUp, Edit, Plus } from "lucide-react";
|
|
5
|
+
import { ActionBar, useGetPuck } from "@puckeditor/core";
|
|
6
|
+
import { useBuilderContext } from "./content-builder-context";
|
|
7
|
+
import { useBuilderPucksContext } from "./content-builder-pucks-context";
|
|
8
|
+
import { usePuckSelectedItem } from "./content-builder-pucks-hooks";
|
|
9
|
+
export const BuilderActionBar = memo(({ children, label }) => {
|
|
10
|
+
const getPuck = useGetPuck();
|
|
11
|
+
const selectedItem = usePuckSelectedItem();
|
|
12
|
+
const { setBuilderPanelsActive } = useBuilderContext();
|
|
13
|
+
const { selectBlock, insterBlock, orderBlock } = useBuilderPucksContext();
|
|
14
|
+
const parentItem = useMemo(() => {
|
|
15
|
+
const { getParentById } = getPuck();
|
|
16
|
+
const { id: itemId } = selectedItem?.props ?? {};
|
|
17
|
+
return itemId ? getParentById(itemId) : null;
|
|
18
|
+
}, [selectedItem]);
|
|
19
|
+
const isParentRoot = parentItem?.type == "root";
|
|
20
|
+
const isOrder = useMemo(() => {
|
|
21
|
+
const { appState } = getPuck();
|
|
22
|
+
const { id: itemId } = selectedItem?.props ?? {};
|
|
23
|
+
const nextContent = [...appState.data.content];
|
|
24
|
+
const selectedIndex = nextContent.findIndex((item) => item.props.id == itemId);
|
|
25
|
+
const maxIndex = nextContent.length - 1;
|
|
26
|
+
return {
|
|
27
|
+
up: selectedIndex > 0,
|
|
28
|
+
down: selectedIndex < maxIndex
|
|
29
|
+
};
|
|
30
|
+
}, [selectedItem]);
|
|
31
|
+
const selectItemParent = () => {
|
|
32
|
+
const { id: itemId } = parentItem?.props ?? {};
|
|
33
|
+
if (isParentRoot || !itemId)
|
|
34
|
+
return;
|
|
35
|
+
selectBlock(itemId);
|
|
36
|
+
};
|
|
37
|
+
return (_jsx(_Fragment, { children: selectedItem && _jsx("div", { className: "relative *:h-8.5 flex justify-end flex-col pt-1.5", children: _jsxs("div", { className: "bg-gray-900 rounded flex flex-rows items-end text-white leading-none border shadow-2xl", children: [_jsxs(ActionBar.Group, { children: [!isParentRoot && _jsx(ActionBar.Action, { label: `Select ${parentItem?.type}`, onClick: (e) => {
|
|
38
|
+
e.stopPropagation();
|
|
39
|
+
selectItemParent();
|
|
40
|
+
}, children: _jsx(CornerLeftUp, { size: 15 }) }), _jsx(ActionBar.Label, { label: label })] }), _jsxs(ActionBar.Group, { children: [isParentRoot && _jsx(ActionBar.Action, { label: "Moving Up", disabled: !isOrder.up, onClick: (e) => {
|
|
41
|
+
e.stopPropagation();
|
|
42
|
+
if (!selectedItem?.props)
|
|
43
|
+
return;
|
|
44
|
+
orderBlock("up");
|
|
45
|
+
}, children: _jsx(ArrowUp, { size: 16 }) }), isParentRoot && _jsx(ActionBar.Action, { label: "Moving Down", disabled: !isOrder.down, onClick: (e) => {
|
|
46
|
+
e.stopPropagation();
|
|
47
|
+
if (!selectedItem?.props)
|
|
48
|
+
return;
|
|
49
|
+
orderBlock("down");
|
|
50
|
+
}, children: _jsx(ArrowDown, { size: 16 }) })] }), _jsxs(ActionBar.Group, { children: [isParentRoot && _jsx(ActionBar.Action, { label: "Inster Block", onClick: (e) => {
|
|
51
|
+
e.stopPropagation();
|
|
52
|
+
if (!selectedItem?.props)
|
|
53
|
+
return;
|
|
54
|
+
insterBlock("after");
|
|
55
|
+
}, children: _jsx(Plus, { size: 18 }) }), _jsx(ActionBar.Action, { label: "Edit", onClick: (e) => {
|
|
56
|
+
e.stopPropagation();
|
|
57
|
+
if (!selectedItem?.props)
|
|
58
|
+
return;
|
|
59
|
+
setBuilderPanelsActive("contentEditor", true);
|
|
60
|
+
}, children: _jsx(Edit, { size: 16 }) }), children] })] }) }) }));
|
|
61
|
+
});
|
|
62
|
+
function getPuck() {
|
|
63
|
+
throw new Error("Function not implemented.");
|
|
64
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { AlertDialog, AlertDialogCancel, AlertDialogContent, } from "../../shadcns/index.js";
|
|
4
|
+
import { useBuilderContext } from "./content-builder-context";
|
|
5
|
+
import { cn } from "../../shadcns/index.js";
|
|
6
|
+
import { Tabs, TabsContent, TabsList } from "../../shadcns/index.js";
|
|
7
|
+
import { X } from "lucide-react";
|
|
8
|
+
import { initialData } from "./initial-datas";
|
|
9
|
+
import { blacksConfigs } from "./content-builder-configs";
|
|
10
|
+
import { useEffect } from "react";
|
|
11
|
+
import { BuilderBlocks } from "./content-builder-blocks";
|
|
12
|
+
export const BuilderBlocksDialog = () => {
|
|
13
|
+
const { config, blocksViews, setBuilderNewBlocks, builderProps, setBuilderDragging } = useBuilderContext();
|
|
14
|
+
const { components, categories } = builderProps.config ?? {};
|
|
15
|
+
const { other, ...restCategories } = categories ?? {};
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (blocksViews?.active)
|
|
18
|
+
setBuilderDragging(blocksViews.active);
|
|
19
|
+
return () => { setBuilderDragging(false); };
|
|
20
|
+
}, [blocksViews.active]);
|
|
21
|
+
return (_jsx(AlertDialog, { open: blocksViews.active, onOpenChange: setBuilderNewBlocks, children: _jsx(AlertDialogContent, { className: cn("w-full!", "max-w-360!", "h-[90dvh]!", "p-0", "rounded-sm", "gap-0", "shadow-2xl"), children: _jsxs("div", { className: cn("relative overflow-hidden h-full w-full"), children: [_jsx("div", { className: cn("absolute right-0 top-0 z-10"), children: _jsx(AlertDialogCancel, { className: cn("border-none shadow-none hover:bg-transparent"), children: _jsx(X, { size: 17 }) }) }), _jsx("div", { className: "h-full flex flex-rows gap-15 overflow-hidden", children: _jsxs(Tabs, { defaultValue: "overview", className: cn("flex-1 flex"), children: [_jsxs("div", { className: "w-70 p-10 space-y-10", children: [_jsx("div", { className: cn("text-xl font-semibold"), children: "Blocks View" }), _jsx(TabsList, { className: cn("flex flex-col justify-start items-start rounded-none bg-transparent p-0 m-0 w-full"), children: categories && Object.keys(categories).map((key, index) => {
|
|
22
|
+
const { title, components } = categories[key];
|
|
23
|
+
return (_jsx("div", { children: "tabs" })
|
|
24
|
+
// <TabsTrigger
|
|
25
|
+
// key={index}
|
|
26
|
+
// value={title ?? ""}
|
|
27
|
+
// render={({ className, ...props }: any) =>
|
|
28
|
+
// <div
|
|
29
|
+
// className={cn(
|
|
30
|
+
// "w-full",
|
|
31
|
+
// "px-2",
|
|
32
|
+
// "py-1.5",
|
|
33
|
+
// "data-active:text-white",
|
|
34
|
+
// "data-active:bg-black",
|
|
35
|
+
// "duration-200"
|
|
36
|
+
// )}
|
|
37
|
+
// {...props}
|
|
38
|
+
// >
|
|
39
|
+
// {title}
|
|
40
|
+
// </div>
|
|
41
|
+
// }
|
|
42
|
+
// />
|
|
43
|
+
);
|
|
44
|
+
}) })] }), _jsxs("div", { className: cn("w-6xl", "overflow-hidden"), children: [_jsx(TabsContent, { value: "Base", className: cn("h-full"), children: _jsx(BuilderBlocks, { data: initialData, config: blacksConfigs, category: "Base" }) }), _jsx(TabsContent, { value: "Base2", className: cn("h-full"), children: "reports" }), _jsx(TabsContent, { value: "Base3", className: cn("h-full"), children: "settings" })] })] }) })] }) }) }));
|
|
45
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PuckComponent, PuckContext, RootConfig } from "@puckeditor/core";
|
|
2
|
+
import type { PuckProps } from "./content-builder-builder";
|
|
3
|
+
export interface BlocksComponentProps extends React.ComponentProps<"div"> {
|
|
4
|
+
puck: PuckContext;
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const BuilderBlocksComponent: React.FC<BlocksComponentProps>;
|
|
8
|
+
export declare const BuilderBlocks: React.FC<PuckProps & {
|
|
9
|
+
category?: string;
|
|
10
|
+
}>;
|
|
11
|
+
export interface BuilderBlocksRootsProps {
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
}
|
|
14
|
+
export declare const BuilderBlocksRoots: PuckComponent<BuilderBlocksRootsProps>;
|
|
15
|
+
export declare const BuilderBlocksRootsConfigs: RootConfig;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { memo, useEffect, useRef } from "react";
|
|
4
|
+
import { Puck } from "@puckeditor/core";
|
|
5
|
+
import { cn } from "../../shadcns/index.js";
|
|
6
|
+
import { useBuilderContext } from "./content-builder-context";
|
|
7
|
+
import { BuilderIframe } from "./content-builder-iframe";
|
|
8
|
+
export const BuilderBlocksComponent = memo(({ children, name, puck }) => {
|
|
9
|
+
const { metadata } = puck;
|
|
10
|
+
const isBlockview = !!metadata?.blockview;
|
|
11
|
+
const { setBuilderNewBlocks } = useBuilderContext();
|
|
12
|
+
const ref = useRef(null);
|
|
13
|
+
const resizeRef = useRef(null);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (!ref?.current || !resizeRef?.current)
|
|
16
|
+
return;
|
|
17
|
+
const { width, height } = ref.current.getBoundingClientRect();
|
|
18
|
+
}, [ref?.current]);
|
|
19
|
+
return (_jsx(_Fragment, { children: isBlockview
|
|
20
|
+
? _jsx("div", { "data-component": "builder-blocks-component", ref: resizeRef, className: cn("**:pointer-events-none", "**:select-none", "my-15", "first:mt-0", "last:mb-0", "border", "rounded-sm", "overflow-hidden", "duration-200", "hover:border-indigo-600", "hover:shadow-xl"), onClick: () => {
|
|
21
|
+
name && setBuilderNewBlocks(name);
|
|
22
|
+
}, children: _jsx("div", { ref: ref, className: cn("w-screen", "origin-top-left"), style: { zoom: "0.372" }, children: children }) })
|
|
23
|
+
: children }));
|
|
24
|
+
});
|
|
25
|
+
export const BuilderBlocks = memo(({ category = "Block Category", ...props }) => {
|
|
26
|
+
if (!props?.data || !props?.config)
|
|
27
|
+
return null;
|
|
28
|
+
return (_jsx("div", { className: cn("w-360", "h-full", "overflow-hidden", "rounded"), children: _jsx(Puck, { ui: { previewMode: "interactive" }, overrides: { iframe: BuilderIframe }, metadata: { blockview: true, blockCategory: category }, height: "100%", ...props, children: _jsx(Puck.Preview, { "data-component": "builder-blocks-preview", id: "builders-blocks-preview" }) }) }));
|
|
29
|
+
});
|
|
30
|
+
export const BuilderBlocksRoots = ({ children, puck, ...props }) => {
|
|
31
|
+
const { metadata } = puck;
|
|
32
|
+
return (_jsxs("div", { "data-component": "builder-blocks-roots", className: cn("py-10", "space-y-11", "*:w-6xl", "*:pr-10", "*:nth-2:columns-2", "*:nth-2:gap-10"), children: [_jsx("div", { className: "text-base font-semibold", children: metadata?.blockCategory ?? "Block Category" }), children] }));
|
|
33
|
+
};
|
|
34
|
+
export const BuilderBlocksRootsConfigs = {
|
|
35
|
+
label: "Builder Blocks",
|
|
36
|
+
resolveData: async ({ props }, { metadata }) => {
|
|
37
|
+
return { props: { ...props, metadata } };
|
|
38
|
+
},
|
|
39
|
+
render: BuilderBlocksRoots
|
|
40
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ComponentData, Config, RootData } from "@puckeditor/core";
|
|
2
|
+
export interface PuckProps {
|
|
3
|
+
data: {
|
|
4
|
+
root: RootData;
|
|
5
|
+
content: ComponentData[];
|
|
6
|
+
};
|
|
7
|
+
metadata?: Record<string, any>;
|
|
8
|
+
overrides?: Record<string, any>;
|
|
9
|
+
config: Config;
|
|
10
|
+
height?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const BuilderRoots: React.FC<React.ComponentProps<"div">>;
|
|
13
|
+
export declare const Builder: React.FC<React.ComponentProps<"div">>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { memo } from "react";
|
|
4
|
+
import { Puck, } from "@puckeditor/core";
|
|
5
|
+
import { useBuilderContext } from "./content-builder-context";
|
|
6
|
+
import { cn } from "../../shadcns/index.js";
|
|
7
|
+
export const BuilderRoots = memo((props) => {
|
|
8
|
+
const { builderRef, viewport } = useBuilderContext();
|
|
9
|
+
const isFullScreen = viewport.view == "fullscreen";
|
|
10
|
+
return (_jsx("div", { ref: builderRef, "data-component": "builder-roots", className: cn("w-full h-full relative", "data-[drag=true]:pointer-events-none!", isFullScreen && ["fixed top-0 w-screen h-screen"]), ...props }));
|
|
11
|
+
});
|
|
12
|
+
export const Builder = memo(({ children, ...props }) => {
|
|
13
|
+
const { builderProps } = useBuilderContext();
|
|
14
|
+
// TODO 在這裡預設放入config設定
|
|
15
|
+
const { height = "100%", ...puckProps } = builderProps;
|
|
16
|
+
return (_jsx(BuilderRoots, { ...props, children: _jsx(Puck, { height: height, ...puckProps, children: children }) }));
|
|
17
|
+
});
|