@simple-builder/react 1.4.2 → 1.5.1

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.
@@ -543,6 +543,9 @@
543
543
  .sb\:w-px {
544
544
  width: 1px;
545
545
  }
546
+ .sb\:w-screen {
547
+ width: 100vw;
548
+ }
546
549
  .sb\:max-w-3xl {
547
550
  max-width: var(--sb-container-3xl);
548
551
  }
@@ -1,5 +1,5 @@
1
- import { BuilderProvider, useBuilder, Button } from './chunk-ZJYB6LEV.mjs';
2
- import { BuildContainer } from './chunk-QSAIF4GO.mjs';
1
+ import { BuilderProvider, useBuilder, Button } from './chunk-5C63BZJZ.mjs';
2
+ import { BuildContainer } from './chunk-TWEX2YSZ.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 chunk7FWFM2TR_js = require('./chunk-7FWFM2TR.js');
4
- var chunk63LNKQZD_js = require('./chunk-63LNKQZD.js');
3
+ var chunk6TXJMYOX_js = require('./chunk-6TXJMYOX.js');
4
+ var chunk37KLYH3L_js = require('./chunk-37KLYH3L.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 } = chunk7FWFM2TR_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(chunk7FWFM2TR_js.Button, { variant: "ghost", size: "sm", onClick: save }, "Opslaan")));
28
+ const { save } = chunk6TXJMYOX_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(chunk6TXJMYOX_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(chunk7FWFM2TR_js.BuilderProvider, { content: props.content }, /* @__PURE__ */ React2__namespace.createElement(BuilderContentInner, null));
34
+ return /* @__PURE__ */ React2__namespace.createElement(chunk6TXJMYOX_js.BuilderProvider, { content: props.content }, /* @__PURE__ */ React2__namespace.createElement(BuilderContentInner, null));
35
35
  };
36
36
  var BuilderContentInner = () => {
37
- const { content } = chunk7FWFM2TR_js.useBuilder();
38
- return /* @__PURE__ */ React2__namespace.createElement(React2__namespace.Fragment, null, /* @__PURE__ */ React2__namespace.createElement(BuilderHeader, null), /* @__PURE__ */ React2__namespace.createElement(chunk63LNKQZD_js.BuildContainer, { name: "root", edit: true, multiple: true, content }));
37
+ const { content } = chunk6TXJMYOX_js.useBuilder();
38
+ return /* @__PURE__ */ React2__namespace.createElement(React2__namespace.Fragment, null, /* @__PURE__ */ React2__namespace.createElement(BuilderHeader, null), /* @__PURE__ */ React2__namespace.createElement(chunk37KLYH3L_js.BuildContainer, { name: "root", edit: true, multiple: true, content }));
39
39
  };
40
40
  var builder_content_default = BuilderContent;
41
41
 
@@ -543,6 +543,9 @@
543
543
  .sb\:w-px {
544
544
  width: 1px;
545
545
  }
546
+ .sb\:w-screen {
547
+ width: 100vw;
548
+ }
546
549
  .sb\:max-w-3xl {
547
550
  max-width: var(--sb-container-3xl);
548
551
  }
@@ -30,41 +30,53 @@ var React3__namespace = /*#__PURE__*/_interopNamespace(React3);
30
30
  var NextImage__default = /*#__PURE__*/_interopDefault(NextImage);
31
31
 
32
32
  // src/lib/builder.ts
33
- var builder = /* @__PURE__ */ (() => {
34
- const components = [];
35
- return {
36
- register: (component, config) => {
37
- if (components.find(({ name }) => name === config.name)) {
38
- console.log(
39
- `[simple-builder]: Component ${config.name} already registered.`
40
- );
41
- return;
42
- }
43
- components.push({
44
- component,
45
- ...config
46
- });
47
- },
48
- getComponents: () => components,
49
- getComponent: (name) => {
50
- return components.find((c) => c.name === name);
51
- },
52
- bindComponent: ({ content, ...block }, edit) => {
53
- const component = components.find(({ name }) => name === block.component);
54
- if (!component) {
55
- throw new Error(
56
- `[simple-builder]: Component ${block.component} not found`
57
- );
58
- }
59
- const Element = React3.createElement(component.component, {
60
- key: block.id,
61
- builder: { id: block.id, content, edit },
62
- ...block.props
63
- });
64
- return Element;
33
+ var Builder = class _Builder {
34
+ static instance;
35
+ components = [];
36
+ constructor() {
37
+ }
38
+ static getInstance() {
39
+ if (!_Builder.instance) {
40
+ _Builder.instance = new _Builder();
65
41
  }
66
- };
67
- })();
42
+ return _Builder.instance;
43
+ }
44
+ register(component, config) {
45
+ if (this.components.find(({ name }) => name === config.name)) {
46
+ console.log(
47
+ `[simple-builder]: Component ${config.name} already registered.`
48
+ );
49
+ return;
50
+ }
51
+ this.components.push({
52
+ component,
53
+ ...config
54
+ });
55
+ }
56
+ getComponents() {
57
+ return this.components;
58
+ }
59
+ getComponent(name) {
60
+ return this.components.find((c) => c.name === name);
61
+ }
62
+ bindComponent({ content, ...block }, edit) {
63
+ const component = this.components.find(
64
+ ({ name }) => name === block.component
65
+ );
66
+ if (!component) {
67
+ throw new Error(
68
+ `[simple-builder]: Component ${block.component} not found`
69
+ );
70
+ }
71
+ const Element = React3.createElement(component.component, {
72
+ key: block.id,
73
+ builder: { id: block.id, content, edit: !!edit },
74
+ ...block.props
75
+ });
76
+ return Element;
77
+ }
78
+ };
79
+ var builder = Builder.getInstance();
68
80
  var Image = (props) => {
69
81
  if (typeof NextImage__default.default !== "undefined") {
70
82
  return /* @__PURE__ */ React3__namespace.createElement(NextImage__default.default, { ...props });
@@ -133,13 +145,13 @@ var DesignWrapper = (props) => {
133
145
  `.replace(/\s\s+/g, " ")));
134
146
  };
135
147
  var BuildContainerInner = React3__namespace.lazy(
136
- () => import('./build-container-client-JAITVVDD.js')
148
+ () => import('./build-container-client-EJNKMHTC.js')
137
149
  );
138
150
  var BuildContainer = (props) => {
139
151
  const { content, edit, name } = props;
140
152
  const items = Array.isArray(content) ? content : content?.[name] || [];
141
153
  if (!edit) {
142
- return items.map((item) => /* @__PURE__ */ React3__namespace.createElement(DesignWrapper, { styles: item.styles }, builder.bindComponent(item, true)));
154
+ return items.map((item) => /* @__PURE__ */ React3__namespace.createElement(DesignWrapper, { key: item.id, styles: item.styles }, builder.bindComponent(item, edit)));
143
155
  }
144
156
  return /* @__PURE__ */ React3__namespace.createElement(React3__namespace.Suspense, { fallback: /* @__PURE__ */ React3__namespace.createElement("div", null, "Loading...") }, /* @__PURE__ */ React3__namespace.createElement(BuildContainerInner, { ...props }));
145
157
  };
@@ -1,4 +1,4 @@
1
- import { cn, builder, insertAt } from './chunk-QSAIF4GO.mjs';
1
+ import { cn, builder, insertAt } from './chunk-TWEX2YSZ.mjs';
2
2
  import * as React from 'react';
3
3
  import { Slot } from '@radix-ui/react-slot';
4
4
  import { cva } from 'class-variance-authority';
@@ -1,4 +1,4 @@
1
- import { BuildContainer } from './chunk-QSAIF4GO.mjs';
1
+ import { BuildContainer } from './chunk-TWEX2YSZ.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-H75SR7I7.mjs'));
18
+ var BuilderContent = lazy(() => import('./builder-content-FTTWEFTK.mjs'));
19
19
 
20
20
  export { BuilderContent, StaticContent };
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunk63LNKQZD_js = require('./chunk-63LNKQZD.js');
3
+ var chunk37KLYH3L_js = require('./chunk-37KLYH3L.js');
4
4
  var React = require('react');
5
5
  var reactSlot = require('@radix-ui/react-slot');
6
6
  var classVarianceAuthority = require('class-variance-authority');
@@ -57,7 +57,7 @@ var BuilderProvider = (props) => {
57
57
  );
58
58
  const addContent = React__namespace.useCallback(
59
59
  (name, container, parent, index = 0) => {
60
- const component = chunk63LNKQZD_js.builder.getComponent(name);
60
+ const component = chunk37KLYH3L_js.builder.getComponent(name);
61
61
  if (!component) {
62
62
  throw new Error(`[simple-builder]: Component "${name}" not found`);
63
63
  }
@@ -79,7 +79,7 @@ var BuilderProvider = (props) => {
79
79
  }
80
80
  };
81
81
  if (!parent) {
82
- setContent((content2) => chunk63LNKQZD_js.insertAt(content2, index, entry));
82
+ setContent((content2) => chunk37KLYH3L_js.insertAt(content2, index, entry));
83
83
  return;
84
84
  }
85
85
  setContent(
@@ -89,7 +89,7 @@ var BuilderProvider = (props) => {
89
89
  ...item,
90
90
  content: {
91
91
  ...item.content,
92
- [container]: chunk63LNKQZD_js.insertAt(item.content?.[container], index, entry)
92
+ [container]: chunk37KLYH3L_js.insertAt(item.content?.[container], index, entry)
93
93
  }
94
94
  };
95
95
  }
@@ -254,7 +254,7 @@ var Button = React__namespace.forwardRef(
254
254
  return /* @__PURE__ */ React__namespace.createElement(
255
255
  Comp,
256
256
  {
257
- className: chunk63LNKQZD_js.cn(buttonVariants({ variant, size, className })),
257
+ className: chunk37KLYH3L_js.cn(buttonVariants({ variant, size, className })),
258
258
  ref,
259
259
  ...props
260
260
  }
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunk63LNKQZD_js = require('./chunk-63LNKQZD.js');
3
+ var chunk37KLYH3L_js = require('./chunk-37KLYH3L.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
- chunk63LNKQZD_js.BuildContainer,
28
+ chunk37KLYH3L_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-7ZRYWXPN.js'));
39
+ var BuilderContent = React.lazy(() => import('./builder-content-QH2VX65W.js'));
40
40
 
41
41
  exports.BuilderContent = BuilderContent;
42
42
  exports.StaticContent = StaticContent;
@@ -6,41 +6,53 @@ import { extendTailwindMerge } from 'tailwind-merge';
6
6
  import { createTV } from 'tailwind-variants';
7
7
 
8
8
  // src/lib/builder.ts
9
- var builder = /* @__PURE__ */ (() => {
10
- const components = [];
11
- return {
12
- register: (component, config) => {
13
- if (components.find(({ name }) => name === config.name)) {
14
- console.log(
15
- `[simple-builder]: Component ${config.name} already registered.`
16
- );
17
- return;
18
- }
19
- components.push({
20
- component,
21
- ...config
22
- });
23
- },
24
- getComponents: () => components,
25
- getComponent: (name) => {
26
- return components.find((c) => c.name === name);
27
- },
28
- bindComponent: ({ content, ...block }, edit) => {
29
- const component = components.find(({ name }) => name === block.component);
30
- if (!component) {
31
- throw new Error(
32
- `[simple-builder]: Component ${block.component} not found`
33
- );
34
- }
35
- const Element = createElement(component.component, {
36
- key: block.id,
37
- builder: { id: block.id, content, edit },
38
- ...block.props
39
- });
40
- return Element;
9
+ var Builder = class _Builder {
10
+ static instance;
11
+ components = [];
12
+ constructor() {
13
+ }
14
+ static getInstance() {
15
+ if (!_Builder.instance) {
16
+ _Builder.instance = new _Builder();
17
+ }
18
+ return _Builder.instance;
19
+ }
20
+ register(component, config) {
21
+ if (this.components.find(({ name }) => name === config.name)) {
22
+ console.log(
23
+ `[simple-builder]: Component ${config.name} already registered.`
24
+ );
25
+ return;
41
26
  }
42
- };
43
- })();
27
+ this.components.push({
28
+ component,
29
+ ...config
30
+ });
31
+ }
32
+ getComponents() {
33
+ return this.components;
34
+ }
35
+ getComponent(name) {
36
+ return this.components.find((c) => c.name === name);
37
+ }
38
+ bindComponent({ content, ...block }, edit) {
39
+ const component = this.components.find(
40
+ ({ name }) => name === block.component
41
+ );
42
+ if (!component) {
43
+ throw new Error(
44
+ `[simple-builder]: Component ${block.component} not found`
45
+ );
46
+ }
47
+ const Element = createElement(component.component, {
48
+ key: block.id,
49
+ builder: { id: block.id, content, edit: !!edit },
50
+ ...block.props
51
+ });
52
+ return Element;
53
+ }
54
+ };
55
+ var builder = Builder.getInstance();
44
56
  var Image = (props) => {
45
57
  if (typeof NextImage !== "undefined") {
46
58
  return /* @__PURE__ */ React3.createElement(NextImage, { ...props });
@@ -109,13 +121,13 @@ var DesignWrapper = (props) => {
109
121
  `.replace(/\s\s+/g, " ")));
110
122
  };
111
123
  var BuildContainerInner = React3.lazy(
112
- () => import('./build-container-client-6S55GQVT.mjs')
124
+ () => import('./build-container-client-6TC2IEII.mjs')
113
125
  );
114
126
  var BuildContainer = (props) => {
115
127
  const { content, edit, name } = props;
116
128
  const items = Array.isArray(content) ? content : content?.[name] || [];
117
129
  if (!edit) {
118
- return items.map((item) => /* @__PURE__ */ React3.createElement(DesignWrapper, { styles: item.styles }, builder.bindComponent(item, true)));
130
+ return items.map((item) => /* @__PURE__ */ React3.createElement(DesignWrapper, { key: item.id, styles: item.styles }, builder.bindComponent(item, edit)));
119
131
  }
120
132
  return /* @__PURE__ */ React3.createElement(React3.Suspense, { fallback: /* @__PURE__ */ React3.createElement("div", null, "Loading...") }, /* @__PURE__ */ React3.createElement(BuildContainerInner, { ...props }));
121
133
  };
package/dist/index.css CHANGED
@@ -543,6 +543,9 @@
543
543
  .sb\:w-px {
544
544
  width: 1px;
545
545
  }
546
+ .sb\:w-screen {
547
+ width: 100vw;
548
+ }
546
549
  .sb\:max-w-3xl {
547
550
  max-width: var(--sb-container-3xl);
548
551
  }
package/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as React from 'react';
2
+ import { createElement } from 'react';
2
3
  import * as _simple_builder_server from '@simple-builder/server';
3
4
  import { BuilderContent as BuilderContent$1, ContentItem } from '@simple-builder/server';
4
5
 
@@ -36,12 +37,17 @@ type BuildContainerProps$1 = {
36
37
  };
37
38
  };
38
39
 
39
- declare const builder: {
40
- register: (component: any, config: Omit<Component, "component">) => void;
41
- getComponents: () => Component[];
42
- getComponent: (name: string) => Component | undefined;
43
- bindComponent: ({ content, ...block }: ContentItem, edit?: boolean) => React.FunctionComponentElement<any>;
44
- };
40
+ declare class Builder {
41
+ private static instance;
42
+ private components;
43
+ private constructor();
44
+ static getInstance(): Builder;
45
+ register(component: Component["component"], config: Omit<Component, "component">): void;
46
+ getComponents(): Component[];
47
+ getComponent(name: string): Component | undefined;
48
+ bindComponent({ content, ...block }: ContentItem, edit?: boolean): ReturnType<typeof createElement>;
49
+ }
50
+ declare const builder: Builder;
45
51
 
46
52
  type StaticContentProps = {
47
53
  content?: BuilderContent$1;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as React from 'react';
2
+ import { createElement } from 'react';
2
3
  import * as _simple_builder_server from '@simple-builder/server';
3
4
  import { BuilderContent as BuilderContent$1, ContentItem } from '@simple-builder/server';
4
5
 
@@ -36,12 +37,17 @@ type BuildContainerProps$1 = {
36
37
  };
37
38
  };
38
39
 
39
- declare const builder: {
40
- register: (component: any, config: Omit<Component, "component">) => void;
41
- getComponents: () => Component[];
42
- getComponent: (name: string) => Component | undefined;
43
- bindComponent: ({ content, ...block }: ContentItem, edit?: boolean) => React.FunctionComponentElement<any>;
44
- };
40
+ declare class Builder {
41
+ private static instance;
42
+ private components;
43
+ private constructor();
44
+ static getInstance(): Builder;
45
+ register(component: Component["component"], config: Omit<Component, "component">): void;
46
+ getComponents(): Component[];
47
+ getComponent(name: string): Component | undefined;
48
+ bindComponent({ content, ...block }: ContentItem, edit?: boolean): ReturnType<typeof createElement>;
49
+ }
50
+ declare const builder: Builder;
45
51
 
46
52
  type StaticContentProps = {
47
53
  content?: BuilderContent$1;
package/dist/index.js CHANGED
@@ -1,23 +1,23 @@
1
1
  'use strict';
2
2
 
3
- var chunkJFWIO2AR_js = require('./chunk-JFWIO2AR.js');
4
- var chunk63LNKQZD_js = require('./chunk-63LNKQZD.js');
3
+ var chunkLPP77IMH_js = require('./chunk-LPP77IMH.js');
4
+ var chunk37KLYH3L_js = require('./chunk-37KLYH3L.js');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "BuilderContent", {
9
9
  enumerable: true,
10
- get: function () { return chunkJFWIO2AR_js.BuilderContent; }
10
+ get: function () { return chunkLPP77IMH_js.BuilderContent; }
11
11
  });
12
12
  Object.defineProperty(exports, "StaticContent", {
13
13
  enumerable: true,
14
- get: function () { return chunkJFWIO2AR_js.StaticContent; }
14
+ get: function () { return chunkLPP77IMH_js.StaticContent; }
15
15
  });
16
16
  Object.defineProperty(exports, "BuildContainer", {
17
17
  enumerable: true,
18
- get: function () { return chunk63LNKQZD_js.BuildContainer; }
18
+ get: function () { return chunk37KLYH3L_js.BuildContainer; }
19
19
  });
20
20
  Object.defineProperty(exports, "builder", {
21
21
  enumerable: true,
22
- get: function () { return chunk63LNKQZD_js.builder; }
22
+ get: function () { return chunk37KLYH3L_js.builder; }
23
23
  });
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export { BuilderContent, StaticContent } from './chunk-X5MZZBYC.mjs';
2
- export { BuildContainer, builder } from './chunk-QSAIF4GO.mjs';
1
+ export { BuilderContent, StaticContent } from './chunk-5X4LY7OW.mjs';
2
+ export { BuildContainer, builder } from './chunk-TWEX2YSZ.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simple-builder/react",
3
- "version": "1.4.2",
3
+ "version": "1.5.1",
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",
@@ -59,7 +59,7 @@
59
59
  "tailwind-merge": "^2.2.0",
60
60
  "tailwind-variants": "^0.1.20",
61
61
  "zod": "^3.22.4",
62
- "@simple-builder/server": "1.4.2"
62
+ "@simple-builder/server": "1.5.1"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "react": ">=16.8.0",