@simple-builder/react 1.2.3 → 1.2.4
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/build-container-client-BAVL356F.js +1 -0
- package/dist/build-container-client-DLQONPHH.mjs +1 -0
- package/dist/build-container-client-KI3QULNY.mjs +1 -0
- package/dist/build-container-client-LR4UL6XD.js +1 -0
- package/dist/build-container-client-UYQEUZU5.mjs +1 -0
- package/dist/build-container-client-XVX67J7D.js +1 -0
- package/dist/build-container-client-YTZ4C67E.mjs +2250 -0
- package/dist/build-container-client-Z34EUPR3.js +2286 -0
- package/dist/builder-content-IQHALH5A.js +42 -0
- package/dist/builder-content-S2ZNOULV.mjs +20 -0
- package/dist/chunk-6NZWMSQR.js +263 -0
- package/dist/chunk-7J7CMYXS.mjs +20 -0
- package/dist/chunk-G6MYXYJU.mjs +238 -0
- package/dist/chunk-NJ6FM7SJ.mjs +123 -0
- package/dist/chunk-OOIADGIA.js +153 -0
- package/dist/chunk-XJ4ZJCQS.js +42 -0
- package/dist/index.js +6 -6
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,153 @@
|
|
|
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
|
+
var tailwindVariants = require('tailwind-variants');
|
|
8
|
+
|
|
9
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
|
|
11
|
+
function _interopNamespace(e) {
|
|
12
|
+
if (e && e.__esModule) return e;
|
|
13
|
+
var n = Object.create(null);
|
|
14
|
+
if (e) {
|
|
15
|
+
Object.keys(e).forEach(function (k) {
|
|
16
|
+
if (k !== 'default') {
|
|
17
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
18
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return e[k]; }
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
n.default = e;
|
|
26
|
+
return Object.freeze(n);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var React3__namespace = /*#__PURE__*/_interopNamespace(React3);
|
|
30
|
+
var NextImage__default = /*#__PURE__*/_interopDefault(NextImage);
|
|
31
|
+
|
|
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;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
})();
|
|
68
|
+
var Image = (props) => {
|
|
69
|
+
if (typeof NextImage__default.default !== "undefined") {
|
|
70
|
+
return /* @__PURE__ */ React3__namespace.createElement(NextImage__default.default, { ...props });
|
|
71
|
+
}
|
|
72
|
+
return /* @__PURE__ */ React3__namespace.createElement("img", { ...props });
|
|
73
|
+
};
|
|
74
|
+
var twMerge = tailwindMerge.extendTailwindMerge({
|
|
75
|
+
prefix: "sb-"
|
|
76
|
+
});
|
|
77
|
+
function cn(...inputs) {
|
|
78
|
+
return twMerge(clsx.clsx(inputs));
|
|
79
|
+
}
|
|
80
|
+
var tv = tailwindVariants.createTV({
|
|
81
|
+
twMergeConfig: {
|
|
82
|
+
prefix: "sb-"
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
var insertAt = (items, index, item) => {
|
|
86
|
+
return Array.isArray(items) ? [...items.slice(0, index), item, ...items.slice(index)] : [item];
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// src/components/design-wrapper.tsx
|
|
90
|
+
var DesignWrapper = (props) => {
|
|
91
|
+
const { children, className, building = false } = props;
|
|
92
|
+
const { background } = props.styles?.desktop ?? {};
|
|
93
|
+
const matches = typeof background === "string" ? background.match(/url\(["']?(.*?)["']?\)/) : void 0;
|
|
94
|
+
const src = matches ? matches[1] : void 0;
|
|
95
|
+
const desktopStyles = props.styles?.desktop ?? {};
|
|
96
|
+
const mobileStyles = props.styles?.mobile ?? {};
|
|
97
|
+
const container = props.styles?.container ?? true;
|
|
98
|
+
const hidden = props.styles?.hidden ?? "never";
|
|
99
|
+
const id = React3__namespace.useId().replace(/[^a-zA-Z0-9]/g, "");
|
|
100
|
+
let hiddenClass = "";
|
|
101
|
+
switch (hidden) {
|
|
102
|
+
case "always":
|
|
103
|
+
hiddenClass = building ? "sb-opacity-30" : "sb-hidden";
|
|
104
|
+
break;
|
|
105
|
+
case "mobile":
|
|
106
|
+
hiddenClass = building ? "max-md:sb-opacity-30" : "max-md:sb-hidden";
|
|
107
|
+
break;
|
|
108
|
+
case "desktop":
|
|
109
|
+
hiddenClass = building ? "md:sb-opacity-30" : "md:sb-hidden";
|
|
110
|
+
break;
|
|
111
|
+
case "never":
|
|
112
|
+
hiddenClass = "";
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
return /* @__PURE__ */ React3__namespace.createElement("div", { id, className: cn("sb-relative", className, hiddenClass) }, 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
|
+
), container ? /* @__PURE__ */ React3__namespace.createElement("div", { className: "container sb-mx-auto" }, children) : children, /* @__PURE__ */ React3__namespace.createElement("style", null, `
|
|
124
|
+
#${id} {
|
|
125
|
+
${Object.entries(desktopStyles).filter(([key]) => !(key === "background" && src)).map(([key, value]) => `${key}: ${value};`).join(" ")}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
@media (max-width: 1024px) {
|
|
129
|
+
#${id} {
|
|
130
|
+
${Object.entries(mobileStyles).filter(([key]) => !(key === "background" && src)).map(([key, value]) => `${key}: ${value}; `).join(" ")}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
`.replace(/\s\s+/g, " ")));
|
|
134
|
+
};
|
|
135
|
+
var BuildContainerInner = React3__namespace.lazy(
|
|
136
|
+
() => import('./build-container-client-Z34EUPR3.js')
|
|
137
|
+
);
|
|
138
|
+
var BuildContainer = (props) => {
|
|
139
|
+
const { content, edit, name } = props;
|
|
140
|
+
const items = Array.isArray(content) ? content : content?.[name] || [];
|
|
141
|
+
if (!edit) {
|
|
142
|
+
return items.map((item) => /* @__PURE__ */ React3__namespace.createElement(DesignWrapper, { styles: item.styles }, builder.bindComponent(item, true)));
|
|
143
|
+
}
|
|
144
|
+
return /* @__PURE__ */ React3__namespace.createElement(React3__namespace.Suspense, { fallback: /* @__PURE__ */ React3__namespace.createElement("div", null, "Loading...") }, /* @__PURE__ */ React3__namespace.createElement(BuildContainerInner, { ...props }));
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
exports.BuildContainer = BuildContainer;
|
|
148
|
+
exports.DesignWrapper = DesignWrapper;
|
|
149
|
+
exports.Image = Image;
|
|
150
|
+
exports.builder = builder;
|
|
151
|
+
exports.cn = cn;
|
|
152
|
+
exports.insertAt = insertAt;
|
|
153
|
+
exports.tv = tv;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkOOIADGIA_js = require('./chunk-OOIADGIA.js');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
|
|
6
|
+
function _interopNamespace(e) {
|
|
7
|
+
if (e && e.__esModule) return e;
|
|
8
|
+
var n = Object.create(null);
|
|
9
|
+
if (e) {
|
|
10
|
+
Object.keys(e).forEach(function (k) {
|
|
11
|
+
if (k !== 'default') {
|
|
12
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return e[k]; }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
25
|
+
|
|
26
|
+
var StaticContent = (props) => {
|
|
27
|
+
return /* @__PURE__ */ React__namespace.createElement(
|
|
28
|
+
chunkOOIADGIA_js.BuildContainer,
|
|
29
|
+
{
|
|
30
|
+
name: "root",
|
|
31
|
+
edit: false,
|
|
32
|
+
multiple: true,
|
|
33
|
+
content: props.content || []
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// src/index.ts
|
|
39
|
+
var BuilderContent = React.lazy(() => import('./builder-content-IQHALH5A.js'));
|
|
40
|
+
|
|
41
|
+
exports.BuilderContent = BuilderContent;
|
|
42
|
+
exports.StaticContent = StaticContent;
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkXJ4ZJCQS_js = require('./chunk-XJ4ZJCQS.js');
|
|
4
|
+
var chunkOOIADGIA_js = require('./chunk-OOIADGIA.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "BuilderContent", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkXJ4ZJCQS_js.BuilderContent; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "StaticContent", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkXJ4ZJCQS_js.StaticContent; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "BuildContainer", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkOOIADGIA_js.BuildContainer; }
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, "builder", {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunkOOIADGIA_js.builder; }
|
|
23
23
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { BuilderContent, StaticContent } from './chunk-
|
|
2
|
-
export { BuildContainer, builder } from './chunk-
|
|
1
|
+
export { BuilderContent, StaticContent } from './chunk-7J7CMYXS.mjs';
|
|
2
|
+
export { BuildContainer, builder } from './chunk-NJ6FM7SJ.mjs';
|