@simple-builder/react 1.2.2 → 1.2.4

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,2250 @@
1
+ 'use client';
2
+ import './chunk-7J7CMYXS.mjs';
3
+ import { buttonVariants, Button, useBuilder } from './chunk-G6MYXYJU.mjs';
4
+ import { cn, tv, DesignWrapper, builder, Image } from './chunk-NJ6FM7SJ.mjs';
5
+ import * as React25 from 'react';
6
+ import { useCallback } from 'react';
7
+ import { ChevronRight, Check, Circle, X, ChevronDown, ChevronUp, PlusIcon, ArrowUp, ArrowDown, Edit2Icon, Trash2Icon, ImageIcon, XIcon, PlusCircleIcon, CalendarIcon, MonitorIcon, SmartphoneIcon, ChevronLeftIcon, ChevronRightIcon, PaintbrushIcon, Loader2Icon, AlignHorizontalSpaceAroundIcon, AlignHorizontalJustifyStartIcon, ScanIcon } from 'lucide-react';
8
+ import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
9
+ import * as PopoverPrimitive from '@radix-ui/react-popover';
10
+ import { mergeAttributes, getMarkRange, EditorContent, useEditor } from '@tiptap/react';
11
+ import { Color } from '@tiptap/extension-color';
12
+ import { TextStyle } from '@tiptap/extension-text-style';
13
+ import { Underline } from '@tiptap/extension-underline';
14
+ import { StarterKit } from '@tiptap/starter-kit';
15
+ import TiptapLink from '@tiptap/extension-link';
16
+ import { Plugin, TextSelection } from '@tiptap/pm/state';
17
+ import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
18
+ import * as SeparatorPrimitive from '@radix-ui/react-separator';
19
+ import * as TogglePrimitive from '@radix-ui/react-toggle';
20
+ import { cva } from 'class-variance-authority';
21
+ import { LuChevronDown, LuCheck, LuHeading, LuLink2, LuEllipsis, LuBold, LuItalic, LuUnderline, LuStrikethrough, LuCode, LuRemoveFormatting, LuQuote, LuMinus, LuListOrdered, LuList } from 'react-icons/lu';
22
+ import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';
23
+ import * as DialogPrimitive from '@radix-ui/react-dialog';
24
+ import { Slot } from '@radix-ui/react-slot';
25
+ import { useFormContext, useForm, useFieldArray, FormProvider, Controller } from 'react-hook-form';
26
+ import * as LabelPrimitive from '@radix-ui/react-label';
27
+ import * as SwitchPrimitives from '@radix-ui/react-switch';
28
+ import { zodResolver } from '@hookform/resolvers/zod';
29
+ import { z } from 'zod';
30
+ import { format } from 'date-fns';
31
+ import { DayPicker } from 'react-day-picker';
32
+ import * as SelectPrimitive from '@radix-ui/react-select';
33
+ import * as TabsPrimitive from '@radix-ui/react-tabs';
34
+ import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
35
+
36
+ var AlertDialog = AlertDialogPrimitive.Root;
37
+ var AlertDialogTrigger = AlertDialogPrimitive.Trigger;
38
+ var AlertDialogPortal = AlertDialogPrimitive.Portal;
39
+ var AlertDialogOverlay = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
40
+ AlertDialogPrimitive.Overlay,
41
+ {
42
+ className: cn(
43
+ "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",
44
+ className
45
+ ),
46
+ ...props,
47
+ ref
48
+ }
49
+ ));
50
+ AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
51
+ var AlertDialogContent = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(AlertDialogPortal, null, /* @__PURE__ */ React25.createElement(AlertDialogOverlay, null), /* @__PURE__ */ React25.createElement(
52
+ AlertDialogPrimitive.Content,
53
+ {
54
+ ref,
55
+ className: cn(
56
+ "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",
57
+ className
58
+ ),
59
+ ...props
60
+ }
61
+ )));
62
+ AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
63
+ var AlertDialogFooter = ({
64
+ className,
65
+ ...props
66
+ }) => /* @__PURE__ */ React25.createElement(
67
+ "div",
68
+ {
69
+ className: cn(
70
+ "sb-flex sb-flex-col-reverse sm:sb-flex-row sm:sb-justify-end sm:sb-space-x-2",
71
+ className
72
+ ),
73
+ ...props
74
+ }
75
+ );
76
+ AlertDialogFooter.displayName = "AlertDialogFooter";
77
+ var AlertDialogTitle = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
78
+ AlertDialogPrimitive.Title,
79
+ {
80
+ ref,
81
+ className: cn("sb-text-lg sb-font-semibold", className),
82
+ ...props
83
+ }
84
+ ));
85
+ AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
86
+ var AlertDialogDescription = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
87
+ AlertDialogPrimitive.Description,
88
+ {
89
+ ref,
90
+ className: cn("sb-text-sm sb-text-muted-foreground", className),
91
+ ...props
92
+ }
93
+ ));
94
+ AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayName;
95
+ var AlertDialogAction = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
96
+ AlertDialogPrimitive.Action,
97
+ {
98
+ ref,
99
+ className: cn(buttonVariants(), className),
100
+ ...props
101
+ }
102
+ ));
103
+ AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
104
+ var AlertDialogCancel = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
105
+ AlertDialogPrimitive.Cancel,
106
+ {
107
+ ref,
108
+ className: cn(
109
+ buttonVariants({ variant: "outline" }),
110
+ "sb-mt-2 sm:sb-mt-0",
111
+ className
112
+ ),
113
+ ...props
114
+ }
115
+ ));
116
+ AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
117
+ var Popover = PopoverPrimitive.Root;
118
+ var PopoverTrigger = PopoverPrimitive.Trigger;
119
+ var PopoverClose = PopoverPrimitive.Close;
120
+ var PopoverContent = React25.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ React25.createElement(PopoverPrimitive.Portal, null, /* @__PURE__ */ React25.createElement(
121
+ PopoverPrimitive.Content,
122
+ {
123
+ ref,
124
+ align,
125
+ sideOffset,
126
+ className: cn(
127
+ "sb-z-50 sb-w-72 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 sb-origin-[--radix-popover-content-transform-origin]",
128
+ className
129
+ ),
130
+ ...props
131
+ }
132
+ )));
133
+ PopoverContent.displayName = PopoverPrimitive.Content.displayName;
134
+ var Link = TiptapLink.extend({
135
+ inclusive: false,
136
+ parseHTML() {
137
+ return [{ tag: 'a[href]:not([data-type="button"]):not([href *= "javascript:" i])' }];
138
+ },
139
+ renderHTML({ HTMLAttributes }) {
140
+ return ["a", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
141
+ },
142
+ addOptions() {
143
+ return {
144
+ ...this.parent?.(),
145
+ openOnClick: false
146
+ };
147
+ },
148
+ addProseMirrorPlugins() {
149
+ return [
150
+ ...this.parent?.() || [],
151
+ new Plugin({
152
+ props: {
153
+ handleClick(view, pos) {
154
+ const { schema: schema2, doc, tr } = view.state;
155
+ const range = getMarkRange(doc.resolve(pos), schema2.marks.link);
156
+ if (!range) {
157
+ return;
158
+ }
159
+ const { from, to } = range;
160
+ const start = Math.min(from, to);
161
+ const end = Math.max(from, to);
162
+ if (pos < start || pos > end) {
163
+ return;
164
+ }
165
+ const $start = doc.resolve(start);
166
+ const $end = doc.resolve(end);
167
+ const transaction = tr.setSelection(new TextSelection($start, $end));
168
+ view.dispatch(transaction);
169
+ }
170
+ }
171
+ })
172
+ ];
173
+ }
174
+ });
175
+
176
+ // src/features/rich-text-editor/utils/get-output.ts
177
+ var getOutput = (editor, format2) => {
178
+ switch (format2) {
179
+ case "json":
180
+ return editor.getJSON();
181
+ case "html":
182
+ return editor.isEmpty ? "" : editor.getHTML();
183
+ default:
184
+ return editor.getText();
185
+ }
186
+ };
187
+
188
+ // src/features/rich-text-editor/hooks/useRichTextEditor.ts
189
+ var useRichTextEditor = ({
190
+ value,
191
+ output = "html",
192
+ editorClassName,
193
+ onUpdate,
194
+ onBlur,
195
+ ...options
196
+ }) => {
197
+ const handleCreate = useCallback(
198
+ (editor2) => {
199
+ if (value && editor2.isEmpty) {
200
+ editor2.commands.setContent(value);
201
+ }
202
+ },
203
+ [value]
204
+ );
205
+ const handleUpdate = useCallback(
206
+ (editor2) => {
207
+ onUpdate?.(getOutput(editor2, output));
208
+ },
209
+ [output]
210
+ );
211
+ const handleBlur = useCallback(
212
+ (editor2) => {
213
+ onBlur?.(getOutput(editor2, output));
214
+ },
215
+ [output, onBlur]
216
+ );
217
+ const editor = useEditor({
218
+ extensions: [StarterKit, Underline, Color, TextStyle, Link],
219
+ editorProps: {
220
+ attributes: {
221
+ autocomplete: "off",
222
+ autocorrect: "off",
223
+ autocapitalize: "off",
224
+ class: cn("sb-focus:outline-none", editorClassName)
225
+ }
226
+ },
227
+ onCreate: ({ editor: editor2 }) => handleCreate(editor2),
228
+ onUpdate: ({ editor: editor2 }) => handleUpdate(editor2),
229
+ onBlur: ({ editor: editor2 }) => handleBlur(editor2),
230
+ ...options
231
+ });
232
+ return editor;
233
+ };
234
+ var DropdownMenu = DropdownMenuPrimitive.Root;
235
+ var DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
236
+ var DropdownMenuSubTrigger = React25.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ React25.createElement(
237
+ DropdownMenuPrimitive.SubTrigger,
238
+ {
239
+ ref,
240
+ className: cn(
241
+ "sb-flex sb-cursor-default sb-select-none sb-items-center sb-gap-2 sb-rounded-sm sb-px-2 sb-py-1.5 sb-text-sm sb-outline-none focus:sb-bg-accent data-[state=open]:sb-bg-accent [&_svg]:sb-pointer-events-none [&_svg]:sb-size-4 [&_svg]:sb-shrink-0",
242
+ inset && "sb-pl-8",
243
+ className
244
+ ),
245
+ ...props
246
+ },
247
+ children,
248
+ /* @__PURE__ */ React25.createElement(ChevronRight, { className: "sb-ml-auto" })
249
+ ));
250
+ DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
251
+ var DropdownMenuSubContent = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
252
+ DropdownMenuPrimitive.SubContent,
253
+ {
254
+ ref,
255
+ className: cn(
256
+ "sb-z-50 sb-min-w-[8rem] sb-overflow-hidden sb-rounded-md sb-border sb-bg-popover sb-p-1 sb-text-popover-foreground sb-shadow-lg 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 sb-origin-[--radix-dropdown-menu-content-transform-origin]",
257
+ className
258
+ ),
259
+ ...props
260
+ }
261
+ ));
262
+ DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
263
+ var DropdownMenuContent = React25.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ React25.createElement(DropdownMenuPrimitive.Portal, null, /* @__PURE__ */ React25.createElement(
264
+ DropdownMenuPrimitive.Content,
265
+ {
266
+ ref,
267
+ sideOffset,
268
+ className: cn(
269
+ "sb-z-50 sb-max-h-[var(--radix-dropdown-menu-content-available-height)] sb-min-w-[8rem] sb-overflow-y-auto sb-overflow-x-hidden sb-rounded-md sb-border sb-bg-popover sb-p-1 sb-text-popover-foreground sb-shadow-md",
270
+ "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 sb-origin-[--radix-dropdown-menu-content-transform-origin]",
271
+ className
272
+ ),
273
+ ...props
274
+ }
275
+ )));
276
+ DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
277
+ var DropdownMenuItem = React25.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ React25.createElement(
278
+ DropdownMenuPrimitive.Item,
279
+ {
280
+ ref,
281
+ className: cn(
282
+ "sb-relative sb-flex sb-cursor-default sb-select-none sb-items-center sb-gap-2 sb-rounded-sm sb-px-2 sb-py-1.5 sb-text-sm sb-outline-none sb-transition-colors focus:sb-bg-accent focus:sb-text-accent-foreground data-[disabled]:sb-pointer-events-none data-[disabled]:sb-opacity-50 [&>svg]:sb-size-4 [&>svg]:sb-shrink-0",
283
+ inset && "sb-pl-8",
284
+ className
285
+ ),
286
+ ...props
287
+ }
288
+ ));
289
+ DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
290
+ var DropdownMenuCheckboxItem = React25.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ React25.createElement(
291
+ DropdownMenuPrimitive.CheckboxItem,
292
+ {
293
+ ref,
294
+ className: cn(
295
+ "sb-relative sb-flex 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 sb-transition-colors focus:sb-bg-accent focus:sb-text-accent-foreground data-[disabled]:sb-pointer-events-none data-[disabled]:sb-opacity-50",
296
+ className
297
+ ),
298
+ checked,
299
+ ...props
300
+ },
301
+ /* @__PURE__ */ React25.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__ */ React25.createElement(DropdownMenuPrimitive.ItemIndicator, null, /* @__PURE__ */ React25.createElement(Check, { className: "sb-h-4 sb-w-4" }))),
302
+ children
303
+ ));
304
+ DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
305
+ var DropdownMenuRadioItem = React25.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React25.createElement(
306
+ DropdownMenuPrimitive.RadioItem,
307
+ {
308
+ ref,
309
+ className: cn(
310
+ "sb-relative sb-flex 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 sb-transition-colors focus:sb-bg-accent focus:sb-text-accent-foreground data-[disabled]:sb-pointer-events-none data-[disabled]:sb-opacity-50",
311
+ className
312
+ ),
313
+ ...props
314
+ },
315
+ /* @__PURE__ */ React25.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__ */ React25.createElement(DropdownMenuPrimitive.ItemIndicator, null, /* @__PURE__ */ React25.createElement(Circle, { className: "sb-h-2 sb-w-2 sb-fill-current" }))),
316
+ children
317
+ ));
318
+ DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
319
+ var DropdownMenuLabel = React25.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ React25.createElement(
320
+ DropdownMenuPrimitive.Label,
321
+ {
322
+ ref,
323
+ className: cn(
324
+ "sb-px-2 sb-py-1.5 sb-text-sm sb-font-semibold",
325
+ inset && "sb-pl-8",
326
+ className
327
+ ),
328
+ ...props
329
+ }
330
+ ));
331
+ DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
332
+ var DropdownMenuSeparator = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
333
+ DropdownMenuPrimitive.Separator,
334
+ {
335
+ ref,
336
+ className: cn("sb--mx-1 sb-my-1 sb-h-px sb-bg-muted", className),
337
+ ...props
338
+ }
339
+ ));
340
+ DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
341
+ var Separator2 = React25.forwardRef(
342
+ ({ className, orientation = "horizontal", decorative = true, ...props }, ref) => /* @__PURE__ */ React25.createElement(
343
+ SeparatorPrimitive.Root,
344
+ {
345
+ ref,
346
+ decorative,
347
+ orientation,
348
+ className: cn(
349
+ "sb-shrink-0 sb-bg-border",
350
+ orientation === "horizontal" ? "sb-h-[1px] sb-w-full" : "sb-h-full sb-w-[1px]",
351
+ className
352
+ ),
353
+ ...props
354
+ }
355
+ )
356
+ );
357
+ Separator2.displayName = SeparatorPrimitive.Root.displayName;
358
+ var toggleVariants = cva(
359
+ "sb-inline-flex sb-items-center sb-justify-center sb-gap-2 sb-rounded-md sb-text-sm sb-font-medium 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 disabled:sb-pointer-events-none disabled:sb-opacity-50 data-[state=on]:sb-bg-accent data-[state=on]:sb-text-accent-foreground [&_svg]:sb-pointer-events-none [&_svg]:sb-size-4 [&_svg]:sb-shrink-0",
360
+ {
361
+ variants: {
362
+ variant: {
363
+ default: "sb-bg-transparent",
364
+ outline: "sb-border sb-border-input sb-bg-transparent sb-shadow-sm hover:sb-bg-accent hover:sb-text-accent-foreground"
365
+ },
366
+ size: {
367
+ default: "sb-h-9 sb-px-2 sb-min-w-9",
368
+ sm: "sb-h-8 sb-px-1.5 sb-min-w-8",
369
+ lg: "sb-h-10 sb-px-2.5 sb-min-w-10"
370
+ }
371
+ },
372
+ defaultVariants: {
373
+ variant: "default",
374
+ size: "default"
375
+ }
376
+ }
377
+ );
378
+ var Toggle = React25.forwardRef(({ className, variant, size, ...props }, ref) => /* @__PURE__ */ React25.createElement(
379
+ TogglePrimitive.Root,
380
+ {
381
+ ref,
382
+ className: cn(toggleVariants({ variant, size, className })),
383
+ ...props
384
+ }
385
+ ));
386
+ Toggle.displayName = TogglePrimitive.Root.displayName;
387
+ var ToggleGroupContext = React25.createContext({
388
+ size: "default",
389
+ variant: "default"
390
+ });
391
+ var ToggleGroup = React25.forwardRef(({ className, variant, size, children, ...props }, ref) => /* @__PURE__ */ React25.createElement(
392
+ ToggleGroupPrimitive.Root,
393
+ {
394
+ ref,
395
+ className: cn("sb-flex sb-items-center sb-justify-center sb-gap-1", className),
396
+ ...props
397
+ },
398
+ /* @__PURE__ */ React25.createElement(ToggleGroupContext.Provider, { value: { variant, size } }, children)
399
+ ));
400
+ ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName;
401
+ var ToggleGroupItem = React25.forwardRef(({ className, children, variant, size, ...props }, ref) => {
402
+ const context = React25.useContext(ToggleGroupContext);
403
+ return /* @__PURE__ */ React25.createElement(
404
+ ToggleGroupPrimitive.Item,
405
+ {
406
+ ref,
407
+ className: cn(
408
+ toggleVariants({
409
+ variant: context.variant || variant,
410
+ size: context.size || size
411
+ }),
412
+ className
413
+ ),
414
+ ...props
415
+ },
416
+ children
417
+ );
418
+ });
419
+ ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
420
+ var PALETTES = [
421
+ {
422
+ inverse: "hsl(var(--background))",
423
+ colors: [
424
+ { cssVar: "hsl(var(--foreground))" },
425
+ { cssVar: "hsl(var(--primary-foreground))" },
426
+ { cssVar: "hsl(var(--secondary-foreground))" },
427
+ { cssVar: "hsl(var(--tertiary-foreground))" },
428
+ { cssVar: "hsl(var(--muted-foreground))" },
429
+ { cssVar: "hsl(var(--accent-foreground))" },
430
+ { cssVar: "hsl(var(--destructive-foreground))" }
431
+ ]
432
+ },
433
+ {
434
+ inverse: "hsl(var(--foreground))",
435
+ colors: [
436
+ { cssVar: "hsl(var(--background))" },
437
+ { cssVar: "hsl(var(--primary))" },
438
+ { cssVar: "hsl(var(--secondary))" },
439
+ { cssVar: "hsl(var(--tertiary))" },
440
+ { cssVar: "hsl(var(--muted))" },
441
+ { cssVar: "hsl(var(--accent))" },
442
+ { cssVar: "hsl(var(--destructive))" }
443
+ ]
444
+ }
445
+ ];
446
+ var ColorTool = ({ editor }) => {
447
+ const color = editor.getAttributes("textStyle")?.color || "hsl(var(--foreground))";
448
+ const [selectedColor, setSelectedColor] = React25.useState(color);
449
+ React25.useEffect(() => {
450
+ setSelectedColor(color);
451
+ }, [color]);
452
+ const handleColorChange = React25.useCallback(
453
+ (value) => {
454
+ setSelectedColor(value);
455
+ editor.chain().focus().setColor(value).run();
456
+ },
457
+ [editor]
458
+ );
459
+ return /* @__PURE__ */ React25.createElement(Popover, { modal: true }, /* @__PURE__ */ React25.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React25.createElement(ToolbarButton, { className: "sb-w-12" }, /* @__PURE__ */ React25.createElement(
460
+ "svg",
461
+ {
462
+ xmlns: "http://www.w3.org/2000/svg",
463
+ width: "24",
464
+ height: "24",
465
+ viewBox: "0 0 24 24",
466
+ fill: "none",
467
+ stroke: "currentColor",
468
+ strokeWidth: "2",
469
+ strokeLinecap: "round",
470
+ strokeLinejoin: "round",
471
+ className: "sb-size-5",
472
+ style: { color: selectedColor }
473
+ },
474
+ /* @__PURE__ */ React25.createElement("path", { d: "M4 20h16" }),
475
+ /* @__PURE__ */ React25.createElement("path", { d: "m6 16 6-12 6 12" }),
476
+ /* @__PURE__ */ React25.createElement("path", { d: "M8 12h8" })
477
+ ), /* @__PURE__ */ React25.createElement(LuChevronDown, { className: "sb-size-5" }))), /* @__PURE__ */ React25.createElement(PopoverContent, { align: "start", className: "sb-w-full" }, /* @__PURE__ */ React25.createElement(
478
+ ToggleGroup,
479
+ {
480
+ type: "single",
481
+ value: selectedColor,
482
+ onValueChange: handleColorChange,
483
+ className: "sb-flex-col sb-gap-1.5"
484
+ },
485
+ PALETTES.map((pallete, i) => /* @__PURE__ */ React25.createElement("div", { key: i, className: "sb-flex sb-gap-1.5" }, pallete.colors.map((color2, j) => /* @__PURE__ */ React25.createElement(
486
+ ToggleGroupItem,
487
+ {
488
+ tabIndex: 0,
489
+ key: j,
490
+ className: "sb-relative sb-size-7 sb-rounded-md sb-border sb-p-0",
491
+ value: color2.cssVar,
492
+ style: { backgroundColor: color2.cssVar }
493
+ },
494
+ selectedColor === color2.cssVar && /* @__PURE__ */ React25.createElement(
495
+ LuCheck,
496
+ {
497
+ className: "sb-absolute sb-inset-0 sb-m-auto sb-size-6",
498
+ style: { color: pallete.inverse }
499
+ }
500
+ )
501
+ ))))
502
+ )));
503
+ };
504
+ var formatActions = [
505
+ {
506
+ label: "Normal Text",
507
+ element: "span",
508
+ className: "sb-grow"
509
+ },
510
+ {
511
+ label: "Heading 1",
512
+ element: "h1",
513
+ level: 1,
514
+ className: "sb-m-0 sb-grow sb-text-3xl sb-font-extrabold"
515
+ },
516
+ {
517
+ label: "Heading 2",
518
+ element: "h2",
519
+ level: 2,
520
+ className: "sb-m-0 sb-grow sb-text-xl sb-font-bold"
521
+ },
522
+ {
523
+ label: "Heading 3",
524
+ element: "h3",
525
+ level: 3,
526
+ className: "sb-m-0 sb-grow sb-text-lg sb-font-semibold"
527
+ },
528
+ {
529
+ label: "Heading 4",
530
+ element: "h4",
531
+ level: 4,
532
+ className: "sb-m-0 sb-grow sb-text-base sb-font-semibold"
533
+ }
534
+ ];
535
+ var ElementTool = ({ editor }) => {
536
+ const isActive = editor.isActive("heading");
537
+ const handleFormatChange = React25.useCallback(
538
+ (level) => {
539
+ if (level) {
540
+ editor.chain().focus().toggleHeading({ level }).run();
541
+ } else {
542
+ editor.chain().focus().setParagraph().run();
543
+ }
544
+ },
545
+ [editor]
546
+ );
547
+ return /* @__PURE__ */ React25.createElement(DropdownMenu, null, /* @__PURE__ */ React25.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React25.createElement(
548
+ ToolbarButton,
549
+ {
550
+ className: "sb-w-12 data-[state=open]:sb-bg-accent",
551
+ pressed: isActive
552
+ },
553
+ /* @__PURE__ */ React25.createElement(LuHeading, { className: "sb-size-5" }),
554
+ /* @__PURE__ */ React25.createElement(LuChevronDown, { className: "sb-size-5" })
555
+ )), /* @__PURE__ */ React25.createElement(DropdownMenuContent, { align: "start" }, formatActions.map(({ element: Element, ...action }) => /* @__PURE__ */ React25.createElement(
556
+ DropdownMenuItem,
557
+ {
558
+ key: action.label,
559
+ className: cn({
560
+ "sb-bg-accent": action.level ? editor.isActive("heading", { level: action.level }) : editor.isActive("paragraph")
561
+ }),
562
+ onClick: () => handleFormatChange(action.level)
563
+ },
564
+ /* @__PURE__ */ React25.createElement(Element, { className: action.className }, action.label)
565
+ ))));
566
+ };
567
+ var actions = [
568
+ {
569
+ value: "bold",
570
+ label: "Bold",
571
+ icon: LuBold,
572
+ action: (editor) => editor.chain().focus().toggleBold().run(),
573
+ isActive: (editor) => editor.isActive("bold"),
574
+ canExecute: (editor) => editor.can().chain().focus().toggleBold().run() && !editor.isActive("codeBlock")
575
+ },
576
+ {
577
+ value: "italic",
578
+ label: "Italic",
579
+ icon: LuItalic,
580
+ action: (editor) => editor.chain().focus().toggleItalic().run(),
581
+ isActive: (editor) => editor.isActive("italic"),
582
+ canExecute: (editor) => editor.can().chain().focus().toggleItalic().run() && !editor.isActive("codeBlock")
583
+ },
584
+ {
585
+ value: "underline",
586
+ label: "Underline",
587
+ icon: LuUnderline,
588
+ action: (editor) => editor.chain().focus().toggleUnderline().run(),
589
+ isActive: (editor) => editor.isActive("underline"),
590
+ canExecute: (editor) => editor.can().chain().focus().toggleUnderline().run() && !editor.isActive("codeBlock")
591
+ },
592
+ {
593
+ value: "strikethrough",
594
+ label: "Strikethrough",
595
+ icon: LuStrikethrough,
596
+ action: (editor) => editor.chain().focus().toggleStrike().run(),
597
+ isActive: (editor) => editor.isActive("strike"),
598
+ canExecute: (editor) => editor.can().chain().focus().toggleStrike().run() && !editor.isActive("codeBlock")
599
+ },
600
+ {
601
+ value: "code",
602
+ label: "Code",
603
+ icon: LuCode,
604
+ action: (editor) => editor.chain().focus().toggleCode().run(),
605
+ isActive: (editor) => editor.isActive("code"),
606
+ canExecute: (editor) => editor.can().chain().focus().toggleCode().run() && !editor.isActive("codeBlock")
607
+ },
608
+ {
609
+ value: "clearFormatting",
610
+ label: "Clear formatting",
611
+ icon: LuRemoveFormatting,
612
+ action: (editor) => editor.chain().focus().unsetAllMarks().run(),
613
+ isActive: () => false,
614
+ canExecute: (editor) => editor.can().chain().focus().unsetAllMarks().run() && !editor.isActive("codeBlock")
615
+ }
616
+ ];
617
+ var FormatTool = ({ editor }) => {
618
+ return /* @__PURE__ */ React25.createElement(ToolbarSection, { editor, actions, mainActionCount: 1 });
619
+ };
620
+ var actions2 = [
621
+ {
622
+ value: "codeBlock",
623
+ label: "Code block",
624
+ icon: LuCode,
625
+ action: (editor) => editor.chain().focus().toggleCodeBlock().run(),
626
+ isActive: (editor) => editor.isActive("codeBlock"),
627
+ canExecute: (editor) => editor.can().chain().focus().toggleCodeBlock().run()
628
+ },
629
+ {
630
+ value: "blockquote",
631
+ label: "Blockquote",
632
+ icon: LuQuote,
633
+ action: (editor) => editor.chain().focus().toggleBlockquote().run(),
634
+ isActive: (editor) => editor.isActive("blockquote"),
635
+ canExecute: (editor) => editor.can().chain().focus().toggleBlockquote().run()
636
+ },
637
+ {
638
+ value: "horizontalRule",
639
+ label: "Divider",
640
+ icon: LuMinus,
641
+ action: (editor) => editor.chain().focus().setHorizontalRule().run(),
642
+ isActive: () => false,
643
+ canExecute: (editor) => editor.can().chain().focus().setHorizontalRule().run()
644
+ }
645
+ ];
646
+ var InsertTool = ({ editor }) => {
647
+ return /* @__PURE__ */ React25.createElement(ToolbarSection, { editor, actions: actions2, mainActionCount: 0 });
648
+ };
649
+ var Dialog = DialogPrimitive.Root;
650
+ var DialogTrigger = DialogPrimitive.Trigger;
651
+ var DialogPortal = DialogPrimitive.Portal;
652
+ var DialogOverlay = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
653
+ DialogPrimitive.Overlay,
654
+ {
655
+ ref,
656
+ className: cn(
657
+ "sb-fixed sb-inset-0 sb-z-50 sb-bg-black/80 sb- 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",
658
+ className
659
+ ),
660
+ ...props
661
+ }
662
+ ));
663
+ DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
664
+ var DialogContent = React25.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React25.createElement(DialogPortal, null, /* @__PURE__ */ React25.createElement(DialogOverlay, null), /* @__PURE__ */ React25.createElement(
665
+ DialogPrimitive.Content,
666
+ {
667
+ ref,
668
+ className: cn(
669
+ "sb-fixed 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",
670
+ className
671
+ ),
672
+ ...props
673
+ },
674
+ children,
675
+ /* @__PURE__ */ React25.createElement(DialogPrimitive.Close, { className: "sb-absolute sb-right-4 sb-top-4 sb-rounded-sm sb-opacity-70 sb-ring-offset-background sb-transition-opacity hover:sb-opacity-100 focus:sb-outline-none focus:sb-ring-2 focus:sb-ring-ring focus:sb-ring-offset-2 disabled:sb-pointer-events-none data-[state=open]:sb-bg-accent data-[state=open]:sb-text-muted-foreground" }, /* @__PURE__ */ React25.createElement(X, { className: "sb-h-4 sb-w-4" }), /* @__PURE__ */ React25.createElement("span", { className: "sb-sr-only" }, "Close"))
676
+ )));
677
+ DialogContent.displayName = DialogPrimitive.Content.displayName;
678
+ var DialogHeader = ({
679
+ className,
680
+ ...props
681
+ }) => /* @__PURE__ */ React25.createElement(
682
+ "div",
683
+ {
684
+ className: cn(
685
+ "sb-flex sb-flex-col sb-space-y-1.5 sb-text-center sm:sb-text-left",
686
+ className
687
+ ),
688
+ ...props
689
+ }
690
+ );
691
+ DialogHeader.displayName = "DialogHeader";
692
+ var DialogTitle = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
693
+ DialogPrimitive.Title,
694
+ {
695
+ ref,
696
+ className: cn(
697
+ "sb-text-lg sb-font-semibold sb-leading-none sb-tracking-tight",
698
+ className
699
+ ),
700
+ ...props
701
+ }
702
+ ));
703
+ DialogTitle.displayName = DialogPrimitive.Title.displayName;
704
+ var DialogDescription = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
705
+ DialogPrimitive.Description,
706
+ {
707
+ ref,
708
+ className: cn("sb-text-sm sb-text-muted-foreground", className),
709
+ ...props
710
+ }
711
+ ));
712
+ DialogDescription.displayName = DialogPrimitive.Description.displayName;
713
+ var labelVariants = cva(
714
+ "sb-text-sm sb-font-medium sb-leading-none peer-disabled:sb-cursor-not-allowed peer-disabled:sb-opacity-70"
715
+ );
716
+ var Label2 = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
717
+ LabelPrimitive.Root,
718
+ {
719
+ ref,
720
+ className: cn(labelVariants(), className),
721
+ ...props
722
+ }
723
+ ));
724
+ Label2.displayName = LabelPrimitive.Root.displayName;
725
+
726
+ // src/components/ui/form.tsx
727
+ var Form = FormProvider;
728
+ var FormFieldContext = React25.createContext(
729
+ {}
730
+ );
731
+ var FormField = ({
732
+ ...props
733
+ }) => {
734
+ return /* @__PURE__ */ React25.createElement(FormFieldContext.Provider, { value: { name: props.name } }, /* @__PURE__ */ React25.createElement(Controller, { ...props }));
735
+ };
736
+ var useFormField = () => {
737
+ const fieldContext = React25.useContext(FormFieldContext);
738
+ const itemContext = React25.useContext(FormItemContext);
739
+ const { getFieldState, formState } = useFormContext();
740
+ const fieldState = getFieldState(fieldContext.name, formState);
741
+ if (!fieldContext) {
742
+ throw new Error("useFormField should be used within <FormField>");
743
+ }
744
+ const { id } = itemContext;
745
+ return {
746
+ id,
747
+ name: fieldContext.name,
748
+ formItemId: `${id}-form-item`,
749
+ formDescriptionId: `${id}-form-item-description`,
750
+ formMessageId: `${id}-form-item-message`,
751
+ ...fieldState
752
+ };
753
+ };
754
+ var FormItemContext = React25.createContext(
755
+ {}
756
+ );
757
+ var FormItem = React25.forwardRef(({ className, ...props }, ref) => {
758
+ const id = React25.useId();
759
+ return /* @__PURE__ */ React25.createElement(FormItemContext.Provider, { value: { id } }, /* @__PURE__ */ React25.createElement("div", { ref, className: cn("sb-space-y-2", className), ...props }));
760
+ });
761
+ FormItem.displayName = "FormItem";
762
+ var FormLabel = React25.forwardRef(({ className, ...props }, ref) => {
763
+ const { error, formItemId } = useFormField();
764
+ return /* @__PURE__ */ React25.createElement(
765
+ Label2,
766
+ {
767
+ ref,
768
+ className: cn(error && "sb-text-destructive", className),
769
+ htmlFor: formItemId,
770
+ ...props
771
+ }
772
+ );
773
+ });
774
+ FormLabel.displayName = "FormLabel";
775
+ var FormControl = React25.forwardRef(({ ...props }, ref) => {
776
+ const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
777
+ return /* @__PURE__ */ React25.createElement(
778
+ Slot,
779
+ {
780
+ ref,
781
+ id: formItemId,
782
+ "aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
783
+ "aria-invalid": !!error,
784
+ ...props
785
+ }
786
+ );
787
+ });
788
+ FormControl.displayName = "FormControl";
789
+ var FormDescription = React25.forwardRef(({ className, ...props }, ref) => {
790
+ const { formDescriptionId } = useFormField();
791
+ return /* @__PURE__ */ React25.createElement(
792
+ "p",
793
+ {
794
+ ref,
795
+ id: formDescriptionId,
796
+ className: cn("sb-text-[0.8rem] sb-text-muted-foreground", className),
797
+ ...props
798
+ }
799
+ );
800
+ });
801
+ FormDescription.displayName = "FormDescription";
802
+ var FormMessage = React25.forwardRef(({ className, children, ...props }, ref) => {
803
+ const { error, formMessageId } = useFormField();
804
+ const body = error ? String(error?.message ?? "") : children;
805
+ if (!body) {
806
+ return null;
807
+ }
808
+ return /* @__PURE__ */ React25.createElement(
809
+ "p",
810
+ {
811
+ ref,
812
+ id: formMessageId,
813
+ className: cn("sb-text-[0.8rem] sb-font-medium sb-text-destructive", className),
814
+ ...props
815
+ },
816
+ body
817
+ );
818
+ });
819
+ FormMessage.displayName = "FormMessage";
820
+ var Input = React25.forwardRef(
821
+ ({ className, type, ...props }, ref) => {
822
+ return /* @__PURE__ */ React25.createElement(
823
+ "input",
824
+ {
825
+ type,
826
+ className: cn(
827
+ "sb-flex sb-h-9 sb-w-full sb-rounded-md sb-border sb-border-input sb-bg-transparent sb-px-3 sb-py-1 sb-text-base sb-shadow-sm sb-transition-colors file:sb-border-0 file:sb-bg-transparent file:sb-text-sm file:sb-font-medium file:sb-text-foreground 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 md:sb-text-sm",
828
+ className
829
+ ),
830
+ ref,
831
+ ...props
832
+ }
833
+ );
834
+ }
835
+ );
836
+ Input.displayName = "Input";
837
+ var AdvancedInput = React25.forwardRef(
838
+ ({ prepend, append, ...props }, ref) => {
839
+ return /* @__PURE__ */ React25.createElement("div", { className: "sb-relative" }, /* @__PURE__ */ React25.createElement(Input, { ref, className: "sb-pl-9 sb-pr-7 sb-text-right", ...props }), prepend && /* @__PURE__ */ React25.createElement("div", { className: "sb-absolute sb-font-roboto sb-top-1/2 sb-left-3 sb--translate-y-1/2" }, prepend), append && /* @__PURE__ */ React25.createElement("div", { className: "sb-absolute sb-font-roboto sb-top-1/2 sb-right-3 sb--translate-y-1/2" }, append));
840
+ }
841
+ );
842
+ AdvancedInput.displayName = "AdvancedInput";
843
+ var Switch = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
844
+ SwitchPrimitives.Root,
845
+ {
846
+ className: cn(
847
+ "sb-peer sb-inline-flex sb-h-5 sb-w-9 sb-shrink-0 sb-cursor-pointer sb-items-center sb-rounded-full sb-border-2 sb-border-transparent sb-shadow-sm 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",
848
+ className
849
+ ),
850
+ ...props,
851
+ ref
852
+ },
853
+ /* @__PURE__ */ React25.createElement(
854
+ SwitchPrimitives.Thumb,
855
+ {
856
+ className: cn(
857
+ "sb-pointer-events-none sb-block sb-h-4 sb-w-4 sb-rounded-full sb-bg-background sb-shadow-lg sb-ring-0 sb-transition-transform data-[state=checked]:sb-translate-x-4 data-[state=unchecked]:sb-translate-x-0"
858
+ )
859
+ }
860
+ )
861
+ ));
862
+ Switch.displayName = SwitchPrimitives.Root.displayName;
863
+ var LinkTool = ({ editor }) => {
864
+ const [open, setOpen] = React25.useState(false);
865
+ const { from, to } = editor.state.selection;
866
+ const text = editor.state.doc.textBetween(from, to, " ");
867
+ const handleSetLink = React25.useCallback(
868
+ (url, text2, openInNewTab) => {
869
+ editor.chain().focus().extendMarkRange("link").insertContent({
870
+ type: "text",
871
+ text: text2 || url,
872
+ marks: [
873
+ {
874
+ type: "link",
875
+ attrs: {
876
+ href: url,
877
+ target: openInNewTab ? "_blank" : ""
878
+ }
879
+ }
880
+ ]
881
+ }).setLink({ href: url }).run();
882
+ editor.commands.enter();
883
+ setOpen(false);
884
+ },
885
+ [editor]
886
+ );
887
+ return /* @__PURE__ */ React25.createElement(Dialog, { open, onOpenChange: setOpen }, /* @__PURE__ */ React25.createElement(DialogTrigger, { asChild: true }, /* @__PURE__ */ React25.createElement(
888
+ ToolbarButton,
889
+ {
890
+ pressed: editor.isActive("link"),
891
+ disabled: editor.isActive("codeBlock")
892
+ },
893
+ /* @__PURE__ */ React25.createElement(LuLink2, { className: "sb-size-5" })
894
+ )), /* @__PURE__ */ React25.createElement(DialogContent, { className: "sb-w-full sb-min-w-80" }, /* @__PURE__ */ React25.createElement(LinkForm, { onSave: handleSetLink, defaultText: text })));
895
+ };
896
+ var schema = z.object({
897
+ url: z.string().min(0),
898
+ text: z.string().optional(),
899
+ isNewTab: z.boolean().optional()
900
+ });
901
+ var LinkForm = ({
902
+ onSave,
903
+ defaultIsNewTab,
904
+ defaultUrl,
905
+ defaultText
906
+ }) => {
907
+ const form = useForm({
908
+ resolver: zodResolver(schema),
909
+ defaultValues: {
910
+ url: defaultUrl || "",
911
+ text: defaultText || "",
912
+ isNewTab: defaultIsNewTab || false
913
+ }
914
+ });
915
+ const handleSubmit = (values) => {
916
+ onSave(values.url, values.text, values.isNewTab);
917
+ };
918
+ return /* @__PURE__ */ React25.createElement(Form, { ...form }, /* @__PURE__ */ React25.createElement("div", { className: "sb-space-y-6" }, /* @__PURE__ */ React25.createElement(
919
+ FormField,
920
+ {
921
+ control: form.control,
922
+ name: "url",
923
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, null, /* @__PURE__ */ React25.createElement(FormLabel, null, "URL"), /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(Input, { type: "url", ...field, autoFocus: true })), /* @__PURE__ */ React25.createElement(FormMessage, null))
924
+ }
925
+ ), /* @__PURE__ */ React25.createElement(
926
+ FormField,
927
+ {
928
+ control: form.control,
929
+ name: "text",
930
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, null, /* @__PURE__ */ React25.createElement(FormLabel, null, "Text"), /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(Input, { ...field })), /* @__PURE__ */ React25.createElement(FormMessage, null))
931
+ }
932
+ ), /* @__PURE__ */ React25.createElement(
933
+ FormField,
934
+ {
935
+ control: form.control,
936
+ name: "isNewTab",
937
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, null, /* @__PURE__ */ React25.createElement("div", { className: "sb-flex sb-items-center sb-space-x-2" }, /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(
938
+ Switch,
939
+ {
940
+ checked: field.value,
941
+ onCheckedChange: field.onChange
942
+ }
943
+ )), /* @__PURE__ */ React25.createElement(FormLabel, null, "Open in new tab")), /* @__PURE__ */ React25.createElement(FormMessage, null))
944
+ }
945
+ ), /* @__PURE__ */ React25.createElement(Button, { type: "button", onClick: form.handleSubmit(handleSubmit) }, "Save")));
946
+ };
947
+ var actions3 = [
948
+ {
949
+ value: "orderedList",
950
+ label: "Numbered list",
951
+ icon: LuListOrdered,
952
+ action: (editor) => editor.chain().focus().toggleOrderedList().run(),
953
+ isActive: (editor) => editor.isActive("orderedList"),
954
+ canExecute: (editor) => editor.can().chain().focus().toggleOrderedList().run()
955
+ },
956
+ {
957
+ value: "bulletList",
958
+ label: "Bullet list",
959
+ icon: LuList,
960
+ action: (editor) => editor.chain().focus().toggleBulletList().run(),
961
+ isActive: (editor) => editor.isActive("bulletList"),
962
+ canExecute: (editor) => editor.can().chain().focus().toggleBulletList().run()
963
+ }
964
+ ];
965
+ var ListTool = ({ editor }) => {
966
+ return /* @__PURE__ */ React25.createElement(ToolbarSection, { editor, actions: actions3, mainActionCount: 2 });
967
+ };
968
+
969
+ // src/features/rich-text-editor/components/toolbar.tsx
970
+ var Toolbar = ({ editor }) => {
971
+ return /* @__PURE__ */ React25.createElement("div", { className: "sb-shrink-0 sb-overflow-x-auto sb-border-b sb-border-border sb-p-2" }, /* @__PURE__ */ React25.createElement("div", { className: "sb-flex sb-w-max sb-items-center sb-gap-px" }, /* @__PURE__ */ React25.createElement(ElementTool, { editor }), /* @__PURE__ */ React25.createElement(Separator2, { orientation: "vertical", className: "sb-mx-2 sb-h-7" }), /* @__PURE__ */ React25.createElement(FormatTool, { editor }), /* @__PURE__ */ React25.createElement(Separator2, { orientation: "vertical", className: "sb-mx-2 sb-h-7" }), /* @__PURE__ */ React25.createElement(ColorTool, { editor }), /* @__PURE__ */ React25.createElement(Separator2, { orientation: "vertical", className: "sb-mx-2 sb-h-7" }), /* @__PURE__ */ React25.createElement(ListTool, { editor }), /* @__PURE__ */ React25.createElement(Separator2, { orientation: "vertical", className: "sb-mx-2 sb-h-7" }), /* @__PURE__ */ React25.createElement(LinkTool, { editor }), /* @__PURE__ */ React25.createElement(InsertTool, { editor })));
972
+ };
973
+ var ToolbarSection = ({
974
+ editor,
975
+ actions: actions4,
976
+ mainActionCount = 0
977
+ }) => {
978
+ const { mainActions, dropdownActions } = React25.useMemo(() => {
979
+ return {
980
+ mainActions: actions4.slice(0, mainActionCount),
981
+ dropdownActions: actions4.slice(mainActionCount)
982
+ };
983
+ }, [actions4, mainActionCount]);
984
+ const isDropdownActive = React25.useMemo(() => {
985
+ return dropdownActions.some((action) => action.isActive(editor));
986
+ }, [dropdownActions, editor]);
987
+ return /* @__PURE__ */ React25.createElement(React25.Fragment, null, mainActions.map((action) => /* @__PURE__ */ React25.createElement(
988
+ ToolbarButton,
989
+ {
990
+ key: action.label,
991
+ onClick: () => action.action(editor),
992
+ disabled: !action.canExecute(editor),
993
+ pressed: action.isActive(editor)
994
+ },
995
+ /* @__PURE__ */ React25.createElement(action.icon, { className: "sb-size-5" })
996
+ )), dropdownActions.length > 0 && /* @__PURE__ */ React25.createElement(DropdownMenu, null, /* @__PURE__ */ React25.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React25.createElement(ToolbarButton, { pressed: isDropdownActive }, /* @__PURE__ */ React25.createElement(LuEllipsis, { className: "sb-size-5" }))), /* @__PURE__ */ React25.createElement(DropdownMenuContent, { align: "start" }, dropdownActions.map((action) => /* @__PURE__ */ React25.createElement(
997
+ DropdownMenuItem,
998
+ {
999
+ key: action.label,
1000
+ className: cn("sb-flex sb-flex-row sb-items-center sb-gap-2", {
1001
+ "sb-bg-accent": action.isActive(editor)
1002
+ }),
1003
+ onClick: () => action.action(editor),
1004
+ disabled: !action.canExecute(editor)
1005
+ },
1006
+ /* @__PURE__ */ React25.createElement(action.icon, { className: "sb-size-4" }),
1007
+ /* @__PURE__ */ React25.createElement("span", null, action.label)
1008
+ )))));
1009
+ };
1010
+ var ToolbarButton = React25.forwardRef(({ className, ...props }, ref) => {
1011
+ return /* @__PURE__ */ React25.createElement(
1012
+ Toggle,
1013
+ {
1014
+ size: "sm",
1015
+ className: cn(
1016
+ "sb-size-8 sb-p-0 data-[state=on]:sb-bg-accent",
1017
+ { "sb-bg-accent": props.pressed },
1018
+ className
1019
+ ),
1020
+ ref,
1021
+ ...props
1022
+ }
1023
+ );
1024
+ });
1025
+ ToolbarButton.displayName = "ToolbarButton";
1026
+
1027
+ // src/features/rich-text-editor/components/rich-text-editor.tsx
1028
+ var RichTextEditor = ({
1029
+ value,
1030
+ onChange,
1031
+ className,
1032
+ editorClassName,
1033
+ editorContentClassName,
1034
+ ...props
1035
+ }) => {
1036
+ const editor = useRichTextEditor({
1037
+ value,
1038
+ onUpdate: onChange,
1039
+ editorClassName: cn("sb-flex-1 sb-px-3 sb-py-1", editorClassName),
1040
+ ...props
1041
+ });
1042
+ if (!editor) {
1043
+ return null;
1044
+ }
1045
+ return /* @__PURE__ */ React25.createElement(
1046
+ "div",
1047
+ {
1048
+ className: cn(
1049
+ "sb-flex sb-h-auto sb-min-h-72 sb-w-full sb-flex-col sb-rounded-md sb-border sb-border-input sb-shadow-sm focus-within:sb-border-primary",
1050
+ className
1051
+ )
1052
+ },
1053
+ /* @__PURE__ */ React25.createElement(Toolbar, { editor }),
1054
+ /* @__PURE__ */ React25.createElement(
1055
+ EditorContent,
1056
+ {
1057
+ editor,
1058
+ className: cn(
1059
+ "sb-editflow prose sb-flex sb-flex-1",
1060
+ editorContentClassName
1061
+ )
1062
+ }
1063
+ )
1064
+ );
1065
+ };
1066
+ function Calendar({
1067
+ className,
1068
+ classNames,
1069
+ showOutsideDays = true,
1070
+ ...props
1071
+ }) {
1072
+ return /* @__PURE__ */ React25.createElement(
1073
+ DayPicker,
1074
+ {
1075
+ showOutsideDays,
1076
+ className: cn("sb-p-3 sb-font-roboto", className),
1077
+ classNames: {
1078
+ months: "sb-flex sb-flex-col sm:sb-flex-row sb-space-y-4 sm:sb-space-x-4 sm:sb-space-y-0",
1079
+ month: "sb-space-y-4",
1080
+ caption: "sb-flex sb-justify-center sb-pt-1 sb-relative sb-items-center",
1081
+ caption_label: "sb-text-sm sb-font-medium",
1082
+ nav: "sb-space-x-1 sb-flex sb-items-center",
1083
+ nav_button: cn(
1084
+ buttonVariants({ variant: "outline" }),
1085
+ "sb-h-7 sb-w-7 sb-bg-transparent sb-p-0 sb-opacity-50 hover:sb-opacity-100"
1086
+ ),
1087
+ nav_button_previous: "sb-absolute sb-left-1",
1088
+ nav_button_next: "sb-absolute sb-right-1",
1089
+ table: "sb-w-full sb-border-collapse sb-space-y-1",
1090
+ head_row: "sb-flex",
1091
+ head_cell: "sb-text-muted-foreground sb-rounded-md sb-w-8 sb-font-normal sb-text-[0.8rem]",
1092
+ row: "sb-flex sb-w-full sb-mt-2",
1093
+ cell: cn(
1094
+ "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",
1095
+ 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"
1096
+ ),
1097
+ day: cn(
1098
+ buttonVariants({ variant: "ghost" }),
1099
+ "sb-h-8 sb-w-8 sb-p-0 sb-font-normal aria-selected:sb-opacity-100"
1100
+ ),
1101
+ day_range_start: "day-range-start",
1102
+ day_range_end: "day-range-end",
1103
+ 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",
1104
+ day_today: "sb-bg-accent sb-text-accent-foreground",
1105
+ 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",
1106
+ day_disabled: "sb-text-muted-foreground sb-opacity-50",
1107
+ day_range_middle: "aria-selected:sb-bg-accent aria-selected:sb-text-accent-foreground",
1108
+ day_hidden: "invisible",
1109
+ ...classNames
1110
+ },
1111
+ components: {
1112
+ IconLeft: () => /* @__PURE__ */ React25.createElement(ChevronLeftIcon, { className: "sb-h-4 sb-w-4" }),
1113
+ IconRight: () => /* @__PURE__ */ React25.createElement(ChevronRightIcon, { className: "sb-h-4 sb-w-4" })
1114
+ },
1115
+ ...props
1116
+ }
1117
+ );
1118
+ }
1119
+ Calendar.displayName = "Calendar";
1120
+ var ColorPicker = (props) => {
1121
+ const { color, onColorChange, className } = props;
1122
+ const colors = props.colors ?? [
1123
+ "#000000",
1124
+ "#ffffff",
1125
+ "#0f172a",
1126
+ "#F1F5F9",
1127
+ "#64748B",
1128
+ "#E6007E",
1129
+ "#F8FAFC",
1130
+ "#009DD1",
1131
+ "#FF0000"
1132
+ ];
1133
+ return /* @__PURE__ */ React25.createElement(Popover, null, /* @__PURE__ */ React25.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React25.createElement(
1134
+ Button,
1135
+ {
1136
+ variant: "outline",
1137
+ size: "sm",
1138
+ className: cn(
1139
+ "sb-justify-start sb-text-left sb-font-normal sb-normal-case sb-w-full",
1140
+ !color && "sb-text-muted-foreground",
1141
+ className
1142
+ )
1143
+ },
1144
+ /* @__PURE__ */ React25.createElement("div", { className: "sb-w-full sb-flex sb-items-center sb-gap-2" }, color ? /* @__PURE__ */ React25.createElement(
1145
+ "div",
1146
+ {
1147
+ className: "sb-h-4 sb-w-4 sb-rounded !sb-bg-center !sb-bg-cover sb-transition-all sb-border",
1148
+ style: { background: color }
1149
+ }
1150
+ ) : /* @__PURE__ */ React25.createElement(PaintbrushIcon, { className: "sb-h-4 sb-w-4" }), /* @__PURE__ */ React25.createElement("div", { className: "sb-truncate sb-flex-1" }, color ? color : "Kies een kleur"))
1151
+ )), /* @__PURE__ */ React25.createElement(PopoverContent, { className: "sb-w-64 sb-p-4 sb-flex sb-flex-wrap sb-gap-1" }, colors.map((s) => /* @__PURE__ */ React25.createElement(
1152
+ "div",
1153
+ {
1154
+ key: s,
1155
+ style: { background: s },
1156
+ className: "sb-rounded-md sb-h-6 sb-w-6 sb-cursor-pointer active:sb-scale-105 sb-border",
1157
+ onClick: () => onColorChange(s)
1158
+ }
1159
+ ))));
1160
+ };
1161
+ var MediaInput = (props) => {
1162
+ const { onFilesChange, limit = 32, multiple = false, onError } = props;
1163
+ const id = React25.useId();
1164
+ const [queue, setQueue] = React25.useState([]);
1165
+ const [sources, setSources] = React25.useState(props.files ?? []);
1166
+ const maxConcurrentUploads = 3;
1167
+ const uploadingCountRef = React25.useRef(0);
1168
+ const handleFilesAdd = async (e) => {
1169
+ const files = e.target.files;
1170
+ if (!files || files.length === 0) {
1171
+ return;
1172
+ }
1173
+ if (files.length + sources.length > (multiple ? limit : 1)) {
1174
+ onError?.(
1175
+ new MediaInputError(
1176
+ `Maximaal ${limit} bestanden.`,
1177
+ `Je probeerde nu ${files.length + sources.length} bestanden toe te voegen, maar je mag er maximaal ${limit} toevoegen.`
1178
+ )
1179
+ );
1180
+ return;
1181
+ }
1182
+ const queue2 = Array.from(files);
1183
+ setQueue(queue2);
1184
+ for (const file of queue2) {
1185
+ try {
1186
+ while (uploadingCountRef.current >= maxConcurrentUploads && uploadingCountRef.current > 0) {
1187
+ await new Promise((resolve) => setTimeout(resolve, 300));
1188
+ }
1189
+ uploadingCountRef.current++;
1190
+ const formData = new FormData();
1191
+ formData.append("file", file);
1192
+ const res = await fetch("/api/simple-builder/file/upload", {
1193
+ method: "POST",
1194
+ body: formData
1195
+ });
1196
+ if (res === void 0 || !res.ok) {
1197
+ onError?.(
1198
+ new MediaInputError(
1199
+ "Bestand uploaden misulukt",
1200
+ `Bestand ${file.name} kon niet worden ge\xFCpload.`
1201
+ )
1202
+ );
1203
+ continue;
1204
+ }
1205
+ const { data: url } = await res.json();
1206
+ if (!url) {
1207
+ onError?.(
1208
+ new MediaInputError(
1209
+ "Bestand uploaden misulukt",
1210
+ `De URL van bestand ${file.name} kon niet worden opgehaald.`
1211
+ )
1212
+ );
1213
+ continue;
1214
+ }
1215
+ setSources((prev) => [...prev, url]);
1216
+ onFilesChange?.([...sources, url]);
1217
+ } catch (e2) {
1218
+ onError?.(
1219
+ new MediaInputError(
1220
+ "Bestand uploaden misulukt",
1221
+ `Bestand ${file.name} kon niet worden ge\xFCpload.`
1222
+ )
1223
+ );
1224
+ } finally {
1225
+ setQueue((prev) => prev.filter((f) => f !== file));
1226
+ uploadingCountRef.current--;
1227
+ }
1228
+ }
1229
+ };
1230
+ const handleSourceDelete = async (src) => {
1231
+ setSources((prev) => prev.filter((s) => s !== src));
1232
+ onFilesChange?.(sources.filter((s) => s !== src));
1233
+ await fetch("/api/uploadthing/delete", {
1234
+ method: "POST",
1235
+ body: JSON.stringify({ src })
1236
+ });
1237
+ };
1238
+ return /* @__PURE__ */ React25.createElement("div", { className: cn("flex flex-wrap gap-4", props.className) }, sources.map((src) => /* @__PURE__ */ React25.createElement(MediaInputItem, { key: src, className: cn("group", props.itemClassName) }, /* @__PURE__ */ React25.createElement(
1239
+ Image,
1240
+ {
1241
+ src,
1242
+ alt: "",
1243
+ fill: true,
1244
+ className: "sb-absolute sb-inset-0 sb-object-cover sb-pointer-events-none"
1245
+ }
1246
+ ), /* @__PURE__ */ React25.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__ */ React25.createElement(
1247
+ "button",
1248
+ {
1249
+ 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",
1250
+ onClick: () => handleSourceDelete(src)
1251
+ },
1252
+ /* @__PURE__ */ React25.createElement(Trash2Icon, { className: "sb-h-4 sb-w-4" })
1253
+ )))), queue.map((_, i) => /* @__PURE__ */ React25.createElement(
1254
+ MediaInputItem,
1255
+ {
1256
+ key: i,
1257
+ className: cn(
1258
+ "sb-flex sb-h-28 sb-w-28 sb-items-center sb-justify-center",
1259
+ props.itemClassName
1260
+ )
1261
+ },
1262
+ /* @__PURE__ */ React25.createElement(Loader2Icon, { className: "sb-h-6 sb-w-6 sb-animate-spin" })
1263
+ )), multiple || !multiple && !sources.length && !queue.length ? /* @__PURE__ */ React25.createElement(
1264
+ "label",
1265
+ {
1266
+ htmlFor: id,
1267
+ className: cn(
1268
+ "sb-flex sb-h-28 sb-w-28 sb-cursor-pointer sb-items-center sb-justify-center sb-rounded-lg sb-border",
1269
+ props.itemClassName
1270
+ )
1271
+ },
1272
+ /* @__PURE__ */ React25.createElement(PlusIcon, { className: "sb-h-6 sb-w-6" }),
1273
+ /* @__PURE__ */ React25.createElement(
1274
+ "input",
1275
+ {
1276
+ id,
1277
+ type: "file",
1278
+ onChange: handleFilesAdd,
1279
+ multiple,
1280
+ accept: ".png,.jpg,.jpeg,.webp,.gif,.svg",
1281
+ className: "sb-hidden"
1282
+ }
1283
+ )
1284
+ ) : null);
1285
+ };
1286
+ var MediaInputItem = (props) => {
1287
+ return /* @__PURE__ */ React25.createElement(
1288
+ "div",
1289
+ {
1290
+ className: cn(
1291
+ "sb-relative sb-h-28 sb-w-28 sb-overflow-hidden sb-rounded-lg sb-border",
1292
+ props.className
1293
+ )
1294
+ },
1295
+ props.children
1296
+ );
1297
+ };
1298
+ var MediaInputError = class extends Error {
1299
+ title;
1300
+ description;
1301
+ constructor(message, description) {
1302
+ super(message);
1303
+ this.title = message;
1304
+ this.description = description;
1305
+ }
1306
+ };
1307
+ var Select = SelectPrimitive.Root;
1308
+ var SelectValue = SelectPrimitive.Value;
1309
+ var SelectTrigger = React25.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React25.createElement(
1310
+ SelectPrimitive.Trigger,
1311
+ {
1312
+ ref,
1313
+ className: cn(
1314
+ "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",
1315
+ className
1316
+ ),
1317
+ ...props
1318
+ },
1319
+ children,
1320
+ /* @__PURE__ */ React25.createElement(SelectPrimitive.Icon, { asChild: true }, /* @__PURE__ */ React25.createElement(ChevronDown, { className: "sb-h-4 sb-w-4 sb-opacity-50" }))
1321
+ ));
1322
+ SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
1323
+ var SelectScrollUpButton = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
1324
+ SelectPrimitive.ScrollUpButton,
1325
+ {
1326
+ ref,
1327
+ className: cn(
1328
+ "sb-flex sb-cursor-default sb-items-center sb-justify-center sb-py-1",
1329
+ className
1330
+ ),
1331
+ ...props
1332
+ },
1333
+ /* @__PURE__ */ React25.createElement(ChevronUp, { className: "sb-h-4 sb-w-4" })
1334
+ ));
1335
+ SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
1336
+ var SelectScrollDownButton = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
1337
+ SelectPrimitive.ScrollDownButton,
1338
+ {
1339
+ ref,
1340
+ className: cn(
1341
+ "sb-flex sb-cursor-default sb-items-center sb-justify-center sb-py-1",
1342
+ className
1343
+ ),
1344
+ ...props
1345
+ },
1346
+ /* @__PURE__ */ React25.createElement(ChevronDown, { className: "sb-h-4 sb-w-4" })
1347
+ ));
1348
+ SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
1349
+ var SelectContent = React25.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ React25.createElement(SelectPrimitive.Portal, null, /* @__PURE__ */ React25.createElement(
1350
+ SelectPrimitive.Content,
1351
+ {
1352
+ ref,
1353
+ className: cn(
1354
+ "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",
1355
+ 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",
1356
+ className
1357
+ ),
1358
+ position,
1359
+ ...props
1360
+ },
1361
+ /* @__PURE__ */ React25.createElement(SelectScrollUpButton, null),
1362
+ /* @__PURE__ */ React25.createElement(
1363
+ SelectPrimitive.Viewport,
1364
+ {
1365
+ className: cn(
1366
+ "sb-p-1",
1367
+ position === "popper" && "sb-h-[var(--radix-select-trigger-height)] sb-w-full sb-min-w-[var(--radix-select-trigger-width)]"
1368
+ )
1369
+ },
1370
+ children
1371
+ ),
1372
+ /* @__PURE__ */ React25.createElement(SelectScrollDownButton, null)
1373
+ )));
1374
+ SelectContent.displayName = SelectPrimitive.Content.displayName;
1375
+ var SelectLabel = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
1376
+ SelectPrimitive.Label,
1377
+ {
1378
+ ref,
1379
+ className: cn(
1380
+ "sb-py-1.5 sb-pl-8 sb-pr-2 sb-text-sm sb-font-semibold",
1381
+ className
1382
+ ),
1383
+ ...props
1384
+ }
1385
+ ));
1386
+ SelectLabel.displayName = SelectPrimitive.Label.displayName;
1387
+ var SelectItem = React25.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React25.createElement(
1388
+ SelectPrimitive.Item,
1389
+ {
1390
+ ref,
1391
+ className: cn(
1392
+ "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",
1393
+ className
1394
+ ),
1395
+ ...props
1396
+ },
1397
+ /* @__PURE__ */ React25.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__ */ React25.createElement(SelectPrimitive.ItemIndicator, null, /* @__PURE__ */ React25.createElement(Check, { className: "sb-h-4 sb-w-4" }))),
1398
+ /* @__PURE__ */ React25.createElement(SelectPrimitive.ItemText, null, children)
1399
+ ));
1400
+ SelectItem.displayName = SelectPrimitive.Item.displayName;
1401
+ var SelectSeparator = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
1402
+ SelectPrimitive.Separator,
1403
+ {
1404
+ ref,
1405
+ className: cn("sb--mx-1 sb-my-1 sb-h-px sb-bg-muted", className),
1406
+ ...props
1407
+ }
1408
+ ));
1409
+ SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
1410
+ var Textarea = React25.forwardRef(
1411
+ ({ className, ...props }, ref) => {
1412
+ return /* @__PURE__ */ React25.createElement(
1413
+ "textarea",
1414
+ {
1415
+ className: cn(
1416
+ "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",
1417
+ className
1418
+ ),
1419
+ ref,
1420
+ ...props
1421
+ }
1422
+ );
1423
+ }
1424
+ );
1425
+ Textarea.displayName = "Textarea";
1426
+
1427
+ // src/components/container-item-form.tsx
1428
+ var ContainerItemForm = (props) => {
1429
+ const { item } = props;
1430
+ const { patchItem } = useBuilder();
1431
+ const component = builder.getComponent(item.component);
1432
+ if (!component) {
1433
+ throw new Error(
1434
+ `[simple-builder]: Component with id ${item.component} not found in container item form component`
1435
+ );
1436
+ }
1437
+ const form = useForm({
1438
+ defaultValues: (component.inputs || []).reduce(
1439
+ (acc, input) => ({
1440
+ ...acc,
1441
+ [input.name]: item?.props?.[input.name] ?? input.defaultValue
1442
+ }),
1443
+ {}
1444
+ )
1445
+ });
1446
+ const onSubmit = (values) => {
1447
+ patchItem(item.id, {
1448
+ props: values
1449
+ });
1450
+ };
1451
+ React25.useEffect(() => {
1452
+ const subscription = form.watch(() => form.handleSubmit(onSubmit)());
1453
+ return () => subscription.unsubscribe();
1454
+ }, [form.watch, form.handleSubmit]);
1455
+ return /* @__PURE__ */ React25.createElement(Form, { ...form }, /* @__PURE__ */ React25.createElement("form", { onSubmit: form.handleSubmit(onSubmit) }, /* @__PURE__ */ React25.createElement("div", { className: "sb-space-y-4 sb-p-4" }, (component.inputs || []).map((input) => /* @__PURE__ */ React25.createElement(
1456
+ RenderFormField,
1457
+ {
1458
+ key: input.name,
1459
+ type: input.type,
1460
+ input,
1461
+ form
1462
+ }
1463
+ )))));
1464
+ };
1465
+ var RenderFormField = (props) => {
1466
+ const { type, input, form } = props;
1467
+ const fieldArray = useFieldArray({
1468
+ control: form.control,
1469
+ name: input.name
1470
+ });
1471
+ if (input.multiple) {
1472
+ return /* @__PURE__ */ React25.createElement("fieldset", { className: "sb-space-y-2" }, /* @__PURE__ */ React25.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React25.createElement("div", { className: "sb-space-y-4" }, fieldArray.fields.map(
1473
+ (field, i) => type !== "grouped" ? /* @__PURE__ */ React25.createElement(
1474
+ FormField,
1475
+ {
1476
+ key: field.id,
1477
+ control: form.control,
1478
+ name: `${input.name}.${i}`,
1479
+ render: ({ field: field2 }) => /* @__PURE__ */ React25.createElement("div", { className: "sb-flex sb-items-center sb-gap-3" }, /* @__PURE__ */ React25.createElement(RenderInput, { field: field2, type: input.type }), /* @__PURE__ */ React25.createElement("button", { type: "button", onClick: () => fieldArray.remove(i) }, /* @__PURE__ */ React25.createElement(XIcon, { className: "sb-h-4 sb-w-4" })))
1480
+ }
1481
+ ) : /* @__PURE__ */ React25.createElement("div", { className: "sb-flex sb-items-center sb-relative" }, /* @__PURE__ */ React25.createElement(
1482
+ RenderFormField,
1483
+ {
1484
+ key: field.id,
1485
+ form,
1486
+ type,
1487
+ input: {
1488
+ ...input,
1489
+ name: `${input.name}.${i}`,
1490
+ multiple: false,
1491
+ friendlyName: ""
1492
+ }
1493
+ }
1494
+ ), /* @__PURE__ */ React25.createElement(
1495
+ "button",
1496
+ {
1497
+ type: "button",
1498
+ onClick: () => fieldArray.remove(i),
1499
+ className: "sb-absolute sb-top-2 sb-right-2 sb-text-foreground/70 hover:sb-text-foreground"
1500
+ },
1501
+ /* @__PURE__ */ React25.createElement(XIcon, { className: "sb-h-4 sb-w-4" })
1502
+ ))
1503
+ ), /* @__PURE__ */ React25.createElement(
1504
+ Button,
1505
+ {
1506
+ type: "button",
1507
+ variant: "outline",
1508
+ size: "sm",
1509
+ className: cn(
1510
+ "sb-w-[89%] sb-border-2 sb-border-dashed sb-text-muted-foreground",
1511
+ type === "grouped" && "sb-w-full"
1512
+ ),
1513
+ onClick: () => fieldArray.append(void 0)
1514
+ },
1515
+ /* @__PURE__ */ React25.createElement(PlusCircleIcon, { className: "sb-h-4 sb-w-4" })
1516
+ )));
1517
+ }
1518
+ switch (type) {
1519
+ case "string":
1520
+ case "number":
1521
+ case "longText":
1522
+ case "color":
1523
+ case "date":
1524
+ case "file":
1525
+ return /* @__PURE__ */ React25.createElement(
1526
+ FormField,
1527
+ {
1528
+ key: input.name,
1529
+ control: form.control,
1530
+ name: input.name,
1531
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, null, /* @__PURE__ */ React25.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(RenderInput, { type, field, options: input?.enum })), input.helperText && /* @__PURE__ */ React25.createElement(FormDescription, null, input.helperText), /* @__PURE__ */ React25.createElement(FormMessage, null))
1532
+ }
1533
+ );
1534
+ case "richText":
1535
+ return /* @__PURE__ */ React25.createElement(Dialog, null, /* @__PURE__ */ React25.createElement("div", { className: "sb-space-y-2" }, /* @__PURE__ */ React25.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React25.createElement(DialogTrigger, { asChild: true }, /* @__PURE__ */ React25.createElement(Button, { variant: "outline", className: "sb-w-full" }, input.friendlyName || input.name, " bewerken"))), /* @__PURE__ */ React25.createElement(DialogContent, { className: "sb-max-w-3xl sb-p-0" }, /* @__PURE__ */ React25.createElement("div", { className: "sb-flex sb-h-full sb-max-h-svh sb-w-full sb-flex-col sm:sb-max-h-[90svh]" }, /* @__PURE__ */ React25.createElement(DialogHeader, { className: "sb-flex-none sb-border-b sb-p-6" }, /* @__PURE__ */ React25.createElement(DialogTitle, null, input.friendlyName || input.name, " editor")), /* @__PURE__ */ React25.createElement("div", { className: "sb-flex-1 sb-overflow-y-auto" }, /* @__PURE__ */ React25.createElement(
1536
+ FormField,
1537
+ {
1538
+ key: input.name,
1539
+ control: form.control,
1540
+ name: input.name,
1541
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, null, /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(RenderInput, { type, field })), input.helperText && /* @__PURE__ */ React25.createElement(FormDescription, null, input.helperText), /* @__PURE__ */ React25.createElement(FormMessage, null))
1542
+ }
1543
+ )))));
1544
+ case "boolean":
1545
+ return /* @__PURE__ */ React25.createElement(
1546
+ FormField,
1547
+ {
1548
+ key: input.name,
1549
+ control: form.control,
1550
+ name: input.name,
1551
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, { className: "sb-flex sb-flex-row sb-items-center sb-justify-between sb-space-y-0" }, /* @__PURE__ */ React25.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(RenderInput, { type, field })), input.helperText && /* @__PURE__ */ React25.createElement(FormDescription, null, input.helperText), /* @__PURE__ */ React25.createElement(FormMessage, null))
1552
+ }
1553
+ );
1554
+ case "grouped":
1555
+ return /* @__PURE__ */ React25.createElement("div", { className: "sb-space-y-2 sb-w-full" }, input.friendlyName !== "" && /* @__PURE__ */ React25.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React25.createElement("div", { className: "sb-space-y-2 sb-p-3 sb-w-full sb-border sb-rounded-lg" }, input.inputs.map((sub) => /* @__PURE__ */ React25.createElement(
1556
+ RenderFormField,
1557
+ {
1558
+ key: `${input.name}.${sub.name}`,
1559
+ type: sub.type,
1560
+ input: {
1561
+ ...sub,
1562
+ name: `${input.name}.${sub.name}`
1563
+ },
1564
+ form
1565
+ }
1566
+ ))));
1567
+ default:
1568
+ throw new Error(
1569
+ `[simple-builder]: Input type "${props.type}" not supported in render form field.`
1570
+ );
1571
+ }
1572
+ };
1573
+ var RenderInput = (props) => {
1574
+ const { type, options, field } = props;
1575
+ switch (type) {
1576
+ case "string":
1577
+ if (!options)
1578
+ return /* @__PURE__ */ React25.createElement(Input, { ...field });
1579
+ return /* @__PURE__ */ React25.createElement(Select, { onValueChange: field.onChange, defaultValue: field.value }, /* @__PURE__ */ React25.createElement(SelectTrigger, null, /* @__PURE__ */ React25.createElement(SelectValue, null)), /* @__PURE__ */ React25.createElement(SelectContent, null, options.map((option) => /* @__PURE__ */ React25.createElement(SelectItem, { key: option, value: option }, option))));
1580
+ case "longText":
1581
+ return /* @__PURE__ */ React25.createElement(Textarea, { ...field });
1582
+ case "richText":
1583
+ return /* @__PURE__ */ React25.createElement(RichTextEditor, { ...field });
1584
+ case "number":
1585
+ return /* @__PURE__ */ React25.createElement(Input, { type: "number", ...field });
1586
+ case "color":
1587
+ return /* @__PURE__ */ React25.createElement(ColorPicker, { color: field.value, onColorChange: field.onChange });
1588
+ case "date":
1589
+ return /* @__PURE__ */ React25.createElement(Popover, null, /* @__PURE__ */ React25.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React25.createElement(
1590
+ Button,
1591
+ {
1592
+ variant: "outline",
1593
+ size: "sm",
1594
+ className: cn(
1595
+ "sb-w-full sb-flex sb-justify-start sb-text-left sb-font-normal",
1596
+ !field.value && "sb-text-muted-foreground"
1597
+ )
1598
+ },
1599
+ /* @__PURE__ */ React25.createElement(CalendarIcon, { className: "sb-mr-2 sb-h-4 sb-w-4" }),
1600
+ field.value && !Array.isArray(field.value) ? format(field.value, "PPP") : /* @__PURE__ */ React25.createElement("span", null, "Pick a date")
1601
+ )), /* @__PURE__ */ React25.createElement(PopoverContent, { className: "sb-w-auto sb-p-0", align: "start" }, /* @__PURE__ */ React25.createElement(
1602
+ Calendar,
1603
+ {
1604
+ mode: "single",
1605
+ selected: field.value,
1606
+ onSelect: field.onChange,
1607
+ initialFocus: true
1608
+ }
1609
+ )));
1610
+ case "boolean":
1611
+ return /* @__PURE__ */ React25.createElement(Switch, { checked: field.value, onCheckedChange: field.onChange });
1612
+ case "file":
1613
+ return /* @__PURE__ */ React25.createElement(
1614
+ MediaInput,
1615
+ {
1616
+ className: "sb-grid sb-grid-cols-2 sb-gap-1",
1617
+ itemClassName: "sb-aspect-video sb-h-auto sb-w-full",
1618
+ multiple: false,
1619
+ files: field.value ? [field.value] : [],
1620
+ onFilesChange: (files) => field.onChange(files[0]),
1621
+ onError: (e) => console.error(
1622
+ "[media-input]: Title: " + e?.title,
1623
+ "media-input: Error: " + e?.description
1624
+ )
1625
+ }
1626
+ );
1627
+ default:
1628
+ throw new Error(
1629
+ `[simple-builder]: Input type "${props.type}" not supported in render input.`
1630
+ );
1631
+ }
1632
+ };
1633
+ var Tabs = TabsPrimitive.Root;
1634
+ var tabsListVariants = tv({
1635
+ variants: {
1636
+ variant: {
1637
+ 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",
1638
+ text: "sb-flex sb-items-center sb-border-b sb-px-4 sb-space-x-6"
1639
+ }
1640
+ },
1641
+ defaultVariants: {
1642
+ variant: "contained"
1643
+ }
1644
+ });
1645
+ var TabsList = React25.forwardRef(({ variant, className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
1646
+ TabsPrimitive.List,
1647
+ {
1648
+ ref,
1649
+ className: tabsListVariants({ variant, className }),
1650
+ ...props
1651
+ }
1652
+ ));
1653
+ TabsList.displayName = TabsPrimitive.List.displayName;
1654
+ var tabsTriggerVariants = tv({
1655
+ variants: {
1656
+ variant: {
1657
+ 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",
1658
+ 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"
1659
+ }
1660
+ },
1661
+ defaultVariants: {
1662
+ variant: "contained"
1663
+ }
1664
+ });
1665
+ var TabsTrigger = React25.forwardRef(({ variant, className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
1666
+ TabsPrimitive.Trigger,
1667
+ {
1668
+ ref,
1669
+ className: tabsTriggerVariants({ variant, className }),
1670
+ ...props
1671
+ }
1672
+ ));
1673
+ TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
1674
+ var TabsContent = React25.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25.createElement(
1675
+ TabsPrimitive.Content,
1676
+ {
1677
+ ref,
1678
+ className: cn(
1679
+ "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",
1680
+ className
1681
+ ),
1682
+ ...props
1683
+ }
1684
+ ));
1685
+ TabsContent.displayName = TabsPrimitive.Content.displayName;
1686
+
1687
+ // src/components/ui/background-picker.tsx
1688
+ var BackgroundPicker = (props) => {
1689
+ const { background, onBackgroundChange, className } = props;
1690
+ const solids = props.solids ?? [
1691
+ "#000000",
1692
+ "#ffffff",
1693
+ "#0f172a",
1694
+ "#F1F5F9",
1695
+ "#64748B",
1696
+ "#E6007E",
1697
+ "#F8FAFC",
1698
+ "#009DD1",
1699
+ "#FF0000"
1700
+ ];
1701
+ const gradients = props.gradients ?? [
1702
+ "linear-gradient(to top left,#accbee,#e7f0fd)",
1703
+ "linear-gradient(to top left,#d5d4d0,#d5d4d0,#eeeeec)"
1704
+ ];
1705
+ const images = props.images ?? [
1706
+ "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)",
1707
+ "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)"
1708
+ ];
1709
+ const defaultTab = React25.useMemo(() => {
1710
+ if (background.includes("url"))
1711
+ return "image";
1712
+ if (background.includes("gradient"))
1713
+ return "gradient";
1714
+ return "solid";
1715
+ }, [background]);
1716
+ return /* @__PURE__ */ React25.createElement(Popover, null, /* @__PURE__ */ React25.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React25.createElement(
1717
+ Button,
1718
+ {
1719
+ variant: "outline",
1720
+ size: "sm",
1721
+ className: cn(
1722
+ "sb-justify-start sb-text-left sb-font-normal sb-normal-case sb-w-full",
1723
+ !background && "sb-text-muted-foreground",
1724
+ className
1725
+ )
1726
+ },
1727
+ /* @__PURE__ */ React25.createElement("div", { className: "sb-w-full sb-flex sb-items-center sb-gap-2" }, background ? /* @__PURE__ */ React25.createElement(
1728
+ "div",
1729
+ {
1730
+ className: "sb-h-4 sb-w-4 sb-rounded !sb-bg-center !sb-bg-cover sb-transition-all sb-border",
1731
+ style: { background }
1732
+ }
1733
+ ) : /* @__PURE__ */ React25.createElement(PaintbrushIcon, { className: "sb-h-4 sb-w-4" }), /* @__PURE__ */ React25.createElement("div", { className: "sb-truncate sb-flex-1" }, background ? background : "Kies een achtergrond"))
1734
+ )), /* @__PURE__ */ React25.createElement(PopoverContent, { className: "sb-w-64 sb-p-0" }, /* @__PURE__ */ React25.createElement(Tabs, { defaultValue: defaultTab }, /* @__PURE__ */ React25.createElement(TabsList, { className: "sb-w-full" }, /* @__PURE__ */ React25.createElement(TabsTrigger, { className: "sb-flex-1", value: "solid" }, "Solid"), /* @__PURE__ */ React25.createElement(TabsTrigger, { className: "sb-flex-1", value: "gradient" }, "Gradient"), /* @__PURE__ */ React25.createElement(TabsTrigger, { className: "sb-flex-1", value: "image" }, "Image")), /* @__PURE__ */ React25.createElement(
1735
+ TabsContent,
1736
+ {
1737
+ value: "solid",
1738
+ className: "data-[state=active]:sb-flex sb-flex-wrap sb-gap-1 sb-p-4"
1739
+ },
1740
+ solids.map((s) => /* @__PURE__ */ React25.createElement(
1741
+ "div",
1742
+ {
1743
+ key: s,
1744
+ style: { background: s },
1745
+ className: "sb-rounded-md sb-h-6 sb-w-6 sb-cursor-pointer active:sb-scale-105 sb-border",
1746
+ onClick: () => onBackgroundChange(s)
1747
+ }
1748
+ ))
1749
+ ), /* @__PURE__ */ React25.createElement(
1750
+ TabsContent,
1751
+ {
1752
+ value: "gradient",
1753
+ className: "data-[state=active]:sb-flex sb-flex-wrap sb-gap-1 sb-p-4"
1754
+ },
1755
+ gradients.map((s) => /* @__PURE__ */ React25.createElement(
1756
+ "div",
1757
+ {
1758
+ key: s,
1759
+ style: { background: s },
1760
+ className: "rounded-md h-6 w-6 cursor-pointer active:scale-105 border",
1761
+ onClick: () => onBackgroundChange(s)
1762
+ }
1763
+ ))
1764
+ ), /* @__PURE__ */ React25.createElement(TabsContent, { value: "image" }, /* @__PURE__ */ React25.createElement("div", { className: "sb-p-4 sb-border-b" }, /* @__PURE__ */ React25.createElement(
1765
+ MediaInput,
1766
+ {
1767
+ className: "sb-grid sb-grid-cols-2 sb-gap-1",
1768
+ itemClassName: "sb-aspect-video sb-h-auto sb-w-full",
1769
+ multiple: false,
1770
+ onFilesChange: (files) => {
1771
+ if (!files.length)
1772
+ return;
1773
+ onBackgroundChange(`url(${files[0]})`);
1774
+ },
1775
+ onError: (e) => console.error(
1776
+ "[media-input]: Title: " + e?.title,
1777
+ "media-input: Error: " + e?.description
1778
+ )
1779
+ }
1780
+ )), /* @__PURE__ */ React25.createElement("div", { className: "sb-grid sb-grid-cols-2 sb-gap-1 sb-p-4" }, images.map((s) => /* @__PURE__ */ React25.createElement(
1781
+ "div",
1782
+ {
1783
+ key: s,
1784
+ style: { backgroundImage: s },
1785
+ 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",
1786
+ onClick: () => onBackgroundChange(s)
1787
+ }
1788
+ )))))));
1789
+ };
1790
+ var SpacingInput = (props) => {
1791
+ const [value, setValue] = React25.useState(parse(props.value || "0px"));
1792
+ const [indipendent, setIndipendent] = React25.useState(
1793
+ isIndipendent(parse(props.value || "0px"))
1794
+ );
1795
+ React25.useEffect(() => {
1796
+ if (!props.onChange)
1797
+ return;
1798
+ props.onChange(stringify(value));
1799
+ }, [value, props.onChange]);
1800
+ return /* @__PURE__ */ React25.createElement("div", { className: "sb-grid sb-grid-cols-[1fr,auto] sb-gap-3" }, /* @__PURE__ */ React25.createElement("div", { className: "sb-grid sb-grid-cols-2 sb-items-center sb-gap-3" }, !indipendent ? /* @__PURE__ */ React25.createElement(React25.Fragment, null, /* @__PURE__ */ React25.createElement(
1801
+ AdvancedInput,
1802
+ {
1803
+ value: value.left,
1804
+ pattern: "\\d+",
1805
+ onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, left: +value2, right: +value2 })),
1806
+ prepend: /* @__PURE__ */ React25.createElement(AlignHorizontalSpaceAroundIcon, { className: "sb-h-4 sb-w-4" }),
1807
+ append: /* @__PURE__ */ React25.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1808
+ }
1809
+ ), /* @__PURE__ */ React25.createElement(
1810
+ AdvancedInput,
1811
+ {
1812
+ value: value.top,
1813
+ pattern: "\\d+",
1814
+ onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, top: +value2, bottom: +value2 })),
1815
+ prepend: /* @__PURE__ */ React25.createElement(AlignHorizontalSpaceAroundIcon, { className: "sb-h-4 sb-w-4 sb-rotate-90" }),
1816
+ append: /* @__PURE__ */ React25.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1817
+ }
1818
+ )) : /* @__PURE__ */ React25.createElement(React25.Fragment, null, /* @__PURE__ */ React25.createElement(
1819
+ AdvancedInput,
1820
+ {
1821
+ value: value.left,
1822
+ pattern: "\\d+",
1823
+ onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, left: +value2 })),
1824
+ prepend: /* @__PURE__ */ React25.createElement(AlignHorizontalJustifyStartIcon, { className: "sb-h-4 sb-w-4" }),
1825
+ append: /* @__PURE__ */ React25.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1826
+ }
1827
+ ), /* @__PURE__ */ React25.createElement(
1828
+ AdvancedInput,
1829
+ {
1830
+ value: value.top,
1831
+ pattern: "\\d+",
1832
+ onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, top: +value2 })),
1833
+ prepend: /* @__PURE__ */ React25.createElement(AlignHorizontalJustifyStartIcon, { className: "sb-h-4 sb-w-4 sb-rotate-90" }),
1834
+ append: /* @__PURE__ */ React25.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1835
+ }
1836
+ ), /* @__PURE__ */ React25.createElement(
1837
+ AdvancedInput,
1838
+ {
1839
+ value: value.right,
1840
+ pattern: "\\d+",
1841
+ onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, right: +value2 })),
1842
+ prepend: /* @__PURE__ */ React25.createElement(AlignHorizontalJustifyStartIcon, { className: "sb-h-4 sb-w-4 sb-rotate-180" }),
1843
+ append: /* @__PURE__ */ React25.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1844
+ }
1845
+ ), /* @__PURE__ */ React25.createElement(
1846
+ AdvancedInput,
1847
+ {
1848
+ value: value.bottom,
1849
+ pattern: "\\d+",
1850
+ onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, bottom: +value2 })),
1851
+ prepend: /* @__PURE__ */ React25.createElement(AlignHorizontalJustifyStartIcon, { className: "sb-h-4 sb-w-4 sb--rotate-90" }),
1852
+ append: /* @__PURE__ */ React25.createElement("span", { className: "sb-text-muted-foreground" }, "px")
1853
+ }
1854
+ ))), /* @__PURE__ */ React25.createElement("div", { className: "sb-shrink-0" }, /* @__PURE__ */ React25.createElement(
1855
+ Toggle,
1856
+ {
1857
+ className: "sb-shrink-0 sb-flex sb-w-8 sb-h-8 sb-p-0",
1858
+ variant: "outline",
1859
+ size: "sm",
1860
+ pressed: indipendent,
1861
+ onPressedChange: setIndipendent
1862
+ },
1863
+ /* @__PURE__ */ React25.createElement(ScanIcon, { className: "sb-h-4 sb-w-4" })
1864
+ )));
1865
+ };
1866
+ var isIndipendent = (value) => {
1867
+ const { top, right, bottom, left } = value;
1868
+ return top !== bottom || right !== left;
1869
+ };
1870
+ var parse = (value) => {
1871
+ const matches = value.match(/(\d+)/gm);
1872
+ const [top = 0, right = 0, bottom = 0, left = 0] = matches?.map((match) => +match) || [];
1873
+ switch (matches?.length) {
1874
+ case 1:
1875
+ return { top, right: top, bottom: top, left: top };
1876
+ case 2:
1877
+ return { top, bottom: top, left: right, right };
1878
+ case 3:
1879
+ return { top, right, left: right, bottom };
1880
+ default:
1881
+ return { top, right, bottom, left };
1882
+ }
1883
+ };
1884
+ var stringify = (value) => {
1885
+ const { top, right, bottom, left } = value;
1886
+ if (top === right && top === bottom && top === left) {
1887
+ return `${top}px`;
1888
+ }
1889
+ if (top === bottom && right === left) {
1890
+ return `${top}px ${right}px`;
1891
+ }
1892
+ if (right === left) {
1893
+ return `${top}px ${right}px ${bottom}px`;
1894
+ }
1895
+ return `${top}px ${right}px ${bottom}px ${left}px`;
1896
+ };
1897
+
1898
+ // src/components/item-design-form.tsx
1899
+ var designSchema = z.object({
1900
+ container: z.coerce.boolean(),
1901
+ hidden: z.enum(["always", "mobile", "desktop", "never"]),
1902
+ desktop: z.object({
1903
+ background: z.string(),
1904
+ color: z.string(),
1905
+ padding: z.string(),
1906
+ margin: z.string()
1907
+ }),
1908
+ mobile: z.object({
1909
+ background: z.string(),
1910
+ color: z.string(),
1911
+ padding: z.string(),
1912
+ margin: z.string()
1913
+ })
1914
+ });
1915
+ var ItemDesignForm = (props) => {
1916
+ const { item } = props;
1917
+ const component = builder.getComponent(item.component);
1918
+ if (!component) {
1919
+ throw new Error(
1920
+ `[simple-builder]: Component "${item.component}" not found`
1921
+ );
1922
+ }
1923
+ const getDefaultDeviceValue = (params) => {
1924
+ const { device: device2 = "desktop", key, fallback = "" } = params;
1925
+ if (item.styles?.[device2]?.[key] !== void 0) {
1926
+ return item.styles[device2][key];
1927
+ }
1928
+ if (component.defaultStyles?.[device2]?.[key] !== void 0) {
1929
+ return component.defaultStyles[device2][key];
1930
+ }
1931
+ if (device2 === "mobile") {
1932
+ const desktopValue = getDefaultDeviceValue({
1933
+ ...params,
1934
+ device: "desktop"
1935
+ });
1936
+ if (desktopValue !== void 0) {
1937
+ return desktopValue;
1938
+ }
1939
+ }
1940
+ return fallback;
1941
+ };
1942
+ const getDefaultDeviceValues = (device2) => {
1943
+ return {
1944
+ background: getDefaultDeviceValue({ device: device2, key: "background" }),
1945
+ color: getDefaultDeviceValue({ device: device2, key: "color" }),
1946
+ padding: getDefaultDeviceValue({ device: device2, key: "padding" }),
1947
+ margin: getDefaultDeviceValue({ device: device2, key: "margin" })
1948
+ };
1949
+ };
1950
+ const form = useForm({
1951
+ resolver: zodResolver(designSchema),
1952
+ values: {
1953
+ container: item.styles?.container ?? true,
1954
+ hidden: item.styles?.hidden ?? "never",
1955
+ desktop: getDefaultDeviceValues("desktop"),
1956
+ mobile: getDefaultDeviceValues("mobile")
1957
+ }
1958
+ });
1959
+ const { patchItem } = useBuilder();
1960
+ const onSubmit = (values) => {
1961
+ const { container, hidden, desktop, mobile } = values;
1962
+ const dirtyFields = form.formState.dirtyFields;
1963
+ const desktopPatch = Object.entries(desktop).reduce(
1964
+ (acc, [key, value]) => ({
1965
+ ...acc,
1966
+ ...value && { [key]: value }
1967
+ }),
1968
+ { ...item.styles?.desktop }
1969
+ );
1970
+ const mobilePatch = Object.entries(mobile).reduce(
1971
+ (acc, [key, value]) => {
1972
+ const desktopValue = desktop[key];
1973
+ const isDirty = dirtyFields.desktop?.[key];
1974
+ if (value === desktopValue || isDirty) {
1975
+ return acc;
1976
+ }
1977
+ if (["padding", "margin"].includes(key)) {
1978
+ if (value === "0px" && desktopValue === "0px") {
1979
+ return acc;
1980
+ }
1981
+ }
1982
+ return {
1983
+ ...acc,
1984
+ ...value && { [key]: value }
1985
+ };
1986
+ },
1987
+ { ...item.styles?.mobile }
1988
+ );
1989
+ patchItem(item.id, {
1990
+ styles: {
1991
+ ...container === false && { container },
1992
+ ...hidden !== "never" && { hidden },
1993
+ ...Object.keys(desktopPatch).length && { desktop: desktopPatch },
1994
+ ...Object.keys(mobilePatch).length && { mobile: mobilePatch }
1995
+ }
1996
+ });
1997
+ };
1998
+ const [device, setDevice] = React25.useState("desktop");
1999
+ React25.useEffect(() => {
2000
+ const subscription = form.watch(() => form.handleSubmit(onSubmit)());
2001
+ return () => subscription.unsubscribe();
2002
+ }, [form.watch, form.handleSubmit]);
2003
+ return /* @__PURE__ */ React25.createElement(Form, { ...form }, /* @__PURE__ */ React25.createElement("form", { onSubmit: form.handleSubmit(onSubmit) }, /* @__PURE__ */ React25.createElement("div", { className: "sb-space-y-4 sb-p-4" }, /* @__PURE__ */ React25.createElement(
2004
+ Tabs,
2005
+ {
2006
+ defaultValue: device,
2007
+ onValueChange: (device2) => setDevice(device2)
2008
+ },
2009
+ /* @__PURE__ */ React25.createElement(TabsList, { className: "sb-h-9 sb-grid sb-w-full sb-grid-cols-2" }, /* @__PURE__ */ React25.createElement(TabsTrigger, { value: "desktop", className: "sb-text-xs" }, /* @__PURE__ */ React25.createElement(MonitorIcon, { className: "sb-h-4 sb-w-4 sb-mr-2" }), /* @__PURE__ */ React25.createElement("span", null, "Desktop")), /* @__PURE__ */ React25.createElement(TabsTrigger, { value: "mobile", className: "sb-text-xs" }, /* @__PURE__ */ React25.createElement(SmartphoneIcon, { className: "sb-h-4 sb-w-4 sb-mr-2" }), /* @__PURE__ */ React25.createElement("span", null, "Mobiel")))
2010
+ ), /* @__PURE__ */ React25.createElement("div", { className: "sb-space-y-4" }, /* @__PURE__ */ React25.createElement(
2011
+ FormField,
2012
+ {
2013
+ control: form.control,
2014
+ key: `${device}.background`,
2015
+ name: `${device}.background`,
2016
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, null, /* @__PURE__ */ React25.createElement(FormLabel, null, "Achtergrond"), /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(
2017
+ BackgroundPicker,
2018
+ {
2019
+ background: field.value,
2020
+ onBackgroundChange: field.onChange
2021
+ }
2022
+ )), /* @__PURE__ */ React25.createElement(FormMessage, null))
2023
+ }
2024
+ ), /* @__PURE__ */ React25.createElement(
2025
+ FormField,
2026
+ {
2027
+ control: form.control,
2028
+ key: `${device}.color`,
2029
+ name: `${device}.color`,
2030
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, null, /* @__PURE__ */ React25.createElement(FormLabel, null, "Inhoud kleur"), /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(
2031
+ ColorPicker,
2032
+ {
2033
+ color: field.value,
2034
+ onColorChange: field.onChange
2035
+ }
2036
+ )), /* @__PURE__ */ React25.createElement(FormMessage, null))
2037
+ }
2038
+ ), /* @__PURE__ */ React25.createElement("hr", null), /* @__PURE__ */ React25.createElement(
2039
+ FormField,
2040
+ {
2041
+ control: form.control,
2042
+ name: "hidden",
2043
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, null, /* @__PURE__ */ React25.createElement(FormLabel, null, "Verbergen"), /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(Select, { value: field.value, onValueChange: field.onChange }, /* @__PURE__ */ React25.createElement(SelectTrigger, null, /* @__PURE__ */ React25.createElement(SelectValue, null)), /* @__PURE__ */ React25.createElement(SelectContent, null, /* @__PURE__ */ React25.createElement(SelectItem, { value: "never" }, "Nooit"), /* @__PURE__ */ React25.createElement(SelectItem, { value: "desktop" }, "Op desktop"), /* @__PURE__ */ React25.createElement(SelectItem, { value: "mobile" }, "Op mobiel"), /* @__PURE__ */ React25.createElement(SelectItem, { value: "always" }, "Altijd")))), /* @__PURE__ */ React25.createElement(FormMessage, null))
2044
+ }
2045
+ ), /* @__PURE__ */ React25.createElement("hr", null), /* @__PURE__ */ React25.createElement(
2046
+ FormField,
2047
+ {
2048
+ control: form.control,
2049
+ name: "container",
2050
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, { className: "sb-flex sb-flex-row sb-items-center sb-justify-between sb-space-y-0" }, /* @__PURE__ */ React25.createElement(FormLabel, null, "Volledige breedte"), /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(
2051
+ Switch,
2052
+ {
2053
+ checked: !field.value,
2054
+ onCheckedChange: (v) => field.onChange(!v)
2055
+ }
2056
+ )), /* @__PURE__ */ React25.createElement(FormMessage, null))
2057
+ }
2058
+ ), /* @__PURE__ */ React25.createElement("hr", null), /* @__PURE__ */ React25.createElement(
2059
+ FormField,
2060
+ {
2061
+ control: form.control,
2062
+ key: `${device}.padding`,
2063
+ name: `${device}.padding`,
2064
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, null, /* @__PURE__ */ React25.createElement(FormLabel, null, "Padding"), /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(
2065
+ SpacingInput,
2066
+ {
2067
+ value: field.value,
2068
+ onChange: field.onChange
2069
+ }
2070
+ )), /* @__PURE__ */ React25.createElement(FormMessage, null))
2071
+ }
2072
+ ), /* @__PURE__ */ React25.createElement(
2073
+ FormField,
2074
+ {
2075
+ control: form.control,
2076
+ key: `${device}.margin`,
2077
+ name: `${device}.margin`,
2078
+ render: ({ field }) => /* @__PURE__ */ React25.createElement(FormItem, null, /* @__PURE__ */ React25.createElement(FormLabel, null, "Margin"), /* @__PURE__ */ React25.createElement(FormControl, null, /* @__PURE__ */ React25.createElement(
2079
+ SpacingInput,
2080
+ {
2081
+ value: field.value,
2082
+ onChange: field.onChange
2083
+ }
2084
+ )), /* @__PURE__ */ React25.createElement(FormMessage, null))
2085
+ }
2086
+ )))));
2087
+ };
2088
+ var ScrollArea = React25.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React25.createElement(
2089
+ ScrollAreaPrimitive.Root,
2090
+ {
2091
+ ref,
2092
+ className: cn("sb-relative sb-overflow-hidden", className),
2093
+ ...props
2094
+ },
2095
+ /* @__PURE__ */ React25.createElement(ScrollAreaPrimitive.Viewport, { className: "sb-h-full sb-max-h-[80vh] sb-w-full sb-rounded-[inherit]" }, children),
2096
+ /* @__PURE__ */ React25.createElement(ScrollBar, null),
2097
+ /* @__PURE__ */ React25.createElement(ScrollAreaPrimitive.Corner, null)
2098
+ ));
2099
+ ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
2100
+ var ScrollBar = React25.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ React25.createElement(
2101
+ ScrollAreaPrimitive.ScrollAreaScrollbar,
2102
+ {
2103
+ ref,
2104
+ orientation,
2105
+ className: cn(
2106
+ "sb-flex sb-touch-none sb-select-none sb-transition-colors",
2107
+ orientation === "vertical" && "sb-h-full sb-w-2.5 sb-border-l sb-border-l-transparent sb-p-[1px]",
2108
+ orientation === "horizontal" && "sb-h-2.5 sb-flex-col sb-border-t sb-border-t-transparent sb-p-[1px]",
2109
+ className
2110
+ ),
2111
+ ...props
2112
+ },
2113
+ /* @__PURE__ */ React25.createElement(ScrollAreaPrimitive.ScrollAreaThumb, { className: "sb-relative sb-flex-1 sb-rounded-full sb-bg-border" })
2114
+ ));
2115
+ ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
2116
+
2117
+ // src/components/container-item-toolbar.tsx
2118
+ var ContainerItemToolbar = (props) => {
2119
+ const { contentId, canBringUp = false, canBringDown = false } = props;
2120
+ const { bringUp, bringDown } = useBuilder();
2121
+ return /* @__PURE__ */ React25.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__ */ React25.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__ */ React25.createElement(EditButton, { id: contentId }), /* @__PURE__ */ React25.createElement(
2122
+ Button,
2123
+ {
2124
+ variant: "ghost",
2125
+ className: "sb-w-8 sb-h-8 sb-p-0",
2126
+ onClick: () => bringUp(contentId),
2127
+ disabled: !canBringUp
2128
+ },
2129
+ /* @__PURE__ */ React25.createElement(ArrowUp, { className: "sb-h-5 sb-w-5" })
2130
+ ), /* @__PURE__ */ React25.createElement(
2131
+ Button,
2132
+ {
2133
+ variant: "ghost",
2134
+ className: "sb-w-8 sb-h-8 sb-p-0",
2135
+ onClick: () => bringDown(contentId),
2136
+ disabled: !canBringDown
2137
+ },
2138
+ /* @__PURE__ */ React25.createElement(ArrowDown, { className: "sb-h-5 sb-w-5" })
2139
+ ), /* @__PURE__ */ React25.createElement(DeleteButton, { contentId })));
2140
+ };
2141
+ var EditButton = ({ id }) => {
2142
+ return /* @__PURE__ */ React25.createElement(Popover, { modal: true }, /* @__PURE__ */ React25.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React25.createElement(Button, { variant: "ghost", className: "sb-w-8 sb-h-8 sb-p-0" }, /* @__PURE__ */ React25.createElement(Edit2Icon, { className: "sb-h-5 sb-w-5" }))), /* @__PURE__ */ React25.createElement(
2143
+ PopoverContent,
2144
+ {
2145
+ side: "left",
2146
+ align: "start",
2147
+ sideOffset: 16,
2148
+ alignOffset: -8,
2149
+ className: "sb-p-0 sb-relative",
2150
+ collisionPadding: 16
2151
+ },
2152
+ /* @__PURE__ */ React25.createElement(EditPopoverInner, { id })
2153
+ ));
2154
+ };
2155
+ var EditPopoverInner = (props) => {
2156
+ const { id } = props;
2157
+ const { getItem } = useBuilder();
2158
+ const item = getItem(id);
2159
+ if (!item) {
2160
+ throw new Error(
2161
+ `[simple-builder]: Item with id ${id} not found in container item form component`
2162
+ );
2163
+ }
2164
+ return /* @__PURE__ */ React25.createElement(Tabs, null, /* @__PURE__ */ React25.createElement(TabsList, { variant: "text", defaultValue: "content" }, /* @__PURE__ */ React25.createElement(TabsTrigger, { variant: "text", value: "content" }, "Inhoud"), /* @__PURE__ */ React25.createElement(TabsTrigger, { variant: "text", value: "design" }, "Design")), /* @__PURE__ */ React25.createElement(TabsContent, { value: "content" }, /* @__PURE__ */ React25.createElement(ScrollArea, null, /* @__PURE__ */ React25.createElement(ContainerItemForm, { item }))), /* @__PURE__ */ React25.createElement(TabsContent, { value: "design" }, /* @__PURE__ */ React25.createElement(ItemDesignForm, { item })));
2165
+ };
2166
+ var DeleteButton = ({ contentId }) => {
2167
+ const { deleteContent } = useBuilder();
2168
+ return /* @__PURE__ */ React25.createElement(AlertDialog, null, /* @__PURE__ */ React25.createElement(AlertDialogTrigger, { asChild: true }, /* @__PURE__ */ React25.createElement(
2169
+ Button,
2170
+ {
2171
+ variant: "ghost",
2172
+ className: "sb-w-8 sb-h-8 sb-p-0 sb-text-destructive"
2173
+ },
2174
+ /* @__PURE__ */ React25.createElement(Trash2Icon, { className: "sb-h-5 sb-w-5" })
2175
+ )), /* @__PURE__ */ React25.createElement(AlertDialogContent, null, /* @__PURE__ */ React25.createElement(AlertDialogDescription, null, "Weet je zeker dat je dit blok wilt verwijderen?"), /* @__PURE__ */ React25.createElement(AlertDialogFooter, null, /* @__PURE__ */ React25.createElement(AlertDialogCancel, null, "Annuleren"), /* @__PURE__ */ React25.createElement(
2176
+ AlertDialogAction,
2177
+ {
2178
+ className: buttonVariants({ variant: "destructive" }),
2179
+ onClick: () => deleteContent(contentId)
2180
+ },
2181
+ "Verwijderen"
2182
+ ))));
2183
+ };
2184
+
2185
+ // src/components/build-container-client.tsx
2186
+ var BuildContainerInner = (props) => {
2187
+ const { id, name, content, multiple = false } = props;
2188
+ const items = Array.isArray(content) ? content : content?.[name] || [];
2189
+ if (!multiple && items.length > 1) {
2190
+ console.error(
2191
+ "[simple-builder]: Multiple content blocks detected when using property multiple false."
2192
+ );
2193
+ }
2194
+ return /* @__PURE__ */ React25.createElement("div", null, items.length <= 0 ? /* @__PURE__ */ React25.createElement(AddContentPlaceholder, { parent: id, container: name, index: 0 }) : multiple && /* @__PURE__ */ React25.createElement(AddContentDividerButton, { parent: id, container: name, index: 0 }), items.map((item, i) => /* @__PURE__ */ React25.createElement(React25.Fragment, { key: item.id }, /* @__PURE__ */ React25.createElement("div", { className: "sb-relative sb-container-item" }, /* @__PURE__ */ React25.createElement(DesignWrapper, { building: true, styles: item.styles }, builder.bindComponent(item, true)), /* @__PURE__ */ React25.createElement(
2195
+ ContainerItemToolbar,
2196
+ {
2197
+ contentId: item.id,
2198
+ canBringUp: i > 0,
2199
+ canBringDown: i < items.length - 1
2200
+ }
2201
+ )), multiple && /* @__PURE__ */ React25.createElement(
2202
+ AddContentDividerButton,
2203
+ {
2204
+ parent: id,
2205
+ container: name,
2206
+ index: i + 1
2207
+ }
2208
+ ))));
2209
+ };
2210
+ var build_container_client_default = BuildContainerInner;
2211
+ var AddContentButton = (props) => {
2212
+ const components = builder.getComponents();
2213
+ const { addContent } = useBuilder();
2214
+ return /* @__PURE__ */ React25.createElement(Popover, null, /* @__PURE__ */ React25.createElement(PopoverTrigger, { asChild: true }, props.children), /* @__PURE__ */ React25.createElement(PopoverContent, { className: "sb-p-1" }, /* @__PURE__ */ React25.createElement("div", { className: "sb-grid sb-grid-cols-2 sb-gap-2" }, components.map((component) => {
2215
+ const Icon2 = component.icon ?? ImageIcon;
2216
+ return /* @__PURE__ */ React25.createElement(PopoverClose, { key: component.name, asChild: true }, /* @__PURE__ */ React25.createElement(
2217
+ Button,
2218
+ {
2219
+ variant: "ghost",
2220
+ className: "sb-justify-start",
2221
+ onClick: () => {
2222
+ addContent(
2223
+ component.name,
2224
+ props.container,
2225
+ props.parent,
2226
+ props.index
2227
+ );
2228
+ }
2229
+ },
2230
+ /* @__PURE__ */ React25.createElement(Icon2, { className: "sb-mr-2 sb-h-4 sb-w-4 sb-shrink-0" }),
2231
+ component.friendlyName ?? component.name
2232
+ ));
2233
+ }))));
2234
+ };
2235
+ var AddContentPlaceholder = (props) => {
2236
+ return /* @__PURE__ */ React25.createElement(AddContentButton, { ...props }, /* @__PURE__ */ React25.createElement("div", { className: "sb-flex sb-justify-center sb-bg-primary/50 p-4" }, /* @__PURE__ */ React25.createElement(Button, { size: "sm" }, /* @__PURE__ */ React25.createElement(PlusIcon, { className: "sb-mr-2 sb-h-4 sb-w-4" }), "Blok Toevoegen")));
2237
+ };
2238
+ var AddContentDividerButton = (props) => {
2239
+ return /* @__PURE__ */ React25.createElement(AddContentButton, { ...props }, /* @__PURE__ */ React25.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__ */ React25.createElement(
2240
+ Button,
2241
+ {
2242
+ size: "sm",
2243
+ className: "sb-absolute sb-left-1/2 sb-top-1/2 sb--translate-y-1/2 sb--translate-x-1/2 sb-shadow"
2244
+ },
2245
+ /* @__PURE__ */ React25.createElement(PlusIcon, { className: "sb-mr-2 sb-h-4 sb-w-4" }),
2246
+ "Blok Toevoegen"
2247
+ )));
2248
+ };
2249
+
2250
+ export { build_container_client_default as default };