@simple-builder/react 1.0.1 → 1.0.3

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