@simple-builder/react 1.0.1 → 1.0.3

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,3 +1,4 @@
1
+ import * as React from 'react';
1
2
  import { createElement } from 'react';
2
3
 
3
4
  // src/lib/builder.ts
@@ -36,5 +37,16 @@ var builder = /* @__PURE__ */ (() => {
36
37
  }
37
38
  };
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
+ };
39
51
 
40
- export { builder };
52
+ export { BuildContainer, builder };
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkVMHWPKU4_js = require('./chunk-VMHWPKU4.js');
3
+ var chunkUZFAGH6G_js = require('./chunk-UZFAGH6G.js');
4
4
  var React = require('react');
5
5
  var clsx = require('clsx');
6
6
  var tailwindMerge = require('tailwind-merge');
@@ -27,8 +27,11 @@ function _interopNamespace(e) {
27
27
 
28
28
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
29
29
 
30
+ var twMerge = tailwindMerge.extendTailwindMerge({
31
+ prefix: "sb-"
32
+ });
30
33
  function cn(...inputs) {
31
- return tailwindMerge.twMerge(clsx.clsx(inputs));
34
+ return twMerge(clsx.clsx(inputs));
32
35
  }
33
36
  var insertAt = (items, index, item) => {
34
37
  return Array.isArray(items) ? [...items.slice(0, index), item, ...items.slice(index)] : [item];
@@ -89,7 +92,7 @@ var BuilderProvider = (props) => {
89
92
  );
90
93
  const addContent = React__namespace.useCallback(
91
94
  (name, container, parent, index = 0) => {
92
- const component = chunkVMHWPKU4_js.builder.getComponent(name);
95
+ const component = chunkUZFAGH6G_js.builder.getComponent(name);
93
96
  if (!component) {
94
97
  throw new Error(`[simple-builder]: Component "${name}" not found`);
95
98
  }
@@ -250,18 +253,18 @@ var findRecursive = (items, predicate, key = "content") => {
250
253
  }
251
254
  };
252
255
  var buttonVariants = classVarianceAuthority.cva(
253
- "inline-flex uppercase font-roboto items-center justify-center whitespace-nowrap rounded-md text-xs font-semibold ring-offset-sb-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sb-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
256
+ "sb-inline-flex sb-uppercase sb-font-roboto sb-items-center sb-justify-center sb-whitespace-nowrap sb-rounded-md sb-text-xs sb-font-semibold ring-offset-background sb-transition-colors focus-visible:sb-outline-none focus-visible:sb-ring-2 focus-visible:ring-ring focus-visible:sb-ring-offset-2 disabled:sb-pointer-events-none disabled:sb-opacity-50",
254
257
  {
255
258
  variants: {
256
259
  variant: {
257
- primary: "bg-sb-primary text-sb-primary-foreground hover:bg-sb-primary/90",
258
- destructive: "bg-sb-destructive text-sb-destructive-foreground hover:bg-sb-destructive/90",
259
- outline: "border border-sb-input bg-sb-background hover:bg-sb-accent hover:text-sb-accent-foreground",
260
- ghost: "hover:bg-sb-accent hover:text-sb-accent-foreground"
260
+ primary: "sb-bg-primary sb-text-primary-foreground hover:sb-bg-primary/90",
261
+ destructive: "sb-bg-destructive sb-text-destructive-foreground hover:sb-bg-destructive/90",
262
+ outline: "sb-border border-input sb-bg-background hover:sb-bg-accent hover:sb-text-accent-foreground",
263
+ ghost: "hover:sb-bg-accent hover:sb-text-accent-foreground"
261
264
  },
262
265
  size: {
263
- default: "h-10 px-4 py-2",
264
- sm: "h-8 px-3 py-1"
266
+ default: "sb-h-10 sb-px-4 sb-py-2",
267
+ sm: "sb-h-8 sb-px-3 sb-py-1"
265
268
  }
266
269
  },
267
270
  defaultVariants: {
@@ -0,0 +1,20 @@
1
+ import { BuildContainer } from './chunk-FGQSJAOO.mjs';
2
+ import * as React from 'react';
3
+ import { lazy } from 'react';
4
+
5
+ var StaticContent = (props) => {
6
+ return /* @__PURE__ */ React.createElement(
7
+ BuildContainer,
8
+ {
9
+ name: "root",
10
+ edit: false,
11
+ multiple: true,
12
+ content: props.content || []
13
+ }
14
+ );
15
+ };
16
+
17
+ // src/index.ts
18
+ var BuilderContent = lazy(() => import('./builder-content-MNCJZTFS.mjs'));
19
+
20
+ export { BuilderContent, StaticContent };
@@ -1,10 +1,13 @@
1
- import { builder } from './chunk-7K7IGTF3.mjs';
1
+ import { builder } from './chunk-FGQSJAOO.mjs';
2
2
  import * as React from 'react';
3
3
  import { clsx } from 'clsx';
4
- import { twMerge } from 'tailwind-merge';
4
+ import { extendTailwindMerge } from 'tailwind-merge';
5
5
  import { Slot } from '@radix-ui/react-slot';
6
6
  import { cva } from 'class-variance-authority';
7
7
 
8
+ var twMerge = extendTailwindMerge({
9
+ prefix: "sb-"
10
+ });
8
11
  function cn(...inputs) {
9
12
  return twMerge(clsx(inputs));
10
13
  }
@@ -228,18 +231,18 @@ var findRecursive = (items, predicate, key = "content") => {
228
231
  }
229
232
  };
230
233
  var buttonVariants = cva(
231
- "inline-flex uppercase font-roboto items-center justify-center whitespace-nowrap rounded-md text-xs font-semibold ring-offset-sb-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sb-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
234
+ "sb-inline-flex sb-uppercase sb-font-roboto sb-items-center sb-justify-center sb-whitespace-nowrap sb-rounded-md sb-text-xs sb-font-semibold ring-offset-background sb-transition-colors focus-visible:sb-outline-none focus-visible:sb-ring-2 focus-visible:ring-ring focus-visible:sb-ring-offset-2 disabled:sb-pointer-events-none disabled:sb-opacity-50",
232
235
  {
233
236
  variants: {
234
237
  variant: {
235
- primary: "bg-sb-primary text-sb-primary-foreground hover:bg-sb-primary/90",
236
- destructive: "bg-sb-destructive text-sb-destructive-foreground hover:bg-sb-destructive/90",
237
- outline: "border border-sb-input bg-sb-background hover:bg-sb-accent hover:text-sb-accent-foreground",
238
- ghost: "hover:bg-sb-accent hover:text-sb-accent-foreground"
238
+ primary: "sb-bg-primary sb-text-primary-foreground hover:sb-bg-primary/90",
239
+ destructive: "sb-bg-destructive sb-text-destructive-foreground hover:sb-bg-destructive/90",
240
+ outline: "sb-border border-input sb-bg-background hover:sb-bg-accent hover:sb-text-accent-foreground",
241
+ ghost: "hover:sb-bg-accent hover:sb-text-accent-foreground"
239
242
  },
240
243
  size: {
241
- default: "h-10 px-4 py-2",
242
- sm: "h-8 px-3 py-1"
244
+ default: "sb-h-10 sb-px-4 sb-py-2",
245
+ sm: "sb-h-8 sb-px-3 sb-py-1"
243
246
  }
244
247
  },
245
248
  defaultVariants: {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkVMHWPKU4_js = require('./chunk-VMHWPKU4.js');
3
+ var chunkUZFAGH6G_js = require('./chunk-UZFAGH6G.js');
4
4
  var React = require('react');
5
5
 
6
6
  function _interopNamespace(e) {
@@ -23,16 +23,20 @@ function _interopNamespace(e) {
23
23
 
24
24
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
25
25
 
26
- var BuildContainerInner = React__namespace.lazy(
27
- () => import('./build-container-client-DICNH7KJ.js')
28
- );
29
- var BuildContainer = (props) => {
30
- const { content, edit, name } = props;
31
- const items = Array.isArray(content) ? content : content?.[name] || [];
32
- if (!edit) {
33
- return items.map((item) => chunkVMHWPKU4_js.builder.bindComponent(item));
34
- }
35
- return /* @__PURE__ */ React__namespace.createElement(BuildContainerInner, { ...props });
26
+ var StaticContent = (props) => {
27
+ return /* @__PURE__ */ React__namespace.createElement(
28
+ chunkUZFAGH6G_js.BuildContainer,
29
+ {
30
+ name: "root",
31
+ edit: false,
32
+ multiple: true,
33
+ content: props.content || []
34
+ }
35
+ );
36
36
  };
37
37
 
38
- exports.BuildContainer = BuildContainer;
38
+ // src/index.ts
39
+ var BuilderContent = React.lazy(() => import('./builder-content-BOQEXOAK.js'));
40
+
41
+ exports.BuilderContent = BuilderContent;
42
+ exports.StaticContent = StaticContent;
@@ -0,0 +1,74 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ function _interopNamespace(e) {
6
+ if (e && e.__esModule) return e;
7
+ var n = Object.create(null);
8
+ if (e) {
9
+ Object.keys(e).forEach(function (k) {
10
+ if (k !== 'default') {
11
+ var d = Object.getOwnPropertyDescriptor(e, k);
12
+ Object.defineProperty(n, k, d.get ? d : {
13
+ enumerable: true,
14
+ get: function () { return e[k]; }
15
+ });
16
+ }
17
+ });
18
+ }
19
+ n.default = e;
20
+ return Object.freeze(n);
21
+ }
22
+
23
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
24
+
25
+ // src/lib/builder.ts
26
+ var builder = /* @__PURE__ */ (() => {
27
+ const components = [];
28
+ return {
29
+ register: (component, config) => {
30
+ if (components.find(({ name }) => name === config.name)) {
31
+ console.log(
32
+ `[simple-builder]: Component ${config.name} already registered.`
33
+ );
34
+ return;
35
+ }
36
+ components.push({
37
+ component,
38
+ ...config
39
+ });
40
+ },
41
+ getComponents: () => components,
42
+ getComponent: (name) => {
43
+ return components.find((c) => c.name === name);
44
+ },
45
+ bindComponent: ({ content, ...block }, edit) => {
46
+ const component = components.find(({ name }) => name === block.component);
47
+ if (!component) {
48
+ throw new Error(
49
+ `[simple-builder]: Component ${block.component} not found`
50
+ );
51
+ }
52
+ const Element = React.createElement(component.component, {
53
+ key: block.id,
54
+ builder: { id: block.id, content, edit },
55
+ ...block.props
56
+ });
57
+ return Element;
58
+ }
59
+ };
60
+ })();
61
+ var BuildContainerInner = React__namespace.lazy(
62
+ () => import('./build-container-client-MHVIH442.js')
63
+ );
64
+ var BuildContainer = (props) => {
65
+ const { content, edit, name } = props;
66
+ const items = Array.isArray(content) ? content : content?.[name] || [];
67
+ if (!edit) {
68
+ return items.map((item) => builder.bindComponent(item));
69
+ }
70
+ return /* @__PURE__ */ React__namespace.createElement(React__namespace.Suspense, { fallback: /* @__PURE__ */ React__namespace.createElement("div", null, "Loading...") }, /* @__PURE__ */ React__namespace.createElement(BuildContainerInner, { ...props }));
71
+ };
72
+
73
+ exports.BuildContainer = BuildContainer;
74
+ exports.builder = builder;