@simple-builder/react 1.0.3 → 1.0.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-MHVIH442.js → build-container-client-PDM3LRIQ.js} +227 -262
- package/dist/{build-container-client-R2FNJHPM.mjs → build-container-client-Y55WZE6M.mjs} +171 -203
- package/dist/{builder-content-MNCJZTFS.mjs → builder-content-GELONUMY.mjs} +2 -2
- package/dist/{builder-content-BOQEXOAK.js → builder-content-QNCUQJUB.js} +7 -7
- package/dist/chunk-BSE6WW6Q.mjs +115 -0
- package/dist/{chunk-LPIHSXYO.mjs → chunk-EQMVGJ6X.mjs} +2 -35
- package/dist/chunk-J36K7WVK.js +145 -0
- package/dist/{chunk-N2X3IJBG.js → chunk-KOBGFPWB.js} +3 -3
- package/dist/{chunk-IVFWYNC3.mjs → chunk-NP2NHVJP.mjs} +2 -2
- package/dist/{chunk-GSOMMLCG.js → chunk-XEMUNFCV.js} +5 -40
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -6
- package/dist/index.mjs +2 -2
- package/package.json +2 -2
- package/dist/chunk-FGQSJAOO.mjs +0 -52
- package/dist/chunk-UZFAGH6G.js +0 -74
package/dist/chunk-UZFAGH6G.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
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;
|