@simple-builder/react 1.3.8 → 1.4.0

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.
Files changed (102) hide show
  1. package/dist/{build-container-client-NXIMV3RF.js → build-container-client-EQBL556Y.js} +148 -115
  2. package/dist/{build-container-client-5QC5KVS3.mjs → build-container-client-LMZUWEUI.mjs} +53 -20
  3. package/dist/{builder-content-4ZNXUE7D.mjs → builder-content-OR2VTIUY.mjs} +2 -2
  4. package/dist/{builder-content-2MA6BKJ5.js → builder-content-XNIM2YVG.js} +7 -7
  5. package/dist/{chunk-EVMN5SX2.js → chunk-4SFXTFFU.js} +5 -5
  6. package/dist/{chunk-4TVSMCQU.js → chunk-7I4RGF45.js} +3 -3
  7. package/dist/{chunk-5OV6KPTF.mjs → chunk-MXIMMIPT.mjs} +1 -1
  8. package/dist/{chunk-5Q4KJW4A.mjs → chunk-UA2CNH3R.mjs} +2 -2
  9. package/dist/{chunk-2CPAROZB.js → chunk-YFRFNRKR.js} +1 -1
  10. package/dist/{chunk-B5R6QY7N.mjs → chunk-ZQBKKI2S.mjs} +1 -1
  11. package/dist/index.css +0 -3
  12. package/dist/index.d.mts +6 -12
  13. package/dist/index.d.ts +6 -12
  14. package/dist/index.js +6 -6
  15. package/dist/index.mjs +2 -2
  16. package/package.json +2 -2
  17. package/dist/build-container-client-7Z6WZVBX.js +0 -2294
  18. package/dist/build-container-client-DWKVE65B.mjs +0 -2261
  19. package/dist/build-container-client-FN3PZMM7.mjs +0 -2256
  20. package/dist/build-container-client-FVDRMOZ7.mjs +0 -2254
  21. package/dist/build-container-client-GV52F5RP.js +0 -2297
  22. package/dist/build-container-client-J56NWFBF.mjs +0 -2260
  23. package/dist/build-container-client-L3WD4CG7.mjs +0 -2258
  24. package/dist/build-container-client-RSJ4H3SB.js +0 -2289
  25. package/dist/build-container-client-THZHNQ5S.mjs +0 -2263
  26. package/dist/build-container-client-WGVIYK47.css +0 -1968
  27. package/dist/build-container-client-WHIUDBOZ.mjs +0 -2262
  28. package/dist/build-container-client-WIGFVNOW.css +0 -1971
  29. package/dist/build-container-client-WN35X6JD.js +0 -2290
  30. package/dist/build-container-client-WYIHRPSW.js +0 -2298
  31. package/dist/build-container-client-XAQDWWKB.mjs +0 -2253
  32. package/dist/build-container-client-XOHYMPBB.js +0 -2292
  33. package/dist/build-container-client-YDRPPWCU.js +0 -2296
  34. package/dist/build-container-client-YWNDWXO2.css +0 -1967
  35. package/dist/build-container-client-ZXO66OL5.js +0 -2299
  36. package/dist/builder-content-2ZXIEMS3.js +0 -42
  37. package/dist/builder-content-3H7GF3KF.mjs +0 -20
  38. package/dist/builder-content-3HENFCB5.js +0 -42
  39. package/dist/builder-content-6PIBXDPE.mjs +0 -20
  40. package/dist/builder-content-73ZKCEIT.mjs +0 -20
  41. package/dist/builder-content-BIVYFWCC.js +0 -42
  42. package/dist/builder-content-BKE4JZ75.js +0 -42
  43. package/dist/builder-content-BU4BXER7.mjs +0 -20
  44. package/dist/builder-content-CP5VLMVD.mjs +0 -20
  45. package/dist/builder-content-CY43LFAA.js +0 -42
  46. package/dist/builder-content-FMTTH7R2.js +0 -42
  47. package/dist/builder-content-GBSIY2Z7.js +0 -42
  48. package/dist/builder-content-GJ4HYIOA.mjs +0 -20
  49. package/dist/builder-content-HQXSXBFZ.mjs +0 -20
  50. package/dist/builder-content-MI55X5HA.css +0 -1971
  51. package/dist/builder-content-PWV6LNFT.mjs +0 -20
  52. package/dist/builder-content-RROSPBT4.css +0 -1968
  53. package/dist/builder-content-RV3DPWFH.js +0 -42
  54. package/dist/builder-content-V2MDRHJI.css +0 -1967
  55. package/dist/chunk-2GOYHVMW.mjs +0 -123
  56. package/dist/chunk-2OHBCAZQ.mjs +0 -244
  57. package/dist/chunk-2OYBZSJQ.mjs +0 -123
  58. package/dist/chunk-3QWMKMTN.js +0 -269
  59. package/dist/chunk-454D7NIH.js +0 -153
  60. package/dist/chunk-6GCMYFBT.mjs +0 -20
  61. package/dist/chunk-6GCUWI4L.mjs +0 -135
  62. package/dist/chunk-6KNCX5O5.mjs +0 -123
  63. package/dist/chunk-6VINC5E2.mjs +0 -244
  64. package/dist/chunk-7X5S5JRE.js +0 -42
  65. package/dist/chunk-C5GHD62W.mjs +0 -20
  66. package/dist/chunk-CARNMQP6.mjs +0 -20
  67. package/dist/chunk-CJGHP5Q7.mjs +0 -244
  68. package/dist/chunk-CJNSRJNF.js +0 -42
  69. package/dist/chunk-DZLUIOVD.js +0 -153
  70. package/dist/chunk-EZFQOJHG.mjs +0 -244
  71. package/dist/chunk-F5JWY4CM.mjs +0 -20
  72. package/dist/chunk-H357GPTV.mjs +0 -244
  73. package/dist/chunk-H6OM2V2U.mjs +0 -20
  74. package/dist/chunk-HCM5NR6G.js +0 -269
  75. package/dist/chunk-IQX5LONG.js +0 -153
  76. package/dist/chunk-LEIASP7E.js +0 -153
  77. package/dist/chunk-MBISMJDL.js +0 -269
  78. package/dist/chunk-NDE4WSBA.js +0 -269
  79. package/dist/chunk-NUDE6YTK.js +0 -165
  80. package/dist/chunk-NZ4ZQMIS.js +0 -42
  81. package/dist/chunk-OWZPAOR6.mjs +0 -244
  82. package/dist/chunk-PADTJYXB.mjs +0 -20
  83. package/dist/chunk-QZQRUNAY.js +0 -153
  84. package/dist/chunk-RGBUK5SR.js +0 -269
  85. package/dist/chunk-RNGHWAPZ.js +0 -269
  86. package/dist/chunk-RZFAIM2Q.mjs +0 -123
  87. package/dist/chunk-SFYJAJOD.js +0 -42
  88. package/dist/chunk-SLWJHIVH.mjs +0 -123
  89. package/dist/chunk-TMDKQB2L.js +0 -153
  90. package/dist/chunk-TQQ4WVQU.mjs +0 -123
  91. package/dist/chunk-VCXFPTGD.js +0 -42
  92. package/dist/chunk-VNNNLYSW.js +0 -42
  93. package/dist/chunk-WA7TKN6M.js +0 -42
  94. package/dist/chunk-WI3YU7TV.js +0 -42
  95. package/dist/chunk-WPBR7BJZ.js +0 -269
  96. package/dist/chunk-X5A4S44V.mjs +0 -244
  97. package/dist/chunk-X5GVLHI2.mjs +0 -20
  98. package/dist/chunk-XLE7GSYM.mjs +0 -244
  99. package/dist/chunk-XSG7W73Z.mjs +0 -20
  100. package/dist/chunk-XZNO7DXS.js +0 -153
  101. package/dist/chunk-YKPZPQ5D.js +0 -269
  102. package/dist/chunk-ZZT7HGAM.mjs +0 -123
@@ -1,269 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkLEIASP7E_js = require('./chunk-LEIASP7E.js');
4
- var React = require('react');
5
- var reactSlot = require('@radix-ui/react-slot');
6
- var classVarianceAuthority = require('class-variance-authority');
7
-
8
- function _interopNamespace(e) {
9
- if (e && e.__esModule) return e;
10
- var n = Object.create(null);
11
- if (e) {
12
- Object.keys(e).forEach(function (k) {
13
- if (k !== 'default') {
14
- var d = Object.getOwnPropertyDescriptor(e, k);
15
- Object.defineProperty(n, k, d.get ? d : {
16
- enumerable: true,
17
- get: function () { return e[k]; }
18
- });
19
- }
20
- });
21
- }
22
- n.default = e;
23
- return Object.freeze(n);
24
- }
25
-
26
- var React__namespace = /*#__PURE__*/_interopNamespace(React);
27
-
28
- var BuilderContext = React__namespace.createContext(
29
- null
30
- );
31
- var BuilderProvider = (props) => {
32
- const url = props.url ?? "/api/simple-builder";
33
- const [content, setContent] = React__namespace.useState(
34
- props.content ?? []
35
- );
36
- const getItem = React__namespace.useCallback(
37
- (id) => {
38
- return findRecursive(content, (item) => item.id === id);
39
- },
40
- [content]
41
- );
42
- const patchItem = React__namespace.useCallback(
43
- (id, patch) => {
44
- setContent(
45
- (content2) => mapRecursive(content2, (item) => {
46
- if (item.id === id) {
47
- return {
48
- ...item,
49
- ...patch
50
- };
51
- }
52
- return item;
53
- })
54
- );
55
- },
56
- [setContent, mapRecursive]
57
- );
58
- const addContent = React__namespace.useCallback(
59
- (name, container, parent, index = 0) => {
60
- const component = chunkLEIASP7E_js.builder.getComponent(name);
61
- if (!component) {
62
- throw new Error(`[simple-builder]: Component "${name}" not found`);
63
- }
64
- const entry = {
65
- id: crypto.randomUUID(),
66
- component: component.name,
67
- ...parent && { parent },
68
- ...component.inputs && {
69
- props: component.inputs.reduce(
70
- (acc, input) => ({
71
- ...acc,
72
- [input.name]: input.defaultValue
73
- }),
74
- {}
75
- )
76
- },
77
- ...component.defaultStyles && {
78
- styles: component.defaultStyles
79
- }
80
- };
81
- if (!parent) {
82
- setContent((content2) => chunkLEIASP7E_js.insertAt(content2, index, entry));
83
- return;
84
- }
85
- setContent(
86
- (content2) => mapRecursive(content2, (item) => {
87
- if (item.id === parent) {
88
- return {
89
- ...item,
90
- content: {
91
- ...item.content,
92
- [container]: chunkLEIASP7E_js.insertAt(item.content?.[container], index, entry)
93
- }
94
- };
95
- }
96
- return item;
97
- })
98
- );
99
- },
100
- [setContent, mapRecursive]
101
- );
102
- const deleteContent = React__namespace.useCallback(
103
- (id) => setContent((prev) => filterRecursive(prev, (item) => item.id !== id)),
104
- [setContent, filterRecursive]
105
- );
106
- const bringUp = React__namespace.useCallback(
107
- (id) => {
108
- setContent(
109
- (content2) => mapRecursive(content2, (item, index, arr) => {
110
- if (item.id === id && index > 0) {
111
- return arr[index - 1];
112
- }
113
- if (arr[index + 1]?.id === id) {
114
- return arr[index + 1];
115
- }
116
- return item;
117
- })
118
- );
119
- },
120
- [setContent, mapRecursive]
121
- );
122
- const bringDown = React__namespace.useCallback(
123
- (id) => {
124
- setContent(
125
- (content2) => mapRecursive(content2, (item, index, arr) => {
126
- if (item.id === id && index < arr.length - 1) {
127
- return arr[index + 1];
128
- }
129
- if (arr[index - 1]?.id === id) {
130
- return arr[index - 1];
131
- }
132
- return item;
133
- })
134
- );
135
- },
136
- [setContent, mapRecursive]
137
- );
138
- const save = React__namespace.useCallback(async () => {
139
- const slug = window.location.pathname;
140
- try {
141
- await fetch(`${url}/page/update`, {
142
- method: "POST",
143
- body: JSON.stringify({
144
- slug,
145
- content
146
- })
147
- });
148
- alert("Pagina opgeslagen!");
149
- } catch (e) {
150
- console.error("[simple-builder]: Failed to save content", e);
151
- alert("Er is iets fout gegaan. Bekijk de console voor meer info.");
152
- }
153
- }, [content]);
154
- return /* @__PURE__ */ React__namespace.createElement(
155
- BuilderContext.Provider,
156
- {
157
- value: {
158
- url,
159
- content,
160
- setContent,
161
- getItem,
162
- patchItem,
163
- addContent,
164
- bringUp,
165
- bringDown,
166
- deleteContent,
167
- save
168
- }
169
- },
170
- props.children
171
- );
172
- };
173
- var useBuilder = () => {
174
- const context = React__namespace.useContext(BuilderContext);
175
- if (!context) {
176
- throw new Error(
177
- "[simple-builder]: useBuilder must be used within a BuilderProvider"
178
- );
179
- }
180
- return context;
181
- };
182
- var filterRecursive = (items, predicate, key = "content") => {
183
- return items.filter(predicate).map((item) => ({
184
- ...item,
185
- ...item[key] && {
186
- [key]: Object.entries(item[key] ?? {}).reduce(
187
- (acc, [name, content]) => ({
188
- ...acc,
189
- [name]: filterRecursive(content, predicate, key)
190
- }),
191
- {}
192
- )
193
- }
194
- }));
195
- };
196
- var mapRecursive = (items, predicate, key = "content") => {
197
- return items.map(predicate).map((item) => ({
198
- ...item,
199
- ...item[key] && {
200
- [key]: Object.entries(item[key] ?? {}).reduce(
201
- (acc, [name, content]) => ({
202
- ...acc,
203
- [name]: mapRecursive(content, predicate, key)
204
- }),
205
- {}
206
- )
207
- }
208
- }));
209
- };
210
- var findRecursive = (items, predicate, key = "content") => {
211
- for (const item of items) {
212
- if (predicate(item)) {
213
- return item;
214
- }
215
- if (item[key]) {
216
- const keys = Object.keys(item[key] ?? {});
217
- for (const x of keys) {
218
- const found = findRecursive(item[key][x], predicate, key);
219
- if (found) {
220
- return found;
221
- }
222
- }
223
- }
224
- }
225
- };
226
- var buttonVariants = classVarianceAuthority.cva(
227
- "sb:inline-flex sb:items-center sb:justify-center sb:gap-2 sb:whitespace-nowrap sb:rounded-md sb:text-sm sb:font-medium sb:transition-colors sb:focus-visible:outline-hidden sb:focus-visible:ring-1 sb:focus-visible:ring-ring sb:disabled:pointer-events-none sb:disabled:opacity-50 sb:[&_svg]:pointer-events-none sb:[&_svg]:size-4 sb:[&_svg]:shrink-0",
228
- {
229
- variants: {
230
- variant: {
231
- default: "sb:bg-primary sb:text-primary-foreground sb:shadow sb:hover:bg-primary/90",
232
- destructive: "sb:bg-destructive sb:text-destructive-foreground sb:shadow-sm sb:hover:bg-destructive/90",
233
- outline: "sb:border sb:border-input sb:bg-background sb:shadow-sm sb:hover:bg-accent sb:hover:text-accent-foreground",
234
- secondary: "sb:bg-secondary sb:text-secondary-foreground sb:shadow-sm sb:hover:bg-secondary/80",
235
- ghost: "sb:hover:bg-accent sb:hover:text-accent-foreground",
236
- link: "sb:text-primary sb:underline-offset-4 sb:hover:underline"
237
- },
238
- size: {
239
- default: "sb:h-9 sb:px-4 sb:py-2",
240
- sm: "sb:h-8 sb:rounded-md sb:px-3 sb:text-xs",
241
- lg: "sb:h-10 sb:rounded-md sb:px-8",
242
- icon: "sb:h-9 sb:w-9"
243
- }
244
- },
245
- defaultVariants: {
246
- variant: "default",
247
- size: "default"
248
- }
249
- }
250
- );
251
- var Button = React__namespace.forwardRef(
252
- ({ className, variant, size, asChild = false, ...props }, ref) => {
253
- const Comp = asChild ? reactSlot.Slot : "button";
254
- return /* @__PURE__ */ React__namespace.createElement(
255
- Comp,
256
- {
257
- className: chunkLEIASP7E_js.cn(buttonVariants({ variant, size, className })),
258
- ref,
259
- ...props
260
- }
261
- );
262
- }
263
- );
264
- Button.displayName = "Button";
265
-
266
- exports.BuilderProvider = BuilderProvider;
267
- exports.Button = Button;
268
- exports.buttonVariants = buttonVariants;
269
- exports.useBuilder = useBuilder;
@@ -1,269 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkNUDE6YTK_js = require('./chunk-NUDE6YTK.js');
4
- var React = require('react');
5
- var reactSlot = require('@radix-ui/react-slot');
6
- var classVarianceAuthority = require('class-variance-authority');
7
-
8
- function _interopNamespace(e) {
9
- if (e && e.__esModule) return e;
10
- var n = Object.create(null);
11
- if (e) {
12
- Object.keys(e).forEach(function (k) {
13
- if (k !== 'default') {
14
- var d = Object.getOwnPropertyDescriptor(e, k);
15
- Object.defineProperty(n, k, d.get ? d : {
16
- enumerable: true,
17
- get: function () { return e[k]; }
18
- });
19
- }
20
- });
21
- }
22
- n.default = e;
23
- return Object.freeze(n);
24
- }
25
-
26
- var React__namespace = /*#__PURE__*/_interopNamespace(React);
27
-
28
- var BuilderContext = React__namespace.createContext(
29
- null
30
- );
31
- var BuilderProvider = (props) => {
32
- const url = props.url ?? "/api/simple-builder";
33
- const [content, setContent] = React__namespace.useState(
34
- props.content ?? []
35
- );
36
- const getItem = React__namespace.useCallback(
37
- (id) => {
38
- return findRecursive(content, (item) => item.id === id);
39
- },
40
- [content]
41
- );
42
- const patchItem = React__namespace.useCallback(
43
- (id, patch) => {
44
- setContent(
45
- (content2) => mapRecursive(content2, (item) => {
46
- if (item.id === id) {
47
- return {
48
- ...item,
49
- ...patch
50
- };
51
- }
52
- return item;
53
- })
54
- );
55
- },
56
- [setContent, mapRecursive]
57
- );
58
- const addContent = React__namespace.useCallback(
59
- (name, container, parent, index = 0) => {
60
- const component = chunkNUDE6YTK_js.builder.getComponent(name);
61
- if (!component) {
62
- throw new Error(`[simple-builder]: Component "${name}" not found`);
63
- }
64
- const entry = {
65
- id: crypto.randomUUID(),
66
- component: component.name,
67
- ...parent && { parent },
68
- ...component.inputs && {
69
- props: component.inputs.reduce(
70
- (acc, input) => ({
71
- ...acc,
72
- [input.name]: input.defaultValue
73
- }),
74
- {}
75
- )
76
- },
77
- ...component.defaultStyles && {
78
- styles: component.defaultStyles
79
- }
80
- };
81
- if (!parent) {
82
- setContent((content2) => chunkNUDE6YTK_js.insertAt(content2, index, entry));
83
- return;
84
- }
85
- setContent(
86
- (content2) => mapRecursive(content2, (item) => {
87
- if (item.id === parent) {
88
- return {
89
- ...item,
90
- content: {
91
- ...item.content,
92
- [container]: chunkNUDE6YTK_js.insertAt(item.content?.[container], index, entry)
93
- }
94
- };
95
- }
96
- return item;
97
- })
98
- );
99
- },
100
- [setContent, mapRecursive]
101
- );
102
- const deleteContent = React__namespace.useCallback(
103
- (id) => setContent((prev) => filterRecursive(prev, (item) => item.id !== id)),
104
- [setContent, filterRecursive]
105
- );
106
- const bringUp = React__namespace.useCallback(
107
- (id) => {
108
- setContent(
109
- (content2) => mapRecursive(content2, (item, index, arr) => {
110
- if (item.id === id && index > 0) {
111
- return arr[index - 1];
112
- }
113
- if (arr[index + 1]?.id === id) {
114
- return arr[index + 1];
115
- }
116
- return item;
117
- })
118
- );
119
- },
120
- [setContent, mapRecursive]
121
- );
122
- const bringDown = React__namespace.useCallback(
123
- (id) => {
124
- setContent(
125
- (content2) => mapRecursive(content2, (item, index, arr) => {
126
- if (item.id === id && index < arr.length - 1) {
127
- return arr[index + 1];
128
- }
129
- if (arr[index - 1]?.id === id) {
130
- return arr[index - 1];
131
- }
132
- return item;
133
- })
134
- );
135
- },
136
- [setContent, mapRecursive]
137
- );
138
- const save = React__namespace.useCallback(async () => {
139
- const slug = window.location.pathname;
140
- try {
141
- await fetch(`${url}/page/update`, {
142
- method: "POST",
143
- body: JSON.stringify({
144
- slug,
145
- content
146
- })
147
- });
148
- alert("Pagina opgeslagen!");
149
- } catch (e) {
150
- console.error("[simple-builder]: Failed to save content", e);
151
- alert("Er is iets fout gegaan. Bekijk de console voor meer info.");
152
- }
153
- }, [content]);
154
- return /* @__PURE__ */ React__namespace.createElement(
155
- BuilderContext.Provider,
156
- {
157
- value: {
158
- url,
159
- content,
160
- setContent,
161
- getItem,
162
- patchItem,
163
- addContent,
164
- bringUp,
165
- bringDown,
166
- deleteContent,
167
- save
168
- }
169
- },
170
- props.children
171
- );
172
- };
173
- var useBuilder = () => {
174
- const context = React__namespace.useContext(BuilderContext);
175
- if (!context) {
176
- throw new Error(
177
- "[simple-builder]: useBuilder must be used within a BuilderProvider"
178
- );
179
- }
180
- return context;
181
- };
182
- var filterRecursive = (items, predicate, key = "content") => {
183
- return items.filter(predicate).map((item) => ({
184
- ...item,
185
- ...item[key] && {
186
- [key]: Object.entries(item[key] ?? {}).reduce(
187
- (acc, [name, content]) => ({
188
- ...acc,
189
- [name]: filterRecursive(content, predicate, key)
190
- }),
191
- {}
192
- )
193
- }
194
- }));
195
- };
196
- var mapRecursive = (items, predicate, key = "content") => {
197
- return items.map(predicate).map((item) => ({
198
- ...item,
199
- ...item[key] && {
200
- [key]: Object.entries(item[key] ?? {}).reduce(
201
- (acc, [name, content]) => ({
202
- ...acc,
203
- [name]: mapRecursive(content, predicate, key)
204
- }),
205
- {}
206
- )
207
- }
208
- }));
209
- };
210
- var findRecursive = (items, predicate, key = "content") => {
211
- for (const item of items) {
212
- if (predicate(item)) {
213
- return item;
214
- }
215
- if (item[key]) {
216
- const keys = Object.keys(item[key] ?? {});
217
- for (const x of keys) {
218
- const found = findRecursive(item[key][x], predicate, key);
219
- if (found) {
220
- return found;
221
- }
222
- }
223
- }
224
- }
225
- };
226
- var buttonVariants = classVarianceAuthority.cva(
227
- "sb:inline-flex sb:items-center sb:justify-center sb:gap-2 sb:whitespace-nowrap sb:rounded-md sb:text-sm sb:font-medium sb:transition-colors sb:focus-visible:outline-hidden sb:focus-visible:ring-1 sb:focus-visible:ring-ring sb:disabled:pointer-events-none sb:disabled:opacity-50 sb:[&_svg]:pointer-events-none sb:[&_svg]:size-4 sb:[&_svg]:shrink-0",
228
- {
229
- variants: {
230
- variant: {
231
- default: "sb:bg-primary sb:text-primary-foreground sb:shadow sb:hover:bg-primary/90",
232
- destructive: "sb:bg-destructive sb:text-destructive-foreground sb:shadow-sm sb:hover:bg-destructive/90",
233
- outline: "sb:border sb:border-input sb:bg-background sb:shadow-sm sb:hover:bg-accent sb:hover:text-accent-foreground",
234
- secondary: "sb:bg-secondary sb:text-secondary-foreground sb:shadow-sm sb:hover:bg-secondary/80",
235
- ghost: "sb:hover:bg-accent sb:hover:text-accent-foreground",
236
- link: "sb:text-primary sb:underline-offset-4 sb:hover:underline"
237
- },
238
- size: {
239
- default: "sb:h-9 sb:px-4 sb:py-2",
240
- sm: "sb:h-8 sb:rounded-md sb:px-3 sb:text-xs",
241
- lg: "sb:h-10 sb:rounded-md sb:px-8",
242
- icon: "sb:h-9 sb:w-9"
243
- }
244
- },
245
- defaultVariants: {
246
- variant: "default",
247
- size: "default"
248
- }
249
- }
250
- );
251
- var Button = React__namespace.forwardRef(
252
- ({ className, variant, size, asChild = false, ...props }, ref) => {
253
- const Comp = asChild ? reactSlot.Slot : "button";
254
- return /* @__PURE__ */ React__namespace.createElement(
255
- Comp,
256
- {
257
- className: chunkNUDE6YTK_js.cn(buttonVariants({ variant, size, className })),
258
- ref,
259
- ...props
260
- }
261
- );
262
- }
263
- );
264
- Button.displayName = "Button";
265
-
266
- exports.BuilderProvider = BuilderProvider;
267
- exports.Button = Button;
268
- exports.buttonVariants = buttonVariants;
269
- exports.useBuilder = useBuilder;
@@ -1,123 +0,0 @@
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
- import { createTV } from 'tailwind-variants';
7
-
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;
41
- }
42
- };
43
- })();
44
- var Image = (props) => {
45
- if (typeof NextImage !== "undefined") {
46
- return /* @__PURE__ */ React3.createElement(NextImage, { ...props });
47
- }
48
- return /* @__PURE__ */ React3.createElement("img", { ...props });
49
- };
50
- var twMerge = extendTailwindMerge({
51
- prefix: "sb-"
52
- });
53
- function cn(...inputs) {
54
- return twMerge(clsx(inputs));
55
- }
56
- var tv = createTV({
57
- twMergeConfig: {
58
- prefix: "sb-"
59
- }
60
- });
61
- var insertAt = (items, index, item) => {
62
- return Array.isArray(items) ? [...items.slice(0, index), item, ...items.slice(index)] : [item];
63
- };
64
-
65
- // src/components/design-wrapper.tsx
66
- var DesignWrapper = (props) => {
67
- const { children, className, building = false } = props;
68
- const { background } = props.styles?.desktop ?? {};
69
- const matches = typeof background === "string" ? background.match(/url\(["']?(.*?)["']?\)/) : void 0;
70
- const src = matches ? matches[1] : void 0;
71
- const desktopStyles = props.styles?.desktop ?? {};
72
- const mobileStyles = props.styles?.mobile ?? {};
73
- const container = props.styles?.container ?? true;
74
- const hidden = props.styles?.hidden ?? "never";
75
- const id = React3.useId().replace(/[^a-zA-Z0-9]/g, "");
76
- let hiddenClass = "";
77
- switch (hidden) {
78
- case "always":
79
- hiddenClass = building ? "sb:opacity-30" : "sb:hidden";
80
- break;
81
- case "mobile":
82
- hiddenClass = building ? "sb:max-md:opacity-30" : "sb:max-md:hidden";
83
- break;
84
- case "desktop":
85
- hiddenClass = building ? "sb:md:opacity-30" : "sb:md:hidden";
86
- break;
87
- case "never":
88
- hiddenClass = "";
89
- break;
90
- }
91
- return /* @__PURE__ */ React3.createElement("div", { id, className: cn("sb:relative", className, hiddenClass) }, 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
- ), container ? /* @__PURE__ */ React3.createElement("div", { className: "container sb:mx-auto" }, children) : children, /* @__PURE__ */ React3.createElement("style", null, `
100
- #${id} {
101
- ${Object.entries(desktopStyles).filter(([key]) => !(key === "background" && src)).map(([key, value]) => `${key}: ${value};`).join(" ")}
102
- }
103
-
104
- @media (max-width: 1024px) {
105
- #${id} {
106
- ${Object.entries(mobileStyles).filter(([key]) => !(key === "background" && src)).map(([key, value]) => `${key}: ${value}; `).join(" ")}
107
- }
108
- }
109
- `.replace(/\s\s+/g, " ")));
110
- };
111
- var BuildContainerInner = React3.lazy(
112
- () => import('./build-container-client-J56NWFBF.mjs')
113
- );
114
- var BuildContainer = (props) => {
115
- const { content, edit, name } = props;
116
- const items = Array.isArray(content) ? content : content?.[name] || [];
117
- if (!edit) {
118
- return items.map((item) => /* @__PURE__ */ React3.createElement(DesignWrapper, { styles: item.styles }, builder.bindComponent(item, true)));
119
- }
120
- return /* @__PURE__ */ React3.createElement(React3.Suspense, { fallback: /* @__PURE__ */ React3.createElement("div", null, "Loading...") }, /* @__PURE__ */ React3.createElement(BuildContainerInner, { ...props }));
121
- };
122
-
123
- export { BuildContainer, DesignWrapper, Image, builder, cn, insertAt, tv };
@@ -1,42 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkXZNO7DXS_js = require('./chunk-XZNO7DXS.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
- chunkXZNO7DXS_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-FMTTH7R2.js'));
40
-
41
- exports.BuilderContent = BuilderContent;
42
- exports.StaticContent = StaticContent;