@simple-builder/react 1.0.3 → 1.0.5

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.
@@ -1,5 +1,5 @@
1
- import { BuilderProvider, useBuilder, Button } from './chunk-LPIHSXYO.mjs';
2
- import { BuildContainer } from './chunk-FGQSJAOO.mjs';
1
+ import { BuilderProvider, useBuilder, Button } from './chunk-V2LC2Z4Q.mjs';
2
+ import { BuildContainer } from './chunk-XHPQBTIC.mjs';
3
3
  import * as React2 from 'react';
4
4
 
5
5
  var BuilderHeader = () => {
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkGSOMMLCG_js = require('./chunk-GSOMMLCG.js');
4
- var chunkUZFAGH6G_js = require('./chunk-UZFAGH6G.js');
3
+ var chunkPJOHRI67_js = require('./chunk-PJOHRI67.js');
4
+ var chunk5YLARMT3_js = require('./chunk-5YLARMT3.js');
5
5
  var React2 = require('react');
6
6
 
7
7
  function _interopNamespace(e) {
@@ -25,17 +25,17 @@ function _interopNamespace(e) {
25
25
  var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
26
26
 
27
27
  var BuilderHeader = () => {
28
- const { save } = chunkGSOMMLCG_js.useBuilder();
29
- return /* @__PURE__ */ React2__namespace.createElement("div", { className: "sb-grid sb-grid-cols-3 sb-gap-4 sb-items-center sb-p-2 sb-shadow-lg sb-sticky sb-inset-x-0 sb-top-0 sb-bg-background sb-z-30" }, /* @__PURE__ */ React2__namespace.createElement("div", { className: "sb-flex sb-gap-4 sb-items-center" }, /* @__PURE__ */ React2__namespace.createElement(chunkGSOMMLCG_js.Button, { variant: "ghost", size: "sm", onClick: save }, "Opslaan")));
28
+ const { save } = chunkPJOHRI67_js.useBuilder();
29
+ return /* @__PURE__ */ React2__namespace.createElement("div", { className: "sb-grid sb-grid-cols-3 sb-gap-4 sb-items-center sb-p-2 sb-shadow-lg sb-sticky sb-inset-x-0 sb-top-0 sb-bg-background sb-z-30" }, /* @__PURE__ */ React2__namespace.createElement("div", { className: "sb-flex sb-gap-4 sb-items-center" }, /* @__PURE__ */ React2__namespace.createElement(chunkPJOHRI67_js.Button, { variant: "ghost", size: "sm", onClick: save }, "Opslaan")));
30
30
  };
31
31
 
32
32
  // src/components/builder-content.tsx
33
33
  var BuilderContent = (props) => {
34
- return /* @__PURE__ */ React2__namespace.createElement(chunkGSOMMLCG_js.BuilderProvider, { content: props.content }, /* @__PURE__ */ React2__namespace.createElement(BuilderContentInner, null));
34
+ return /* @__PURE__ */ React2__namespace.createElement(chunkPJOHRI67_js.BuilderProvider, { content: props.content }, /* @__PURE__ */ React2__namespace.createElement(BuilderContentInner, null));
35
35
  };
36
36
  var BuilderContentInner = () => {
37
- const { content } = chunkGSOMMLCG_js.useBuilder();
38
- return /* @__PURE__ */ React2__namespace.createElement(React2__namespace.Fragment, null, /* @__PURE__ */ React2__namespace.createElement(BuilderHeader, null), /* @__PURE__ */ React2__namespace.createElement(chunkUZFAGH6G_js.BuildContainer, { name: "root", edit: true, multiple: true, content }));
37
+ const { content } = chunkPJOHRI67_js.useBuilder();
38
+ return /* @__PURE__ */ React2__namespace.createElement(React2__namespace.Fragment, null, /* @__PURE__ */ React2__namespace.createElement(BuilderHeader, null), /* @__PURE__ */ React2__namespace.createElement(chunk5YLARMT3_js.BuildContainer, { name: "root", edit: true, multiple: true, content }));
39
39
  };
40
40
  var builder_content_default = BuilderContent;
41
41
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkUZFAGH6G_js = require('./chunk-UZFAGH6G.js');
3
+ var chunk5YLARMT3_js = require('./chunk-5YLARMT3.js');
4
4
  var React = require('react');
5
5
 
6
6
  function _interopNamespace(e) {
@@ -25,7 +25,7 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
25
25
 
26
26
  var StaticContent = (props) => {
27
27
  return /* @__PURE__ */ React__namespace.createElement(
28
- chunkUZFAGH6G_js.BuildContainer,
28
+ chunk5YLARMT3_js.BuildContainer,
29
29
  {
30
30
  name: "root",
31
31
  edit: false,
@@ -36,7 +36,7 @@ var StaticContent = (props) => {
36
36
  };
37
37
 
38
38
  // src/index.ts
39
- var BuilderContent = React.lazy(() => import('./builder-content-BOQEXOAK.js'));
39
+ var BuilderContent = React.lazy(() => import('./builder-content-RAITJRFM.js'));
40
40
 
41
41
  exports.BuilderContent = BuilderContent;
42
42
  exports.StaticContent = StaticContent;
@@ -1,4 +1,4 @@
1
- import { BuildContainer } from './chunk-FGQSJAOO.mjs';
1
+ import { BuildContainer } from './chunk-XHPQBTIC.mjs';
2
2
  import * as React from 'react';
3
3
  import { lazy } from 'react';
4
4
 
@@ -15,6 +15,6 @@ var StaticContent = (props) => {
15
15
  };
16
16
 
17
17
  // src/index.ts
18
- var BuilderContent = lazy(() => import('./builder-content-MNCJZTFS.mjs'));
18
+ var BuilderContent = lazy(() => import('./builder-content-2ZCDLKAI.mjs'));
19
19
 
20
20
  export { BuilderContent, StaticContent };
@@ -0,0 +1,145 @@
1
+ 'use strict';
2
+
3
+ var React3 = require('react');
4
+ var NextImage = require('next/image');
5
+ var clsx = require('clsx');
6
+ var tailwindMerge = require('tailwind-merge');
7
+
8
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
+
10
+ function _interopNamespace(e) {
11
+ if (e && e.__esModule) return e;
12
+ var n = Object.create(null);
13
+ if (e) {
14
+ Object.keys(e).forEach(function (k) {
15
+ if (k !== 'default') {
16
+ var d = Object.getOwnPropertyDescriptor(e, k);
17
+ Object.defineProperty(n, k, d.get ? d : {
18
+ enumerable: true,
19
+ get: function () { return e[k]; }
20
+ });
21
+ }
22
+ });
23
+ }
24
+ n.default = e;
25
+ return Object.freeze(n);
26
+ }
27
+
28
+ var React3__namespace = /*#__PURE__*/_interopNamespace(React3);
29
+ var NextImage__default = /*#__PURE__*/_interopDefault(NextImage);
30
+
31
+ // src/lib/builder.ts
32
+ var builder = /* @__PURE__ */ (() => {
33
+ const components = [];
34
+ return {
35
+ register: (component, config) => {
36
+ if (components.find(({ name }) => name === config.name)) {
37
+ console.log(
38
+ `[simple-builder]: Component ${config.name} already registered.`
39
+ );
40
+ return;
41
+ }
42
+ components.push({
43
+ component,
44
+ ...config
45
+ });
46
+ },
47
+ getComponents: () => components,
48
+ getComponent: (name) => {
49
+ return components.find((c) => c.name === name);
50
+ },
51
+ bindComponent: ({ content, ...block }, edit) => {
52
+ const component = components.find(({ name }) => name === block.component);
53
+ if (!component) {
54
+ throw new Error(
55
+ `[simple-builder]: Component ${block.component} not found`
56
+ );
57
+ }
58
+ const Element = React3.createElement(component.component, {
59
+ key: block.id,
60
+ builder: { id: block.id, content, edit },
61
+ ...block.props
62
+ });
63
+ return Element;
64
+ }
65
+ };
66
+ })();
67
+ var Image = (props) => {
68
+ if (typeof NextImage__default.default !== "undefined") {
69
+ return /* @__PURE__ */ React3__namespace.createElement(NextImage__default.default.default, { ...props });
70
+ }
71
+ return /* @__PURE__ */ React3__namespace.createElement("img", { ...props });
72
+ };
73
+ var twMerge = tailwindMerge.extendTailwindMerge({
74
+ prefix: "sb-"
75
+ });
76
+ function cn(...inputs) {
77
+ return twMerge(clsx.clsx(inputs));
78
+ }
79
+ var insertAt = (items, index, item) => {
80
+ return Array.isArray(items) ? [...items.slice(0, index), item, ...items.slice(index)] : [item];
81
+ };
82
+ var spacing = {
83
+ parse: (input) => {
84
+ const matches = input.match(/(\d+)/gm);
85
+ const [top = 0, right = 0, bottom = 0, left = 0] = matches?.map((match) => +match) || [];
86
+ switch (matches?.length) {
87
+ case 1:
88
+ return { top, right: top, bottom: top, left: top };
89
+ case 2:
90
+ return { top, bottom: top, left: right, right };
91
+ case 3:
92
+ return { top, right, left: right, bottom };
93
+ default:
94
+ return { top, right, bottom, left };
95
+ }
96
+ },
97
+ isIndipendent: (input) => {
98
+ const { top, right, bottom, left } = spacing.parse(input);
99
+ return top !== bottom || right !== left;
100
+ }
101
+ };
102
+
103
+ // src/components/design-wrapper.tsx
104
+ var DesignWrapper = (props) => {
105
+ const { children, className, styles } = props;
106
+ const { container = true, background, ...rest } = styles || {};
107
+ const matches = typeof background === "string" ? background.match(/url\(["']?(.*?)["']?\)/) : void 0;
108
+ const src = matches ? matches[1] : void 0;
109
+ return /* @__PURE__ */ React3__namespace.createElement(
110
+ "div",
111
+ {
112
+ className: cn("sb-relative", className),
113
+ style: { ...!src && { background }, ...rest }
114
+ },
115
+ src && /* @__PURE__ */ React3__namespace.createElement(
116
+ Image,
117
+ {
118
+ src,
119
+ alt: "",
120
+ fill: true,
121
+ className: "sb-object-cover sb-absolute sb-inset-0 sb-pointer-events-none sb--z-[1]"
122
+ }
123
+ ),
124
+ container ? /* @__PURE__ */ React3__namespace.createElement("div", { className: "sb-container sb-mx-auto" }, children) : children
125
+ );
126
+ };
127
+ var BuildContainerInner = React3__namespace.lazy(
128
+ () => import('./build-container-client-DKP66XWJ.js')
129
+ );
130
+ var BuildContainer = (props) => {
131
+ const { content, edit, name } = props;
132
+ const items = Array.isArray(content) ? content : content?.[name] || [];
133
+ if (!edit) {
134
+ return items.map((item) => /* @__PURE__ */ React3__namespace.createElement(DesignWrapper, { styles: item.styles }, builder.bindComponent(item, true)));
135
+ }
136
+ return /* @__PURE__ */ React3__namespace.createElement(React3__namespace.Suspense, { fallback: /* @__PURE__ */ React3__namespace.createElement("div", null, "Loading...") }, /* @__PURE__ */ React3__namespace.createElement(BuildContainerInner, { ...props }));
137
+ };
138
+
139
+ exports.BuildContainer = BuildContainer;
140
+ exports.DesignWrapper = DesignWrapper;
141
+ exports.Image = Image;
142
+ exports.builder = builder;
143
+ exports.cn = cn;
144
+ exports.insertAt = insertAt;
145
+ exports.spacing = spacing;
@@ -1,9 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkUZFAGH6G_js = require('./chunk-UZFAGH6G.js');
3
+ var chunk5YLARMT3_js = require('./chunk-5YLARMT3.js');
4
4
  var React = require('react');
5
- var clsx = require('clsx');
6
- var tailwindMerge = require('tailwind-merge');
7
5
  var reactSlot = require('@radix-ui/react-slot');
8
6
  var classVarianceAuthority = require('class-variance-authority');
9
7
 
@@ -27,37 +25,6 @@ function _interopNamespace(e) {
27
25
 
28
26
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
29
27
 
30
- var twMerge = tailwindMerge.extendTailwindMerge({
31
- prefix: "sb-"
32
- });
33
- function cn(...inputs) {
34
- return twMerge(clsx.clsx(inputs));
35
- }
36
- var insertAt = (items, index, item) => {
37
- return Array.isArray(items) ? [...items.slice(0, index), item, ...items.slice(index)] : [item];
38
- };
39
- var spacing = {
40
- parse: (input) => {
41
- const matches = input.match(/(\d+)/gm);
42
- const [top = 0, right = 0, bottom = 0, left = 0] = matches?.map((match) => +match) || [];
43
- switch (matches?.length) {
44
- case 1:
45
- return { top, right: top, bottom: top, left: top };
46
- case 2:
47
- return { top, bottom: top, left: right, right };
48
- case 3:
49
- return { top, right, left: right, bottom };
50
- default:
51
- return { top, right, bottom, left };
52
- }
53
- },
54
- isIndipendent: (input) => {
55
- const { top, right, bottom, left } = spacing.parse(input);
56
- return top !== bottom || right !== left;
57
- }
58
- };
59
-
60
- // src/components/context/builder-context.tsx
61
28
  var BuilderContext = React__namespace.createContext(
62
29
  null
63
30
  );
@@ -92,7 +59,7 @@ var BuilderProvider = (props) => {
92
59
  );
93
60
  const addContent = React__namespace.useCallback(
94
61
  (name, container, parent, index = 0) => {
95
- const component = chunkUZFAGH6G_js.builder.getComponent(name);
62
+ const component = chunk5YLARMT3_js.builder.getComponent(name);
96
63
  if (!component) {
97
64
  throw new Error(`[simple-builder]: Component "${name}" not found`);
98
65
  }
@@ -114,7 +81,7 @@ var BuilderProvider = (props) => {
114
81
  }
115
82
  };
116
83
  if (!parent) {
117
- setContent((content2) => insertAt(content2, index, entry));
84
+ setContent((content2) => chunk5YLARMT3_js.insertAt(content2, index, entry));
118
85
  return;
119
86
  }
120
87
  setContent(
@@ -124,7 +91,7 @@ var BuilderProvider = (props) => {
124
91
  ...item,
125
92
  content: {
126
93
  ...item.content,
127
- [container]: insertAt(item.content?.[container], index, entry)
94
+ [container]: chunk5YLARMT3_js.insertAt(item.content?.[container], index, entry)
128
95
  }
129
96
  };
130
97
  }
@@ -279,7 +246,7 @@ var Button = React__namespace.forwardRef(
279
246
  return /* @__PURE__ */ React__namespace.createElement(
280
247
  Comp,
281
248
  {
282
- className: cn(buttonVariants({ variant, size, className })),
249
+ className: chunk5YLARMT3_js.cn(buttonVariants({ variant, size, className })),
283
250
  ref,
284
251
  ...props
285
252
  }
@@ -291,6 +258,4 @@ Button.displayName = "Button";
291
258
  exports.BuilderProvider = BuilderProvider;
292
259
  exports.Button = Button;
293
260
  exports.buttonVariants = buttonVariants;
294
- exports.cn = cn;
295
- exports.spacing = spacing;
296
261
  exports.useBuilder = useBuilder;
@@ -1,41 +1,8 @@
1
- import { builder } from './chunk-FGQSJAOO.mjs';
1
+ import { cn, builder, insertAt } from './chunk-XHPQBTIC.mjs';
2
2
  import * as React from 'react';
3
- import { clsx } from 'clsx';
4
- import { extendTailwindMerge } from 'tailwind-merge';
5
3
  import { Slot } from '@radix-ui/react-slot';
6
4
  import { cva } from 'class-variance-authority';
7
5
 
8
- var twMerge = extendTailwindMerge({
9
- prefix: "sb-"
10
- });
11
- function cn(...inputs) {
12
- return twMerge(clsx(inputs));
13
- }
14
- var insertAt = (items, index, item) => {
15
- return Array.isArray(items) ? [...items.slice(0, index), item, ...items.slice(index)] : [item];
16
- };
17
- var spacing = {
18
- parse: (input) => {
19
- const matches = input.match(/(\d+)/gm);
20
- const [top = 0, right = 0, bottom = 0, left = 0] = matches?.map((match) => +match) || [];
21
- switch (matches?.length) {
22
- case 1:
23
- return { top, right: top, bottom: top, left: top };
24
- case 2:
25
- return { top, bottom: top, left: right, right };
26
- case 3:
27
- return { top, right, left: right, bottom };
28
- default:
29
- return { top, right, bottom, left };
30
- }
31
- },
32
- isIndipendent: (input) => {
33
- const { top, right, bottom, left } = spacing.parse(input);
34
- return top !== bottom || right !== left;
35
- }
36
- };
37
-
38
- // src/components/context/builder-context.tsx
39
6
  var BuilderContext = React.createContext(
40
7
  null
41
8
  );
@@ -266,4 +233,4 @@ var Button = React.forwardRef(
266
233
  );
267
234
  Button.displayName = "Button";
268
235
 
269
- export { BuilderProvider, Button, buttonVariants, cn, spacing, useBuilder };
236
+ export { BuilderProvider, Button, buttonVariants, useBuilder };
@@ -0,0 +1,115 @@
1
+ import * as React3 from 'react';
2
+ import { createElement } from 'react';
3
+ import NextImage from 'next/image';
4
+ import { clsx } from 'clsx';
5
+ import { extendTailwindMerge } from 'tailwind-merge';
6
+
7
+ // src/lib/builder.ts
8
+ var builder = /* @__PURE__ */ (() => {
9
+ const components = [];
10
+ return {
11
+ register: (component, config) => {
12
+ if (components.find(({ name }) => name === config.name)) {
13
+ console.log(
14
+ `[simple-builder]: Component ${config.name} already registered.`
15
+ );
16
+ return;
17
+ }
18
+ components.push({
19
+ component,
20
+ ...config
21
+ });
22
+ },
23
+ getComponents: () => components,
24
+ getComponent: (name) => {
25
+ return components.find((c) => c.name === name);
26
+ },
27
+ bindComponent: ({ content, ...block }, edit) => {
28
+ const component = components.find(({ name }) => name === block.component);
29
+ if (!component) {
30
+ throw new Error(
31
+ `[simple-builder]: Component ${block.component} not found`
32
+ );
33
+ }
34
+ const Element = createElement(component.component, {
35
+ key: block.id,
36
+ builder: { id: block.id, content, edit },
37
+ ...block.props
38
+ });
39
+ return Element;
40
+ }
41
+ };
42
+ })();
43
+ var Image = (props) => {
44
+ if (typeof NextImage !== "undefined") {
45
+ return /* @__PURE__ */ React3.createElement(NextImage.default, { ...props });
46
+ }
47
+ return /* @__PURE__ */ React3.createElement("img", { ...props });
48
+ };
49
+ var twMerge = extendTailwindMerge({
50
+ prefix: "sb-"
51
+ });
52
+ function cn(...inputs) {
53
+ return twMerge(clsx(inputs));
54
+ }
55
+ var insertAt = (items, index, item) => {
56
+ return Array.isArray(items) ? [...items.slice(0, index), item, ...items.slice(index)] : [item];
57
+ };
58
+ var spacing = {
59
+ parse: (input) => {
60
+ const matches = input.match(/(\d+)/gm);
61
+ const [top = 0, right = 0, bottom = 0, left = 0] = matches?.map((match) => +match) || [];
62
+ switch (matches?.length) {
63
+ case 1:
64
+ return { top, right: top, bottom: top, left: top };
65
+ case 2:
66
+ return { top, bottom: top, left: right, right };
67
+ case 3:
68
+ return { top, right, left: right, bottom };
69
+ default:
70
+ return { top, right, bottom, left };
71
+ }
72
+ },
73
+ isIndipendent: (input) => {
74
+ const { top, right, bottom, left } = spacing.parse(input);
75
+ return top !== bottom || right !== left;
76
+ }
77
+ };
78
+
79
+ // src/components/design-wrapper.tsx
80
+ var DesignWrapper = (props) => {
81
+ const { children, className, styles } = props;
82
+ const { container = true, background, ...rest } = styles || {};
83
+ const matches = typeof background === "string" ? background.match(/url\(["']?(.*?)["']?\)/) : void 0;
84
+ const src = matches ? matches[1] : void 0;
85
+ return /* @__PURE__ */ React3.createElement(
86
+ "div",
87
+ {
88
+ className: cn("sb-relative", className),
89
+ style: { ...!src && { background }, ...rest }
90
+ },
91
+ src && /* @__PURE__ */ React3.createElement(
92
+ Image,
93
+ {
94
+ src,
95
+ alt: "",
96
+ fill: true,
97
+ className: "sb-object-cover sb-absolute sb-inset-0 sb-pointer-events-none sb--z-[1]"
98
+ }
99
+ ),
100
+ container ? /* @__PURE__ */ React3.createElement("div", { className: "sb-container sb-mx-auto" }, children) : children
101
+ );
102
+ };
103
+ var BuildContainerInner = React3.lazy(
104
+ () => import('./build-container-client-VVBART5S.mjs')
105
+ );
106
+ var BuildContainer = (props) => {
107
+ const { content, edit, name } = props;
108
+ const items = Array.isArray(content) ? content : content?.[name] || [];
109
+ if (!edit) {
110
+ return items.map((item) => /* @__PURE__ */ React3.createElement(DesignWrapper, { styles: item.styles }, builder.bindComponent(item, true)));
111
+ }
112
+ return /* @__PURE__ */ React3.createElement(React3.Suspense, { fallback: /* @__PURE__ */ React3.createElement("div", null, "Loading...") }, /* @__PURE__ */ React3.createElement(BuildContainerInner, { ...props }));
113
+ };
114
+
115
+ export { BuildContainer, DesignWrapper, Image, builder, cn, insertAt, spacing };
package/dist/index.d.mts CHANGED
@@ -52,7 +52,7 @@ type BuildContainerProps = {
52
52
  multiple?: boolean;
53
53
  edit: boolean;
54
54
  };
55
- declare const BuildContainer: (props: BuildContainerProps) => React.JSX.Element | React.FunctionComponentElement<any>[];
55
+ declare const BuildContainer: (props: BuildContainerProps) => React.JSX.Element | React.JSX.Element[];
56
56
 
57
57
  declare const BuilderContent: React.LazyExoticComponent<(props: {
58
58
  content?: _simple_builder_server.BuilderContent | undefined;
package/dist/index.d.ts CHANGED
@@ -52,7 +52,7 @@ type BuildContainerProps = {
52
52
  multiple?: boolean;
53
53
  edit: boolean;
54
54
  };
55
- declare const BuildContainer: (props: BuildContainerProps) => React.JSX.Element | React.FunctionComponentElement<any>[];
55
+ declare const BuildContainer: (props: BuildContainerProps) => React.JSX.Element | React.JSX.Element[];
56
56
 
57
57
  declare const BuilderContent: React.LazyExoticComponent<(props: {
58
58
  content?: _simple_builder_server.BuilderContent | undefined;
package/dist/index.js CHANGED
@@ -1,23 +1,23 @@
1
1
  'use strict';
2
2
 
3
- var chunkN2X3IJBG_js = require('./chunk-N2X3IJBG.js');
4
- var chunkUZFAGH6G_js = require('./chunk-UZFAGH6G.js');
3
+ var chunk2CKQ5QRQ_js = require('./chunk-2CKQ5QRQ.js');
4
+ var chunk5YLARMT3_js = require('./chunk-5YLARMT3.js');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "BuilderContent", {
9
9
  enumerable: true,
10
- get: function () { return chunkN2X3IJBG_js.BuilderContent; }
10
+ get: function () { return chunk2CKQ5QRQ_js.BuilderContent; }
11
11
  });
12
12
  Object.defineProperty(exports, "StaticContent", {
13
13
  enumerable: true,
14
- get: function () { return chunkN2X3IJBG_js.StaticContent; }
14
+ get: function () { return chunk2CKQ5QRQ_js.StaticContent; }
15
15
  });
16
16
  Object.defineProperty(exports, "BuildContainer", {
17
17
  enumerable: true,
18
- get: function () { return chunkUZFAGH6G_js.BuildContainer; }
18
+ get: function () { return chunk5YLARMT3_js.BuildContainer; }
19
19
  });
20
20
  Object.defineProperty(exports, "builder", {
21
21
  enumerable: true,
22
- get: function () { return chunkUZFAGH6G_js.builder; }
22
+ get: function () { return chunk5YLARMT3_js.builder; }
23
23
  });
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export { BuilderContent, StaticContent } from './chunk-IVFWYNC3.mjs';
2
- export { BuildContainer, builder } from './chunk-FGQSJAOO.mjs';
1
+ export { BuilderContent, StaticContent } from './chunk-5IFB55LU.mjs';
2
+ export { BuildContainer, builder } from './chunk-XHPQBTIC.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simple-builder/react",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "private": false,
5
5
  "description": "React package for the simple builder package.",
6
6
  "repository": "https://github.com/pieter-berkel/simple-builder.git",
@@ -44,7 +44,7 @@
44
44
  "server-only": "^0.0.1",
45
45
  "tailwind-merge": "^2.2.0",
46
46
  "zod": "^3.22.4",
47
- "@simple-builder/server": "1.0.3"
47
+ "@simple-builder/server": "1.0.5"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "react": ">=16.8.0",
@@ -1,52 +0,0 @@
1
- import * as React from 'react';
2
- import { createElement } from 'react';
3
-
4
- // src/lib/builder.ts
5
- var builder = /* @__PURE__ */ (() => {
6
- const components = [];
7
- return {
8
- register: (component, config) => {
9
- if (components.find(({ name }) => name === config.name)) {
10
- console.log(
11
- `[simple-builder]: Component ${config.name} already registered.`
12
- );
13
- return;
14
- }
15
- components.push({
16
- component,
17
- ...config
18
- });
19
- },
20
- getComponents: () => components,
21
- getComponent: (name) => {
22
- return components.find((c) => c.name === name);
23
- },
24
- bindComponent: ({ content, ...block }, edit) => {
25
- const component = components.find(({ name }) => name === block.component);
26
- if (!component) {
27
- throw new Error(
28
- `[simple-builder]: Component ${block.component} not found`
29
- );
30
- }
31
- const Element = createElement(component.component, {
32
- key: block.id,
33
- builder: { id: block.id, content, edit },
34
- ...block.props
35
- });
36
- return Element;
37
- }
38
- };
39
- })();
40
- var BuildContainerInner = React.lazy(
41
- () => import('./build-container-client-R2FNJHPM.mjs')
42
- );
43
- var BuildContainer = (props) => {
44
- const { content, edit, name } = props;
45
- const items = Array.isArray(content) ? content : content?.[name] || [];
46
- if (!edit) {
47
- return items.map((item) => builder.bindComponent(item));
48
- }
49
- return /* @__PURE__ */ React.createElement(React.Suspense, { fallback: /* @__PURE__ */ React.createElement("div", null, "Loading...") }, /* @__PURE__ */ React.createElement(BuildContainerInner, { ...props }));
50
- };
51
-
52
- export { BuildContainer, builder };