@simple-builder/react 1.0.21 → 1.2.0

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