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