@simple-builder/react 1.0.8 → 1.0.10

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,1372 +0,0 @@
1
- 'use client';
2
- 'use strict';
3
-
4
- require('./chunk-MSCSJUNQ.js');
5
- var chunkI2LWMDYD_js = require('./chunk-I2LWMDYD.js');
6
- var chunkLJSVUW4D_js = require('./chunk-LJSVUW4D.js');
7
- var React15 = require('react');
8
- var lucideReact = require('lucide-react');
9
- var AlertDialogPrimitive = require('@radix-ui/react-alert-dialog');
10
- var PopoverPrimitive = require('@radix-ui/react-popover');
11
- var dateFns = require('date-fns');
12
- var reactHookForm = require('react-hook-form');
13
- var reactDayPicker = require('react-day-picker');
14
- var reactSlot = require('@radix-ui/react-slot');
15
- var LabelPrimitive = require('@radix-ui/react-label');
16
- var SwitchPrimitives = require('@radix-ui/react-switch');
17
- var zod$1 = require('@hookform/resolvers/zod');
18
- var zod = require('zod');
19
- var TabsPrimitive = require('@radix-ui/react-tabs');
20
- var TogglePrimitive = require('@radix-ui/react-toggle');
21
-
22
- function _interopNamespace(e) {
23
- if (e && e.__esModule) return e;
24
- var n = Object.create(null);
25
- if (e) {
26
- Object.keys(e).forEach(function (k) {
27
- if (k !== 'default') {
28
- var d = Object.getOwnPropertyDescriptor(e, k);
29
- Object.defineProperty(n, k, d.get ? d : {
30
- enumerable: true,
31
- get: function () { return e[k]; }
32
- });
33
- }
34
- });
35
- }
36
- n.default = e;
37
- return Object.freeze(n);
38
- }
39
-
40
- var React15__namespace = /*#__PURE__*/_interopNamespace(React15);
41
- var AlertDialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(AlertDialogPrimitive);
42
- var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
43
- var LabelPrimitive__namespace = /*#__PURE__*/_interopNamespace(LabelPrimitive);
44
- var SwitchPrimitives__namespace = /*#__PURE__*/_interopNamespace(SwitchPrimitives);
45
- var TabsPrimitive__namespace = /*#__PURE__*/_interopNamespace(TabsPrimitive);
46
- var TogglePrimitive__namespace = /*#__PURE__*/_interopNamespace(TogglePrimitive);
47
-
48
- var AlertDialog = AlertDialogPrimitive__namespace.Root;
49
- var AlertDialogTrigger = AlertDialogPrimitive__namespace.Trigger;
50
- var AlertDialogPortal = AlertDialogPrimitive__namespace.Portal;
51
- var AlertDialogOverlay = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React15__namespace.createElement(
52
- AlertDialogPrimitive__namespace.Overlay,
53
- {
54
- className: chunkLJSVUW4D_js.cn(
55
- "sb-fixed sb-inset-0 sb-z-50 sb-bg-background/80 sb-backdrop-blur-sm data-[state=open]:sb-animate-in data-[state=closed]:sb-animate-out data-[state=closed]:sb-fade-out-0 data-[state=open]:sb-fade-in-0",
56
- className
57
- ),
58
- ...props,
59
- ref
60
- }
61
- ));
62
- AlertDialogOverlay.displayName = AlertDialogPrimitive__namespace.Overlay.displayName;
63
- var AlertDialogContent = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React15__namespace.createElement(AlertDialogPortal, null, /* @__PURE__ */ React15__namespace.createElement(AlertDialogOverlay, null), /* @__PURE__ */ React15__namespace.createElement(
64
- AlertDialogPrimitive__namespace.Content,
65
- {
66
- ref,
67
- className: chunkLJSVUW4D_js.cn(
68
- "sb-fixed sb-font-roboto sb-left-[50%] sb-top-[50%] sb-z-50 sb-grid sb-w-full sb-max-w-lg sb-translate-x-[-50%] sb-translate-y-[-50%] sb-gap-4 sb-border sb-bg-background sb-p-6 sb-shadow-lg sb-duration-200 data-[state=open]:sb-animate-in data-[state=closed]:sb-animate-out data-[state=closed]:sb-fade-out-0 data-[state=open]:sb-fade-in-0 data-[state=closed]:sb-zoom-out-95 data-[state=open]:sb-zoom-in-95 data-[state=closed]:sb-slide-out-to-left-1/2 data-[state=closed]:sb-slide-out-to-top-[48%] data-[state=open]:sb-slide-in-from-left-1/2 data-[state=open]:sb-slide-in-from-top-[48%] sm:sb-rounded-lg",
69
- className
70
- ),
71
- ...props
72
- }
73
- )));
74
- AlertDialogContent.displayName = AlertDialogPrimitive__namespace.Content.displayName;
75
- var AlertDialogFooter = ({
76
- className,
77
- ...props
78
- }) => /* @__PURE__ */ React15__namespace.createElement(
79
- "div",
80
- {
81
- className: chunkLJSVUW4D_js.cn(
82
- "sb-flex sb-flex-col-reverse sm:sb-flex-row sm:sb-justify-end sm:sb-space-x-2",
83
- className
84
- ),
85
- ...props
86
- }
87
- );
88
- AlertDialogFooter.displayName = "AlertDialogFooter";
89
- var AlertDialogTitle = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React15__namespace.createElement(
90
- AlertDialogPrimitive__namespace.Title,
91
- {
92
- ref,
93
- className: chunkLJSVUW4D_js.cn("sb-text-lg sb-font-semibold", className),
94
- ...props
95
- }
96
- ));
97
- AlertDialogTitle.displayName = AlertDialogPrimitive__namespace.Title.displayName;
98
- var AlertDialogDescription = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React15__namespace.createElement(
99
- AlertDialogPrimitive__namespace.Description,
100
- {
101
- ref,
102
- className: chunkLJSVUW4D_js.cn("sb-text-sm sb-text-muted-foreground", className),
103
- ...props
104
- }
105
- ));
106
- AlertDialogDescription.displayName = AlertDialogPrimitive__namespace.Description.displayName;
107
- var AlertDialogAction = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React15__namespace.createElement(
108
- AlertDialogPrimitive__namespace.Action,
109
- {
110
- ref,
111
- className: chunkLJSVUW4D_js.cn(chunkI2LWMDYD_js.buttonVariants(), className),
112
- ...props
113
- }
114
- ));
115
- AlertDialogAction.displayName = AlertDialogPrimitive__namespace.Action.displayName;
116
- var AlertDialogCancel = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React15__namespace.createElement(
117
- AlertDialogPrimitive__namespace.Cancel,
118
- {
119
- ref,
120
- className: chunkLJSVUW4D_js.cn(
121
- chunkI2LWMDYD_js.buttonVariants({ variant: "outline" }),
122
- "sb-mt-2 sm:sb-mt-0",
123
- className
124
- ),
125
- ...props
126
- }
127
- ));
128
- AlertDialogCancel.displayName = AlertDialogPrimitive__namespace.Cancel.displayName;
129
- var Popover = PopoverPrimitive__namespace.Root;
130
- var PopoverTrigger = PopoverPrimitive__namespace.Trigger;
131
- var PopoverClose = PopoverPrimitive__namespace.Close;
132
- var PopoverContent = React15__namespace.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ React15__namespace.createElement(PopoverPrimitive__namespace.Portal, null, /* @__PURE__ */ React15__namespace.createElement(
133
- PopoverPrimitive__namespace.Content,
134
- {
135
- ref,
136
- align,
137
- sideOffset,
138
- className: chunkLJSVUW4D_js.cn(
139
- "sb-z-50 sb-w-72 sb-font-roboto sb-rounded-md sb-border sb-bg-popover sb-p-4 sb-text-popover-foreground sb-shadow-md sb-outline-none data-[state=open]:sb-animate-in data-[state=closed]:sb-animate-out data-[state=closed]:sb-fade-out-0 data-[state=open]:sb-fade-in-0 data-[state=closed]:sb-zoom-out-95 data-[state=open]:sb-zoom-in-95 data-[side=bottom]:sb-slide-in-from-top-2 data-[side=left]:sb-slide-in-from-right-2 data-[side=right]:sb-slide-in-from-left-2 data-[side=top]:sb-slide-in-from-bottom-2",
140
- className
141
- ),
142
- ...props
143
- }
144
- )));
145
- PopoverContent.displayName = PopoverPrimitive__namespace.Content.displayName;
146
- function Calendar({
147
- className,
148
- classNames,
149
- showOutsideDays = true,
150
- ...props
151
- }) {
152
- return /* @__PURE__ */ React15__namespace.createElement(
153
- reactDayPicker.DayPicker,
154
- {
155
- showOutsideDays,
156
- className: chunkLJSVUW4D_js.cn("sb-p-3 sb-font-roboto", className),
157
- classNames: {
158
- months: "sb-flex sb-flex-col sm:sb-flex-row sb-space-y-4 sm:sb-space-x-4 sm:sb-space-y-0",
159
- month: "sb-space-y-4",
160
- caption: "sb-flex sb-justify-center sb-pt-1 sb-relative sb-items-center",
161
- caption_label: "sb-text-sm sb-font-medium",
162
- nav: "sb-space-x-1 sb-flex sb-items-center",
163
- nav_button: chunkLJSVUW4D_js.cn(
164
- chunkI2LWMDYD_js.buttonVariants({ variant: "outline" }),
165
- "sb-h-7 sb-w-7 sb-bg-transparent sb-p-0 sb-opacity-50 hover:sb-opacity-100"
166
- ),
167
- nav_button_previous: "sb-absolute sb-left-1",
168
- nav_button_next: "sb-absolute sb-right-1",
169
- table: "sb-w-full sb-border-collapse sb-space-y-1",
170
- head_row: "sb-flex",
171
- head_cell: "sb-text-muted-foreground sb-rounded-md sb-w-8 sb-font-normal sb-text-[0.8rem]",
172
- row: "sb-flex sb-w-full sb-mt-2",
173
- cell: chunkLJSVUW4D_js.cn(
174
- "sb-relative sb-p-0 sb-text-center sb-text-sm focus-within:sb-relative focus-within:sb-z-20 [&:has([aria-selected])]:sb-bg-accent [&:has([aria-selected].day-outside)]:sb-bg-accent/50 [&:has([aria-selected].day-range-end)]:sb-rounded-r-md",
175
- props.mode === "range" ? "[&:has(>.day-range-end)]:sb-rounded-r-md [&:has(>.day-range-start)]:sb-rounded-l-md first:[&:has([aria-selected])]:sb-rounded-l-md last:[&:has([aria-selected])]:sb-rounded-r-md" : "[&:has([aria-selected])]:sb-rounded-md"
176
- ),
177
- day: chunkLJSVUW4D_js.cn(
178
- chunkI2LWMDYD_js.buttonVariants({ variant: "ghost" }),
179
- "sb-h-8 sb-w-8 sb-p-0 sb-font-normal aria-selected:sb-opacity-100"
180
- ),
181
- day_range_start: "day-range-start",
182
- day_range_end: "day-range-end",
183
- day_selected: "sb-bg-primary sb-text-primary-foreground hover:sb-bg-primary hover:sb-text-primary-foreground focus:sb-bg-primary focus:sb-text-primary-foreground",
184
- day_today: "sb-bg-accent sb-text-accent-foreground",
185
- day_outside: "day-outside sb-text-muted-foreground sb-opacity-50 aria-selected:sb-bg-accent/50 aria-selected:sb-text-muted-foreground aria-selected:sb-opacity-30",
186
- day_disabled: "sb-text-muted-foreground sb-opacity-50",
187
- day_range_middle: "aria-selected:sb-bg-accent aria-selected:sb-text-accent-foreground",
188
- day_hidden: "invisible",
189
- ...classNames
190
- },
191
- components: {
192
- IconLeft: () => /* @__PURE__ */ React15__namespace.createElement(lucideReact.ChevronLeftIcon, { className: "sb-h-4 sb-w-4" }),
193
- IconRight: () => /* @__PURE__ */ React15__namespace.createElement(lucideReact.ChevronRightIcon, { className: "sb-h-4 sb-w-4" })
194
- },
195
- ...props
196
- }
197
- );
198
- }
199
- Calendar.displayName = "Calendar";
200
- var ColorPicker = (props) => {
201
- const { color, onColorChange, className } = props;
202
- const colors = props.colors ?? [
203
- "#000000",
204
- "#ffffff",
205
- "#0f172a",
206
- "#F1F5F9",
207
- "#64748B",
208
- "#E6007E",
209
- "#F8FAFC",
210
- "#009DD1",
211
- "#FF0000"
212
- ];
213
- return /* @__PURE__ */ React15__namespace.createElement(Popover, null, /* @__PURE__ */ React15__namespace.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React15__namespace.createElement(
214
- chunkI2LWMDYD_js.Button,
215
- {
216
- variant: "outline",
217
- size: "sm",
218
- className: chunkLJSVUW4D_js.cn(
219
- "sb-justify-start sb-text-left sb-font-normal sb-normal-case sb-w-full",
220
- !color && "sb-text-muted-foreground",
221
- className
222
- )
223
- },
224
- /* @__PURE__ */ React15__namespace.createElement("div", { className: "sb-w-full sb-flex sb-items-center sb-gap-2" }, color ? /* @__PURE__ */ React15__namespace.createElement(
225
- "div",
226
- {
227
- className: "sb-h-4 sb-w-4 sb-rounded !sb-bg-center !sb-bg-cover sb-transition-all sb-border",
228
- style: { background: color }
229
- }
230
- ) : /* @__PURE__ */ React15__namespace.createElement(lucideReact.PaintbrushIcon, { className: "sb-h-4 sb-w-4" }), /* @__PURE__ */ React15__namespace.createElement("div", { className: "sb-truncate sb-flex-1" }, color ? color : "Kies een kleur"))
231
- )), /* @__PURE__ */ React15__namespace.createElement(PopoverContent, { className: "sb-w-64 sb-p-4 sb-flex sb-flex-wrap sb-gap-1" }, colors.map((s) => /* @__PURE__ */ React15__namespace.createElement(
232
- "div",
233
- {
234
- key: s,
235
- style: { background: s },
236
- className: "sb-rounded-md sb-h-6 sb-w-6 sb-cursor-pointer active:sb-scale-105 sb-border",
237
- onClick: () => onColorChange(s)
238
- }
239
- ))));
240
- };
241
- var labelVariants = chunkLJSVUW4D_js.tv({
242
- base: "sb-text-sm sb-font-medium sb-font-roboto sb-leading-none peer-disabled:sb-cursor-not-allowed peer-disabled:sb-opacity-70"
243
- });
244
- var Label = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React15__namespace.createElement(
245
- LabelPrimitive__namespace.Root,
246
- {
247
- ref,
248
- className: labelVariants({ className }),
249
- ...props
250
- }
251
- ));
252
- Label.displayName = LabelPrimitive__namespace.Root.displayName;
253
-
254
- // src/components/ui/form.tsx
255
- var Form = reactHookForm.FormProvider;
256
- var FormFieldContext = React15__namespace.createContext(
257
- {}
258
- );
259
- var FormField = ({
260
- ...props
261
- }) => {
262
- return /* @__PURE__ */ React15__namespace.createElement(FormFieldContext.Provider, { value: { name: props.name } }, /* @__PURE__ */ React15__namespace.createElement(reactHookForm.Controller, { ...props }));
263
- };
264
- var useFormField = () => {
265
- const fieldContext = React15__namespace.useContext(FormFieldContext);
266
- const itemContext = React15__namespace.useContext(FormItemContext);
267
- const { getFieldState, formState } = reactHookForm.useFormContext();
268
- const fieldState = getFieldState(fieldContext.name, formState);
269
- if (!fieldContext) {
270
- throw new Error("useFormField should be used within <FormField>");
271
- }
272
- const { id } = itemContext;
273
- return {
274
- id,
275
- name: fieldContext.name,
276
- formItemId: `${id}-form-item`,
277
- formDescriptionId: `${id}-form-item-description`,
278
- formMessageId: `${id}-form-item-message`,
279
- ...fieldState
280
- };
281
- };
282
- var FormItemContext = React15__namespace.createContext(
283
- {}
284
- );
285
- var FormItem = React15__namespace.forwardRef(({ className, ...props }, ref) => {
286
- const id = React15__namespace.useId();
287
- return /* @__PURE__ */ React15__namespace.createElement(FormItemContext.Provider, { value: { id } }, /* @__PURE__ */ React15__namespace.createElement("div", { ref, className: chunkLJSVUW4D_js.cn("sb-space-y-2", className), ...props }));
288
- });
289
- FormItem.displayName = "FormItem";
290
- var FormLabel = React15__namespace.forwardRef(({ className, ...props }, ref) => {
291
- const { error, formItemId } = useFormField();
292
- return /* @__PURE__ */ React15__namespace.createElement(
293
- Label,
294
- {
295
- ref,
296
- className: chunkLJSVUW4D_js.cn(error && "sb-text-destructive", className),
297
- htmlFor: formItemId,
298
- ...props
299
- }
300
- );
301
- });
302
- FormLabel.displayName = "FormLabel";
303
- var FormControl = React15__namespace.forwardRef(({ ...props }, ref) => {
304
- const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
305
- return /* @__PURE__ */ React15__namespace.createElement(
306
- reactSlot.Slot,
307
- {
308
- ref,
309
- id: formItemId,
310
- "aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
311
- "aria-invalid": !!error,
312
- ...props
313
- }
314
- );
315
- });
316
- FormControl.displayName = "FormControl";
317
- var FormDescription = React15__namespace.forwardRef(({ className, ...props }, ref) => {
318
- const { formDescriptionId } = useFormField();
319
- return /* @__PURE__ */ React15__namespace.createElement(
320
- "p",
321
- {
322
- ref,
323
- id: formDescriptionId,
324
- className: chunkLJSVUW4D_js.cn(
325
- "sb-text-sm sb-font-roboto sb-text-muted-foreground",
326
- className
327
- ),
328
- ...props
329
- }
330
- );
331
- });
332
- FormDescription.displayName = "FormDescription";
333
- var FormMessage = React15__namespace.forwardRef(({ className, children, ...props }, ref) => {
334
- const { error, formMessageId } = useFormField();
335
- const body = error ? String(error?.message) : children;
336
- if (!body) {
337
- return null;
338
- }
339
- return /* @__PURE__ */ React15__namespace.createElement(
340
- "p",
341
- {
342
- ref,
343
- id: formMessageId,
344
- className: chunkLJSVUW4D_js.cn(
345
- "sb-text-sm sb-font-roboto sb-font-medium sb-text-destructive",
346
- className
347
- ),
348
- ...props
349
- },
350
- body
351
- );
352
- });
353
- FormMessage.displayName = "FormMessage";
354
- var Input = React15__namespace.forwardRef(
355
- ({ className, type, ...props }, ref) => {
356
- return /* @__PURE__ */ React15__namespace.createElement(
357
- "input",
358
- {
359
- type,
360
- className: chunkLJSVUW4D_js.cn(
361
- "sb-flex sb-h-8 sb-w-full sb-font-roboto sb-rounded-md sb-border sb-border-input sb-bg-background sb-px-3 sb-py-1 sb-text-sm sb-ring-offset-background file:sb-border-0 file:sb-bg-transparent file:sb-text-sm file:sb-font-medium placeholder:sb-text-muted-foreground focus-visible:sb-outline-none focus-visible:sb-ring-1 focus-visible:ring-sb-ring focus-visible:sb-ring-offset-2 disabled:sb-cursor-not-allowed disabled:sb-opacity-50",
362
- className
363
- ),
364
- ref,
365
- ...props
366
- }
367
- );
368
- }
369
- );
370
- Input.displayName = "Input";
371
- var AdvancedInput = React15__namespace.forwardRef(
372
- ({ prepend, append, ...props }, ref) => {
373
- return /* @__PURE__ */ React15__namespace.createElement("div", { className: "sb-relative" }, /* @__PURE__ */ React15__namespace.createElement(Input, { ref, className: "sb-pl-9 sb-pr-7 sb-text-right", ...props }), prepend && /* @__PURE__ */ React15__namespace.createElement("div", { className: "sb-absolute sb-font-roboto sb-top-1/2 sb-left-3 sb--translate-y-1/2" }, prepend), append && /* @__PURE__ */ React15__namespace.createElement("div", { className: "sb-absolute sb-font-roboto sb-top-1/2 sb-right-3 sb--translate-y-1/2" }, append));
374
- }
375
- );
376
- AdvancedInput.displayName = "AdvancedInput";
377
- var MediaInput = (props) => {
378
- const { onFilesChange, limit = 32, multiple = false, onError } = props;
379
- const id = React15__namespace.useId();
380
- const [queue, setQueue] = React15__namespace.useState([]);
381
- const [sources, setSources] = React15__namespace.useState(props.files ?? []);
382
- const maxConcurrentUploads = 3;
383
- const uploadingCountRef = React15__namespace.useRef(0);
384
- const handleFilesAdd = async (e) => {
385
- const files = e.target.files;
386
- if (!files || files.length === 0) {
387
- return;
388
- }
389
- if (files.length + sources.length > (multiple ? limit : 1)) {
390
- onError?.(
391
- new MediaInputError(
392
- `Maximaal ${limit} bestanden.`,
393
- `Je probeerde nu ${files.length + sources.length} bestanden toe te voegen, maar je mag er maximaal ${limit} toevoegen.`
394
- )
395
- );
396
- return;
397
- }
398
- const queue2 = Array.from(files);
399
- setQueue(queue2);
400
- for (const file of queue2) {
401
- try {
402
- while (uploadingCountRef.current >= maxConcurrentUploads && uploadingCountRef.current > 0) {
403
- await new Promise((resolve) => setTimeout(resolve, 300));
404
- }
405
- uploadingCountRef.current++;
406
- const formData = new FormData();
407
- formData.append("file", file);
408
- const res = await fetch("/api/simple-builder/file/upload", {
409
- method: "POST",
410
- body: formData
411
- });
412
- if (res === void 0 || !res.ok) {
413
- onError?.(
414
- new MediaInputError(
415
- "Bestand uploaden misulukt",
416
- `Bestand ${file.name} kon niet worden ge\xFCpload.`
417
- )
418
- );
419
- continue;
420
- }
421
- const { data: url } = await res.json();
422
- if (!url) {
423
- onError?.(
424
- new MediaInputError(
425
- "Bestand uploaden misulukt",
426
- `De URL van bestand ${file.name} kon niet worden opgehaald.`
427
- )
428
- );
429
- continue;
430
- }
431
- setSources((prev) => [...prev, url]);
432
- onFilesChange?.([...sources, url]);
433
- } catch (e2) {
434
- onError?.(
435
- new MediaInputError(
436
- "Bestand uploaden misulukt",
437
- `Bestand ${file.name} kon niet worden ge\xFCpload.`
438
- )
439
- );
440
- } finally {
441
- setQueue((prev) => prev.filter((f) => f !== file));
442
- uploadingCountRef.current--;
443
- }
444
- }
445
- };
446
- const handleSourceDelete = async (src) => {
447
- setSources((prev) => prev.filter((s) => s !== src));
448
- onFilesChange?.(sources.filter((s) => s !== src));
449
- await fetch("/api/uploadthing/delete", {
450
- method: "POST",
451
- body: JSON.stringify({ src })
452
- });
453
- };
454
- return /* @__PURE__ */ React15__namespace.createElement("div", { className: chunkLJSVUW4D_js.cn("flex flex-wrap gap-4", props.className) }, sources.map((src) => /* @__PURE__ */ React15__namespace.createElement(MediaInputItem, { key: src, className: chunkLJSVUW4D_js.cn("group", props.itemClassName) }, /* @__PURE__ */ React15__namespace.createElement(
455
- chunkLJSVUW4D_js.Image,
456
- {
457
- src,
458
- alt: "",
459
- fill: true,
460
- className: "sb-absolute sb-inset-0 sb-object-cover sb-pointer-events-none"
461
- }
462
- ), /* @__PURE__ */ React15__namespace.createElement("div", { className: "sb-absolute sb-right-1 sb-top-1 sb-z-30 sb-flex sb-items-center sb-justify-end sb-gap-3 sb-opacity-0 sb-transition-opacity group-hover:sb-opacity-100" }, /* @__PURE__ */ React15__namespace.createElement(
463
- "button",
464
- {
465
- className: "sb-flex sb-h-8 sb-w-8 sb-items-center sb-justify-center sb-rounded-full sb-border sb-bg-secondary sb-text-secondary-foreground sb-opacity-90 sb-shadow sb-transition-opacity hover:sb-opacity-100",
466
- onClick: () => handleSourceDelete(src)
467
- },
468
- /* @__PURE__ */ React15__namespace.createElement(lucideReact.Trash2Icon, { className: "sb-h-4 sb-w-4" })
469
- )))), queue.map((_, i) => /* @__PURE__ */ React15__namespace.createElement(
470
- MediaInputItem,
471
- {
472
- key: i,
473
- className: chunkLJSVUW4D_js.cn(
474
- "sb-flex sb-h-28 sb-w-28 sb-items-center sb-justify-center",
475
- props.itemClassName
476
- )
477
- },
478
- /* @__PURE__ */ React15__namespace.createElement(lucideReact.Loader2Icon, { className: "sb-h-6 sb-w-6 sb-animate-spin" })
479
- )), multiple || !multiple && !sources.length && !queue.length ? /* @__PURE__ */ React15__namespace.createElement(
480
- "label",
481
- {
482
- htmlFor: id,
483
- className: chunkLJSVUW4D_js.cn(
484
- "sb-flex sb-h-28 sb-w-28 sb-cursor-pointer sb-items-center sb-justify-center sb-rounded-lg sb-border",
485
- props.itemClassName
486
- )
487
- },
488
- /* @__PURE__ */ React15__namespace.createElement(lucideReact.PlusIcon, { className: "sb-h-6 sb-w-6" }),
489
- /* @__PURE__ */ React15__namespace.createElement(
490
- "input",
491
- {
492
- id,
493
- type: "file",
494
- onChange: handleFilesAdd,
495
- multiple,
496
- accept: ".png,.jpg,.jpeg,.webp,.gif,.svg",
497
- className: "sb-hidden"
498
- }
499
- )
500
- ) : null);
501
- };
502
- var MediaInputItem = (props) => {
503
- return /* @__PURE__ */ React15__namespace.createElement(
504
- "div",
505
- {
506
- className: chunkLJSVUW4D_js.cn(
507
- "sb-relative sb-h-28 sb-w-28 sb-overflow-hidden sb-rounded-lg sb-border",
508
- props.className
509
- )
510
- },
511
- props.children
512
- );
513
- };
514
- var MediaInputError = class extends Error {
515
- title;
516
- description;
517
- constructor(message, description) {
518
- super(message);
519
- this.title = message;
520
- this.description = description;
521
- }
522
- };
523
- var Switch = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React15__namespace.createElement(
524
- SwitchPrimitives__namespace.Root,
525
- {
526
- className: chunkLJSVUW4D_js.cn(
527
- "peer sb-inline-flex sb-h-6 sb-w-11 sb-shrink-0 sb-cursor-pointer sb-items-center sb-rounded-full sb-border-2 sb-border-transparent sb-transition-colors focus-visible:sb-outline-none focus-visible:sb-ring-2 focus-visible:sb-ring-ring focus-visible:sb-ring-offset-2 focus-visible:sb-ring-offset-background disabled:sb-cursor-not-allowed disabled:sb-opacity-50 data-[state=checked]:sb-bg-primary data-[state=unchecked]:sb-bg-input",
528
- className
529
- ),
530
- ...props,
531
- ref
532
- },
533
- /* @__PURE__ */ React15__namespace.createElement(
534
- SwitchPrimitives__namespace.Thumb,
535
- {
536
- className: chunkLJSVUW4D_js.cn(
537
- "sb-pointer-events-none sb-block sb-h-5 sb-w-5 sb-rounded-full sb-bg-background sb-shadow-lg sb-ring-0 sb-transition-transform data-[state=checked]:sb-translate-x-5 data-[state=unchecked]:sb-translate-x-0"
538
- )
539
- }
540
- )
541
- ));
542
- Switch.displayName = SwitchPrimitives__namespace.Root.displayName;
543
- var Textarea = React15__namespace.forwardRef(
544
- ({ className, ...props }, ref) => {
545
- return /* @__PURE__ */ React15__namespace.createElement(
546
- "textarea",
547
- {
548
- className: chunkLJSVUW4D_js.cn(
549
- "sb-flex sb-min-h-[60px] sb-font-roboto sb-w-full sb-rounded-md sb-border sb-border-input sb-bg-transparent sb-px-3 sb-py-2 sb-text-sm sb-shadow-sm placeholder:sb-text-muted-foreground focus-visible:sb-outline-none focus-visible:sb-ring-1 focus-visible:sb-ring-ring disabled:sb-cursor-not-allowed disabled:sb-opacity-50",
550
- className
551
- ),
552
- ref,
553
- ...props
554
- }
555
- );
556
- }
557
- );
558
- Textarea.displayName = "Textarea";
559
-
560
- // src/components/container-item-form.tsx
561
- var ContainerItemForm = (props) => {
562
- const { item } = props;
563
- const { patchItem } = chunkI2LWMDYD_js.useBuilder();
564
- const component = chunkLJSVUW4D_js.builder.getComponent(item.component);
565
- if (!component) {
566
- throw new Error(
567
- `[simple-builder]: Component with id ${item.component} not found in container item form component`
568
- );
569
- }
570
- const form = reactHookForm.useForm({
571
- defaultValues: (component.inputs || []).reduce(
572
- (acc, input) => ({
573
- ...acc,
574
- [input.name]: item?.props?.[input.name] ?? input.defaultValue
575
- }),
576
- {}
577
- )
578
- });
579
- const onSubmit = (values) => {
580
- patchItem(item.id, {
581
- props: values
582
- });
583
- };
584
- React15__namespace.useEffect(() => {
585
- const subscription = form.watch(() => form.handleSubmit(onSubmit)());
586
- return () => subscription.unsubscribe();
587
- }, [form.watch, form.handleSubmit]);
588
- return /* @__PURE__ */ React15__namespace.createElement(Form, { ...form }, /* @__PURE__ */ React15__namespace.createElement("form", { onSubmit: form.handleSubmit(onSubmit) }, /* @__PURE__ */ React15__namespace.createElement("div", { className: "sb-space-y-4 sb-p-4" }, (component.inputs || []).map((input) => /* @__PURE__ */ React15__namespace.createElement(
589
- FormField,
590
- {
591
- key: input.name,
592
- control: form.control,
593
- name: input.name,
594
- render: ({ field }) => /* @__PURE__ */ React15__namespace.createElement(RenderInput, { type: input.type, input, field })
595
- }
596
- )))));
597
- };
598
- var RenderInput = (props) => {
599
- const { type, input, field } = props;
600
- switch (type) {
601
- case "string":
602
- return /* @__PURE__ */ React15__namespace.createElement(FormItem, null, /* @__PURE__ */ React15__namespace.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React15__namespace.createElement(FormControl, null, /* @__PURE__ */ React15__namespace.createElement(Input, { ...field })), input.helperText && /* @__PURE__ */ React15__namespace.createElement(FormDescription, null, input.helperText), /* @__PURE__ */ React15__namespace.createElement(FormMessage, null));
603
- case "longText":
604
- return /* @__PURE__ */ React15__namespace.createElement(FormItem, null, /* @__PURE__ */ React15__namespace.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React15__namespace.createElement(FormControl, null, /* @__PURE__ */ React15__namespace.createElement(Textarea, { ...field })), input.helperText && /* @__PURE__ */ React15__namespace.createElement(FormDescription, null, input.helperText), /* @__PURE__ */ React15__namespace.createElement(FormMessage, null));
605
- case "richText":
606
- return /* @__PURE__ */ React15__namespace.createElement(FormItem, null, /* @__PURE__ */ React15__namespace.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React15__namespace.createElement(FormControl, null, /* @__PURE__ */ React15__namespace.createElement(Textarea, { ...field })), input.helperText && /* @__PURE__ */ React15__namespace.createElement(FormDescription, null, input.helperText), /* @__PURE__ */ React15__namespace.createElement(FormMessage, null));
607
- case "number":
608
- return /* @__PURE__ */ React15__namespace.createElement(FormItem, null, /* @__PURE__ */ React15__namespace.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React15__namespace.createElement(FormControl, null, /* @__PURE__ */ React15__namespace.createElement(Input, { type: "number", ...field })), input.helperText && /* @__PURE__ */ React15__namespace.createElement(FormDescription, null, input.helperText), /* @__PURE__ */ React15__namespace.createElement(FormMessage, null));
609
- case "color":
610
- return /* @__PURE__ */ React15__namespace.createElement(FormItem, null, /* @__PURE__ */ React15__namespace.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React15__namespace.createElement(FormControl, null, /* @__PURE__ */ React15__namespace.createElement(ColorPicker, { color: field.value, onColorChange: field.onChange })), input.helperText && /* @__PURE__ */ React15__namespace.createElement(FormDescription, null, input.helperText), /* @__PURE__ */ React15__namespace.createElement(FormMessage, null));
611
- case "date":
612
- return /* @__PURE__ */ React15__namespace.createElement(FormItem, null, /* @__PURE__ */ React15__namespace.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React15__namespace.createElement(FormControl, null, /* @__PURE__ */ React15__namespace.createElement(Popover, null, /* @__PURE__ */ React15__namespace.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React15__namespace.createElement(
613
- chunkI2LWMDYD_js.Button,
614
- {
615
- variant: "outline",
616
- size: "sm",
617
- className: chunkLJSVUW4D_js.cn(
618
- "sb-w-full sb-flex sb-justify-start sb-text-left sb-font-normal",
619
- !field.value && "sb-text-muted-foreground"
620
- )
621
- },
622
- /* @__PURE__ */ React15__namespace.createElement(lucideReact.CalendarIcon, { className: "sb-mr-2 sb-h-4 sb-w-4" }),
623
- field.value ? dateFns.format(field.value, "PPP") : /* @__PURE__ */ React15__namespace.createElement("span", null, "Pick a date")
624
- )), /* @__PURE__ */ React15__namespace.createElement(PopoverContent, { className: "sb-w-auto sb-p-0", align: "start" }, /* @__PURE__ */ React15__namespace.createElement(
625
- Calendar,
626
- {
627
- mode: "single",
628
- selected: field.value,
629
- onSelect: field.onChange,
630
- initialFocus: true
631
- }
632
- )))), input.helperText && /* @__PURE__ */ React15__namespace.createElement(FormDescription, null, input.helperText), /* @__PURE__ */ React15__namespace.createElement(FormMessage, null));
633
- case "boolean":
634
- return /* @__PURE__ */ React15__namespace.createElement(FormItem, { className: "sb-flex sb-flex-row sb-items-center sb-justify-between sb-space-y-0" }, /* @__PURE__ */ React15__namespace.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React15__namespace.createElement(FormControl, null, /* @__PURE__ */ React15__namespace.createElement(Switch, { checked: field.value, onCheckedChange: field.onChange })), input.helperText && /* @__PURE__ */ React15__namespace.createElement(FormDescription, null, input.helperText), /* @__PURE__ */ React15__namespace.createElement(FormMessage, null));
635
- case "file":
636
- return /* @__PURE__ */ React15__namespace.createElement(FormItem, null, /* @__PURE__ */ React15__namespace.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React15__namespace.createElement(FormControl, null, /* @__PURE__ */ React15__namespace.createElement(
637
- MediaInput,
638
- {
639
- className: "sb-grid sb-grid-cols-2 sb-gap-1",
640
- itemClassName: "sb-aspect-video sb-h-auto sb-w-full",
641
- multiple: false,
642
- onFilesChange: (files) => field.onChange(files[0]),
643
- onError: (e) => console.error(
644
- "[media-input]: Title: " + e?.title,
645
- "media-input: Error: " + e?.description
646
- )
647
- }
648
- )), input.helperText && /* @__PURE__ */ React15__namespace.createElement(FormDescription, null, input.helperText), /* @__PURE__ */ React15__namespace.createElement(FormMessage, null));
649
- default:
650
- throw new Error(
651
- `[simple-builder]: Input type "${props.type}" not supported`
652
- );
653
- }
654
- };
655
- var Tabs = TabsPrimitive__namespace.Root;
656
- var tabsListVariants = chunkLJSVUW4D_js.tv({
657
- variants: {
658
- variant: {
659
- contained: "sb-inline-flex sb-h-10 sb-items-center sb-justify-center sb-rounded-md sb-bg-muted sb-p-1 sb-text-muted-foreground",
660
- text: "sb-flex sb-items-center sb-border-b sb-px-4 sb-space-x-6"
661
- }
662
- },
663
- defaultVariants: {
664
- variant: "contained"
665
- }
666
- });
667
- var TabsList = React15__namespace.forwardRef(({ variant, className, ...props }, ref) => /* @__PURE__ */ React15__namespace.createElement(
668
- TabsPrimitive__namespace.List,
669
- {
670
- ref,
671
- className: tabsListVariants({ variant, className }),
672
- ...props
673
- }
674
- ));
675
- TabsList.displayName = TabsPrimitive__namespace.List.displayName;
676
- var tabsTriggerVariants = chunkLJSVUW4D_js.tv({
677
- variants: {
678
- variant: {
679
- contained: "sb-inline-flex sb-items-center sb-justify-center sb-whitespace-nowrap sb-rounded-sm sb-px-3 sb-py-1.5 sb-text-sm sb-font-medium sb-ring-offset-background sb-transition-all focus-visible:sb-outline-none focus-visible:sb-ring-2 focus-visible:sb-ring-ring focus-visible:sb-ring-offset-2 disabled:sb-pointer-events-none disabled:sb-opacity-50 data-[state=active]:sb-bg-background data-[state=active]:sb-text-foreground data-[state=active]:sb-shadow-sm",
680
- text: "sb-inline-flex sb-font-roboto sb-items-center sb-justify-center sb-whitespace-nowrap sb-py-3 sb-text-sm sb-font-medium sb-transition-all focus-visible:sb-outline-none disabled:sb-pointer-events-none disabled:sb-opacity-50 data-[state=active]:sb-border-black sb-border-b-2 sb-border-transparent data-[state=active]:sb-text-foreground sb-text-muted-foreground"
681
- }
682
- },
683
- defaultVariants: {
684
- variant: "contained"
685
- }
686
- });
687
- var TabsTrigger = React15__namespace.forwardRef(({ variant, className, ...props }, ref) => /* @__PURE__ */ React15__namespace.createElement(
688
- TabsPrimitive__namespace.Trigger,
689
- {
690
- ref,
691
- className: tabsTriggerVariants({ variant, className }),
692
- ...props
693
- }
694
- ));
695
- TabsTrigger.displayName = TabsPrimitive__namespace.Trigger.displayName;
696
- var TabsContent = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React15__namespace.createElement(
697
- TabsPrimitive__namespace.Content,
698
- {
699
- ref,
700
- className: chunkLJSVUW4D_js.cn(
701
- "sb-ring-offset-background sb-font-roboto focus-visible:sb-outline-none focus-visible:sb-ring-2 focus-visible:sb-ring-ring focus-visible:sb-ring-offset-2",
702
- className
703
- ),
704
- ...props
705
- }
706
- ));
707
- TabsContent.displayName = TabsPrimitive__namespace.Content.displayName;
708
-
709
- // src/components/ui/background-picker.tsx
710
- var BackgroundPicker = (props) => {
711
- const { background, onBackgroundChange, className } = props;
712
- const solids = props.solids ?? [
713
- "#000000",
714
- "#ffffff",
715
- "#0f172a",
716
- "#F1F5F9",
717
- "#64748B",
718
- "#E6007E",
719
- "#F8FAFC",
720
- "#009DD1",
721
- "#FF0000"
722
- ];
723
- const gradients = props.gradients ?? [
724
- "linear-gradient(to top left,#accbee,#e7f0fd)",
725
- "linear-gradient(to top left,#d5d4d0,#d5d4d0,#eeeeec)"
726
- ];
727
- const images = props.images ?? [
728
- "url(https://images.unsplash.com/photo-1688822863426-8c5f9b257090?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=2532&q=90)",
729
- "url(https://images.unsplash.com/photo-1691225850735-6e4e51834cad?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=2532&q=90)"
730
- ];
731
- const defaultTab = React15__namespace.useMemo(() => {
732
- if (background.includes("url"))
733
- return "image";
734
- if (background.includes("gradient"))
735
- return "gradient";
736
- return "solid";
737
- }, [background]);
738
- return /* @__PURE__ */ React15__namespace.createElement(Popover, null, /* @__PURE__ */ React15__namespace.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React15__namespace.createElement(
739
- chunkI2LWMDYD_js.Button,
740
- {
741
- variant: "outline",
742
- size: "sm",
743
- className: chunkLJSVUW4D_js.cn(
744
- "sb-justify-start sb-text-left sb-font-normal sb-normal-case sb-w-full",
745
- !background && "sb-text-muted-foreground",
746
- className
747
- )
748
- },
749
- /* @__PURE__ */ React15__namespace.createElement("div", { className: "sb-w-full sb-flex sb-items-center sb-gap-2" }, background ? /* @__PURE__ */ React15__namespace.createElement(
750
- "div",
751
- {
752
- className: "sb-h-4 sb-w-4 sb-rounded !sb-bg-center !sb-bg-cover sb-transition-all sb-border",
753
- style: { background }
754
- }
755
- ) : /* @__PURE__ */ React15__namespace.createElement(lucideReact.PaintbrushIcon, { className: "sb-h-4 sb-w-4" }), /* @__PURE__ */ React15__namespace.createElement("div", { className: "sb-truncate sb-flex-1" }, background ? background : "Kies een achtergrond"))
756
- )), /* @__PURE__ */ React15__namespace.createElement(PopoverContent, { className: "sb-w-64 sb-p-0" }, /* @__PURE__ */ React15__namespace.createElement(Tabs, { defaultValue: defaultTab }, /* @__PURE__ */ React15__namespace.createElement(TabsList, { className: "sb-w-full" }, /* @__PURE__ */ React15__namespace.createElement(TabsTrigger, { className: "sb-flex-1", value: "solid" }, "Solid"), /* @__PURE__ */ React15__namespace.createElement(TabsTrigger, { className: "sb-flex-1", value: "gradient" }, "Gradient"), /* @__PURE__ */ React15__namespace.createElement(TabsTrigger, { className: "sb-flex-1", value: "image" }, "Image")), /* @__PURE__ */ React15__namespace.createElement(
757
- TabsContent,
758
- {
759
- value: "solid",
760
- className: "data-[state=active]:sb-flex sb-flex-wrap sb-gap-1 sb-p-4"
761
- },
762
- solids.map((s) => /* @__PURE__ */ React15__namespace.createElement(
763
- "div",
764
- {
765
- key: s,
766
- style: { background: s },
767
- className: "sb-rounded-md sb-h-6 sb-w-6 sb-cursor-pointer active:sb-scale-105 sb-border",
768
- onClick: () => onBackgroundChange(s)
769
- }
770
- ))
771
- ), /* @__PURE__ */ React15__namespace.createElement(
772
- TabsContent,
773
- {
774
- value: "gradient",
775
- className: "data-[state=active]:sb-flex sb-flex-wrap sb-gap-1 sb-p-4"
776
- },
777
- gradients.map((s) => /* @__PURE__ */ React15__namespace.createElement(
778
- "div",
779
- {
780
- key: s,
781
- style: { background: s },
782
- className: "rounded-md h-6 w-6 cursor-pointer active:scale-105 border",
783
- onClick: () => onBackgroundChange(s)
784
- }
785
- ))
786
- ), /* @__PURE__ */ React15__namespace.createElement(TabsContent, { value: "image" }, /* @__PURE__ */ React15__namespace.createElement("div", { className: "sb-p-4 sb-border-b" }, /* @__PURE__ */ React15__namespace.createElement(
787
- MediaInput,
788
- {
789
- className: "sb-grid sb-grid-cols-2 sb-gap-1",
790
- itemClassName: "sb-aspect-video sb-h-auto sb-w-full",
791
- multiple: false,
792
- onFilesChange: (files) => {
793
- if (!files.length)
794
- return;
795
- onBackgroundChange(`url(${files[0]})`);
796
- },
797
- onError: (e) => console.error(
798
- "[media-input]: Title: " + e?.title,
799
- "media-input: Error: " + e?.description
800
- )
801
- }
802
- )), /* @__PURE__ */ React15__namespace.createElement("div", { className: "sb-grid sb-grid-cols-2 sb-gap-1 sb-p-4" }, images.map((s) => /* @__PURE__ */ React15__namespace.createElement(
803
- "div",
804
- {
805
- key: s,
806
- style: { backgroundImage: s },
807
- className: "sb-rounded-md sb-bg-cover sb-bg-center sb-aspect-video sb-w-full sb-cursor-pointer sb-border active:sb-scale-105",
808
- onClick: () => onBackgroundChange(s)
809
- }
810
- )))))));
811
- };
812
- var toggleVariants = chunkLJSVUW4D_js.tv({
813
- base: "sb-inline-flex sb-items-center sb-justify-center sb-rounded-md sb-text-sm sb-font-medium sb-ring-offset-background sb-transition-colors hover:sb-bg-muted hover:sb-text-muted-foreground focus-visible:sb-outline-none focus-visible:sb-ring-1 focus-visible:sb-ring-ring focus-visible:sb-ring-offset-2 disabled:sb-pointer-events-none disabled:sb-opacity-50 data-[state=on]:sb-bg-accent data-[state=on]:sb-text-accent-foreground",
814
- variants: {
815
- variant: {
816
- default: "sb-bg-transparent",
817
- outline: "sb-border sb-border-input sb-bg-transparent hover:sb-bg-accent hover:sb-text-accent-foreground"
818
- },
819
- size: {
820
- default: "sb-h-10 sb-px-3",
821
- sm: "sb-h-9 sb-px-2.5",
822
- lg: "sb-h-11 sb-px-5"
823
- }
824
- },
825
- defaultVariants: {
826
- variant: "default",
827
- size: "default"
828
- }
829
- });
830
- var Toggle = React15__namespace.forwardRef(({ className, variant, size, ...props }, ref) => /* @__PURE__ */ React15__namespace.createElement(
831
- TogglePrimitive__namespace.Root,
832
- {
833
- ref,
834
- className: toggleVariants({ variant, size, className }),
835
- ...props
836
- }
837
- ));
838
- Toggle.displayName = TogglePrimitive__namespace.Root.displayName;
839
-
840
- // src/components/item-design-form.tsx
841
- var spacingSchema = zod.z.discriminatedUnion("indipendent", [
842
- zod.z.object({
843
- indipendent: zod.z.literal(false),
844
- horizontal: zod.z.coerce.number(),
845
- vertical: zod.z.coerce.number()
846
- }),
847
- zod.z.object({
848
- indipendent: zod.z.literal(true),
849
- left: zod.z.coerce.number(),
850
- right: zod.z.coerce.number(),
851
- top: zod.z.coerce.number(),
852
- bottom: zod.z.coerce.number()
853
- })
854
- ]);
855
- var designSchema = zod.z.object({
856
- container: zod.z.boolean(),
857
- desktop: zod.z.object({
858
- padding: spacingSchema.optional(),
859
- margin: spacingSchema.optional()
860
- }).passthrough().optional(),
861
- mobile: zod.z.object({
862
- padding: spacingSchema.optional(),
863
- margin: spacingSchema.optional()
864
- }).passthrough().optional()
865
- }).passthrough();
866
- var ItemDesignForm = (props) => {
867
- const { item } = props;
868
- const component = chunkLJSVUW4D_js.builder.getComponent(item.component);
869
- if (!component) {
870
- throw new Error(
871
- `[simple-builder]: Component "${item.component}" not found`
872
- );
873
- }
874
- const defaults = component.defaultStyles || {};
875
- const { patchItem } = chunkI2LWMDYD_js.useBuilder();
876
- const [device, setDevice] = React15__namespace.useState("desktop");
877
- const getDefaultDesktopValue = (key, initial = "") => {
878
- const value = item.styles?.desktop?.[key];
879
- const def = defaults?.desktop?.[key];
880
- if (value !== void 0) {
881
- return value;
882
- } else if (def !== void 0) {
883
- return def;
884
- } else {
885
- return initial;
886
- }
887
- };
888
- const getDefaultMobileValue = (key, initial = "") => {
889
- const value = item.styles?.mobile?.[key];
890
- const desktopValue = item.styles?.desktop?.[key];
891
- const def = defaults?.mobile?.[key];
892
- const desktopDef = defaults?.desktop?.[key];
893
- if (value !== void 0) {
894
- return value;
895
- } else if (def !== void 0) {
896
- return def;
897
- } else if (desktopValue !== void 0) {
898
- return desktopValue;
899
- } else if (desktopDef !== void 0) {
900
- return desktopDef;
901
- } else {
902
- return initial;
903
- }
904
- };
905
- const getSpacingValue = (str) => {
906
- const parsed = chunkLJSVUW4D_js.spacing.parse(str);
907
- return {
908
- indipendent: chunkLJSVUW4D_js.spacing.isIndipendent(str),
909
- horizontal: parsed.left,
910
- vertical: parsed.top,
911
- ...parsed
912
- };
913
- };
914
- const form = reactHookForm.useForm({
915
- resolver: zod$1.zodResolver(designSchema),
916
- defaultValues: {
917
- container: item.styles?.container || defaults.container || true,
918
- desktop: {
919
- background: getDefaultDesktopValue("background"),
920
- color: getDefaultDesktopValue("color"),
921
- padding: getSpacingValue(getDefaultDesktopValue("padding")),
922
- margin: getSpacingValue(getDefaultDesktopValue("margin"))
923
- },
924
- mobile: {
925
- background: getDefaultMobileValue("background"),
926
- color: getDefaultMobileValue("color"),
927
- padding: getSpacingValue(getDefaultMobileValue("padding")),
928
- margin: getSpacingValue(getDefaultMobileValue("margin"))
929
- }
930
- }
931
- });
932
- const onSubmit = (values) => {
933
- const { container } = values;
934
- const getPatchedDeviceValues = (device2 = "desktop") => {
935
- const initital = Object.keys(item.styles?.[device2] || {}).filter((key) => !Object.keys(values[device2]).includes(key)).reduce(
936
- (acc, key) => ({ ...acc, [key]: item.styles?.[device2][key] }),
937
- {}
938
- );
939
- return Object.entries(values[device2]).reduce((acc, [key, value]) => {
940
- let res = value;
941
- if (key === "padding" || key === "margin") {
942
- const data = value;
943
- const params = data.indipendent ? data : {
944
- top: data.vertical,
945
- bottom: data.vertical,
946
- left: data.horizontal,
947
- right: data.horizontal
948
- };
949
- res = chunkLJSVUW4D_js.spacing.stringify(params);
950
- }
951
- return {
952
- ...acc,
953
- ...res ? { [key]: res } : {}
954
- };
955
- }, initital);
956
- };
957
- const patchedDesktopValues = getPatchedDeviceValues();
958
- const patchedMobileValues = getPatchedDeviceValues("mobile");
959
- patchItem(item.id, {
960
- styles: {
961
- ...container === false && { container },
962
- ...Object.keys(patchedDesktopValues).length && {
963
- desktop: patchedDesktopValues
964
- },
965
- ...Object.keys(patchedMobileValues).length && {
966
- mobile: patchedMobileValues
967
- }
968
- }
969
- });
970
- };
971
- React15__namespace.useEffect(() => {
972
- const subscription = form.watch(() => form.handleSubmit(onSubmit)());
973
- return () => subscription.unsubscribe();
974
- }, [form.watch, form.handleSubmit]);
975
- const [indipendentPadding, indipendentMargin] = form.watch([
976
- `${device}.padding.indipendent`,
977
- `${device}.margin.indipendent`
978
- ]);
979
- return /* @__PURE__ */ React15__namespace.createElement(Form, { ...form }, /* @__PURE__ */ React15__namespace.createElement("form", { onSubmit: form.handleSubmit(onSubmit) }, /* @__PURE__ */ React15__namespace.createElement("div", { className: "sb-space-y-4 sb-p-4" }, /* @__PURE__ */ React15__namespace.createElement(Tabs, { defaultValue: device, onValueChange: setDevice }, /* @__PURE__ */ React15__namespace.createElement(TabsList, { className: "sb-h-9 sb-grid sb-w-full sb-grid-cols-2" }, /* @__PURE__ */ React15__namespace.createElement(TabsTrigger, { value: "desktop", className: "sb-text-xs" }, /* @__PURE__ */ React15__namespace.createElement(lucideReact.MonitorIcon, { className: "sb-h-4 sb-w-4 sb-mr-2" }), /* @__PURE__ */ React15__namespace.createElement("span", null, "Desktop")), /* @__PURE__ */ React15__namespace.createElement(TabsTrigger, { value: "mobile", className: "sb-text-xs" }, /* @__PURE__ */ React15__namespace.createElement(lucideReact.SmartphoneIcon, { className: "sb-h-4 sb-w-4 sb-mr-2" }), /* @__PURE__ */ React15__namespace.createElement("span", null, "Mobiel")))), /* @__PURE__ */ React15__namespace.createElement("div", { className: "sb-space-y-4" }, /* @__PURE__ */ React15__namespace.createElement(
980
- FormField,
981
- {
982
- control: form.control,
983
- key: `${device}.background`,
984
- name: `${device}.background`,
985
- render: ({ field }) => /* @__PURE__ */ React15__namespace.createElement(FormItem, null, /* @__PURE__ */ React15__namespace.createElement(FormLabel, null, "Achtergrond"), /* @__PURE__ */ React15__namespace.createElement(FormControl, null, /* @__PURE__ */ React15__namespace.createElement(
986
- BackgroundPicker,
987
- {
988
- background: field.value,
989
- onBackgroundChange: field.onChange
990
- }
991
- )), /* @__PURE__ */ React15__namespace.createElement(FormMessage, null))
992
- }
993
- ), /* @__PURE__ */ React15__namespace.createElement(
994
- FormField,
995
- {
996
- control: form.control,
997
- key: `${device}.color`,
998
- name: `${device}.color`,
999
- render: ({ field }) => /* @__PURE__ */ React15__namespace.createElement(FormItem, null, /* @__PURE__ */ React15__namespace.createElement(FormLabel, null, "Inhoud kleur"), /* @__PURE__ */ React15__namespace.createElement(FormControl, null, /* @__PURE__ */ React15__namespace.createElement(
1000
- ColorPicker,
1001
- {
1002
- color: field.value,
1003
- onColorChange: field.onChange
1004
- }
1005
- )), /* @__PURE__ */ React15__namespace.createElement(FormMessage, null))
1006
- }
1007
- ), /* @__PURE__ */ React15__namespace.createElement("hr", null), /* @__PURE__ */ React15__namespace.createElement(
1008
- FormField,
1009
- {
1010
- control: form.control,
1011
- name: "container",
1012
- render: ({ field }) => /* @__PURE__ */ React15__namespace.createElement(FormItem, { className: "sb-flex sb-flex-row sb-items-center sb-justify-between sb-space-y-0" }, /* @__PURE__ */ React15__namespace.createElement(FormLabel, null, "Volledige breedte"), /* @__PURE__ */ React15__namespace.createElement(FormControl, null, /* @__PURE__ */ React15__namespace.createElement(
1013
- Switch,
1014
- {
1015
- checked: !field.value,
1016
- onCheckedChange: (v) => field.onChange(!v)
1017
- }
1018
- )), /* @__PURE__ */ React15__namespace.createElement(FormMessage, null))
1019
- }
1020
- ), /* @__PURE__ */ React15__namespace.createElement("hr", null), /* @__PURE__ */ React15__namespace.createElement("div", { className: "sb-space-y-2" }, /* @__PURE__ */ React15__namespace.createElement(FormLabel, null, "Padding"), /* @__PURE__ */ React15__namespace.createElement("div", { className: "sb-grid sb-grid-cols-[1fr,auto] sb-gap-3" }, /* @__PURE__ */ React15__namespace.createElement("div", { className: "sb-grid sb-grid-cols-2 sb-items-center sb-gap-3" }, !indipendentPadding ? /* @__PURE__ */ React15__namespace.createElement(React15__namespace.Fragment, null, /* @__PURE__ */ React15__namespace.createElement(
1021
- FormField,
1022
- {
1023
- control: form.control,
1024
- key: `${device}.padding.horizontal`,
1025
- name: `${device}.padding.horizontal`,
1026
- render: ({ field }) => /* @__PURE__ */ React15__namespace.createElement(FormItem, null, /* @__PURE__ */ React15__namespace.createElement(FormControl, null, /* @__PURE__ */ React15__namespace.createElement(
1027
- AdvancedInput,
1028
- {
1029
- ...field,
1030
- prepend: /* @__PURE__ */ React15__namespace.createElement(lucideReact.AlignHorizontalSpaceAroundIcon, { className: "sb-h-4 sb-w-4" }),
1031
- append: /* @__PURE__ */ React15__namespace.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1032
- }
1033
- )))
1034
- }
1035
- ), /* @__PURE__ */ React15__namespace.createElement(
1036
- FormField,
1037
- {
1038
- control: form.control,
1039
- key: `${device}.padding.vertical`,
1040
- name: `${device}.padding.vertical`,
1041
- render: ({ field }) => /* @__PURE__ */ React15__namespace.createElement(FormItem, null, /* @__PURE__ */ React15__namespace.createElement(FormControl, null, /* @__PURE__ */ React15__namespace.createElement(
1042
- AdvancedInput,
1043
- {
1044
- ...field,
1045
- prepend: /* @__PURE__ */ React15__namespace.createElement(lucideReact.AlignHorizontalSpaceAroundIcon, { className: "sb-h-4 sb-w-4 sb-rotate-90" }),
1046
- append: /* @__PURE__ */ React15__namespace.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1047
- }
1048
- )))
1049
- }
1050
- )) : /* @__PURE__ */ React15__namespace.createElement(React15__namespace.Fragment, null, /* @__PURE__ */ React15__namespace.createElement(
1051
- FormField,
1052
- {
1053
- control: form.control,
1054
- key: `${device}.padding.left`,
1055
- name: `${device}.padding.left`,
1056
- render: ({ field }) => /* @__PURE__ */ React15__namespace.createElement(FormItem, null, /* @__PURE__ */ React15__namespace.createElement(FormControl, null, /* @__PURE__ */ React15__namespace.createElement(
1057
- AdvancedInput,
1058
- {
1059
- ...field,
1060
- prepend: /* @__PURE__ */ React15__namespace.createElement(lucideReact.AlignHorizontalJustifyStartIcon, { className: "sb-h-4 sb-w-4" }),
1061
- append: /* @__PURE__ */ React15__namespace.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1062
- }
1063
- )))
1064
- }
1065
- ), /* @__PURE__ */ React15__namespace.createElement(
1066
- FormField,
1067
- {
1068
- control: form.control,
1069
- key: `${device}.padding.top`,
1070
- name: `${device}.padding.top`,
1071
- render: ({ field }) => /* @__PURE__ */ React15__namespace.createElement(FormItem, null, /* @__PURE__ */ React15__namespace.createElement(FormControl, null, /* @__PURE__ */ React15__namespace.createElement(
1072
- AdvancedInput,
1073
- {
1074
- ...field,
1075
- prepend: /* @__PURE__ */ React15__namespace.createElement(lucideReact.AlignHorizontalJustifyStartIcon, { className: "sb-h-4 sb-w-4 sb-rotate-90" }),
1076
- append: /* @__PURE__ */ React15__namespace.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1077
- }
1078
- )))
1079
- }
1080
- ), /* @__PURE__ */ React15__namespace.createElement(
1081
- FormField,
1082
- {
1083
- control: form.control,
1084
- key: `${device}.padding.right`,
1085
- name: `${device}.padding.right`,
1086
- render: ({ field }) => /* @__PURE__ */ React15__namespace.createElement(FormItem, null, /* @__PURE__ */ React15__namespace.createElement(FormControl, null, /* @__PURE__ */ React15__namespace.createElement(
1087
- AdvancedInput,
1088
- {
1089
- ...field,
1090
- prepend: /* @__PURE__ */ React15__namespace.createElement(lucideReact.AlignHorizontalJustifyStartIcon, { className: "sb-h-4 sb-w-4 sb-rotate-180" }),
1091
- append: /* @__PURE__ */ React15__namespace.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1092
- }
1093
- )))
1094
- }
1095
- ), /* @__PURE__ */ React15__namespace.createElement(
1096
- FormField,
1097
- {
1098
- control: form.control,
1099
- key: `${device}.padding.bottom`,
1100
- name: `${device}.padding.bottom`,
1101
- render: ({ field }) => /* @__PURE__ */ React15__namespace.createElement(FormItem, null, /* @__PURE__ */ React15__namespace.createElement(FormControl, null, /* @__PURE__ */ React15__namespace.createElement(
1102
- AdvancedInput,
1103
- {
1104
- ...field,
1105
- prepend: /* @__PURE__ */ React15__namespace.createElement(lucideReact.AlignHorizontalJustifyStartIcon, { className: "sb-h-4 sb-w-4 sb--rotate-90" }),
1106
- append: /* @__PURE__ */ React15__namespace.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1107
- }
1108
- )))
1109
- }
1110
- ))), /* @__PURE__ */ React15__namespace.createElement("div", { className: "sb-shrink-0" }, /* @__PURE__ */ React15__namespace.createElement(
1111
- FormField,
1112
- {
1113
- control: form.control,
1114
- key: `${device}.padding.indipendent`,
1115
- name: `${device}.padding.indipendent`,
1116
- render: ({ field }) => /* @__PURE__ */ React15__namespace.createElement(FormControl, null, /* @__PURE__ */ React15__namespace.createElement(
1117
- Toggle,
1118
- {
1119
- className: "sb-shrink-0 sb-flex sb-w-8 sb-h-8 sb-p-0",
1120
- variant: "outline",
1121
- size: "sm",
1122
- pressed: field.value,
1123
- onPressedChange: field.onChange
1124
- },
1125
- /* @__PURE__ */ React15__namespace.createElement(lucideReact.ScanIcon, { className: "sb-h-4 sb-w-4" })
1126
- ))
1127
- }
1128
- ))), /* @__PURE__ */ React15__namespace.createElement(FormMessage, null)), /* @__PURE__ */ React15__namespace.createElement("div", { className: "sb-space-y-2" }, /* @__PURE__ */ React15__namespace.createElement(FormLabel, null, "Margin"), /* @__PURE__ */ React15__namespace.createElement("div", { className: "sb-grid sb-grid-cols-[1fr,auto] sb-gap-3" }, /* @__PURE__ */ React15__namespace.createElement("div", { className: "sb-grid sb-grid-cols-2 sb-items-center sb-gap-3" }, !indipendentMargin ? /* @__PURE__ */ React15__namespace.createElement(React15__namespace.Fragment, null, /* @__PURE__ */ React15__namespace.createElement(
1129
- FormField,
1130
- {
1131
- control: form.control,
1132
- key: `${device}.margin.horizontal`,
1133
- name: `${device}.margin.horizontal`,
1134
- render: ({ field }) => /* @__PURE__ */ React15__namespace.createElement(FormItem, null, /* @__PURE__ */ React15__namespace.createElement(FormControl, null, /* @__PURE__ */ React15__namespace.createElement(
1135
- AdvancedInput,
1136
- {
1137
- ...field,
1138
- prepend: /* @__PURE__ */ React15__namespace.createElement(lucideReact.AlignHorizontalSpaceAroundIcon, { className: "sb-h-4 sb-w-4" }),
1139
- append: /* @__PURE__ */ React15__namespace.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1140
- }
1141
- )))
1142
- }
1143
- ), /* @__PURE__ */ React15__namespace.createElement(
1144
- FormField,
1145
- {
1146
- control: form.control,
1147
- key: `${device}.margin.vertical`,
1148
- name: `${device}.margin.vertical`,
1149
- render: ({ field }) => /* @__PURE__ */ React15__namespace.createElement(FormItem, null, /* @__PURE__ */ React15__namespace.createElement(FormControl, null, /* @__PURE__ */ React15__namespace.createElement(
1150
- AdvancedInput,
1151
- {
1152
- ...field,
1153
- prepend: /* @__PURE__ */ React15__namespace.createElement(lucideReact.AlignHorizontalSpaceAroundIcon, { className: "sb-h-4 sb-w-4 sb-rotate-90" }),
1154
- append: /* @__PURE__ */ React15__namespace.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1155
- }
1156
- )))
1157
- }
1158
- )) : /* @__PURE__ */ React15__namespace.createElement(React15__namespace.Fragment, null, /* @__PURE__ */ React15__namespace.createElement(
1159
- FormField,
1160
- {
1161
- control: form.control,
1162
- key: `${device}.margin.left`,
1163
- name: `${device}.margin.left`,
1164
- render: ({ field }) => /* @__PURE__ */ React15__namespace.createElement(FormItem, null, /* @__PURE__ */ React15__namespace.createElement(FormControl, null, /* @__PURE__ */ React15__namespace.createElement(
1165
- AdvancedInput,
1166
- {
1167
- ...field,
1168
- prepend: /* @__PURE__ */ React15__namespace.createElement(lucideReact.AlignHorizontalJustifyStartIcon, { className: "sb-h-4 sb-w-4" }),
1169
- append: /* @__PURE__ */ React15__namespace.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1170
- }
1171
- )))
1172
- }
1173
- ), /* @__PURE__ */ React15__namespace.createElement(
1174
- FormField,
1175
- {
1176
- control: form.control,
1177
- key: `${device}.margin.top`,
1178
- name: `${device}.margin.top`,
1179
- render: ({ field }) => /* @__PURE__ */ React15__namespace.createElement(FormItem, null, /* @__PURE__ */ React15__namespace.createElement(FormControl, null, /* @__PURE__ */ React15__namespace.createElement(
1180
- AdvancedInput,
1181
- {
1182
- ...field,
1183
- prepend: /* @__PURE__ */ React15__namespace.createElement(lucideReact.AlignHorizontalJustifyStartIcon, { className: "sb-h-4 sb-w-4 sb-rotate-90" }),
1184
- append: /* @__PURE__ */ React15__namespace.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1185
- }
1186
- )))
1187
- }
1188
- ), /* @__PURE__ */ React15__namespace.createElement(
1189
- FormField,
1190
- {
1191
- control: form.control,
1192
- key: `${device}.margin.right`,
1193
- name: `${device}.margin.right`,
1194
- render: ({ field }) => /* @__PURE__ */ React15__namespace.createElement(FormItem, null, /* @__PURE__ */ React15__namespace.createElement(FormControl, null, /* @__PURE__ */ React15__namespace.createElement(
1195
- AdvancedInput,
1196
- {
1197
- ...field,
1198
- prepend: /* @__PURE__ */ React15__namespace.createElement(lucideReact.AlignHorizontalJustifyStartIcon, { className: "sb-h-4 sb-w-4 sb-rotate-180" }),
1199
- append: /* @__PURE__ */ React15__namespace.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1200
- }
1201
- )))
1202
- }
1203
- ), /* @__PURE__ */ React15__namespace.createElement(
1204
- FormField,
1205
- {
1206
- control: form.control,
1207
- key: `${device}.margin.bottom`,
1208
- name: `${device}.margin.bottom`,
1209
- render: ({ field }) => /* @__PURE__ */ React15__namespace.createElement(FormItem, null, /* @__PURE__ */ React15__namespace.createElement(FormControl, null, /* @__PURE__ */ React15__namespace.createElement(
1210
- AdvancedInput,
1211
- {
1212
- ...field,
1213
- prepend: /* @__PURE__ */ React15__namespace.createElement(lucideReact.AlignHorizontalJustifyStartIcon, { className: "sb-h-4 sb-w-4 sb--rotate-90" }),
1214
- append: /* @__PURE__ */ React15__namespace.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1215
- }
1216
- )))
1217
- }
1218
- ))), /* @__PURE__ */ React15__namespace.createElement("div", { className: "sb-shrink-0" }, /* @__PURE__ */ React15__namespace.createElement(
1219
- FormField,
1220
- {
1221
- control: form.control,
1222
- key: `${device}.margin.indipendent`,
1223
- name: `${device}.margin.indipendent`,
1224
- render: ({ field }) => /* @__PURE__ */ React15__namespace.createElement(FormControl, null, /* @__PURE__ */ React15__namespace.createElement(
1225
- Toggle,
1226
- {
1227
- className: "sb-shrink-0 sb-flex sb-w-8 sb-h-8 sb-p-0",
1228
- variant: "outline",
1229
- size: "sm",
1230
- pressed: field.value,
1231
- onPressedChange: field.onChange
1232
- },
1233
- /* @__PURE__ */ React15__namespace.createElement(lucideReact.ScanIcon, { className: "sb-h-4 sb-w-4" })
1234
- ))
1235
- }
1236
- ))), /* @__PURE__ */ React15__namespace.createElement(FormMessage, null))))));
1237
- };
1238
-
1239
- // src/components/container-item-toolbar.tsx
1240
- var ContainerItemToolbar = (props) => {
1241
- const { contentId, canBringUp = false, canBringDown = false } = props;
1242
- const { bringUp, bringDown } = chunkI2LWMDYD_js.useBuilder();
1243
- return /* @__PURE__ */ React15__namespace.createElement("div", { className: "sb-absolute sb-z-20 sb-top-1 sb-right-1 sb-rounded-md sb-shadow sb-flex sb-flex-col sb-gap-1 sb-p-1 sb-bg-card sb-text-card-foreground sb-item-toolbar sb-opacity-0 sb-transition-opacity" }, /* @__PURE__ */ React15__namespace.createElement("div", { className: "sb-h-10 sb-p-1 sb-border sb-border-input sb-bg-background sb-rounded-md sb-text-sm sb-font-medium sb-flex sb-gap-1 sb-items-center sb-justify-start" }, /* @__PURE__ */ React15__namespace.createElement(EditButton, { id: contentId }), /* @__PURE__ */ React15__namespace.createElement(
1244
- chunkI2LWMDYD_js.Button,
1245
- {
1246
- variant: "ghost",
1247
- className: "sb-w-8 sb-h-8 sb-p-0",
1248
- onClick: () => bringUp(contentId),
1249
- disabled: !canBringUp
1250
- },
1251
- /* @__PURE__ */ React15__namespace.createElement(lucideReact.ArrowUp, { className: "sb-h-5 sb-w-5" })
1252
- ), /* @__PURE__ */ React15__namespace.createElement(
1253
- chunkI2LWMDYD_js.Button,
1254
- {
1255
- variant: "ghost",
1256
- className: "sb-w-8 sb-h-8 sb-p-0",
1257
- onClick: () => bringDown(contentId),
1258
- disabled: !canBringDown
1259
- },
1260
- /* @__PURE__ */ React15__namespace.createElement(lucideReact.ArrowDown, { className: "sb-h-5 sb-w-5" })
1261
- ), /* @__PURE__ */ React15__namespace.createElement(DeleteButton, { contentId })));
1262
- };
1263
- var EditButton = ({ id }) => {
1264
- return /* @__PURE__ */ React15__namespace.createElement(Popover, null, /* @__PURE__ */ React15__namespace.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React15__namespace.createElement(chunkI2LWMDYD_js.Button, { variant: "ghost", className: "sb-w-8 sb-h-8 sb-p-0" }, /* @__PURE__ */ React15__namespace.createElement(lucideReact.Edit2Icon, { className: "sb-h-5 sb-w-5" }))), /* @__PURE__ */ React15__namespace.createElement(
1265
- PopoverContent,
1266
- {
1267
- side: "left",
1268
- align: "start",
1269
- sideOffset: 16,
1270
- alignOffset: -8,
1271
- className: "sb-p-0",
1272
- collisionPadding: 16
1273
- },
1274
- /* @__PURE__ */ React15__namespace.createElement(EditPopoverInner, { id })
1275
- ));
1276
- };
1277
- var EditPopoverInner = (props) => {
1278
- const { id } = props;
1279
- const { getItem } = chunkI2LWMDYD_js.useBuilder();
1280
- const item = getItem(id);
1281
- if (!item) {
1282
- throw new Error(
1283
- `[simple-builder]: Item with id ${id} not found in container item form component`
1284
- );
1285
- }
1286
- return /* @__PURE__ */ React15__namespace.createElement(Tabs, null, /* @__PURE__ */ React15__namespace.createElement(TabsList, { variant: "text", defaultValue: "content" }, /* @__PURE__ */ React15__namespace.createElement(TabsTrigger, { variant: "text", value: "content" }, "Inhoud"), /* @__PURE__ */ React15__namespace.createElement(TabsTrigger, { variant: "text", value: "design" }, "Design")), /* @__PURE__ */ React15__namespace.createElement(TabsContent, { value: "content" }, /* @__PURE__ */ React15__namespace.createElement(ContainerItemForm, { item })), /* @__PURE__ */ React15__namespace.createElement(TabsContent, { value: "design" }, /* @__PURE__ */ React15__namespace.createElement(ItemDesignForm, { item })));
1287
- };
1288
- var DeleteButton = ({ contentId }) => {
1289
- const { deleteContent } = chunkI2LWMDYD_js.useBuilder();
1290
- return /* @__PURE__ */ React15__namespace.createElement(AlertDialog, null, /* @__PURE__ */ React15__namespace.createElement(AlertDialogTrigger, { asChild: true }, /* @__PURE__ */ React15__namespace.createElement(
1291
- chunkI2LWMDYD_js.Button,
1292
- {
1293
- variant: "ghost",
1294
- className: "sb-w-8 sb-h-8 sb-p-0 sb-text-destructive"
1295
- },
1296
- /* @__PURE__ */ React15__namespace.createElement(lucideReact.Trash2Icon, { className: "sb-h-5 sb-w-5" })
1297
- )), /* @__PURE__ */ React15__namespace.createElement(AlertDialogContent, null, /* @__PURE__ */ React15__namespace.createElement(AlertDialogDescription, null, "Weet je zeker dat je dit blok wilt verwijderen?"), /* @__PURE__ */ React15__namespace.createElement(AlertDialogFooter, null, /* @__PURE__ */ React15__namespace.createElement(AlertDialogCancel, null, "Annuleren"), /* @__PURE__ */ React15__namespace.createElement(
1298
- AlertDialogAction,
1299
- {
1300
- className: chunkI2LWMDYD_js.buttonVariants({ variant: "destructive" }),
1301
- onClick: () => deleteContent(contentId)
1302
- },
1303
- "Verwijderen"
1304
- ))));
1305
- };
1306
-
1307
- // src/components/build-container-client.tsx
1308
- var BuildContainerInner = (props) => {
1309
- const { id, name, content, multiple = false } = props;
1310
- const items = Array.isArray(content) ? content : content?.[name] || [];
1311
- if (!multiple && items.length > 1) {
1312
- console.error(
1313
- "[simple-builder]: Multiple content blocks detected when using property multiple false."
1314
- );
1315
- }
1316
- return /* @__PURE__ */ React15__namespace.createElement("div", null, items.length <= 0 ? /* @__PURE__ */ React15__namespace.createElement(AddContentPlaceholder, { parent: id, container: name, index: 0 }) : multiple && /* @__PURE__ */ React15__namespace.createElement(AddContentDividerButton, { parent: id, container: name, index: 0 }), items.map((item, i) => /* @__PURE__ */ React15__namespace.createElement(React15__namespace.Fragment, { key: item.id }, /* @__PURE__ */ React15__namespace.createElement("div", { className: "sb-relative sb-container-item" }, /* @__PURE__ */ React15__namespace.createElement(chunkLJSVUW4D_js.DesignWrapper, { styles: item.styles }, chunkLJSVUW4D_js.builder.bindComponent(item, true)), /* @__PURE__ */ React15__namespace.createElement(
1317
- ContainerItemToolbar,
1318
- {
1319
- contentId: item.id,
1320
- canBringUp: i > 0,
1321
- canBringDown: i < items.length - 1
1322
- }
1323
- )), multiple && /* @__PURE__ */ React15__namespace.createElement(
1324
- AddContentDividerButton,
1325
- {
1326
- parent: id,
1327
- container: name,
1328
- index: i + 1
1329
- }
1330
- ))));
1331
- };
1332
- var build_container_client_default = BuildContainerInner;
1333
- var AddContentButton = (props) => {
1334
- const components = chunkLJSVUW4D_js.builder.getComponents();
1335
- const { addContent } = chunkI2LWMDYD_js.useBuilder();
1336
- return /* @__PURE__ */ React15__namespace.createElement(Popover, null, /* @__PURE__ */ React15__namespace.createElement(PopoverTrigger, { asChild: true }, props.children), /* @__PURE__ */ React15__namespace.createElement(PopoverContent, { className: "sb-p-1" }, /* @__PURE__ */ React15__namespace.createElement("div", { className: "sb-grid sb-grid-cols-2 sb-gap-2" }, components.map((component) => {
1337
- const Icon = component.icon ?? lucideReact.ImageIcon;
1338
- return /* @__PURE__ */ React15__namespace.createElement(PopoverClose, { key: component.name, asChild: true }, /* @__PURE__ */ React15__namespace.createElement(
1339
- chunkI2LWMDYD_js.Button,
1340
- {
1341
- variant: "ghost",
1342
- className: "sb-justify-start",
1343
- onClick: () => {
1344
- addContent(
1345
- component.name,
1346
- props.container,
1347
- props.parent,
1348
- props.index
1349
- );
1350
- }
1351
- },
1352
- /* @__PURE__ */ React15__namespace.createElement(Icon, { className: "sb-mr-2 sb-h-4 sb-w-4 sb-shrink-0" }),
1353
- component.friendlyName ?? component.name
1354
- ));
1355
- }))));
1356
- };
1357
- var AddContentPlaceholder = (props) => {
1358
- return /* @__PURE__ */ React15__namespace.createElement(AddContentButton, { ...props }, /* @__PURE__ */ React15__namespace.createElement("div", { className: "sb-flex sb-justify-center sb-bg-primary/50 p-4" }, /* @__PURE__ */ React15__namespace.createElement(chunkI2LWMDYD_js.Button, { size: "sm" }, /* @__PURE__ */ React15__namespace.createElement(lucideReact.PlusIcon, { className: "sb-mr-2 sb-h-4 sb-w-4" }), "Blok Toevoegen")));
1359
- };
1360
- var AddContentDividerButton = (props) => {
1361
- return /* @__PURE__ */ React15__namespace.createElement(AddContentButton, { ...props }, /* @__PURE__ */ React15__namespace.createElement("div", { className: "sb-w-full sb-h-1 sb--my-[2px] sb-bg-primary sb-relative sb-z-20 sb-opacity-0 add-content-divider-button sb-transition-opacity" }, /* @__PURE__ */ React15__namespace.createElement(
1362
- chunkI2LWMDYD_js.Button,
1363
- {
1364
- size: "sm",
1365
- className: "sb-absolute sb-left-1/2 sb-top-1/2 sb--translate-y-1/2 sb--translate-x-1/2 sb-shadow"
1366
- },
1367
- /* @__PURE__ */ React15__namespace.createElement(lucideReact.PlusIcon, { className: "sb-mr-2 sb-h-4 sb-w-4" }),
1368
- "Blok Toevoegen"
1369
- )));
1370
- };
1371
-
1372
- module.exports = build_container_client_default;