@crediblemark/build 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/LICENSE +21 -0
  2. package/dist/Editor-XZF6CWVW.css +404 -0
  3. package/dist/Editor-ZC67OU2A.mjs +205 -0
  4. package/dist/Render-JBFI6HYN.mjs +55 -0
  5. package/dist/Render-WCX4AXOX.css +102 -0
  6. package/dist/actions-CEH_5LMY.d.mts +838 -0
  7. package/dist/actions-CEH_5LMY.d.ts +838 -0
  8. package/dist/chunk-3AJBFQU4.mjs +560 -0
  9. package/dist/chunk-4SQOX3ZQ.mjs +476 -0
  10. package/dist/chunk-B4BOBGYB.mjs +42 -0
  11. package/dist/chunk-CDMESQDA.mjs +148 -0
  12. package/dist/chunk-DSXRK4QJ.mjs +704 -0
  13. package/dist/chunk-GUJDGRSM.mjs +469 -0
  14. package/dist/chunk-HHBUU7WF.mjs +35 -0
  15. package/dist/chunk-IJHL7BIR.mjs +11 -0
  16. package/dist/chunk-PHGC6QYB.mjs +105 -0
  17. package/dist/chunk-QF3GD5WQ.mjs +65 -0
  18. package/dist/chunk-U2NVBXAC.mjs +2064 -0
  19. package/dist/chunk-VFD76OD5.mjs +55 -0
  20. package/dist/chunk-VGDMWS44.mjs +107 -0
  21. package/dist/chunk-VKBVSWU3.mjs +8538 -0
  22. package/dist/chunk-YH7AXYKP.mjs +109 -0
  23. package/dist/full-ABQQRJAO.css +301 -0
  24. package/dist/full-LJRK5736.mjs +94 -0
  25. package/dist/index-CkSfgrvw.d.ts +117 -0
  26. package/dist/index-Cxwg4vUV.d.mts +117 -0
  27. package/dist/index.css +2576 -0
  28. package/dist/index.d.mts +310 -0
  29. package/dist/index.d.ts +310 -0
  30. package/dist/index.js +15012 -0
  31. package/dist/index.mjs +83 -0
  32. package/dist/internal.d.mts +27 -0
  33. package/dist/internal.d.ts +27 -0
  34. package/dist/internal.js +960 -0
  35. package/dist/internal.mjs +13 -0
  36. package/dist/loaded-DWCENJKQ.mjs +55 -0
  37. package/dist/loaded-N7VXUR4O.mjs +59 -0
  38. package/dist/loaded-NE2PIHUQ.mjs +56 -0
  39. package/dist/loaded-SMEIWWHS.css +87 -0
  40. package/dist/no-external.css +2574 -0
  41. package/dist/no-external.d.mts +21 -0
  42. package/dist/no-external.d.ts +21 -0
  43. package/dist/no-external.js +15012 -0
  44. package/dist/no-external.mjs +83 -0
  45. package/dist/rsc.css +102 -0
  46. package/dist/rsc.d.mts +27 -0
  47. package/dist/rsc.d.ts +27 -0
  48. package/dist/rsc.js +1466 -0
  49. package/dist/rsc.mjs +147 -0
  50. package/dist/walk-tree-B4ZvMfxS.d.ts +29 -0
  51. package/dist/walk-tree-C78ZVz19.d.mts +29 -0
  52. package/package.json +145 -0
package/dist/rsc.mjs ADDED
@@ -0,0 +1,147 @@
1
+ import {
2
+ SlotRenderPure,
3
+ migrate,
4
+ resolveAllData,
5
+ transformProps,
6
+ useRichtextProps,
7
+ useSlots
8
+ } from "./chunk-4SQOX3ZQ.mjs";
9
+ import "./chunk-IJHL7BIR.mjs";
10
+ import "./chunk-CDMESQDA.mjs";
11
+ import "./chunk-YH7AXYKP.mjs";
12
+ import {
13
+ rootAreaId,
14
+ rootDroppableId,
15
+ rootZone,
16
+ setupZone,
17
+ walkTree
18
+ } from "./chunk-GUJDGRSM.mjs";
19
+ import {
20
+ init_react_import
21
+ } from "./chunk-B4BOBGYB.mjs";
22
+
23
+ // bundle/rsc.tsx
24
+ init_react_import();
25
+
26
+ // components/ServerRender/index.tsx
27
+ init_react_import();
28
+ import { Fragment, jsx } from "react/jsx-runtime";
29
+ function DropZoneRenderItem({
30
+ item,
31
+ data,
32
+ config,
33
+ metadata
34
+ }) {
35
+ const Component = config.components[item.type];
36
+ const props = {
37
+ ...item.props,
38
+ credbuild: {
39
+ renderDropZone: ({ zone }) => /* @__PURE__ */ jsx(
40
+ DropZoneRender,
41
+ {
42
+ zone,
43
+ data,
44
+ areaId: item.props.id,
45
+ config,
46
+ metadata
47
+ }
48
+ ),
49
+ metadata,
50
+ dragRef: null,
51
+ isEditing: false
52
+ }
53
+ };
54
+ const renderItem = { ...item, props };
55
+ const propsWithSlots = useSlots(config, renderItem, (slotProps) => /* @__PURE__ */ jsx(SlotRenderPure, { ...slotProps, config, metadata }));
56
+ const richtextProps = useRichtextProps(Component?.fields, propsWithSlots);
57
+ if (!Component) {
58
+ return null;
59
+ }
60
+ return /* @__PURE__ */ jsx(Component.render, { ...propsWithSlots, ...richtextProps });
61
+ }
62
+ function DropZoneRender({
63
+ zone,
64
+ data,
65
+ areaId = "root",
66
+ config,
67
+ metadata = {}
68
+ }) {
69
+ let zoneCompound = rootDroppableId;
70
+ let content = data?.content || [];
71
+ if (!data || !config) {
72
+ return null;
73
+ }
74
+ if (areaId !== rootAreaId && zone !== rootZone) {
75
+ zoneCompound = `${areaId}:${zone}`;
76
+ content = setupZone(data, zoneCompound).zones[zoneCompound];
77
+ }
78
+ return /* @__PURE__ */ jsx(Fragment, { children: content.map((item) => {
79
+ return /* @__PURE__ */ jsx(
80
+ DropZoneRenderItem,
81
+ {
82
+ item,
83
+ data,
84
+ config,
85
+ metadata
86
+ },
87
+ item.props.id
88
+ );
89
+ }) });
90
+ }
91
+ function Render({
92
+ config,
93
+ data,
94
+ metadata = {}
95
+ }) {
96
+ const rootProps = "props" in data.root ? data.root.props : data.root;
97
+ const title = rootProps.title || "";
98
+ const props = {
99
+ ...rootProps,
100
+ credbuild: {
101
+ renderDropZone: ({ zone }) => /* @__PURE__ */ jsx(
102
+ DropZoneRender,
103
+ {
104
+ zone,
105
+ data,
106
+ config,
107
+ metadata
108
+ }
109
+ ),
110
+ isEditing: false,
111
+ dragRef: null,
112
+ metadata
113
+ },
114
+ title,
115
+ editMode: false,
116
+ id: "credbuild-root"
117
+ };
118
+ const propsWithSlots = useSlots(config, { type: "root", props }, (props2) => /* @__PURE__ */ jsx(SlotRenderPure, { ...props2, config, metadata }));
119
+ const richtextProps = useRichtextProps(config.root?.fields, props);
120
+ if (config.root?.render) {
121
+ return /* @__PURE__ */ jsx(config.root.render, { ...propsWithSlots, ...richtextProps, children: /* @__PURE__ */ jsx(
122
+ DropZoneRender,
123
+ {
124
+ config,
125
+ data,
126
+ zone: rootZone,
127
+ metadata
128
+ }
129
+ ) });
130
+ }
131
+ return /* @__PURE__ */ jsx(
132
+ DropZoneRender,
133
+ {
134
+ config,
135
+ data,
136
+ zone: rootZone,
137
+ metadata
138
+ }
139
+ );
140
+ }
141
+ export {
142
+ Render,
143
+ migrate,
144
+ resolveAllData,
145
+ transformProps,
146
+ walkTree
147
+ };
@@ -0,0 +1,29 @@
1
+ import { a as Config, D as Data, W as WithId, U as UserGenerics, b as Content, c as ComponentData, d as DefaultComponents, e as DefaultComponentProps, f as DefaultRootFieldProps, M as Metadata, R as RootData } from './actions-CEH_5LMY.js';
2
+
3
+ type MigrationOptions<UserConfig extends Config> = {
4
+ migrateDynamicZonesForComponent?: {
5
+ [ComponentName in keyof UserConfig["components"]]: (props: WithId<UserGenerics<UserConfig>["UserProps"][ComponentName]>, zones: Record<string, Content>) => ComponentData["props"];
6
+ };
7
+ };
8
+ declare function migrate<UserConfig extends Config = Config>(data: Data, config?: UserConfig, migrationOptions?: MigrationOptions<UserConfig>): Data;
9
+
10
+ type PropTransform<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
11
+ [ComponentName in keyof Components]: (props: Components[ComponentName] & {
12
+ [key: string]: any;
13
+ }) => Components[ComponentName];
14
+ } & {
15
+ root: (props: RootProps & {
16
+ [key: string]: any;
17
+ }) => RootProps;
18
+ }>;
19
+ declare function transformProps<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Components, RootProps>, config?: Config): Data;
20
+
21
+ declare function resolveAllData<Components extends DefaultComponents = DefaultComponents, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, metadata?: Metadata, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Components, RootProps>>;
22
+
23
+ type WalkTreeOptions = {
24
+ parentId: string;
25
+ propName: string;
26
+ };
27
+ declare function walkTree<T extends ComponentData | RootData | G["UserData"], UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(data: T, config: UserConfig, callbackFn: (data: Content, options: WalkTreeOptions) => Content | null | void): T;
28
+
29
+ export { migrate as m, resolveAllData as r, transformProps as t, walkTree as w };
@@ -0,0 +1,29 @@
1
+ import { a as Config, D as Data, W as WithId, U as UserGenerics, b as Content, c as ComponentData, d as DefaultComponents, e as DefaultComponentProps, f as DefaultRootFieldProps, M as Metadata, R as RootData } from './actions-CEH_5LMY.mjs';
2
+
3
+ type MigrationOptions<UserConfig extends Config> = {
4
+ migrateDynamicZonesForComponent?: {
5
+ [ComponentName in keyof UserConfig["components"]]: (props: WithId<UserGenerics<UserConfig>["UserProps"][ComponentName]>, zones: Record<string, Content>) => ComponentData["props"];
6
+ };
7
+ };
8
+ declare function migrate<UserConfig extends Config = Config>(data: Data, config?: UserConfig, migrationOptions?: MigrationOptions<UserConfig>): Data;
9
+
10
+ type PropTransform<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
11
+ [ComponentName in keyof Components]: (props: Components[ComponentName] & {
12
+ [key: string]: any;
13
+ }) => Components[ComponentName];
14
+ } & {
15
+ root: (props: RootProps & {
16
+ [key: string]: any;
17
+ }) => RootProps;
18
+ }>;
19
+ declare function transformProps<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Components, RootProps>, config?: Config): Data;
20
+
21
+ declare function resolveAllData<Components extends DefaultComponents = DefaultComponents, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, metadata?: Metadata, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Components, RootProps>>;
22
+
23
+ type WalkTreeOptions = {
24
+ parentId: string;
25
+ propName: string;
26
+ };
27
+ declare function walkTree<T extends ComponentData | RootData | G["UserData"], UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(data: T, config: UserConfig, callbackFn: (data: Content, options: WalkTreeOptions) => Content | null | void): T;
28
+
29
+ export { migrate as m, resolveAllData as r, transformProps as t, walkTree as w };
package/package.json ADDED
@@ -0,0 +1,145 @@
1
+ {
2
+ "name": "@crediblemark/build",
3
+ "version": "0.22.0",
4
+ "description": "The open-source visual editor for React",
5
+ "author": "Rasyiqi Crediblemark",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/crediblemark-official/credbuild.git",
9
+ "directory": "."
10
+ },
11
+ "bugs": "https://build.crediblemark.com/issues",
12
+ "homepage": "https://build.crediblemark.com",
13
+ "keywords": [
14
+ "credbuild",
15
+ "visual",
16
+ "editor",
17
+ "react",
18
+ "drag and drop",
19
+ "dnd",
20
+ "page",
21
+ "website",
22
+ "builder",
23
+ "headless",
24
+ "cms",
25
+ "low-code",
26
+ "no-code",
27
+ "javascript",
28
+ "typescript",
29
+ "WYSIWYG"
30
+ ],
31
+ "private": false,
32
+ "main": "./dist/index.js",
33
+ "types": "./dist/index.d.ts",
34
+ "exports": {
35
+ ".": {
36
+ "react-server": {
37
+ "types": "./dist/rsc.d.ts",
38
+ "import": "./dist/rsc.mjs",
39
+ "require": "./dist/rsc.js"
40
+ },
41
+ "default": {
42
+ "types": "./dist/index.d.ts",
43
+ "import": "./dist/index.mjs",
44
+ "require": "./dist/index.js"
45
+ }
46
+ },
47
+ "./rsc": {
48
+ "types": "./dist/rsc.d.ts",
49
+ "import": "./dist/rsc.mjs",
50
+ "require": "./dist/rsc.js"
51
+ },
52
+ "./internal": {
53
+ "types": "./dist/internal.d.ts",
54
+ "import": "./dist/internal.mjs",
55
+ "require": "./dist/internal.js"
56
+ },
57
+ "./credbuild.css": "./dist/index.css",
58
+ "./no-external.css": "./dist/no-external.css",
59
+ "./dist/index.css": "./dist/index.css",
60
+ "./package.json": "./package.json"
61
+ },
62
+ "typesVersions": {
63
+ "*": {
64
+ "rsc": [
65
+ "./dist/rsc.js"
66
+ ]
67
+ }
68
+ },
69
+ "license": "MIT",
70
+ "scripts": {
71
+ "lint": "eslint \"**/*.ts*\"",
72
+ "build": "rm -rf dist && tsup bundle/index.ts bundle/rsc.tsx bundle/no-external.ts bundle/internal.ts",
73
+ "dev": "tsup bundle/index.ts bundle/rsc.tsx bundle/no-external.ts bundle/internal.ts --watch",
74
+ "test": "jest",
75
+ "prepublishOnly": "npm run build"
76
+ },
77
+ "files": [
78
+ "dist"
79
+ ],
80
+ "devDependencies": {
81
+ "@juggle/resize-observer": "^3.4.0",
82
+ "@testing-library/jest-dom": "^6.6.3",
83
+ "@testing-library/react": "^16.1.0",
84
+ "@types/deep-diff": "^1.0.3",
85
+ "@types/flat": "^5.0.5",
86
+ "@types/jest": "^29.5.14",
87
+ "@types/node": "^24.12.2",
88
+ "@types/object-hash": "^3.0.6",
89
+ "@types/react": "^19.2.7",
90
+ "@types/react-dom": "^19.2.3",
91
+ "@types/uuid": "^10.0.0",
92
+ "css-box-model": "^1.2.1",
93
+ "eslint": "^8.57.0",
94
+ "identity-obj-proxy": "^3.0.0",
95
+ "jest": "^29.7.0",
96
+ "jest-environment-jsdom": "^30.0.0-beta.3",
97
+ "lucide-react": "^0.556.0",
98
+ "ts-jest": "^29.3.4",
99
+ "tsup": "^8.2.4",
100
+ "typescript": "^5.5.4"
101
+ },
102
+ "dependencies": {
103
+ "@dnd-kit/abstract": "0.1.21",
104
+ "@dnd-kit/collision": "0.1.21",
105
+ "@dnd-kit/dom": "0.1.21",
106
+ "@dnd-kit/geometry": "0.1.21",
107
+ "@dnd-kit/helpers": "0.1.18",
108
+ "@dnd-kit/react": "0.1.18",
109
+ "@dnd-kit/state": "0.1.21",
110
+ "@radix-ui/react-popover": "^1.1.15",
111
+ "@tanstack/react-virtual": "^3.13.9",
112
+ "@tiptap/core": "^3.11.1",
113
+ "@tiptap/extension-blockquote": "^3.11.1",
114
+ "@tiptap/extension-bold": "^3.11.1",
115
+ "@tiptap/extension-code": "^3.11.1",
116
+ "@tiptap/extension-code-block": "^3.11.1",
117
+ "@tiptap/extension-document": "^3.11.1",
118
+ "@tiptap/extension-hard-break": "^3.11.1",
119
+ "@tiptap/extension-heading": "^3.11.1",
120
+ "@tiptap/extension-horizontal-rule": "^3.11.1",
121
+ "@tiptap/extension-italic": "^3.11.1",
122
+ "@tiptap/extension-link": "^3.11.1",
123
+ "@tiptap/extension-list": "^3.11.1",
124
+ "@tiptap/extension-paragraph": "^3.11.1",
125
+ "@tiptap/extension-strike": "^3.11.1",
126
+ "@tiptap/extension-text": "^3.11.1",
127
+ "@tiptap/extension-text-align": "^3.11.1",
128
+ "@tiptap/extension-underline": "^3.11.1",
129
+ "@tiptap/html": "^3.11.1",
130
+ "@tiptap/pm": "^3.11.1",
131
+ "@tiptap/react": "^3.11.1",
132
+ "deep-diff": "^1.0.2",
133
+ "fast-equals": "5.2.2",
134
+ "flat": "^5.0.2",
135
+ "happy-dom": "^20.0.10",
136
+ "object-hash": "^3.0.0",
137
+ "react-hotkeys-hook": "^4.6.1",
138
+ "use-debounce": "^9.0.4",
139
+ "uuid": "^9.0.1",
140
+ "zustand": "^5.0.3"
141
+ },
142
+ "peerDependencies": {
143
+ "react": "^18.0.0 || ^19.0.0"
144
+ }
145
+ }